Changeset 2288705 for account.c


Ignore:
Timestamp:
2009-12-07T21:54:19Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
1c3008a
Parents:
aac4017 (diff), 36cf9fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging head.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • account.c

    raac4017 r2288705  
    2727#include "bitlbee.h"
    2828#include "account.h"
     29#include "chat.h"
    2930
    3031account_t *account_add( irc_t *irc, struct prpl *prpl, char *user, char *pass )
     
    5556       
    5657        s = set_add( &a->set, "password", NULL, set_eval_account, a );
    57         s->flags |= ACC_SET_NOSAVE;
     58        s->flags |= ACC_SET_NOSAVE | SET_NULL_OK;
    5859       
    5960        s = set_add( &a->set, "username", NULL, set_eval_account, a );
     
    7778        /* Double-check: We refuse to edit on-line accounts. */
    7879        if( set->flags & ACC_SET_OFFLINE_ONLY && acc->ic )
    79                 return NULL;
    80        
    81         if( strcmp( set->key, "username" ) == 0 )
     80                return SET_INVALID;
     81       
     82        if( strcmp( set->key, "server" ) == 0 )
     83        {
     84                g_free( acc->server );
     85                if( value && *value )
     86                {
     87                        acc->server = g_strdup( value );
     88                        return value;
     89                }
     90                else
     91                {
     92                        acc->server = g_strdup( set->def );
     93                        return g_strdup( set->def );
     94                }
     95        }
     96        else if( strcmp( set->key, "username" ) == 0 )
    8297        {
    8398                g_free( acc->user );
     
    87102        else if( strcmp( set->key, "password" ) == 0 )
    88103        {
    89                 g_free( acc->pass );
    90                 acc->pass = g_strdup( value );
    91                 return NULL;    /* password shouldn't be visible in plaintext! */
    92         }
    93         else if( strcmp( set->key, "server" ) == 0 )
    94         {
    95                 g_free( acc->server );
    96                 if( *value )
    97                 {
    98                         acc->server = g_strdup( value );
    99                         return value;
     104                if( value )
     105                {
     106                        g_free( acc->pass );
     107                        acc->pass = g_strdup( value );
     108                        return NULL;    /* password shouldn't be visible in plaintext! */
    100109                }
    101110                else
    102111                {
    103                         acc->server = NULL;
    104                         return g_strdup( set->def );
     112                        /* NULL can (should) be stored in the set_t
     113                           variable, but is otherwise not correct. */
     114                        return SET_INVALID;
    105115                }
    106116        }
     
    108118        {
    109119                if( !is_bool( value ) )
    110                         return NULL;
     120                        return SET_INVALID;
    111121               
    112122                acc->auto_connect = bool2int( value );
     
    114124        }
    115125       
    116         return NULL;
     126        return SET_INVALID;
    117127}
    118128
     
    181191{
    182192        account_t *a, *l = NULL;
     193        struct chat *c, *nc;
    183194       
    184195        if( acc->ic )
     
    193204                        else
    194205                                irc->accounts = a->next;
     206                       
     207                        for( c = irc->chatrooms; c; c = nc )
     208                        {
     209                                nc = c->next;
     210                                if( acc == c->acc )
     211                                        chat_del( irc, c );
     212                        }
    195213                       
    196214                        while( a->set )
     
    254272       
    255273        /* Sure, call me evil for implementing my own fscanf here, but it's
    256            dead simple and I'm immediately at the next part to parse. */
     274           dead simple and I immediately know where to continue parsing. */
    257275       
    258276        if( *value == 0 )
     
    287305        struct account_reconnect_delay p;
    288306       
    289         return account_reconnect_delay_parse( value, &p ) ? value : NULL;
     307        return account_reconnect_delay_parse( value, &p ) ? value : SET_INVALID;
    290308}
    291309
Note: See TracChangeset for help on using the changeset viewer.