comparison src/gtkaccount.c @ 12285:af257d8679fe

[gaim-migrate @ 14589] Ok, so I'm changing the semantics of gaim_account_notify_added, having it check for the existance of a buddy was breaking some jabber scenarios. So buddy checks should now be done in the prpls. I also added a gaim_account_request_add. _notify_added only notifies the user of the add, request_add notifies the user AND asks them if they want to add the buddy to their buddy list. I only updated jabber for these changes because it's the only protocol I really know at all well. So everyone PLEASE make sure that the other protocols get updated for this. That is make sure that when you expect to prompt the user to add the buddy you use _request_add instead of just using _notify_added and expecting the core to determine if it needs to prompt the user. Oh, there are also some other jabber changes which should hopefully fix some issues that people were seeing, like buddies not signing off when you unsubscribed with them, etc. Let me know if anyone notices any jabber oddities after this. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Thu, 01 Dec 2005 20:09:27 +0000
parents 1c0fd404e07e
children 255e6912607b
comparison
equal deleted inserted replaced
12284:ecd471d1eeec 12285:af257d8679fe
2525 } 2525 }
2526 2526
2527 free_add_user_data(data); 2527 free_add_user_data(data);
2528 } 2528 }
2529 2529
2530 static char *
2531 make_info(GaimAccount *account, GaimConnection *gc, const char *remote_user,
2532 const char *id, const char *alias, const char *msg)
2533 {
2534 return g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s."),
2535 remote_user,
2536 (alias != NULL ? " (" : ""),
2537 (alias != NULL ? alias : ""),
2538 (alias != NULL ? ")" : ""),
2539 (id != NULL
2540 ? id
2541 : (gaim_connection_get_display_name(gc) != NULL
2542 ? gaim_connection_get_display_name(gc)
2543 : gaim_account_get_username(account))),
2544 (msg != NULL ? ": " : "."),
2545 (msg != NULL ? msg : ""));
2546 }
2547
2530 static void 2548 static void
2531 gaim_gtk_accounts_notify_added(GaimAccount *account, const char *remote_user, 2549 gaim_gtk_accounts_notify_added(GaimAccount *account, const char *remote_user,
2532 const char *id, const char *alias, 2550 const char *id, const char *alias,
2533 const char *msg) 2551 const char *msg)
2534 { 2552 {
2535 char *buffer; 2553 char *buffer;
2536 GaimConnection *gc; 2554 GaimConnection *gc;
2537 GaimGtkAccountAddUserData *data; 2555 GaimGtkAccountAddUserData *data;
2538 GaimBuddy *buddy;
2539 2556
2540 gc = gaim_account_get_connection(account); 2557 gc = gaim_account_get_connection(account);
2541
2542 buddy = gaim_find_buddy(account, remote_user);
2543 2558
2544 data = g_new0(GaimGtkAccountAddUserData, 1); 2559 data = g_new0(GaimGtkAccountAddUserData, 1);
2545 data->account = account; 2560 data->account = account;
2546 data->username = g_strdup(remote_user); 2561 data->username = g_strdup(remote_user);
2547 data->alias = (alias != NULL ? g_strdup(alias) : NULL); 2562 data->alias = (alias != NULL ? g_strdup(alias) : NULL);
2548 2563
2549 buffer = g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s%s"), 2564 buffer = make_info(account, gc, remote_user, id, alias, msg);
2550 remote_user, 2565
2551 (alias != NULL ? " (" : ""), 2566 gaim_notify_info(NULL, NULL, buffer, NULL);
2552 (alias != NULL ? alias : ""),
2553 (alias != NULL ? ")" : ""),
2554 (id != NULL
2555 ? id
2556 : (gaim_connection_get_display_name(gc) != NULL
2557 ? gaim_connection_get_display_name(gc)
2558 : gaim_account_get_username(account))),
2559 (msg != NULL ? ": " : "."),
2560 (msg != NULL ? msg : ""),
2561 (buddy != NULL
2562 ? ""
2563 : _("\n\nDo you wish to add him or her to your buddy list?")));
2564
2565 if (buddy != NULL)
2566 {
2567 gaim_notify_info(NULL, NULL, buffer, NULL);
2568 }
2569 else
2570 {
2571 gaim_request_action(NULL, NULL, _("Add buddy to your list?"),
2572 buffer, GAIM_DEFAULT_ACTION_NONE, data, 2,
2573 _("Add"), G_CALLBACK(add_user_cb),
2574 _("Cancel"), G_CALLBACK(free_add_user_data));
2575 }
2576 2567
2577 g_free(buffer); 2568 g_free(buffer);
2578 } 2569 }
2579 2570
2571
2572 static void
2573 gaim_gtk_accounts_request_add(GaimAccount *account, const char *remote_user,
2574 const char *id, const char *alias,
2575 const char *msg)
2576 {
2577 char *buffer;
2578 GaimConnection *gc;
2579 GaimGtkAccountAddUserData *data;
2580
2581 gc = gaim_account_get_connection(account);
2582
2583 data = g_new0(GaimGtkAccountAddUserData, 1);
2584 data->account = account;
2585 data->username = g_strdup(remote_user);
2586 data->alias = (alias != NULL ? g_strdup(alias) : NULL);
2587
2588 buffer = make_info(account, gc, remote_user, id, alias, msg);
2589
2590 gaim_request_action(NULL, NULL, _("Add buddy to your list?"),
2591 buffer, GAIM_DEFAULT_ACTION_NONE, data, 2,
2592 _("Add"), G_CALLBACK(add_user_cb),
2593 _("Cancel"), G_CALLBACK(free_add_user_data));
2594
2595 g_free(buffer);
2596 }
2597
2580 static GaimAccountUiOps ui_ops = 2598 static GaimAccountUiOps ui_ops =
2581 { 2599 {
2582 gaim_gtk_accounts_notify_added, 2600 gaim_gtk_accounts_notify_added,
2583 NULL 2601 NULL,
2602 gaim_gtk_accounts_request_add
2584 }; 2603 };
2585 2604
2586 GaimAccountUiOps * 2605 GaimAccountUiOps *
2587 gaim_gtk_accounts_get_ui_ops(void) 2606 gaim_gtk_accounts_get_ui_ops(void)
2588 { 2607 {