aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-03 22:32:10 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-03 22:32:10 +0100
commitc35143409dfd96e4a8a5de32063e73816b1b8de4 (patch)
tree402b90fbc62386e942b8328a0213a6c961fea55d
parent8203da9d2f792252d2144e5e9063391a3ceebfe9 (diff)
Skip unsupported tags in user configs. (This should make downgrades from
ui-fix for whatever reason less painful.)
-rw-r--r--storage_xml.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/storage_xml.c b/storage_xml.c
index 071fcd11..7321637c 100644
--- a/storage_xml.c
+++ b/storage_xml.c
@@ -59,6 +59,7 @@ struct xml_parsedata
char *given_nick;
char *given_pass;
xml_pass_st pass_st;
+ int unknown_tag;
};
static char *xml_attr( const gchar **attr_names, const gchar **attr_values, const gchar *key )
@@ -86,7 +87,11 @@ static void xml_start_element( GMarkupParseContext *ctx, const gchar *element_na
struct xml_parsedata *xd = data;
irc_t *irc = xd->irc;
- if( g_strcasecmp( element_name, "user" ) == 0 )
+ if( xd->unknown_tag > 0 )
+ {
+ xd->unknown_tag ++;
+ }
+ else if( g_strcasecmp( element_name, "user" ) == 0 )
{
char *nick = xml_attr( attr_names, attr_values, "nick" );
char *pass = xml_attr( attr_names, attr_values, "password" );
@@ -224,8 +229,15 @@ static void xml_start_element( GMarkupParseContext *ctx, const gchar *element_na
}
else
{
+ xd->unknown_tag ++;
+ irc_usermsg( irc, "Warning: Unknown XML tag found in configuration file (%s). "
+ "This may happen when downgrading BitlBee versions. "
+ "This tag will be skipped and the information will be lost "
+ "once you save your settings.", element_name );
+ /*
g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT,
"Unkown element: %s", element_name );
+ */
}
}
@@ -233,7 +245,11 @@ static void xml_end_element( GMarkupParseContext *ctx, const gchar *element_name
{
struct xml_parsedata *xd = data;
- if( g_strcasecmp( element_name, "setting" ) == 0 && xd->current_setting )
+ if( xd->unknown_tag > 0 )
+ {
+ xd->unknown_tag --;
+ }
+ else if( g_strcasecmp( element_name, "setting" ) == 0 && xd->current_setting )
{
g_free( xd->current_setting );
xd->current_setting = NULL;