aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--storage.c2
-rw-r--r--storage_text.c57
-rw-r--r--storage_xml.c5
3 files changed, 28 insertions, 36 deletions
diff --git a/storage.c b/storage.c
index 807d5bb4..06044f80 100644
--- a/storage.c
+++ b/storage.c
@@ -69,7 +69,7 @@ GList *storage_init(const char *primary, char **migrate)
register_storage_backend(&storage_xml);
storage = storage_init_single(primary);
- if (storage == NULL)
+ if (storage == NULL && storage->save == NULL)
return NULL;
ret = g_list_append(ret, storage);
diff --git a/storage_text.c b/storage_text.c
index ac197685..acc9eefe 100644
--- a/storage_text.c
+++ b/storage_text.c
@@ -27,32 +27,6 @@
#include "bitlbee.h"
#include "crypting.h"
-/* DO NOT USE THIS FUNCTION IN NEW CODE. This
- * function is here merely because the save/load code still uses
- * ids rather than names */
-static struct prpl *find_protocol_by_id(int id)
-{
- switch (id) {
- case 0: case 1: case 3: return find_protocol("oscar");
- case 4: return find_protocol("msn");
- case 2: return find_protocol("yahoo");
- case 8: return find_protocol("jabber");
- default: break;
- }
- return NULL;
-}
-
-static int find_protocol_id(const char *name)
-{
- if (!strcmp(name, "oscar")) return 1;
- if (!strcmp(name, "msn")) return 4;
- if (!strcmp(name, "yahoo")) return 2;
- if (!strcmp(name, "jabber")) return 8;
-
- return -1;
-}
-
-
static void text_init (void)
{
if( access( global.conf->configdir, F_OK ) != 0 )
@@ -69,6 +43,7 @@ static storage_status_t text_load ( const char *my_nick, const char* password, i
char nick[MAX_NICK_LENGTH+1];
FILE *fp;
user_t *ru = user_find( irc, ROOT_NICK );
+ account_t *acc, *acc_lookup[9];
if( irc->status & USTATUS_IDENTIFIED )
return( 1 );
@@ -79,7 +54,7 @@ static storage_status_t text_load ( const char *my_nick, const char* password, i
fscanf( fp, "%32[^\n]s", s );
- if (checkpass (password, s) != 0)
+ if( checkpass( password, s ) != 0 )
{
fclose( fp );
return STORAGE_INVALID_PASSWORD;
@@ -99,20 +74,34 @@ static storage_status_t text_load ( const char *my_nick, const char* password, i
}
fclose( fp );
+ /* Build a list with the first listed account of every protocol
+ number. So if the user had nicks defined for a second account on
+ the same IM network, those nicks will be added to the wrong
+ account, and the user should rename those buddies again. But at
+ least from now on things will be saved properly. */
+ memset( acc_lookup, 0, sizeof( acc_lookup ) );
+ for( acc = irc->accounts; acc; acc = acc->next )
+ {
+ if( acc_lookup[0] == NULL && strcmp( acc->prpl->name, "oscar" ) == 0 )
+ acc_lookup[0] = acc_lookup[1] = acc_lookup[3] = acc;
+ else if( acc_lookup[2] == NULL && strcmp( acc->prpl->name, "yahoo" ) == 0 )
+ acc_lookup[2] = acc;
+ else if( acc_lookup[4] == NULL && strcmp( acc->prpl->name, "msn" ) == 0 )
+ acc_lookup[4] = acc;
+ else if( acc_lookup[8] == NULL && strcmp( acc->prpl->name, "jabber" ) == 0 )
+ acc_lookup[8] = acc;
+ }
+
g_snprintf( s, 511, "%s%s%s", global.conf->configdir, my_nick, ".nicks" );
fp = fopen( s, "r" );
if( !fp ) return STORAGE_NO_SUCH_USER;
while( fscanf( fp, "%s %d %s", s, &proto, nick ) > 0 )
{
- struct prpl *prpl;
-
- prpl = find_protocol_by_id(proto);
-
- if (!prpl)
+ if( ( acc = acc_lookup[proto] ) == NULL )
continue;
-
+
http_decode( s );
- // FIXME!!!! nick_set( irc, s, prpl, nick );
+ nick_set( acc, s, nick );
}
fclose( fp );
diff --git a/storage_xml.c b/storage_xml.c
index b01f35d6..2585b475 100644
--- a/storage_xml.c
+++ b/storage_xml.c
@@ -381,7 +381,10 @@ static storage_status_t xml_save( irc_t *irc, int overwrite )
return STORAGE_OTHER_ERROR;
}
- g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, irc->nick, ".xml" );
+ path2 = g_strdup( irc->nick );
+ nick_lc( path2 );
+ g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, path2, ".xml" );
+ g_free( path2 );
if( !overwrite && access( path, F_OK ) != -1 )
return STORAGE_ALREADY_EXISTS;