Ticket #917: 0001-local-clist.patch

File 0001-local-clist.patch, 3.0 KB (added by Michał Siejak, at 2012-02-11T13:58:07Z)
  • protocols/account.c

    === modified file 'protocols/account.c'
     
    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 )
     
    342346
    343347void account_on( bee_t *bee, account_t *a )
    344348{
     349        GHashTableIter nicks;
     350        gpointer k, v;
     351
    345352        if( a->ic )
    346353        {
    347354                /* Trying to enable an already-enabled account */
     
    355362       
    356363        if( a->ic && !( a->ic->flags & OPT_SLOW_LOGIN ) )
    357364                a->ic->keepalive = b_timeout_add( 120000, account_on_timeout, a->ic );
     365
     366        if( a->flags & ACC_FLAG_LOCAL )
     367        {
     368                g_hash_table_iter_init(&nicks, a->nicks);
     369                while( g_hash_table_iter_next( &nicks, &k, &v ) )
     370                {
     371                        a->prpl->add_buddy( a->ic, (char*) k, NULL );
     372                }
     373        }
    358374}
    359375
    360376void account_off( bee_t *bee, account_t *a )
     
    457473       
    458474        return a->auto_reconnect_delay;
    459475}
     476
     477int protocol_account_islocal( const char* protocol )
     478{
     479        const char** p = account_protocols_local;
     480        do {
     481                if( strcmp( *p, protocol ) == 0 )
     482                        return 1;
     483        } while( *( ++p ) );
     484        return 0;
     485}
  • protocols/account.h

    === modified file 'protocols/account.h'
     
    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_NOSAVE = 0x01,          /* Don't save this setting (i.e. stored elsewhere). */
     
    6971{
    7072        ACC_FLAG_AWAY_MESSAGE = 0x01,   /* Supports away messages instead of just states. */
    7173        ACC_FLAG_STATUS_MESSAGE = 0x02, /* Supports status messages (without being away). */
     74        ACC_FLAG_LOCAL = 0x04,          /* Contact list is local. */
    7275} account_flag_t;
    7376
    7477#endif
  • storage_xml.c

    === modified file 'storage_xml.c'
     
    129129                char *protocol, *handle, *server, *password = NULL, *autoconnect, *tag;
    130130                char *pass_b64 = NULL;
    131131                unsigned char *pass_cr = NULL;
    132                 int pass_len;
     132                int pass_len, local = 0;
    133133                struct prpl *prpl = NULL;
    134134               
    135135                handle = xml_attr( attr_names, attr_values, "handle" );
     
    139139                tag = xml_attr( attr_names, attr_values, "tag" );
    140140               
    141141                protocol = xml_attr( attr_names, attr_values, "protocol" );
    142                 if( protocol )
    143                         prpl = find_protocol( protocol );
     142                if( protocol )
     143                {
     144                        prpl  = find_protocol( protocol );
     145                        local = protocol_account_islocal( protocol );
     146                }
    144147               
    145148                if( !handle || !pass_b64 || !protocol )
    146149                        g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
     
    158161                                set_setstr( &xd->current_account->set, "auto_connect", autoconnect );
    159162                        if( tag )
    160163                                set_setstr( &xd->current_account->set, "tag", tag );
     164                        if( local )
     165                                xd->current_account->flags |= ACC_FLAG_LOCAL;
    161166                }
    162167                else
    163168                {