Changeset ca7de3a for protocols/msn
- Timestamp:
- 2010-08-12T22:13:26Z (14 years ago)
- Branches:
- master
- Children:
- be7a180
- Parents:
- 7f34ce2
- Location:
- protocols/msn
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r7f34ce2 rca7de3a 68 68 md->ic = ic; 69 69 md->away_state = msn_away_state_list; 70 md->domaintree = g_tree_new( msn_domaintree_cmp ); 70 71 71 72 msn_connections = g_slist_append( msn_connections, ic ); … … 106 107 g_free( md->tokens[1] ); 107 108 g_free( md->lock_key ); 109 110 g_tree_destroy( md->domaintree ); 111 md->domaintree = NULL; 108 112 109 113 while( md->grpq ) … … 336 340 static void msn_buddy_data_add( bee_user_t *bu ) 337 341 { 342 struct msn_data *md = bu->ic->proto_data; 338 343 bu->data = g_new0( struct msn_buddy_data, 1 ); 344 g_tree_insert( md->domaintree, bu->handle, bu ); 339 345 } 340 346 341 347 static void msn_buddy_data_free( bee_user_t *bu ) 342 348 { 349 struct msn_data *md = bu->ic->proto_data; 350 g_tree_remove( md->domaintree, bu->handle ); 343 351 g_free( bu->data ); 344 352 } -
protocols/msn/msn.h
r7f34ce2 rca7de3a 89 89 int groupcount; 90 90 char **grouplist; 91 GTree *domaintree; 91 92 }; 92 93 … … 153 154 typedef enum 154 155 { 155 MSN_BUDDY_FL = 1, 156 MSN_BUDDY_FL = 1, /* Warning: FL,AL,BL *must* be 1,2,4. */ 156 157 MSN_BUDDY_AL = 2, 157 158 MSN_BUDDY_BL = 4, … … 187 188 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ); 188 189 void msn_auth_got_passport_token( struct im_connection *ic, char *token ); 190 void msn_auth_got_contact_list( struct im_connection *ic ); 189 191 190 192 /* msn_util.c */ … … 201 203 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ); 202 204 char *msn_p11_challenge( char *challenge ); 205 gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ ); 203 206 204 207 /* tables.c */ -
protocols/msn/msn_util.c
r7f34ce2 rca7de3a 528 528 return output; 529 529 } 530 531 gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ ) 532 { 533 const char *a = a_, *b = b_; 534 gint ret; 535 536 if( !( a = strchr( a, '@' ) ) || !( b = strchr( b, '@' ) ) || 537 ( ret = strcmp( a, b ) ) == 0 ) 538 ret = strcmp( a_, b_ ); 539 540 return ret; 541 } -
protocols/msn/ns.c
r7f34ce2 rca7de3a 27 27 #include "nogaim.h" 28 28 #include "msn.h" 29 #include "passport.h"30 29 #include "md5.h" 31 30 #include "soap.h" 31 #include "xmltree.h" 32 32 33 33 static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ); … … 36 36 37 37 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ); 38 static void msn_ns_send_adl( struct im_connection *ic ); 38 39 39 40 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) … … 135 136 int port; 136 137 137 if( num_parts == 6 && strcmp( cmd[2], "NS" ) == 0 )138 if( num_parts >= 6 && strcmp( cmd[2], "NS" ) == 0 ) 138 139 { 139 140 b_event_remove( ic->inpa ); … … 156 157 md->fd = proxy_connect( server, port, msn_ns_connected, ic ); 157 158 } 158 else if( num_parts == 6 && strcmp( cmd[2], "SB" ) == 0 )159 else if( num_parts >= 6 && strcmp( cmd[2], "SB" ) == 0 ) 159 160 { 160 161 struct msn_switchboard *sb; … … 261 262 } 262 263 } 263 else if( strcmp( cmd[0], "SYN" ) == 0 ) 264 { 265 if( num_parts == 5 ) 266 { 267 int i, groupcount; 268 269 groupcount = atoi( cmd[4] ); 270 if( groupcount > 0 ) 271 { 272 /* valgrind says this is leaking memory, I'm guessing 273 that this happens during server redirects. */ 274 if( md->grouplist ) 275 { 276 for( i = 0; i < md->groupcount; i ++ ) 277 g_free( md->grouplist[i] ); 278 g_free( md->grouplist ); 279 } 280 281 md->groupcount = groupcount; 282 md->grouplist = g_new0( char *, md->groupcount ); 283 } 284 285 md->buddycount = atoi( cmd[3] ); 286 if( !*cmd[3] || md->buddycount == 0 ) 287 msn_logged_in( ic ); 288 } 289 else 290 { 291 /* Hrrm... This SYN reply doesn't really look like something we expected. 292 Let's assume everything is okay. */ 293 294 msn_logged_in( ic ); 295 } 296 } 297 else if( strcmp( cmd[0], "LST" ) == 0 ) 298 { 299 int list; 300 301 if( num_parts != 4 && num_parts != 5 ) 302 { 303 imcb_error( ic, "Syntax error" ); 304 imc_logout( ic, TRUE ); 305 return( 0 ); 306 } 307 308 http_decode( cmd[2] ); 309 list = atoi( cmd[3] ); 310 311 if( list & 1 ) /* FL */ 312 { 313 char *group = NULL; 314 int num; 315 316 if( cmd[4] != NULL && sscanf( cmd[4], "%d", &num ) == 1 && num < md->groupcount ) 317 group = md->grouplist[num]; 318 319 imcb_add_buddy( ic, cmd[1], group ); 320 imcb_rename_buddy( ic, cmd[1], cmd[2] ); 321 } 322 if( list & 2 ) /* AL */ 323 { 324 ic->permit = g_slist_append( ic->permit, g_strdup( cmd[1] ) ); 325 } 326 if( list & 4 ) /* BL */ 327 { 328 ic->deny = g_slist_append( ic->deny, g_strdup( cmd[1] ) ); 329 } 330 if( list & 8 ) /* RL */ 331 { 332 if( ( list & 6 ) == 0 ) 333 msn_buddy_ask( ic, cmd[1], cmd[2] ); 334 } 335 336 if( --md->buddycount == 0 ) 337 { 338 if( ic->flags & OPT_LOGGED_IN ) 339 { 340 imcb_log( ic, "Successfully transferred to different server" ); 341 g_snprintf( buf, sizeof( buf ), "CHG %d %s %d\r\n", ++md->trId, md->away_state->code, 0 ); 342 return( msn_write( ic, buf, strlen( buf ) ) ); 343 } 344 else 345 { 346 msn_logged_in( ic ); 347 } 348 } 349 } 350 else if( strcmp( cmd[0], "LSG" ) == 0 ) 351 { 352 int num; 353 354 if( num_parts != 4 ) 355 { 356 imcb_error( ic, "Syntax error" ); 357 imc_logout( ic, TRUE ); 358 return( 0 ); 359 } 360 361 http_decode( cmd[2] ); 362 num = atoi( cmd[1] ); 363 364 if( num < md->groupcount ) 365 md->grouplist[num] = g_strdup( cmd[2] ); 264 else if( strcmp( cmd[0], "BLP" ) == 0 ) 265 { 266 msn_ns_send_adl( ic ); 267 } 268 else if( strcmp( cmd[0], "ADL" ) == 0 ) 269 { 270 if( num_parts >= 3 && strcmp( cmd[2], "OK" ) == 0 ) 271 { 272 char buf[1024]; 273 char *fn_raw = set_getstr( &ic->acc->set, "display_name" ); 274 char *fn; 275 276 if( fn_raw == NULL ) 277 fn_raw = ic->acc->user; 278 fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); 279 strcpy( fn, fn_raw ); 280 http_encode( fn ); 281 282 g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", 283 ++md->trId, fn ); 284 g_free( fn ); 285 286 msn_write( ic, buf, strlen( buf ) ); 287 } 288 } 289 else if( strcmp( cmd[0], "PRP" ) == 0 ) 290 { 291 imcb_connected( ic ); 366 292 } 367 293 else if( strcmp( cmd[0], "CHL" ) == 0 ) … … 393 319 const struct msn_away_state *st; 394 320 395 if( num_parts !=6 )396 { 397 imcb_error( ic, "Syntax error" ); 398 imc_logout( ic, TRUE ); 399 return( 0 ); 400 } 401 402 http_decode( cmd[ 4] );403 imcb_rename_buddy( ic, cmd[3], cmd[ 4] );321 if( num_parts < 6 ) 322 { 323 imcb_error( ic, "Syntax error" ); 324 imc_logout( ic, TRUE ); 325 return( 0 ); 326 } 327 328 http_decode( cmd[5] ); 329 imcb_rename_buddy( ic, cmd[3], cmd[5] ); 404 330 405 331 st = msn_away_state_by_code( cmd[2] ); … … 787 713 } 788 714 715 void msn_auth_got_contact_list( struct im_connection *ic ) 716 { 717 char buf[64]; 718 struct msn_data *md; 719 720 /* Dead connection? */ 721 if( g_slist_find( msn_connections, ic ) == NULL ) 722 return; 723 724 md = ic->proto_data; 725 726 727 g_snprintf( buf, sizeof( buf ), "BLP %d %s\r\n", ++md->trId, "BL" ); 728 msn_write( ic, buf, strlen( buf ) ); 729 } 730 731 static gboolean msn_ns_send_adl_1( gpointer key, gpointer value, gpointer data ) 732 { 733 struct xt_node *adl = data, *d, *c; 734 struct bee_user *bu = value; 735 struct msn_buddy_data *bd = bu->data; 736 char handle[strlen(bu->handle)]; 737 char *domain; 738 char l[4]; 739 740 strcpy( handle, bu->handle ); 741 if( ( domain = strchr( handle, '@' ) ) == NULL ) /* WTF */ 742 return FALSE; 743 *domain = '\0'; 744 domain ++; 745 746 if( ( d = adl->children ) == NULL || 747 g_strcasecmp( xt_find_attr( d, "n" ), domain ) != 0 ) 748 { 749 d = xt_new_node( "d", NULL, NULL ); 750 xt_add_attr( d, "n", domain ); 751 xt_insert_child( adl, d ); 752 } 753 754 g_snprintf( l, sizeof( l ), "%d", bd->flags & 7 ); 755 c = xt_new_node( "c", NULL, NULL ); 756 xt_add_attr( c, "n", handle ); 757 xt_add_attr( c, "l", l ); 758 xt_add_attr( c, "t", "1" ); /* 1 means normal, 4 means mobile? */ 759 xt_insert_child( d, c ); 760 761 return FALSE; 762 } 763 764 static void msn_ns_send_adl( struct im_connection *ic ) 765 { 766 struct xt_node *adl; 767 struct msn_data *md; 768 char *adls, buf[64]; 769 770 /* Dead connection? */ 771 if( g_slist_find( msn_connections, ic ) == NULL ) 772 return; 773 774 md = ic->proto_data; 775 776 adl = xt_new_node( "ml", NULL, NULL ); 777 xt_add_attr( adl, "l", "1" ); 778 g_tree_foreach( md->domaintree, msn_ns_send_adl_1, adl ); 779 adls = xt_to_string( adl ); 780 781 g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n", ++md->trId, strlen( adls ) ); 782 if( msn_write( ic, buf, strlen( buf ) ) ) 783 msn_write( ic, adls, strlen( adls ) ); 784 785 g_free( adls ); 786 xt_free_node( adl ); 787 } 788 789 789 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name ) 790 790 { -
protocols/msn/soap.c
r7f34ce2 rca7de3a 578 578 static int msn_soap_addressbook_handle_response( struct msn_soap_req_data *soap_req ) 579 579 { 580 msn_auth_got_contact_list( soap_req->ic ); 580 581 return MSN_SOAP_OK; 581 582 }
Note: See TracChangeset
for help on using the changeset viewer.