Mercurial > pidgin
comparison libpurple/protocols/msn/dialog.c @ 19843:60bc06498746
Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
committer: Richard Laager <rlaager@wiktel.com>
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sun, 15 Apr 2007 04:12:27 +0000 |
parents | 32c366eeeb99 |
children | 6f986caeab59 |
comparison
equal
deleted
inserted
replaced
16121:6167ee79ecd0 | 19843:60bc06498746 |
---|---|
32 char *group; | 32 char *group; |
33 gboolean add; | 33 gboolean add; |
34 | 34 |
35 } MsnAddRemData; | 35 } MsnAddRemData; |
36 | 36 |
37 /* Remove the buddy referenced by the MsnAddRemData before the serverside list is changed. | |
38 * If the buddy will be added, he'll be added back; if he will be removed, he won't be. */ | |
39 static void | |
40 msn_complete_sync_issue(MsnAddRemData *data) | |
41 { | |
42 PurpleBuddy *buddy; | |
43 PurpleGroup *group = NULL; | |
44 | |
45 if (data->group != NULL) | |
46 group = purple_find_group(data->group); | |
47 | |
48 if (group != NULL) | |
49 buddy = purple_find_buddy_in_group(purple_connection_get_account(data->gc), data->who, group); | |
50 else | |
51 buddy = purple_find_buddy(purple_connection_get_account(data->gc), data->who); | |
52 | |
53 if (buddy != NULL) | |
54 purple_blist_remove_buddy(buddy); | |
55 } | |
56 | |
57 static void | 37 static void |
58 msn_add_cb(MsnAddRemData *data) | 38 msn_add_cb(MsnAddRemData *data) |
59 { | 39 { |
60 MsnSession *session; | 40 if (g_list_find(purple_connections_get_all(), data->gc) != NULL) |
61 MsnUserList *userlist; | 41 { |
42 MsnSession *session = data->gc->proto_data; | |
43 MsnUserList *userlist = session->userlist; | |
62 | 44 |
63 msn_complete_sync_issue(data); | 45 msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group); |
46 } | |
64 | 47 |
65 session = data->gc->proto_data; | 48 if (data->group != NULL) |
66 userlist = session->userlist; | 49 g_free(data->group); |
67 | 50 |
68 msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group); | |
69 | |
70 g_free(data->group); | |
71 g_free(data->who); | 51 g_free(data->who); |
72 g_free(data); | 52 g_free(data); |
73 } | 53 } |
74 | 54 |
75 static void | 55 static void |
76 msn_rem_cb(MsnAddRemData *data) | 56 msn_rem_cb(MsnAddRemData *data) |
77 { | 57 { |
78 MsnSession *session; | 58 if (g_list_find(purple_connections_get_all(), data->gc) != NULL) |
79 MsnUserList *userlist; | 59 { |
60 MsnSession *session = data->gc->proto_data; | |
61 MsnUserList *userlist = session->userlist; | |
80 | 62 |
81 msn_complete_sync_issue(data); | 63 msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group); |
64 } | |
82 | 65 |
83 session = data->gc->proto_data; | 66 if (data->group != NULL) |
84 userlist = session->userlist; | 67 g_free(data->group); |
85 | 68 |
86 msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group); | |
87 | |
88 g_free(data->group); | |
89 g_free(data->who); | 69 g_free(data->who); |
90 g_free(data); | 70 g_free(data); |
91 } | 71 } |
92 | 72 |
93 void | 73 void |
96 { | 76 { |
97 PurpleConnection *gc; | 77 PurpleConnection *gc; |
98 PurpleAccount *account; | 78 PurpleAccount *account; |
99 MsnAddRemData *data; | 79 MsnAddRemData *data; |
100 char *msg, *reason; | 80 char *msg, *reason; |
81 PurpleBuddy *buddy; | |
82 PurpleGroup *group = NULL; | |
101 | 83 |
102 account = session->account; | 84 account = session->account; |
103 gc = purple_account_get_connection(account); | 85 gc = purple_account_get_connection(account); |
104 | 86 |
105 data = g_new0(MsnAddRemData, 1); | 87 data = g_new0(MsnAddRemData, 1); |
109 | 91 |
110 msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"), | 92 msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"), |
111 purple_account_get_username(account), | 93 purple_account_get_username(account), |
112 purple_account_get_protocol_name(account)); | 94 purple_account_get_protocol_name(account)); |
113 | 95 |
114 if (group_name != NULL) | 96 if (group_name != NULL){ |
115 { | |
116 reason = g_strdup_printf(_("%s on the local list is " | 97 reason = g_strdup_printf(_("%s on the local list is " |
117 "inside the group \"%s\" but not on " | 98 "inside the group \"%s\" but not on " |
118 "the server list. " | 99 "the server list. " |
119 "Do you want this buddy to be added?"), | 100 "Do you want this buddy to be added?"), |
120 passport, group_name); | 101 passport, group_name); |
121 } | 102 }else{ |
122 else | |
123 { | |
124 reason = g_strdup_printf(_("%s is on the local list but " | 103 reason = g_strdup_printf(_("%s is on the local list but " |
125 "not on the server list. " | 104 "not on the server list. " |
126 "Do you want this buddy to be added?"), | 105 "Do you want this buddy to be added?"), |
127 passport); | 106 passport); |
128 } | 107 } |
130 purple_request_action(gc, NULL, msg, reason, PURPLE_DEFAULT_ACTION_NONE, | 109 purple_request_action(gc, NULL, msg, reason, PURPLE_DEFAULT_ACTION_NONE, |
131 data, 2, | 110 data, 2, |
132 _("Yes"), G_CALLBACK(msn_add_cb), | 111 _("Yes"), G_CALLBACK(msn_add_cb), |
133 _("No"), G_CALLBACK(msn_rem_cb)); | 112 _("No"), G_CALLBACK(msn_rem_cb)); |
134 | 113 |
114 if (group_name != NULL) | |
115 group = purple_find_group(group_name); | |
116 | |
117 if (group != NULL){ | |
118 buddy = purple_find_buddy_in_group(account, passport, group); | |
119 }else{ | |
120 buddy = purple_find_buddy(account, passport); | |
121 } | |
122 | |
123 if (buddy != NULL) | |
124 purple_blist_remove_buddy(buddy); | |
125 | |
135 g_free(reason); | 126 g_free(reason); |
136 g_free(msg); | 127 g_free(msg); |
137 } | 128 } |