From bd1dd4fa59a3cfac003c3fd0c13d75727f36a29c Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Fri, 23 Jan 2009 19:59:03 +0000 Subject: [PATCH] Hide singleton providers from wizard providers list if already set up pmo-trunk-r7278 --- src/hildon2/modest-provider-picker.c | 34 ++++++++++++++++++++++------------ src/modest-account-mgr.c | 25 +++++++++++++++++++++++++ src/modest-account-mgr.h | 2 ++ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/hildon2/modest-provider-picker.c b/src/hildon2/modest-provider-picker.c index 4fb130c..aef688c 100644 --- a/src/hildon2/modest-provider-picker.c +++ b/src/hildon2/modest-provider-picker.c @@ -240,24 +240,34 @@ modest_provider_picker_fill (ModestProviderPicker *self, registry = modest_runtime_get_protocol_registry (); provider_protos = modest_protocol_registry_get_by_tag (registry, MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS); - tmp = provider_protos; - while (tmp) { + for (tmp = provider_protos; tmp != NULL; tmp = g_slist_next (tmp)) { + GtkTreeIter iter; ModestProtocol *proto = MODEST_PROTOCOL (tmp->data); const gchar *name = modest_protocol_get_display_name (proto); /* only add store protocols, no need to duplicate them */ - if (modest_protocol_registry_protocol_type_has_tag (registry, - modest_protocol_get_type_id (proto), - MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS)) { - gtk_list_store_append (liststore, &iter); - gtk_list_store_set (liststore, &iter, - MODEL_COL_ID, modest_protocol_get_name (proto), - MODEL_COL_NAME, name, - MODEL_COL_ID_TYPE, MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL, - -1); + if (!modest_protocol_registry_protocol_type_has_tag (registry, + modest_protocol_get_type_id (proto), + MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS)) + continue; + + if (modest_protocol_registry_protocol_type_has_tag + (registry, + modest_protocol_get_type_id (proto), + MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS)) { + /* Check if there's already an account configured with this account type */ + if (modest_account_mgr_singleton_protocol_exists (modest_runtime_get_account_mgr (), + modest_protocol_get_type_id (proto))) + continue; } - tmp = g_slist_next (tmp); + + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + MODEL_COL_ID, modest_protocol_get_name (proto), + MODEL_COL_NAME, name, + MODEL_COL_ID_TYPE, MODEST_PROVIDER_PICKER_ID_PLUGIN_PROTOCOL, + -1); } g_slist_free (provider_protos); diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index f77e247..913d7d4 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -1650,3 +1650,28 @@ modest_account_mgr_set_display_name (ModestAccountMgr *self, if (notify) g_signal_emit (self, signals[DISPLAY_NAME_CHANGED_SIGNAL], 0, account_name); } + +gboolean +modest_account_mgr_singleton_protocol_exists (ModestAccountMgr *mgr, + ModestProtocolType protocol_type) +{ + GSList *account_names, *node; + gboolean found = FALSE; + + g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR (mgr), FALSE); + account_names = modest_account_mgr_account_names (mgr, TRUE); + + for (node = account_names; node != NULL; node = g_slist_next (node)) { + ModestProtocolType current_protocol; + + current_protocol = modest_account_mgr_get_store_protocol (mgr, (gchar *) node->data); + if (current_protocol == protocol_type) { + found = TRUE; + break; + } + } + + modest_account_mgr_free_account_names (account_names); + + return found; +} diff --git a/src/modest-account-mgr.h b/src/modest-account-mgr.h index f7b21ef..56bfb8f 100644 --- a/src/modest-account-mgr.h +++ b/src/modest-account-mgr.h @@ -358,6 +358,8 @@ void modest_account_mgr_set_display_name (ModestAccountMgr *self, const gchar *account_name, const gchar *display_name); +gboolean modest_account_mgr_singleton_protocol_exists (ModestAccountMgr *mgr, + ModestProtocolType protocol_type); G_END_DECLS -- 1.7.9.5