changeset 15768:c7a7ea7c07a8

merge of '12db4a9e09675b5127f1f310972303177d1b2ca8' and 'ad7432a7ea65bcc312ac4541c0cfe777630248f9'
author Nathan Walp <nwalp@pidgin.im>
date Sun, 04 Mar 2007 16:52:02 +0000
parents 0869f00ca178 (diff) ed29bd084eb5 (current diff)
children 2ed235b0f97e
files
diffstat 1 files changed, 89 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntaccount.c	Sun Mar 04 16:51:57 2007 +0000
+++ b/console/gntaccount.c	Sun Mar 04 16:52:02 2007 +0000
@@ -835,11 +835,98 @@
 	g_free(buffer);
 }
 
-static GaimAccountUiOps ui_ops = 
+/* Copied from gtkaccount.c */
+typedef struct {
+	GaimAccountRequestAuthorizationCb auth_cb;
+	GaimAccountRequestAuthorizationCb deny_cb;
+	void *data;
+	char *username;
+	char *alias;
+	GaimAccount *account;
+} auth_and_add;
+
+static void
+authorize_and_add_cb(auth_and_add *aa)
+{
+	aa->auth_cb(aa->data);
+	gaim_blist_request_add_buddy(aa->account, aa->username,
+	 	                    NULL, aa->alias);
+
+	g_free(aa->username);
+	g_free(aa->alias);
+	g_free(aa);
+}
+
+static void
+deny_no_add_cb(auth_and_add *aa)
+{
+	aa->deny_cb(aa->data);
+
+	g_free(aa->username);
+	g_free(aa->alias);
+	g_free(aa);
+}
+
+static void *
+gg_request_authorize(GaimAccount *account, const char *remote_user,
+					const char *id, const char *alias, const char *message, gboolean on_list,
+					GCallback auth_cb, GCallback deny_cb, void *user_data)
+{
+	char *buffer;
+	GaimConnection *gc;
+	void *uihandle;
+
+	gc = gaim_account_get_connection(account);
+	if (message != NULL && *message == '\0')
+		message = NULL;
+
+	buffer = g_strdup_printf(_("%s%s%s%s wants to add %s to his or her buddy list%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))),
+		                (message != NULL ? ": " : "."),
+		                (message != NULL ? message  : ""));
+	if (!on_list) {
+		auth_and_add *aa = g_new(auth_and_add, 1);
+		aa->auth_cb = (GaimAccountRequestAuthorizationCb)auth_cb;
+		aa->deny_cb = (GaimAccountRequestAuthorizationCb)deny_cb;
+		aa->data = user_data;
+		aa->username = g_strdup(remote_user);
+		aa->alias = g_strdup(alias);
+		aa->account = account;
+		uihandle = gaim_request_action(NULL, _("Authorize buddy?"), buffer, NULL,
+			GAIM_DEFAULT_ACTION_NONE, aa, 2,
+			_("Authorize"), authorize_and_add_cb,
+			_("Deny"), deny_no_add_cb);
+	} else {
+		uihandle = gaim_request_action(NULL, _("Authorize buddy?"), buffer, NULL,
+			GAIM_DEFAULT_ACTION_NONE, user_data, 2,
+			_("Authorize"), auth_cb,
+			_("Deny"), deny_cb);
+	}
+	g_free(buffer);
+	return uihandle;
+}
+
+static void
+gg_request_close(void *uihandle)
+{
+	gaim_request_close(GAIM_REQUEST_ACTION, uihandle);
+}
+
+static GaimAccountUiOps ui_ops =
 {
 	.notify_added = notify_added,
 	.status_changed = NULL,
-	.request_add  = request_add
+	.request_add  = request_add,
+	.request_authorize = gg_request_authorize,
+	.close_account_request = gg_request_close
 };
 
 GaimAccountUiOps *gg_accounts_get_ui_ops()