{
ModestAccountMgrPrivate *priv;
gchar *key;
- gboolean retval;
+ gboolean retval, default_account_deleted;
GError *err = NULL;
g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE);
return FALSE;
}
+ default_account_deleted = FALSE;
+
if (!server_account) {
- gchar *server_account_name;
+ gchar *server_account_name, *default_account_name;
+
+ /* If this was the default, then remove that setting: */
+ default_account_name = modest_account_mgr_get_default_account (self);
+ if (default_account_name && (strcmp (default_account_name, name) == 0)) {
+ modest_account_mgr_unset_default_account (self);
+ default_account_deleted = TRUE;
+ }
+ g_free (default_account_name);
/* in case we're deleting an account, also delete the dependent store and transport account */
server_account_name = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_STORE_ACCOUNT,
g_error_free (err);
}
- /* If this was the default, then remove that setting: */
- if (!server_account) {
- gchar *default_account_name = modest_account_mgr_get_default_account (self);
- if (default_account_name && (strcmp (default_account_name, name) == 0))
- modest_account_mgr_unset_default_account (self);
- g_free (default_account_name);
-
- /* pick another one as the new default account */
+ if (default_account_deleted) {
+ /* pick another one as the new default account. We do
+ this *after* deleting the keys, because otherwise a
+ call to account_names will retrieve also the
+ deleted account */
modest_account_mgr_set_first_account_as_default (self);
+ }
+ if (server_account) {
/* Notify the observers. We do this *after* deleting
the keys, because otherwise a call to account_names
will retrieve also the deleted account */
g_signal_emit (G_OBJECT(self), signals[ACCOUNT_REMOVED_SIGNAL], 0,
name, server_account);
}
+
return retval;
}
static void
foreach_add_item (gpointer header, gpointer user_data)
{
- /* printf("DEBUG: %s: header subject=%s\n",
- * __FUNCTION__, tny_header_get_subject(TNY_HEADER(header)));
- */
tny_list_prepend (TNY_LIST (user_data),
g_object_ref (G_OBJECT (header)));
}
list = tny_simple_list_new ();
tny_folder_change_get_added_headers (change, list);
- /* printf ("DEBUG: %s: Calling foreach with a list of size=%d\n",
- * __FUNCTION__, tny_list_get_length(list));
- */
-
/* Add them to the folder observer */
tny_list_foreach (list, foreach_add_item,
derived->new_headers);
static void
on_account_removed (ModestAccountMgr *acc_mgr,
const gchar *account,
- gboolean server_account,
+ gboolean is_server_account,
gpointer user_data)
{
ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
- TnyAccount *store_account;
+ TnyAccount *server_account;
/* Clear the account cache */
- store_account = modest_tny_account_store_get_tny_account_by (self,
+ server_account = modest_tny_account_store_get_tny_account_by (self,
MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
account);
- if (store_account) {
- tny_store_account_delete_cache (TNY_STORE_ACCOUNT (store_account));
-
- g_signal_emit (G_OBJECT (self),
- tny_account_store_signals [TNY_ACCOUNT_STORE_ACCOUNT_REMOVED],
- 0, store_account);
+ if (server_account) {
+ if (TNY_IS_STORE_ACCOUNT (server_account)) {
- g_object_unref (store_account);
+ tny_store_account_delete_cache (TNY_STORE_ACCOUNT (server_account));
+
+ g_signal_emit (G_OBJECT (self),
+ tny_account_store_signals [TNY_ACCOUNT_STORE_ACCOUNT_REMOVED],
+ 0, server_account);
+
+/* /\* FIXME: make this more finegrained; changes do not */
+/* * really affect _all_ accounts, and some do not */
+/* * affect tny accounts at all (such as 'last_update') */
+/* *\/ */
+/* recreate_all_accounts (self); */
+
+/* g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0, */
+/* account); */
+ }
+ g_object_unref (server_account);
} else
g_printerr ("modest: cannot find server account for %s", account);
-
- /* FIXME: make this more finegrained; changes do not
- * really affect _all_ accounts, and some do not
- * affect tny accounts at all (such as 'last_update')
- */
- recreate_all_accounts (self);
-
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0,
- account);
}
static void
if (type == TNY_ACCOUNT_TYPE_STORE && account_data->store_account)
id = g_strdup (account_data->store_account->account_name);
- else if (account_data->transport_account)
+ else if (type == TNY_ACCOUNT_TYPE_TRANSPORT && account_data->transport_account)
id = g_strdup (account_data->transport_account->account_name);
modest_account_mgr_free_account_data (priv->account_mgr, account_data);