Changes in storage_xml.c [b75acf6:823de9d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
storage_xml.c
rb75acf6 r823de9d 29 29 #include "arc.h" 30 30 #include "md5.h" 31 #include "chat.h"32 31 33 32 #if GLIB_CHECK_VERSION(2,8,0) … … 39 38 #endif 40 39 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 41 45 typedef enum 42 46 { … … 55 59 char *current_setting; 56 60 account_t *current_account; 57 struct chat *current_chat;58 set_t **current_set_head;59 61 char *given_nick; 60 62 char *given_pass; … … 175 177 176 178 if( ( setting = xml_attr( attr_names, attr_values, "name" ) ) ) 177 {178 if( xd->current_chat != NULL )179 xd->current_set_head = &xd->current_chat->set;180 else if( xd->current_account != NULL )181 xd->current_set_head = &xd->current_account->set;182 else183 xd->current_set_head = &xd->irc->set;184 185 179 xd->current_setting = g_strdup( setting ); 186 }187 180 else 188 181 g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, … … 206 199 } 207 200 } 208 else if( g_strcasecmp( element_name, "chat" ) == 0 )209 {210 char *handle, *channel;211 212 handle = xml_attr( attr_names, attr_values, "handle" );213 channel = xml_attr( attr_names, attr_values, "channel" );214 215 if( xd->current_account && handle && channel )216 {217 xd->current_chat = chat_add( xd->irc, xd->current_account, handle, channel );218 }219 else220 {221 g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,222 "Missing attributes for %s element", element_name );223 }224 }225 201 else 226 202 { … … 243 219 xd->current_account = NULL; 244 220 } 245 else if( g_strcasecmp( element_name, "chat" ) == 0 )246 {247 xd->current_chat = NULL;248 }249 221 } 250 222 … … 253 225 char text[text_len+1]; 254 226 struct xml_parsedata *xd = data; 227 irc_t *irc = xd->irc; 255 228 256 229 strncpy( text, text_orig, text_len ); … … 265 238 else if( g_strcasecmp( g_markup_parse_context_get_element( ctx ), "setting" ) == 0 && xd->current_setting ) 266 239 { 267 set_setstr( xd->current_set_head, xd->current_setting, (char*) text ); 240 set_setstr( xd->current_account ? &xd->current_account->set : &irc->set, 241 xd->current_setting, (char*) text ); 268 242 g_free( xd->current_setting ); 269 243 xd->current_setting = NULL; … … 428 402 429 403 for( set = irc->set; set; set = set->next ) 430 if( set->value )404 if( set->value && set->def ) 431 405 if( !xml_printf( fd, 1, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) 432 406 goto write_error; … … 437 411 char *pass_b64; 438 412 int pass_len; 439 struct chat *c;440 413 441 414 pass_len = arc_encode( acc->pass, strlen( acc->pass ), (unsigned char**) &pass_cr, irc->password, 12 ); … … 456 429 457 430 for( set = acc->set; set; set = set->next ) 458 if( set->value && !( set->flags & ACC_SET_NOSAVE ) )431 if( set->value && set->def && !( set->flags & ACC_SET_NOSAVE ) ) 459 432 if( !xml_printf( fd, 2, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) 460 433 goto write_error; … … 470 443 goto write_error; 471 444 472 for( c = irc->chatrooms; c; c = c->next )473 {474 if( c->acc != acc )475 continue;476 477 if( !xml_printf( fd, 2, "<chat handle=\"%s\" channel=\"%s\" type=\"%s\">\n",478 c->handle, c->channel, "room" ) )479 goto write_error;480 481 for( set = c->set; set; set = set->next )482 if( set->value && !( set->flags & ACC_SET_NOSAVE ) )483 if( !xml_printf( fd, 3, "<setting name=\"%s\">%s</setting>\n",484 set->key, set->value ) )485 goto write_error;486 487 if( !xml_printf( fd, 2, "</chat>\n" ) )488 goto write_error;489 }490 491 445 if( !xml_printf( fd, 1, "</account>\n" ) ) 492 446 goto write_error;
Note: See TracChangeset
for help on using the changeset viewer.