Ticket #917: gadugadu-local-clist-fixed.patch

File gadugadu-local-clist-fixed.patch, 3.0 KB (added by dx, at 2014-01-15T23:53:57Z)

The patch updated to 3.2.1

  • protocols/account.c

    a b  
    2727#include "bitlbee.h"
    2828#include "account.h"
    2929
     30static const char* account_protocols_local[] = {
     31        "gg", NULL
     32};
     33
    3034static char *set_eval_nick_source( set_t *set, char *value );
    3135
    3236account_t *account_add( bee_t *bee, struct prpl *prpl, char *user, char *pass )
    static gboolean account_on_timeout( gpointer d, gint fd, b_input_condition cond 
    338342
    339343void account_on( bee_t *bee, account_t *a )
    340344{
     345        GHashTableIter nicks;
     346        gpointer k, v;
     347
    341348        if( a->ic )
    342349        {
    343350                /* Trying to enable an already-enabled account */
    void account_on( bee_t *bee, account_t *a ) 
    351358       
    352359        if( a->ic && !( a->ic->flags & ( OPT_SLOW_LOGIN | OPT_LOGGED_IN ) ) )
    353360                a->ic->keepalive = b_timeout_add( 120000, account_on_timeout, a->ic );
     361
     362        if( a->flags & ACC_FLAG_LOCAL )
     363        {
     364                g_hash_table_iter_init(&nicks, a->nicks);
     365                while( g_hash_table_iter_next( &nicks, &k, &v ) )
     366                {
     367                        a->prpl->add_buddy( a->ic, (char*) k, NULL );
     368                }
     369        }
    354370}
    355371
    356372void account_off( bee_t *bee, account_t *a )
    int account_reconnect_delay( account_t *a ) 
    456472       
    457473        return a->auto_reconnect_delay;
    458474}
     475
     476int protocol_account_islocal( const char* protocol )
     477{
     478        const char** p = account_protocols_local;
     479        do {
     480                if( strcmp( *p, protocol ) == 0 )
     481                        return 1;
     482        } while( *( ++p ) );
     483        return 0;
     484}
  • protocols/account.h

    a b char *set_eval_account( set_t *set, char *value ); 
    5858char *set_eval_account_reconnect_delay( set_t *set, char *value );
    5959int account_reconnect_delay( account_t *a );
    6060
     61int protocol_account_islocal( const char* protocol );
     62
    6163typedef enum
    6264{
    6365        ACC_SET_OFFLINE_ONLY = 0x02,    /* Allow changes only if the acct is offline. */
    typedef enum 
    6971        ACC_FLAG_AWAY_MESSAGE = 0x01,   /* Supports away messages instead of just states. */
    7072        ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */
    7173        ACC_FLAG_HANDLE_DOMAINS = 0x04, /* Contact handles need a domain portion. */
     74        ACC_FLAG_LOCAL = 0x08,          /* Contact list is local. */
    7275} account_flag_t;
    7376
    7477#endif
  • storage_xml.c

    a b static xt_status handle_account( struct xt_node *node, gpointer data ) 
    8686        char *protocol, *handle, *server, *password = NULL, *autoconnect, *tag;
    8787        char *pass_b64 = NULL;
    8888        unsigned char *pass_cr = NULL;
    89         int pass_len;
     89        int pass_len, local = 0;
    9090        struct prpl *prpl = NULL;
    9191        account_t *acc;
    9292        struct xt_node *c;
    static xt_status handle_account( struct xt_node *node, gpointer data ) 
    9999       
    100100        protocol = xt_find_attr( node, "protocol" );
    101101        if( protocol )
     102        {
    102103                prpl = find_protocol( protocol );
     104                local = protocol_account_islocal( protocol );
     105        }
    103106       
    104107        if( !handle || !pass_b64 || !protocol || !prpl )
    105108                return XT_ABORT;
    static xt_status handle_account( struct xt_node *node, gpointer data ) 
    113116                        set_setstr( &acc->set, "auto_connect", autoconnect );
    114117                if( tag )
    115118                        set_setstr( &acc->set, "tag", tag );
     119                if( local )
     120                        acc->flags |= ACC_FLAG_LOCAL;
    116121        }
    117122        else
    118123                return XT_ABORT;