From: Sergio Villar Senin Date: Mon, 9 Jul 2007 15:59:12 +0000 (+0000) Subject: * Removed some comments X-Git-Tag: git_migration_finished~2884 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=884de4214f84ff6be760be7bf1d54782b2a61acd * Removed some comments * Fixed the removal of accounts, now the cache is deleted again * Fixed a bug when retrieving server accouns, that could cause crashes when refreshing the accounts pmo-trunk-r2654 --- diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index 06b8558..98a2c0a 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -535,7 +535,7 @@ modest_account_mgr_remove_account (ModestAccountMgr * self, { 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); @@ -546,8 +546,18 @@ modest_account_mgr_remove_account (ModestAccountMgr * self, 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, @@ -582,22 +592,22 @@ modest_account_mgr_remove_account (ModestAccountMgr * self, 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; } diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index c55834e..be9d055 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -713,9 +713,6 @@ G_DEFINE_TYPE_WITH_CODE (InternalFolderObserver, 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))); } @@ -737,10 +734,6 @@ internal_folder_observer_update (TnyFolderObserver *self, TnyFolderChange *chang 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); diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 8857626..e1b9b97 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -336,35 +336,37 @@ on_vfs_volume_unmounted(GnomeVFSVolumeMonitor *volume_monitor, 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 @@ -1289,7 +1291,7 @@ modest_tny_account_store_get_server_account (ModestTnyAccountStore *self, 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);