changeset 30264:38d5dd9c9a07

merge of 'c4a26372086186405c4635b2fbf448b8d089f863' and 'c9659a3fecdd575434640e531c3eb61f90de6976'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 30 Apr 2010 03:35:28 +0000
parents 1f5c86f79eeb (current diff) 2a436e0ce977 (diff)
children e72f6383095b
files
diffstat 24 files changed, 250 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Wed Apr 28 20:57:59 2010 +0000
+++ b/ChangeLog.API	Fri Apr 30 03:35:28 2010 +0000
@@ -8,7 +8,9 @@
 		   * account-signed-off
 		   * account-connection-error
 		* purple_account_get_name_for_display
+		* purple_account_get_public_alias
 		* purple_account_get_privacy_type
+		* purple_account_set_public_alias
 		* purple_account_set_privacy_type
 		* purple_buddy_get_media_caps
 		* purple_buddy_set_media_caps
--- a/libpurple/account.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/account.c	Fri Apr 30 03:35:28 2010 +0000
@@ -1782,6 +1782,92 @@
 	schedule_accounts_save();
 }
 
+struct public_alias_closure
+{
+	PurpleAccount *account;
+	gpointer failure_cb;
+};
+
+static gboolean
+set_public_alias_unsupported(gpointer data)
+{
+	struct public_alias_closure *closure = data;
+	PurpleSetPublicAliasFailureCallback failure_cb = closure->failure_cb;
+
+	failure_cb(closure->account,
+	           _("This protocol does not support setting a public alias."));
+	g_free(closure);
+
+	return FALSE;
+}
+
+void
+purple_account_set_public_alias(PurpleAccount *account,
+		const char *alias, PurpleSetPublicAliasSuccessCallback success_cb,
+		PurpleSetPublicAliasFailureCallback failure_cb)
+{
+	PurpleConnection *gc;
+	PurplePlugin *prpl = NULL;
+	PurplePluginProtocolInfo *prpl_info = NULL;
+
+	g_return_if_fail(account != NULL);
+	g_return_if_fail(purple_account_is_connected(account));
+
+	gc = purple_account_get_connection(account);
+	prpl = purple_connection_get_prpl(gc);
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+	if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, set_public_alias))
+		prpl_info->set_public_alias(gc, alias, success_cb, failure_cb);
+	else {
+		struct public_alias_closure *closure =
+				g_new0(struct public_alias_closure, 1);
+		closure->account = account;
+		closure->failure_cb = failure_cb;
+		purple_timeout_add(0, set_public_alias_unsupported, closure);
+	}
+}
+
+static gboolean
+get_public_alias_unsupported(gpointer data)
+{
+	struct public_alias_closure *closure = data;
+	PurpleGetPublicAliasFailureCallback failure_cb = closure->failure_cb;
+
+	failure_cb(closure->account,
+	           _("This protocol does not support fetching the public alias."));
+	g_free(closure);
+
+	return FALSE;
+}
+
+void
+purple_account_get_public_alias(PurpleAccount *account,
+		PurpleGetPublicAliasSuccessCallback success_cb,
+		PurpleGetPublicAliasFailureCallback failure_cb)
+{
+	PurpleConnection *gc;
+	PurplePlugin *prpl = NULL;
+	PurplePluginProtocolInfo *prpl_info = NULL;
+
+	g_return_if_fail(account != NULL);
+	g_return_if_fail(purple_account_is_connected(account));
+
+	gc = purple_account_get_connection(account);
+	prpl = purple_connection_get_prpl(gc);
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+	if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_public_alias))
+		prpl_info->get_public_alias(gc, success_cb, failure_cb);
+	else {
+		struct public_alias_closure *closure =
+				g_new0(struct public_alias_closure, 1);
+		closure->account = account;
+		closure->failure_cb = failure_cb;
+		purple_timeout_add(0, get_public_alias_unsupported, closure);
+	}
+}
+
 void
 purple_account_clear_settings(PurpleAccount *account)
 {
--- a/libpurple/account.h	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/account.h	Fri Apr 30 03:35:28 2010 +0000
@@ -39,6 +39,10 @@
 typedef void (*PurpleAccountRequestAuthorizationCb)(void *);
 typedef void (*PurpleAccountRegistrationCb)(PurpleAccount *account, gboolean succeeded, void *user_data);
 typedef void (*PurpleAccountUnregistrationCb)(PurpleAccount *account, gboolean succeeded, void *user_data);
+typedef void (*PurpleSetPublicAliasSuccessCallback)(PurpleAccount *account, const char *new_alias);
+typedef void (*PurpleSetPublicAliasFailureCallback)(PurpleAccount *account, const char *error);
+typedef void (*PurpleGetPublicAliasSuccessCallback)(PurpleAccount *account, const char *alias);
+typedef void (*PurpleGetPublicAliasFailureCallback)(PurpleAccount *account, const char *error);
 
 #include "connection.h"
 #include "log.h"
@@ -462,6 +466,42 @@
 	const char *status_id, gboolean active, GList *attrs);
 
 /**
+ * Set a server-side (public) alias for this account.  The account
+ * must already be connected.
+ *
+ * Currently, the public alias is not stored locally, although this
+ * may change in a later version.
+ *
+ * @param account    The account
+ * @param alias      The new public alias for this account or NULL
+ *                   to unset the alias/nickname (or return it to
+ *                   a protocol-specific "default", like the username)
+ * @param success_cb A callback which will be called if the alias
+ *                   is successfully set on the server (or NULL).
+ * @param failure_cb A callback which will be called if the alias
+ *                   is not successfully set on the server (or NULL).
+ *
+ * @since 2.7.0
+ */
+void purple_account_set_public_alias(PurpleAccount *account,
+	const char *alias, PurpleSetPublicAliasSuccessCallback success_cb,
+	PurpleSetPublicAliasFailureCallback failure_cb);
+
+/**
+ * Fetch the server-side (public) alias for this account.  The account
+ * must already be connected.
+ *
+ * @param account    The account
+ * @param success_cb A callback which will be called with the alias
+ * @param failure_cb A callback which will be called if the prpl is
+ *                   unable to retrieve the server-side alias.
+ * @since 2.7.0
+ */
+void purple_account_get_public_alias(PurpleAccount *account,
+	PurpleGetPublicAliasSuccessCallback success_cb,
+	PurpleGetPublicAliasFailureCallback failure_cb);
+
+/**
  * Clears all protocol-specific settings on an account.
  *
  * @param account The account.
--- a/libpurple/protocols/bonjour/bonjour.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/bonjour/bonjour.c	Fri Apr 30 03:35:28 2010 +0000
@@ -528,7 +528,9 @@
 	NULL,                                                    /* get_account_text_table */
 	NULL,                                                    /* initiate_media */
 	NULL,                                                    /* get_media_caps */
