Changes in protocols/msn/sb.c [bb839e8:17a6ee9]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/sb.c
rbb839e8 r17a6ee9 29 29 #include "passport.h" 30 30 #include "md5.h" 31 #include "invitation.h" 31 32 32 33 static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond ); … … 174 175 i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user ); 175 176 } 176 else if( str cmp( text, SB_KEEPALIVE_MESSAGE ) == 0 )177 { 178 buf = g_strdup( SB_KEEPALIVE_HEADERS);177 else if( strncmp( text, MSN_INVITE_HEADERS, sizeof( MSN_INVITE_HEADERS ) - 1 ) == 0 ) 178 { 179 buf = g_strdup( text ); 179 180 i = strlen( buf ); 180 181 } … … 255 256 256 257 msn_msgq_purge( ic, &sb->msgq ); 257 msn_sb_stop_keepalives( sb );258 258 259 259 if( sb->key ) g_free( sb->key ); … … 477 477 478 478 sb->ready = 1; 479 480 msn_sb_start_keepalives( sb, FALSE );481 479 } 482 480 else if( strcmp( cmd[0], "CAL" ) == 0 ) … … 528 526 } 529 527 530 msn_sb_start_keepalives( sb, FALSE );531 532 528 return( st ); 533 529 } … … 591 587 if( sb->who ) 592 588 { 593 msn_sb_stop_keepalives( sb );594 595 589 /* This is a single-person chat, and the other person is leaving. */ 596 590 g_free( sb->who ); … … 697 691 } 698 692 } 693 #if 0 694 // Disable MSN ft support for now. 699 695 else if( g_strncasecmp( ct, "text/x-msmsgsinvite", 19 ) == 0 ) 700 696 { 701 char *itype = msn_findheader( body, "Application-GUID:", blen ); 702 char buf[1024]; 697 char *command = msn_findheader( body, "Invitation-Command:", blen ); 698 char *cookie = msn_findheader( body, "Invitation-Cookie:", blen ); 699 unsigned int icookie; 703 700 704 701 g_free( ct ); 705 702 706 *buf = 0; 707 708 if( !itype ) 709 return( 1 ); 710 711 /* File transfer. */ 712 if( strcmp( itype, "{5D3E02AB-6190-11d3-BBBB-00C04F795683}" ) == 0 ) 713 { 714 char *name = msn_findheader( body, "Application-File:", blen ); 715 char *size = msn_findheader( body, "Application-FileSize:", blen ); 716 717 if( name && size ) 718 { 719 g_snprintf( buf, sizeof( buf ), "<< \x02""BitlBee\x02"" - Filetransfer: `%s', %s bytes >>\n" 720 "Filetransfers are not supported by BitlBee for now...", name, size ); 721 } 722 else 723 { 724 strcpy( buf, "<< \x02""BitlBee\x02"" - Corrupted MSN filetransfer invitation message >>" ); 725 } 726 727 if( name ) g_free( name ); 728 if( size ) g_free( size ); 729 } 730 else 731 { 732 char *iname = msn_findheader( body, "Application-Name:", blen ); 733 734 g_snprintf( buf, sizeof( buf ), "<< \x02""BitlBee\x02"" - Unknown MSN invitation - %s (%s) >>", 735 itype, iname ? iname : "no name" ); 736 737 if( iname ) g_free( iname ); 738 } 739 740 g_free( itype ); 741 742 if( !*buf ) 743 return( 1 ); 744 745 if( sb->who ) 746 { 747 imcb_buddy_msg( ic, cmd[1], buf, 0, 0 ); 748 } 749 else if( sb->chat ) 750 { 751 imcb_chat_msg( sb->chat, cmd[1], buf, 0, 0 ); 752 } 753 else 754 { 755 /* PANIC! */ 756 } 703 /* Every invite should have both a Command and Cookie header */ 704 if( !command || !cookie ) { 705 g_free( command ); 706 g_free( cookie ); 707 imcb_log( ic, "Warning: No command or cookie from %s", sb->who ); 708 return 1; 709 } 710 711 icookie = strtoul( cookie, NULL, 10 ); 712 g_free( cookie ); 713 714 if( g_strncasecmp( command, "INVITE", 6 ) == 0 ) { 715 msn_invitation_invite( sb, cmd[1], icookie, body, blen ); 716 } else if( g_strncasecmp( command, "ACCEPT", 6 ) == 0 ) { 717 msn_invitation_accept( sb, cmd[1], icookie, body, blen ); 718 } else if( g_strncasecmp( command, "CANCEL", 6 ) == 0 ) { 719 msn_invitation_cancel( sb, cmd[1], icookie, body, blen ); 720 } else { 721 imcb_log( ic, "Warning: Received invalid invitation with " 722 "command %s from %s", command, sb->who ); 723 } 724 725 g_free( command ); 726 } 727 #endif 728 else if( g_strncasecmp( ct, "application/x-msnmsgrp2p", 24 ) == 0 ) 729 { 730 imcb_error( sb->ic, "Cannot receive file from %s: BitlBee does not " 731 "support msnmsgrp2p yet.", sb->who ); 732 g_free( ct ); 757 733 } 758 734 else if( g_strncasecmp( ct, "text/x-msmsgscontrol", 20 ) == 0 ) … … 776 752 return( 1 ); 777 753 } 778 779 static gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond )780 {781 struct msn_switchboard *sb = data;782 return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE );783 }784 785 void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial )786 {787 struct buddy *b;788 789 if( sb && sb->who && sb->keepalive == 0 &&790 ( b = imcb_find_buddy( sb->ic, sb->who ) ) && !b->present &&791 set_getbool( &sb->ic->acc->set, "switchboard_keepalives" ) )792 {793 if( initial )794 msn_sb_keepalive( sb, 0, 0 );795 796 sb->keepalive = b_timeout_add( 20000, msn_sb_keepalive, sb );797 }798 }799 800 void msn_sb_stop_keepalives( struct msn_switchboard *sb )801 {802 if( sb && sb->keepalive > 0 )803 {804 b_event_remove( sb->keepalive );805 sb->keepalive = 0;806 }807 }
Note: See TracChangeset
for help on using the changeset viewer.