Changeset 7e3592e


Ignore:
Timestamp:
2006-07-05T18:34:31Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
75a4b85
Parents:
5b52a48
Message:

Fixed text_load(), added detection of primary storage backends without
save support (which shouldn't be allowed) and added a call to nick_lc()
to xml_save() so at least nicks should now be case-insensitive.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • storage.c

    r5b52a48 r7e3592e  
    7070       
    7171        storage = storage_init_single(primary);
    72         if (storage == NULL)
     72        if (storage == NULL && storage->save == NULL)
    7373                return NULL;
    7474
  • storage_text.c

    r5b52a48 r7e3592e  
    2828#include "crypting.h"
    2929
    30 /* DO NOT USE THIS FUNCTION IN NEW CODE. This
    31  * function is here merely because the save/load code still uses
    32  * ids rather than names */
    33 static struct prpl *find_protocol_by_id(int id)
    34 {
    35         switch (id) {
    36         case 0: case 1: case 3: return find_protocol("oscar");
    37         case 4: return find_protocol("msn");
    38         case 2: return find_protocol("yahoo");
    39         case 8: return find_protocol("jabber");
    40         default: break;
    41         }
    42         return NULL;
    43 }
    44 
    45 static int find_protocol_id(const char *name)
    46 {
    47         if (!strcmp(name, "oscar")) return 1;
    48         if (!strcmp(name, "msn")) return 4;
    49         if (!strcmp(name, "yahoo")) return 2;
    50         if (!strcmp(name, "jabber")) return 8;
    51 
    52         return -1;
    53 }
    54 
    55 
    5630static void text_init (void)
    5731{
     
    7044        FILE *fp;
    7145        user_t *ru = user_find( irc, ROOT_NICK );
     46        account_t *acc, *acc_lookup[9];
    7247       
    7348        if( irc->status & USTATUS_IDENTIFIED )
     
    8055        fscanf( fp, "%32[^\n]s", s );
    8156
    82         if (checkpass (password, s) != 0)
     57        if( checkpass( password, s ) != 0 )
    8358        {
    8459                fclose( fp );
     
    10075        fclose( fp );
    10176       
     77        /* Build a list with the first listed account of every protocol
     78           number. So if the user had nicks defined for a second account on
     79           the same IM network, those nicks will be added to the wrong
     80           account, and the user should rename those buddies again. But at
     81           least from now on things will be saved properly. */
     82        memset( acc_lookup, 0, sizeof( acc_lookup ) );
     83        for( acc = irc->accounts; acc; acc = acc->next )
     84        {
     85                if( acc_lookup[0] == NULL && strcmp( acc->prpl->name, "oscar" ) == 0 )
     86                        acc_lookup[0] = acc_lookup[1] = acc_lookup[3] = acc;
     87                else if( acc_lookup[2] == NULL && strcmp( acc->prpl->name, "yahoo" ) == 0 )
     88                        acc_lookup[2] = acc;
     89                else if( acc_lookup[4] == NULL && strcmp( acc->prpl->name, "msn" ) == 0 )
     90                        acc_lookup[4] = acc;
     91                else if( acc_lookup[8] == NULL && strcmp( acc->prpl->name, "jabber" ) == 0 )
     92                        acc_lookup[8] = acc;
     93        }
     94       
    10295        g_snprintf( s, 511, "%s%s%s", global.conf->configdir, my_nick, ".nicks" );
    10396        fp = fopen( s, "r" );
     
    10598        while( fscanf( fp, "%s %d %s", s, &proto, nick ) > 0 )
    10699        {
    107                 struct prpl *prpl;
    108 
    109                 prpl = find_protocol_by_id(proto);
    110 
    111                 if (!prpl)
     100                if( ( acc = acc_lookup[proto] ) == NULL )
    112101                        continue;
    113 
     102               
    114103                http_decode( s );
    115                 // FIXME!!!! nick_set( irc, s, prpl, nick );
     104                nick_set( acc, s, nick );
    116105        }
    117106        fclose( fp );
  • storage_xml.c

    r5b52a48 r7e3592e  
    382382        }
    383383       
    384         g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, irc->nick, ".xml" );
     384        path2 = g_strdup( irc->nick );
     385        nick_lc( path2 );
     386        g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, path2, ".xml" );
     387        g_free( path2 );
    385388       
    386389        if( !overwrite && access( path, F_OK ) != -1 )
Note: See TracChangeset for help on using the changeset viewer.