Changeset 673a54c for storage_xml.c


Ignore:
Timestamp:
2009-03-12T19:33:28Z (15 years ago)
Author:
Sven Moritz Hallberg <pesco@…>
Branches:
master
Children:
fc34fb5
Parents:
823de9d (diff), 9e768da (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:

pretty blind try at merging in the latest trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • storage_xml.c

    r823de9d r673a54c  
    3838#endif
    3939
    40 #if !GLIB_CHECK_VERSION(2,8,0)
    41 /* GLib < 2.8.0 doesn't have g_access, so just use the system access(). */
    42 #define g_access access
    43 #endif
    44 
    4540typedef enum
    4641{
     
    5954        char *current_setting;
    6055        account_t *current_account;
     56        struct chat *current_chat;
     57        set_t **current_set_head;
    6158        char *given_nick;
    6259        char *given_pass;
     
    177174               
    178175                if( ( setting = xml_attr( attr_names, attr_values, "name" ) ) )
     176                {
     177                        if( xd->current_chat != NULL )
     178                                xd->current_set_head = &xd->current_chat->set;
     179                        else if( xd->current_account != NULL )
     180                                xd->current_set_head = &xd->current_account->set;
     181                        else
     182                                xd->current_set_head = &xd->irc->set;
     183                       
    179184                        xd->current_setting = g_strdup( setting );
     185                }
    180186                else
    181187                        g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
     
    199205                }
    200206        }
     207        else if( g_strcasecmp( element_name, "chat" ) == 0 )
     208        {
     209                char *handle, *channel;
     210               
     211                handle = xml_attr( attr_names, attr_values, "handle" );
     212                channel = xml_attr( attr_names, attr_values, "channel" );
     213               
     214                if( xd->current_account && handle && channel )
     215                {
     216                        xd->current_chat = chat_add( xd->irc, xd->current_account, handle, channel );
     217                }
     218                else
     219                {
     220                        g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
     221                                     "Missing attributes for %s element", element_name );
     222                }
     223        }
    201224        else
    202225        {
     
    219242                xd->current_account = NULL;
    220243        }
     244        else if( g_strcasecmp( element_name, "chat" ) == 0 )
     245        {
     246                xd->current_chat = NULL;
     247        }
    221248}
    222249
     
    225252        char text[text_len+1];
    226253        struct xml_parsedata *xd = data;
    227         irc_t *irc = xd->irc;
    228254       
    229255        strncpy( text, text_orig, text_len );
     
    238264        else if( g_strcasecmp( g_markup_parse_context_get_element( ctx ), "setting" ) == 0 && xd->current_setting )
    239265        {
    240                 set_setstr( xd->current_account ? &xd->current_account->set : &irc->set,
    241                             xd->current_setting, (char*) text );
     266                set_setstr( xd->current_set_head, xd->current_setting, (char*) text );
    242267                g_free( xd->current_setting );
    243268                xd->current_setting = NULL;
     
    402427       
    403428        for( set = irc->set; set; set = set->next )
    404                 if( set->value && set->def )
     429                if( set->value )
    405430                        if( !xml_printf( fd, 1, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) )
    406431                                goto write_error;
     
    411436                char *pass_b64;
    412437                int pass_len;
     438                struct chat *c;
    413439               
    414440                pass_len = arc_encode( acc->pass, strlen( acc->pass ), (unsigned char**) &pass_cr, irc->password, 12 );
     
    429455               
    430456                for( set = acc->set; set; set = set->next )
    431                         if( set->value && set->def && !( set->flags & ACC_SET_NOSAVE ) )
     457                        if( set->value && !( set->flags & ACC_SET_NOSAVE ) )
    432458                                if( !xml_printf( fd, 2, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) )
    433459                                        goto write_error;
     
    443469                        goto write_error;
    444470               
     471                for( c = irc->chatrooms; c; c = c->next )
     472                {
     473                        if( c->acc != acc )
     474                                continue;
     475                       
     476                        if( !xml_printf( fd, 2, "<chat handle=\"%s\" channel=\"%s\" type=\"%s\">\n",
     477                                                c->handle, c->channel, "room" ) )
     478                                goto write_error;
     479                       
     480                        for( set = c->set; set; set = set->next )
     481                                if( set->value && !( set->flags & ACC_SET_NOSAVE ) )
     482                                        if( !xml_printf( fd, 3, "<setting name=\"%s\">%s</setting>\n",
     483                                                                set->key, set->value ) )
     484                                                goto write_error;
     485
     486                        if( !xml_printf( fd, 2, "</chat>\n" ) )
     487                                goto write_error;
     488                }
     489               
    445490                if( !xml_printf( fd, 1, "</account>\n" ) )
    446491                        goto write_error;
Note: See TracChangeset for help on using the changeset viewer.