return FALSE;
}
+ /* in case we're not deleting an account, also delete the dependent store and transport account */
+ if (!server_account) {
+ gchar *server_account_name;
+
+ server_account_name = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_STORE_ACCOUNT,
+ FALSE);
+ if (server_account_name) {
+ if (!modest_account_mgr_remove_account (self, server_account_name, TRUE))
+ g_printerr ("modest: failed to remove store account '%s' (%s)\n",
+ server_account_name, name);
+ g_free (server_account_name);
+ } else
+ g_printerr ("modest: could not find the store account for %s\n", name);
+
+ server_account_name = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_TRANSPORT_ACCOUNT,
+ FALSE);
+ if (server_account_name) {
+ if (!modest_account_mgr_remove_account (self, server_account_name, TRUE))
+ g_printerr ("modest: failed to remove transport account '%s' (%s)\n",
+ server_account_name, name);
+ g_free (server_account_name);
+ } else
+ g_printerr ("modest: could not find the transport account for %s\n", name);
+ }
+
priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
key = _modest_account_mgr_get_account_keyname (name, NULL, server_account);
* @server_account: TRUE if the account to remove is a server account
* @err: a #GError ptr, or NULL to ignore.
*
- * remove an existing account. the account with @name should already exist
+ * remove an existing account. the account with @name should already exist; note
+ * that when deleting an account, also the corresponding server accounts will
+ * be deleted
*
* Returns: TRUE if the creation succeeded, FALSE otherwise,
* @err gives details in case of error
gchar *account_name = NULL;
gchar *from_str = NULL;
GError *err = NULL;
- TnyAccount *account;
+ TnyAccount *account = NULL;
ModestWindowMgr *mgr;
account_name = g_strdup(modest_window_get_active_account (win));
if (!account_name)
account_name = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
+ if (!account_name) {
+ g_printerr ("modest: no account found\n");
+ goto cleanup;
+ }
account = modest_tny_account_store_get_tny_account_by_account (modest_runtime_get_account_store(),
account_name,