-	NULL                                                     /* get_moods */
+	NULL,                                                    /* get_moods */
+	NULL,                                                    /* set_public_alias */
+	NULL                                                     /* get_public_alias */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/gg/gg.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/gg/gg.c	Fri Apr 30 03:35:28 2010 +0000
@@ -1601,12 +1601,6 @@
 			}
 			break;
 		case GG_EVENT_NOTIFY60:
-			purple_debug_info("gg",
-				"notify60_pre: (%d) status=%d; version=%d; descr=%s\n",
-				ev->event.notify60->uin, GG_S(ev->event.notify60->status),
-				ev->event.notify60->version,
-				ev->event.notify60->descr ? ev->event.notify60->descr : "(null)");
-
 			for (i = 0; ev->event.notify60[i].uin; i++) {
 				purple_debug_info("gg",
 					"notify60: (%d) status=%d; version=%d; descr=%s\n",
@@ -2512,7 +2506,9 @@
 	NULL,                           /* get_account_text_table */
 	NULL,                           /* initiate_media */
 	NULL,                            /* can_do_media */
-	NULL 				/* get_moods */
+	NULL,				/* get_moods */
+	NULL,				/* set_public_alias */
+	NULL				/* get_public_alias */
 };
 
 static PurplePluginInfo info = {
--- a/libpurple/protocols/irc/irc.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/irc/irc.c	Fri Apr 30 03:35:28 2010 +0000
@@ -945,7 +945,9 @@
 	NULL,                    /* get_account_text_table */
 	NULL,                    /* initiate_media */
 	NULL,					 /* get_media_caps */
-	NULL					 /* get_moods */
+	NULL,					 /* get_moods */
+	NULL,					 /* set_public_alias */
+	NULL					 /* get_public_alias */
 };
 
 static gboolean load_plugin (PurplePlugin *plugin) {
--- a/libpurple/protocols/jabber/auth_scram.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/jabber/auth_scram.c	Fri Apr 30 03:35:28 2010 +0000
@@ -47,6 +47,32 @@
 	g_return_val_if_reached(NULL);
 }
 
+static const struct {
+	const char *error;
+	const char *meaning;
+} server_errors[] = {
+	{ "invalid-encoding",
+		N_("Invalid Encoding")},
+	{ "extensions-not-supported",
+		N_("Unsupported Extension") },
+	{ "channel-bindings-dont-match",
+		N_("Unexpected response from the server.  This may indicate a possible MITM attack") },
+	{ "server-does-support-channel-binding",
+		N_("The server does support channel binding, but did not appear to advertise it.  This indicates a likely MITM attack") },
+	{ "channel-binding-not-supported",
+		N_("Server does not support channel binding") },
+	{ "unsupported-channel-binding-type",
+		N_("Unsupported channel binding method") },
+	{ "unknown-user",
+		N_("User not found") },
+	{ "invalid-username-encoding",
+		N_("Invalid Username Encoding") },
+	{ "no-resources",
+		N_("Resource Constraint") },
+	{ "other-error",
+		N_("Unknown Error") }
+};
+
 guchar *jabber_scram_hi(const JabberScramHash *hash, const GString *str,
                         GString *salt, guint iterations)
 {
--- a/libpurple/protocols/jabber/libxmpp.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/jabber/libxmpp.c	Fri Apr 30 03:35:28 2010 +0000
@@ -127,7 +127,9 @@
 	NULL, /* get_account_text_table */
 	jabber_initiate_media,          /* initiate_media */
 	jabber_get_media_caps,                  /* get_media_caps */
-	jabber_get_moods  							/* get_moods */
+	jabber_get_moods,  							/* get_moods */
+	NULL, /* set_public_alias */
+	NULL  /* get_public_alias */
 };
 
 static gboolean load_plugin(PurplePlugin *plugin)
--- a/libpurple/protocols/msn/msn.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/msn/msn.c	Fri Apr 30 03:35:28 2010 +0000
@@ -2742,7 +2742,9 @@
 	msn_get_account_text_table,             /* get_account_text_table */
 	NULL,                                   /* initiate_media */
 	NULL,                                   /* get_media_caps */
-	NULL                                    /* get_moods */
+	NULL,                                   /* get_moods */
+	NULL,                                   /* set_public_alias */
+	NULL                                    /* get_public_alias */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/mxit/mxit.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/mxit/mxit.c	Fri Apr 30 03:35:28 2010 +0000
@@ -635,7 +635,9 @@
 	mxit_get_text_table,	/* get_account_text_table */
 	NULL,					/* initiate_media */
 	NULL,					/* get_media_caps */
-	NULL					/* get_moods */
+	NULL,					/* get_moods */
+	NULL,					/* set_public_alias */
+	NULL					/* get_public_alias */
 };
 
 
