-/* Copyright (c) 2007, Nokia Corporation
+/*
+ * Copyright (C) 2007 Nokia Corporation, all rights reserved.
* All rights reserved.
*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "modest-secureauth-combo-box.h"
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkcelllayout.h>
-#include <gtk/gtkcellrenderertext.h>
+#include <modest-runtime.h>
+#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <stdlib.h>
static void
modest_secureauth_combo_box_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
+ GValue *value, GParamSpec *pspec)
{
switch (property_id) {
default:
static void
modest_secureauth_combo_box_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
+ const GValue *value, GParamSpec *pspec)
{
switch (property_id) {
default:
*/
void modest_secureauth_combo_box_fill (ModestSecureauthComboBox *combobox)
{
- ModestSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
+ ModestSecureauthComboBoxPrivate *priv;
+ GtkListStore *liststore;
+ ModestProtocolRegistry *protocol_registry;
+ GSList *protocols, *node;
+ GtkTreeIter iter;
+
+ priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
/* Remove any existing rows: */
- GtkListStore *liststore = GTK_LIST_STORE (priv->model);
+ liststore = GTK_LIST_STORE (priv->model);
gtk_list_store_clear (liststore);
-
- GtkTreeIter iter;
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_NONE, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_none"), -1);
-
- /* Select the None item: */
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
-
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_PASSWORD, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_login"), -1);
-
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_AUTH_CRAMMD5, MODEL_COL_NAME, _("mcen_fi_advsetup_smtp_cram_md5"), -1);
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocols = modest_protocol_registry_get_by_tag (protocol_registry, MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS);
+
+ for (node = protocols; node != NULL; node = g_slist_next (node)) {
+ ModestProtocol *protocol;
+ protocol = (ModestProtocol *) node->data;
+
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter,
+ MODEL_COL_ID, (gint)modest_protocol_get_type_id (protocol),
+ MODEL_COL_NAME, modest_protocol_get_display_name (protocol),
+ -1);
+ }
+ g_slist_free (protocols);
}
/**
* Returns the selected secureauth,
- * or MODEST_PROTOCOL_UNKNOWN if no secureauth was selected.
+ * or MODEST_PROTOCOL_REGISTRY_TYPE_INVALID if no secureauth was selected.
*/
-ModestProtocol
+ModestProtocolType
modest_secureauth_combo_box_get_active_secureauth (ModestSecureauthComboBox *combobox)
{
GtkTreeIter active;
- const gboolean found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &active);
+ gboolean found;
+
+ found = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &active);
if (found) {
ModestSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
- ModestProtocol secureauth = MODEST_PROTOCOL_UNKNOWN;
+ ModestProtocolType secureauth = MODEST_PROTOCOLS_AUTH_NONE;
gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &secureauth, -1);
return secureauth;
}
- return MODEST_PROTOCOL_UNKNOWN; /* Failed. */
+ return MODEST_PROTOCOL_REGISTRY_TYPE_INVALID; /* Failed. */
}
/* This allows us to pass more than one piece of data to the signal handler,
typedef struct
{
ModestSecureauthComboBox* self;
- gint id;
+ ModestProtocolType id;
gboolean found;
} ForEachData;
on_model_foreach_select_id(GtkTreeModel *model,
GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
{
- ForEachData *state = (ForEachData*)(user_data);
+ ForEachData *state;
+ ModestProtocolType id = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+
+ state = (ForEachData*)(user_data);
/* Select the item if it has the matching ID: */
- guint id = 0;
gtk_tree_model_get (model, iter, MODEL_COL_ID, &id, -1);
if(id == state->id) {
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (state->self), iter);
/**
* Selects the specified secureauth,
- * or MODEST_PROTOCOL_UNKNOWN if no secureauth was selected.
+ * or MODEST_PROTOCOL_REGISTRY_TYPE_INVALID if no secureauth was selected.
*/
gboolean
-modest_secureauth_combo_box_set_active_secureauth (ModestSecureauthComboBox *combobox, ModestProtocol secureauth)
+modest_secureauth_combo_box_set_active_secureauth (ModestSecureauthComboBox *combobox, ModestProtocolType secureauth)
{
- ModestSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
+ ModestSecureauthComboBoxPrivate *priv;
+ ForEachData *state;
+ gboolean result;
+
+ priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox);
/* Create a state instance so we can send two items of data to the signal handler: */
- ForEachData *state = g_new0 (ForEachData, 1);
+ state = g_new0 (ForEachData, 1);
state->self = combobox;
state->id = secureauth;
state->found = FALSE;
/* Look at each item, and select the one with the correct ID: */
gtk_tree_model_foreach (priv->model, &on_model_foreach_select_id, state);
- const gboolean result = state->found;
+ result = state->found;
/* Free the state instance: */
g_free(state);