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