--- a/libpurple/protocols/myspace/myspace.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Fri Apr 30 03:35:28 2010 +0000
@@ -3094,7 +3094,9 @@
 	msim_get_account_text_table,              /* get_account_text_table */
 	NULL,                   /* initiate_media */
 	NULL,                   /* get_media_caps */
-	NULL                    /* get_moods */
+	NULL,                   /* get_moods */
+	NULL,                   /* set_public_alias */
+	NULL                    /* get_public_alias */
 };
 
 /**
--- a/libpurple/protocols/novell/novell.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/novell/novell.c	Fri Apr 30 03:35:28 2010 +0000
@@ -3530,7 +3530,9 @@
 	NULL,						/* get_account_text_table */
 	NULL,						/* initiate_media */
 	NULL,						/* get_media_caps */
-	NULL						/* get_moods */
+	NULL,						/* get_moods */
+	NULL,						/* set_public_alias */
+	NULL						/* get_public_alias */
 };
 
 static PurplePluginInfo info = {
--- a/libpurple/protocols/null/nullprpl.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/null/nullprpl.c	Fri Apr 30 03:35:28 2010 +0000
@@ -1120,6 +1120,8 @@
   NULL,                                /* get_account_text_table */
   NULL,                                /* initiate_media */
   NULL,                                /* get_media_caps */
+  NULL,                                /* set_public_alias */
+  NULL,                                /* get_public_alias */
   NULL                                 /* get_moods */
 };
 
