comparison libgaim/protocols/msn/userlist.c @ 20390:d634f88e25d8

msn.tgz from SF Patch #1621854 from Ka-Hing Cheung "This tarball brings soc-2006-msnp13 up to head. In addition to that it also fixes a crash with sending offline messages. I wasn't able to generate a diff against that branch, svn seems to insist on diff'ing against HEAD after I run the merge command. After running `svn merge -r 16309:HEAD https://gaim.svn.sourceforge.net/svnroot/gaim/trunk` on the soc-2006-msnp13 you can replace the msn directory with the attached tarball. The fix for offline messaging is on msn.c:901: if (!session->oim) session->oim = msn_oim_new(session)" committer: Richard Laager <rlaager@wiktel.com>
author Ka-Hing Cheung <khc@hxbc.us>
date Sun, 15 Apr 2007 02:18:17 +0000
parents e354528c4163
children 9ba7dee775e1 9755b2f7bb0f
comparison
equal deleted inserted replaced
20389:e354528c4163 20390:d634f88e25d8
38 * Callbacks 38 * Callbacks
39 **************************************************************************/ 39 **************************************************************************/
40 static void 40 static void
41 msn_accept_add_cb(MsnPermitAdd *pa) 41 msn_accept_add_cb(MsnPermitAdd *pa)
42 { 42 {
43 MsnSession *session = pa->gc->proto_data;
44 MsnUserList *userlist = session->userlist;
45
46 msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL);
47
48 g_free(pa->who);
49 g_free(pa->friendly);
50 g_free(pa);
51 }
52
53 static void
54 msn_cancel_add_cb(MsnPermitAdd *pa)
55 {
43 if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL) 56 if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL)
44 { 57 {
45 MsnSession *session = pa->gc->proto_data; 58 MsnSession *session = pa->gc->proto_data;
46 MsnUserList *userlist = session->userlist; 59 MsnUserList *userlist = session->userlist;
47 GaimBuddy *buddy; 60
48 61 msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL);
49 msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL);
50
51 buddy = gaim_find_buddy(pa->gc->account, pa->who);
52
53 if (buddy != NULL)
54 gaim_account_notify_added(pa->gc->account, pa->who,
55 NULL, pa->friendly, NULL);
56 else
57 gaim_account_request_add(pa->gc->account, pa->who,
58 NULL, pa->friendly, NULL);
59 } 62 }
60 63
61 g_free(pa->who); 64 g_free(pa->who);
62 g_free(pa->friendly); 65 g_free(pa->friendly);
63 g_free(pa); 66 g_free(pa);
64 } 67 }
65 68
66 static void 69 static void
67 msn_cancel_add_cb(MsnPermitAdd *pa)
68 {
69 if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL)
70 {
71 MsnSession *session = pa->gc->proto_data;
72 MsnUserList *userlist = session->userlist;
73
74 msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL);
75 }
76
77 g_free(pa->who);
78 g_free(pa->friendly);
79 g_free(pa);
80 }
81
82 static void
83 got_new_entry(GaimConnection *gc, const char *passport, const char *friendly) 70 got_new_entry(GaimConnection *gc, const char *passport, const char *friendly)
84 { 71 {
85 MsnPermitAdd *pa; 72 MsnPermitAdd *pa;
86 char *msg;
87 73
88 pa = g_new0(MsnPermitAdd, 1); 74 pa = g_new0(MsnPermitAdd, 1);
89 pa->who = g_strdup(passport); 75 pa->who = g_strdup(passport);
90 pa->friendly = g_strdup(friendly); 76 pa->friendly = g_strdup(friendly);
91 pa->gc = gc; 77 pa->gc = gc;
92 78
93 if (friendly != NULL) 79 gaim_account_request_authorization(gaim_connection_get_account(gc), passport, NULL, friendly, NULL,
94 { 80 gaim_find_buddy(gaim_connection_get_account(gc), passport) != NULL,
95 msg = g_strdup_printf( 81 G_CALLBACK(msn_accept_add_cb), G_CALLBACK(msn_cancel_add_cb), pa);
96 _("The user %s (%s) wants to add %s to his or her " 82
97 "buddy list."),
98 passport, friendly,
99 gaim_account_get_username(gc->account));
100 }
101 else
102 {
103 msg = g_strdup_printf(
104 _("The user %s wants to add %s to his or "
105 "her buddy list."),
106 passport, gaim_account_get_username(gc->account));
107 }
108
109 gaim_request_action(gc, NULL, msg, NULL,
110 GAIM_DEFAULT_ACTION_NONE, pa, 2,
111 _("Authorize"), G_CALLBACK(msn_accept_add_cb),
112 _("Deny"), G_CALLBACK(msn_cancel_add_cb));
113
114 g_free(msg);
115 } 83 }
116 84
117 /************************************************************************** 85 /**************************************************************************
118 * Utility functions 86 * Utility functions
119 **************************************************************************/ 87 **************************************************************************/
186 msn_request_add_group(MsnUserList *userlist, const char *who, 154 msn_request_add_group(MsnUserList *userlist, const char *who,
187 const char *old_group_name, const char *new_group_name) 155 const char *old_group_name, const char *new_group_name)
188 { 156 {
189 MsnSession *session; 157 MsnSession *session;
190 MsnCmdProc *cmdproc; 158 MsnCmdProc *cmdproc;
191 MsnTransaction *trans;
192 MsnMoveBuddy *data; 159 MsnMoveBuddy *data;
193 160
194 session = userlist->session; 161 session = userlist->session;
195 cmdproc = session->notification->cmdproc; 162 cmdproc = session->notification->cmdproc;
196 data = g_new0(MsnMoveBuddy, 1); 163 data = g_new0(MsnMoveBuddy, 1);
204 } 171 }
205 172
206 /*add new group via SOAP action*/ 173 /*add new group via SOAP action*/
207 msn_add_group(session, new_group_name); 174 msn_add_group(session, new_group_name);
208 175
209 msn_transaction_set_data(trans, data);
210
211 msn_cmdproc_send_trans(cmdproc, trans);
212 } 176 }
213 177
214 /************************************************************************** 178 /**************************************************************************
215 * Server functions 179 * Server functions
216 **************************************************************************/ 180 **************************************************************************/
253 serv_got_alias(gc, passport, friendly); 217 serv_got_alias(gc, passport, friendly);
254 218
255 if (group_id != NULL) 219 if (group_id != NULL)
256 { 220 {
257 msn_user_add_group_id(user, group_id); 221 msn_user_add_group_id(user, group_id);
258 } 222 }else{
259 else
260 {
261 /* session->sync->fl_users_count++; */ 223 /* session->sync->fl_users_count++; */
262 } 224 }
263 } 225 }else if (list_id == MSN_LIST_AL){
264 else if (list_id == MSN_LIST_AL)
265 {
266 gaim_privacy_permit_add(account, passport, TRUE); 226 gaim_privacy_permit_add(account, passport, TRUE);
267 } 227 }else if (list_id == MSN_LIST_BL){
268 else if (list_id == MSN_LIST_BL)
269 {
270 gaim_privacy_deny_add(account, passport, TRUE); 228 gaim_privacy_deny_add(account, passport, TRUE);
271 } 229 }else if (list_id == MSN_LIST_RL){
272 else if (list_id == MSN_LIST_RL)
273 {
274 GaimConnection *gc; 230 GaimConnection *gc;
275 GaimConversation *convo; 231 GaimConversation *convo;
276 232
277 gc = gaim_account_get_connection(account); 233 gc = gaim_account_get_connection(account);
278 234
292 gaim_conv_im_write(GAIM_CONV_IM(convo), passport, msg, 248 gaim_conv_im_write(GAIM_CONV_IM(convo), passport, msg,
293 GAIM_MESSAGE_SYSTEM, time(NULL)); 249 GAIM_MESSAGE_SYSTEM, time(NULL));
294 g_free(msg); 250 g_free(msg);
295 } 251 }
296 252
297 if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) 253 if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))){
298 {
299 /* 254 /*
300 * TODO: The friendly name was NULL for me when I 255 * TODO: The friendly name was NULL for me when I
301 * looked at this. Maybe we should use the store 256 * looked at this. Maybe we should use the store
302 * name instead? --KingAnt 257 * name instead? --KingAnt
303 */ 258 */
318 273
319 account = session->account; 274 account = session->account;
320 275
321 passport = msn_user_get_passport(user); 276 passport = msn_user_get_passport(user);
322 277
323 if (list_id == MSN_LIST_FL) 278 if (list_id == MSN_LIST_FL){
324 {
325 /* TODO: When is the user totally removed? */ 279 /* TODO: When is the user totally removed? */
326 if (group_id != NULL) 280 if (group_id != NULL){
327 {
328 msn_user_remove_group_id(user, group_id); 281 msn_user_remove_group_id(user, group_id);
329 return; 282 return;
330 } 283 }else{
331 else
332 {
333 /* session->sync->fl_users_count--; */ 284 /* session->sync->fl_users_count--; */
334 } 285 }
335 } 286 }else if (list_id == MSN_LIST_AL){
336 else if (list_id == MSN_LIST_AL)
337 {
338 gaim_privacy_permit_remove(account, passport, TRUE); 287 gaim_privacy_permit_remove(account, passport, TRUE);
339 } 288 }else if (list_id == MSN_LIST_BL){
340 else if (list_id == MSN_LIST_BL)
341 {
342 gaim_privacy_deny_remove(account, passport, TRUE); 289 gaim_privacy_deny_remove(account, passport, TRUE);
343 } 290 }else if (list_id == MSN_LIST_RL){
344 else if (list_id == MSN_LIST_RL)
345 {
346 GaimConversation *convo; 291 GaimConversation *convo;
347 292
348 gaim_debug_info("msn", 293 gaim_debug_info("msn",
349 "%s has removed you from his or her buddy list.\n", 294 "%s has removed you from his or her buddy list.\n",
350 passport); 295 passport);
365 } 310 }
366 311
367 user->list_op &= ~(1 << list_id); 312 user->list_op &= ~(1 << list_id);
368 /* gaim_user_remove_list_id (user, list_id); */ 313 /* gaim_user_remove_list_id (user, list_id); */
369 314
370 if (user->list_op == 0) 315 if (user->list_op == 0){
371 {
372 gaim_debug_info("msn", "Buddy '%s' shall be deleted?.\n", 316 gaim_debug_info("msn", "Buddy '%s' shall be deleted?.\n",
373 passport); 317 passport);
374
375 } 318 }
376 } 319 }
377 320
378 void 321 void
379 msn_got_lst_user(MsnSession *session, MsnUser *user, 322 msn_got_lst_user(MsnSession *session, MsnUser *user,
388 gc = gaim_account_get_connection(account); 331 gc = gaim_account_get_connection(account);
389 332
390 passport = msn_user_get_passport(user); 333 passport = msn_user_get_passport(user);
391 store = msn_user_get_store_name(user); 334 store = msn_user_get_store_name(user);
392 335
393 if (list_op & MSN_LIST_FL_OP) 336 if (list_op & MSN_LIST_FL_OP){
394 {
395 GSList *c; 337 GSList *c;
396 for (c = group_ids; c != NULL; c = g_slist_next(c)) { 338 for (c = group_ids; c != NULL; c = g_slist_next(c)) {
397 char *group_id; 339 char *group_id;
398 group_id = c->data; 340 group_id = c->data;
399 msn_user_add_group_id(user, group_id); 341 msn_user_add_group_id(user, group_id);
402 /* FIXME: It might be a real alias */ 344 /* FIXME: It might be a real alias */
403 /* Umm, what? This might fix bug #1385130 */ 345 /* Umm, what? This might fix bug #1385130 */
404 serv_got_alias(gc, passport, store); 346 serv_got_alias(gc, passport, store);
405 } 347 }
406 348
407 if (list_op & MSN_LIST_AL_OP) 349 if (list_op & MSN_LIST_AL_OP){
408 {
409 /* These are users who are allowed to see our status. */ 350 /* These are users who are allowed to see our status. */
410 gaim_privacy_deny_remove(account, passport, TRUE); 351 gaim_privacy_deny_remove(account, passport, TRUE);
411 gaim_privacy_permit_add(account, passport, TRUE); 352 gaim_privacy_permit_add(account, passport, TRUE);
412 } 353 }
413 354
414 if (list_op & MSN_LIST_BL_OP) 355 if (list_op & MSN_LIST_BL_OP){
415 {
416 /* These are users who are not allowed to see our status. */ 356 /* These are users who are not allowed to see our status. */
417 gaim_privacy_permit_remove(account, passport, TRUE); 357 gaim_privacy_permit_remove(account, passport, TRUE);
418 gaim_privacy_deny_add(account, passport, TRUE); 358 gaim_privacy_deny_add(account, passport, TRUE);
419 } 359 }
420 360
421 if (list_op & MSN_LIST_RL_OP) 361 if (list_op & MSN_LIST_RL_OP){
422 {
423 /* These are users who have us on their buddy list. */ 362 /* These are users who have us on their buddy list. */
424 /* 363 /*
425 * TODO: What is store name set to when this happens? 364 * TODO: What is store name set to when this happens?
426 * For one of my accounts "something@hotmail.com" 365 * For one of my accounts "something@hotmail.com"
427 * the store name was "something." Maybe we 366 * the store name was "something." Maybe we
428 * should use the friendly name, instead? --KingAnt 367 * should use the friendly name, instead? --KingAnt
429 */ 368 */
430 369
431 if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) 370 if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))){
432 {
433 // got_new_entry(gc, passport, store); 371 // got_new_entry(gc, passport, store);
434 } 372 }
435 } 373 }
436 374
437 user->list_op |= list_op; 375 user->list_op |= list_op;
463 msn_userlist_destroy(MsnUserList *userlist) 401 msn_userlist_destroy(MsnUserList *userlist)
464 { 402 {
465 GList *l; 403 GList *l;
466 404
467 /*destroy userlist*/ 405 /*destroy userlist*/
468 for (l = userlist->users; l != NULL; l = l->next) 406 for (l = userlist->users; l != NULL; l = l->next){
469 {
470 msn_user_destroy(l->data); 407 msn_user_destroy(l->data);
471 } 408 }
472
473 g_list_free(userlist->users); 409 g_list_free(userlist->users);
474 410
475 /*destroy group list*/ 411 /*destroy group list*/
476 for (l = userlist->groups; l != NULL; l = l->next) 412 for (l = userlist->groups; l != NULL; l = l->next){
477 {
478 msn_group_destroy(l->data); 413 msn_group_destroy(l->data);
479 } 414 }
480
481 g_list_free(userlist->groups); 415 g_list_free(userlist->groups);
482 416
483 g_queue_free(userlist->buddy_icon_requests); 417 g_queue_free(userlist->buddy_icon_requests);
484 418
485 if (userlist->buddy_icon_request_timer) 419 if (userlist->buddy_icon_request_timer)
486 gaim_timeout_remove(userlist->buddy_icon_request_timer); 420 gaim_timeout_remove(userlist->buddy_icon_request_timer);
487 421
488 g_free(userlist); 422 g_free(userlist);
489 } 423 }
490 424
425 MsnUser *
426 msn_userlist_find_add_user(MsnUserList *userlist,const char *passport,const char *userName)
427 {
428 MsnUser *user;
429
430 user = msn_userlist_find_user(userlist, passport);
431 if (user == NULL){
432 user = msn_user_new(userlist, passport, userName);
433 msn_userlist_add_user(userlist, user);
434 }
435 msn_user_set_store_name(user, userName);
436 return user;
437 }
438
491 void 439 void
492 msn_userlist_add_user(MsnUserList *userlist, MsnUser *user) 440 msn_userlist_add_user(MsnUserList *userlist, MsnUser *user)
493 { 441 {
494 userlist->users = g_list_append(userlist->users, user); 442 userlist->users = g_list_append(userlist->users, user);
495 } 443 }
505 { 453 {
506 GList *l; 454 GList *l;
507 455
508 g_return_val_if_fail(passport != NULL, NULL); 456 g_return_val_if_fail(passport != NULL, NULL);
509 457
510 for (l = userlist->users; l != NULL; l = l->next) 458 for (l = userlist->users; l != NULL; l = l->next){
511 {
512 MsnUser *user = (MsnUser *)l->data; 459 MsnUser *user = (MsnUser *)l->data;
513 460 // gaim_debug_info("MsnUserList","user passport:%s,passport:%s\n",user->passport,passport);
514 g_return_val_if_fail(user->passport != NULL, NULL); 461 g_return_val_if_fail(user->passport != NULL, NULL);
515 462
516 if (!strcmp(passport, user->passport)) 463 if (!g_strcasecmp(passport, user->passport)){
464 // gaim_debug_info("MsnUserList","return:%p\n",user);
517 return user; 465 return user;
466 }
518 } 467 }
519 468
520 return NULL; 469 return NULL;
521 } 470 }
522 471
538 GList *l; 487 GList *l;
539 488
540 g_return_val_if_fail(userlist != NULL, NULL); 489 g_return_val_if_fail(userlist != NULL, NULL);
541 g_return_val_if_fail(id != NULL, NULL); 490 g_return_val_if_fail(id != NULL, NULL);
542 491
543 for (l = userlist->groups; l != NULL; l = l->next) 492 for (l = userlist->groups; l != NULL; l = l->next){
544 {
545 MsnGroup *group = l->data; 493 MsnGroup *group = l->data;
546 494
547 if (!g_strcasecmp(group->id, id)) 495 if (!g_strcasecmp(group->id,id))
548 return group; 496 return group;
549 } 497 }
550 498
551 return NULL; 499 return NULL;
552 } 500 }
557 GList *l; 505 GList *l;
558 506
559 g_return_val_if_fail(userlist != NULL, NULL); 507 g_return_val_if_fail(userlist != NULL, NULL);
560 g_return_val_if_fail(name != NULL, NULL); 508 g_return_val_if_fail(name != NULL, NULL);
561 509
562 for (l = userlist->groups; l != NULL; l = l->next) 510 for (l = userlist->groups; l != NULL; l = l->next){
563 {
564 MsnGroup *group = l->data; 511 MsnGroup *group = l->data;
565 512
566 if ((group->name != NULL) && !g_strcasecmp(name, group->name)) 513 if ((group->name != NULL) && !g_strcasecmp(name, group->name))
567 return group; 514 return group;
568 } 515 }
575 { 522 {
576 MsnGroup *group; 523 MsnGroup *group;
577 524
578 group = msn_userlist_find_group_with_name(userlist, group_name); 525 group = msn_userlist_find_group_with_name(userlist, group_name);
579 526
580 if (group != NULL) 527 if (group != NULL){
581 return msn_group_get_id(group); 528 return msn_group_get_id(group);
582 } 529 }else{
583 else
584 {
585 return NULL; 530 return NULL;
586 } 531 }
587 } 532 }
588 533
589 const char * 534 const char *
591 { 536 {
592 MsnGroup *group; 537 MsnGroup *group;
593 538
594 group = msn_userlist_find_group_with_id(userlist, group_id); 539 group = msn_userlist_find_group_with_id(userlist, group_id);
595 540
596 if (group != NULL) 541 if (group != NULL){
597 return msn_group_get_name(group); 542 return msn_group_get_name(group);
598 else 543 }else{
599 return NULL; 544 return NULL;
545 }
600 } 546 }
601 547
602 void 548 void
603 msn_userlist_rename_group_id(MsnUserList *userlist, const char * group_id, 549 msn_userlist_rename_group_id(MsnUserList *userlist, const char * group_id,
604 const char *new_name) 550 const char *new_name)
632 MsnUser *user; 578 MsnUser *user;
633 const char *group_id; 579 const char *group_id;
634 const char *list; 580 const char *list;
635 581
636 user = msn_userlist_find_user(userlist, who); 582 user = msn_userlist_find_user(userlist, who);
637 group_id = -1;
638 583
639 g_return_if_fail(user != NULL); 584 g_return_if_fail(user != NULL);
640 585
641 /*delete the contact from address book via soap action*/ 586 /*delete the contact from address book via soap action*/
642 msn_delete_contact(userlist->session->contact,user->uid); 587 msn_delete_contact(userlist->session->contact,user->uid);
652 return; 597 return;
653 } 598 }
654 } 599 }
655 600
656 /* First we're going to check if not there. */ 601 /* First we're going to check if not there. */
657 if (!(user_is_there(user, list_id, group_id))) 602 if (!(user_is_there(user, list_id, group_id))){
658 {
659 list = lists[list_id]; 603 list = lists[list_id];
660 gaim_debug_error("msn", "User '%s' is not there: %s\n", 604 gaim_debug_error("msn", "User '%s' is not there: %s\n",
661 who, list); 605 who, list);
662 return; 606 return;
663 } 607 }
680 const char *store_name; 624 const char *store_name;
681 625
682 gaim_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name); 626 gaim_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name);
683 group_id = NULL; 627 group_id = NULL;
684 628
685 if (!gaim_email_is_valid(who)) 629 if (!gaim_email_is_valid(who)){
686 {
687 /* only notify the user about problems adding to the friends list 630 /* only notify the user about problems adding to the friends list
688 * maybe we should do something else for other lists, but it probably 631 * maybe we should do something else for other lists, but it probably
689 * won't cause too many problems if we just ignore it */ 632 * won't cause too many problems if we just ignore it */
690 if (list_id == MSN_LIST_FL) 633 if (list_id == MSN_LIST_FL) {
691 {
692 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who); 634 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who);
693 gaim_notify_error(NULL, NULL, str, 635 gaim_notify_error(NULL, NULL, str,
694 _("The screen name specified is invalid.")); 636 _("The screen name specified is invalid."));
695 g_free(str); 637 g_free(str);
696 } 638 }
697 639
698 return; 640 return;
699 } 641 }
700 642
701 if (group_name != NULL) 643 if (group_name != NULL){
702 {
703 group_id = msn_userlist_find_group_id(userlist, group_name); 644 group_id = msn_userlist_find_group_id(userlist, group_name);
704 645
705 if (group_id < 0) 646 if (group_id == NULL){
706 {
707 /* Whoa, we must add that group first. */ 647 /* Whoa, we must add that group first. */
708 msn_request_add_group(userlist, who, NULL, group_name); 648 msn_request_add_group(userlist, who, NULL, group_name);
709 return; 649 return;
710 } 650 }
711 } 651 }
712 652
713 user = msn_userlist_find_user(userlist, who); 653 user = msn_userlist_find_user(userlist, who);
714 654
715 /* First we're going to check if it's already there. */ 655 /* First we're going to check if it's already there. */
716 if (user_is_there(user, list_id, group_id)) 656 if (user_is_there(user, list_id, group_id)){
717 {
718 list = lists[list_id]; 657 list = lists[list_id];
719 gaim_debug_error("msn", "User '%s' is already there: %s\n", who, list); 658 gaim_debug_error("msn", "User '%s' is already there: %s\n", who, list);
720 return; 659 return;
721 } 660 }
722 661
725 /* Then request the add to the server. */ 664 /* Then request the add to the server. */
726 list = lists[list_id]; 665 list = lists[list_id];
727 666
728 gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id); 667 gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id);
729 msn_add_contact(userlist->session->contact,who,group_id); 668 msn_add_contact(userlist->session->contact,who,group_id);
669 #if 1
730 msn_notification_add_buddy(userlist->session->notification, list, who, 670 msn_notification_add_buddy(userlist->session->notification, list, who,
731 store_name, group_id); 671 store_name, group_id);
672 #endif
732 } 673 }
733 674
734 void 675 void
735 msn_userlist_move_buddy(MsnUserList *userlist, const char *who, 676 msn_userlist_move_buddy(MsnUserList *userlist, const char *who,
736 const char *old_group_name, const char *new_group_name) 677 const char *old_group_name, const char *new_group_name)
737 { 678 {
738 const char *new_group_id; 679 const char *new_group_id;
739 680
740 new_group_id = msn_userlist_find_group_id(userlist, new_group_name); 681 new_group_id = msn_userlist_find_group_id(userlist, new_group_name);
741 682
742 if (new_group_id == NULL) 683 if (new_group_id == NULL){
743 {
744 msn_request_add_group(userlist, who, old_group_name, new_group_name); 684 msn_request_add_group(userlist, who, old_group_name, new_group_name);
745 return; 685 return;
746 } 686 }
747 687
748 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, new_group_name); 688 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, new_group_name);
749 msn_userlist_rem_buddy(userlist, who, MSN_LIST_FL, old_group_name); 689 msn_userlist_rem_buddy(userlist, who, MSN_LIST_FL, old_group_name);
750 } 690 }
691
692 /*load userlist from the Blist file cache*/
693 void
694 msn_userlist_load(MsnSession *session)
695 {
696 GaimBlistNode *gnode, *cnode, *bnode;
697 GaimConnection *gc = gaim_account_get_connection(session->account);
698 GSList *l;
699 MsnUser * user;
700
701 g_return_if_fail(gc != NULL);
702
703 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next){
704 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
705 continue;
706 for(cnode = gnode->child; cnode; cnode = cnode->next) {
707 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))
708 continue;
709 for(bnode = cnode->child; bnode; bnode = bnode->next) {
710 GaimBuddy *b;
711 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
712 continue;
713 b = (GaimBuddy *)bnode;
714 if(b->account == gc->account){
715 user = msn_userlist_find_add_user(session->userlist,
716 b->name,NULL);
717 msn_user_set_op(user,MSN_LIST_FL_OP);
718 }
719 }
720 }
721 }
722 for (l = session->account->permit; l != NULL; l = l->next) {
723 user = msn_userlist_find_add_user(session->userlist,
724 (char *)l->data,NULL);
725 msn_user_set_op(user,MSN_LIST_AL_OP);
726 }
727 for (l = session->account->deny; l != NULL; l = l->next) {
728 user = msn_userlist_find_add_user(session->userlist,
729 (char *)l->data,NULL);
730 msn_user_set_op(user,MSN_LIST_BL_OP);
731 }
732
733 }
734