- gchar *key, *account_id;
-
- /* Restore the visible account */
- key = _modest_widget_memory_get_keyname (name, "visible_server_account_id");
-
- if (modest_conf_key_exists (conf, key, NULL)) {
- account_id = modest_conf_get_string (conf, key, NULL);
- modest_folder_view_set_account_id_of_visible_server_account (folder_view,
- (const gchar *) account_id);
- g_free (account_id);
- } else {
- ModestAccountMgr *mgr;
- gchar *default_acc;
-
- /* If there is no visible account id in the
- configuration then pick the default account as
- visible account */
- mgr = modest_runtime_get_account_mgr ();
- default_acc = modest_account_mgr_get_default_account (mgr);
- if (default_acc) {
- ModestAccountData *acc_data;
- const gchar *server_acc_id;
-
- acc_data = modest_account_mgr_get_account_data (mgr, (const gchar*) default_acc);
- server_acc_id = (const gchar *) acc_data->store_account->account_name;
-
- modest_conf_set_string (conf, key, server_acc_id, NULL);
- modest_folder_view_set_account_id_of_visible_server_account (folder_view, server_acc_id);
-
- g_free (default_acc);
+ ModestAccountMgr *mgr;
+ gchar *default_acc;
+
+ /* Always show the default account as visible server account */
+ mgr = modest_runtime_get_account_mgr ();
+ default_acc = modest_account_mgr_get_default_account (mgr);
+ if (default_acc) {
+ ModestAccountSettings *settings;
+ const gchar *server_acc_id;
+
+ settings = modest_account_mgr_load_account_settings (mgr, (const gchar*) default_acc);
+ /* If there was any problem with the settings storage
+ the settings could be NULL */
+ if (settings) {
+ ModestServerAccountSettings *store_settings;
+ store_settings = modest_account_settings_get_store_settings (settings);
+
+ if (store_settings) {
+ server_acc_id = modest_server_account_settings_get_account_name (store_settings);
+ modest_folder_view_set_account_id_of_visible_server_account (folder_view, server_acc_id);
+ g_object_unref (store_settings);
+ }
+ g_object_unref (settings);