Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/userlist.c @ 20486:ff4ae9dde291
Make block/unblock work right, as well as being add by a buddy. Finally fixes #723
author | Carlos Silva <typ0@pidgin.im> |
---|---|
date | Mon, 03 Sep 2007 05:47:52 +0000 |
parents | 98613886411a |
children | 64c322c3b1b0 |
comparison
equal
deleted
inserted
replaced
20485:87eea1c5be97 | 20486:ff4ae9dde291 |
---|---|
41 msn_accept_add_cb(gpointer data) | 41 msn_accept_add_cb(gpointer data) |
42 { | 42 { |
43 MsnPermitAdd *pa = data; | 43 MsnPermitAdd *pa = data; |
44 MsnSession *session = pa->gc->proto_data; | 44 MsnSession *session = pa->gc->proto_data; |
45 MsnUserList *userlist = session->userlist; | 45 MsnUserList *userlist = session->userlist; |
46 | 46 MsnUser *user = msn_userlist_find_add_user(userlist, pa->who, pa->who); |
47 | |
48 purple_debug_misc("MSN Userlist", "Accepted the new buddy: %s\n", pa->who); | |
49 | |
47 msn_userlist_add_buddy_to_list(userlist, pa->who, MSN_LIST_AL); | 50 msn_userlist_add_buddy_to_list(userlist, pa->who, MSN_LIST_AL); |
48 msn_userlist_add_buddy(userlist, pa->who, NULL); | 51 |
52 if (msn_userlist_user_is_in_list(user, MSN_LIST_FL)) { | |
53 msn_del_contact_from_list(session->contact, NULL, pa->who, MSN_LIST_PL); | |
54 } | |
49 | 55 |
50 g_free(pa->who); | 56 g_free(pa->who); |
51 g_free(pa->friendly); | 57 g_free(pa->friendly); |
52 g_free(pa); | 58 g_free(pa); |
53 } | 59 } |
55 static void | 61 static void |
56 msn_cancel_add_cb(gpointer data) | 62 msn_cancel_add_cb(gpointer data) |
57 { | 63 { |
58 MsnPermitAdd *pa = data; | 64 MsnPermitAdd *pa = data; |
59 | 65 |
66 purple_debug_misc("MSN Userlist", "Deniedthe new buddy: %s\n", pa->who); | |
67 | |
60 if (g_list_find(purple_connections_get_all(), pa->gc) != NULL) | 68 if (g_list_find(purple_connections_get_all(), pa->gc) != NULL) |
61 { | 69 { |
62 MsnSession *session = pa->gc->proto_data; | 70 MsnSession *session = pa->gc->proto_data; |
63 MsnUserList *userlist = session->userlist; | 71 MsnUserList *userlist = session->userlist; |
72 MsnCallbackState *state = msn_callback_state_new(); | |
73 | |
74 msn_callback_state_set_action(state, MSN_DENIED_BUDDY); | |
64 | 75 |
65 msn_userlist_add_buddy_to_list(userlist, pa->who, MSN_LIST_BL); | 76 msn_userlist_add_buddy_to_list(userlist, pa->who, MSN_LIST_BL); |
77 msn_del_contact_from_list(session->contact, state, pa->who, MSN_LIST_PL); | |
66 } | 78 } |
67 | 79 |
68 g_free(pa->who); | 80 g_free(pa->who); |
69 g_free(pa->friendly); | 81 g_free(pa->friendly); |
70 g_free(pa); | 82 g_free(pa); |
88 | 100 |
89 /************************************************************************** | 101 /************************************************************************** |
90 * Utility functions | 102 * Utility functions |
91 **************************************************************************/ | 103 **************************************************************************/ |
92 | 104 |
93 static gboolean | 105 gboolean |
94 msn_userlist_user_is_in_group(MsnUser *user, const char * group_id) | 106 msn_userlist_user_is_in_group(MsnUser *user, const char * group_id) |
95 { | 107 { |
96 if (user == NULL) | 108 if (user == NULL) |
97 return FALSE; | 109 return FALSE; |
98 | 110 |
103 return TRUE; | 115 return TRUE; |
104 | 116 |
105 return FALSE; | 117 return FALSE; |
106 } | 118 } |
107 | 119 |
108 static gboolean | 120 gboolean |
109 msn_userlist_user_is_in_list(MsnUser *user, MsnListId list_id) | 121 msn_userlist_user_is_in_list(MsnUser *user, MsnListId list_id) |
110 { | 122 { |
111 int list_op; | 123 int list_op; |
112 | 124 |
113 if (user == NULL) | 125 if (user == NULL) |
325 account = session->account; | 337 account = session->account; |
326 gc = purple_account_get_connection(account); | 338 gc = purple_account_get_connection(account); |
327 | 339 |
328 passport = msn_user_get_passport(user); | 340 passport = msn_user_get_passport(user); |
329 store = msn_user_get_store_name(user); | 341 store = msn_user_get_store_name(user); |
342 | |
343 msn_user_set_op(user, list_op); | |
330 | 344 |
331 if (list_op & MSN_LIST_FL_OP) | 345 if (list_op & MSN_LIST_FL_OP) |
332 { | 346 { |
333 GSList *c; | 347 GSList *c; |
334 for (c = group_ids; c != NULL; c = g_slist_next(c)) | 348 for (c = group_ids; c != NULL; c = g_slist_next(c)) |
375 | 389 |
376 if (list_op & MSN_LIST_PL_OP) | 390 if (list_op & MSN_LIST_PL_OP) |
377 { | 391 { |
378 got_new_entry(gc, passport, store); | 392 got_new_entry(gc, passport, store); |
379 } | 393 } |
380 | |
381 user->list_op |= list_op; | |
382 } | 394 } |
383 | 395 |
384 /************************************************************************** | 396 /************************************************************************** |
385 * UserList functions | 397 * UserList functions |
386 **************************************************************************/ | 398 **************************************************************************/ |
607 msn_userlist_rem_buddy_from_list(MsnUserList *userlist, const char *who, | 619 msn_userlist_rem_buddy_from_list(MsnUserList *userlist, const char *who, |
608 MsnListId list_id) | 620 MsnListId list_id) |
609 { | 621 { |
610 MsnUser *user; | 622 MsnUser *user; |
611 const gchar *list; | 623 const gchar *list; |
612 | 624 MsnListOp list_op = 1 << list_id; |
625 | |
613 user = msn_userlist_find_user(userlist, who); | 626 user = msn_userlist_find_user(userlist, who); |
614 | 627 |
615 g_return_if_fail(user != NULL); | 628 g_return_if_fail(user != NULL); |
616 | 629 |
617 if ( !msn_userlist_user_is_in_list(user, list_id)) { | 630 if ( !msn_userlist_user_is_in_list(user, list_id)) { |
618 list = lists[list_id]; | 631 list = lists[list_id]; |
619 purple_debug_info("MSN Userlist", "User %s is not in list %s, not removing.\n", who, list); | 632 purple_debug_info("MSN Userlist", "User %s is not in list %s, not removing.\n", who, list); |
620 return; | 633 return; |
621 } | 634 } |
622 | 635 |
636 msn_user_unset_op(user, list_op); | |
637 | |
623 msn_notification_rem_buddy_from_list(userlist->session->notification, list_id, who); | 638 msn_notification_rem_buddy_from_list(userlist->session->notification, list_id, who); |
624 } | 639 } |
625 | 640 |
626 /*add buddy*/ | 641 /*add buddy*/ |
627 void | 642 void |
628 msn_userlist_add_buddy(MsnUserList *userlist, const char *who, | 643 msn_userlist_add_buddy(MsnUserList *userlist, const char *who, const char *group_name) |
629 const char *group_name) | |
630 { | 644 { |
631 MsnUser *user; | 645 MsnUser *user; |
632 MsnCallbackState *state = NULL; | 646 MsnCallbackState *state = NULL; |
633 const char *group_id = NULL, *new_group_name; | 647 const char *group_id = NULL, *new_group_name; |
634 | 648 |