Changeset 21c87a7 for protocols/msn
- Timestamp:
- 2010-04-14T09:27:50Z (15 years ago)
- Branches:
- master
- Children:
- d33679e
- Parents:
- 81186cab (diff), 156bbd7 (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:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r81186cab r21c87a7 31 31 GSList *msn_switchboards; 32 32 33 static char * msn_set_display_name( set_t *set, char *value );33 static char *set_eval_display_name( set_t *set, char *value ); 34 34 35 35 static void msn_init( account_t *acc ) 36 36 { 37 set_t *s; 38 39 s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); 40 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 41 42 s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 37 set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); 38 set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc ); 39 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 43 40 } 44 41 … … 173 170 static void msn_set_my_name( struct im_connection *ic, char *info ) 174 171 { 175 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );172 msn_set_display_name( ic, info ); 176 173 } 177 174 … … 289 286 } 290 287 291 static char * msn_set_display_name( set_t *set, char *value )288 static char *set_eval_display_name( set_t *set, char *value ) 292 289 { 293 290 account_t *acc = set->data; 294 291 struct im_connection *ic = acc->ic; 295 struct msn_data *md; 296 char buf[1024], *fn; 297 298 /* Double-check. */ 292 293 /* Allow any name if we're offline. */ 299 294 if( ic == NULL ) 300 return NULL; 301 302 md = ic->proto_data; 295 return value; 303 296 304 297 if( strlen( value ) > 129 ) … … 307 300 return NULL; 308 301 } 309 310 fn = msn_http_encode( value );311 312 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );313 msn_write( ic, buf, strlen( buf ) );314 g_free( fn );315 302 316 303 /* Returning NULL would be better, because the server still has to 317 304 confirm the name change. However, it looks a bit confusing to the 318 305 user. */ 319 return value;306 return msn_set_display_name( ic, value ) ? value : NULL; 320 307 } 321 308 -
protocols/msn/msn.h
r81186cab r21c87a7 162 162 char *msn_http_encode( const char *input ); 163 163 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 164 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ); 164 165 165 166 /* tables.c */ -
protocols/msn/msn_util.c
r81186cab r21c87a7 38 38 imcb_error( ic, "Short write() to main server" ); 39 39 imc_logout( ic, TRUE ); 40 return ( 0 );41 } 42 43 return ( 1 );40 return 0; 41 } 42 43 return 1; 44 44 } 45 45 … … 376 376 g_string_free( ret, TRUE ); 377 377 } 378 379 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ) 380 { 381 char *fn = msn_http_encode( rawname ); 382 struct msn_data *md = ic->proto_data; 383 char buf[1024]; 384 385 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn ); 386 g_free( fn ); 387 388 return msn_write( ic, buf, strlen( buf ) ) != 0; 389 } -
protocols/msn/ns.c
r81186cab r21c87a7 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 ) … … 231 232 else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) 232 233 { 233 set_t *s;234 235 234 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 } 235 msn_ns_got_display_name( ic, cmd[4] ); 248 236 else 249 {250 237 imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); 251 }252 238 253 239 imcb_log( ic, "Authenticated, getting buddy list" ); … … 567 553 return( 0 ); 568 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. */ 569 558 else if( strcmp( cmd[0], "REA" ) == 0 ) 570 559 { … … 597 586 } 598 587 } 588 #endif 599 589 else if( strcmp( cmd[0], "IPG" ) == 0 ) 600 590 { … … 746 736 } 747 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.