Changes in protocols/msn/msn.c [5b52a48:bf25fa3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r5b52a48 rbf25fa3 27 27 #include "msn.h" 28 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 } 38 39 static void msn_login( account_t *acc ) 40 { 41 struct gaim_connection *gc = new_gaim_conn( acc ); 29 static void msn_login( struct aim_user *acct ) 30 { 31 struct gaim_connection *gc = new_gaim_conn( acct ); 42 32 struct msn_data *md = g_new0( struct msn_data, 1 ); 43 33 … … 47 37 md->fd = -1; 48 38 49 if( strchr( acc ->user, '@' ) == NULL )39 if( strchr( acct->username, '@' ) == NULL ) 50 40 { 51 41 hide_login_progress( gc, "Invalid account name" ); … … 105 95 } 106 96 97 while( md->groupcount > 0 ) 98 g_free( md->grouplist[--md->groupcount] ); 107 99 g_free( md->grouplist ); 108 100 … … 220 212 static void msn_set_info( struct gaim_connection *gc, char *info ) 221 213 { 222 msn_set_display_name( set_find( &gc->acc->set, "display_name" ), info ); 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 ); 223 244 } 224 245 … … 359 380 } 360 381 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 encode382 every character, the server is less likely to complain about the383 chosen name. However, the MSN server doesn't seem to like escaped384 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 else393 {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 to403 confirm the name change. However, it looks a bit confusing to the404 user. */405 return value;406 }407 408 382 void msn_init() 409 383 { 410 384 struct prpl *ret = g_new0(struct prpl, 1); 411 412 385 ret->name = "msn"; 413 386 ret->login = msn_login; 414 ret->acc_init = msn_acc_init;415 387 ret->close = msn_close; 416 388 ret->send_im = msn_send_im; … … 432 404 ret->rem_deny = msn_rem_deny; 433 405 ret->send_typing = msn_send_typing; 434 ret-> handle_cmp= g_strcasecmp;406 ret->cmp_buddynames = g_strcasecmp; 435 407 436 408 register_protocol(ret);
Note: See TracChangeset
for help on using the changeset viewer.