Changeset e8c8d00 for protocols/msn
- Timestamp:
- 2010-03-17T15:15:19Z (15 years ago)
- Branches:
- master
- Children:
- 60e4df3
- Parents:
- 1c3008a (diff), f9928cb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- protocols/msn
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r1c3008a re8c8d00 26 26 #include "nogaim.h" 27 27 #include "msn.h" 28 29 int msn_chat_id; 30 GSList *msn_connections; 31 GSList *msn_switchboards; 28 32 29 33 static char *msn_set_display_name( set_t *set, char *value ); … … 143 147 144 148 if( l == NULL ) 145 for( i = 0; msn_away_state_list[i].number > -1; i ++ ) 146 l = g_list_append( l, (void*) msn_away_state_list[i].name ); 149 for( i = 0; *msn_away_state_list[i].code; i ++ ) 150 if( *msn_away_state_list[i].name ) 151 l = g_list_append( l, (void*) msn_away_state_list[i].name ); 147 152 148 153 return l; … … 153 158 char buf[1024]; 154 159 struct msn_data *md = ic->proto_data; 155 const struct msn_away_state *st;156 157 if( strcmp( state, GAIM_AWAY_CUSTOM ) == 0 )158 st = msn_away_state_by_name( "Away" );160 161 if( state ) 162 md->away_state = msn_away_state_by_name( state ) ? : 163 msn_away_state_list + 1; 159 164 else 160 st = msn_away_state_by_name( state ); 161 162 if( !st ) st = msn_away_state_list; 163 md->away_state = st; 164 165 g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); 165 md->away_state = msn_away_state_list; 166 167 g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code ); 166 168 msn_write( ic, buf, strlen( buf ) ); 167 169 } -
protocols/msn/msn.h
r1c3008a re8c8d00 98 98 struct msn_away_state 99 99 { 100 int number;101 100 char code[4]; 102 101 char name[16]; … … 137 136 #define STATUS_SB_CHAT_SPARE 8 /* Same, but also for groupchats (not used yet). */ 138 137 139 int msn_chat_id;138 extern int msn_chat_id; 140 139 extern const struct msn_away_state msn_away_state_list[]; 141 140 extern const struct msn_status_code msn_status_code_list[]; … … 146 145 connection), the callback should check whether it's still listed here 147 146 before doing *anything* else. */ 148 GSList *msn_connections;149 GSList *msn_switchboards;147 extern GSList *msn_connections; 148 extern GSList *msn_switchboards; 150 149 151 150 /* ns.c */ -
protocols/msn/msn_util.c
r1c3008a re8c8d00 171 171 172 172 /* End of headers? */ 173 if( strncmp( text + i - 2, "\n\n", 2 ) == 0||174 strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ||175 strncmp( text + i - 2, "\r\r", 2 ) == 0)173 if( ( i >= 4 && strncmp( text + i - 4, "\r\n\r\n", 4 ) == 0 ) || 174 ( i >= 2 && ( strncmp( text + i - 2, "\n\n", 2 ) == 0 || 175 strncmp( text + i - 2, "\r\r", 2 ) == 0 ) ) ) 176 176 { 177 177 break; … … 374 374 *list = NULL; 375 375 376 imcb_log( ic, ret->str );376 imcb_log( ic, "%s", ret->str ); 377 377 g_string_free( ret, TRUE ); 378 378 } -
protocols/msn/ns.c
r1c3008a re8c8d00 229 229 } 230 230 } 231 else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 )231 else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) 232 232 { 233 233 set_t *s; 234 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] ); 235 if( num_parts == 7 ) 236 { 237 http_decode( cmd[4] ); 238 239 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 240 ic->displayname[sizeof(ic->displayname)-1] = 0; 241 242 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 243 { 244 g_free( s->value ); 245 s->value = g_strdup( cmd[4] ); 246 } 247 } 248 else 249 { 250 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 244 251 } 245 252 … … 420 427 { 421 428 /* 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 ); 429 st = msn_away_state_list + 1; 430 } 431 432 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | 433 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 434 st->name, NULL ); 427 435 } 428 436 else if( strcmp( cmd[0], "FLN" ) == 0 ) … … 449 457 { 450 458 /* 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 ); 459 st = msn_away_state_list + 1; 460 } 461 462 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | 463 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 464 st->name, NULL ); 456 465 } 457 466 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 663 672 } 664 673 665 if( arg1 )g_free( arg1 );666 if( mtype )g_free( mtype );674 g_free( arg1 ); 675 g_free( mtype ); 667 676 } 668 677 else if( g_strncasecmp( ct, "text/x-msmsgsprofile", 20 ) == 0 ) … … 672 681 else if( g_strncasecmp( ct, "text/x-msmsgsinitialemailnotification", 37 ) == 0 ) 673 682 { 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" ) ) 683 if( set_getbool( &ic->acc->set, "mail_notifications" ) ) 678 684 { 679 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 685 char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); 686 char *folders = msn_findheader( body, "Folders-Unread:", blen ); 687 688 if( inbox && folders ) 689 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 690 691 g_free( inbox ); 692 g_free( folders ); 680 693 } 681 682 g_free( inbox );683 g_free( folders );684 694 } 685 695 else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) 686 696 { 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" ) ) 697 if( set_getbool( &ic->acc->set, "mail_notifications" ) ) 691 698 { 692 imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 699 char *from = msn_findheader( body, "From-Addr:", blen ); 700 char *fromname = msn_findheader( body, "From:", blen ); 701 702 if( from && fromname ) 703 imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 704 705 g_free( from ); 706 g_free( fromname ); 693 707 } 694 708 } -
protocols/msn/tables.c
r1c3008a re8c8d00 29 29 const struct msn_away_state msn_away_state_list[] = 30 30 { 31 { 0, "NLN", "Available" },32 { 1, "BSY", "Busy" },33 { 3, "IDL", "Idle" },34 { 5, "BRB", "Be Right Back" },35 { 7, "AWY", "Away" },36 { 9,"PHN", "On the Phone" },37 { 11,"LUN", "Out to Lunch" },38 { 13,"HDN", "Hidden" },39 { -1,"", "" }31 { "NLN", "" }, 32 { "AWY", "Away" }, 33 { "BSY", "Busy" }, 34 { "IDL", "Idle" }, 35 { "BRB", "Be Right Back" }, 36 { "PHN", "On the Phone" }, 37 { "LUN", "Out to Lunch" }, 38 { "HDN", "Hidden" }, 39 { "", "" } 40 40 }; 41 42 const struct msn_away_state *msn_away_state_by_number( int number )43 {44 int i;45 46 for( i = 0; msn_away_state_list[i].number > -1; i ++ )47 if( msn_away_state_list[i].number == number )48 return( msn_away_state_list + i );49 50 return( NULL );51 }52 41 53 42 const struct msn_away_state *msn_away_state_by_code( char *code ) … … 55 44 int i; 56 45 57 for( i = 0; msn_away_state_list[i].number > -1; i ++ )46 for( i = 0; *msn_away_state_list[i].code; i ++ ) 58 47 if( g_strcasecmp( msn_away_state_list[i].code, code ) == 0 ) 59 48 return( msn_away_state_list + i ); 60 49 61 return ( NULL );50 return NULL; 62 51 } 63 52 … … 66 55 int i; 67 56 68 for( i = 0; msn_away_state_list[i].number > -1; i ++ )57 for( i = 0; *msn_away_state_list[i].code; i ++ ) 69 58 if( g_strcasecmp( msn_away_state_list[i].name, name ) == 0 ) 70 59 return( msn_away_state_list + i ); 71 60 72 return ( NULL );61 return NULL; 73 62 } 74 63
Note: See TracChangeset
for help on using the changeset viewer.