--- a/libpurple/protocols/oscar/libaim.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/oscar/libaim.c	Fri Apr 30 03:35:28 2010 +0000
@@ -97,7 +97,9 @@
 	NULL,					/* get_account_text_table */
 	NULL,					/* initiate_media */
 	NULL,					/* get_media_caps */
-	NULL					/* get_moods */
+	NULL,					/* get_moods */
+	NULL,					/* set_public_alias */
+	NULL					/* get_public_alias */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/oscar/libicq.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/oscar/libicq.c	Fri Apr 30 03:35:28 2010 +0000
@@ -109,6 +109,8 @@
 	NULL,					/* initiate_media */
 	NULL,					/* can_do_media */
 	oscar_get_purple_moods, /* get_moods */
+	NULL,					/* set_public_alias */
+	NULL					/* get_public_alias */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/qq/qq.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/qq/qq.c	Fri Apr 30 03:35:28 2010 +0000
@@ -1041,7 +1041,9 @@
 	NULL,							/* get_account_text_table */
 	NULL,							/* initiate_media */
 	NULL,							/* get_media_caps */
-	NULL							/* get_moods */
+	NULL,							/* get_moods */
+	NULL,							/* set_public_alias */
+	NULL							/* get_public_alias */
 };
 
 static PurplePluginInfo info = {
--- a/libpurple/protocols/silc/silc.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/silc/silc.c	Fri Apr 30 03:35:28 2010 +0000
@@ -2117,7 +2117,9 @@
 	NULL,				        /* get_account_text_table */
 	NULL,				        /* initiate_media */
 	NULL,				        /* get_media_caps */
-	NULL				        /* get_moods */
+	NULL,				        /* get_moods */
+	NULL,				        /* set_public_alias */
+	NULL				        /* get_public_alias */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/silc10/silc.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/silc10/silc.c	Fri Apr 30 03:35:28 2010 +0000
@@ -1842,7 +1842,10 @@
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	NULL,                       /* get_account_text_table */
 	NULL,                       /* initiate_media */
-	NULL                       /* can_do_media */
+	NULL,                       /* get_media_caps */
+	NULL,                       /* get_moods */
+	NULL,                       /* set_public_alias */
+	NULL                        /* get_public_alias */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/simple/simple.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/simple/simple.c	Fri Apr 30 03:35:28 2010 +0000
@@ -2110,7 +2110,9 @@
 	NULL,					/* get_account_text_table */
 	NULL,					/* initiate_media */
 	NULL,					/* get_media_caps */
-	NULL					/* get_moods */
+	NULL,					/* get_moods */
+	NULL,					/* set_public_alias */
+	NULL					/* get_public_alias */
 };
 
 
--- a/libpurple/protocols/yahoo/libyahoo.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/yahoo/libyahoo.c	Fri Apr 30 03:35:28 2010 +0000
@@ -265,7 +265,9 @@
 	yahoo_get_account_text_table,    /* get_account_text_table */
 	NULL, /* initiate_media */
 	NULL,  /* get_media_caps */
