Changeset 5b52a48 for storage_xml.c


Ignore:
Timestamp:
2006-07-03T21:22:45Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
7e3592e
Parents:
911f2eb
Message:

Implemented per-account nick lists instead of per-protocol nick lists.
nick_t is dead, instead nicks are just saves in a per-account_t GLib
hash table. While doing this, the import_buddies command finally died
and text_save() disappeared, because the old file format can't handle
most of the new features in this branch anyway.

Still have to implement support for the new nick lists in text_load()!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • storage_xml.c

    r911f2eb r5b52a48  
    197197                if( xd->current_account && handle && nick )
    198198                {
    199                         nick_set( irc, handle, xd->current_account->prpl, nick );
     199                        nick_set( xd->current_account, handle, nick );
    200200                }
    201201                else
     
    365365}
    366366
     367static gboolean xml_save_nick( gpointer key, gpointer value, gpointer data );
     368
    367369static storage_status_t xml_save( irc_t *irc, int overwrite )
    368370{
    369371        char path[512], *path2, *pass_buf = NULL;
    370372        set_t *set;
    371         nick_t *nick;
    372373        account_t *acc;
    373374        int fd;
     
    440441                                        goto write_error;
    441442               
    442                 for( nick = irc->nicks; nick; nick = nick->next )
    443                         if( nick->proto == acc->prpl )
    444                                 if( !xml_printf( fd, 2, "<buddy handle=\"%s\" nick=\"%s\" />\n", nick->handle, nick->nick ) )
    445                                         goto write_error;
     443                /* This probably looks pretty strange. g_hash_table_foreach
     444                   is quite a PITA already (but it can't get much better in
     445                   C without using #define, I'm afraid), and since it
     446                   doesn't seem to be possible to abort the foreach on write
     447                   errors, so instead let's use the _find function and
     448                   return TRUE on write errors. Which means, if we found
     449                   something, there was an error. :-) */
     450                if( g_hash_table_find( acc->nicks, xml_save_nick, (gpointer) fd ) )
     451                        goto write_error;
    446452               
    447453                if( !xml_printf( fd, 1, "</account>\n" ) )
     
    476482       
    477483        return STORAGE_OTHER_ERROR;
     484}
     485
     486static gboolean xml_save_nick( gpointer key, gpointer value, gpointer data )
     487{
     488        return !xml_printf( (int) data, 2, "<buddy handle=\"%s\" nick=\"%s\" />\n", key, value );
    478489}
    479490
Note: See TracChangeset for help on using the changeset viewer.