Changes in protocols/msn/sb.c [e5abfd4:f8cb76d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/sb.c
re5abfd4 rf8cb76d 29 29 #include "passport.h" 30 30 #include "md5.h" 31 #include "invitation.h"32 31 33 32 static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond ); … … 178 177 { 179 178 buf = g_strdup( SB_KEEPALIVE_HEADERS ); 180 i = strlen( buf );181 }182 else if( strncmp( text, MSN_INVITE_HEADERS, sizeof( MSN_INVITE_HEADERS ) - 1 ) == 0 )183 {184 buf = g_strdup( text );185 179 i = strlen( buf ); 186 180 } … … 233 227 { 234 228 struct im_connection *ic = sb->ic; 235 struct groupchat *c = NULL;236 229 char buf[1024]; 237 230 238 231 /* Create the groupchat structure. */ 239 232 g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); 240 if( sb->who ) 241 c = bee_chat_by_title( ic->bee, ic, sb->who ); 242 if( c && !msn_sb_by_chat( c ) ) 243 sb->chat = c; 244 else 245 sb->chat = imcb_chat_new( ic, buf ); 233 sb->chat = imcb_chat_new( ic, buf ); 246 234 247 235 /* Populate the channel. */ … … 340 328 struct msn_data *md = ic->proto_data; 341 329 342 if( msn_handler( sb->handler ) == -1 ) 330 if( msn_handler( sb->handler ) != -1 ) 331 return TRUE; 332 333 if( sb->msgq != NULL ) 343 334 { 344 335 time_t now = time( NULL ); 336 char buf[1024]; 345 337 346 338 if( now - md->first_sb_failure > 600 ) … … 359 351 "There might be problems delivering your messages." ); 360 352 361 if( sb->msgq != NULL ) 362 { 363 char buf[1024]; 364 365 if( md->msgq == NULL ) 366 { 367 md->msgq = sb->msgq; 368 } 369 else 370 { 371 GSList *l; 372 373 for( l = md->msgq; l->next; l = l->next ); 374 l->next = sb->msgq; 375 } 376 sb->msgq = NULL; 377 378 debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." ); 379 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 380 if( !msn_write( ic, buf, strlen( buf ) ) ) 381 return FALSE; 382 } 383 384 msn_sb_destroy( sb ); 385 386 return FALSE; 387 } 388 else 389 { 390 return TRUE; 391 } 353 if( md->msgq == NULL ) 354 { 355 md->msgq = sb->msgq; 356 } 357 else 358 { 359 GSList *l; 360 361 for( l = md->msgq; l->next; l = l->next ); 362 l->next = sb->msgq; 363 } 364 sb->msgq = NULL; 365 366 debug( "Moved queued messages back to the main queue, " 367 "creating a new switchboard to retry." ); 368 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 369 if( !msn_write( ic, buf, strlen( buf ) ) ) 370 return FALSE; 371 } 372 373 msn_sb_destroy( sb ); 374 return FALSE; 392 375 } 393 376 … … 709 692 } 710 693 } 711 #if 0712 // Disable MSN ft support for now.713 694 else if( g_strncasecmp( ct, "text/x-msmsgsinvite", 19 ) == 0 ) 714 695 { 715 char *command = msn_findheader( body, "Invitation-Command:", blen ); 716 char *cookie = msn_findheader( body, "Invitation-Cookie:", blen ); 717 unsigned int icookie; 696 char *itype = msn_findheader( body, "Application-GUID:", blen ); 697 char buf[1024]; 718 698 719 699 g_free( ct ); 720 700 721 /* Every invite should have both a Command and Cookie header */ 722 if( !command || !cookie ) { 723 g_free( command ); 724 g_free( cookie ); 725 imcb_log( ic, "Warning: No command or cookie from %s", sb->who ); 726 return 1; 727 } 728 729 icookie = strtoul( cookie, NULL, 10 ); 730 g_free( cookie ); 731 732 if( g_strncasecmp( command, "INVITE", 6 ) == 0 ) { 733 msn_invitation_invite( sb, cmd[1], icookie, body, blen ); 734 } else if( g_strncasecmp( command, "ACCEPT", 6 ) == 0 ) { 735 msn_invitation_accept( sb, cmd[1], icookie, body, blen ); 736 } else if( g_strncasecmp( command, "CANCEL", 6 ) == 0 ) { 737 msn_invitation_cancel( sb, cmd[1], icookie, body, blen ); 738 } else { 739 imcb_log( ic, "Warning: Received invalid invitation with " 740 "command %s from %s", command, sb->who ); 741 } 742 743 g_free( command ); 744 } 745 #endif 746 else if( g_strncasecmp( ct, "application/x-msnmsgrp2p", 24 ) == 0 ) 747 { 748 imcb_error( sb->ic, "Cannot receive file from %s: BitlBee does not " 749 "support msnmsgrp2p yet.", sb->who ); 750 g_free( ct ); 701 *buf = 0; 702 703 if( !itype ) 704 return( 1 ); 705 706 /* File transfer. */ 707 if( strcmp( itype, "{5D3E02AB-6190-11d3-BBBB-00C04F795683}" ) == 0 ) 708 { 709 char *name = msn_findheader( body, "Application-File:", blen ); 710 char *size = msn_findheader( body, "Application-FileSize:", blen ); 711 712 if( name && size ) 713 { 714 g_snprintf( buf, sizeof( buf ), "<< \x02""BitlBee\x02"" - Filetransfer: `%s', %s bytes >>\n" 715 "Filetransfers are not supported by BitlBee for now...", name, size ); 716 } 717 else 718 { 719 strcpy( buf, "<< \x02""BitlBee\x02"" - Corrupted MSN filetransfer invitation message >>" ); 720 } 721 722 if( name ) g_free( name ); 723 if( size ) g_free( size ); 724 } 725 else 726 { 727 char *iname = msn_findheader( body, "Application-Name:", blen ); 728 729 g_snprintf( buf, sizeof( buf ), "<< \x02""BitlBee\x02"" - Unknown MSN invitation - %s (%s) >>", 730 itype, iname ? iname : "no name" ); 731 732 if( iname ) g_free( iname ); 733 } 734 735 g_free( itype ); 736 737 if( !*buf ) 738 return( 1 ); 739 740 if( sb->who ) 741 { 742 imcb_buddy_msg( ic, cmd[1], buf, 0, 0 ); 743 } 744 else if( sb->chat ) 745 { 746 imcb_chat_msg( sb->chat, cmd[1], buf, 0, 0 ); 747 } 748 else 749 { 750 /* PANIC! */ 751 } 751 752 } 752 753 else if( g_strncasecmp( ct, "text/x-msmsgscontrol", 20 ) == 0 ) … … 779 780 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial ) 780 781 { 781 bee_user_t *bu;782 struct buddy *b; 782 783 783 784 if( sb && sb->who && sb->keepalive == 0 && 784 ( bu = bee_user_by_handle( sb->ic->bee, sb->ic, sb->who ) ) && 785 !( bu->flags & BEE_USER_ONLINE ) && 785 ( b = imcb_find_buddy( sb->ic, sb->who ) ) && !b->present && 786 786 set_getbool( &sb->ic->acc->set, "switchboard_keepalives" ) ) 787 787 {
Note: See TracChangeset
for help on using the changeset viewer.