Mercurial > pidgin.yaz
comparison libgaim/protocols/msn/userlist.c @ 20397:6ac7e33fdabf
propagate from branch 'im.pidgin.rlaager.merging.msnp13-and-sf-1621854-1-rlaager-whitespace' (head 5083cfbc09503360bacf3ff0ebf528700770e6af)
to branch 'im.pidgin.rlaager.merging.msnp13-and-sf-1621854-4-rlaager-whitespace' (head 4d82c29e56bd33cd6f94302e343dfeb5d68ab3eb)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 15 Apr 2007 03:04:05 +0000 |
parents | 9ba7dee775e1 9755b2f7bb0f |
children |
comparison
equal
deleted
inserted
replaced
20393:40a04930b233 | 20397:6ac7e33fdabf |
---|---|
220 { | 220 { |
221 msn_user_add_group_id(user, group_id); | 221 msn_user_add_group_id(user, group_id); |
222 }else{ | 222 }else{ |
223 /* session->sync->fl_users_count++; */ | 223 /* session->sync->fl_users_count++; */ |
224 } | 224 } |
225 }else if (list_id == MSN_LIST_AL){ | 225 } |
226 else if (list_id == MSN_LIST_AL) | |
227 { | |
226 gaim_privacy_permit_add(account, passport, TRUE); | 228 gaim_privacy_permit_add(account, passport, TRUE); |
227 }else if (list_id == MSN_LIST_BL){ | 229 } |
230 else if (list_id == MSN_LIST_BL) | |
231 { | |
228 gaim_privacy_deny_add(account, passport, TRUE); | 232 gaim_privacy_deny_add(account, passport, TRUE); |
229 }else if (list_id == MSN_LIST_RL){ | 233 } |
234 else if (list_id == MSN_LIST_RL) | |
235 { | |
230 GaimConnection *gc; | 236 GaimConnection *gc; |
231 GaimConversation *convo; | 237 GaimConversation *convo; |
232 | 238 |
233 gc = gaim_account_get_connection(account); | 239 gc = gaim_account_get_connection(account); |
234 | 240 |
273 | 279 |
274 account = session->account; | 280 account = session->account; |
275 | 281 |
276 passport = msn_user_get_passport(user); | 282 passport = msn_user_get_passport(user); |
277 | 283 |
278 if (list_id == MSN_LIST_FL){ | 284 if (list_id == MSN_LIST_FL) |
285 { | |
279 /* TODO: When is the user totally removed? */ | 286 /* TODO: When is the user totally removed? */ |
280 if (group_id != NULL){ | 287 if (group_id != NULL) |
288 { | |
281 msn_user_remove_group_id(user, group_id); | 289 msn_user_remove_group_id(user, group_id); |
282 return; | 290 return; |
283 }else{ | 291 } |
292 else | |
293 { | |
284 /* session->sync->fl_users_count--; */ | 294 /* session->sync->fl_users_count--; */ |
285 } | 295 } |
286 }else if (list_id == MSN_LIST_AL){ | 296 } |
297 else if (list_id == MSN_LIST_AL) | |
298 { | |
287 gaim_privacy_permit_remove(account, passport, TRUE); | 299 gaim_privacy_permit_remove(account, passport, TRUE); |
288 }else if (list_id == MSN_LIST_BL){ | 300 } |
301 else if (list_id == MSN_LIST_BL) | |
302 { | |
289 gaim_privacy_deny_remove(account, passport, TRUE); | 303 gaim_privacy_deny_remove(account, passport, TRUE); |
290 }else if (list_id == MSN_LIST_RL){ | 304 } |
305 else if (list_id == MSN_LIST_RL) | |
306 { | |
291 GaimConversation *convo; | 307 GaimConversation *convo; |
292 | 308 |
293 gaim_debug_info("msn", | 309 gaim_debug_info("msn", |
294 "%s has removed you from his or her buddy list.\n", | 310 "%s has removed you from his or her buddy list.\n", |
295 passport); | 311 passport); |
331 gc = gaim_account_get_connection(account); | 347 gc = gaim_account_get_connection(account); |
332 | 348 |
333 passport = msn_user_get_passport(user); | 349 passport = msn_user_get_passport(user); |
334 store = msn_user_get_store_name(user); | 350 store = msn_user_get_store_name(user); |
335 | 351 |
336 if (list_op & MSN_LIST_FL_OP){ | 352 if (list_op & MSN_LIST_FL_OP) |
353 { | |
337 GSList *c; | 354 GSList *c; |
338 for (c = group_ids; c != NULL; c = g_slist_next(c)) { | 355 for (c = group_ids; c != NULL; c = g_slist_next(c)) |
356 { | |
339 char *group_id; | 357 char *group_id; |
340 group_id = c->data; | 358 group_id = c->data; |
341 msn_user_add_group_id(user, group_id); | 359 msn_user_add_group_id(user, group_id); |
342 } | 360 } |
343 | 361 |
344 /* FIXME: It might be a real alias */ | 362 /* FIXME: It might be a real alias */ |
345 /* Umm, what? This might fix bug #1385130 */ | 363 /* Umm, what? This might fix bug #1385130 */ |
346 serv_got_alias(gc, passport, store); | 364 serv_got_alias(gc, passport, store); |
347 } | 365 } |
348 | 366 |
349 if (list_op & MSN_LIST_AL_OP){ | 367 if (list_op & MSN_LIST_AL_OP) |
368 { | |
350 /* These are users who are allowed to see our status. */ | 369 /* These are users who are allowed to see our status. */ |
351 gaim_privacy_deny_remove(account, passport, TRUE); | 370 gaim_privacy_deny_remove(account, passport, TRUE); |
352 gaim_privacy_permit_add(account, passport, TRUE); | 371 gaim_privacy_permit_add(account, passport, TRUE); |
353 } | 372 } |
354 | 373 |
355 if (list_op & MSN_LIST_BL_OP){ | 374 if (list_op & MSN_LIST_BL_OP) |
375 { | |
356 /* These are users who are not allowed to see our status. */ | 376 /* These are users who are not allowed to see our status. */ |
357 gaim_privacy_permit_remove(account, passport, TRUE); | 377 gaim_privacy_permit_remove(account, passport, TRUE); |
358 gaim_privacy_deny_add(account, passport, TRUE); | 378 gaim_privacy_deny_add(account, passport, TRUE); |
359 } | 379 } |
360 | 380 |
361 if (list_op & MSN_LIST_RL_OP){ | 381 if (list_op & MSN_LIST_RL_OP) |
382 { | |
362 /* These are users who have us on their buddy list. */ | 383 /* These are users who have us on their buddy list. */ |
363 /* | 384 /* |
364 * TODO: What is store name set to when this happens? | 385 * TODO: What is store name set to when this happens? |
365 * For one of my accounts "something@hotmail.com" | 386 * For one of my accounts "something@hotmail.com" |
366 * the store name was "something." Maybe we | 387 * the store name was "something." Maybe we |
367 * should use the friendly name, instead? --KingAnt | 388 * should use the friendly name, instead? --KingAnt |
368 */ | 389 */ |
369 | 390 |
370 if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))){ | 391 if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) |
392 { | |
371 // got_new_entry(gc, passport, store); | 393 // got_new_entry(gc, passport, store); |
372 } | 394 } |
373 } | 395 } |
374 | 396 |
375 user->list_op |= list_op; | 397 user->list_op |= list_op; |
401 msn_userlist_destroy(MsnUserList *userlist) | 423 msn_userlist_destroy(MsnUserList *userlist) |
402 { | 424 { |
403 GList *l; | 425 GList *l; |
404 | 426 |
405 /*destroy userlist*/ | 427 /*destroy userlist*/ |
406 for (l = userlist->users; l != NULL; l = l->next){ | 428 for (l = userlist->users; l != NULL; l = l->next) |
429 { | |
407 msn_user_destroy(l->data); | 430 msn_user_destroy(l->data); |
408 } | 431 } |
409 g_list_free(userlist->users); | 432 g_list_free(userlist->users); |
410 | 433 |
411 /*destroy group list*/ | 434 /*destroy group list*/ |
412 for (l = userlist->groups; l != NULL; l = l->next){ | 435 for (l = userlist->groups; l != NULL; l = l->next) |
436 { | |
413 msn_group_destroy(l->data); | 437 msn_group_destroy(l->data); |
414 } | 438 } |
415 g_list_free(userlist->groups); | 439 g_list_free(userlist->groups); |
416 | 440 |
417 g_queue_free(userlist->buddy_icon_requests); | 441 g_queue_free(userlist->buddy_icon_requests); |
426 msn_userlist_find_add_user(MsnUserList *userlist,const char *passport,const char *userName) | 450 msn_userlist_find_add_user(MsnUserList *userlist,const char *passport,const char *userName) |
427 { | 451 { |
428 MsnUser *user; | 452 MsnUser *user; |
429 | 453 |
430 user = msn_userlist_find_user(userlist, passport); | 454 user = msn_userlist_find_user(userlist, passport); |
431 if (user == NULL){ | 455 if (user == NULL) |
456 { | |
432 user = msn_user_new(userlist, passport, userName); | 457 user = msn_user_new(userlist, passport, userName); |
433 msn_userlist_add_user(userlist, user); | 458 msn_userlist_add_user(userlist, user); |
434 } | 459 } |
435 msn_user_set_store_name(user, userName); | 460 msn_user_set_store_name(user, userName); |
436 return user; | 461 return user; |
453 { | 478 { |
454 GList *l; | 479 GList *l; |
455 | 480 |
456 g_return_val_if_fail(passport != NULL, NULL); | 481 g_return_val_if_fail(passport != NULL, NULL); |
457 | 482 |
458 for (l = userlist->users; l != NULL; l = l->next){ | 483 for (l = userlist->users; l != NULL; l = l->next) |
484 { | |
459 MsnUser *user = (MsnUser *)l->data; | 485 MsnUser *user = (MsnUser *)l->data; |
460 // gaim_debug_info("MsnUserList","user passport:%s,passport:%s\n",user->passport,passport); | 486 // gaim_debug_info("MsnUserList","user passport:%s,passport:%s\n",user->passport,passport); |
461 g_return_val_if_fail(user->passport != NULL, NULL); | 487 g_return_val_if_fail(user->passport != NULL, NULL); |
462 | 488 |
463 if (!g_strcasecmp(passport, user->passport)){ | 489 if (!g_strcasecmp(passport, user->passport)) |
490 { | |
464 // gaim_debug_info("MsnUserList","return:%p\n",user); | 491 // gaim_debug_info("MsnUserList","return:%p\n",user); |
465 return user; | 492 return user; |
466 } | 493 } |
467 } | 494 } |
468 | 495 |
487 GList *l; | 514 GList *l; |
488 | 515 |
489 g_return_val_if_fail(userlist != NULL, NULL); | 516 g_return_val_if_fail(userlist != NULL, NULL); |
490 g_return_val_if_fail(id != NULL, NULL); | 517 g_return_val_if_fail(id != NULL, NULL); |
491 | 518 |
492 for (l = userlist->groups; l != NULL; l = l->next){ | 519 for (l = userlist->groups; l != NULL; l = l->next) |
520 { | |
493 MsnGroup *group = l->data; | 521 MsnGroup *group = l->data; |
494 | 522 |
495 if (!g_strcasecmp(group->id,id)) | 523 if (!g_strcasecmp(group->id, id)) |
496 return group; | 524 return group; |
497 } | 525 } |
498 | 526 |
499 return NULL; | 527 return NULL; |
500 } | 528 } |
505 GList *l; | 533 GList *l; |
506 | 534 |
507 g_return_val_if_fail(userlist != NULL, NULL); | 535 g_return_val_if_fail(userlist != NULL, NULL); |
508 g_return_val_if_fail(name != NULL, NULL); | 536 g_return_val_if_fail(name != NULL, NULL); |
509 | 537 |
510 for (l = userlist->groups; l != NULL; l = l->next){ | 538 for (l = userlist->groups; l != NULL; l = l->next) |
539 { | |
511 MsnGroup *group = l->data; | 540 MsnGroup *group = l->data; |
512 | 541 |
513 if ((group->name != NULL) && !g_strcasecmp(name, group->name)) | 542 if ((group->name != NULL) && !g_strcasecmp(name, group->name)) |
514 return group; | 543 return group; |
515 } | 544 } |
522 { | 551 { |
523 MsnGroup *group; | 552 MsnGroup *group; |
524 | 553 |
525 group = msn_userlist_find_group_with_name(userlist, group_name); | 554 group = msn_userlist_find_group_with_name(userlist, group_name); |
526 | 555 |
527 if (group != NULL){ | 556 if (group != NULL) |
557 { | |
528 return msn_group_get_id(group); | 558 return msn_group_get_id(group); |
529 }else{ | 559 } |
560 else | |
561 { | |
530 return NULL; | 562 return NULL; |
531 } | 563 } |
532 } | 564 } |
533 | 565 |
534 const char * | 566 const char * |
536 { | 568 { |
537 MsnGroup *group; | 569 MsnGroup *group; |
538 | 570 |
539 group = msn_userlist_find_group_with_id(userlist, group_id); | 571 group = msn_userlist_find_group_with_id(userlist, group_id); |
540 | 572 |
541 if (group != NULL){ | 573 if (group != NULL) |
574 { | |
542 return msn_group_get_name(group); | 575 return msn_group_get_name(group); |
543 }else{ | 576 } |
577 else | |
578 { | |
544 return NULL; | 579 return NULL; |
545 } | 580 } |
546 } | 581 } |
547 | 582 |
548 void | 583 void |
597 return; | 632 return; |
598 } | 633 } |
599 } | 634 } |
600 | 635 |
601 /* First we're going to check if not there. */ | 636 /* First we're going to check if not there. */ |
602 if (!(user_is_there(user, list_id, group_id))){ | 637 if (!(user_is_there(user, list_id, group_id))) |
638 { | |
603 list = lists[list_id]; | 639 list = lists[list_id]; |
604 gaim_debug_error("msn", "User '%s' is not there: %s\n", | 640 gaim_debug_error("msn", "User '%s' is not there: %s\n", |
605 who, list); | 641 who, list); |
606 return; | 642 return; |
607 } | 643 } |
624 const char *store_name; | 660 const char *store_name; |
625 | 661 |
626 gaim_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name); | 662 gaim_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name); |
627 group_id = NULL; | 663 group_id = NULL; |
628 | 664 |
629 if (!gaim_email_is_valid(who)){ | 665 if (!gaim_email_is_valid(who)) |
666 { | |
630 /* only notify the user about problems adding to the friends list | 667 /* only notify the user about problems adding to the friends list |
631 * maybe we should do something else for other lists, but it probably | 668 * maybe we should do something else for other lists, but it probably |
632 * won't cause too many problems if we just ignore it */ | 669 * won't cause too many problems if we just ignore it */ |
633 if (list_id == MSN_LIST_FL) { | 670 if (list_id == MSN_LIST_FL) |
671 { | |
634 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who); | 672 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who); |
635 gaim_notify_error(NULL, NULL, str, | 673 gaim_notify_error(NULL, NULL, str, |
636 _("The screen name specified is invalid.")); | 674 _("The screen name specified is invalid.")); |
637 g_free(str); | 675 g_free(str); |
638 } | 676 } |
639 | 677 |
640 return; | 678 return; |
641 } | 679 } |
642 | 680 |
643 if (group_name != NULL){ | 681 if (group_name != NULL) |
682 { | |
644 group_id = msn_userlist_find_group_id(userlist, group_name); | 683 group_id = msn_userlist_find_group_id(userlist, group_name); |
645 | 684 |
646 if (group_id == NULL){ | 685 if (group_id == NULL) |
686 { | |
647 /* Whoa, we must add that group first. */ | 687 /* Whoa, we must add that group first. */ |
648 msn_request_add_group(userlist, who, NULL, group_name); | 688 msn_request_add_group(userlist, who, NULL, group_name); |
649 return; | 689 return; |
650 } | 690 } |
651 } | 691 } |
652 | 692 |
653 user = msn_userlist_find_user(userlist, who); | 693 user = msn_userlist_find_user(userlist, who); |
654 | 694 |
655 /* First we're going to check if it's already there. */ | 695 /* First we're going to check if it's already there. */ |
656 if (user_is_there(user, list_id, group_id)){ | 696 if (user_is_there(user, list_id, group_id)) |
697 { | |
657 list = lists[list_id]; | 698 list = lists[list_id]; |
658 gaim_debug_error("msn", "User '%s' is already there: %s\n", who, list); | 699 gaim_debug_error("msn", "User '%s' is already there: %s\n", who, list); |
659 return; | 700 return; |
660 } | 701 } |
661 | 702 |
664 /* Then request the add to the server. */ | 705 /* Then request the add to the server. */ |
665 list = lists[list_id]; | 706 list = lists[list_id]; |
666 | 707 |
667 gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id); | 708 gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id); |
668 msn_add_contact(userlist->session->contact,who,group_id); | 709 msn_add_contact(userlist->session->contact,who,group_id); |
669 #if 1 | |
670 msn_notification_add_buddy(userlist->session->notification, list, who, | 710 msn_notification_add_buddy(userlist->session->notification, list, who, |
671 store_name, group_id); | 711 store_name, group_id); |
672 #endif | |
673 } | 712 } |
674 | 713 |
675 void | 714 void |
676 msn_userlist_move_buddy(MsnUserList *userlist, const char *who, | 715 msn_userlist_move_buddy(MsnUserList *userlist, const char *who, |
677 const char *old_group_name, const char *new_group_name) | 716 const char *old_group_name, const char *new_group_name) |
678 { | 717 { |
679 const char *new_group_id; | 718 const char *new_group_id; |
680 | 719 |
681 new_group_id = msn_userlist_find_group_id(userlist, new_group_name); | 720 new_group_id = msn_userlist_find_group_id(userlist, new_group_name); |
682 | 721 |
683 if (new_group_id == NULL){ | 722 if (new_group_id == NULL) |
723 { | |
684 msn_request_add_group(userlist, who, old_group_name, new_group_name); | 724 msn_request_add_group(userlist, who, old_group_name, new_group_name); |
685 return; | 725 return; |
686 } | 726 } |
687 | 727 |
688 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, new_group_name); | 728 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, new_group_name); |
698 GSList *l; | 738 GSList *l; |
699 MsnUser * user; | 739 MsnUser * user; |
700 | 740 |
701 g_return_if_fail(gc != NULL); | 741 g_return_if_fail(gc != NULL); |
702 | 742 |
703 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next){ | 743 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) |
704 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | 744 { |
745 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
705 continue; | 746 continue; |
706 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 747 for (cnode = gnode->child; cnode; cnode = cnode->next) |
707 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | 748 { |
749 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
708 continue; | 750 continue; |
709 for(bnode = cnode->child; bnode; bnode = bnode->next) { | 751 for (bnode = cnode->child; bnode; bnode = bnode->next) |
752 { | |
710 GaimBuddy *b; | 753 GaimBuddy *b; |
711 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | 754 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
712 continue; | 755 continue; |
713 b = (GaimBuddy *)bnode; | 756 b = (GaimBuddy *)bnode; |
714 if(b->account == gc->account){ | 757 if (b->account == gc->account) |
758 { | |
715 user = msn_userlist_find_add_user(session->userlist, | 759 user = msn_userlist_find_add_user(session->userlist, |
716 b->name,NULL); | 760 b->name,NULL); |
717 b->proto_data = user; | 761 b->proto_data = user; |
718 msn_user_set_op(user, MSN_LIST_FL_OP); | 762 msn_user_set_op(user, MSN_LIST_FL_OP); |
719 } | 763 } |
720 } | 764 } |
721 } | 765 } |
722 } | 766 } |
723 for (l = session->account->permit; l != NULL; l = l->next) { | 767 for (l = session->account->permit; l != NULL; l = l->next) |
768 { | |
724 user = msn_userlist_find_add_user(session->userlist, | 769 user = msn_userlist_find_add_user(session->userlist, |
725 (char *)l->data,NULL); | 770 (char *)l->data,NULL); |
726 msn_user_set_op(user, MSN_LIST_AL_OP); | 771 msn_user_set_op(user, MSN_LIST_AL_OP); |
727 } | 772 } |
728 for (l = session->account->deny; l != NULL; l = l->next) { | 773 for (l = session->account->deny; l != NULL; l = l->next) |
774 { | |
729 user = msn_userlist_find_add_user(session->userlist, | 775 user = msn_userlist_find_add_user(session->userlist, |
730 (char *)l->data,NULL); | 776 (char *)l->data,NULL); |
731 msn_user_set_op(user, MSN_LIST_BL_OP); | 777 msn_user_set_op(user, MSN_LIST_BL_OP); |
732 } | 778 } |
733 | 779 } |
734 } | 780 |
735 |