Changes in protocols/msn/ns.c [7815a2b:d84e2a9]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/ns.c
r7815a2b rd84e2a9 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 );38 37 39 38 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) … … 230 229 } 231 230 } 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" ); 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 } 238 245 239 246 imcb_log( ic, "Authenticated, getting buddy list" ); … … 413 420 { 414 421 /* FIXME: Warn/Bomb about unknown away state? */ 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 ); 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 ); 421 427 } 422 428 else if( strcmp( cmd[0], "FLN" ) == 0 ) … … 443 449 { 444 450 /* FIXME: Warn/Bomb about unknown away state? */ 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 ); 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 ); 451 456 } 452 457 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 553 558 return( 0 ); 554 559 } 555 #if 0556 /* Discard this one completely for now since I don't care about the ack557 and since MSN servers can apparently screw up the formatting. */558 560 else if( strcmp( cmd[0], "REA" ) == 0 ) 559 561 { … … 586 588 } 587 589 } 588 #endif589 590 else if( strcmp( cmd[0], "IPG" ) == 0 ) 590 591 { … … 662 663 } 663 664 664 g_free( arg1 );665 g_free( mtype );665 if( arg1 ) g_free( arg1 ); 666 if( mtype ) g_free( mtype ); 666 667 } 667 668 else if( g_strncasecmp( ct, "text/x-msmsgsprofile", 20 ) == 0 ) … … 671 672 else if( g_strncasecmp( ct, "text/x-msmsgsinitialemailnotification", 37 ) == 0 ) 672 673 { 673 if( set_getbool( &ic->acc->set, "mail_notifications" ) ) 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" ) ) 674 678 { 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 ); 679 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 683 680 } 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 if( set_getbool( &ic->acc->set, "mail_notifications" ) ) 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" ) ) 688 691 { 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 ); 692 imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 697 693 } 698 694 } … … 736 732 } 737 733 } 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 address758 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 else763 {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 else776 {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.