diff 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
line wrap: on
line diff
--- a/src/gtkaccount.c	Thu Dec 01 19:55:35 2005 +0000
+++ b/src/gtkaccount.c	Thu Dec 01 20:09:27 2005 +0000
@@ -2527,52 +2527,70 @@
 	free_add_user_data(data);
 }
 
+static char *
+make_info(GaimAccount *account, GaimConnection *gc, const char *remote_user,
+          const char *id, const char *alias, const char *msg)
+{
+	return g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s."),
+	                       remote_user,
+	                       (alias != NULL ? " ("  : ""),
+	                       (alias != NULL ? alias : ""),
+	                       (alias != NULL ? ")"   : ""),
+	                       (id != NULL
+	                        ? id
+	                        : (gaim_connection_get_display_name(gc) != NULL
+	                           ? gaim_connection_get_display_name(gc)
+	                           : gaim_account_get_username(account))),
+	                       (msg != NULL ? ": " : "."),
+	                       (msg != NULL ? msg  : ""));
+}
+
 static void
 gaim_gtk_accounts_notify_added(GaimAccount *account, const char *remote_user,
-							   const char *id, const char *alias,
-							   const char *msg)
+                               const char *id, const char *alias,
+                               const char *msg)
 {
 	char *buffer;
 	GaimConnection *gc;
 	GaimGtkAccountAddUserData *data;
-	GaimBuddy *buddy;
 
 	gc = gaim_account_get_connection(account);
 
-	buddy = gaim_find_buddy(account, remote_user);
-
 	data = g_new0(GaimGtkAccountAddUserData, 1);
 	data->account  = account;
 	data->username = g_strdup(remote_user);
 	data->alias    = (alias != NULL ? g_strdup(alias) : NULL);
 
-	buffer = g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s%s"),
-		remote_user,
-		(alias != NULL ? " ("  : ""),
-		(alias != NULL ? alias : ""),
-		(alias != NULL ? ")"   : ""),
-		(id != NULL
-		 ? id
-		 : (gaim_connection_get_display_name(gc) != NULL
-			? gaim_connection_get_display_name(gc)
-			: gaim_account_get_username(account))),
-		(msg != NULL ? ": " : "."),
-		(msg != NULL ? msg  : ""),
-		(buddy != NULL
-		 ? ""
-		 : _("\n\nDo you wish to add him or her to your buddy list?")));
-
-	if (buddy != NULL)
-	{
-		gaim_notify_info(NULL, NULL, buffer, NULL);
-	}
-	else
-	{
-		gaim_request_action(NULL, NULL, _("Add buddy to your list?"),
-							buffer, GAIM_DEFAULT_ACTION_NONE, data, 2,
-							_("Add"),    G_CALLBACK(add_user_cb),
-							_("Cancel"), G_CALLBACK(free_add_user_data));
-	}
+	buffer = make_info(account, gc, remote_user, id, alias, msg);
+
+	gaim_notify_info(NULL, NULL, buffer, NULL);
+
+	g_free(buffer);
+}
+
+
+static void
+gaim_gtk_accounts_request_add(GaimAccount *account, const char *remote_user,
+                              const char *id, const char *alias,
+                              const char *msg)
+{
+	char *buffer;
+	GaimConnection *gc;
+	GaimGtkAccountAddUserData *data;
+
+	gc = gaim_account_get_connection(account);
+
+	data = g_new0(GaimGtkAccountAddUserData, 1);
+	data->account  = account;
+	data->username = g_strdup(remote_user);
+	data->alias    = (alias != NULL ? g_strdup(alias) : NULL);
+
+	buffer = make_info(account, gc, remote_user, id, alias, msg);
+
+	gaim_request_action(NULL, NULL, _("Add buddy to your list?"),
+	                    buffer, GAIM_DEFAULT_ACTION_NONE, data, 2,
+	                    _("Add"),    G_CALLBACK(add_user_cb),
+	                    _("Cancel"), G_CALLBACK(free_add_user_data));
 
 	g_free(buffer);
 }
@@ -2580,7 +2598,8 @@
 static GaimAccountUiOps ui_ops =
 {
 	gaim_gtk_accounts_notify_added,
-	NULL
+	NULL,
+	gaim_gtk_accounts_request_add
 };
 
 GaimAccountUiOps *