Tue, 08 Nov 2022 03:15:58 -0600
Remove purple_account_request_add
This behavior has been replicated by purple_add_contact_request_new and the
notification API. The only consume of this function was the demo protocol
plugin, so this was updated to use the aforementioned API.
Testing Done:
Used the demo protocol plugin's account action to test it. Also fixed an off-by-one in that action.
Reviewed at https://reviews.imfreedom.org/r/2050/
--- a/ChangeLog.API Mon Nov 07 23:31:50 2022 -0600 +++ b/ChangeLog.API Tue Nov 08 03:15:58 2022 -0600 @@ -376,6 +376,8 @@ * purple_account_get_ui_string * purple_account_get_ui_bool * purple_account_notify_added + * purple_account_request_add. Use purple_add_contact_request_new + instead. * purple_account_request_authorization * purple_account_request_close * purple_account_set_check_mail
--- a/libpurple/account.c Mon Nov 07 23:31:50 2022 -0600 +++ b/libpurple/account.c Tue Nov 08 03:15:58 2022 -0600 @@ -1090,32 +1090,6 @@ } void -purple_account_request_add(PurpleAccount *account, const char *remote_user, - const char *alias, const char *message) -{ - PurpleAddContactRequest *request = NULL; - PurpleNotification *notification = NULL; - PurpleNotificationManager *manager = NULL; - - g_return_if_fail(PURPLE_IS_ACCOUNT(account)); - g_return_if_fail(remote_user != NULL); - - request = purple_add_contact_request_new(account, remote_user); - if(alias != NULL && *alias != '\0') { - purple_add_contact_request_set_alias(request, alias); - } - - if(message != NULL && *message != '\0') { - purple_add_contact_request_set_message(request, message); - } - - notification = purple_notification_new_from_add_contact_request(request); - - manager = purple_notification_manager_get_default(); - purple_notification_manager_add(manager, notification); -} - -void purple_account_request_close_with_account(PurpleAccount *account) { PurpleNotificationManager *manager = NULL;
--- a/libpurple/account.h Mon Nov 07 23:31:50 2022 -0600 +++ b/libpurple/account.h Tue Nov 08 03:15:58 2022 -0600 @@ -155,22 +155,6 @@ gboolean purple_account_is_disconnecting(PurpleAccount *account); /** - * purple_account_request_add: - * @account: The account that was added. - * @remote_user: The name of the user that added this account. - * @alias: The optional alias of the user. - * @message: The optional message sent from the user adding you. - * - * Notifies the user that the account was added to a remote user's buddy list - * and asks the user if they want to add the remote user to their buddy list. - * - * This will present a dialog informing the local user that the remote user - * added them to the remote user's buddy list and will ask if they want to add - * the remote user to the buddy list. - */ -void purple_account_request_add(PurpleAccount *account, const char *remote_user, const char *alias, const char *message); - -/** * purple_account_request_close_with_account: * @account: The account for which requests should be closed *
--- a/libpurple/protocols/demo/purpledemoprotocolactions.c Mon Nov 07 23:31:50 2022 -0600 +++ b/libpurple/protocols/demo/purpledemoprotocolactions.c Tue Nov 08 03:15:58 2022 -0600 @@ -33,7 +33,7 @@ #define TEMPORARY_TICK_PLURAL_STR N_("Pruning connection in %d seconds...") #define TEMPORARY_DISCONNECT_STR N_("%s pruned the connection") -static const gchar *contacts[] = {"Alice", "Bob", "Carlos", "Erin", NULL }; +static const gchar *contacts[] = {"Alice", "Bob", "Carlos", "Erin" }; static void purple_demo_protocol_remote_add(G_GNUC_UNUSED GSimpleAction *action, @@ -41,15 +41,22 @@ G_GNUC_UNUSED gpointer data) { PurpleAccount *account = NULL; - PurpleAccountManager *manager = NULL; + PurpleAccountManager *account_manager = NULL; + PurpleAddContactRequest *request = NULL; + PurpleNotification *notification = NULL; + PurpleNotificationManager *notification_manager = NULL; const gchar *account_id = NULL; static gint counter = 0; account_id = g_variant_get_string(parameter, NULL); - manager = purple_account_manager_get_default(); - account = purple_account_manager_find_by_id(manager, account_id); + account_manager = purple_account_manager_get_default(); + account = purple_account_manager_find_by_id(account_manager, account_id); - purple_account_request_add(account, contacts[counter], NULL, NULL); + request = purple_add_contact_request_new(account, contacts[counter]); + notification = purple_notification_new_from_add_contact_request(request); + + notification_manager = purple_notification_manager_get_default(); + purple_notification_manager_add(notification_manager, notification); counter++; if(counter >= G_N_ELEMENTS(contacts)) {