Workaround for libpurple's lack of set_alias()
Felipe Contreras
felipe.contreras at gmail.com
Thu Jan 14 19:24:53 EST 2010
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-purple-implement-set_alias.patch
Type: text/x-patch
Size: 1975 bytes
Desc: not available
URL: <http://pidgin.im/pipermail/devel/attachments/20100115/6ba4d57a/attachment-0002.bin>
More information about the Devel
mailing list