- Timestamp:
- 2006-07-02T23:20:27Z (18 years ago)
- Branches:
- master
- Children:
- 5b52a48
- Parents:
- 96863f6
- Location:
- protocols/msn
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r96863f6 r911f2eb 26 26 #include "nogaim.h" 27 27 #include "msn.h" 28 29 static char *msn_set_display_name( set_t *set, char *value ); 30 31 static void msn_acc_init( account_t *acc ) 32 { 33 set_t *s; 34 35 s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); 36 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 37 } 28 38 29 39 static void msn_login( account_t *acc ) … … 210 220 static void msn_set_info( struct gaim_connection *gc, char *info ) 211 221 { 212 int i; 213 char buf[1024], *fn, *s; 214 struct msn_data *md = gc->proto_data; 215 216 if( strlen( info ) > 129 ) 217 { 218 do_error_dialog( gc, "Maximum name length exceeded", "MSN" ); 219 return; 220 } 221 222 /* Of course we could use http_encode() here, but when we encode 223 every character, the server is less likely to complain about the 224 chosen name. However, the MSN server doesn't seem to like escaped 225 non-ASCII chars, so we keep those unescaped. */ 226 s = fn = g_new0( char, strlen( info ) * 3 + 1 ); 227 for( i = 0; info[i]; i ++ ) 228 if( info[i] & 128 ) 229 { 230 *s = info[i]; 231 s ++; 232 } 233 else 234 { 235 g_snprintf( s, 4, "%%%02X", info[i] ); 236 s += 3; 237 } 238 239 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn ); 240 msn_write( gc, buf, strlen( buf ) ); 241 g_free( fn ); 222 msn_set_display_name( set_find( &gc->acc->set, "display_name" ), info ); 242 223 } 243 224 … … 378 359 } 379 360 361 static char *msn_set_display_name( set_t *set, char *value ) 362 { 363 account_t *acc = set->data; 364 struct gaim_connection *gc = acc->gc; 365 struct msn_data *md; 366 char buf[1024], *fn, *s; 367 int i; 368 369 /* Double-check. */ 370 if( gc == NULL ) 371 return NULL; 372 373 md = gc->proto_data; 374 375 if( strlen( value ) > 129 ) 376 { 377 serv_got_crap( gc, "Maximum name length exceeded" ); 378 return NULL; 379 } 380 381 /* Of course we could use http_encode() here, but when we encode 382 every character, the server is less likely to complain about the 383 chosen name. However, the MSN server doesn't seem to like escaped 384 non-ASCII chars, so we keep those unescaped. */ 385 s = fn = g_new0( char, strlen( value ) * 3 + 1 ); 386 for( i = 0; value[i]; i ++ ) 387 if( value[i] & 128 ) 388 { 389 *s = value[i]; 390 s ++; 391 } 392 else 393 { 394 g_snprintf( s, 4, "%%%02X", value[i] ); 395 s += 3; 396 } 397 398 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn ); 399 msn_write( gc, buf, strlen( buf ) ); 400 g_free( fn ); 401 402 /* Returning NULL would be better, because the server still has to 403 confirm the name change. However, it looks a bit confusing to the 404 user. */ 405 return value; 406 } 407 380 408 void msn_init() 381 409 { 382 410 struct prpl *ret = g_new0(struct prpl, 1); 411 383 412 ret->name = "msn"; 384 413 ret->login = msn_login; 414 ret->acc_init = msn_acc_init; 385 415 ret->close = msn_close; 386 416 ret->send_im = msn_send_im; -
protocols/msn/ns.c
r96863f6 r911f2eb 223 223 else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 ) 224 224 { 225 set_t *s; 226 225 227 http_decode( cmd[4] ); 226 228 227 229 strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) ); 228 230 gc->displayname[sizeof(gc->displayname)-1] = 0; 231 232 if( ( s = set_find( &gc->acc->set, "display_name" ) ) ) 233 { 234 g_free( s->value ); 235 s->value = g_strdup( cmd[4] ); 236 } 229 237 230 238 set_login_progress( gc, 1, "Authenticated, getting buddy list" ); … … 517 525 if( g_strcasecmp( cmd[3], gc->username ) == 0 ) 518 526 { 527 set_t *s; 528 519 529 http_decode( cmd[4] ); 520 530 strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) ); 521 531 gc->displayname[sizeof(gc->displayname)-1] = 0; 532 533 if( ( s = set_find( &gc->acc->set, "display_name" ) ) ) 534 { 535 g_free( s->value ); 536 s->value = g_strdup( cmd[4] ); 537 } 522 538 } 523 539 else
Note: See TracChangeset
for help on using the changeset viewer.