14192
|
1 /**
|
|
2 * @file userlist.c MSN user list support
|
|
3 *
|
|
4 * gaim
|
|
5 *
|
|
6 * Gaim 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
|
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
23 */
|
|
24 #include "msn.h"
|
|
25 #include "userlist.h"
|
|
26
|
|
27 const char *lists[] = { "FL", "AL", "BL", "RL" };
|
|
28
|
|
29 typedef struct
|
|
30 {
|
|
31 GaimConnection *gc;
|
|
32 char *who;
|
|
33 char *friendly;
|
|
34
|
|
35 } MsnPermitAdd;
|
|
36
|
|
37 /**************************************************************************
|
|
38 * Callbacks
|
|
39 **************************************************************************/
|
|
40 static void
|
|
41 msn_accept_add_cb(MsnPermitAdd *pa)
|
|
42 {
|
|
43 MsnSession *session = pa->gc->proto_data;
|
|
44 MsnUserList *userlist = session->userlist;
|
|
45
|
|
46 msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_AL, NULL);
|
|
47
|
|
48 g_free(pa->who);
|
|
49 g_free(pa->friendly);
|
|
50 g_free(pa);
|
|
51 }
|
|
52
|
|
53 static void
|
|
54 msn_cancel_add_cb(MsnPermitAdd *pa)
|
|
55 {
|
|
56 MsnSession *session = pa->gc->proto_data;
|
|
57 MsnUserList *userlist = session->userlist;
|
|
58
|
|
59 msn_userlist_add_buddy(userlist, pa->who, MSN_LIST_BL, NULL);
|
|
60
|
|
61 g_free(pa->who);
|
|
62 g_free(pa->friendly);
|
|
63 g_free(pa);
|
|
64 }
|
|
65
|
|
66 static void
|
|
67 got_new_entry(GaimConnection *gc, const char *passport, const char *friendly)
|
|
68 {
|
|
69 MsnPermitAdd *pa;
|
|
70
|
|
71 pa = g_new0(MsnPermitAdd, 1);
|
|
72 pa->who = g_strdup(passport);
|
|
73 pa->friendly = g_strdup(friendly);
|
|
74 pa->gc = gc;
|
15058
|
75
|
|
76 gaim_account_request_authorization(gaim_connection_get_account(gc), passport, NULL, friendly, NULL,
|
|
77 msn_accept_add_cb, msn_cancel_add_cb, pa);
|
14192
|
78 }
|
|
79
|
|
80 /**************************************************************************
|
|
81 * Utility functions
|
|
82 **************************************************************************/
|
|
83
|
|
84 static gboolean
|
|
85 user_is_in_group(MsnUser *user, int group_id)
|
|
86 {
|
|
87 if (user == NULL)
|
|
88 return FALSE;
|
|
89
|
|
90 if (group_id < 0)
|
|
91 return FALSE;
|
|
92
|
|
93 if (g_list_find(user->group_ids, GINT_TO_POINTER(group_id)))
|
|
94 return TRUE;
|
|
95
|
|
96 return FALSE;
|
|
97 }
|
|
98
|
|
99 static gboolean
|
|
100 user_is_there(MsnUser *user, int list_id, int group_id)
|
|
101 {
|
|
102 int list_op;
|
|
103
|
|
104 if (user == NULL)
|
|
105 return FALSE;
|
|
106
|
|
107 list_op = 1 << list_id;
|
|
108
|
|
109 if (!(user->list_op & list_op))
|
|
110 return FALSE;
|
|
111
|
|
112 if (list_id == MSN_LIST_FL)
|
|
113 {
|
|
114 if (group_id >= 0)
|
|
115 return user_is_in_group(user, group_id);
|
|
116 }
|
|
117
|
|
118 return TRUE;
|
|
119 }
|
|
120
|
|
121 static const char*
|
|
122 get_store_name(MsnUser *user)
|
|
123 {
|
|
124 const char *store_name;
|
|
125
|
|
126 g_return_val_if_fail(user != NULL, NULL);
|
|
127
|
|
128 store_name = msn_user_get_store_name(user);
|
|
129
|
|
130 if (store_name != NULL)
|
|
131 store_name = gaim_url_encode(store_name);
|
|
132 else
|
|
133 store_name = msn_user_get_passport(user);
|
|
134
|
|
135 /* this might be a bit of a hack, but it should prevent notification server
|
|
136 * disconnections for people who have buddies with insane friendly names
|
|
137 * who added you to their buddy list from being disconnected. Stu. */
|
|
138 /* Shx: What? Isn't the store_name obtained from the server, and hence it's
|
|
139 * below the BUDDY_ALIAS_MAXLEN ? */
|
|
140 /* Stu: yeah, that's why it's a bit of a hack, as you pointed out, we're
|
|
141 * probably decoding the incoming store_name wrong, or something. bleh. */
|
|
142
|
|
143 if (strlen(store_name) > BUDDY_ALIAS_MAXLEN)
|
|
144 store_name = msn_user_get_passport(user);
|
|
145
|
|
146 return store_name;
|
|
147 }
|
|
148
|
|
149 static void
|
|
150 msn_request_add_group(MsnUserList *userlist, const char *who,
|
|
151 const char *old_group_name, const char *new_group_name)
|
|
152 {
|
|
153 MsnCmdProc *cmdproc;
|
|
154 MsnTransaction *trans;
|
|
155 MsnMoveBuddy *data;
|
|
156
|
|
157 cmdproc = userlist->session->notification->cmdproc;
|
|
158 data = g_new0(MsnMoveBuddy, 1);
|
|
159
|
|
160 data->who = g_strdup(who);
|
|
161
|
|
162 if (old_group_name)
|
|
163 data->old_group_name = g_strdup(old_group_name);
|
|
164
|
|
165 trans = msn_transaction_new(cmdproc, "ADG", "%s %d",
|
|
166 gaim_url_encode(new_group_name),
|
|
167 0);
|
|
168
|
|
169 msn_transaction_set_data(trans, data);
|
|
170
|
|
171 msn_cmdproc_send_trans(cmdproc, trans);
|
|
172 }
|
|
173
|
|
174 /**************************************************************************
|
|
175 * Server functions
|
|
176 **************************************************************************/
|
|
177
|
|
178 MsnListId
|
|
179 msn_get_list_id(const char *list)
|
|
180 {
|
|
181 if (list[0] == 'F')
|
|
182 return MSN_LIST_FL;
|
|
183 else if (list[0] == 'A')
|
|
184 return MSN_LIST_AL;
|
|
185 else if (list[0] == 'B')
|
|
186 return MSN_LIST_BL;
|
|
187 else if (list[0] == 'R')
|
|
188 return MSN_LIST_RL;
|
|
189
|
|
190 return -1;
|
|
191 }
|
|
192
|
|
193 void
|
|
194 msn_got_add_user(MsnSession *session, MsnUser *user,
|
|
195 MsnListId list_id, int group_id)
|
|
196 {
|
|
197 GaimAccount *account;
|
|
198 const char *passport;
|
|
199 const char *friendly;
|
|
200
|
|
201 account = session->account;
|
|
202
|
|
203 passport = msn_user_get_passport(user);
|
|
204 friendly = msn_user_get_friendly_name(user);
|
|
205
|
|
206 if (list_id == MSN_LIST_FL)
|
|
207 {
|
|
208 GaimConnection *gc;
|
|
209
|
|
210 gc = gaim_account_get_connection(account);
|
|
211
|
|
212 serv_got_alias(gc, passport, friendly);
|
|
213
|
|
214 if (group_id >= 0)
|
|
215 {
|
|
216 msn_user_add_group_id(user, group_id);
|
|
217 }
|
|
218 else
|
|
219 {
|
|
220 /* session->sync->fl_users_count++; */
|
|
221 }
|
|
222 }
|
|
223 else if (list_id == MSN_LIST_AL)
|
|
224 {
|
|
225 gaim_privacy_permit_add(account, passport, TRUE);
|
|
226 }
|
|
227 else if (list_id == MSN_LIST_BL)
|
|
228 {
|
|
229 gaim_privacy_deny_add(account, passport, TRUE);
|
|
230 }
|
|
231 else if (list_id == MSN_LIST_RL)
|
|
232 {
|
|
233 GaimConnection *gc;
|
|
234 GaimConversation *convo;
|
|
235
|
|
236 gc = gaim_account_get_connection(account);
|
|
237
|
|
238 gaim_debug_info("msn",
|
|
239 "%s has added you to his or her buddy list.\n",
|
|
240 passport);
|
|
241
|
|
242 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, passport, account);
|
|
243 if (convo) {
|
|
244 GaimBuddy *buddy;
|
|
245 char *msg;
|
|
246
|
|
247 buddy = gaim_find_buddy(account, passport);
|
|
248 msg = g_strdup_printf(
|
|
249 _("%s has added you to his or her buddy list."),
|
|
250 buddy ? gaim_buddy_get_contact_alias(buddy) : passport);
|
|
251 gaim_conv_im_write(GAIM_CONV_IM(convo), passport, msg,
|
|
252 GAIM_MESSAGE_SYSTEM, time(NULL));
|
|
253 g_free(msg);
|
|
254 }
|
|
255
|
|
256 if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP)))
|
|
257 {
|
|
258 /*
|
|
259 * TODO: The friendly name was NULL for me when I
|
|
260 * looked at this. Maybe we should use the store
|
|
261 * name instead? --KingAnt
|
|
262 */
|
|
263 got_new_entry(gc, passport, friendly);
|
|
264 }
|
|
265 }
|
|
266
|
|
267 user->list_op |= (1 << list_id);
|
|
268 /* gaim_user_add_list_id (user, list_id); */
|
|
269 }
|
|
270
|
|
271 void
|
|
272 msn_got_rem_user(MsnSession *session, MsnUser *user,
|
|
273 MsnListId list_id, int group_id)
|
|
274 {
|
|
275 GaimAccount *account;
|
|
276 const char *passport;
|
|
277
|
|
278 account = session->account;
|
|
279
|
|
280 passport = msn_user_get_passport(user);
|
|
281
|
|
282 if (list_id == MSN_LIST_FL)
|
|
283 {
|
|
284 /* TODO: When is the user totally removed? */
|
|
285 if (group_id >= 0)
|
|
286 {
|
|
287 msn_user_remove_group_id(user, group_id);
|
|
288 return;
|
|
289 }
|
|
290 else
|
|
291 {
|
|
292 /* session->sync->fl_users_count--; */
|
|
293 }
|
|
294 }
|
|
295 else if (list_id == MSN_LIST_AL)
|
|
296 {
|
|
297 gaim_privacy_permit_remove(account, passport, TRUE);
|
|
298 }
|
|
299 else if (list_id == MSN_LIST_BL)
|
|
300 {
|
|
301 gaim_privacy_deny_remove(account, passport, TRUE);
|
|
302 }
|
|
303 else if (list_id == MSN_LIST_RL)
|
|
304 {
|
|
305 GaimConversation *convo;
|
|
306
|
|
307 gaim_debug_info("msn",
|
|
308 "%s has removed you from his or her buddy list.\n",
|
|
309 passport);
|
|
310
|
|
311 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, passport, account);
|
|
312 if (convo) {
|
|
313 GaimBuddy *buddy;
|
|
314 char *msg;
|
|
315
|
|
316 buddy = gaim_find_buddy(account, passport);
|
|
317 msg = g_strdup_printf(
|
|
318 _("%s has removed you from his or her buddy list."),
|
|
319 buddy ? gaim_buddy_get_contact_alias(buddy) : passport);
|
|
320 gaim_conv_im_write(GAIM_CONV_IM(convo), passport, msg,
|
|
321 GAIM_MESSAGE_SYSTEM, time(NULL));
|
|
322 g_free(msg);
|
|
323 }
|
|
324 }
|
|
325
|
|
326 user->list_op &= ~(1 << list_id);
|
|
327 /* gaim_user_remove_list_id (user, list_id); */
|
|
328
|
|
329 if (user->list_op == 0)
|
|
330 {
|
|
331 gaim_debug_info("msn", "Buddy '%s' shall be deleted?.\n",
|
|
332 passport);
|
|
333
|
|
334 }
|
|
335 }
|
|
336
|
|
337 void
|
|
338 msn_got_lst_user(MsnSession *session, MsnUser *user,
|
|
339 int list_op, GSList *group_ids)
|
|
340 {
|
|
341 GaimConnection *gc;
|
|
342 GaimAccount *account;
|
|
343 const char *passport;
|
|
344 const char *store;
|
|
345
|
|
346 account = session->account;
|
|
347 gc = gaim_account_get_connection(account);
|
|
348
|
|
349 passport = msn_user_get_passport(user);
|
|
350 store = msn_user_get_store_name(user);
|
|
351
|
|
352 if (list_op & MSN_LIST_FL_OP)
|
|
353 {
|
|
354 GSList *c;
|
|
355 for (c = group_ids; c != NULL; c = g_slist_next(c))
|
|
356 {
|
|
357 int group_id;
|
|
358 group_id = GPOINTER_TO_INT(c->data);
|
|
359 msn_user_add_group_id(user, group_id);
|
|
360 }
|
|
361
|
|
362 /* FIXME: It might be a real alias */
|
|
363 /* Umm, what? This might fix bug #1385130 */
|
|
364 serv_got_alias(gc, passport, store);
|
|
365 }
|
|
366
|
|
367 if (list_op & MSN_LIST_AL_OP)
|
|
368 {
|
|
369 /* These are users who are allowed to see our status. */
|
|
370 gaim_privacy_deny_remove(account, passport, TRUE);
|
|
371 gaim_privacy_permit_add(account, passport, TRUE);
|
|
372 }
|
|
373
|
|
374 if (list_op & MSN_LIST_BL_OP)
|
|
375 {
|
|
376 /* These are users who are not allowed to see our status. */
|
|
377 gaim_privacy_permit_remove(account, passport, TRUE);
|
|
378 gaim_privacy_deny_add(account, passport, TRUE);
|
|
379 }
|
|
380
|
|
381 if (list_op & MSN_LIST_RL_OP)
|
|
382 {
|
|
383 /* These are users who have us on their buddy list. */
|
|
384 /*
|
|
385 * TODO: What is store name set to when this happens?
|
|
386 * For one of my accounts "something@hotmail.com"
|
|
387 * the store name was "something." Maybe we
|
|
388 * should use the friendly name, instead? --KingAnt
|
|
389 */
|
|
390
|
|
391 if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP)))
|
|
392 {
|
|
393 got_new_entry(gc, passport, store);
|
|
394 }
|
|
395 }
|
|
396
|
|
397 user->list_op = list_op;
|
|
398 }
|
|
399
|
|
400 /**************************************************************************
|
|
401 * UserList functions
|
|
402 **************************************************************************/
|
|
403
|
|
404 MsnUserList*
|
|
405 msn_userlist_new(MsnSession *session)
|
|
406 {
|
|
407 MsnUserList *userlist;
|
|
408
|
|
409 userlist = g_new0(MsnUserList, 1);
|
|
410
|
|
411 userlist->session = session;
|
|
412 userlist->buddy_icon_requests = g_queue_new();
|
|
413
|
|
414 /* buddy_icon_window is the number of allowed simultaneous buddy icon requests.
|
|
415 * XXX With smarter rate limiting code, we could allow more at once... 5 was the limit set when
|
|
416 * we weren't retrieiving any more than 5 per MSN session. */
|
|
417 userlist->buddy_icon_window = 1;
|
|
418
|
|
419 return userlist;
|
|
420 }
|
|
421
|
|
422 void
|
|
423 msn_userlist_destroy(MsnUserList *userlist)
|
|
424 {
|
|
425 GList *l;
|
|
426
|
|
427 for (l = userlist->users; l != NULL; l = l->next)
|
|
428 {
|
|
429 msn_user_destroy(l->data);
|
|
430 }
|
|
431
|
|
432 g_list_free(userlist->users);
|
|
433
|
|
434 for (l = userlist->groups; l != NULL; l = l->next)
|
|
435 {
|
|
436 msn_group_destroy(l->data);
|
|
437 }
|
|
438
|
|
439 g_list_free(userlist->groups);
|
|
440
|
|
441 g_queue_free(userlist->buddy_icon_requests);
|
|
442
|
|
443 if (userlist->buddy_icon_request_timer)
|
|
444 gaim_timeout_remove(userlist->buddy_icon_request_timer);
|
|
445
|
|
446 g_free(userlist);
|
|
447 }
|
|
448
|
|
449 void
|
|
450 msn_userlist_add_user(MsnUserList *userlist, MsnUser *user)
|
|
451 {
|
|
452 userlist->users = g_list_append(userlist->users, user);
|
|
453 }
|
|
454
|
|
455 void
|
|
456 msn_userlist_remove_user(MsnUserList *userlist, MsnUser *user)
|
|
457 {
|
|
458 userlist->users = g_list_remove(userlist->users, user);
|
|
459 }
|
|
460
|
|
461 MsnUser *
|
|
462 msn_userlist_find_user(MsnUserList *userlist, const char *passport)
|
|
463 {
|
|
464 GList *l;
|
|
465
|
|
466 g_return_val_if_fail(passport != NULL, NULL);
|
|
467
|
|
468 for (l = userlist->users; l != NULL; l = l->next)
|
|
469 {
|
|
470 MsnUser *user = (MsnUser *)l->data;
|
|
471
|
|
472 g_return_val_if_fail(user->passport != NULL, NULL);
|
|
473
|
|
474 if (!strcmp(passport, user->passport))
|
|
475 return user;
|
|
476 }
|
|
477
|
|
478 return NULL;
|
|
479 }
|
|
480
|
|
481 void
|
|
482 msn_userlist_add_group(MsnUserList *userlist, MsnGroup *group)
|
|
483 {
|
|
484 userlist->groups = g_list_append(userlist->groups, group);
|
|
485 }
|
|
486
|
|
487 void
|
|
488 msn_userlist_remove_group(MsnUserList *userlist, MsnGroup *group)
|
|
489 {
|
|
490 userlist->groups = g_list_remove(userlist->groups, group);
|
|
491 }
|
|
492
|
|
493 MsnGroup *
|
|
494 msn_userlist_find_group_with_id(MsnUserList *userlist, int id)
|
|
495 {
|
|
496 GList *l;
|
|
497
|
|
498 g_return_val_if_fail(userlist != NULL, NULL);
|
|
499 g_return_val_if_fail(id >= 0, NULL);
|
|
500
|
|
501 for (l = userlist->groups; l != NULL; l = l->next)
|
|
502 {
|
|
503 MsnGroup *group = l->data;
|
|
504
|
|
505 if (group->id == id)
|
|
506 return group;
|
|
507 }
|
|
508
|
|
509 return NULL;
|
|
510 }
|
|
511
|
|
512 MsnGroup *
|
|
513 msn_userlist_find_group_with_name(MsnUserList *userlist, const char *name)
|
|
514 {
|
|
515 GList *l;
|
|
516
|
|
517 g_return_val_if_fail(userlist != NULL, NULL);
|
|
518 g_return_val_if_fail(name != NULL, NULL);
|
|
519
|
|
520 for (l = userlist->groups; l != NULL; l = l->next)
|
|
521 {
|
|
522 MsnGroup *group = l->data;
|
|
523
|
|
524 if ((group->name != NULL) && !g_ascii_strcasecmp(name, group->name))
|
|
525 return group;
|
|
526 }
|
|
527
|
|
528 return NULL;
|
|
529 }
|
|
530
|
|
531 int
|
|
532 msn_userlist_find_group_id(MsnUserList *userlist, const char *group_name)
|
|
533 {
|
|
534 MsnGroup *group;
|
|
535
|
|
536 group = msn_userlist_find_group_with_name(userlist, group_name);
|
|
537
|
|
538 if (group != NULL)
|
|
539 return msn_group_get_id(group);
|
|
540 else
|
|
541 return -1;
|
|
542 }
|
|
543
|
|
544 const char *
|
|
545 msn_userlist_find_group_name(MsnUserList *userlist, int group_id)
|
|
546 {
|
|
547 MsnGroup *group;
|
|
548
|
|
549 group = msn_userlist_find_group_with_id(userlist, group_id);
|
|
550
|
|
551 if (group != NULL)
|
|
552 return msn_group_get_name(group);
|
|
553 else
|
|
554 return NULL;
|
|
555 }
|
|
556
|
|
557 void
|
|
558 msn_userlist_rename_group_id(MsnUserList *userlist, int group_id,
|
|
559 const char *new_name)
|
|
560 {
|
|
561 MsnGroup *group;
|
|
562
|
|
563 group = msn_userlist_find_group_with_id(userlist, group_id);
|
|
564
|
|
565 if (group != NULL)
|
|
566 msn_group_set_name(group, new_name);
|
|
567 }
|
|
568
|
|
569 void
|
|
570 msn_userlist_remove_group_id(MsnUserList *userlist, int group_id)
|
|
571 {
|
|
572 MsnGroup *group;
|
|
573
|
|
574 group = msn_userlist_find_group_with_id(userlist, group_id);
|
|
575
|
|
576 if (group != NULL)
|
|
577 {
|
|
578 msn_userlist_remove_group(userlist, group);
|
|
579 msn_group_destroy(group);
|
|
580 }
|
|
581 }
|
|
582
|
|
583 void
|
|
584 msn_userlist_rem_buddy(MsnUserList *userlist,
|
|
585 const char *who, int list_id, const char *group_name)
|
|
586 {
|
|
587 MsnUser *user;
|
|
588 int group_id;
|
|
589 const char *list;
|
|
590
|
|
591 user = msn_userlist_find_user(userlist, who);
|
|
592 group_id = -1;
|
|
593
|
|
594 if (group_name != NULL)
|
|
595 {
|
|
596 group_id = msn_userlist_find_group_id(userlist, group_name);
|
|
597
|
|
598 if (group_id < 0)
|
|
599 {
|
|
600 /* Whoa, there is no such group. */
|
|
601 gaim_debug_error("msn", "Group doesn't exist: %s\n", group_name);
|
|
602 return;
|
|
603 }
|
|
604 }
|
|
605
|
|
606 /* First we're going to check if not there. */
|
|
607 if (!(user_is_there(user, list_id, group_id)))
|
|
608 {
|
|
609 list = lists[list_id];
|
|
610 gaim_debug_error("msn", "User '%s' is not there: %s\n",
|
|
611 who, list);
|
|
612 return;
|
|
613 }
|
|
614
|
|
615 /* Then request the rem to the server. */
|
|
616 list = lists[list_id];
|
|
617
|
|
618 msn_notification_rem_buddy(userlist->session->notification, list, who, group_id);
|
|
619 }
|
|
620
|
|
621 void
|
|
622 msn_userlist_add_buddy(MsnUserList *userlist,
|
|
623 const char *who, int list_id,
|
|
624 const char *group_name)
|
|
625 {
|
|
626 MsnUser *user;
|
|
627 int group_id;
|
|
628 const char *list;
|
|
629 const char *store_name;
|
|
630
|
|
631 group_id = -1;
|
|
632
|
|
633 if (!gaim_email_is_valid(who))
|
|
634 {
|
|
635 /* only notify the user about problems adding to the friends list
|
|
636 * maybe we should do something else for other lists, but it probably
|
|
637 * won't cause too many problems if we just ignore it */
|
|
638 if (list_id == MSN_LIST_FL)
|
|
639 {
|
|
640 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who);
|
|
641 gaim_notify_error(NULL, NULL, str,
|
|
642 _("The screen name specified is invalid."));
|
|
643 g_free(str);
|
|
644 }
|
|
645
|
|
646 return;
|
|
647 }
|
|
648
|
|
649 if (group_name != NULL)
|
|
650 {
|
|
651 group_id = msn_userlist_find_group_id(userlist, group_name);
|
|
652
|
|
653 if (group_id < 0)
|
|
654 {
|
|
655 /* Whoa, we must add that group first. */
|
|
656 msn_request_add_group(userlist, who, NULL, group_name);
|
|
657 return;
|
|
658 }
|
|
659 }
|
|
660
|
|
661 user = msn_userlist_find_user(userlist, who);
|
|
662
|
|
663 /* First we're going to check if it's already there. */
|
|
664 if (user_is_there(user, list_id, group_id))
|
|
665 {
|
|
666 list = lists[list_id];
|
|
667 gaim_debug_error("msn", "User '%s' is already there: %s\n", who, list);
|
|
668 return;
|
|
669 }
|
|
670
|
|
671 store_name = (user != NULL) ? get_store_name(user) : who;
|
|
672
|
|
673 /* Then request the add to the server. */
|
|
674 list = lists[list_id];
|
|
675
|
|
676 msn_notification_add_buddy(userlist->session->notification, list, who,
|
|
677 store_name, group_id);
|
|
678 }
|
|
679
|
|
680 void
|
|
681 msn_userlist_move_buddy(MsnUserList *userlist, const char *who,
|
|
682 const char *old_group_name, const char *new_group_name)
|
|
683 {
|
|
684 int new_group_id;
|
|
685
|
|
686 new_group_id = msn_userlist_find_group_id(userlist, new_group_name);
|
|
687
|
|
688 if (new_group_id < 0)
|
|
689 {
|
|
690 msn_request_add_group(userlist, who, old_group_name, new_group_name);
|
|
691 return;
|
|
692 }
|
|
693
|
|
694 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, new_group_name);
|
|
695 msn_userlist_rem_buddy(userlist, who, MSN_LIST_FL, old_group_name);
|
|
696 }
|