Mercurial > pidgin
comparison libpurple/protocols/msn/userlist.c @ 20399:6f986caeab59
merge of 'b4911943cba6f29cf0694dfd563cac17612236dc'
and 'c28931a50bfa21e0be81777bcd91fdeab9116d77'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 15 Apr 2007 04:29:56 +0000 |
parents | 60bc06498746 61d6a3dfbb3c |
children |
comparison
equal
deleted
inserted
replaced
19843:60bc06498746 | 20399:6f986caeab59 |
---|---|
217 serv_got_alias(gc, passport, friendly); | 217 serv_got_alias(gc, passport, friendly); |
218 | 218 |
219 if (group_id != NULL) | 219 if (group_id != NULL) |
220 { | 220 { |
221 msn_user_add_group_id(user, group_id); | 221 msn_user_add_group_id(user, group_id); |
222 }else{ | 222 } |
223 else | |
224 { | |
223 /* session->sync->fl_users_count++; */ | 225 /* session->sync->fl_users_count++; */ |
224 } | 226 } |
225 }else if (list_id == MSN_LIST_AL){ | 227 } |
228 else if (list_id == MSN_LIST_AL) | |
229 { | |
226 purple_privacy_permit_add(account, passport, TRUE); | 230 purple_privacy_permit_add(account, passport, TRUE); |
227 }else if (list_id == MSN_LIST_BL){ | 231 } |
232 else if (list_id == MSN_LIST_BL) | |
233 { | |
228 purple_privacy_deny_add(account, passport, TRUE); | 234 purple_privacy_deny_add(account, passport, TRUE); |
229 }else if (list_id == MSN_LIST_RL){ | 235 } |
236 else if (list_id == MSN_LIST_RL) | |
237 { | |
230 PurpleConnection *gc; | 238 PurpleConnection *gc; |
231 PurpleConversation *convo; | 239 PurpleConversation *convo; |
232 | 240 |
233 gc = purple_account_get_connection(account); | 241 gc = purple_account_get_connection(account); |
234 | 242 |
248 purple_conv_im_write(PURPLE_CONV_IM(convo), passport, msg, | 256 purple_conv_im_write(PURPLE_CONV_IM(convo), passport, msg, |
249 PURPLE_MESSAGE_SYSTEM, time(NULL)); | 257 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
250 g_free(msg); | 258 g_free(msg); |
251 } | 259 } |
252 | 260 |
253 if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))){ | 261 if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) |
262 { | |
254 /* | 263 /* |
255 * TODO: The friendly name was NULL for me when I | 264 * TODO: The friendly name was NULL for me when I |
256 * looked at this. Maybe we should use the store | 265 * looked at this. Maybe we should use the store |
257 * name instead? --KingAnt | 266 * name instead? --KingAnt |
258 */ | 267 */ |
273 | 282 |
274 account = session->account; | 283 account = session->account; |
275 | 284 |
276 passport = msn_user_get_passport(user); | 285 passport = msn_user_get_passport(user); |
277 | 286 |
278 if (list_id == MSN_LIST_FL){ | 287 if (list_id == MSN_LIST_FL) |
288 { | |
279 /* TODO: When is the user totally removed? */ | 289 /* TODO: When is the user totally removed? */ |
280 if (group_id != NULL){ | 290 if (group_id >= 0) |
291 { | |
281 msn_user_remove_group_id(user, group_id); | 292 msn_user_remove_group_id(user, group_id); |
282 return; | 293 return; |
283 }else{ | 294 } |
295 else | |
296 { | |
284 /* session->sync->fl_users_count--; */ | 297 /* session->sync->fl_users_count--; */ |
285 } | 298 } |
286 }else if (list_id == MSN_LIST_AL){ | 299 } |
300 else if (list_id == MSN_LIST_AL) | |
301 { | |
287 purple_privacy_permit_remove(account, passport, TRUE); | 302 purple_privacy_permit_remove(account, passport, TRUE); |
288 }else if (list_id == MSN_LIST_BL){ | 303 } |
304 else if (list_id == MSN_LIST_BL) | |
305 { | |
289 purple_privacy_deny_remove(account, passport, TRUE); | 306 purple_privacy_deny_remove(account, passport, TRUE); |
290 }else if (list_id == MSN_LIST_RL){ | 307 } |
308 else if (list_id == MSN_LIST_RL) | |
309 { | |
291 PurpleConversation *convo; | 310 PurpleConversation *convo; |
292 | 311 |
293 purple_debug_info("msn", | 312 purple_debug_info("msn", |
294 "%s has removed you from his or her buddy list.\n", | 313 "%s has removed you from his or her buddy list.\n", |
295 passport); | 314 passport); |
310 } | 329 } |
311 | 330 |
312 user->list_op &= ~(1 << list_id); | 331 user->list_op &= ~(1 << list_id); |
313 /* purple_user_remove_list_id (user, list_id); */ | 332 /* purple_user_remove_list_id (user, list_id); */ |
314 | 333 |
315 if (user->list_op == 0){ | 334 if (user->list_op == 0) |
335 { | |
316 purple_debug_info("msn", "Buddy '%s' shall be deleted?.\n", | 336 purple_debug_info("msn", "Buddy '%s' shall be deleted?.\n", |
317 passport); | 337 passport); |
318 } | 338 } |
319 } | 339 } |
320 | 340 |
331 gc = purple_account_get_connection(account); | 351 gc = purple_account_get_connection(account); |
332 | 352 |
333 passport = msn_user_get_passport(user); | 353 passport = msn_user_get_passport(user); |
334 store = msn_user_get_store_name(user); | 354 store = msn_user_get_store_name(user); |
335 | 355 |
336 if (list_op & MSN_LIST_FL_OP){ | 356 if (list_op & MSN_LIST_FL_OP) |
357 { | |
337 GSList *c; | 358 GSList *c; |
338 for (c = group_ids; c != NULL; c = g_slist_next(c)) { | 359 for (c = group_ids; c != NULL; c = g_slist_next(c)) { |
339 char *group_id; | 360 char *group_id; |
340 group_id = c->data; | 361 group_id = c->data; |
341 msn_user_add_group_id(user, group_id); | 362 msn_user_add_group_id(user, group_id); |
344 /* FIXME: It might be a real alias */ | 365 /* FIXME: It might be a real alias */ |
345 /* Umm, what? This might fix bug #1385130 */ | 366 /* Umm, what? This might fix bug #1385130 */ |
346 serv_got_alias(gc, passport, store); | 367 serv_got_alias(gc, passport, store); |
347 } | 368 } |
348 | 369 |
349 if (list_op & MSN_LIST_AL_OP){ | 370 if (list_op & MSN_LIST_AL_OP) |
371 { | |
350 /* These are users who are allowed to see our status. */ | 372 /* These are users who are allowed to see our status. */ |
351 purple_privacy_deny_remove(account, passport, TRUE); | 373 purple_privacy_deny_remove(account, passport, TRUE); |
352 purple_privacy_permit_add(account, passport, TRUE); | 374 purple_privacy_permit_add(account, passport, TRUE); |
353 } | 375 } |
354 | 376 |
355 if (list_op & MSN_LIST_BL_OP){ | 377 if (list_op & MSN_LIST_BL_OP) |
378 { | |
356 /* These are users who are not allowed to see our status. */ | 379 /* These are users who are not allowed to see our status. */ |
357 purple_privacy_permit_remove(account, passport, TRUE); | 380 purple_privacy_permit_remove(account, passport, TRUE); |
358 purple_privacy_deny_add(account, passport, TRUE); | 381 purple_privacy_deny_add(account, passport, TRUE); |
359 } | 382 } |
360 | 383 |
361 if (list_op & MSN_LIST_RL_OP){ | 384 if (list_op & MSN_LIST_RL_OP) |
385 { | |
362 /* These are users who have us on their buddy list. */ | 386 /* These are users who have us on their buddy list. */ |
363 /* | 387 /* |
364 * TODO: What is store name set to when this happens? | 388 * TODO: What is store name set to when this happens? |
365 * For one of my accounts "something@hotmail.com" | 389 * For one of my accounts "something@hotmail.com" |
366 * the store name was "something." Maybe we | 390 * the store name was "something." Maybe we |
367 * should use the friendly name, instead? --KingAnt | 391 * should use the friendly name, instead? --KingAnt |
368 */ | 392 */ |
369 | 393 |
370 if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))){ | 394 if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) |
371 // got_new_entry(gc, passport, store); | 395 { |
396 got_new_entry(gc, passport, store); | |
372 } | 397 } |
373 } | 398 } |
374 | 399 |
375 user->list_op |= list_op; | 400 user->list_op |= list_op; |
376 } | 401 } |
401 msn_userlist_destroy(MsnUserList *userlist) | 426 msn_userlist_destroy(MsnUserList *userlist) |
402 { | 427 { |
403 GList *l; | 428 GList *l; |
404 | 429 |
405 /*destroy userlist*/ | 430 /*destroy userlist*/ |
406 for (l = userlist->users; l != NULL; l = l->next){ | 431 for (l = userlist->users; l != NULL; l = l->next) |
432 { | |
407 msn_user_destroy(l->data); | 433 msn_user_destroy(l->data); |
408 } | 434 } |
409 g_list_free(userlist->users); | 435 g_list_free(userlist->users); |
410 | 436 |
411 /*destroy group list*/ | 437 /*destroy group list*/ |
412 for (l = userlist->groups; l != NULL; l = l->next){ | 438 for (l = userlist->groups; l != NULL; l = l->next) |
439 { | |
413 msn_group_destroy(l->data); | 440 msn_group_destroy(l->data); |
414 } | 441 } |
415 g_list_free(userlist->groups); | 442 g_list_free(userlist->groups); |
416 | 443 |
417 g_queue_free(userlist->buddy_icon_requests); | 444 g_queue_free(userlist->buddy_icon_requests); |
426 msn_userlist_find_add_user(MsnUserList *userlist,const char *passport,const char *userName) | 453 msn_userlist_find_add_user(MsnUserList *userlist,const char *passport,const char *userName) |
427 { | 454 { |
428 MsnUser *user; | 455 MsnUser *user; |
429 | 456 |
430 user = msn_userlist_find_user(userlist, passport); | 457 user = msn_userlist_find_user(userlist, passport); |
431 if (user == NULL){ | 458 if (user == NULL) |
459 { | |
432 user = msn_user_new(userlist, passport, userName); | 460 user = msn_user_new(userlist, passport, userName); |
433 msn_userlist_add_user(userlist, user); | 461 msn_userlist_add_user(userlist, user); |
434 } | 462 } |
435 msn_user_set_store_name(user, userName); | 463 msn_user_set_store_name(user, userName); |
436 return user; | 464 return user; |
453 { | 481 { |
454 GList *l; | 482 GList *l; |
455 | 483 |
456 g_return_val_if_fail(passport != NULL, NULL); | 484 g_return_val_if_fail(passport != NULL, NULL); |
457 | 485 |
458 for (l = userlist->users; l != NULL; l = l->next){ | 486 for (l = userlist->users; l != NULL; l = l->next) |
487 { | |
459 MsnUser *user = (MsnUser *)l->data; | 488 MsnUser *user = (MsnUser *)l->data; |
460 // purple_debug_info("MsnUserList","user passport:%s,passport:%s\n",user->passport,passport); | 489 // purple_debug_info("MsnUserList","user passport:%s,passport:%s\n",user->passport,passport); |
461 g_return_val_if_fail(user->passport != NULL, NULL); | 490 g_return_val_if_fail(user->passport != NULL, NULL); |
462 | 491 |
463 if (!g_strcasecmp(passport, user->passport)){ | 492 if (!g_strcasecmp(passport, user->passport)){ |
505 GList *l; | 534 GList *l; |
506 | 535 |
507 g_return_val_if_fail(userlist != NULL, NULL); | 536 g_return_val_if_fail(userlist != NULL, NULL); |
508 g_return_val_if_fail(name != NULL, NULL); | 537 g_return_val_if_fail(name != NULL, NULL); |
509 | 538 |
510 for (l = userlist->groups; l != NULL; l = l->next){ | 539 for (l = userlist->groups; l != NULL; l = l->next) |
540 { | |
511 MsnGroup *group = l->data; | 541 MsnGroup *group = l->data; |
512 | 542 |
513 if ((group->name != NULL) && !g_strcasecmp(name, group->name)) | 543 if ((group->name != NULL) && !g_strcasecmp(name, group->name)) |
514 return group; | 544 return group; |
515 } | 545 } |
522 { | 552 { |
523 MsnGroup *group; | 553 MsnGroup *group; |
524 | 554 |
525 group = msn_userlist_find_group_with_name(userlist, group_name); | 555 group = msn_userlist_find_group_with_name(userlist, group_name); |
526 | 556 |
527 if (group != NULL){ | 557 if (group != NULL) |
528 return msn_group_get_id(group); | 558 return msn_group_get_id(group); |
529 }else{ | 559 else |
530 return NULL; | 560 return NULL; |
531 } | |
532 } | 561 } |
533 | 562 |
534 const char * | 563 const char * |
535 msn_userlist_find_group_name(MsnUserList *userlist, const char * group_id) | 564 msn_userlist_find_group_name(MsnUserList *userlist, const char * group_id) |
536 { | 565 { |
537 MsnGroup *group; | 566 MsnGroup *group; |
538 | 567 |
539 group = msn_userlist_find_group_with_id(userlist, group_id); | 568 group = msn_userlist_find_group_with_id(userlist, group_id); |
540 | 569 |
541 if (group != NULL){ | 570 if (group != NULL) |
542 return msn_group_get_name(group); | 571 return msn_group_get_name(group); |
543 }else{ | 572 else |
544 return NULL; | 573 return NULL; |
545 } | |
546 } | 574 } |
547 | 575 |
548 void | 576 void |
549 msn_userlist_rename_group_id(MsnUserList *userlist, const char * group_id, | 577 msn_userlist_rename_group_id(MsnUserList *userlist, const char * group_id, |
550 const char *new_name) | 578 const char *new_name) |
597 return; | 625 return; |
598 } | 626 } |
599 } | 627 } |
600 | 628 |
601 /* First we're going to check if not there. */ | 629 /* First we're going to check if not there. */ |
602 if (!(user_is_there(user, list_id, group_id))){ | 630 if (!(user_is_there(user, list_id, group_id))) |
631 { | |
603 list = lists[list_id]; | 632 list = lists[list_id]; |
604 purple_debug_error("msn", "User '%s' is not there: %s\n", | 633 purple_debug_error("msn", "User '%s' is not there: %s\n", |
605 who, list); | 634 who, list); |
606 return; | 635 return; |
607 } | 636 } |
624 const char *store_name; | 653 const char *store_name; |
625 | 654 |
626 purple_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name); | 655 purple_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name); |
627 group_id = NULL; | 656 group_id = NULL; |
628 | 657 |
629 if (!purple_email_is_valid(who)){ | 658 if (!purple_email_is_valid(who)) |
659 { | |
630 /* only notify the user about problems adding to the friends list | 660 /* only notify the user about problems adding to the friends list |
631 * maybe we should do something else for other lists, but it probably | 661 * maybe we should do something else for other lists, but it probably |
632 * won't cause too many problems if we just ignore it */ | 662 * won't cause too many problems if we just ignore it */ |
633 if (list_id == MSN_LIST_FL) { | 663 if (list_id == MSN_LIST_FL) { |
634 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who); | 664 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who); |
638 } | 668 } |
639 | 669 |
640 return; | 670 return; |
641 } | 671 } |
642 | 672 |
643 if (group_name != NULL){ | 673 if (group_name != NULL) |
674 { | |
644 group_id = msn_userlist_find_group_id(userlist, group_name); | 675 group_id = msn_userlist_find_group_id(userlist, group_name); |
645 | 676 |
646 if (group_id == NULL){ | 677 if (group_id == NULL) |
678 { | |
647 /* Whoa, we must add that group first. */ | 679 /* Whoa, we must add that group first. */ |
648 msn_request_add_group(userlist, who, NULL, group_name); | 680 msn_request_add_group(userlist, who, NULL, group_name); |
649 return; | 681 return; |
650 } | 682 } |
651 } | 683 } |
652 | 684 |
653 user = msn_userlist_find_user(userlist, who); | 685 user = msn_userlist_find_user(userlist, who); |
654 | 686 |
655 /* First we're going to check if it's already there. */ | 687 /* First we're going to check if it's already there. */ |
656 if (user_is_there(user, list_id, group_id)){ | 688 if (user_is_there(user, list_id, group_id)) |
689 { | |
657 list = lists[list_id]; | 690 list = lists[list_id]; |
658 purple_debug_error("msn", "User '%s' is already there: %s\n", who, list); | 691 purple_debug_error("msn", "User '%s' is already there: %s\n", who, list); |
659 return; | 692 return; |
660 } | 693 } |
661 | 694 |
664 /* Then request the add to the server. */ | 697 /* Then request the add to the server. */ |
665 list = lists[list_id]; | 698 list = lists[list_id]; |
666 | 699 |
667 purple_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id); | 700 purple_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); | 701 msn_add_contact(userlist->session->contact,who,group_id); |
669 #if 1 | |
670 msn_notification_add_buddy(userlist->session->notification, list, who, | 702 msn_notification_add_buddy(userlist->session->notification, list, who, |
671 store_name, group_id); | 703 store_name, group_id); |
672 #endif | |
673 } | 704 } |
674 | 705 |
675 void | 706 void |
676 msn_userlist_move_buddy(MsnUserList *userlist, const char *who, | 707 msn_userlist_move_buddy(MsnUserList *userlist, const char *who, |
677 const char *old_group_name, const char *new_group_name) | 708 const char *old_group_name, const char *new_group_name) |
678 { | 709 { |
679 const char *new_group_id; | 710 const char *new_group_id; |
680 | 711 |
681 new_group_id = msn_userlist_find_group_id(userlist, new_group_name); | 712 new_group_id = msn_userlist_find_group_id(userlist, new_group_name); |
682 | 713 |
683 if (new_group_id == NULL){ | 714 if (new_group_id == NULL) |
715 { | |
684 msn_request_add_group(userlist, who, old_group_name, new_group_name); | 716 msn_request_add_group(userlist, who, old_group_name, new_group_name); |
685 return; | 717 return; |
686 } | 718 } |
687 | 719 |
688 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, new_group_name); | 720 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, new_group_name); |
698 GSList *l; | 730 GSList *l; |
699 MsnUser * user; | 731 MsnUser * user; |
700 | 732 |
701 g_return_if_fail(gc != NULL); | 733 g_return_if_fail(gc != NULL); |
702 | 734 |
703 for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next){ | 735 for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) |
704 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) | 736 { |
737 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) | |
705 continue; | 738 continue; |
706 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 739 for (cnode = gnode->child; cnode; cnode = cnode->next) |
707 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) | 740 { |
741 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) | |
708 continue; | 742 continue; |
709 for(bnode = cnode->child; bnode; bnode = bnode->next) { | 743 for (bnode = cnode->child; bnode; bnode = bnode->next) |
744 { | |
710 PurpleBuddy *b; | 745 PurpleBuddy *b; |
711 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) | 746 if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
712 continue; | 747 continue; |
713 b = (PurpleBuddy *)bnode; | 748 b = (PurpleBuddy *)bnode; |
714 if(b->account == gc->account){ | 749 if (b->account == gc->account) |
750 { | |
715 user = msn_userlist_find_add_user(session->userlist, | 751 user = msn_userlist_find_add_user(session->userlist, |
716 b->name,NULL); | 752 b->name,NULL); |
717 b->proto_data = user; | 753 b->proto_data = user; |
718 msn_user_set_op(user, MSN_LIST_FL_OP); | 754 msn_user_set_op(user, MSN_LIST_FL_OP); |
719 } | 755 } |
720 } | 756 } |
721 } | 757 } |
722 } | 758 } |
723 for (l = session->account->permit; l != NULL; l = l->next) { | 759 for (l = session->account->permit; l != NULL; l = l->next) |
760 { | |
724 user = msn_userlist_find_add_user(session->userlist, | 761 user = msn_userlist_find_add_user(session->userlist, |
725 (char *)l->data,NULL); | 762 (char *)l->data,NULL); |
726 msn_user_set_op(user, MSN_LIST_AL_OP); | 763 msn_user_set_op(user, MSN_LIST_AL_OP); |
727 } | 764 } |
728 for (l = session->account->deny; l != NULL; l = l->next) { | 765 for (l = session->account->deny; l != NULL; l = l->next) |
766 { | |
729 user = msn_userlist_find_add_user(session->userlist, | 767 user = msn_userlist_find_add_user(session->userlist, |
730 (char *)l->data,NULL); | 768 (char *)l->data,NULL); |
731 msn_user_set_op(user, MSN_LIST_BL_OP); | 769 msn_user_set_op(user, MSN_LIST_BL_OP); |
732 } | 770 } |
733 | 771 |