Changeset 5a7af1b
- Timestamp:
- 2010-08-15T13:02:52Z (14 years ago)
- Branches:
- master
- Children:
- 660cb00
- Parents:
- ff27648
- Location:
- protocols/msn
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.h
rff27648 r5a7af1b 94 94 const struct msn_away_state *away_state; 95 95 GSList *groups; 96 97 /* Mostly used for sending the ADL command; since MSNP13 the client 98 is responsible for downloading the contact list and then sending 99 it to the MSNP server. */ 96 100 GTree *domaintree; 101 int adl_todo; 97 102 }; 98 103 … … 164 169 MSN_BUDDY_RL = 8, 165 170 MSN_BUDDY_PL = 16, 171 MSN_BUDDY_ADL_SYNCED = 256, 166 172 } msn_buddy_flags_t; 167 173 -
protocols/msn/ns.c
rff27648 r5a7af1b 35 35 static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ); 36 36 37 static void msn_ns_send_adl_start( struct im_connection *ic ); 37 38 static void msn_ns_send_adl( struct im_connection *ic ); 38 39 … … 257 258 else if( strcmp( cmd[0], "BLP" ) == 0 ) 258 259 { 259 msn_ns_send_adl ( ic );260 msn_ns_send_adl_start( ic ); 260 261 } 261 262 else if( strcmp( cmd[0], "ADL" ) == 0 ) … … 263 264 if( num_parts >= 3 && strcmp( cmd[2], "OK" ) == 0 ) 264 265 { 265 char buf[1024]; 266 char *fn_raw; 267 char *fn; 268 269 if( ic->flags & OPT_LOGGED_IN ) 270 return 1; 271 272 if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL ) 273 fn_raw = ic->acc->user; 274 fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); 275 strcpy( fn, fn_raw ); 276 http_encode( fn ); 277 278 g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", 279 ++md->trId, fn ); 280 g_free( fn ); 281 282 msn_write( ic, buf, strlen( buf ) ); 266 msn_ns_send_adl( ic ); 267 268 if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) 269 { 270 char buf[1024]; 271 char *fn_raw; 272 char *fn; 273 274 if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL ) 275 fn_raw = ic->acc->user; 276 fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); 277 strcpy( fn, fn_raw ); 278 http_encode( fn ); 279 280 g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", 281 ++md->trId, fn ); 282 g_free( fn ); 283 284 msn_write( ic, buf, strlen( buf ) ); 285 } 283 286 } 284 287 else if( num_parts >= 3 ) … … 733 736 struct bee_user *bu = value; 734 737 struct msn_buddy_data *bd = bu->data; 738 struct msn_data *md = bu->ic->proto_data; 735 739 char handle[strlen(bu->handle)]; 736 740 char *domain; 737 741 char l[4]; 738 742 739 if( ( bd->flags & 7 ) == 0 )743 if( ( bd->flags & 7 ) == 0 || ( bd->flags & MSN_BUDDY_ADL_SYNCED ) ) 740 744 return FALSE; 741 745 … … 761 765 xt_insert_child( d, c ); 762 766 763 return FALSE; 767 /* Do this in batches of 100. */ 768 bd->flags |= MSN_BUDDY_ADL_SYNCED; 769 return (--md->adl_todo % 140) == 0; 764 770 } 765 771 … … 767 773 { 768 774 struct xt_node *adl; 775 struct msn_data *md = ic->proto_data; 776 char *adls, buf[64]; 777 778 adl = xt_new_node( "ml", NULL, NULL ); 779 xt_add_attr( adl, "l", "1" ); 780 g_tree_foreach( md->domaintree, msn_ns_send_adl_1, adl ); 781 if( adl->children == NULL ) 782 { 783 /* This tells the caller that we're done now. */ 784 md->adl_todo = -1; 785 xt_free_node( adl ); 786 return; 787 } 788 adls = xt_to_string( adl ); 789 790 g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n", ++md->trId, strlen( adls ) ); 791 if( msn_write( ic, buf, strlen( buf ) ) ) 792 msn_write( ic, adls, strlen( adls ) ); 793 794 g_free( adls ); 795 } 796 797 static void msn_ns_send_adl_start( struct im_connection *ic ) 798 { 769 799 struct msn_data *md; 770 char *adls, buf[64];800 GSList *l; 771 801 772 802 /* Dead connection? */ … … 775 805 776 806 md = ic->proto_data; 777 778 adl = xt_new_node( "ml", NULL, NULL ); 779 xt_add_attr( adl, "l", "1" ); 780 g_tree_foreach( md->domaintree, msn_ns_send_adl_1, adl ); 781 adls = xt_to_string( adl ); 782 783 g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n", ++md->trId, strlen( adls ) ); 784 if( msn_write( ic, buf, strlen( buf ) ) ) 785 msn_write( ic, adls, strlen( adls ) ); 786 787 g_free( adls ); 788 xt_free_node( adl ); 807 md->adl_todo = 0; 808 for( l = ic->bee->users; l; l = l->next ) 809 { 810 bee_user_t *bu = l->data; 811 struct msn_buddy_data *bd = bu->data; 812 813 if( bu->ic != ic || ( bd->flags & 7 ) == 0 ) 814 continue; 815 816 bd->flags &= ~MSN_BUDDY_ADL_SYNCED; 817 md->adl_todo++; 818 } 819 820 msn_ns_send_adl( ic ); 789 821 }
Note: See TracChangeset
for help on using the changeset viewer.