Changeset 8a90001 for protocols/jabber
- Timestamp:
- 2008-07-22T12:37:49Z (16 years ago)
- Branches:
- master
- Children:
- 4ac647d
- Parents:
- 9afeefa
- Location:
- protocols/jabber
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
r9afeefa r8a90001 62 62 s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc ); 63 63 s->flags |= ACC_SET_OFFLINE_ONLY; 64 65 s = set_add( &acc->set, "proxy", "<local>;<auto>", NULL, acc ); 64 66 } 65 67 -
protocols/jabber/s5bytestream.c
r9afeefa r8a90001 362 362 tf->ft->free = jabber_bs_free_transfer; 363 363 364 jabber_bs_recv_handshake( bt, 0, 0 );364 jabber_bs_recv_handshake( bt, -1, 0 ); 365 365 366 366 return XT_HANDLED; … … 381 381 int gret; 382 382 383 if ( ( fd != 0) && !jabber_bs_poll( bt, fd, &revents ) )383 if ( ( fd != -1 ) && !jabber_bs_poll( bt, fd, &revents ) ) 384 384 return FALSE; 385 385 … … 554 554 { 555 555 bt->sh = shlist->next->data; 556 return jabber_bs_recv_handshake( bt, 0, 0 );556 return jabber_bs_recv_handshake( bt, -1, 0 ); 557 557 } 558 558 … … 620 620 struct jabber_transfer *tf = bt->tf; 621 621 622 if( fd != 0) /* called via event thread */622 if( fd != -1 ) /* called via event thread */ 623 623 { 624 624 tf->watch_in = 0; … … 666 666 } 667 667 668 jabber_bs_recv_read( tf->streamhandle, 0, 0 );668 jabber_bs_recv_read( tf->streamhandle, -1 , 0 ); 669 669 670 670 return TRUE; … … 776 776 /* using a proxy, abort listen */ 777 777 778 if 778 if( tf->watch_in ) 779 779 { 780 780 b_event_remove( tf->watch_in ); … … 782 782 } 783 783 784 closesocket( tf->fd ); 785 tf->fd = 0; 784 if( tf->fd != -1 ) { 785 closesocket( tf->fd ); 786 tf->fd = -1; 787 } 786 788 787 789 if ( bt->connect_timeout ) … … 798 800 { 799 801 bt->sh = sh; 800 jabber_bs_recv_handshake( bt, 0, 0 );802 jabber_bs_recv_handshake( bt, -1, 0 ); 801 803 return XT_HANDLED; 802 804 } … … 872 874 } 873 875 876 jabber_streamhost_t *jabber_si_parse_proxy( struct im_connection *ic, char *proxy ) 877 { 878 char *host, *port, *jid; 879 jabber_streamhost_t *sh; 880 881 if( ( ( host = strchr( proxy, ',' ) ) == 0 ) || 882 ( ( port = strchr( host+1, ',' ) ) == 0 ) ) { 883 imcb_log( ic, "Error parsing proxy setting: \"%s\" (ignored)", proxy ); 884 return NULL; 885 } 886 887 jid = proxy; 888 *host++ = '\0'; 889 *port++ = '\0'; 890 891 sh = g_new0( jabber_streamhost_t, 1 ); 892 sh->jid = g_strdup( jid ); 893 sh->host = g_strdup( host ); 894 strcpy( sh->port, port ); 895 896 return sh; 897 } 898 899 void jabber_si_set_proxies( struct bs_transfer *bt ) 900 { 901 struct jabber_transfer *tf = bt->tf; 902 struct jabber_data *jd = tf->ic->proto_data; 903 char *proxysetting = g_strdup ( set_getstr( &tf->ic->acc->set, "proxy" ) ); 904 char *proxy,*next; 905 char port[6]; 906 char host[INET6_ADDRSTRLEN]; 907 jabber_streamhost_t *sh, *sh2; 908 GSList *streamhosts = jd->streamhosts; 909 910 proxy = proxysetting; 911 while ( proxy && ( *proxy!='\0' ) ) { 912 if( ( next = strchr( proxy, ';' ) ) ) 913 *next++ = '\0'; 914 915 if( ( strcmp( proxy, "<local>" ) == 0 ) && jabber_bs_send_listen( bt, &tf->saddr, host, port ) ) { 916 sh = g_new0( jabber_streamhost_t, 1 ); 917 sh->jid = g_strdup( tf->ini_jid ); 918 sh->host = g_strdup( host ); 919 strcpy( sh->port, port ); 920 bt->streamhosts = g_slist_append( bt->streamhosts, sh ); 921 922 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt ); 923 bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 924 } else if( strcmp( proxy, "<auto>" ) == 0 ) { 925 while ( streamhosts ) { 926 sh = g_new0( jabber_streamhost_t, 1 ); 927 sh2 = streamhosts->data; 928 sh->jid = g_strdup( sh2->jid ); 929 sh->host = g_strdup( sh2->host ); 930 strcpy( sh->port, sh2->port ); 931 bt->streamhosts = g_slist_append( bt->streamhosts, sh ); 932 streamhosts = g_slist_next( streamhosts ); 933 } 934 } else if( ( sh = jabber_si_parse_proxy( tf->ic, proxy ) ) ) 935 bt->streamhosts = g_slist_append( bt->streamhosts, sh ); 936 proxy = next; 937 } 938 } 939 874 940 /* 875 941 * Starts a bytestream. … … 877 943 gboolean jabber_bs_send_start( struct jabber_transfer *tf ) 878 944 { 879 char host[INET6_ADDRSTRLEN];880 945 struct bs_transfer *bt; 881 946 sha1_state_t sha; … … 883 948 unsigned char hash[20]; 884 949 int i,ret; 885 struct jabber_data *jd = tf->ic->proto_data;886 jabber_streamhost_t sh;887 GSList *streamhosts = jd->streamhosts;888 950 889 951 /* SHA1( SID + Initiator JID + Target JID ) is given to the streamhost which it will match against the initiator's value */ … … 905 967 tf->ft->canceled = jabber_bs_canceled; 906 968 907 if ( !jabber_bs_send_listen( bt, &tf->saddr, sh.host = host, sh.port ) ) 908 return FALSE; 909 910 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt ); 911 bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 912 913 sh.jid = tf->ini_jid; 914 915 /* temporarily add listen address to streamhosts, send the request and remove it */ 916 streamhosts = g_slist_prepend( streamhosts, &sh ); 917 ret = jabber_bs_send_request( tf, streamhosts); 918 streamhosts = g_slist_remove( streamhosts, &sh ); 969 jabber_si_set_proxies( bt ); 970 971 ret = jabber_bs_send_request( tf, bt->streamhosts); 919 972 920 973 return ret; -
protocols/jabber/si.c
r9afeefa r8a90001 39 39 jd->filetransfers = g_slist_remove( jd->filetransfers, tf ); 40 40 41 if( tf->fd )41 if( tf->fd != -1 ) 42 42 { 43 43 close( tf->fd ); 44 tf->fd = 0;44 tf->fd = -1; 45 45 } 46 46 … … 129 129 130 130 if( tf->bud->features && jd->have_streamhosts==1 ) { 131 tf->disco_timeout = 0; 131 132 jabber_si_transfer_start( tf ); 132 tf->disco_timeout = 0;133 133 return FALSE; 134 134 } … … 139 139 140 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" );141 imcb_log( tf->ic, "Couldn't get buddy's features nor discover all services of the server" ); 142 142 else if( !tf->bud->features ) 143 imcb_ file_canceled( tf->ft, "Couldn't get buddy's features" );143 imcb_log( tf->ic, "Couldn't get buddy's features" ); 144 144 else 145 imcb_ file_canceled( tf->ft, "Couldn't get server's features" );145 imcb_log( tf->ic, "Couldn't discover some of the server's services" ); 146 146 147 147 tf->disco_timeout = 0; 148 jabber_si_transfer_start( tf ); 148 149 return FALSE; 149 150 } … … 173 174 tf->ic = ic; 174 175 tf->ft = ft; 176 tf->fd = -1; 175 177 tf->ft->data = tf; 176 178 tf->ft->free = jabber_si_free_transfer; … … 186 188 jabber_iq_query_features( ic, bud->full_jid ); 187 189 188 if( jd->have_streamhosts!=1 ) { 190 /* If <auto> is not set don't check for proxies */ 191 if( ( jd->have_streamhosts!=1 ) && ( jd->streamhosts==NULL ) && 192 ( strstr( set_getstr( &ic->acc->set, "proxy" ), "<auto>" ) != NULL ) ) { 189 193 jd->have_streamhosts = 0; 190 194 jabber_iq_query_server( ic, server, XMLNS_DISCO_ITEMS ); 191 } 195 } else if ( jd->streamhosts!=NULL ) 196 jd->have_streamhosts = 1; 192 197 193 198 /* if we had to do a query, wait for the result. … … 309 314 tf->ic = ic; 310 315 tf->ft = ft; 316 tf->fd = -1; 311 317 tf->ft->data = tf; 312 318 tf->ft->accept = jabber_si_answer_request;
Note: See TracChangeset
for help on using the changeset viewer.