Added is_supported method to account protocol.
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 18 Feb 2009 15:43:29 +0000 (15:43 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 18 Feb 2009 15:43:29 +0000 (15:43 +0000)
pmo-trunk-r7559

src/hildon2/modest-provider-picker.c
src/maemo/easysetup/modest-easysetup-provider-combo-box.c
src/modest-account-protocol.c
src/modest-account-protocol.h
src/widgets/modest-wizard-dialog.c

index aef688c..e949d81 100644 (file)
@@ -35,6 +35,7 @@
 #include <modest-text-utils.h>
 #include "modest-protocol-registry.h"
 #include "modest-runtime.h"
+#include <modest-account-protocol.h>
 
 #include <stdlib.h>
 #include <string.h> /* For memcpy() */
@@ -262,6 +263,11 @@ modest_provider_picker_fill (ModestProviderPicker *self,
                                continue;
                }
 
+               if (MODEST_ACCOUNT_PROTOCOL (proto) && 
+                   !modest_account_protocol_is_supported (MODEST_ACCOUNT_PROTOCOL (proto))) {
+                       continue;
+               }
+
                gtk_list_store_append (liststore, &iter);
                gtk_list_store_set (liststore, &iter,
                                    MODEL_COL_ID, modest_protocol_get_name (proto),
index 1147a1d..c39b80c 100644 (file)
@@ -35,6 +35,7 @@
 #include <modest-text-utils.h>
 #include "modest-protocol-registry.h"
 #include "modest-runtime.h"
+#include <modest-account-protocol.h>
 
 #include <stdlib.h>
 #include <string.h> /* For memcpy() */
@@ -241,18 +242,25 @@ easysetup_provider_combo_box_fill (EasysetupProviderComboBox *combobox,
        while (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, EASYSETUP_PROVIDER_COMBO_BOX_ID_PLUGIN_PROTOCOL,
-                                           -1);
+                       gboolean supported;
+
+                       supported = modest_account_protocol_is_supported (MODEST_ACCOUNT_PROTOCOL (proto));
+
+                       if (supported) {
+                               const gchar *name = modest_protocol_get_display_name (proto);
+
+                               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, EASYSETUP_PROVIDER_COMBO_BOX_ID_PLUGIN_PROTOCOL,
+                                                   -1);
+                       }
                }
                tmp = g_slist_next (tmp);
        }
index 01781e6..0db2e41 100644 (file)
@@ -85,6 +85,8 @@ static void modest_account_protocol_save_wizard_settings_default (ModestAccountP
 static ModestWizardDialogResponseOverrideFunc 
 modest_account_protocol_get_wizard_response_override_default (ModestAccountProtocol *self);
 
+static gboolean modest_account_protocol_is_supported_default (ModestAccountProtocol *self);
+
 /* globals */
 static GObjectClass *parent_class = NULL;
 
@@ -167,6 +169,8 @@ modest_account_protocol_class_init (ModestAccountProtocolClass *klass)
                modest_account_protocol_create_account_default;
        account_class->get_wizard_response_override =
                modest_account_protocol_get_wizard_response_override_default;
+       account_class->is_supported =
+               modest_account_protocol_is_supported_default;
 }
 
 static void
@@ -575,3 +579,14 @@ modest_account_protocol_get_wizard_response_override (ModestAccountProtocol *sel
        return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_wizard_response_override (self);   
 }
 
+static gboolean
+modest_account_protocol_is_supported_default (ModestAccountProtocol *self)
+{
+       return TRUE;
+}
+
+gboolean
+modest_account_protocol_is_supported (ModestAccountProtocol *self)
+{
+       return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->is_supported (self);
+}
index cc056f0..ef7ac27 100644 (file)
@@ -68,6 +68,7 @@ struct _ModestAccountProtocolClass {
        ModestWizardDialogResponseOverrideFunc (*get_wizard_response_override) (ModestAccountProtocol *self);
        void (*save_settings) (ModestAccountProtocol *self, ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings);
        void (*save_wizard_settings) (ModestAccountProtocol *self, GList *wizard_pages, ModestAccountSettings *settings);
+       gboolean (*is_supported) (ModestAccountProtocol *self);
 };
 
 /**
@@ -285,6 +286,15 @@ void modest_account_protocol_save_wizard_settings (ModestAccountProtocol *self,
  */
 ModestWizardDialogResponseOverrideFunc modest_account_protocol_get_wizard_response_override (ModestAccountProtocol *self);
 
+/**
+ * modest_account_protocol_is_supported:
+ * @self: a #ModestAccountProtocol
+ *
+ * Determines if the account protocol is supported on this device.
+ *
+ * Returns: %TRUE if the protocol is supported, %FALSE otherwise
+ */
+gboolean modest_account_protocol_is_supported (ModestAccountProtocol *self);
 
 G_END_DECLS
 
index 7b9bf11..4b5c84e 100644 (file)
@@ -505,7 +505,7 @@ create_title (ModestWizardDialog *wizard_dialog)
                 priv->wizard_name, current + 1, pages, steps);
         */
 
-        str = g_strdup_printf (_HL("%s: %s"), 
+        str = g_strdup_printf ((steps&&*steps)?_HL("%s: %s"):_HL("%s"), 
                 priv->wizard_name, steps);
     /* } */