comparison libpurple/protocols/msn/error.c @ 31558:ce968e115c95

propagate from branch 'im.pidgin.cpw.masca.p2p' (head 33ca865dacb9e5bcf763d06f6a42cbaca337cc64) to branch 'im.pidgin.pidgin' (head 92f47f4e8b0cbb107fd97e1ab814d1cedbf109ad)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 06 May 2011 06:25:14 +0000
parents f033f3c49a41
children 10e5000326a5
comparison
equal deleted inserted replaced
31557:f021d93a1f9b 31558:ce968e115c95
29 29
30 #include "error.h" 30 #include "error.h"
31 31
32 typedef struct 32 typedef struct
33 { 33 {
34 PurpleConnection *gc; 34 MsnSession *session;
35 char *who; 35 char *who;
36 char *group; 36 char *group;
37 gboolean add; 37 gboolean add;
38 38
39 } MsnAddRemData; 39 } MsnAddRemData;
291 291
292 if (data->group != NULL) 292 if (data->group != NULL)
293 group = purple_find_group(data->group); 293 group = purple_find_group(data->group);
294 294
295 if (group != NULL) 295 if (group != NULL)
296 buddy = purple_find_buddy_in_group(purple_connection_get_account(data->gc), data->who, group); 296 buddy = purple_find_buddy_in_group(data->session->account, data->who, group);
297 else 297 else
298 buddy = purple_find_buddy(purple_connection_get_account(data->gc), data->who); 298 buddy = purple_find_buddy(data->session->account, data->who);
299 299
300 if (buddy != NULL) 300 if (buddy != NULL)
301 purple_blist_remove_buddy(buddy); 301 purple_blist_remove_buddy(buddy);
302 } 302 }
303 303
307 { 307 {
308 #if 0 308 #if 0
309 /* this *should* be necessary !! */ 309 /* this *should* be necessary !! */
310 msn_complete_sync_issue(data); 310 msn_complete_sync_issue(data);
311 #endif 311 #endif
312 312 MsnUserList *userlist = data->session->userlist;
313 if (g_list_find(purple_connections_get_all(), data->gc) != NULL) 313
314 { 314 msn_userlist_add_buddy(userlist, data->who, data->group);
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 315
321 g_free(data->group); 316 g_free(data->group);
322 g_free(data->who); 317 g_free(data->who);
323 g_free(data); 318 g_free(data);
324 } 319 }
325 320
326 static void 321 static void
327 msn_rem_cb(MsnAddRemData *data) 322 msn_rem_cb(MsnAddRemData *data)
328 { 323 {
324 MsnUserList *userlist = data->session->userlist;
329 msn_complete_sync_issue(data); 325 msn_complete_sync_issue(data);
330 326
331 if (g_list_find(purple_connections_get_all(), data->gc) != NULL) 327
332 { 328 if (data->group == NULL) {
333 MsnSession *session = data->gc->proto_data; 329 msn_userlist_rem_buddy_from_list(userlist, data->who, MSN_LIST_FL);
334 MsnUserList *userlist = session->userlist; 330 } else {
335 331 g_free(data->group);
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 } 332 }
342 333
343 g_free(data->who); 334 g_free(data->who);
344 g_free(data); 335 g_free(data);
345 } 336 }
354 char *msg, *reason; 345 char *msg, *reason;
355 346
356 account = session->account; 347 account = session->account;
357 gc = purple_account_get_connection(account); 348 gc = purple_account_get_connection(account);
358 349
359 data = g_new0(MsnAddRemData, 1); 350 data = g_new0(MsnAddRemData, 1);
360 data->who = g_strdup(passport); 351 data->who = g_strdup(passport);
361 data->group = g_strdup(group_name); 352 data->group = g_strdup(group_name);
362 data->gc = gc; 353 data->session = session;
363 354
364 msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"), 355 msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"),
365 purple_account_get_username(account), 356 purple_account_get_username(account),
366 purple_account_get_protocol_name(account)); 357 purple_account_get_protocol_name(account));
367 358
368 if (group_name != NULL) 359 if (group_name != NULL)
369 { 360 {
370 reason = g_strdup_printf(_("%s on the local list is " 361 reason = g_strdup_printf(_("%s on the local list is "
371 "inside the group \"%s\" but not on " 362 "inside the group \"%s\" but not on "
372 "the server list. " 363 "the server list. "
373 "Do you want this buddy to be added?"), 364 "Do you want this buddy to be added?"),
374 passport, group_name); 365 passport, group_name);
375 } 366 }
376 else 367 else
377 { 368 {
378 reason = g_strdup_printf(_("%s is on the local list but " 369 reason = g_strdup_printf(_("%s is on the local list but "
379 "not on the server list. " 370 "not on the server list. "
380 "Do you want this buddy to be added?"), 371 "Do you want this buddy to be added?"),
381 passport); 372 passport);
382 } 373 }
383 374
384 purple_request_action(gc, NULL, msg, reason, PURPLE_DEFAULT_ACTION_NONE, 375 purple_request_action(gc, NULL, msg, reason, PURPLE_DEFAULT_ACTION_NONE,
385 purple_connection_get_account(gc), data->who, NULL, 376 account, data->who, NULL,
386 data, 2, 377 data, 2,
387 _("Yes"), G_CALLBACK(msn_add_cb), 378 _("Yes"), G_CALLBACK(msn_add_cb),
388 _("No"), G_CALLBACK(msn_rem_cb)); 379 _("No"), G_CALLBACK(msn_rem_cb));
389 380
390 g_free(reason); 381 g_free(reason);
391 g_free(msg); 382 g_free(msg);
392 } 383 }
384