1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
1 |
/**
|
2 |
* @file userlist.c MSN user list support
|
|
3 |
*
|
|
4 |
* purple
|
|
5 |
*
|
|
6 |
* Purple is the legal property of its developers, whose names are too numerous
|
|
7 |
* to list here. Please refer to the COPYRIGHT file distributed with this
|
|
8 |
* source distribution.
|
|
9 |
*
|
|
10 |
* This program is free software; you can redistribute it and/or modify
|
|
11 |
* it under the terms of the GNU General Public License as published by
|
|
12 |
* the Free Software Foundation; either version 2 of the License, or
|
|
13 |
* (at your option) any later version.
|
|
14 |
*
|
|
15 |
* This program is distributed in the hope that it will be useful,
|
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 |
* GNU General Public License for more details.
|
|
19 |
*
|
|
20 |
* You should have received a copy of the GNU General Public License
|
|
21 |
* along with this program; if not, write to the Free Software
|
|
1.1.4
by Sebastien Bacher
Import upstream version 2.2.0 |
22 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
23 |
*/
|
24 |
#include "msn.h" |
|
25 |
#include "userlist.h" |
|
26 |
||
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
27 |
#include "contact.h" |
28 |
||
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
29 |
const char *lists[] = { "FL", "AL", "BL", "RL" }; |
30 |
||
31 |
typedef struct |
|
32 |
{
|
|
33 |
PurpleConnection *gc; |
|
34 |
char *who; |
|
35 |
char *friendly; |
|
36 |
||
37 |
} MsnPermitAdd; |
|
38 |
||
39 |
/**************************************************************************
|
|
40 |
* Callbacks
|
|
41 |
**************************************************************************/
|
|
42 |
static void |
|
1.1.3
by Sebastien Bacher
Import upstream version 2.1.1 |
43 |
msn_accept_add_cb(gpointer data) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
44 |
{
|
1.1.3
by Sebastien Bacher
Import upstream version 2.1.1 |
45 |
MsnPermitAdd *pa = data; |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
46 |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
47 |
purple_debug_misc("msn", "Accepted the new buddy: %s\n", pa->who); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
48 |
|
49 |
if (PURPLE_CONNECTION_IS_VALID(pa->gc)) |
|
50 |
{
|
|
51 |
MsnSession *session = pa->gc->proto_data; |
|
52 |
MsnUserList *userlist = session->userlist; |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
53 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
54 |
msn_userlist_add_buddy_to_list(userlist, pa->who, MSN_LIST_AL); |
55 |
||
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
56 |
msn_del_contact_from_list(session, NULL, pa->who, MSN_LIST_PL); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
57 |
}
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
58 |
|
59 |
g_free(pa->who); |
|
60 |
g_free(pa->friendly); |
|
61 |
g_free(pa); |
|
62 |
}
|
|
63 |
||
64 |
static void |
|
1.1.3
by Sebastien Bacher
Import upstream version 2.1.1 |
65 |
msn_cancel_add_cb(gpointer data) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
66 |
{
|
1.1.3
by Sebastien Bacher
Import upstream version 2.1.1 |
67 |
MsnPermitAdd *pa = data; |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
68 |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
69 |
purple_debug_misc("msn", "Denied the new buddy: %s\n", pa->who); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
70 |
|
71 |
if (PURPLE_CONNECTION_IS_VALID(pa->gc)) |
|
72 |
{
|
|
73 |
MsnSession *session = pa->gc->proto_data; |
|
74 |
MsnUserList *userlist = session->userlist; |
|
75 |
MsnCallbackState *state = msn_callback_state_new(session); |
|
76 |
||
77 |
msn_callback_state_set_action(state, MSN_DENIED_BUDDY); |
|
78 |
||
79 |
msn_userlist_add_buddy_to_list(userlist, pa->who, MSN_LIST_BL); |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
80 |
msn_del_contact_from_list(session, state, pa->who, MSN_LIST_PL); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
81 |
}
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
82 |
|
83 |
g_free(pa->who); |
|
84 |
g_free(pa->friendly); |
|
85 |
g_free(pa); |
|
86 |
}
|
|
87 |
||
88 |
static void |
|
89 |
got_new_entry(PurpleConnection *gc, const char *passport, const char *friendly) |
|
90 |
{
|
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
91 |
PurpleAccount *acct; |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
92 |
MsnPermitAdd *pa; |
93 |
||
94 |
pa = g_new0(MsnPermitAdd, 1); |
|
95 |
pa->who = g_strdup(passport); |
|
96 |
pa->friendly = g_strdup(friendly); |
|
97 |
pa->gc = gc; |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
98 |
|
99 |
acct = purple_connection_get_account(gc); |
|
100 |
purple_account_request_authorization(acct, passport, NULL, friendly, NULL, |
|
101 |
purple_find_buddy(acct, passport) != NULL, |
|
102 |
msn_accept_add_cb, msn_cancel_add_cb, pa); |
|
103 |
||
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
104 |
}
|
105 |
||
106 |
/**************************************************************************
|
|
107 |
* Utility functions
|
|
108 |
**************************************************************************/
|
|
109 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
110 |
gboolean
|
111 |
msn_userlist_user_is_in_group(MsnUser *user, const char * group_id) |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
112 |
{
|
113 |
if (user == NULL) |
|
114 |
return FALSE; |
|
115 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
116 |
if (group_id == NULL) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
117 |
return FALSE; |
118 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
119 |
if (g_list_find_custom(user->group_ids, group_id, (GCompareFunc)strcmp)) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
120 |
return TRUE; |
121 |
||
122 |
return FALSE; |
|
123 |
}
|
|
124 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
125 |
gboolean
|
126 |
msn_userlist_user_is_in_list(MsnUser *user, MsnListId list_id) |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
127 |
{
|
128 |
int list_op; |
|
129 |
||
130 |
if (user == NULL) |
|
131 |
return FALSE; |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
132 |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
133 |
list_op = 1 << list_id; |
134 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
135 |
if (user->list_op & list_op) |
136 |
return TRUE; |
|
137 |
else
|
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
138 |
return FALSE; |
139 |
}
|
|
140 |
||
141 |
/**************************************************************************
|
|
142 |
* Server functions
|
|
143 |
**************************************************************************/
|
|
144 |
||
145 |
MsnListId
|
|
146 |
msn_get_list_id(const char *list) |
|
147 |
{
|
|
148 |
if (list[0] == 'F') |
|
149 |
return MSN_LIST_FL; |
|
150 |
else if (list[0] == 'A') |
|
151 |
return MSN_LIST_AL; |
|
152 |
else if (list[0] == 'B') |
|
153 |
return MSN_LIST_BL; |
|
154 |
else if (list[0] == 'R') |
|
155 |
return MSN_LIST_RL; |
|
156 |
||
157 |
return -1; |
|
158 |
}
|
|
159 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
160 |
/* this function msn_got_add_user isn't called anywhere */
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
161 |
void
|
162 |
msn_got_add_user(MsnSession *session, MsnUser *user, |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
163 |
MsnListId list_id, const char * group_id) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
164 |
{
|
165 |
PurpleAccount *account; |
|
166 |
const char *passport; |
|
167 |
const char *friendly; |
|
168 |
||
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
169 |
purple_debug_info("msn", "got add user...\n"); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
170 |
account = session->account; |
171 |
||
172 |
passport = msn_user_get_passport(user); |
|
173 |
friendly = msn_user_get_friendly_name(user); |
|
174 |
||
175 |
if (list_id == MSN_LIST_FL) |
|
176 |
{
|
|
177 |
PurpleConnection *gc; |
|
178 |
||
179 |
gc = purple_account_get_connection(account); |
|
180 |
||
181 |
serv_got_alias(gc, passport, friendly); |
|
182 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
183 |
if (group_id != NULL) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
184 |
{
|
185 |
msn_user_add_group_id(user, group_id); |
|
186 |
}
|
|
187 |
else
|
|
188 |
{
|
|
189 |
/* session->sync->fl_users_count++; */
|
|
190 |
}
|
|
191 |
}
|
|
192 |
else if (list_id == MSN_LIST_AL) |
|
193 |
{
|
|
194 |
purple_privacy_permit_add(account, passport, TRUE); |
|
195 |
}
|
|
196 |
else if (list_id == MSN_LIST_BL) |
|
197 |
{
|
|
198 |
purple_privacy_deny_add(account, passport, TRUE); |
|
199 |
}
|
|
200 |
else if (list_id == MSN_LIST_RL) |
|
201 |
{
|
|
202 |
PurpleConversation *convo; |
|
203 |
||
204 |
purple_debug_info("msn", |
|
205 |
"%s has added you to his or her buddy list.\n", |
|
206 |
passport); |
|
207 |
||
208 |
convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, passport, account); |
|
209 |
if (convo) { |
|
210 |
PurpleBuddy *buddy; |
|
211 |
char *msg; |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
212 |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
213 |
buddy = purple_find_buddy(account, passport); |
214 |
msg = g_strdup_printf( |
|
215 |
_("%s has added you to his or her buddy list."), |
|
216 |
buddy ? purple_buddy_get_contact_alias(buddy) : passport); |
|
217 |
purple_conv_im_write(PURPLE_CONV_IM(convo), passport, msg, |
|
218 |
PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
219 |
g_free(msg); |
|
220 |
}
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
221 |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
222 |
if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) |
223 |
{
|
|
224 |
/*
|
|
225 |
* TODO: The friendly name was NULL for me when I
|
|
226 |
* looked at this. Maybe we should use the store
|
|
227 |
* name instead? --KingAnt
|
|
228 |
*/
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
229 |
/* got_new_entry(gc, passport, friendly); */
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
230 |
}
|
231 |
}
|
|
232 |
||
233 |
user->list_op |= (1 << list_id); |
|
234 |
/* purple_user_add_list_id (user, list_id); */
|
|
235 |
}
|
|
236 |
||
237 |
void
|
|
238 |
msn_got_rem_user(MsnSession *session, MsnUser *user, |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
239 |
MsnListId list_id, const char * group_id) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
240 |
{
|
241 |
PurpleAccount *account; |
|
242 |
const char *passport; |
|
243 |
||
244 |
account = session->account; |
|
245 |
||
246 |
passport = msn_user_get_passport(user); |
|
247 |
||
248 |
if (list_id == MSN_LIST_FL) |
|
249 |
{
|
|
250 |
/* TODO: When is the user totally removed? */
|
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
251 |
if (group_id != NULL) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
252 |
{
|
253 |
msn_user_remove_group_id(user, group_id); |
|
254 |
return; |
|
255 |
}
|
|
256 |
else
|
|
257 |
{
|
|
258 |
/* session->sync->fl_users_count--; */
|
|
259 |
}
|
|
260 |
}
|
|
261 |
else if (list_id == MSN_LIST_AL) |
|
262 |
{
|
|
263 |
purple_privacy_permit_remove(account, passport, TRUE); |
|
264 |
}
|
|
265 |
else if (list_id == MSN_LIST_BL) |
|
266 |
{
|
|
267 |
purple_privacy_deny_remove(account, passport, TRUE); |
|
268 |
}
|
|
269 |
else if (list_id == MSN_LIST_RL) |
|
270 |
{
|
|
271 |
PurpleConversation *convo; |
|
272 |
||
273 |
purple_debug_info("msn", |
|
274 |
"%s has removed you from his or her buddy list.\n", |
|
275 |
passport); |
|
276 |
||
277 |
convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, passport, account); |
|
278 |
if (convo) { |
|
279 |
PurpleBuddy *buddy; |
|
280 |
char *msg; |
|
281 |
||
282 |
buddy = purple_find_buddy(account, passport); |
|
283 |
msg = g_strdup_printf( |
|
284 |
_("%s has removed you from his or her buddy list."), |
|
285 |
buddy ? purple_buddy_get_contact_alias(buddy) : passport); |
|
286 |
purple_conv_im_write(PURPLE_CONV_IM(convo), passport, msg, |
|
287 |
PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
288 |
g_free(msg); |
|
289 |
}
|
|
290 |
}
|
|
291 |
||
292 |
user->list_op &= ~(1 << list_id); |
|
293 |
/* purple_user_remove_list_id (user, list_id); */
|
|
294 |
||
295 |
if (user->list_op == 0) |
|
296 |
{
|
|
297 |
purple_debug_info("msn", "Buddy '%s' shall be deleted?.\n", |
|
298 |
passport); |
|
299 |
}
|
|
300 |
}
|
|
301 |
||
302 |
void
|
|
303 |
msn_got_lst_user(MsnSession *session, MsnUser *user, |
|
304 |
int list_op, GSList *group_ids) |
|
305 |
{
|
|
306 |
PurpleConnection *gc; |
|
307 |
PurpleAccount *account; |
|
308 |
const char *passport; |
|
309 |
const char *store; |
|
310 |
||
311 |
account = session->account; |
|
312 |
gc = purple_account_get_connection(account); |
|
313 |
||
314 |
passport = msn_user_get_passport(user); |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
315 |
store = msn_user_get_friendly_name(user); |
316 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
317 |
msn_user_set_op(user, list_op); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
318 |
|
319 |
if (list_op & MSN_LIST_FL_OP) |
|
320 |
{
|
|
321 |
GSList *c; |
|
322 |
for (c = group_ids; c != NULL; c = g_slist_next(c)) |
|
323 |
{
|
|
1.1.10
by Pedro Fragoso
Import upstream version 2.4.2 |
324 |
char *group_id = c->data; |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
325 |
msn_user_add_group_id(user, group_id); |
326 |
}
|
|
327 |
||
328 |
/* FIXME: It might be a real alias */
|
|
329 |
/* Umm, what? This might fix bug #1385130 */
|
|
330 |
serv_got_alias(gc, passport, store); |
|
331 |
}
|
|
332 |
||
333 |
if (list_op & MSN_LIST_AL_OP) |
|
334 |
{
|
|
335 |
/* These are users who are allowed to see our status. */
|
|
336 |
purple_privacy_deny_remove(account, passport, TRUE); |
|
337 |
purple_privacy_permit_add(account, passport, TRUE); |
|
338 |
}
|
|
339 |
||
340 |
if (list_op & MSN_LIST_BL_OP) |
|
341 |
{
|
|
342 |
/* These are users who are not allowed to see our status. */
|
|
343 |
purple_privacy_permit_remove(account, passport, TRUE); |
|
344 |
purple_privacy_deny_add(account, passport, TRUE); |
|
345 |
}
|
|
346 |
||
347 |
if (list_op & MSN_LIST_RL_OP) |
|
348 |
{
|
|
349 |
/* These are users who have us on their buddy list. */
|
|
350 |
/*
|
|
351 |
* TODO: What is store name set to when this happens?
|
|
352 |
* For one of my accounts "something@hotmail.com"
|
|
353 |
* the store name was "something." Maybe we
|
|
354 |
* should use the friendly name, instead? --KingAnt
|
|
355 |
*/
|
|
356 |
||
357 |
if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) |
|
358 |
{
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
359 |
/* got_new_entry(gc, passport, store); */
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
360 |
}
|
361 |
}
|
|
362 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
363 |
if (list_op & MSN_LIST_PL_OP) |
364 |
{
|
|
365 |
got_new_entry(gc, passport, store); |
|
366 |
}
|
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
367 |
}
|
368 |
||
369 |
/**************************************************************************
|
|
370 |
* UserList functions
|
|
371 |
**************************************************************************/
|
|
372 |
||
373 |
MsnUserList* |
|
374 |
msn_userlist_new(MsnSession *session) |
|
375 |
{
|
|
376 |
MsnUserList *userlist; |
|
377 |
||
378 |
userlist = g_new0(MsnUserList, 1); |
|
379 |
||
380 |
userlist->session = session; |
|
381 |
userlist->buddy_icon_requests = g_queue_new(); |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
382 |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
383 |
/* buddy_icon_window is the number of allowed simultaneous buddy icon requests.
|
384 |
* XXX With smarter rate limiting code, we could allow more at once... 5 was the limit set when
|
|
385 |
* we weren't retrieiving any more than 5 per MSN session. */
|
|
386 |
userlist->buddy_icon_window = 1; |
|
387 |
||
388 |
return userlist; |
|
389 |
}
|
|
390 |
||
391 |
void
|
|
392 |
msn_userlist_destroy(MsnUserList *userlist) |
|
393 |
{
|
|
394 |
GList *l; |
|
395 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
396 |
/*destroy userlist*/
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
397 |
for (l = userlist->users; l != NULL; l = l->next) |
398 |
{
|
|
399 |
msn_user_destroy(l->data); |
|
400 |
}
|
|
401 |
g_list_free(userlist->users); |
|
402 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
403 |
/*destroy group list*/
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
404 |
for (l = userlist->groups; l != NULL; l = l->next) |
405 |
{
|
|
406 |
msn_group_destroy(l->data); |
|
407 |
}
|
|
408 |
g_list_free(userlist->groups); |
|
409 |
||
410 |
g_queue_free(userlist->buddy_icon_requests); |
|
411 |
||
412 |
if (userlist->buddy_icon_request_timer) |
|
413 |
purple_timeout_remove(userlist->buddy_icon_request_timer); |
|
414 |
||
415 |
g_free(userlist); |
|
416 |
}
|
|
417 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
418 |
MsnUser * |
419 |
msn_userlist_find_add_user(MsnUserList *userlist,const char *passport,const char *userName) |
|
420 |
{
|
|
421 |
MsnUser *user; |
|
422 |
||
423 |
user = msn_userlist_find_user(userlist, passport); |
|
424 |
if (user == NULL) |
|
425 |
{
|
|
426 |
user = msn_user_new(userlist, passport, userName); |
|
427 |
msn_userlist_add_user(userlist, user); |
|
428 |
} else { |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
429 |
msn_user_set_friendly_name(user, userName); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
430 |
}
|
431 |
return user; |
|
432 |
}
|
|
433 |
||
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
434 |
void
|
435 |
msn_userlist_add_user(MsnUserList *userlist, MsnUser *user) |
|
436 |
{
|
|
1.1.4
by Sebastien Bacher
Import upstream version 2.2.0 |
437 |
userlist->users = g_list_prepend(userlist->users, user); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
438 |
}
|
439 |
||
440 |
void
|
|
441 |
msn_userlist_remove_user(MsnUserList *userlist, MsnUser *user) |
|
442 |
{
|
|
443 |
userlist->users = g_list_remove(userlist->users, user); |
|
444 |
}
|
|
445 |
||
446 |
MsnUser * |
|
447 |
msn_userlist_find_user(MsnUserList *userlist, const char *passport) |
|
448 |
{
|
|
449 |
GList *l; |
|
450 |
||
451 |
g_return_val_if_fail(passport != NULL, NULL); |
|
452 |
||
453 |
for (l = userlist->users; l != NULL; l = l->next) |
|
454 |
{
|
|
455 |
MsnUser *user = (MsnUser *)l->data; |
|
456 |
||
457 |
g_return_val_if_fail(user->passport != NULL, NULL); |
|
458 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
459 |
if (!g_strcasecmp(passport, user->passport)){ |
460 |
return user; |
|
461 |
}
|
|
462 |
}
|
|
463 |
||
464 |
return NULL; |
|
465 |
}
|
|
466 |
||
467 |
MsnUser * |
|
468 |
msn_userlist_find_user_with_id(MsnUserList *userlist, const char *uid) |
|
469 |
{
|
|
470 |
GList *l; |
|
471 |
||
1.1.9
by Pedro Fragoso
Import upstream version 2.4.1 |
472 |
g_return_val_if_fail(uid != NULL, NULL); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
473 |
|
1.1.9
by Pedro Fragoso
Import upstream version 2.4.1 |
474 |
for (l = userlist->users; l != NULL; l = l->next) { |
475 |
MsnUser *user = (MsnUser *)l->data; |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
476 |
|
477 |
if (user->uid == NULL) { |
|
478 |
continue; |
|
479 |
}
|
|
480 |
||
481 |
if ( !g_strcasecmp(uid, user->uid) ) { |
|
482 |
return user; |
|
483 |
}
|
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
484 |
}
|
485 |
||
486 |
return NULL; |
|
487 |
}
|
|
488 |
||
1.1.9
by Pedro Fragoso
Import upstream version 2.4.1 |
489 |
MsnUser * |
490 |
msn_userlist_find_user_with_mobile_phone(MsnUserList *userlist, const char *number) |
|
491 |
{
|
|
492 |
GList *l; |
|
493 |
||
494 |
g_return_val_if_fail(number != NULL, NULL); |
|
495 |
||
496 |
for (l = userlist->users; l != NULL; l = l->next) { |
|
497 |
MsnUser *user = (MsnUser *)l->data; |
|
498 |
||
499 |
if (user->phone.mobile == NULL) { |
|
500 |
continue; |
|
501 |
}
|
|
502 |
||
503 |
if (!g_strcasecmp(number, user->phone.mobile)) { |
|
504 |
return user; |
|
505 |
}
|
|
506 |
}
|
|
507 |
||
508 |
return NULL; |
|
509 |
}
|
|
510 |
||
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
511 |
void
|
512 |
msn_userlist_add_group(MsnUserList *userlist, MsnGroup *group) |
|
513 |
{
|
|
514 |
userlist->groups = g_list_append(userlist->groups, group); |
|
515 |
}
|
|
516 |
||
517 |
void
|
|
518 |
msn_userlist_remove_group(MsnUserList *userlist, MsnGroup *group) |
|
519 |
{
|
|
520 |
userlist->groups = g_list_remove(userlist->groups, group); |
|
521 |
}
|
|
522 |
||
523 |
MsnGroup * |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
524 |
msn_userlist_find_group_with_id(MsnUserList *userlist, const char * id) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
525 |
{
|
526 |
GList *l; |
|
527 |
||
528 |
g_return_val_if_fail(userlist != NULL, NULL); |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
529 |
g_return_val_if_fail(id != NULL, NULL); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
530 |
|
531 |
for (l = userlist->groups; l != NULL; l = l->next) |
|
532 |
{
|
|
533 |
MsnGroup *group = l->data; |
|
534 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
535 |
if (!g_strcasecmp(group->id,id)) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
536 |
return group; |
537 |
}
|
|
538 |
||
539 |
return NULL; |
|
540 |
}
|
|
541 |
||
542 |
MsnGroup * |
|
543 |
msn_userlist_find_group_with_name(MsnUserList *userlist, const char *name) |
|
544 |
{
|
|
545 |
GList *l; |
|
546 |
||
547 |
g_return_val_if_fail(userlist != NULL, NULL); |
|
548 |
g_return_val_if_fail(name != NULL, NULL); |
|
549 |
||
550 |
for (l = userlist->groups; l != NULL; l = l->next) |
|
551 |
{
|
|
552 |
MsnGroup *group = l->data; |
|
553 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
554 |
if ((group->name != NULL) && !g_strcasecmp(name, group->name)) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
555 |
return group; |
556 |
}
|
|
557 |
||
558 |
return NULL; |
|
559 |
}
|
|
560 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
561 |
const char * |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
562 |
msn_userlist_find_group_id(MsnUserList *userlist, const char *group_name) |
563 |
{
|
|
564 |
MsnGroup *group; |
|
565 |
||
566 |
group = msn_userlist_find_group_with_name(userlist, group_name); |
|
567 |
||
568 |
if (group != NULL) |
|
569 |
return msn_group_get_id(group); |
|
570 |
else
|
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
571 |
return NULL; |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
572 |
}
|
573 |
||
574 |
const char * |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
575 |
msn_userlist_find_group_name(MsnUserList *userlist, const char * group_id) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
576 |
{
|
577 |
MsnGroup *group; |
|
578 |
||
579 |
group = msn_userlist_find_group_with_id(userlist, group_id); |
|
580 |
||
581 |
if (group != NULL) |
|
582 |
return msn_group_get_name(group); |
|
583 |
else
|
|
584 |
return NULL; |
|
585 |
}
|
|
586 |
||
587 |
void
|
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
588 |
msn_userlist_rename_group_id(MsnUserList *userlist, const char * group_id, |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
589 |
const char *new_name) |
590 |
{
|
|
591 |
MsnGroup *group; |
|
592 |
||
593 |
group = msn_userlist_find_group_with_id(userlist, group_id); |
|
594 |
||
595 |
if (group != NULL) |
|
596 |
msn_group_set_name(group, new_name); |
|
597 |
}
|
|
598 |
||
599 |
void
|
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
600 |
msn_userlist_remove_group_id(MsnUserList *userlist, const char * group_id) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
601 |
{
|
602 |
MsnGroup *group; |
|
603 |
||
604 |
group = msn_userlist_find_group_with_id(userlist, group_id); |
|
605 |
||
606 |
if (group != NULL) |
|
607 |
{
|
|
608 |
msn_userlist_remove_group(userlist, group); |
|
609 |
msn_group_destroy(group); |
|
610 |
}
|
|
611 |
}
|
|
612 |
||
1.1.14
by Sebastien Bacher
Import upstream version 2.5.2 |
613 |
typedef struct { |
614 |
MsnSession *session; |
|
615 |
char *uid; |
|
616 |
} MsnUserlistABData; |
|
617 |
||
618 |
static void |
|
619 |
userlist_ab_delete_cb(void *data, int choice) |
|
620 |
{
|
|
621 |
MsnUserlistABData *ab = (MsnUserlistABData *)data; |
|
622 |
||
623 |
/* msn_delete_contact(ab->session, ab->uid, (gboolean)choice); */
|
|
624 |
||
625 |
g_free(ab->uid); |
|
626 |
g_free(ab); |
|
627 |
}
|
|
628 |
||
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
629 |
void
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
630 |
msn_userlist_rem_buddy(MsnUserList *userlist, const char *who) |
631 |
{
|
|
632 |
MsnUser *user = NULL; |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
633 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
634 |
g_return_if_fail(userlist != NULL); |
635 |
g_return_if_fail(userlist->session != NULL); |
|
636 |
g_return_if_fail(who != NULL); |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
637 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
638 |
user = msn_userlist_find_user(userlist, who); |
639 |
||
640 |
msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_FL); |
|
641 |
||
642 |
/* delete the contact from address book via soap action */
|
|
643 |
if (user != NULL) { |
|
1.1.14
by Sebastien Bacher
Import upstream version 2.5.2 |
644 |
if (0 /*not ready yet*/ && userlist->session->passport_info.email_enabled) { |
645 |
MsnUserlistABData *ab = g_new0(MsnUserlistABData, 1); |
|
646 |
ab->session = userlist->session; |
|
647 |
ab->uid = g_strdup(user->uid); /* Not necessary? */ |
|
648 |
purple_request_yes_no(userlist->session->account, |
|
649 |
_("Delete Buddy from Address Book?"), |
|
650 |
_("Do you want to delete this buddy from your address book as well?"), |
|
651 |
user->passport, 0, userlist->session->account, user->passport, |
|
652 |
NULL, ab, |
|
653 |
G_CALLBACK(userlist_ab_delete_cb), G_CALLBACK(userlist_ab_delete_cb)); |
|
654 |
} else |
|
655 |
msn_delete_contact(userlist->session, user); |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
656 |
}
|
657 |
}
|
|
658 |
||
659 |
void
|
|
660 |
msn_userlist_rem_buddy_from_list(MsnUserList *userlist, const char *who, |
|
661 |
MsnListId list_id) |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
662 |
{
|
663 |
MsnUser *user; |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
664 |
const gchar *list; |
665 |
MsnListOp list_op = 1 << list_id; |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
666 |
|
667 |
user = msn_userlist_find_user(userlist, who); |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
668 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
669 |
g_return_if_fail(user != NULL); |
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
670 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
671 |
if ( !msn_userlist_user_is_in_list(user, list_id)) { |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
672 |
list = lists[list_id]; |
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
673 |
purple_debug_info("msn", "User %s is not in list %s, not removing.\n", who, list); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
674 |
return; |
675 |
}
|
|
676 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
677 |
msn_user_unset_op(user, list_op); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
678 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
679 |
msn_notification_rem_buddy_from_list(userlist->session->notification, list_id, who); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
680 |
}
|
681 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
682 |
/*add buddy*/
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
683 |
void
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
684 |
msn_userlist_add_buddy(MsnUserList *userlist, const char *who, const char *group_name) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
685 |
{
|
686 |
MsnUser *user; |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
687 |
MsnCallbackState *state = NULL; |
688 |
const char *group_id = NULL, *new_group_name; |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
689 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
690 |
new_group_name = group_name == NULL ? MSN_INDIVIDUALS_GROUP_NAME : group_name; |
691 |
||
692 |
g_return_if_fail(userlist != NULL); |
|
693 |
g_return_if_fail(userlist->session != NULL); |
|
694 |
||
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
695 |
purple_debug_info("msn", "Add user: %s to group: %s\n", who, new_group_name); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
696 |
|
697 |
if (!purple_email_is_valid(who)) |
|
698 |
{
|
|
699 |
/* only notify the user about problems adding to the friends list
|
|
700 |
* maybe we should do something else for other lists, but it probably
|
|
701 |
* won't cause too many problems if we just ignore it */
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
702 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
703 |
char *str = g_strdup_printf(_("Unable to add \"%s\"."), who); |
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
704 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
705 |
purple_notify_error(NULL, NULL, str, |
1.1.10
by Pedro Fragoso
Import upstream version 2.4.2 |
706 |
_("The username specified is invalid.")); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
707 |
g_free(str); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
708 |
|
709 |
return; |
|
710 |
}
|
|
711 |
||
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
712 |
state = msn_callback_state_new(userlist->session); |
713 |
msn_callback_state_set_who(state, who); |
|
714 |
msn_callback_state_set_new_group_name(state, new_group_name); |
|
715 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
716 |
group_id = msn_userlist_find_group_id(userlist, new_group_name); |
717 |
||
718 |
if (group_id == NULL) |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
719 |
{
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
720 |
/* Whoa, we must add that group first. */
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
721 |
purple_debug_info("msn", "Adding user %s to a new group, creating group %s first\n", who, new_group_name); |
722 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
723 |
msn_callback_state_set_action(state, MSN_ADD_BUDDY); |
724 |
||
725 |
msn_add_group(userlist->session, state, new_group_name); |
|
726 |
return; |
|
727 |
} else { |
|
728 |
msn_callback_state_set_guid(state, group_id); |
|
729 |
}
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
730 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
731 |
/* XXX: adding user here may not be correct (should add them in the
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
732 |
* ACK to the ADL command), but for now we need to make sure they exist
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
733 |
* early enough that the ILN command doesn't screw us up */
|
734 |
||
735 |
user = msn_userlist_find_add_user(userlist, who, who); |
|
736 |
||
737 |
if ( msn_userlist_user_is_in_list(user, MSN_LIST_FL) ) { |
|
738 |
||
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
739 |
purple_debug_info("msn", "User %s already exists\n", who); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
740 |
|
741 |
msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL); |
|
742 |
||
743 |
if (msn_userlist_user_is_in_group(user, group_id)) { |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
744 |
purple_debug_info("msn", "User %s is already in group %s, returning\n", who, new_group_name); |
745 |
msn_callback_state_free(state); |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
746 |
return; |
747 |
}
|
|
748 |
}
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
749 |
|
750 |
purple_debug_info("msn", "Adding user: %s to group id: %s\n", who, group_id); |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
751 |
|
752 |
msn_callback_state_set_action(state, MSN_ADD_BUDDY); |
|
753 |
||
754 |
/* Add contact in the Contact server with a SOAP request and if
|
|
755 |
successful, send ADL with MSN_LIST_AL and MSN_LIST_FL and a FQY */
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
756 |
msn_add_contact_to_group(userlist->session, state, who, group_id); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
757 |
}
|
758 |
||
759 |
void
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
760 |
msn_userlist_add_buddy_to_list(MsnUserList *userlist, const char *who, |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
761 |
MsnListId list_id) |
762 |
{
|
|
763 |
MsnUser *user = NULL; |
|
764 |
const gchar *list; |
|
765 |
MsnListOp list_op = 1 << list_id; |
|
766 |
||
767 |
g_return_if_fail(userlist != NULL); |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
768 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
769 |
user = msn_userlist_find_add_user(userlist, who, who); |
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
770 |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
771 |
/* First we're going to check if it's already there. */
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
772 |
if (msn_userlist_user_is_in_list(user, list_id)) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
773 |
{
|
774 |
list = lists[list_id]; |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
775 |
purple_debug_info("msn", "User '%s' is already in list: %s\n", who, list); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
776 |
return; |
777 |
}
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
778 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
779 |
/* XXX: see XXX above, this should really be done when we get the response from
|
780 |
the server */
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
781 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
782 |
msn_user_set_op(user, list_op); |
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
783 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
784 |
msn_notification_add_buddy_to_list(userlist->session->notification, list_id, who); |
785 |
}
|
|
786 |
||
787 |
gboolean
|
|
788 |
msn_userlist_add_buddy_to_group(MsnUserList *userlist, const char *who, |
|
789 |
const char *group_name) |
|
790 |
{
|
|
791 |
MsnUser *user; |
|
792 |
gchar * group_id; |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
793 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
794 |
g_return_val_if_fail(userlist != NULL, FALSE); |
795 |
g_return_val_if_fail(group_name != NULL, FALSE); |
|
796 |
g_return_val_if_fail(who != NULL, FALSE); |
|
797 |
||
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
798 |
purple_debug_info("msn", "Adding buddy with passport %s to group %s\n", who, group_name); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
799 |
|
800 |
if ( (group_id = (gchar *)msn_userlist_find_group_id(userlist, group_name)) == NULL) { |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
801 |
purple_debug_error("msn", "Group %s has no guid!\n", group_name); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
802 |
return FALSE; |
803 |
}
|
|
804 |
||
805 |
if ( (user = msn_userlist_find_user(userlist, who)) == NULL) { |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
806 |
purple_debug_error("msn", "User %s not found!", who); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
807 |
return FALSE; |
808 |
}
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
809 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
810 |
msn_user_add_group_id(user, group_id); |
811 |
||
812 |
return TRUE; |
|
813 |
}
|
|
814 |
||
815 |
||
816 |
gboolean
|
|
817 |
msn_userlist_rem_buddy_from_group(MsnUserList *userlist, const char *who, |
|
818 |
const char *group_name) |
|
819 |
{
|
|
820 |
const gchar * group_id; |
|
821 |
MsnUser *user; |
|
822 |
||
823 |
g_return_val_if_fail(userlist != NULL, FALSE); |
|
824 |
g_return_val_if_fail(group_name != NULL, FALSE); |
|
825 |
g_return_val_if_fail(who != NULL, FALSE); |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
826 |
|
827 |
purple_debug_info("msn", "Removing buddy with passport %s from group %s\n", who, group_name); |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
828 |
|
829 |
if ( (group_id = msn_userlist_find_group_id(userlist, group_name)) == NULL) { |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
830 |
purple_debug_error("msn", "Group %s has no guid!\n", group_name); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
831 |
return FALSE; |
832 |
}
|
|
833 |
||
834 |
if ( (user = msn_userlist_find_user(userlist, who)) == NULL) { |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
835 |
purple_debug_error("msn", "User %s not found!", who); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
836 |
return FALSE; |
837 |
}
|
|
838 |
||
839 |
msn_user_remove_group_id(user, group_id); |
|
840 |
||
841 |
return TRUE; |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
842 |
}
|
843 |
||
844 |
void
|
|
845 |
msn_userlist_move_buddy(MsnUserList *userlist, const char *who, |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
846 |
const char *old_group_name, const char *new_group_name) |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
847 |
{
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
848 |
const char *new_group_id; |
849 |
MsnCallbackState *state; |
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
850 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
851 |
g_return_if_fail(userlist != NULL); |
852 |
g_return_if_fail(userlist->session != NULL); |
|
853 |
||
854 |
state = msn_callback_state_new(userlist->session); |
|
855 |
msn_callback_state_set_who(state, who); |
|
856 |
msn_callback_state_set_action(state, MSN_MOVE_BUDDY); |
|
857 |
msn_callback_state_set_old_group_name(state, old_group_name); |
|
858 |
msn_callback_state_set_new_group_name(state, new_group_name); |
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
859 |
|
860 |
new_group_id = msn_userlist_find_group_id(userlist, new_group_name); |
|
861 |
||
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
862 |
if (new_group_id == NULL) |
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
863 |
{
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
864 |
msn_add_group(userlist->session, state, new_group_name); |
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
865 |
return; |
866 |
}
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
867 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
868 |
/* add the contact to the new group, and remove it from the old one in
|
869 |
* the callback
|
|
870 |
*/
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
871 |
msn_add_contact_to_group(userlist->session, state, who, new_group_id); |
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
872 |
}
|
873 |
||
874 |
/*load userlist from the Blist file cache*/
|
|
875 |
void
|
|
876 |
msn_userlist_load(MsnSession *session) |
|
877 |
{
|
|
878 |
PurpleBlistNode *gnode, *cnode, *bnode; |
|
879 |
PurpleConnection *gc = purple_account_get_connection(session->account); |
|
880 |
GSList *l; |
|
881 |
MsnUser * user; |
|
882 |
||
883 |
g_return_if_fail(gc != NULL); |
|
884 |
||
885 |
for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) |
|
886 |
{
|
|
887 |
if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
|
888 |
continue; |
|
889 |
for (cnode = gnode->child; cnode; cnode = cnode->next) |
|
890 |
{
|
|
891 |
if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
892 |
continue; |
|
893 |
for (bnode = cnode->child; bnode; bnode = bnode->next) |
|
894 |
{
|
|
895 |
PurpleBuddy *b; |
|
896 |
if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
|
897 |
continue; |
|
898 |
b = (PurpleBuddy *)bnode; |
|
899 |
if (b->account == gc->account) |
|
900 |
{
|
|
901 |
user = msn_userlist_find_add_user(session->userlist, |
|
902 |
b->name,NULL); |
|
903 |
b->proto_data = user; |
|
904 |
msn_user_set_op(user, MSN_LIST_FL_OP); |
|
905 |
}
|
|
906 |
}
|
|
907 |
}
|
|
908 |
}
|
|
909 |
for (l = session->account->permit; l != NULL; l = l->next) |
|
910 |
{
|
|
911 |
user = msn_userlist_find_add_user(session->userlist, |
|
912 |
(char *)l->data,NULL); |
|
913 |
msn_user_set_op(user, MSN_LIST_AL_OP); |
|
914 |
}
|
|
915 |
for (l = session->account->deny; l != NULL; l = l->next) |
|
916 |
{
|
|
917 |
user = msn_userlist_find_add_user(session->userlist, |
|
918 |
(char *)l->data,NULL); |
|
919 |
msn_user_set_op(user, MSN_LIST_BL_OP); |
|
920 |
}
|
|
1.1.12
by Sebastien Bacher
Import upstream version 2.5.0 |
921 |
|
1.1.7
by Pedro Fragoso
Import upstream version 2.3.1 |
922 |
}
|
923 |