-	NULL   /* get_moods */
+	NULL,  /* get_moods */
+	NULL,  /* set_public_alias */
+	NULL   /* get_public_alias */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/yahoo/libyahoojp.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/yahoo/libyahoojp.c	Fri Apr 30 03:35:28 2010 +0000
@@ -161,7 +161,9 @@
 	yahoojp_get_account_text_table,    /* get_account_text_table */
 	NULL, /* initiate_media */
 	NULL, /* get_media_caps */
-	NULL  /* get_moods */
+	NULL, /* get_moods */
+	NULL, /* set_public_alias */
+	NULL  /* get_public_alias */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/zephyr/zephyr.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/protocols/zephyr/zephyr.c	Fri Apr 30 03:35:28 2010 +0000
@@ -2909,7 +2909,9 @@
 	NULL,					/* get_account_text_table */
 	NULL,					/* initate_media */
 	NULL,					/* get_media_caps */
-	NULL					/* get_moods */
+	NULL,					/* get_moods */
+	NULL,					/* set_public_alias */
+	NULL					/* get_public_alias */
 };
 
 static PurplePluginInfo info = {
--- a/libpurple/prpl.h	Wed Apr 28 20:57:59 2010 +0000
+++ b/libpurple/prpl.h	Fri Apr 30 03:35:28 2010 +0000
@@ -580,8 +580,48 @@
 	/**
 	 * Returns an array of "PurpleMood"s, with the last one having
 	 * "mood" set to @c NULL.
+	 * @since 2.7.0
 	 */
 	PurpleMood *(*get_moods)(PurpleAccount *account);
+
+	/**
+	 * Set the user's "friendly name" (or alias or nickname or
+	 * whatever term you want to call it) on the server.  The
+	 * protocol plugin should call success_cb or failure_cb
+	 * *asynchronously* (if it knows immediately that the set will fail,
+	 * call one of the callbacks from an idle/0-second timeout) depending
+	 * on if the nickname is set successfully.
+	 *
+	 * @param gc    The connection for which to set an alias
+	 * @param alias The new server-side alias/nickname for this account,
+	 *              or NULL to unset the alias/nickname (or return it to
+	 *              a protocol-specific "default").
+	 * @param success_cb Callback to be called if the public alias is set
+	 * @param failure_cb Callback to be called if setting the public alias
+	 *                   fails
+	 * @see purple_account_set_public_alias
+	 * @since 2.7.0
+	 */
+	void (*set_public_alias)(PurpleConnection *gc, const char *alias,
+	                         PurpleSetPublicAliasSuccessCallback success_cb,
+	                         PurpleSetPublicAliasFailureCallback failure_cb);
+	/**
+	 * Retrieve the user's "friendly name" as set on the server.
+	 * The protocol plugin should call success_cb or failure_cb
+	 * *asynchronously* (even if it knows immediately that the set will fail,
+	 * call one of the callbacks from an idle/0-second timeout) depending
+	 * on if the nickname is retrieved.
+	 *
+	 * @param gc    The connection for which to retireve the alias
+	 * @param success_cb Callback to be called with the retrieved alias
+	 * @param failure_cb Callback to be called if the prpl is unable to
+	 *                   retrieve the alias
+	 * @see purple_account_get_public_alias
+	 * @since 2.7.0
+	 */
+	void (*get_public_alias)(PurpleConnection *gc,
+	                         PurpleSetPublicAliasSuccessCallback success_cb,
+	                         PurpleSetPublicAliasFailureCallback failure_cb);
 };
 
 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
--- a/pidgin/gtkrequest.c	Wed Apr 28 20:57:59 2010 +0000
+++ b/pidgin/gtkrequest.c	Fri Apr 30 03:35:28 2010 +0000
@@ -738,8 +738,9 @@
 					    PurpleAccount *account, const char *who, PurpleConversation *conv,
 						void *user_data, size_t action_count, va_list actions)
 {
-	pidgin_request_action_with_icon(title, primary, secondary, default_action,
-		account, who, conv, NULL, 0, user_data, action_count, actions);
+	return pidgin_request_action_with_icon(title, primary, secondary,
+		default_action, account, who, conv, NULL, 0, user_data, action_count,
+		actions);
 }
 
 static void