Feature: don't autosave blist.xml upon "last_seen" changes

immerrr again immerrr at gmail.com
Mon Apr 1 03:35:09 EDT 2013

On Sat, Mar 30, 2013 at 3:08 PM, Peter Lawler <bleeter at gmail.com> wrote:
> On 30/03/13 21:24, immerrr again wrote:
>> The problem is that a buddy going offline alters
>> "last_seen" node attribute
> What you'd probably want to do is modify the blist so that plugins can have
> a preference to not write blist updates to disk immediately (you could have
> it set a timer for X minutes, or account logoff, or pidgin shutdown).

Alright, thanks. The first thing that comes to mind is to add a
"reason" parameter to save_node callback, smth like:

    typedef enum {


    } PurpleBlistNodeSaveReason;

    purple_blist_save_node_with_reason(PurpleBlistNode *node,
PurpleBlistNodeSaveReason reason, void* arg);

which would be called as


Well, I'm not really sure where to find the guidelines in writing
plugins/GUIs for libpurple, so but something tells me that this might
open a pandora box of backward incompatibility (especially, ABI
incompatibility) issues when a plugin (or a GUI) is oblivious of the
new API.

So, another option is to define those "PurpleBlistNodeSaveReason"
reason & "void* arg" as a variable accessible from outside with
something like:

    PurpleBlistNodeSaveReason purple_blist_node_get_save_reason();
    void* purple_blist_node_get_save_arg();

And then do the following in blist.c where save_node is used:

    purple_blist_node_set_int(PurpleBlistNode* node, const char *key, int data)
        if (ops && ops->save_node) {

            ops->save_node((PurpleBlistNode *) buddy);


> This is to say, to get 'last_seen' to not write as much to disk, blist
> probably needs changing then the last_seen plugin needs changing to meet the
> new blist foo.

The latter solution feels much more hackish to me, but AFAIU it avoids
all sorts of ABI incompatibility and will be fine for as long as
libpurple is single-threaded by design. And it would avoid the
necessity to modify lastseen or any other plugins.


More information about the Devel mailing list