Ticket #917: whatsapp-local-contacts.patch

File whatsapp-local-contacts.patch, 2.2 KB (added by dx, at 2015-01-23T20:10:32Z)

here's the fix for the whatsapp side, will upstream it soon™ (and yes it turned out to be what i said about imcb_connected, yes i know it took too long, don't look at me that way)

  • protocols/account.c

    From 812031ba549e2b3ee7aa732b6e3e34237c903b56 Mon Sep 17 00:00:00 2001
    From: dequis <dx@dxzone.com.ar>
    Date: Fri, 23 Jan 2015 03:29:00 -0300
    Subject: [PATCH] Fix whatsapp local contact lists
    
    Had to move the code that adds contacts to imcb_connected to avoid
    dereferencing a null im_connection.
    
    Turns out this kind of local contact lists only applies to renamed
    contacts, though. It doesn't deal with libpurple's blist.xml at all
    (it could, there are APIs for it since 2.6.0)
    ---
     protocols/account.c | 14 +-------------
     protocols/nogaim.c  | 11 +++++++++++
     2 files changed, 12 insertions(+), 13 deletions(-)
    
    diff --git a/protocols/account.c b/protocols/account.c
    index 188e362..234b9de 100644
    a b  
    2828#include "account.h"
    2929
    3030static const char* account_protocols_local[] = {
    31         "gg", NULL
     31        "gg", "whatsapp", NULL
    3232};
    3333
    3434static char *set_eval_nick_source( set_t *set, char *value );
    static gboolean account_on_timeout( gpointer d, gint fd, b_input_condition cond 
    350350
    351351void account_on( bee_t *bee, account_t *a )
    352352{
    353         GHashTableIter nicks;
    354         gpointer k, v;
    355 
    356353        if( a->ic )
    357354        {
    358355                /* Trying to enable an already-enabled account */
    void account_on( bee_t *bee, account_t *a ) 
    366363       
    367364        if( a->ic && !( a->ic->flags & ( OPT_SLOW_LOGIN | OPT_LOGGED_IN ) ) )
    368365                a->ic->keepalive = b_timeout_add( 120000, account_on_timeout, a->ic );
    369 
    370         if( a->flags & ACC_FLAG_LOCAL )
    371         {
    372                 g_hash_table_iter_init(&nicks, a->nicks);
    373                 while( g_hash_table_iter_next( &nicks, &k, &v ) )
    374                 {
    375                         a->prpl->add_buddy( a->ic, (char*) k, NULL );
    376                 }
    377         }
    378366}
    379367
    380368void account_off( bee_t *bee, account_t *a )
  • protocols/nogaim.c

    diff --git a/protocols/nogaim.c b/protocols/nogaim.c
    index ff1c9a8..0a674b4 100644
    a b void imcb_connected( struct im_connection *ic ) 
    293293           function should be handled correctly. (IOW, ignored) */
    294294        if( ic->flags & OPT_LOGGED_IN )
    295295                return;
     296
     297        if( ic->acc->flags & ACC_FLAG_LOCAL )
     298        {
     299                GHashTableIter nicks;
     300                gpointer k, v;
     301                g_hash_table_iter_init( &nicks, ic->acc->nicks );
     302                while( g_hash_table_iter_next( &nicks, &k, &v ) )
     303                {
     304                        ic->acc->prpl->add_buddy( ic, (char*) k, NULL );
     305                }
     306        }
    296307       
    297308        imcb_log( ic, "Logged in" );
    298309