X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-account-mgr-priv.c;h=d0c80f6e3cdc48c64dd489fc5e9910b06666a74c;hb=6bab4bfef92fef73852d6acd51d1ebf381a338e4;hp=a3607e7722f38363a413571cfd4f23efd63f18f3;hpb=33919cc56b8e4848bfd28b5711e8784d8d15f458;p=modest diff --git a/src/modest-account-mgr-priv.c b/src/modest-account-mgr-priv.c index a3607e7..d0c80f6 100644 --- a/src/modest-account-mgr-priv.c +++ b/src/modest-account-mgr-priv.c @@ -32,6 +32,7 @@ #include #include #include +#include gchar* _modest_account_mgr_account_from_key (const gchar *key, gboolean *is_account_key, gboolean *is_server_account) @@ -78,7 +79,13 @@ _modest_account_mgr_account_from_key (const gchar *key, gboolean *is_account_key if (cursor) *cursor = '\0'; - return account; + if (account) { + /* The key is an escaped string, so unescape it to get the actual account name: */ + gchar *unescaped_name = modest_conf_key_unescape (account); + g_free (account); + return unescaped_name; + } else + return NULL; } @@ -87,32 +94,31 @@ _modest_account_mgr_account_from_key (const gchar *key, gboolean *is_account_key gchar * _modest_account_mgr_get_account_keyname (const gchar *account_name, const gchar * name, gboolean server_account) { - gchar *namespace; - gchar *retval; + gchar *retval = NULL; - namespace = server_account ? MODEST_SERVER_ACCOUNT_NAMESPACE : MODEST_ACCOUNT_NAMESPACE; + gchar *namespace = server_account ? MODEST_SERVER_ACCOUNT_NAMESPACE : MODEST_ACCOUNT_NAMESPACE; if (!account_name) return g_strdup (namespace); - if (name) - retval = g_strconcat (namespace, "/", account_name, "/", name, NULL); - else - retval = g_strconcat (namespace, "/", account_name, NULL); + /* Always escape the conf keys, so that it is acceptable to gconf: */ + gchar *escaped_account_name = account_name ? modest_conf_key_escape (account_name) : NULL; + gchar *escaped_name = name ? modest_conf_key_escape (name) : NULL; - /* special case: the key has some weird characters */ - if (!modest_conf_key_is_valid (retval)) { + if (escaped_account_name && escaped_name) + retval = g_strconcat (namespace, "/", escaped_account_name, "/", escaped_name, NULL); + else if (escaped_account_name) + retval = g_strconcat (namespace, "/", escaped_account_name, NULL); - gchar *account_name_esc, *name_esc; + /* Sanity check: */ + if (!modest_conf_key_is_valid (retval)) { + g_warning ("%s: Generated conf key was invalid: %s", __FUNCTION__, retval); g_free (retval); - - account_name_esc = account_name ? modest_conf_key_escape (account_name) : NULL; - name_esc = name ? modest_conf_key_escape (name) : NULL; - - retval = _modest_account_mgr_get_account_keyname (account_name_esc, name_esc, server_account); - - g_free (account_name_esc); - g_free (name_esc); + retval = NULL; } + + g_free (escaped_name); + g_free (escaped_account_name); + return retval; }