comparison src/protocols/msn/msn.c @ 9091:97a1fb329cd2

[gaim-migrate @ 9868] Patch by Felipe Contreras (shx) to check first if we have a buddy already in a group before trying to add it to the group. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 27 May 2004 08:04:11 +0000
parents 9fcbb18aa7be
children 9e5a709c30a8
comparison
equal deleted inserted replaced
9090:cab225a333b5 9091:97a1fb329cd2
735 { 735 {
736 /* This is a broken blist entry. */ 736 /* This is a broken blist entry. */
737 return; 737 return;
738 } 738 }
739 739
740 if (group != NULL)
741 msn_group = msn_groups_find_with_name(session->groups, group->name);
742
743 /* We should check if the user isn't alredy there. */
740 for (l = session->lists.forward; l != NULL; l = l->next) 744 for (l = session->lists.forward; l != NULL; l = l->next)
741 { 745 {
742 MsnUser *user = l->data; 746 MsnUser *user = l->data;
743 747
744 if (!gaim_utf8_strcasecmp(who, msn_user_get_passport(user))) 748 if (!gaim_utf8_strcasecmp(who, msn_user_get_passport(user)))
745 break; 749 {
750 if (group == NULL)
751 break;
752 else if (msn_group != NULL)
753 {
754 /* Now we should check if it's in the group. */
755 if (g_list_find(user->group_ids,
756 GINT_TO_POINTER(msn_group->id)))
757 break;
758 }
759 }
746 } 760 }
747 761
748 if (l != NULL) 762 if (l != NULL)
749 return; 763 return;
750 764
751 if (group != NULL)
752 msn_group = msn_groups_find_with_name(session->groups, group->name);
753
754 if (msn_group != NULL) 765 if (msn_group != NULL)
755 { 766 {
756 msn_cmdproc_send(cmdproc, "ADD", "FL %s %s %d", who, who, 767 msn_cmdproc_send(cmdproc, "ADD", "FL %s %s %d", who, who,
757 msn_group_get_id(msn_group)); 768 msn_group_get_id(msn_group));
758 } 769 }
766 msn_rem_buddy(GaimConnection *gc, const char *who, const char *group_name) 777 msn_rem_buddy(GaimConnection *gc, const char *who, const char *group_name)
767 { 778 {
768 MsnSession *session; 779 MsnSession *session;
769 MsnCmdProc *cmdproc; 780 MsnCmdProc *cmdproc;
770 MsnGroup *group; 781 MsnGroup *group;
782 GSList *l;
771 783
772 session = gc->proto_data; 784 session = gc->proto_data;
773 cmdproc = session->notification_conn->cmdproc; 785 cmdproc = session->notification_conn->cmdproc;
774 786
775 if (strchr(who, ' ')) 787 if (strchr(who, ' '))
777 /* This is a broken blist entry. */ 789 /* This is a broken blist entry. */
778 return; 790 return;
779 } 791 }
780 792
781 group = msn_groups_find_with_name(session->groups, group_name); 793 group = msn_groups_find_with_name(session->groups, group_name);
794
795 /* We should check if the user is there. */
796 for (l = session->lists.forward; l != NULL; l = l->next)
797 {
798 MsnUser *user = l->data;
799
800 if (!gaim_utf8_strcasecmp(who, msn_user_get_passport(user)))
801 {
802 if (group_name == NULL)
803 break;
804 else if (group != NULL)
805 {
806 /* Now we should check if it's in the group. */
807 if (g_list_find(user->group_ids,
808 GINT_TO_POINTER(group->id)))
809 break;
810 }
811 }
812 }
813
814 if (l == NULL)
815 return;
782 816
783 if (group == NULL) 817 if (group == NULL)
784 { 818 {
785 msn_cmdproc_send(cmdproc, "REM", "FL %s", who); 819 msn_cmdproc_send(cmdproc, "REM", "FL %s", who);
786 } 820 }