Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/error.c @ 31292:47b6eda87723
propagate from branch 'im.pidgin.pidgin' (head 07d0765c444a097af45c2650f54323afb900a07b)
to branch 'im.pidgin.soc.2010.msn-tlc' (head f3998422a4724ab424e4e2328f58fc0504856557)
author | masca@cpw.pidgin.im |
---|---|
date | Mon, 19 Jul 2010 21:11:32 +0000 |
parents | 230caecf5435 |
children | a8cc50c2279f |
comparison
equal
deleted
inserted
replaced
30698:e874875a74a7 | 31292:47b6eda87723 |
---|---|
19 * | 19 * |
20 * You should have received a copy of the GNU General Public License | 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 | 21 * along with this program; if not, write to the Free Software |
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
23 */ | 23 */ |
24 #include "msn.h" | 24 |
25 #include "internal.h" | |
26 #include "debug.h" | |
27 /* Masca: can we get rid of the sync issue dialog? */ | |
28 #include "request.h" | |
29 | |
25 #include "error.h" | 30 #include "error.h" |
31 | |
32 typedef struct | |
33 { | |
34 PurpleConnection *gc; | |
35 char *who; | |
36 char *group; | |
37 gboolean add; | |
38 | |
39 } MsnAddRemData; | |
26 | 40 |
27 const char * | 41 const char * |
28 msn_error_get_text(unsigned int type, gboolean *debug) | 42 msn_error_get_text(unsigned int type, gboolean *debug) |
29 { | 43 { |
30 static char msg[256]; | 44 static char msg[256]; |
262 else | 276 else |
263 purple_notify_error(session->account->gc, NULL, buf, NULL); | 277 purple_notify_error(session->account->gc, NULL, buf, NULL); |
264 g_free(buf); | 278 g_free(buf); |
265 } | 279 } |
266 | 280 |
281 /* Remove the buddy referenced by the MsnAddRemData before the serverside list | |
282 * is changed. If the buddy will be added, he'll be added back; if he will be | |
283 * removed, he won't be. */ | |
284 /* Actually with our MSNP14 code that isn't true yet, he won't be added back :( | |
285 * */ | |
286 static void | |
287 msn_complete_sync_issue(MsnAddRemData *data) | |
288 { | |
289 PurpleBuddy *buddy; | |
290 PurpleGroup *group = NULL; | |
291 | |
292 if (data->group != NULL) | |
293 group = purple_find_group(data->group); | |
294 | |
295 if (group != NULL) | |
296 buddy = purple_find_buddy_in_group(purple_connection_get_account(data->gc), data->who, group); | |
297 else | |
298 buddy = purple_find_buddy(purple_connection_get_account(data->gc), data->who); | |
299 | |
300 if (buddy != NULL) | |
301 purple_blist_remove_buddy(buddy); | |
302 } | |
303 | |
304 | |
305 static void | |
306 msn_add_cb(MsnAddRemData *data) | |
307 { | |
308 #if 0 | |
309 /* this *should* be necessary !! */ | |
310 msn_complete_sync_issue(data); | |
311 #endif | |
312 | |
313 if (g_list_find(purple_connections_get_all(), data->gc) != NULL) | |
314 { | |
315 MsnSession *session = data->gc->proto_data; | |
316 MsnUserList *userlist = session->userlist; | |
317 | |
318 msn_userlist_add_buddy(userlist, data->who, data->group); | |
319 } | |
320 | |
321 g_free(data->group); | |
322 g_free(data->who); | |
323 g_free(data); | |
324 } | |
325 | |
326 static void | |
327 msn_rem_cb(MsnAddRemData *data) | |
328 { | |
329 msn_complete_sync_issue(data); | |
330 | |
331 if (g_list_find(purple_connections_get_all(), data->gc) != NULL) | |
332 { | |
333 MsnSession *session = data->gc->proto_data; | |
334 MsnUserList *userlist = session->userlist; | |
335 | |
336 if (data->group == NULL) { | |
337 msn_userlist_rem_buddy_from_list(userlist, data->who, MSN_LIST_FL); | |
338 } else { | |
339 g_free(data->group); | |
340 } | |
341 } | |
342 | |
343 g_free(data->who); | |
344 g_free(data); | |
345 } | |
346 | |
347 void | |
348 msn_error_sync_issue(MsnSession *session, const char *passport, | |
349 const char *group_name) | |
350 { | |
351 PurpleConnection *gc; | |
352 PurpleAccount *account; | |
353 MsnAddRemData *data; | |
354 char *msg, *reason; | |
355 | |
356 account = session->account; | |
357 gc = purple_account_get_connection(account); | |
358 | |
359 data = g_new0(MsnAddRemData, 1); | |
360 data->who = g_strdup(passport); | |
361 data->group = g_strdup(group_name); | |
362 data->gc = gc; | |
363 | |
364 msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"), | |
365 purple_account_get_username(account), | |
366 purple_account_get_protocol_name(account)); | |
367 | |
368 if (group_name != NULL) | |
369 { | |
370 reason = g_strdup_printf(_("%s on the local list is " | |
371 "inside the group \"%s\" but not on " | |
372 "the server list. " | |
373 "Do you want this buddy to be added?"), | |
374 passport, group_name); | |
375 } | |
376 else | |
377 { | |
378 reason = g_strdup_printf(_("%s is on the local list but " | |
379 "not on the server list. " | |
380 "Do you want this buddy to be added?"), | |
381 passport); | |
382 } | |
383 | |
384 purple_request_action(gc, NULL, msg, reason, PURPLE_DEFAULT_ACTION_NONE, | |
385 purple_connection_get_account(gc), data->who, NULL, | |
386 data, 2, | |
387 _("Yes"), G_CALLBACK(msn_add_cb), | |
388 _("No"), G_CALLBACK(msn_rem_cb)); | |
389 | |
390 g_free(reason); | |
391 g_free(msg); | |
392 } |