- Timestamp:
- 2008-05-10T10:09:19Z (17 years ago)
- Branches:
- master
- Children:
- cce0450
- Parents:
- b043ad5
- Location:
- protocols/jabber
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.h
rb043ad5 rb5cfc2b 154 154 gpointer streamhandle; 155 155 156 /* timeout for discover queries */ 157 gint disco_timeout; 158 gint disco_timeout_fired; 159 156 160 struct im_connection *ic; 161 162 struct jabber_buddy *bud; 157 163 158 164 int watch_in; -
protocols/jabber/si.c
rb043ad5 rb5cfc2b 45 45 } 46 46 47 if( tf->disco_timeout ) 48 b_event_remove( tf->disco_timeout ); 49 47 50 g_free( tf->ini_jid ); 48 51 g_free( tf->tgt_jid ); … … 80 83 } 81 84 85 int jabber_si_check_features( struct jabber_transfer *tf, GSList *features ) { 86 int foundft = FALSE, foundbt = FALSE, foundsi = FALSE; 87 88 while ( features ) 89 { 90 if( !strcmp( features->data, XMLNS_FILETRANSFER ) ) 91 foundft = TRUE; 92 if( !strcmp( features->data, XMLNS_BYTESTREAMS ) ) 93 foundbt = TRUE; 94 if( !strcmp( features->data, XMLNS_SI ) ) 95 foundsi = TRUE; 96 97 features = g_slist_next(features); 98 } 99 100 if( !foundft ) 101 imcb_file_canceled( tf->ft, "Buddy's client doesn't feature file transfers" ); 102 else if( !foundbt ) 103 imcb_file_canceled( tf->ft, "Buddy's client doesn't feature byte streams (required)" ); 104 else if( !foundsi ) 105 imcb_file_canceled( tf->ft, "Buddy's client doesn't feature stream initiation (required)" ); 106 107 return foundft && foundbt && foundsi; 108 } 109 110 void jabber_si_transfer_start( struct jabber_transfer *tf ) { 111 112 if( !jabber_si_check_features( tf, tf->bud->features ) ) 113 return; 114 115 /* send the request to our buddy */ 116 jabber_si_send_request( tf->ic, tf->bud->full_jid, tf ); 117 118 /* and start the receive logic */ 119 imcb_file_recv_start( tf->ft ); 120 121 } 122 123 gboolean jabber_si_waitfor_disco( gpointer data, gint fd, b_input_condition cond ) 124 { 125 struct jabber_transfer *tf = data; 126 struct jabber_data *jd = tf->ic->proto_data; 127 128 tf->disco_timeout_fired++; 129 130 if( tf->bud->features && jd->have_streamhosts==1 ) { 131 jabber_si_transfer_start( tf ); 132 tf->disco_timeout = 0; 133 return FALSE; 134 } 135 136 /* 8 seconds should be enough for server and buddy to respond */ 137 if ( tf->disco_timeout_fired < 16 ) 138 return TRUE; 139 140 if( !tf->bud->features && jd->have_streamhosts!=1 ) 141 imcb_file_canceled( tf->ft, "Couldn't get buddy's features or the server's" ); 142 else if( !tf->bud->features ) 143 imcb_file_canceled( tf->ft, "Couldn't get buddy's features" ); 144 else 145 imcb_file_canceled( tf->ft, "Couldn't get server's features" ); 146 147 tf->disco_timeout = 0; 148 return FALSE; 149 } 150 82 151 void jabber_si_transfer_request( struct im_connection *ic, file_transfer_t *ft, char *who ) 83 152 { 84 153 struct jabber_transfer *tf; 85 154 struct jabber_data *jd = ic->proto_data; 86 char *server = jd->server; 87 155 struct jabber_buddy *bud; 156 char *server = jd->server, *s; 157 158 if( ( s = strchr( who, '=' ) ) && jabber_chat_by_jid( ic, s + 1 ) ) 159 bud = jabber_buddy_by_ext_jid( ic, who, 0 ); 160 else 161 bud = jabber_buddy_by_jid( ic, who, 0 ); 162 163 if( bud == NULL ) 164 { 165 imcb_file_canceled( tf->ft, "Couldn't find buddy (BUG?)" ); 166 return; 167 } 168 88 169 imcb_log( ic, "Trying to send %s(%zd bytes) to %s", ft->file_name, ft->file_size, who ); 89 170 … … 95 176 tf->ft->free = jabber_si_free_transfer; 96 177 tf->ft->finished = jabber_si_finished; 178 tf->bud = bud; 97 179 ft->write = jabber_bs_send_write; 98 180 99 181 jd->filetransfers = g_slist_prepend( jd->filetransfers, tf ); 100 182 101 /* query the buddy's features */ 102 jabber_iq_query_features( ic, who ); 103 104 /* query proxies from the server */ 105 if( !jd->have_streamhosts ) 183 /* query buddy's features and server's streaming proxies if neccessary */ 184 185 if( !tf->bud->features ) 186 jabber_iq_query_features( ic, bud->full_jid ); 187 188 if( jd->have_streamhosts!=1 ) { 189 jd->have_streamhosts = 0; 106 190 jabber_iq_query_server( ic, server, XMLNS_DISCO_ITEMS ); 107 108 /* send the request to our buddy */ 109 jabber_si_send_request( ic, who, tf ); 110 111 /* and start the receive logic */ 112 imcb_file_recv_start( ft ); 191 } 192 193 /* if we had to do a query, wait for the result. 194 * Otherwise fire away. */ 195 if( !tf->bud->features || jd->have_streamhosts!=1 ) 196 tf->disco_timeout = b_timeout_add( 500, jabber_si_waitfor_disco, tf ); 197 else 198 jabber_si_transfer_start( tf ); 113 199 } 114 200
Note: See TracChangeset
for help on using the changeset viewer.