# HG changeset patch
# Node ID 858e7e0aa3ec
# Parent  4d9e01eb0560
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -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
diff --git a/pidgin/gtkdialogs.h b/pidgin/gtkdialogs.h
--- a/pidgin/gtkdialogs.h
+++ b/pidgin/gtkdialogs.h
@@ -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.
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -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;
diff --git a/pidgin/pidginnotificationaddcontact.c b/pidgin/pidginnotificationaddcontact.c
--- a/pidgin/pidginnotificationaddcontact.c
+++ b/pidgin/pidginnotificationaddcontact.c
@@ -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
diff --git a/pidgin/pidginnotificationauthorizationrequest.c b/pidgin/pidginnotificationauthorizationrequest.c
--- a/pidgin/pidginnotificationauthorizationrequest.c
+++ b/pidgin/pidginnotificationauthorizationrequest.c
@@ -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
