Changes in protocols/msn/msn.c [bf25fa3:5b52a48]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
rbf25fa3 r5b52a48 27 27 #include "msn.h" 28 28 29 static void msn_login( struct aim_user *acct ) 30 { 31 struct gaim_connection *gc = new_gaim_conn( acct ); 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 } 38 39 static void msn_login( account_t *acc ) 40 { 41 struct gaim_connection *gc = new_gaim_conn( acc ); 32 42 struct msn_data *md = g_new0( struct msn_data, 1 ); 33 43 … … 37 47 md->fd = -1; 38 48 39 if( strchr( acc t->username, '@' ) == NULL )49 if( strchr( acc->user, '@' ) == NULL ) 40 50 { 41 51 hide_login_progress( gc, "Invalid account name" ); … … 95 105 } 96 106 97 while( md->groupcount > 0 )98 g_free( md->grouplist[--md->groupcount] );99 107 g_free( md->grouplist ); 100 108 … … 212 220 static void msn_set_info( struct gaim_connection *gc, char *info ) 213 221 { 214 int i; 215 char buf[1024], *fn, *s; 216 struct msn_data *md = gc->proto_data; 217 218 if( strlen( info ) > 129 ) 219 { 220 do_error_dialog( gc, "Maximum name length exceeded", "MSN" ); 221 return; 222 } 223 224 /* Of course we could use http_encode() here, but when we encode 225 every character, the server is less likely to complain about the 226 chosen name. However, the MSN server doesn't seem to like escaped 227 non-ASCII chars, so we keep those unescaped. */ 228 s = fn = g_new0( char, strlen( info ) * 3 + 1 ); 229 for( i = 0; info[i]; i ++ ) 230 if( info[i] & 128 ) 231 { 232 *s = info[i]; 233 s ++; 234 } 235 else 236 { 237 g_snprintf( s, 4, "%%%02X", info[i] ); 238 s += 3; 239 } 240 241 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn ); 242 msn_write( gc, buf, strlen( buf ) ); 243 g_free( fn ); 222 msn_set_display_name( set_find( &gc->acc->set, "display_name" ), info ); 244 223 } 245 224 … … 380 359 } 381 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 382 408 void msn_init() 383 409 { 384 410 struct prpl *ret = g_new0(struct prpl, 1); 411 385 412 ret->name = "msn"; 386 413 ret->login = msn_login; 414 ret->acc_init = msn_acc_init; 387 415 ret->close = msn_close; 388 416 ret->send_im = msn_send_im; … … 404 432 ret->rem_deny = msn_rem_deny; 405 433 ret->send_typing = msn_send_typing; 406 ret-> cmp_buddynames= g_strcasecmp;434 ret->handle_cmp = g_strcasecmp; 407 435 408 436 register_protocol(ret);
Note: See TracChangeset
for help on using the changeset viewer.