annotate src/protocols/msn/userlist.c @ 19774:ea23c4c010cf

[gaim-migrate @ 17006] fix msg send bug tested ok on windows committed by MaYuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Wed, 23 Aug 2006 17:01:31 +0000
parents d928bccffe4c
children a8d00b8dae40
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
1 /**
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
2 * @file userlist.c MSN user list support
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
3 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
4 * gaim
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
5 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
6 * Gaim is the legal property of its developers, whose names are too numerous
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
8 * source distribution.
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
9 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
10 * This program is free software; you can redistribute it and/or modify
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
11 * it under the terms of the GNU General Public License as published by
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
13 * (at your option) any later version.
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
14 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
15 * This program is distributed in the hope that it will be useful,
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
18 * GNU General Public License for more details.
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
19 *
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
20 * You should have received a copy of the GNU General Public License
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
21 * along with this program; if not, write to the Free Software
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
23 */
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "msn.h"
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "userlist.h"
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 const char *lists[] = { "FL", "AL", "BL", "RL" };
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 typedef struct
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 GaimConnection *gc;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 char *who;
12380
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
33 char *friendly;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 } MsnPermitAdd;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 /**************************************************************************
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 * Callbacks
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 **************************************************************************/
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 static void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 msn_accept_add_cb(MsnPermitAdd *pa)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 MsnSession *session = pa->gc->proto_data;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 MsnUserList *userlist = session->userlist;
12380
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
47 GaimBuddy *buddy;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50
12380
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
51 buddy = gaim_find_buddy(pa->gc->account, pa->who);
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
52
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
53 if (buddy != NULL)
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
54 gaim_account_notify_added(pa->gc->account, pa->who,
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
55 NULL, pa->friendly, NULL);
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
56 else
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
57 gaim_account_request_add(pa->gc->account, pa->who,
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
58 NULL, pa->friendly, NULL);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 g_free(pa->who);
12380
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
62 g_free(pa->friendly);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 g_free(pa);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 static void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 msn_cancel_add_cb(MsnPermitAdd *pa)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 if (g_list_find(gaim_connections_get_all(), pa->gc) != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 MsnSession *session = pa->gc->proto_data;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 MsnUserList *userlist = session->userlist;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 g_free(pa->who);
12380
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
78 g_free(pa->friendly);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 g_free(pa);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 static void
9976
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9948
diff changeset
83 got_new_entry(GaimConnection *gc, const char *passport, const char *friendly)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 MsnPermitAdd *pa;
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10583
diff changeset
86 char *msg;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
12380
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
88 pa = g_new0(MsnPermitAdd, 1);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 pa->who = g_strdup(passport);
12381
29e237c4141b [gaim-migrate @ 14685]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12380
diff changeset
90 pa->friendly = g_strdup(friendly);
12380
553dd80f6130 [gaim-migrate @ 14684]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12318
diff changeset
91 pa->gc = gc;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
19766
d928bccffe4c [gaim-migrate @ 16952]
Ma Yuan <mayuan2006@gmail.com>
parents: 19764
diff changeset
93 if (friendly != NULL){
9210
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
94 msg = g_strdup_printf(
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
95 _("The user %s (%s) wants to add %s to his or her "
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
96 "buddy list."),
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10583
diff changeset
97 passport, friendly,
9210
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
98 gaim_account_get_username(gc->account));
19766
d928bccffe4c [gaim-migrate @ 16952]
Ma Yuan <mayuan2006@gmail.com>
parents: 19764
diff changeset
99 }else{
9210
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
100 msg = g_strdup_printf(
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
101 _("The user %s wants to add %s to his or "
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
102 "her buddy list."),
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
103 passport, gaim_account_get_username(gc->account));
62b601ddb4bc [gaim-migrate @ 10005]
Christian Hammond <chipx86@chipx86.com>
parents: 9208
diff changeset
104 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
9976
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9948
diff changeset
106 gaim_request_action(gc, NULL, msg, NULL,
9948
b13013595c08 [gaim-migrate @ 10844]
Luke Schierer <lschiere@pidgin.im>
parents: 9895
diff changeset
107 GAIM_DEFAULT_ACTION_NONE, pa, 2,
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 _("Authorize"), G_CALLBACK(msn_accept_add_cb),
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 _("Deny"), G_CALLBACK(msn_cancel_add_cb));
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 g_free(msg);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 /**************************************************************************
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 * Utility functions
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 **************************************************************************/
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 static gboolean
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
119 user_is_in_group(MsnUser *user, const char * group_id)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 if (user == NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 return FALSE;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
124 if (group_id == NULL)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 return FALSE;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
127 if (g_list_find(user->group_ids, group_id))
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 return TRUE;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 return FALSE;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 static gboolean
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
134 user_is_there(MsnUser *user, int list_id, const char * group_id)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 int list_op;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 if (user == NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 return FALSE;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 list_op = 1 << list_id;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 if (!(user->list_op & list_op))
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 return FALSE;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
146 if (list_id == MSN_LIST_FL){
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
147 if (group_id != NULL)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 return user_is_in_group(user, group_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 return TRUE;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 static const char*
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 get_store_name(MsnUser *user)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 const char *store_name;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 g_return_val_if_fail(user != NULL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
10533
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
161 store_name = msn_user_get_store_name(user);
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
162
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
163 if (store_name != NULL)
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
164 store_name = gaim_url_encode(store_name);
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
165 else
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
166 store_name = msn_user_get_passport(user);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167
10533
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
168 /* this might be a bit of a hack, but it should prevent notification server
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
169 * disconnections for people who have buddies with insane friendly names
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
170 * who added you to their buddy list from being disconnected. Stu. */
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
171 /* Shx: What? Isn't the store_name obtained from the server, and hence it's
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
172 * below the BUDDY_ALIAS_MAXLEN ? */
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
173 /* Stu: yeah, that's why it's a bit of a hack, as you pointed out, we're
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
174 * probably decoding the incoming store_name wrong, or something. bleh. */
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
175
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
176 if (strlen(store_name) > BUDDY_ALIAS_MAXLEN)
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
177 store_name = msn_user_get_passport(user);
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
178
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
179 return store_name;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 static void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 msn_request_add_group(MsnUserList *userlist, const char *who,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 const char *old_group_name, const char *new_group_name)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 MsnCmdProc *cmdproc;
9218
08e7ccb4610d [gaim-migrate @ 10014]
Luke Schierer <lschiere@pidgin.im>
parents: 9211
diff changeset
187 MsnMoveBuddy *data;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 cmdproc = userlist->session->notification->cmdproc;
9218
08e7ccb4610d [gaim-migrate @ 10014]
Luke Schierer <lschiere@pidgin.im>
parents: 9211
diff changeset
190 data = g_new0(MsnMoveBuddy, 1);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 data->who = g_strdup(who);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 if (old_group_name)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 data->old_group_name = g_strdup(old_group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
197 /*TODO:add new group via SOAP action*/
19749
38e4a4b404e5 [gaim-migrate @ 16685]
Ma Yuan <mayuan2006@gmail.com>
parents: 19745
diff changeset
198
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 /**************************************************************************
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 * Server functions
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 **************************************************************************/
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 MsnListId
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 msn_get_list_id(const char *list)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 if (list[0] == 'F')
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 return MSN_LIST_FL;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 else if (list[0] == 'A')
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 return MSN_LIST_AL;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 else if (list[0] == 'B')
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 return MSN_LIST_BL;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 else if (list[0] == 'R')
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 return MSN_LIST_RL;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 return -1;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 msn_got_add_user(MsnSession *session, MsnUser *user,
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
222 MsnListId list_id, const char * group_id)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 GaimAccount *account;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 const char *passport;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 const char *friendly;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
19753
88b0c434259a [gaim-migrate @ 16733]
Ma Yuan <mayuan2006@gmail.com>
parents: 19750
diff changeset
228 gaim_debug_info("MaYuan","got add user...\n");
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 account = session->account;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 passport = msn_user_get_passport(user);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 friendly = msn_user_get_friendly_name(user);
9197
ec417d2f9666 [gaim-migrate @ 9992]
Christian Hammond <chipx86@chipx86.com>
parents: 9196
diff changeset
233
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234 if (list_id == MSN_LIST_FL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 {
9861
68561f39acdc [gaim-migrate @ 10740]
Luke Schierer <lschiere@pidgin.im>
parents: 9860
diff changeset
236 GaimConnection *gc;
68561f39acdc [gaim-migrate @ 10740]
Luke Schierer <lschiere@pidgin.im>
parents: 9860
diff changeset
237
68561f39acdc [gaim-migrate @ 10740]
Luke Schierer <lschiere@pidgin.im>
parents: 9860
diff changeset
238 gc = gaim_account_get_connection(account);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 serv_got_alias(gc, passport, friendly);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
242 if (group_id != NULL)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 msn_user_add_group_id(user, group_id);
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
245 }else{
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 /* session->sync->fl_users_count++; */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 }
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
248 }else if (list_id == MSN_LIST_AL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 gaim_privacy_permit_add(account, passport, TRUE);
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
250 }else if (list_id == MSN_LIST_BL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 gaim_privacy_deny_add(account, passport, TRUE);
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
252 }else if (list_id == MSN_LIST_RL){
9861
68561f39acdc [gaim-migrate @ 10740]
Luke Schierer <lschiere@pidgin.im>
parents: 9860
diff changeset
253 GaimConnection *gc;
11039
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
254 GaimConversation *convo;
9861
68561f39acdc [gaim-migrate @ 10740]
Luke Schierer <lschiere@pidgin.im>
parents: 9860
diff changeset
255
68561f39acdc [gaim-migrate @ 10740]
Luke Schierer <lschiere@pidgin.im>
parents: 9860
diff changeset
256 gc = gaim_account_get_connection(account);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 gaim_debug_info("msn",
12318
e346a085bb4f [gaim-migrate @ 14622]
Richard Laager <rlaager@wiktel.com>
parents: 11638
diff changeset
259 "%s has added you to his or her buddy list.\n",
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 passport);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11058
diff changeset
262 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, passport, account);
11039
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
263 if (convo) {
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
264 GaimBuddy *buddy;
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
265 char *msg;
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
266
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
267 buddy = gaim_find_buddy(account, passport);
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
268 msg = g_strdup_printf(
12318
e346a085bb4f [gaim-migrate @ 14622]
Richard Laager <rlaager@wiktel.com>
parents: 11638
diff changeset
269 _("%s has added you to his or her buddy list."),
11039
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
270 buddy ? gaim_buddy_get_contact_alias(buddy) : passport);
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
271 gaim_conv_im_write(GAIM_CONV_IM(convo), passport, msg,
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
272 GAIM_MESSAGE_SYSTEM, time(NULL));
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
273 g_free(msg);
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
274 }
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
275
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
276 if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))){
13827
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
277 /*
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
278 * TODO: The friendly name was NULL for me when I
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
279 * looked at this. Maybe we should use the store
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
280 * name instead? --KingAnt
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
281 */
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 got_new_entry(gc, passport, friendly);
9223
f46154d6de2b [gaim-migrate @ 10019]
Christian Hammond <chipx86@chipx86.com>
parents: 9218
diff changeset
283 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 user->list_op |= (1 << list_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 /* gaim_user_add_list_id (user, list_id); */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 msn_got_rem_user(MsnSession *session, MsnUser *user,
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
292 MsnListId list_id, const char * group_id)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 GaimAccount *account;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 const char *passport;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 account = session->account;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 passport = msn_user_get_passport(user);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
301 if (list_id == MSN_LIST_FL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 /* TODO: When is the user totally removed? */
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
303 if (group_id != NULL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 msn_user_remove_group_id(user, group_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 return;
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
306 }else{
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 /* session->sync->fl_users_count--; */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 }
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
309 }else if (list_id == MSN_LIST_AL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 gaim_privacy_permit_remove(account, passport, TRUE);
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
311 }else if (list_id == MSN_LIST_BL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 gaim_privacy_deny_remove(account, passport, TRUE);
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
313 }else if (list_id == MSN_LIST_RL){
11039
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
314 GaimConversation *convo;
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
315
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 gaim_debug_info("msn",
12318
e346a085bb4f [gaim-migrate @ 14622]
Richard Laager <rlaager@wiktel.com>
parents: 11638
diff changeset
317 "%s has removed you from his or her buddy list.\n",
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 passport);
11039
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
319
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11058
diff changeset
320 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, passport, account);
11039
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
321 if (convo) {
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
322 GaimBuddy *buddy;
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
323 char *msg;
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
324
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
325 buddy = gaim_find_buddy(account, passport);
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
326 msg = g_strdup_printf(
12318
e346a085bb4f [gaim-migrate @ 14622]
Richard Laager <rlaager@wiktel.com>
parents: 11638
diff changeset
327 _("%s has removed you from his or her buddy list."),
11039
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
328 buddy ? gaim_buddy_get_contact_alias(buddy) : passport);
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
329 gaim_conv_im_write(GAIM_CONV_IM(convo), passport, msg,
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
330 GAIM_MESSAGE_SYSTEM, time(NULL));
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
331 g_free(msg);
34d2aac7b34f [gaim-migrate @ 12938]
Richard Laager <rlaager@wiktel.com>
parents: 10774
diff changeset
332 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 user->list_op &= ~(1 << list_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 /* gaim_user_remove_list_id (user, list_id); */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
338 if (user->list_op == 0){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 gaim_debug_info("msn", "Buddy '%s' shall be deleted?.\n",
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 passport);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 msn_got_lst_user(MsnSession *session, MsnUser *user,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 int list_op, GSList *group_ids)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 GaimConnection *gc;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 GaimAccount *account;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 const char *passport;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 const char *store;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 account = session->account;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 gc = gaim_account_get_connection(account);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 passport = msn_user_get_passport(user);
9211
74c81f56b0a5 [gaim-migrate @ 10006]
Christian Hammond <chipx86@chipx86.com>
parents: 9210
diff changeset
357 store = msn_user_get_store_name(user);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
359 if (list_op & MSN_LIST_FL_OP){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 GSList *c;
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
361 for (c = group_ids; c != NULL; c = g_slist_next(c)) {
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
362 char *group_id;
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
363 group_id = c->data;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 msn_user_add_group_id(user, group_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 /* FIXME: It might be a real alias */
13448
4b8dcf7c38a2 [gaim-migrate @ 15823]
Stu Tomlinson <stu@nosnilmot.com>
parents: 13125
diff changeset
368 /* Umm, what? This might fix bug #1385130 */
4b8dcf7c38a2 [gaim-migrate @ 15823]
Stu Tomlinson <stu@nosnilmot.com>
parents: 13125
diff changeset
369 serv_got_alias(gc, passport, store);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
372 if (list_op & MSN_LIST_AL_OP){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 /* These are users who are allowed to see our status. */
13692
ea77ce998dc7 [gaim-migrate @ 16095]
Richard Laager <rlaager@wiktel.com>
parents: 13448
diff changeset
374 gaim_privacy_deny_remove(account, passport, TRUE);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 gaim_privacy_permit_add(account, passport, TRUE);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
378 if (list_op & MSN_LIST_BL_OP){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 /* These are users who are not allowed to see our status. */
13692
ea77ce998dc7 [gaim-migrate @ 16095]
Richard Laager <rlaager@wiktel.com>
parents: 13448
diff changeset
380 gaim_privacy_permit_remove(account, passport, TRUE);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 gaim_privacy_deny_add(account, passport, TRUE);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
384 if (list_op & MSN_LIST_RL_OP){
12318
e346a085bb4f [gaim-migrate @ 14622]
Richard Laager <rlaager@wiktel.com>
parents: 11638
diff changeset
385 /* These are users who have us on their buddy list. */
13827
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
386 /*
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
387 * TODO: What is store name set to when this happens?
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
388 * For one of my accounts "something@hotmail.com"
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
389 * the store name was "something." Maybe we
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
390 * should use the friendly name, instead? --KingAnt
6c3c8d0d389f [gaim-migrate @ 16271]
Mark Doliner <mark@kingant.net>
parents: 13692
diff changeset
391 */
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
393 if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 got_new_entry(gc, passport, store);
9225
554ef91db2dd [gaim-migrate @ 10021]
Christian Hammond <chipx86@chipx86.com>
parents: 9223
diff changeset
395 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
398 user->list_op |= list_op;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 /**************************************************************************
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 * UserList functions
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 **************************************************************************/
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 MsnUserList*
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 msn_userlist_new(MsnSession *session)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 MsnUserList *userlist;
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
409
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 userlist = g_new0(MsnUserList, 1);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 userlist->session = session;
9860
65b3156f9f48 [gaim-migrate @ 10739]
Luke Schierer <lschiere@pidgin.im>
parents: 9857
diff changeset
413 userlist->buddy_icon_requests = g_queue_new();
13125
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
414
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
415 /* buddy_icon_window is the number of allowed simultaneous buddy icon requests.
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
416 * XXX With smarter rate limiting code, we could allow more at once... 5 was the limit set when
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
417 * we weren't retrieiving any more than 5 per MSN session. */
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
418 userlist->buddy_icon_window = 1;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 return userlist;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 msn_userlist_destroy(MsnUserList *userlist)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 GList *l;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
428 /*destroy userlist*/
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
429 for (l = userlist->users; l != NULL; l = l->next){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 msn_user_destroy(l->data);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 g_list_free(userlist->users);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
434 /*destroy group list*/
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
435 for (l = userlist->groups; l != NULL; l = l->next){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436 msn_group_destroy(l->data);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 g_list_free(userlist->groups);
9895
1dfebce5eac9 [gaim-migrate @ 10784]
Luke Schierer <lschiere@pidgin.im>
parents: 9861
diff changeset
439
1dfebce5eac9 [gaim-migrate @ 10784]
Luke Schierer <lschiere@pidgin.im>
parents: 9861
diff changeset
440 g_queue_free(userlist->buddy_icon_requests);
13125
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
441
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
442 if (userlist->buddy_icon_request_timer)
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
443 gaim_timeout_remove(userlist->buddy_icon_request_timer);
442b23efba54 [gaim-migrate @ 15487]
Mark Doliner <mark@kingant.net>
parents: 12381
diff changeset
444
9857
d326dd512662 [gaim-migrate @ 10736]
Luke Schierer <lschiere@pidgin.im>
parents: 9225
diff changeset
445 g_free(userlist);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447
19754
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
448 MsnUser *
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
449 msn_userlist_find_add_user(MsnUserList *userlist,const char *passport,const char *userName)
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
450 {
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
451 MsnUser *user;
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
452
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
453 user = msn_userlist_find_user(userlist, passport);
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
454 if (user == NULL){
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
455 user = msn_user_new(userlist, passport, userName);
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
456 msn_userlist_add_user(userlist, user);
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
457 }
19764
da1075366756 [gaim-migrate @ 16885]
Ma Yuan <mayuan2006@gmail.com>
parents: 19754
diff changeset
458 msn_user_set_store_name(user, userName);
19754
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
459 return user;
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
460 }
da3f8f7ec3ce [gaim-migrate @ 16737]
Ma Yuan <mayuan2006@gmail.com>
parents: 19753
diff changeset
461
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463 msn_userlist_add_user(MsnUserList *userlist, MsnUser *user)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465 userlist->users = g_list_append(userlist->users, user);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
466 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
467
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
468 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
469 msn_userlist_remove_user(MsnUserList *userlist, MsnUser *user)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
471 userlist->users = g_list_remove(userlist->users, user);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
473
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
474 MsnUser *
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
475 msn_userlist_find_user(MsnUserList *userlist, const char *passport)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
476 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
477 GList *l;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
478
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
479 g_return_val_if_fail(passport != NULL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
481 for (l = userlist->users; l != NULL; l = l->next){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482 MsnUser *user = (MsnUser *)l->data;
19741
b99512bd6d85 [gaim-migrate @ 16547]
Ma Yuan <mayuan2006@gmail.com>
parents: 19740
diff changeset
483 // gaim_debug_info("MsnUserList","user passport:%s,passport:%s\n",user->passport,passport);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
484 g_return_val_if_fail(user->passport != NULL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
485
19741
b99512bd6d85 [gaim-migrate @ 16547]
Ma Yuan <mayuan2006@gmail.com>
parents: 19740
diff changeset
486 if (!g_strcasecmp(passport, user->passport)){
b99512bd6d85 [gaim-migrate @ 16547]
Ma Yuan <mayuan2006@gmail.com>
parents: 19740
diff changeset
487 // gaim_debug_info("MsnUserList","return:%p\n",user);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488 return user;
19741
b99512bd6d85 [gaim-migrate @ 16547]
Ma Yuan <mayuan2006@gmail.com>
parents: 19740
diff changeset
489 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 return NULL;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
494
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
495 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
496 msn_userlist_add_group(MsnUserList *userlist, MsnGroup *group)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
498 userlist->groups = g_list_append(userlist->groups, group);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 msn_userlist_remove_group(MsnUserList *userlist, MsnGroup *group)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 userlist->groups = g_list_remove(userlist->groups, group);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
505 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507 MsnGroup *
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
508 msn_userlist_find_group_with_id(MsnUserList *userlist, const char * id)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510 GList *l;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512 g_return_val_if_fail(userlist != NULL, NULL);
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
513 g_return_val_if_fail(id != NULL, NULL);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
515 for (l = userlist->groups; l != NULL; l = l->next){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516 MsnGroup *group = l->data;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
518 if (!g_strcasecmp(group->id,id))
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
519 return group;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
520 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
521
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522 return NULL;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
523 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
524
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
525 MsnGroup *
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
526 msn_userlist_find_group_with_name(MsnUserList *userlist, const char *name)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
527 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
528 GList *l;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
529
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
530 g_return_val_if_fail(userlist != NULL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
531 g_return_val_if_fail(name != NULL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
532
19741
b99512bd6d85 [gaim-migrate @ 16547]
Ma Yuan <mayuan2006@gmail.com>
parents: 19740
diff changeset
533 for (l = userlist->groups; l != NULL; l = l->next){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
534 MsnGroup *group = l->data;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
535
19741
b99512bd6d85 [gaim-migrate @ 16547]
Ma Yuan <mayuan2006@gmail.com>
parents: 19740
diff changeset
536 if ((group->name != NULL) && !g_strcasecmp(name, group->name))
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
537 return group;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
538 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
539
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
540 return NULL;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
541 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
542
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
543 const char *
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
544 msn_userlist_find_group_id(MsnUserList *userlist, const char *group_name)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
545 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
546 MsnGroup *group;
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
547
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
548 group = msn_userlist_find_group_with_name(userlist, group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
549
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
550 if (group != NULL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
551 return msn_group_get_id(group);
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
552 }else{
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
553 return NULL;
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
554 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
555 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
556
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
557 const char *
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
558 msn_userlist_find_group_name(MsnUserList *userlist, const char * group_id)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
559 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
560 MsnGroup *group;
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9197
diff changeset
561
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
562 group = msn_userlist_find_group_with_id(userlist, group_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
563
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
564 if (group != NULL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
565 return msn_group_get_name(group);
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
566 }else{
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
567 return NULL;
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
568 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
569 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
570
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
571 void
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
572 msn_userlist_rename_group_id(MsnUserList *userlist, const char * group_id,
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
573 const char *new_name)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
574 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
575 MsnGroup *group;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
577 group = msn_userlist_find_group_with_id(userlist, group_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
578
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
579 if (group != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
580 msn_group_set_name(group, new_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
581 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
582
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
583 void
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
584 msn_userlist_remove_group_id(MsnUserList *userlist, const char * group_id)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
585 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
586 MsnGroup *group;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
587
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
588 group = msn_userlist_find_group_with_id(userlist, group_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
589
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
590 if (group != NULL)
10533
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
591 {
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
592 msn_userlist_remove_group(userlist, group);
10533
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
593 msn_group_destroy(group);
ace8cd0de6ea [gaim-migrate @ 11862]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10504
diff changeset
594 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
595 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
596
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
597 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
598 msn_userlist_rem_buddy(MsnUserList *userlist,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
599 const char *who, int list_id, const char *group_name)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
600 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
601 MsnUser *user;
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
602 const char *group_id;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
603 const char *list;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
604
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
605 user = msn_userlist_find_user(userlist, who);
19750
3a15b4e5c336 [gaim-migrate @ 16716]
Ma Yuan <mayuan2006@gmail.com>
parents: 19749
diff changeset
606
3a15b4e5c336 [gaim-migrate @ 16716]
Ma Yuan <mayuan2006@gmail.com>
parents: 19749
diff changeset
607 /*delete the contact from address book via soap action*/
3a15b4e5c336 [gaim-migrate @ 16716]
Ma Yuan <mayuan2006@gmail.com>
parents: 19749
diff changeset
608 msn_delete_contact(userlist->session->contact,user->uid);
3a15b4e5c336 [gaim-migrate @ 16716]
Ma Yuan <mayuan2006@gmail.com>
parents: 19749
diff changeset
609
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
610 group_id = NULL;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
611
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
612 if (group_name != NULL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
613 group_id = msn_userlist_find_group_id(userlist, group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
614
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
615 if (group_id == NULL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
616 /* Whoa, there is no such group. */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
617 gaim_debug_error("msn", "Group doesn't exist: %s\n", group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
618 return;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
619 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
620 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
621
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
622 /* First we're going to check if not there. */
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
623 if (!(user_is_there(user, list_id, group_id))){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
624 list = lists[list_id];
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
625 gaim_debug_error("msn", "User '%s' is not there: %s\n",
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
626 who, list);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
627 return;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
628 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
629
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
630 /* Then request the rem to the server. */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
631 list = lists[list_id];
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
632
19750
3a15b4e5c336 [gaim-migrate @ 16716]
Ma Yuan <mayuan2006@gmail.com>
parents: 19749
diff changeset
633 // msn_notification_rem_buddy(userlist->session->notification, list, who, group_id);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
634 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
635
19745
bddd32f36bde [gaim-migrate @ 16653]
Ma Yuan <mayuan2006@gmail.com>
parents: 19741
diff changeset
636 /*add buddy*/
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
637 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
638 msn_userlist_add_buddy(MsnUserList *userlist,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
639 const char *who, int list_id,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
640 const char *group_name)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
641 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
642 MsnUser *user;
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
643 const char *group_id;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
644 const char *list;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
645 const char *store_name;
9194
364aa73323b5 [gaim-migrate @ 9989]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
646
19750
3a15b4e5c336 [gaim-migrate @ 16716]
Ma Yuan <mayuan2006@gmail.com>
parents: 19749
diff changeset
647 gaim_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name);
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
648 group_id = NULL;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
649
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
650 if (!gaim_email_is_valid(who)){
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
651 /* only notify the user about problems adding to the friends list
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
652 * maybe we should do something else for other lists, but it probably
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
653 * won't cause too many problems if we just ignore it */
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
654 if (list_id == MSN_LIST_FL) {
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
655 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who);
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
656 gaim_notify_error(NULL, NULL, str,
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
657 _("The screen name specified is invalid."));
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
658 g_free(str);
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
659 }
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11624
diff changeset
660
11057
e9eeacd1a8d0 [gaim-migrate @ 13009]
Richard Laager <rlaager@wiktel.com>
parents: 11039
diff changeset
661 return;
e9eeacd1a8d0 [gaim-migrate @ 13009]
Richard Laager <rlaager@wiktel.com>
parents: 11039
diff changeset
662 }
e9eeacd1a8d0 [gaim-migrate @ 13009]
Richard Laager <rlaager@wiktel.com>
parents: 11039
diff changeset
663
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
664 if (group_name != NULL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
665 group_id = msn_userlist_find_group_id(userlist, group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
666
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
667 if (group_id == NULL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
668 /* Whoa, we must add that group first. */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
669 msn_request_add_group(userlist, who, NULL, group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
670 return;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
671 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
672 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
673
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
674 user = msn_userlist_find_user(userlist, who);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
675
9194
364aa73323b5 [gaim-migrate @ 9989]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
676 /* First we're going to check if it's already there. */
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
677 if (user_is_there(user, list_id, group_id)){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
678 list = lists[list_id];
9194
364aa73323b5 [gaim-migrate @ 9989]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
679 gaim_debug_error("msn", "User '%s' is already there: %s\n", who, list);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
680 return;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
681 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
682
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
683 store_name = (user != NULL) ? get_store_name(user) : who;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
684
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
685 /* Then request the add to the server. */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
686 list = lists[list_id];
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
687
19750
3a15b4e5c336 [gaim-migrate @ 16716]
Ma Yuan <mayuan2006@gmail.com>
parents: 19749
diff changeset
688 gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id);
3a15b4e5c336 [gaim-migrate @ 16716]
Ma Yuan <mayuan2006@gmail.com>
parents: 19749
diff changeset
689 msn_add_contact(userlist->session->contact,who,group_id);
19753
88b0c434259a [gaim-migrate @ 16733]
Ma Yuan <mayuan2006@gmail.com>
parents: 19750
diff changeset
690 msn_notification_add_buddy(userlist->session->notification, list, who,
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
691 store_name, group_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
692 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
693
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
694 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
695 msn_userlist_move_buddy(MsnUserList *userlist, const char *who,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
696 const char *old_group_name, const char *new_group_name)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
697 {
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
698 const char *new_group_id;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
699
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
700 new_group_id = msn_userlist_find_group_id(userlist, new_group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
701
19740
23258253c7a0 [gaim-migrate @ 16546]
Ma Yuan <mayuan2006@gmail.com>
parents: 19739
diff changeset
702 if (new_group_id == NULL){
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
703 msn_request_add_group(userlist, who, old_group_name, new_group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
704 return;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
705 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
706
10568
fed2a7c2471d [gaim-migrate @ 11954]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10533
diff changeset
707 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, new_group_name);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
708 msn_userlist_rem_buddy(userlist, who, MSN_LIST_FL, old_group_name);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
709 }
19739
852b32710df0 [gaim-migrate @ 16507]
Ma Yuan <mayuan2006@gmail.com>
parents: 13827
diff changeset
710