+ /* Notify the observers. We need to do that here because they
+ could need to use the configuration keys before deleting
+ them, i.e., the account store will delete the cache. We
+ only notify about removals of modest accounts */
+ if (!server_account)
+ g_signal_emit (G_OBJECT(self), signals[ACCOUNT_REMOVED_SIGNAL], 0,
+ name, server_account);
+
+ /* in case we're 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);
+
+ retval = modest_conf_remove_key (priv->modest_conf, key, &err);
+ g_free (key);
+
+ if (err) {
+ g_printerr ("modest: error removing key: %s\n", err->message);
+ g_error_free (err);
+ }