Workaround for libpurple's lack of set_alias()

Felipe Contreras felipe.contreras at
Thu Jan 14 19:24:53 EST 2010


Obviously libpurple needs a set_alias() (aka nickname/friendly-name) function.

As Mark Doliner clearly stated here:

Adium works around it for msn by calling msn_act_id() [or
msn_set_friendly_name()] directly:

The personalbar plug-in works around it similarly by loading the
module manually:

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)

    prpl = purple_connection_get_prpl (gc);
    if (!g_module_symbol (prpl->handle, "set_alias", (void *) &set_alias))

    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.


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: <>

More information about the Devel mailing list