Changeset d8d63a2 for protocols/msn
- Timestamp:
- 2006-12-05T20:40:17Z (18 years ago)
- Branches:
- master
- Children:
- 7740c4c
- Parents:
- f4aa393 (diff), 55078f5 (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
rf4aa393 rd8d63a2 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 34 set_login_progress( gc, 1, "Connecting" );35 43 36 44 gc->proto_data = md; 37 45 md->fd = -1; 38 46 39 if( strchr( acc t->username, '@' ) == NULL )47 if( strchr( acc->user, '@' ) == NULL ) 40 48 { 41 49 hide_login_progress( gc, "Invalid account name" ); … … 44 52 } 45 53 54 set_login_progress( gc, 1, "Connecting" ); 55 46 56 md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, gc ); 47 57 if( md->fd < 0 ) … … 49 59 hide_login_progress( gc, "Could not connect to server" ); 50 60 signoff( gc ); 51 } 52 else 53 { 54 md->gc = gc; 55 md->away_state = msn_away_state_list; 56 57 msn_connections = g_slist_append( msn_connections, gc ); 58 } 61 return; 62 } 63 64 md->gc = gc; 65 md->away_state = msn_away_state_list; 66 67 msn_connections = g_slist_append( msn_connections, gc ); 59 68 } 60 69 … … 212 221 static void msn_set_info( struct gaim_connection *gc, char *info ) 213 222 { 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 msn_set_display_name( set_find( &gc->acc->set, "display_name" ), info ); 244 224 } 245 225 … … 380 360 } 381 361 362 static char *msn_set_display_name( set_t *set, char *value ) 363 { 364 account_t *acc = set->data; 365 struct gaim_connection *gc = acc->gc; 366 struct msn_data *md; 367 char buf[1024], *fn; 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 fn = msn_http_encode( value ); 382 383 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn ); 384 msn_write( gc, buf, strlen( buf ) ); 385 g_free( fn ); 386 387 /* Returning NULL would be better, because the server still has to 388 confirm the name change. However, it looks a bit confusing to the 389 user. */ 390 return value; 391 } 392 382 393 void msn_init() 383 394 { 384 395 struct prpl *ret = g_new0(struct prpl, 1); 396 385 397 ret->name = "msn"; 386 398 ret->login = msn_login; 399 ret->acc_init = msn_acc_init; 387 400 ret->close = msn_close; 388 401 ret->send_im = msn_send_im; … … 404 417 ret->rem_deny = msn_rem_deny; 405 418 ret->send_typing = msn_send_typing; 406 ret-> cmp_buddynames= g_strcasecmp;419 ret->handle_cmp = g_strcasecmp; 407 420 408 421 register_protocol(ret); -
protocols/msn/msn.h
rf4aa393 rd8d63a2 157 157 char **msn_linesplit( char *line ); 158 158 int msn_handler( struct msn_handler_data *h ); 159 char *msn_http_encode( const char *input ); 159 160 160 161 /* tables.c */ -
protocols/msn/msn_util.c
rf4aa393 rd8d63a2 54 54 { 55 55 struct msn_data *md = gc->proto_data; 56 GSList *l, **lp = NULL;57 56 char buf[1024], *realname; 58 57 59 if( strcmp( list, "AL" ) == 0 ) 60 lp = &gc->permit; 61 else if( strcmp( list, "BL" ) == 0 ) 62 lp = &gc->deny; 63 64 if( lp ) 65 for( l = *lp; l; l = l->next ) 66 if( g_strcasecmp( l->data, who ) == 0 ) 67 return( 1 ); 68 69 realname = g_new0( char, strlen( realname_ ) * 3 + 1 ); 70 strcpy( realname, realname_ ); 71 http_encode( realname ); 58 realname = msn_http_encode( realname_ ); 72 59 73 60 g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname ); … … 76 63 g_free( realname ); 77 64 78 if( lp )79 *lp = g_slist_append( *lp, g_strdup( who ) );80 81 65 return( 1 ); 82 66 } … … 90 74 { 91 75 struct msn_data *md = gc->proto_data; 92 GSList *l = NULL, **lp = NULL;93 76 char buf[1024]; 94 95 if( strcmp( list, "AL" ) == 0 )96 lp = &gc->permit;97 else if( strcmp( list, "BL" ) == 0 )98 lp = &gc->deny;99 100 if( lp )101 {102 for( l = *lp; l; l = l->next )103 if( g_strcasecmp( l->data, who ) == 0 )104 break;105 106 if( !l )107 return( 1 );108 }109 77 110 78 g_snprintf( buf, sizeof( buf ), "REM %d %s %s\r\n", ++md->trId, list, who ); 111 79 if( msn_write( gc, buf, strlen( buf ) ) ) 112 {113 if( lp )114 *lp = g_slist_remove( *lp, l->data );115 116 80 return( 1 ); 117 }118 81 119 82 return( 0 ); … … 350 313 return( 1 ); 351 314 } 315 316 /* The difference between this function and the normal http_encode() function 317 is that this one escapes every 7-bit ASCII character because this is said 318 to avoid some lame server-side checks when setting a real-name. Also, 319 non-ASCII characters are not escaped because MSN servers don't seem to 320 appreciate that! */ 321 char *msn_http_encode( const char *input ) 322 { 323 char *ret, *s; 324 int i; 325 326 ret = s = g_new0( char, strlen( input ) * 3 + 1 ); 327 for( i = 0; input[i]; i ++ ) 328 if( input[i] & 128 ) 329 { 330 *s = input[i]; 331 s ++; 332 } 333 else 334 { 335 g_snprintf( s, 4, "%%%02X", input[i] ); 336 s += 3; 337 } 338 339 return ret; 340 } -
protocols/msn/ns.c
rf4aa393 rd8d63a2 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 -
protocols/msn/passport.c
rf4aa393 rd8d63a2 59 59 rep->data = data; 60 60 rep->func = func; 61 rep->header = header; 61 62 62 63 server = g_strdup( prd_cached ); … … 125 126 static char *passport_create_header( char *cookie, char *email, char *pwd ) 126 127 { 127 char *buffer = g_new0( char, 2048 );128 char *buffer; 128 129 char *currenttoken; 129 130 char *email_enc, *pwd_enc; 131 132 currenttoken = strstr( cookie, "lc=" ); 133 if( currenttoken == NULL ) 134 return NULL; 130 135 131 136 email_enc = g_new0( char, strlen( email ) * 3 + 1 ); … … 137 142 http_encode( pwd_enc ); 138 143 139 currenttoken = strstr( cookie, "lc=" ); 140 if( currenttoken == NULL ) 141 return( NULL ); 142 143 g_snprintf( buffer, 2048, 144 "Authorization: Passport1.4 OrgVerb=GET," 145 "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom," 146 "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc, 147 currenttoken ); 144 buffer = g_strdup_printf( "Authorization: Passport1.4 OrgVerb=GET," 145 "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom," 146 "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc, 147 currenttoken ); 148 148 149 149 g_free( email_enc ); 150 150 g_free( pwd_enc ); 151 151 152 return ( buffer );152 return buffer; 153 153 } 154 154 … … 212 212 if( passport_get_id_real( rep->func, rep->data, rep->header ) ) 213 213 { 214 rep->header = NULL; 214 215 destroy_reply( rep ); 215 216 return;
Note: See TracChangeset
for help on using the changeset viewer.