Changeset 703f0f7 for storage_text.c


Ignore:
Timestamp:
2005-12-14T01:17:25Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
547f937
Parents:
22bf64e (diff), 568aaf7 (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:

Merge my pluginable branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • storage_text.c

    r22bf64e r703f0f7  
    2727#include "bitlbee.h"
    2828#include "crypting.h"
     29
     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 then names */
     33static struct prpl *find_protocol_by_id(int id)
     34{
     35        switch (id) {
     36        case 1: 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
     45static 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
    2955
    3056static void text_init (void)
     
    79105        while( fscanf( fp, "%s %d %s", s, &proto, nick ) > 0 )
    80106        {
     107                struct prpl *prpl;
     108
     109                prpl = find_protocol_by_id(proto);
     110
     111                if (!prpl)
     112                        continue;
     113
    81114                http_decode( s );
    82                 nick_set( irc, s, proto, nick );
     115                nick_set( irc, s, prpl, nick );
    83116        }
    84117        fclose( fp );
     
    145178                s[169] = 0; /* Prevent any overflow (169 ~ 512 / 3) */
    146179                http_encode( s );
    147                 g_snprintf( s + strlen( s ), 510 - strlen( s ), " %d %s", n->proto, n->nick );
     180                g_snprintf( s + strlen( s ), 510 - strlen( s ), " %d %s", find_protocol_id(n->proto->name), n->nick );
    148181                if( fprintf( fp, "%s\n", s ) != strlen( s ) + 1 )
    149182                {
     
    187220        for( a = irc->accounts; a; a = a->next )
    188221        {
    189                 if( a->protocol == PROTO_OSCAR || a->protocol == PROTO_ICQ || a->protocol == PROTO_TOC )
     222                if( !strcmp(a->prpl->name, "oscar") )
    190223                        g_snprintf( s, sizeof( s ), "account add oscar \"%s\" \"%s\" %s", a->user, a->pass, a->server );
    191224                else
    192225                        g_snprintf( s, sizeof( s ), "account add %s \"%s\" \"%s\" \"%s\"",
    193                                     proto_name[a->protocol], a->user, a->pass, a->server ? a->server : "" );
     226                                    a->prpl->name, a->user, a->pass, a->server ? a->server : "" );
    194227               
    195228                line = obfucrypt( s, irc->password );
Note: See TracChangeset for help on using the changeset viewer.