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);
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;
+}