pidgin/pidgin

Remove pidgin_dialogs_im_with_user

2 weeks ago, Gary Kramlich
d122647268be
Parents 4d9e01eb0560
Children ab244bae3b82
Remove pidgin_dialogs_im_with_user

I ported the the two remaining users of it to use purple_contact_find_dm and
purple_contact_create_dm_async.

Testing Done:
Ran the turtles and tested the notification from the demo protocol plugin.

This is a bit bugged out right now in the demo protocol plugin, as the new code requires that a PurpleContact exists, but the demo protocol plugin isn't creating them for the add user notifications.

Reviewed at https://reviews.imfreedom.org/r/3108/
--- a/ChangeLog.API Sat Apr 13 19:42:52 2024 -0500
+++ b/ChangeLog.API Sat Apr 13 20:25:38 2024 -0500
@@ -1127,6 +1127,7 @@
* pidgin_dialogs_alias_contact
* pidgin_dialogs_destroy_all
* pidgin_dialogs_im
+ * pidgin_dialogs_im_with_user
* pidgin_dialogs_log
* pidgin_dialogs_merge_groups
* pidgin_dialogs_remove_buddy
--- a/pidgin/gtkdialogs.c Sat Apr 13 19:42:52 2024 -0500
+++ b/pidgin/gtkdialogs.c Sat Apr 13 20:25:38 2024 -0500
@@ -31,26 +31,6 @@
#include "gtkutils.h"
#include "pidgincore.h"
-void
-pidgin_dialogs_im_with_user(PurpleAccount *account, const char *username)
-{
- PurpleConversation *im;
- PurpleConversationManager *manager;
-
- g_return_if_fail(account != NULL);
- g_return_if_fail(username != NULL);
-
- manager = purple_conversation_manager_get_default();
- im = purple_conversation_manager_find_im(manager, account, username);
-
- if(!PURPLE_IS_IM_CONVERSATION(im)) {
- /* This constructor automagically registers the conversation with the
- * manager.
- */
- purple_im_conversation_new(account, username);
- }
-}
-
static void
pidgin_dialogs_info_cb(G_GNUC_UNUSED gpointer data, PurpleRequestPage *page) {
char *username;
--- a/pidgin/gtkdialogs.h Sat Apr 13 19:42:52 2024 -0500
+++ b/pidgin/gtkdialogs.h Sat Apr 13 20:25:38 2024 -0500
@@ -33,18 +33,6 @@
G_BEGIN_DECLS
/**
- * pidgin_dialogs_im_with_user:
- * @account: The account.
- * @username: The username.
- *
- * Creates an IM conversation with @username on @account if necessary.
- *
- * Since: 2.0
- */
-PIDGIN_AVAILABLE_IN_ALL
-void pidgin_dialogs_im_with_user(PurpleAccount *account, const char *username);
-
-/**
* pidgin_dialogs_info:
*
* Creates a dialog to get another user's profile.
--- a/pidgin/pidginnotificationaddcontact.c Sat Apr 13 19:42:52 2024 -0500
+++ b/pidgin/pidginnotificationaddcontact.c Sat Apr 13 20:25:38 2024 -0500
@@ -161,14 +161,34 @@
PidginNotificationAddContact *pidgin_request = data;
PurpleAddContactRequest *request = NULL;
PurpleAccount *account = NULL;
- const gchar *username = NULL;
+ PurpleContact *contact = NULL;
+ PurpleContactManager *manager = NULL;
+ PurpleConversation *conversation = NULL;
+ const char *username = NULL;
request = purple_notification_get_data(pidgin_request->notification);
account = purple_add_contact_request_get_account(request);
username = purple_add_contact_request_get_username(request);
- pidgin_dialogs_im_with_user(account, username);
+ manager = purple_contact_manager_get_default();
+ contact = purple_contact_manager_find_with_username(manager, account,
+ username);
+
+ if(!PURPLE_IS_CONTACT(contact)) {
+ g_warning("failed to find a user named '%s' on account %s",
+ username,
+ purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)));
+
+ return;
+ }
+
+ conversation = purple_contact_find_dm(contact);
+ if(PURPLE_IS_CONVERSATION(conversation)) {
+ purple_conversation_present(conversation);
+ } else {
+ purple_contact_create_dm_async(contact, NULL, NULL, NULL);
+ }
}
static void
--- a/pidgin/pidginnotificationauthorizationrequest.c Sat Apr 13 19:42:52 2024 -0500
+++ b/pidgin/pidginnotificationauthorizationrequest.c Sat Apr 13 20:25:38 2024 -0500
@@ -189,14 +189,34 @@
PidginNotificationAuthorizationRequest *pidgin_request = data;
PurpleAuthorizationRequest *request = NULL;
PurpleAccount *account = NULL;
- const gchar *username = NULL;
+ PurpleContact *contact = NULL;
+ PurpleContactManager *manager = NULL;
+ PurpleConversation *conversation = NULL;
+ const char *username = NULL;
request = purple_notification_get_data(pidgin_request->notification);
account = purple_authorization_request_get_account(request);
username = purple_authorization_request_get_username(request);
- pidgin_dialogs_im_with_user(account, username);
+ manager = purple_contact_manager_get_default();
+ contact = purple_contact_manager_find_with_username(manager, account,
+ username);
+
+ if(!PURPLE_IS_CONTACT(contact)) {
+ g_warning("failed to find a user named '%s' on account %s",
+ username,
+ purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)));
+
+ return;
+ }
+
+ conversation = purple_contact_find_dm(contact);
+ if(PURPLE_IS_CONVERSATION(conversation)) {
+ purple_conversation_present(conversation);
+ } else {
+ purple_contact_create_dm_async(contact, NULL, NULL, NULL);
+ }
}
static void