pidgin: c9659a3f: Add purple_account_[gs]et_public_alias f...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Thu Apr 29 02:00:59 EDT 2010
-----------------------------------------------------------------
Revision: c9659a3fecdd575434640e531c3eb61f90de6976
Ancestor: d6d07ff80215abf9ed3d80637a7ad3e050781a65
Author: darkrain42 at pidgin.im
Date: 2010-04-29T05:58:02
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c9659a3fecdd575434640e531c3eb61f90de6976
Modified files:
ChangeLog.API libpurple/account.c libpurple/account.h
libpurple/protocols/bonjour/bonjour.c
libpurple/protocols/gg/gg.c libpurple/protocols/irc/irc.c
libpurple/protocols/jabber/libxmpp.c
libpurple/protocols/msn/msn.c
libpurple/protocols/mxit/mxit.c
libpurple/protocols/myspace/myspace.c
libpurple/protocols/novell/novell.c
libpurple/protocols/null/nullprpl.c
libpurple/protocols/oscar/libaim.c
libpurple/protocols/oscar/libicq.c
libpurple/protocols/qq/qq.c libpurple/protocols/silc/silc.c
libpurple/protocols/silc10/silc.c
libpurple/protocols/simple/simple.c
libpurple/protocols/yahoo/libyahoo.c
libpurple/protocols/yahoo/libyahoojp.c
libpurple/protocols/zephyr/zephyr.c libpurple/prpl.h
ChangeLog:
Add purple_account_[gs]et_public_alias functions, per discussion in d at cpi
-------------- next part --------------
============================================================
--- ChangeLog.API 1f6f7682d352aec879637157a718a8051c5e199e
+++ ChangeLog.API 281b6563db11e89b6969c005e159b60fb633689d
@@ -8,7 +8,9 @@ version 2.7.0 (??/??/????):
* 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
============================================================
--- libpurple/account.c 071f041650e4ad0822440b693708a1944e584d02
+++ libpurple/account.c d8b86378c4aeae32fabdcaf478e904ec4c844526
@@ -1782,7 +1782,93 @@ purple_account_set_status_list(PurpleAcc
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)
{
g_return_if_fail(account != NULL);
============================================================
--- libpurple/account.h af3593c23ae35b33285547bce90deb5eac7859c7
+++ libpurple/account.h 7a5280dd166fe18d8674819f38bb21cff6603c94
@@ -39,6 +39,10 @@ typedef void (*PurpleAccountUnregistrati
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 @@ void purple_account_set_status_list(Purp
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.
============================================================
--- libpurple/protocols/bonjour/bonjour.c f4a3499329e3dae805b276959553ea90471c8d25
+++ libpurple/protocols/bonjour/bonjour.c 5ac67fd0631d3e1cf3950e1c36b1d88aa5eb84b7
@@ -528,7 +528,9 @@ static PurplePluginProtocolInfo prpl_inf
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 =
============================================================
--- libpurple/protocols/gg/gg.c 736287c1e736efe0c596a18015a7e8c04fb9c2f7
+++ libpurple/protocols/gg/gg.c 69a3357fc4821ad56a660a42d44df8c14ee8293a
@@ -2506,7 +2506,9 @@ static PurplePluginProtocolInfo prpl_inf
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 = {
============================================================
--- libpurple/protocols/irc/irc.c ed26270e58beca4cea8dd4b422634bcae0c71785
+++ libpurple/protocols/irc/irc.c 7f37c323a474e7e1dee1dbd1a9b11da76deeae9c
@@ -945,7 +945,9 @@ static PurplePluginProtocolInfo prpl_inf
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) {
============================================================
--- libpurple/protocols/jabber/libxmpp.c eb3c713d4904a50323e1e11e5474a3c5af410cef
+++ libpurple/protocols/jabber/libxmpp.c cbfca2a5d3f10d83f1d05ff858ec52306c6eee68
@@ -127,7 +127,9 @@ static PurplePluginProtocolInfo prpl_inf
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)
============================================================
--- libpurple/protocols/msn/msn.c 1f196cd3ab1a5d239bb9d1cb00f7c5626ce6b951
+++ libpurple/protocols/msn/msn.c c1c19c5e1ea1bfb280ad0378dc70cb5e02557710
@@ -2742,7 +2742,9 @@ static PurplePluginProtocolInfo prpl_inf
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 =
============================================================
--- libpurple/protocols/mxit/mxit.c bd5e4e9204cd0e5aecd7890dd6b60dbb27bd93f7
+++ libpurple/protocols/mxit/mxit.c 3a11fef72cf21c0aea6318fdab19556adac30eaf
@@ -635,7 +635,9 @@ static PurplePluginProtocolInfo proto_in
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 */
};
============================================================
--- libpurple/protocols/myspace/myspace.c fbe1f2bbbb066cd2b306f1c7786625dba728a6a3
+++ libpurple/protocols/myspace/myspace.c 6462f2cb353af2649c37d9c2e8634badca244de5
@@ -3094,7 +3094,9 @@ static PurplePluginProtocolInfo prpl_inf
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 */
};
/**
============================================================
--- libpurple/protocols/novell/novell.c f8e9ca37230059dd36526b2e10fc56c41a3f49c9
+++ libpurple/protocols/novell/novell.c acf5c86796a0220d71bea93c603df67d31c9be84
@@ -3530,7 +3530,9 @@ static PurplePluginProtocolInfo prpl_inf
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 = {
============================================================
--- libpurple/protocols/null/nullprpl.c 4207f6911a52c5131d7a01492d7b79816df3457f
+++ libpurple/protocols/null/nullprpl.c 0fd949edbb3ad21a0215f7e8f422e6f1905945c0
@@ -1120,6 +1120,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* get_account_text_table */
NULL, /* initiate_media */
NULL, /* get_media_caps */
+ NULL, /* set_public_alias */
+ NULL, /* get_public_alias */
NULL /* get_moods */
};
============================================================
--- libpurple/protocols/oscar/libaim.c aaf891693df785ac5f727e3bbf2dab91da4e496e
+++ libpurple/protocols/oscar/libaim.c 3dc9d826ff98e1ff596fa383479b11c2cf677061
@@ -97,7 +97,9 @@ static PurplePluginProtocolInfo prpl_inf
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 =
============================================================
--- libpurple/protocols/oscar/libicq.c c142e88d51d0c17682b5574d807aa604f332c391
+++ libpurple/protocols/oscar/libicq.c a45c5680773c949b0f6c3263afd58c6259f6fc23
@@ -109,6 +109,8 @@ static PurplePluginProtocolInfo prpl_inf
NULL, /* initiate_media */
NULL, /* can_do_media */
oscar_get_purple_moods, /* get_moods */
+ NULL, /* set_public_alias */
+ NULL /* get_public_alias */
};
static PurplePluginInfo info =
============================================================
--- libpurple/protocols/qq/qq.c 14ed198169b87cd92e135dd0e7750119016152b9
+++ libpurple/protocols/qq/qq.c 555e549265519d242352127d645f43a5054f88b3
@@ -1041,7 +1041,9 @@ static PurplePluginProtocolInfo prpl_inf
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 = {
============================================================
--- libpurple/protocols/silc/silc.c e1a19ed0782fd71fb10137a557ae511255743326
+++ libpurple/protocols/silc/silc.c 7d6870429118aaf4deed6e1916b2ec60d369b688
@@ -2117,7 +2117,9 @@ static PurplePluginProtocolInfo prpl_inf
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 =
============================================================
--- libpurple/protocols/silc10/silc.c 558f05f118164a877683de3a250ea7da9a97d02f
+++ libpurple/protocols/silc10/silc.c 916b57c324445356514ebeb97df4f65475e91fe1
@@ -1842,7 +1842,10 @@ static PurplePluginProtocolInfo prpl_inf
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 =
============================================================
--- libpurple/protocols/simple/simple.c 59e4a147cd1445804992ec13946b9304ef70a805
+++ libpurple/protocols/simple/simple.c 8a2f298f4f681f8116aa9787b3114590cec92291
@@ -2110,7 +2110,9 @@ static PurplePluginProtocolInfo prpl_inf
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 */
};
============================================================
--- libpurple/protocols/yahoo/libyahoo.c 0cd4bcbc78671cbfd02e20824301eaa1e9f1c5c0
+++ libpurple/protocols/yahoo/libyahoo.c 3b665fc43ba5773de00087dac573cf7c9dd1d8b0
@@ -265,7 +265,9 @@ static PurplePluginProtocolInfo prpl_inf
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 =
============================================================
--- libpurple/protocols/yahoo/libyahoojp.c 7bcf6941679d32321af2e69786d141dca7a9fd22
+++ libpurple/protocols/yahoo/libyahoojp.c 404dee90b563851004f718d5e2dd502b0ef81613
@@ -161,7 +161,9 @@ static PurplePluginProtocolInfo prpl_inf
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 =
============================================================
--- libpurple/protocols/zephyr/zephyr.c c5d9a1ba069c4048606400e46256d4e62d78b8d1
+++ libpurple/protocols/zephyr/zephyr.c f2415735b9165ab2cadfedcacc1c783772f22fec
@@ -2909,7 +2909,9 @@ static PurplePluginProtocolInfo prpl_inf
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 = {
============================================================
--- libpurple/prpl.h d68fe1e6ff5bbbf61067466126b6145c5442bd6e
+++ libpurple/prpl.h 937e7082078e8ee2dcd3bfcfa397b8feed0184ed
@@ -580,8 +580,48 @@ struct _PurplePluginProtocolInfo
/**
* 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) \
More information about the Commits
mailing list