Changes in storage_xml.c [15d1469:b75acf6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
storage_xml.c
r15d1469 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) … … 54 55 char *current_setting; 55 56 account_t *current_account; 57 struct chat *current_chat; 58 set_t **current_set_head; 56 59 char *given_nick; 57 60 char *given_pass; … … 172 175 173 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 174 185 xd->current_setting = g_strdup( setting ); 186 } 175 187 else 176 188 g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, … … 194 206 } 195 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 } 196 225 else 197 226 { … … 214 243 xd->current_account = NULL; 215 244 } 245 else if( g_strcasecmp( element_name, "chat" ) == 0 ) 246 { 247 xd->current_chat = NULL; 248 } 216 249 } 217 250 … … 220 253 char text[text_len+1]; 221 254 struct xml_parsedata *xd = data; 222 irc_t *irc = xd->irc;223 255 224 256 strncpy( text, text_orig, text_len ); … … 233 265 else if( g_strcasecmp( g_markup_parse_context_get_element( ctx ), "setting" ) == 0 && xd->current_setting ) 234 266 { 235 set_setstr( xd->current_account ? &xd->current_account->set : &irc->set, 236 xd->current_setting, (char*) text ); 267 set_setstr( xd->current_set_head, xd->current_setting, (char*) text ); 237 268 g_free( xd->current_setting ); 238 269 xd->current_setting = NULL; … … 397 428 398 429 for( set = irc->set; set; set = set->next ) 399 if( set->value && set->def)430 if( set->value ) 400 431 if( !xml_printf( fd, 1, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) 401 432 goto write_error; … … 406 437 char *pass_b64; 407 438 int pass_len; 439 struct chat *c; 408 440 409 441 pass_len = arc_encode( acc->pass, strlen( acc->pass ), (unsigned char**) &pass_cr, irc->password, 12 ); … … 424 456 425 457 for( set = acc->set; set; set = set->next ) 426 if( set->value && set->def &&!( set->flags & ACC_SET_NOSAVE ) )458 if( set->value && !( set->flags & ACC_SET_NOSAVE ) ) 427 459 if( !xml_printf( fd, 2, "<setting name=\"%s\">%s</setting>\n", set->key, set->value ) ) 428 460 goto write_error; … … 438 470 goto write_error; 439 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 440 491 if( !xml_printf( fd, 1, "</account>\n" ) ) 441 492 goto write_error;
Note: See TracChangeset
for help on using the changeset viewer.