X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-account-mgr.c;h=7f0ee82c97ae6ec284bfd09ed7c5ca437010f080;hp=368b9c25e077fcc597bcb2cc4c03affcb5fa0d7f;hb=011fac630357428e59d7eae29888d905255c9580;hpb=cb68944c4c0c8e36453b07926bca8ebee668aa7b diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index 368b9c2..7f0ee82 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -721,6 +721,26 @@ modest_account_mgr_remove_account (ModestAccountMgr * self, return TRUE; } +gboolean +modest_account_mgr_remove_server_account (ModestAccountMgr * self, + const gchar* name) +{ + ModestAccountMgrPrivate *priv; + + g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE); + g_return_val_if_fail (name, FALSE); + + if (!modest_account_mgr_account_exists (self, name, TRUE)) { + g_printerr ("modest: %s: server account '%s' does not exist\n", __FUNCTION__, name); + return FALSE; + } + + priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); + real_remove_account (priv->modest_conf, name, TRUE); + + return TRUE; +} + /* strip the first /n/ character from each element @@ -939,7 +959,7 @@ modest_account_mgr_get_list (ModestAccountMgr *self, const gchar *name, const gchar *key, ModestConfValueType list_type, gboolean server_account) { - ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); + ModestAccountMgrPrivate *priv = NULL; const gchar *keyname; GSList *retval; @@ -1271,6 +1291,11 @@ modest_account_mgr_unset (ModestAccountMgr *self, const gchar *name, gchar* _modest_account_mgr_account_from_key (const gchar *key, gboolean *is_account_key, gboolean *is_server_account) { + const gchar* account_ns; + const gchar* server_account_ns; + gchar *account = NULL; + gchar *unescaped_name = NULL; + /* Initialize input parameters: */ if (is_account_key) *is_account_key = FALSE; @@ -1278,10 +1303,8 @@ _modest_account_mgr_account_from_key (const gchar *key, gboolean *is_account_key if (is_server_account) *is_server_account = FALSE; - const gchar* account_ns = modest_defs_namespace (MODEST_ACCOUNT_SUBNAMESPACE "/"); - const gchar* server_account_ns = modest_defs_namespace (MODEST_SERVER_ACCOUNT_SUBNAMESPACE "/"); - gchar *cursor; - gchar *account = NULL; + account_ns = modest_defs_namespace (MODEST_ACCOUNT_SUBNAMESPACE "/"); + server_account_ns = modest_defs_namespace (MODEST_SERVER_ACCOUNT_SUBNAMESPACE "/"); /* determine whether it's an account or a server account, * based on the prefix */ @@ -1289,37 +1312,40 @@ _modest_account_mgr_account_from_key (const gchar *key, gboolean *is_account_key if (is_server_account) *is_server_account = FALSE; - + account = g_strdup (key + strlen (account_ns)); } else if (g_str_has_prefix (key, server_account_ns)) { if (is_server_account) *is_server_account = TRUE; - - account = g_strdup (key + strlen (server_account_ns)); + + account = g_strdup (key + strlen (server_account_ns)); } else return NULL; - /* if there are any slashes left in the key, it's not - * the toplevel entry for an account - */ - cursor = strstr(account, "/"); - - if (is_account_key && cursor) - *is_account_key = TRUE; + if (account) { + gchar *cursor; - /* put a NULL where the first slash was */ - if (cursor) - *cursor = '\0'; + /* if there are any slashes left in the key, it's not + * the toplevel entry for an account + */ + cursor = strstr(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); + if (cursor) { + if (is_account_key) + *is_account_key = TRUE; + + /* put a NULL where the first slash was */ + *cursor = '\0'; + } + + /* The key is an escaped string, so unescape it to get the actual account name */ + unescaped_name = modest_conf_key_unescape (account); g_free (account); - return unescaped_name; - } else - return NULL; + } + + return unescaped_name; }