Hi, Obviously libpurple needs a set_alias() (aka nickname/friendly-name) function.
As Mark Doliner clearly stated here: http://pidgin.im/pipermail/devel/2009-December/009065.html Adium works around it for msn by calling msn_act_id() [or msn_set_friendly_name()] directly: http://hg.adium.im/adium/file/d68b2e761e79/Plugins/Purple%20Service/ESPurpleMSNAccount.m#l364 The personalbar plug-in works around it similarly by loading the module manually: http://code.google.com/p/pidgin-personalbar/source/browse/trunk/personalbar.c telepathy-haze simply throws an error: g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED, "Sadly, there's no general API in libpurple to set your own " "server alias."); Indeed it's sad, and I'm sure other clients would have exactly the same problem, and other prpls as well. There's a much better way to workaround libpurple's handicap: --- static void serv_set_alias (PurpleConnection *gc, const char *alias) { PurplePlugin *prpl; void (*set_alias) (PurpleConnection *gc, const char *alias); if (!gc) return; prpl = purple_connection_get_prpl (gc); if (!g_module_symbol (prpl->handle, "set_alias", (void *) &set_alias)) return; set_alias (gc, alias); } --- Then the prpl would have to export a set_alias() function (just like msn_set_friendly_name()). In case you are wondering if multiple plugins's definition of set_alias() would conflict: no; symbols are loaded in the local name-space. For example, all plugins export 'purple_init_plugin' safely. You might wonder: wouldn't it be better to just fix libpurple? And to that my answer is: ha! I wouldn't hold my breath. I'm attaching the patch just in case somebody else succeeds in getting it accepted, perhaps by issuing a secret offering to the right god, or maybe by nailing the time when developers are not feeling moody. Anyway, if the patch gets accepted, serv_got_alias() would work exactly the same. Note: I chose serv_set_alias() because there was a long discussion between Pidgin developers and me, and the consensus was that the best naming for nicknames/aliases stuff was: public_alias (nickname), and private_alias. However, it really doesn't make sense to issue a serv_set_private_alias(); if it's private, why would the server want to know about it? So the only one that makes sense is serv_set_public_alias(), but since there's no other one we can get rid of the "public". Naturally, msn-pecan would export set_alias() for clients to use this way. Cheers. -- Felipe Contreras
From ada30d909a11a8b6fa109e9352fca658b4cfe12b Mon Sep 17 00:00:00 2001 From: Felipe Contreras <[email protected]> Date: Fri, 15 Jan 2010 01:11:55 +0200 Subject: [PATCH] purple: implement set_alias() So that we can set our personal alias (aka friendly name). Signed-off-by: Felipe Contreras <[email protected]> --- purple/prpl.h | 2 ++ purple/server.c | 22 ++++++++++++++++++++++ purple/server.h | 2 ++ 3 files changed, 26 insertions(+), 0 deletions(-) diff --git a/purple/prpl.h b/purple/prpl.h index 5d46075..6b6941a 100644 --- a/purple/prpl.h +++ b/purple/prpl.h @@ -481,6 +481,8 @@ struct _PurplePluginProtocolInfo */ PurpleMediaCaps (*get_media_caps)(PurpleAccount *account, const char *who); + + void (*set_alias)(PurpleConnection *gc, const char *alias); }; #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \ diff --git a/purple/server.c b/purple/server.c index 351e6d0..eb27f82 100644 --- a/purple/server.c +++ b/purple/server.c @@ -995,3 +995,25 @@ void serv_send_file(PurpleConnection *gc, const char *who, const char *file) } } } + +void serv_set_alias(PurpleConnection *gc, const char *alias) +{ + PurplePlugin *prpl; + PurplePluginProtocolInfo *prpl_info; + + if (!gc) + return; + + prpl = purple_connection_get_prpl(gc); + + if (!prpl) + return; + + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); + + if (!prpl_info) + return; + + if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, set_alias)) + prpl_info->set_alias(gc, alias); +} diff --git a/purple/server.h b/purple/server.h index 5c5b40d..b9f9be6 100644 --- a/purple/server.h +++ b/purple/server.h @@ -186,6 +186,8 @@ void serv_got_chat_in(PurpleConnection *g, int id, const char *who, PurpleMessageFlags flags, const char *message, time_t mtime); void serv_send_file(PurpleConnection *gc, const char *who, const char *file); +void serv_set_alias(PurpleConnection *gc, const char *alias); + #ifdef __cplusplus } #endif -- 1.6.6
