Changes in protocols/msn/ns.c [d84e2a9:7815a2b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/ns.c
rd84e2a9 r7815a2b 35 35 36 36 static void msn_auth_got_passport_token( struct msn_auth_data *mad ); 37 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ); 37 38 38 39 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) … … 229 230 } 230 231 } 231 else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 ) 232 { 233 set_t *s; 234 235 http_decode( cmd[4] ); 236 237 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 238 ic->displayname[sizeof(ic->displayname)-1] = 0; 239 240 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 241 { 242 g_free( s->value ); 243 s->value = g_strdup( cmd[4] ); 244 } 232 else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) 233 { 234 if( num_parts == 7 ) 235 msn_ns_got_display_name( ic, cmd[4] ); 236 else 237 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 245 238 246 239 imcb_log( ic, "Authenticated, getting buddy list" ); … … 420 413 { 421 414 /* FIXME: Warn/Bomb about unknown away state? */ 422 st = msn_away_state_list; 423 } 424 425 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | 426 ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); 415 st = msn_away_state_list + 1; 416 } 417 418 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | 419 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 420 st->name, NULL ); 427 421 } 428 422 else if( strcmp( cmd[0], "FLN" ) == 0 ) … … 449 443 { 450 444 /* FIXME: Warn/Bomb about unknown away state? */ 451 st = msn_away_state_list; 452 } 453 454 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | 455 ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); 445 st = msn_away_state_list + 1; 446 } 447 448 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | 449 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 450 st->name, NULL ); 456 451 } 457 452 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 558 553 return( 0 ); 559 554 } 555 #if 0 556 /* Discard this one completely for now since I don't care about the ack 557 and since MSN servers can apparently screw up the formatting. */ 560 558 else if( strcmp( cmd[0], "REA" ) == 0 ) 561 559 { … … 588 586 } 589 587 } 588 #endif 590 589 else if( strcmp( cmd[0], "IPG" ) == 0 ) 591 590 { … … 663 662 } 664 663 665 if( arg1 )g_free( arg1 );666 if( mtype )g_free( mtype );664 g_free( arg1 ); 665 g_free( mtype ); 667 666 } 668 667 else if( g_strncasecmp( ct, "text/x-msmsgsprofile", 20 ) == 0 ) … … 672 671 else if( g_strncasecmp( ct, "text/x-msmsgsinitialemailnotification", 37 ) == 0 ) 673 672 { 674 char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); 675 char *folders = msn_findheader( body, "Folders-Unread:", blen ); 676 677 if( inbox && folders && set_getbool( &ic->acc->set, "mail_notifications" ) ) 673 if( set_getbool( &ic->acc->set, "mail_notifications" ) ) 678 674 { 679 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 675 char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); 676 char *folders = msn_findheader( body, "Folders-Unread:", blen ); 677 678 if( inbox && folders ) 679 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 680 681 g_free( inbox ); 682 g_free( folders ); 680 683 } 681 682 g_free( inbox );683 g_free( folders );684 684 } 685 685 else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) 686 686 { 687 char *from = msn_findheader( body, "From-Addr:", blen ); 688 char *fromname = msn_findheader( body, "From:", blen ); 689 690 if( from && fromname && set_getbool( &ic->acc->set, "mail_notifications" ) ) 687 if( set_getbool( &ic->acc->set, "mail_notifications" ) ) 691 688 { 692 imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 689 char *from = msn_findheader( body, "From-Addr:", blen ); 690 char *fromname = msn_findheader( body, "From:", blen ); 691 692 if( from && fromname ) 693 imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 694 695 g_free( from ); 696 g_free( fromname ); 693 697 } 694 698 } … … 732 736 } 733 737 } 738 739 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ) 740 { 741 set_t *s; 742 743 if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL ) 744 return FALSE; /* Shouldn't happen.. */ 745 746 http_decode( name ); 747 748 if( s->value && strcmp( s->value, name ) == 0 ) 749 { 750 return TRUE; 751 /* The names match, nothing to worry about. */ 752 } 753 else if( s->value != NULL && 754 ( strcmp( name, ic->acc->user ) == 0 || 755 set_getbool( &ic->acc->set, "local_display_name" ) ) ) 756 { 757 /* The server thinks our display name is our e-mail address 758 which is probably wrong, or the user *wants* us to do this: 759 Always use the locally set display_name. */ 760 return msn_set_display_name( ic, s->value ); 761 } 762 else 763 { 764 if( s->value && *s->value ) 765 imcb_log( ic, "BitlBee thinks your display name is `%s' but " 766 "the MSN server says it's `%s'. Using the MSN " 767 "server's name. Set local_display_name to true " 768 "to use the local name.", s->value, name ); 769 770 if( g_utf8_validate( name, -1, NULL ) ) 771 { 772 g_free( s->value ); 773 s->value = g_strdup( name ); 774 } 775 else 776 { 777 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 778 } 779 780 return TRUE; 781 } 782 }
Note: See TracChangeset
for help on using the changeset viewer.