Changes in protocols/msn/sb.c [17a6ee9:bb839e8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/sb.c
r17a6ee9 rbb839e8 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 ); … … 175 174 i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user ); 176 175 } 177 else if( str ncmp( text, MSN_INVITE_HEADERS, sizeof( MSN_INVITE_HEADERS ) - 1 ) == 0 )178 { 179 buf = g_strdup( text);176 else if( strcmp( text, SB_KEEPALIVE_MESSAGE ) == 0 ) 177 { 178 buf = g_strdup( SB_KEEPALIVE_HEADERS ); 180 179 i = strlen( buf ); 181 180 } … … 256 255 257 256 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 ); 479 481 } 480 482 else if( strcmp( cmd[0], "CAL" ) == 0 ) … … 526 528 } 527 529 530 msn_sb_start_keepalives( sb, FALSE ); 531 528 532 return( st ); 529 533 } … … 587 591 if( sb->who ) 588 592 { 593 msn_sb_stop_keepalives( sb ); 594 589 595 /* This is a single-person chat, and the other person is leaving. */ 590 596 g_free( sb->who ); … … 691 697 } 692 698 } 693 #if 0694 // Disable MSN ft support for now.695 699 else if( g_strncasecmp( ct, "text/x-msmsgsinvite", 19 ) == 0 ) 696 700 { 697 char *command = msn_findheader( body, "Invitation-Command:", blen ); 698 char *cookie = msn_findheader( body, "Invitation-Cookie:", blen ); 699 unsigned int icookie; 701 char *itype = msn_findheader( body, "Application-GUID:", blen ); 702 char buf[1024]; 700 703 701 704 g_free( ct ); 702 705 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 ); 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 } 733 757 } 734 758 else if( g_strncasecmp( ct, "text/x-msmsgscontrol", 20 ) == 0 ) … … 752 776 return( 1 ); 753 777 } 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.