- Timestamp:
- 2007-12-19T00:24:32Z (17 years ago)
- Branches:
- master
- Children:
- 1ba7e8f
- Parents:
- 793cc25 (diff), 2379566 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- protocols
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/conference.c
r793cc25 r0fbd3a6d 174 174 175 175 return 1; 176 } 177 178 void jabber_chat_invite( struct groupchat *c, char *who, char *message ) 179 { 180 struct xt_node *node; 181 struct im_connection *ic = c->ic; 182 struct jabber_chat *jc = c->data; 183 184 node = xt_new_node( "reason", message, NULL ); 185 186 node = xt_new_node( "invite", NULL, node ); 187 xt_add_attr( node, "to", who ); 188 189 node = xt_new_node( "x", NULL, node ); 190 xt_add_attr( node, "xmlns", XMLNS_MUC_USER ); 191 192 node = jabber_make_packet( "message", NULL, jc->name, node ); 193 194 jabber_write_packet( ic, node ); 195 196 xt_free_node( node ); 176 197 } 177 198 -
protocols/jabber/io.c
r793cc25 r0fbd3a6d 120 120 return TRUE; 121 121 } 122 else if( st == 0 || ( st < 0 && !s ockerr_again() ) )122 else if( st == 0 || ( st < 0 && !ssl_sockerr_again( jd->ssl ) ) ) 123 123 { 124 124 /* Set fd to -1 to make sure we won't write to it anymore. */ … … 231 231 } 232 232 } 233 else if( st == 0 || ( st < 0 && !s ockerr_again() ) )233 else if( st == 0 || ( st < 0 && !ssl_sockerr_again( jd->ssl ) ) ) 234 234 { 235 235 closesocket( jd->fd ); -
protocols/jabber/iq.c
r793cc25 r0fbd3a6d 50 50 else if( strcmp( type, "get" ) == 0 ) 51 51 { 52 if( !( c = xt_find_node( node->children, "query" ) ) || 52 if( !( ( c = xt_find_node( node->children, "query" ) ) || 53 ( c = xt_find_node( node->children, "ping" ) ) ) || /* O_o WHAT is wrong with just <query/> ????? */ 53 54 !( s = xt_find_attr( c, "xmlns" ) ) ) 54 55 { … … 81 82 xt_add_child( reply, xt_new_node( "tz", buf, NULL ) ); 82 83 } 83 else if( strcmp( s, XMLNS_DISCOVER ) == 0 ) 84 else if( strcmp( s, XMLNS_PING ) == 0 ) 85 { 86 xt_free_node( reply ); 87 reply = jabber_make_packet( "iq", "result", xt_find_attr( node, "from" ), NULL ); 88 if( ( s = xt_find_attr( node, "id" ) ) ) 89 xt_add_attr( reply, "id", s ); 90 pack = 0; 91 } 92 else if( strcmp( s, XMLNS_DISCO_INFO ) == 0 ) 84 93 { 85 94 const char *features[] = { XMLNS_VERSION, … … 87 96 XMLNS_CHATSTATES, 88 97 XMLNS_MUC, 98 XMLNS_PING, 89 99 XMLNS_SI, 90 100 XMLNS_BYTESTREAMS, … … 565 575 return st; 566 576 } 577 578 xt_status jabber_iq_parse_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 579 580 xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid ) 581 { 582 struct xt_node *node, *query; 583 struct jabber_buddy *bud; 584 585 if( ( bud = jabber_buddy_by_jid( ic, bare_jid , 0 ) ) == NULL ) 586 { 587 /* Who cares about the unknown... */ 588 imcb_log( ic, "Couldnt find the man: %s", bare_jid); 589 return 0; 590 } 591 592 if( bud->features ) /* been here already */ 593 return XT_HANDLED; 594 595 node = xt_new_node( "query", NULL, NULL ); 596 xt_add_attr( node, "xmlns", XMLNS_DISCO_INFO ); 597 598 if( !( query = jabber_make_packet( "iq", "get", bare_jid, node ) ) ) 599 { 600 imcb_log( ic, "WARNING: Couldn't generate feature query" ); 601 xt_free_node( node ); 602 } 603 604 jabber_cache_add( ic, query, jabber_iq_parse_features ); 605 606 return jabber_write_packet( ic, query ); 607 } 608 609 xt_status jabber_iq_parse_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 610 { 611 struct xt_node *c; 612 struct jabber_buddy *bud; 613 char *feature; 614 615 if( !( c = xt_find_node( node->children, "query" ) ) || 616 !( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_INFO ) == 0 ) ) 617 { 618 imcb_log( ic, "WARNING: Received incomplete IQ-result packet for discover" ); 619 return XT_HANDLED; 620 } 621 if( ( bud = jabber_buddy_by_jid( ic, xt_find_attr( node, "from") , 0 ) ) == NULL ) 622 { 623 /* Who cares about the unknown... */ 624 imcb_log( ic, "Couldnt find the man: %s", xt_find_attr( node, "from")); 625 return 0; 626 } 627 628 c = c->children; 629 while( ( c = xt_find_node( c, "feature" ) ) ) { 630 feature = xt_find_attr( c, "var" ); 631 bud->features = g_slist_append(bud->features, g_strdup(feature) ); 632 c = c->next; 633 } 634 635 return XT_HANDLED; 636 } 637 638 xt_status jabber_iq_parse_server_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 639 640 xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns ) 641 { 642 struct xt_node *node, *query; 643 struct jabber_data *jd = ic->proto_data; 644 645 node = xt_new_node( "query", NULL, NULL ); 646 xt_add_attr( node, "xmlns", xmlns ); 647 648 if( !( query = jabber_make_packet( "iq", "get", jid, node ) ) ) 649 { 650 imcb_log( ic, "WARNING: Couldn't generate server query" ); 651 xt_free_node( node ); 652 } 653 654 jd->have_streamhosts--; 655 jabber_cache_add( ic, query, jabber_iq_parse_server_features ); 656 657 return jabber_write_packet( ic, query ); 658 } 659 660 /* 661 * Query the server for "items", query each "item" for identities, query each "item" that's a proxy for it's bytestream info 662 */ 663 xt_status jabber_iq_parse_server_features( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 664 { 665 struct xt_node *c; 666 struct jabber_data *jd = ic->proto_data; 667 668 if( !( c = xt_find_node( node->children, "query" ) ) || 669 !xt_find_attr( node, "from" ) ) 670 { 671 imcb_log( ic, "WARNING: Received incomplete IQ-result packet for discover" ); 672 return XT_HANDLED; 673 } 674 675 jd->have_streamhosts++; 676 677 if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_ITEMS ) == 0 ) 678 { 679 char *item, *itemjid; 680 681 /* answer from server */ 682 683 c = c->children; 684 while( ( c = xt_find_node( c, "item" ) ) ) 685 { 686 item = xt_find_attr( c, "name" ); 687 itemjid = xt_find_attr( c, "jid" ); 688 689 jabber_iq_query_server( ic, itemjid, XMLNS_DISCO_INFO ); 690 691 c = c->next; 692 } 693 } else if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_DISCO_INFO ) == 0 ) 694 { 695 char *category, *type; 696 697 /* answer from potential proxy */ 698 699 c = c->children; 700 while( ( c = xt_find_node( c, "identity" ) ) ) 701 { 702 category = xt_find_attr( c, "category" ); 703 type = xt_find_attr( c, "type" ); 704 705 if( type && ( strcmp( type, "bytestreams" ) == 0 ) && 706 category && ( strcmp( category, "proxy" ) == 0 ) ) 707 jabber_iq_query_server( ic, xt_find_attr( node, "from" ), XMLNS_BYTESTREAMS ); 708 709 c = c->next; 710 } 711 } else if( strcmp( xt_find_attr( c, "xmlns" ), XMLNS_BYTESTREAMS ) == 0 ) 712 { 713 char *host, *jid; 714 int port; 715 716 /* answer from proxy */ 717 718 if( ( c = xt_find_node( c->children, "streamhost" ) ) && 719 ( host = xt_find_attr( c, "host" ) ) && 720 ( port = atoi( xt_find_attr( c, "port" ) ) ) && 721 ( jid = xt_find_attr( c, "jid" ) ) ) 722 { 723 jabber_streamhost_t *sh = g_new0( jabber_streamhost_t, 1 ); 724 sh->jid = g_strdup( jid ); 725 sh->host = g_strdup( host ); 726 sprintf( sh->port, "%u", port ); 727 728 imcb_log( ic, "Proxy found: jid %s host %s port %u", jid, host, port ); 729 jd->streamhosts = g_slist_append( jd->streamhosts, sh ); 730 } 731 } 732 733 if( jd->have_streamhosts == 0 ) 734 jd->have_streamhosts++; 735 return XT_HANDLED; 736 } -
protocols/jabber/jabber.c
r793cc25 r0fbd3a6d 76 76 jd->username = g_strdup( acc->user ); 77 77 jd->server = strchr( jd->username, '@' ); 78 79 jd->fd = jd->r_inpa = jd->w_inpa = -1; 78 80 79 81 if( jd->server == NULL ) … … 232 234 struct jabber_data *jd = ic->proto_data; 233 235 234 jabber_end_stream( ic ); 236 if( jd->fd >= 0 ) 237 jabber_end_stream( ic ); 235 238 236 239 while( ic->groupchats ) … … 250 253 g_free( jd->txq ); 251 254 252 g_hash_table_destroy( jd->node_cache ); 255 if( jd->node_cache ) 256 g_hash_table_destroy( jd->node_cache ); 253 257 254 258 xt_free( jd->xt ); … … 421 425 if( c ) 422 426 jabber_chat_leave( c, NULL ); 427 } 428 429 static void jabber_chat_invite_( struct groupchat *c, char *who, char *msg ) 430 { 431 struct jabber_chat *jc = c->data; 432 gchar *msg_alt = NULL; 433 434 if( msg == NULL ) 435 msg_alt = g_strdup_printf( "%s invited you to %s", c->ic->acc->user, jc->name ); 436 437 if( c && who ) 438 jabber_chat_invite( c, who, msg ? msg : msg_alt ); 439 440 g_free( msg_alt ); 423 441 } 424 442 … … 494 512 ret->chat_msg = jabber_chat_msg_; 495 513 ret->chat_topic = jabber_chat_topic_; 496 // ret->chat_invite = jabber_chat_invite;514 ret->chat_invite = jabber_chat_invite_; 497 515 ret->chat_leave = jabber_chat_leave_; 498 516 ret->chat_join = jabber_chat_join_; -
protocols/jabber/jabber.h
r793cc25 r0fbd3a6d 57 57 } jabber_buddy_flags_t; 58 58 59 /* Stores a streamhost's(a.k.a. proxy) data */ 60 typedef struct 61 { 62 char *jid; 63 char *host; 64 char port[6]; 65 } jabber_streamhost_t; 66 59 67 struct jabber_data 60 68 { … … 83 91 84 92 GSList *filetransfers; 93 GSList *streamhosts; 94 int have_streamhosts; 85 95 }; 86 96 … … 111 121 struct jabber_away_state *away_state; 112 122 char *away_message; 123 GSList *features; 113 124 114 125 time_t last_act; … … 178 189 #define XMLNS_VERSION "jabber:iq:version" /* XEP-0092 */ 179 190 #define XMLNS_TIME "jabber:iq:time" /* XEP-0090 */ 191 #define XMLNS_PING "urn:xmpp:ping" /* XEP-0199 */ 180 192 #define XMLNS_VCARD "vcard-temp" /* XEP-0054 */ 181 193 #define XMLNS_DELAY "jabber:x:delay" /* XEP-0091 */ 182 194 #define XMLNS_XDATA "jabber:x:data" /* XEP-0004 */ 183 195 #define XMLNS_CHATSTATES "http://jabber.org/protocol/chatstates" /* XEP-0085 */ 184 #define XMLNS_DISCOVER "http://jabber.org/protocol/disco#info" /* XEP-0030 */ 196 #define XMLNS_DISCO_INFO "http://jabber.org/protocol/disco#info" /* XEP-0030 */ 197 #define XMLNS_DISCO_ITEMS "http://jabber.org/protocol/disco#items" /* XEP-0030 */ 185 198 #define XMLNS_MUC "http://jabber.org/protocol/muc" /* XEP-0045 */ 186 199 #define XMLNS_MUC_USER "http://jabber.org/protocol/muc#user" /* XEP-0045 */ … … 199 212 int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name ); 200 213 int jabber_remove_from_roster( struct im_connection *ic, char *handle ); 214 xt_status jabber_iq_query_features( struct im_connection *ic, char *bare_jid ); 215 xt_status jabber_iq_query_server( struct im_connection *ic, char *jid, char *xmlns ); 201 216 202 217 /* si.c */ … … 279 294 void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); 280 295 void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); 296 void jabber_chat_invite( struct groupchat *c, char *who, char *message ); 281 297 282 298 #endif -
protocols/jabber/s5bytestream.c
r793cc25 r0fbd3a6d 30 30 struct jabber_transfer *tf; 31 31 32 /* <query> element and <streamhost> elements */33 struct xt_node *qnode, *shnode;32 jabber_streamhost_t *sh; 33 GSList *streamhosts; 34 34 35 35 enum … … 74 74 gboolean jabber_bs_abort( struct bs_transfer *bt, char *format, ... ); 75 75 void jabber_bs_canceled( file_transfer_t *ft , char *reason ); 76 void jabber_bs_free_transfer( file_transfer_t *ft );76 void jabber_bs_free_transfer( file_transfer_t *ft ); 77 77 gboolean jabber_bs_connect_timeout( gpointer data, gint fd, b_input_condition cond ); 78 78 gboolean jabber_bs_poll( struct bs_transfer *bt, int fd, short *revents ); … … 84 84 gboolean jabber_bs_recv_handshake( gpointer data, gint fd, b_input_condition cond ); 85 85 gboolean jabber_bs_recv_handshake_abort( struct bs_transfer *bt, char *error ); 86 int jabber_bs_recv_request( struct im_connection *ic, struct xt_node *node, struct xt_node *qnode );86 int jabber_bs_recv_request( struct im_connection *ic, struct xt_node *node, struct xt_node *qnode ); 87 87 88 88 gboolean jabber_bs_send_handshake_abort( struct bs_transfer *bt, char *error ); 89 gboolean jabber_bs_send_request( struct jabber_transfer *tf, char *host, char *port);89 gboolean jabber_bs_send_request( struct jabber_transfer *tf, GSList *streamhosts ); 90 90 gboolean jabber_bs_send_handshake( gpointer data, gint fd, b_input_condition cond ); 91 91 gboolean jabber_bs_send_listen( struct bs_transfer *bt, struct sockaddr_storage *saddr, char *host, char *port ); 92 static xt_status jabber_bs_send_handle_activate( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 93 void jabber_bs_send_activate( struct bs_transfer *bt ); 92 94 93 95 /* … … 97 99 struct jabber_transfer *tf = ft->data; 98 100 struct bs_transfer *bt = tf->streamhandle; 101 jabber_streamhost_t *sh; 99 102 100 103 if ( tf->watch_in ) … … 105 108 106 109 g_free( bt->pseudoadr ); 107 xt_free_node( bt->qnode ); 110 111 while( bt->streamhosts ) 112 { 113 sh = bt->streamhosts->data; 114 bt->streamhosts = g_slist_remove( bt->streamhosts, sh ); 115 g_free( sh->jid ); 116 g_free( sh->host ); 117 g_free( sh ); 118 } 119 108 120 g_free( bt ); 109 121 … … 111 123 } 112 124 125 /* 126 * Checks if buflen data is available on the socket and 127 * writes it to buffer if that's the case. 128 */ 113 129 gboolean jabber_bs_peek( struct bs_transfer *bt, void *buffer, int buflen ) 114 130 { … … 147 163 } 148 164 165 /* 166 * Polls the socket, checks for errors and removes a connect timer 167 * if there is one. 168 */ 149 169 gboolean jabber_bs_poll( struct bs_transfer *bt, int fd, short *revents ) 150 170 { … … 181 201 } 182 202 203 /* 204 * Used for receive and send path. 205 */ 183 206 gboolean jabber_bs_abort( struct bs_transfer *bt, char *format, ... ) 184 207 { … … 191 214 va_end( params ); 192 215 if( bt->tf->ft->sending ) 216 return jabber_bs_send_handshake_abort( bt, error ); 217 else 193 218 return jabber_bs_recv_handshake_abort( bt, error ); 194 else195 return jabber_bs_send_handshake_abort( bt, error );196 219 } 197 220 … … 214 237 GSList *tflist; 215 238 struct bs_transfer *bt; 239 GSList *shlist=NULL; 240 struct xt_node *shnode; 216 241 217 242 sha1_state_t sha; … … 233 258 { 234 259 imcb_log( ic, "WARNING: Received SI Request for unsupported bytestream mode %s", xt_find_attr( qnode, "mode" ) ); 260 return XT_HANDLED; 261 } 262 263 shnode = qnode->children; 264 while( ( shnode = xt_find_node( shnode, "streamhost" ) ) ) 265 { 266 char *jid, *host; 267 int port; 268 if( ( jid = xt_find_attr( shnode, "jid" ) ) && 269 ( host = xt_find_attr( shnode, "host" ) ) && 270 ( ( port = atoi( xt_find_attr( shnode, "port" ) ) ) ) ) 271 { 272 jabber_streamhost_t *sh = g_new0( jabber_streamhost_t, 1 ); 273 sh->jid = g_strdup(jid); 274 sh->host = g_strdup(host); 275 sprintf( sh->port, "%u", port ); 276 shlist = g_slist_append( shlist, sh ); 277 } 278 shnode = shnode->next; 279 } 280 281 if( !shlist ) 282 { 283 imcb_log( ic, "WARNING: Received incomplete SI bytestream request, no parseable streamhost entries"); 235 284 return XT_HANDLED; 236 285 } … … 274 323 bt = g_new0( struct bs_transfer, 1 ); 275 324 bt->tf = tf; 276 bt-> qnode = xt_dup( qnode );277 bt->sh node = bt->qnode->children;325 bt->streamhosts = shlist; 326 bt->sh = shlist->data; 278 327 bt->phase = BS_PHASE_CONNECT; 279 328 bt->pseudoadr = g_strdup( hash_hex ); … … 285 334 return XT_HANDLED; 286 335 } 336 287 337 /* 288 338 * This is what a protocol handshake can look like in cooperative multitasking :) … … 305 355 case BS_PHASE_CONNECT: 306 356 { 307 struct xt_node *c;308 char *host, *port;309 357 struct addrinfo hints, *rp; 310 358 311 if( ( c = bt->shnode = xt_find_node( bt->shnode, "streamhost" ) ) && 312 ( port = xt_find_attr( c, "port" ) ) && 313 ( host = xt_find_attr( c, "host" ) ) && 314 xt_find_attr( c, "jid" ) ) 315 { 316 memset( &hints, 0, sizeof( struct addrinfo ) ); 317 hints.ai_socktype = SOCK_STREAM; 318 319 if ( getaddrinfo( host, port, &hints, &rp ) != 0 ) 320 return jabber_bs_abort( bt, "getaddrinfo() failed: %s", strerror( errno ) ); 321 322 ASSERTSOCKOP( bt->tf->fd = fd = socket( rp->ai_family, rp->ai_socktype, 0 ), "Opening socket" ); 323 324 sock_make_nonblocking( fd ); 325 326 imcb_log( bt->tf->ic, "File %s: Connecting to streamhost %s:%s", bt->tf->ft->file_name, host, port ); 327 328 if( ( connect( fd, rp->ai_addr, rp->ai_addrlen ) == -1 ) && 329 ( errno != EINPROGRESS ) ) 330 return jabber_bs_abort( bt , "connect() failed: %s", strerror( errno ) ); 331 332 freeaddrinfo( rp ); 333 334 bt->phase = BS_PHASE_CONNECTED; 335 336 bt->tf->watch_out = b_input_add( fd, GAIM_INPUT_WRITE, jabber_bs_recv_handshake, bt ); 337 338 /* since it takes forever(3mins?) till connect() fails on itself we schedule a timeout */ 339 bt->connect_timeout = b_timeout_add( JABBER_BS_CONTIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 340 341 bt->tf->watch_in = 0; 342 return FALSE; 343 } else 344 return jabber_bs_abort( bt, c ? "incomplete streamhost entry: host=%s port=%s jid=%s" : NULL, 345 host, port, xt_find_attr( c, "jid" ) ); 359 memset( &hints, 0, sizeof( struct addrinfo ) ); 360 hints.ai_socktype = SOCK_STREAM; 361 362 if ( getaddrinfo( bt->sh->host, bt->sh->port, &hints, &rp ) != 0 ) 363 return jabber_bs_abort( bt, "getaddrinfo() failed: %s", strerror( errno ) ); 364 365 ASSERTSOCKOP( bt->tf->fd = fd = socket( rp->ai_family, rp->ai_socktype, 0 ), "Opening socket" ); 366 367 sock_make_nonblocking( fd ); 368 369 imcb_log( bt->tf->ic, "File %s: Connecting to streamhost %s:%s", bt->tf->ft->file_name, bt->sh->host, bt->sh->port ); 370 371 if( ( connect( fd, rp->ai_addr, rp->ai_addrlen ) == -1 ) && 372 ( errno != EINPROGRESS ) ) 373 return jabber_bs_abort( bt , "connect() failed: %s", strerror( errno ) ); 374 375 freeaddrinfo( rp ); 376 377 bt->phase = BS_PHASE_CONNECTED; 378 379 bt->tf->watch_out = b_input_add( fd, GAIM_INPUT_WRITE, jabber_bs_recv_handshake, bt ); 380 381 /* since it takes forever(3mins?) till connect() fails on itself we schedule a timeout */ 382 bt->connect_timeout = b_timeout_add( JABBER_BS_CONTIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 383 384 bt->tf->watch_in = 0; 385 return FALSE; 346 386 } 347 387 case BS_PHASE_CONNECTED: … … 422 462 socks5_reply.addrlen); 423 463 424 jabber_bs_recv_answer_request( bt ); 464 if( bt->tf->ft->sending ) 465 jabber_bs_send_activate( bt ); 466 else 467 jabber_bs_recv_answer_request( bt ); 425 468 426 469 return FALSE; … … 447 490 struct jabber_transfer *tf = bt->tf; 448 491 struct xt_node *reply, *iqnode; 449 450 if( bt->shnode ) 451 {452 imcb_log( tf->ic, "Transferring file %s: connection to streamhost %s:%s failed (%s)",453 tf->ft->file_name,454 xt_find_attr( bt->shnode, "host" ),455 xt_find_attr( bt->shnode, "port" ),456 error ); 457 458 /* Alright, this streamhost failed, let's try the next... */459 bt->phase = BS_PHASE_CONNECT;460 bt->shnode = bt->shnode->next;461 462 /* the if is not neccessary but saves us one recursion */463 if( bt->shnode )464 return jabber_bs_recv_handshake( bt, 0, 0 );465 } 492 GSList *shlist; 493 494 imcb_log( tf->ic, "Transferring file %s: connection to streamhost %s:%s failed (%s)", 495 tf->ft->file_name, 496 bt->sh->host, 497 bt->sh->port, 498 error ); 499 500 /* Alright, this streamhost failed, let's try the next... */ 501 bt->phase = BS_PHASE_CONNECT; 502 shlist = g_slist_find( bt->streamhosts, bt->sh ); 503 if( shlist && shlist->next ) 504 { 505 bt->sh = shlist->next->data; 506 return jabber_bs_recv_handshake( bt, 0, 0 ); 507 } 508 466 509 467 510 /* out of stream hosts */ … … 495 538 imcb_log( tf->ic, "File %s: established SOCKS5 connection to %s:%s", 496 539 tf->ft->file_name, 497 xt_find_attr( bt->shnode, "host" ),498 xt_find_attr( bt->shnode, "port" ));540 bt->sh->host, 541 bt->sh->port ); 499 542 500 543 tf->ft->data = tf; 501 tf->ft->started = time( NULL );502 544 tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_recv_read, bt ); 503 545 tf->ft->write_request = jabber_bs_recv_write_request; 504 546 505 547 reply = xt_new_node( "streamhost-used", NULL, NULL ); 506 xt_add_attr( reply, "jid", xt_find_attr( bt->shnode, "jid" ));548 xt_add_attr( reply, "jid", bt->sh->jid ); 507 549 508 550 reply = xt_new_node( "query", NULL, reply ); … … 551 593 return jabber_bs_abort( bt, "Remote end closed connection" ); 552 594 595 if( tf->bytesread == 0 ) 596 tf->ft->started = time( NULL ); 597 553 598 tf->bytesread += ret; 554 599 … … 603 648 return jabber_bs_abort( bt, "BUG: write() called while watching " ); 604 649 650 /* TODO: catch broken pipe */ 605 651 ASSERTSOCKOP( ret = send( tf->fd, buffer, len, 0 ), "Sending" ); 652 653 if( tf->byteswritten == 0 ) 654 tf->ft->started = time( NULL ); 606 655 607 656 tf->byteswritten += ret; … … 665 714 tf->accepted = TRUE; 666 715 667 if( bt->phase == BS_PHASE_REPLY ) 668 { 669 /* handshake went through, let's start transferring */ 670 tf->ft->started = time( NULL ); 671 tf->ft->write_request( tf->ft ); 716 if( strcmp( jid, tf->ini_jid ) == 0 ) 717 { 718 /* we're streamhost and target */ 719 if( bt->phase == BS_PHASE_REPLY ) 720 { 721 /* handshake went through, let's start transferring */ 722 tf->ft->write_request( tf->ft ); 723 } 724 } else 725 { 726 /* using a proxy */ 727 GSList *shlist; 728 for( shlist = jd->streamhosts ; shlist ; shlist = g_slist_next( shlist ) ) 729 { 730 jabber_streamhost_t *sh = shlist->data; 731 if( strcmp( sh->jid, jid ) == 0 ) 732 { 733 bt->sh = sh; 734 jabber_bs_recv_handshake( bt, 0, 0 ); 735 return XT_HANDLED; 736 } 737 } 738 739 imcb_log( ic, "WARNING: Received SOCKS5 bytestream reply with unknown streamhost %s", jid ); 672 740 } 673 741 … … 675 743 } 676 744 745 /* 746 * Tell the proxy to activate the stream. Looks like this: 747 * 748 * <iq type=set> 749 * <query xmlns=bs sid=sid> 750 * <activate>tgt_jid</activate> 751 * </query> 752 * </iq> 753 */ 754 void jabber_bs_send_activate( struct bs_transfer *bt ) 755 { 756 struct xt_node *node; 757 758 node = xt_new_node( "activate", bt->tf->tgt_jid, NULL ); 759 node = xt_new_node( "query", NULL, node ); 760 xt_add_attr( node, "xmlns", XMLNS_BYTESTREAMS ); 761 xt_add_attr( node, "sid", bt->tf->sid ); 762 node = jabber_make_packet( "iq", "set", bt->sh->jid, node ); 763 764 jabber_cache_add( bt->tf->ic, node, jabber_bs_send_handle_activate ); 765 766 jabber_write_packet( bt->tf->ic, node ); 767 } 768 769 /* 770 * The proxy has activated the bytestream. 771 * We can finally start pushing some data out. 772 */ 773 static xt_status jabber_bs_send_handle_activate( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 774 { 775 char *sid; 776 GSList *tflist; 777 struct jabber_transfer *tf; 778 struct xt_node *query; 779 struct jabber_data *jd = ic->proto_data; 780 781 query = xt_find_node( orig->children, "query" ); 782 sid = xt_find_attr( query, "sid" ); 783 784 for( tflist = jd->filetransfers ; tflist; tflist = g_slist_next(tflist) ) 785 { 786 struct jabber_transfer *tft = tflist->data; 787 if( ( strcmp( tft->sid, sid ) == 0 ) ) 788 { 789 tf = tft; 790 break; 791 } 792 } 793 794 if( !tf ) 795 { 796 imcb_log( ic, "WARNING: Received SOCKS5 bytestream activation for unknown stream" ); 797 return XT_HANDLED; 798 } 799 800 /* handshake went through, let's start transferring */ 801 tf->ft->write_request( tf->ft ); 802 803 return XT_HANDLED; 804 } 805 806 /* 807 * Starts a bytestream. 808 */ 677 809 gboolean jabber_bs_send_start( struct jabber_transfer *tf ) 678 810 { 679 char host[INET6_ADDRSTRLEN] , port[6];811 char host[INET6_ADDRSTRLEN]; 680 812 struct bs_transfer *bt; 681 813 sha1_state_t sha; 682 814 char hash_hex[41]; 683 815 unsigned char hash[20]; 684 int i; 816 int i,ret; 817 struct jabber_data *jd = tf->ic->proto_data; 818 jabber_streamhost_t sh; 819 GSList *streamhosts = jd->streamhosts; 685 820 686 821 /* SHA1( SID + Initiator JID + Target JID ) is given to the streamhost which it will match against the initiator's value */ … … 702 837 tf->ft->canceled = jabber_bs_canceled; 703 838 704 if ( !jabber_bs_send_listen( bt, &tf->saddr, host,port ) )839 if ( !jabber_bs_send_listen( bt, &tf->saddr, sh.host = host, sh.port ) ) 705 840 return FALSE; 706 841 707 842 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt ); 708 843 bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt ); 709 return jabber_bs_send_request( tf, host, port ); 710 } 711 712 gboolean jabber_bs_send_request( struct jabber_transfer *tf, char *host, char *port ) 713 { 714 struct xt_node *sh, *query, *iq; 715 716 sh = xt_new_node( "streamhost", NULL, NULL ); 717 xt_add_attr( sh, "jid", tf->ini_jid ); 718 xt_add_attr( sh, "host", host ); 719 xt_add_attr( sh, "port", port ); 844 845 sh.jid = tf->ini_jid; 846 847 /* temporarily add listen address to streamhosts, send the request and remove it */ 848 streamhosts = g_slist_prepend( streamhosts, &sh ); 849 ret = jabber_bs_send_request( tf, streamhosts); 850 streamhosts = g_slist_remove( streamhosts, &sh ); 851 852 return ret; 853 } 854 855 gboolean jabber_bs_send_request( struct jabber_transfer *tf, GSList *streamhosts ) 856 { 857 struct xt_node *shnode, *query, *iq; 720 858 721 859 query = xt_new_node( "query", NULL, NULL ); … … 723 861 xt_add_attr( query, "sid", tf->sid ); 724 862 xt_add_attr( query, "mode", "tcp" ); 725 xt_add_child( query, sh ); 863 864 while( streamhosts ) { 865 jabber_streamhost_t *sh = streamhosts->data; 866 shnode = xt_new_node( "streamhost", NULL, NULL ); 867 xt_add_attr( shnode, "jid", sh->jid ); 868 xt_add_attr( shnode, "host", sh->host ); 869 xt_add_attr( shnode, "port", sh->port ); 870 871 xt_add_child( query, shnode ); 872 873 streamhosts = g_slist_next( streamhosts ); 874 } 875 726 876 727 877 iq = jabber_make_packet( "iq", "set", tf->tgt_jid, query ); … … 739 889 struct jabber_transfer *tf = bt->tf; 740 890 891 /* TODO: did the receiver get here somehow??? */ 741 892 imcb_log( tf->ic, "Transferring file %s: SOCKS5 handshake failed: %s", 742 893 tf->ft->file_name, … … 901 1052 { 902 1053 /* streamhost-used message came already in(possible?), let's start sending */ 903 tf->ft->started = time( NULL );904 1054 tf->ft->write_request( tf->ft ); 905 1055 } -
protocols/jabber/si.c
r793cc25 r0fbd3a6d 83 83 struct jabber_transfer *tf; 84 84 struct jabber_data *jd = ic->proto_data; 85 char *server = jd->server; 85 86 86 87 imcb_log( ic, "Trying to send %s(%zd bytes) to %s", ft->file_name, ft->file_size, who ); … … 97 98 jd->filetransfers = g_slist_prepend( jd->filetransfers, tf ); 98 99 100 /* query the buddy's features */ 101 jabber_iq_query_features( ic, who ); 102 103 /* query proxies from the server */ 104 if( !jd->have_streamhosts ) 105 jabber_iq_query_server( ic, server, XMLNS_DISCO_ITEMS ); 106 107 /* send the request to our buddy */ 99 108 jabber_si_send_request( ic, who, tf ); 100 109 110 /* and start the receive logic */ 101 111 imcb_file_recv_start( ft ); 102 112 } -
protocols/msn/msn.c
r793cc25 r0fbd3a6d 241 241 } 242 242 243 static void msn_chat_invite( struct groupchat *c, char * msg, char *who)243 static void msn_chat_invite( struct groupchat *c, char *who, char *message ) 244 244 { 245 245 struct msn_switchboard *sb = msn_sb_by_chat( c ); -
protocols/oscar/aim.h
r793cc25 r0fbd3a6d 94 94 * 95 95 */ 96 #define AIM_DEFAULT_LOGIN_SERVER "login. oscar.aol.com"96 #define AIM_DEFAULT_LOGIN_SERVER "login.messaging.aol.com" 97 97 #define AIM_LOGIN_PORT 5190 98 98 -
protocols/oscar/oscar.c
r793cc25 r0fbd3a6d 341 341 set_t *s; 342 342 343 s = set_add( &acc->set, "server", NULL, set_eval_account, acc );343 s = set_add( &acc->set, "server", AIM_DEFAULT_LOGIN_SERVER, set_eval_account, acc ); 344 344 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 345 345 … … 356 356 struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); 357 357 358 if (isdigit(acc->user[0])) { 359 odata->icq = TRUE; 360 /* This is odd but it's necessary for a proper do_import and do_export. 361 We don't do those anymore, but let's stick with it, just in case 362 it accidentally fixes something else too... </bitlbee> */ 363 /* ic->acc->pass[8] = 0; 364 Not touching this anymore now that it belongs to account_t! 365 Let's hope nothing will break. ;-) */ 366 } else { 358 if (!isdigit(acc->user[0])) { 367 359 ic->flags |= OPT_DOES_HTML; 368 360 } … … 385 377 } 386 378 387 if (acc->server == NULL) {388 imcb_error(ic, "No servername specified");389 imc_logout(ic, FALSE);390 return;391 }392 393 if (g_strcasecmp(acc->server, "login.icq.com") != 0 &&394 g_strcasecmp(acc->server, "login.oscar.aol.com") != 0) {395 imcb_log(ic, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",acc->server);396 }397 398 379 imcb_log(ic, _("Signon: %s"), ic->acc->user); 399 380 … … 402 383 403 384 conn->status |= AIM_CONN_STATUS_INPROGRESS; 404 conn->fd = proxy_connect(acc->server, AIM_LOGIN_PORT, oscar_login_connect, ic); 385 conn->fd = proxy_connect(set_getstr(&acc->set, "server"), 386 AIM_LOGIN_PORT, oscar_login_connect, ic); 405 387 if (conn->fd < 0) { 406 388 imcb_error(ic, _("Couldn't connect to host")); … … 2509 2491 } 2510 2492 2511 void oscar_chat_invite(struct groupchat *c, char * message, char *who)2493 void oscar_chat_invite(struct groupchat *c, char *who, char *message) 2512 2494 { 2513 2495 struct im_connection *ic = c->ic; -
protocols/yahoo/yahoo.c
r793cc25 r0fbd3a6d 306 306 } 307 307 308 static void byahoo_chat_invite( struct groupchat *c, char * msg, char *who)308 static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg ) 309 309 { 310 310 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
Note: See TracChangeset
for help on using the changeset viewer.