# (using the postinst thingie in debian/
NEWS_FILE=NEWS
newsdir=$(datadir)/modest/data
-news_DATA = $(NEWS_FILE)
\ No newline at end of file
+news_DATA = $(NEWS_FILE)
with_platform=$detected_platform
fi
+if test "$with_platform" = "maemo"; then
+ MODEST_PLUGIN_DEFINES=" -DMODEST_PLATFORM_MAEMO"
+elif test "$with_platform" = "gnome"; then
+ MODEST_PLUGIN_DEFINES=" -DMODEST_PLATFORM_GNOME"
+fi
dnl Whether to use maemo-launcher or not
AC_ARG_ENABLE([maemo-launcher],
#
# check the version of the widgets on maemo
#
+hildonpkgs=
if test "x$with_platform" == "xmaemo"; then
PKG_CHECK_MODULES(MODEST_HILDON_WIDGETS, hildon-1 >= 0.9.9 hildon-fm-2, have_hildon1=true,have_hildon1=false)
+hildonpkgs=hildon-1
+
if test "x$have_hildon1" == "xfalse"; then
PKG_CHECK_MODULES(MODEST_HILDON_WIDGETS, hildon-libs >= 0.12.0 hildon-fm, have_hildon0=true,have_hildon0=false)
+ hildonpkgs=hildon-libs
if test "x$have_hildon0" == "xtrue"; then
AC_DEFINE_UNQUOTED(MODEST_HAVE_HILDON0_WIDGETS, 1, ["Whether hildon0 widgets are used."])
+ MODEST_PLUGIN_DEFINES+=" -DMODEST_HAVE_HILDON0_WIDGETS"
else
AC_MSG_ERROR([hildon widgets and/or hildon-fm not found])
fi
fi
fi
-
+AC_SUBST(hildonpkgs)
+AC_SUBST(MODEST_PLUGIN_DEFINES)
#
# check the version of the addressbook on maemo
AM_CONDITIONAL(MODEST_USE_DUMMY_ADDRESS_BOOK,test "x$have_abook" != "xtrue")
+AM_GLIB_GNU_GETTEXT
+IT_PROG_INTLTOOL([0.35.0])
+
# gettext support
GETTEXT_PACKAGE=modest
AC_SUBST(GETTEXT_PACKAGE)
dnl ## gtk-doc
GTK_DOC_CHECK([1.0])
-dnl Intltool utility programs
-#AC_PROG_INTLTOOL([0.33.0],[no-xml])
-
AC_OUTPUT([
po/Makefile.in
Makefile
man/Makefile
src/Makefile
+src/modest-plugin-1.0.pc
src/dbus_api/Makefile
src/gnome/Makefile
src/maemo/Makefile
Depends: ${shlibs:Depends}, ${misc:Depends},${launcher:Depends},maemo-providers-data
Description: an e-mail client for platforms with modest resources
+Package: modest-plugin-dev
+Architecture: any
+Depends: modest
+Description: Plugin development packages for modest mail client.
+ Plugin development packages for modest, the e-mail client for osso.
+
Package: modest-dbg
Section: devel
Architecture: all
Description: an e-mail client for platforms with modest resources
e-mail client for osso
+Package: modest-plugin-dev
+Architecture: any
+Depends: modest
+Description: Plugin development packages for modest mail client.
+ Plugin development packages for modest, the e-mail client for osso.
+
Package: modest-dbg
Section: devel
Architecture: any
Description: an e-mail client for platforms with modest resources
e-mail client for osso
+Package: modest-plugin-dev
+Architecture: any
+Depends: modest
+Description: Plugin development packages for modest mail client.
+ Plugin development packages for modest, the e-mail client for osso.
+
Package: modest-dbg
Section: devel
Architecture: any
--- /dev/null
+usr/lib/pkgconfig/modest-plugin-1.0.pc
+usr/include/modest-plugin-1.0/
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libmodest-dbus-client-1.0.pc
-
+DISTCLEANFILES = $(pkgconfig_DATA)
# Makefile.am
# Time-stamp: <2008-01-06 10:18:49 (djcb)>
-SUBDIRS=$(MODEST_PLATFORM) widgets $(dbus_api)
+SUBDIRS= $(MODEST_PLATFORM) widgets $(dbus_api)
DIST_SUBDIRS = widgets gnome maemo dbus_api
INCLUDES=\
- $(MODEST_GSTUFF_CFLAGS)\
- $(MODEST_PLATFORM_CFLAGS) \
- $(MODEST_HILDON_WIDGETS_CFLAGS) \
- $(MODEST_OGS_CFLAGS) \
- $(MODEST_HILDON_HELP_CFLAGS) \
- $(MODEST_LIBCONIC_CFLAGS) \
- $(MODEST_HILDON_NOTIFY_CFLAGS) \
- $(MODEST_MOZEMBED_CFLAGS) \
- -I$(MODEST_PLATFORM) \
- -DPREFIX=\"@prefix@\" \
- -DMAEMO_CHANGES \
- -DMODEST_LOCALEDIR=\"$(MODEST_LOCALEDIR)\" \
- -DMODEST_PLATFORM=\"$(MODEST_PLATFORM)\" \
- -DPIXMAP_PREFIX=\"${datadir}/pixmaps/modest/\" \
- -DMODEST_UIDIR=\"$(datadir)/modest/ui/\"
+ $(MODEST_GSTUFF_CFLAGS) \
+ $(MODEST_PLATFORM_CFLAGS) \
+ $(MODEST_HILDON_WIDGETS_CFLAGS) \
+ $(MODEST_OGS_CFLAGS) \
+ $(MODEST_HILDON_HELP_CFLAGS) \
+ $(MODEST_LIBCONIC_CFLAGS) \
+ $(MODEST_HILDON_NOTIFY_CFLAGS) \
+ $(MODEST_MOZEMBED_CFLAGS) \
+ -fPIC \
+ -I$(MODEST_PLATFORM) \
+ -DPREFIX=\"@prefix@\" \
+ -DMAEMO_CHANGES \
+ -DMODEST_LOCALEDIR=\"$(MODEST_LOCALEDIR)\" \
+ -DMODEST_PLATFORM=\"$(MODEST_PLATFORM)\" \
+ -DPIXMAP_PREFIX=\"${datadir}/pixmaps/modest/\" \
+ -DMODEST_UIDIR=\"$(datadir)/modest/ui/\" \
+ -DMODEST_MAILPLUGINDIR=\"$(libdir)/modest/mail-plugins\"
BUILT_SOURCES = modest-marshal.c modest-marshal.h
modest-marshal.h: modest-marshal.list
glib-genmarshal --header --prefix=modest_marshal < modest-marshal.list > modest-marshal.h
+noinst_LTLIBRARIES = libmodest.la
+
bin_PROGRAMS=\
modest
+to_remove=\
+ modest-testplugin-protocol.c \
+ modest-testplugin-protocol.h
+
#
# NOTE: $(addressbook) will be modest-addressbook-dummy.c
# if no real addressbook has been defined (configure.ac)
#
-modest_SOURCES=\
- modest-account-mgr-helpers.c \
+
+modest_public_headers = \
+ modest-account-mgr.h \
modest-account-mgr-helpers.h \
+ modest-account-protocol.h \
+ modest-account-settings.h \
+ modest-cache-mgr.h \
+ modest-conf.h \
+ modest-pair.h \
+ modest-platform.h \
+ modest-plugin.h \
+ modest-protocol.h \
+ modest-protocol-registry.h \
+ modest-server-account-settings.h \
+ modest-tny-account-store.h \
+ modest-tny-local-folders-account.h \
+ modest-utils.h
+
+libmodest_la_SOURCES=\
+ $(modest_public_headers) \
+ modest-account-mgr-helpers.c \
modest-account-mgr-priv.h \
modest-account-mgr.c \
- modest-account-mgr.h \
+ modest-account-protocol.c \
modest-account-settings.c \
- modest-account-settings.h \
modest-address-book.h \
modest-cache-mgr.c \
- modest-cache-mgr.h \
modest-conf.c \
- modest-conf.h \
modest-count-stream.c \
modest-count-stream.h \
- modest-defs.h \
modest-debug.h \
+ modest-defs.h \
modest-dimming-rule.c \
modest-dimming-rule.h \
modest-dimming-rules-group.c \
modest-dimming-rules-group.h \
- modest-email-clipboard.c \
modest-email-clipboard.h \
+ modest-email-clipboard.c \
modest-error.h \
modest-formatter.c \
modest-formatter.h \
modest-main.c \
modest-marshal.c \
modest-marshal.h \
+ modest-module.c \
+ modest-module.h \
modest-pair.c \
- modest-pair.h \
- modest-platform.h \
- modest-platform.h \
+ modest-plugin.c \
+ modest-plugin-factory.c \
+ modest-plugin-factory.h \
modest-progress-object.c \
modest-progress-object.h \
- modest-protocol-info.c \
- modest-protocol-info.h \
+ modest-protocol.c \
+ modest-protocol-registry.c \
modest-runtime-priv.h \
modest-runtime.c \
modest-runtime.h \
modest-singletons.c \
modest-singletons.h \
modest-server-account-settings.c \
- modest-server-account-settings.h \
modest-text-utils.c \
modest-text-utils.h \
modest-tny-account-store.c \
- modest-tny-account-store.h \
modest-tny-account.c \
modest-tny-account.h \
modest-tny-folder.c \
modest-tny-folder.h \
modest-tny-local-folders-account.c \
- modest-tny-local-folders-account.h \
modest-tny-mime-part.c \
modest-tny-mime-part.h \
modest-tny-msg.c \
modest-ui-dimming-rules.c \
modest-ui-dimming-rules.h \
modest-utils.c \
- modest-utils.h \
modest-widget-memory-priv.h \
modest-widget-memory.c \
modest-widget-memory.h \
modest-default-connection-policy.h
if MODEST_USE_DUMMY_ADDRESS_BOOK
-modest_SOURCES += modest-address-book-dummy.c
+libmodest_la_SOURCES += modest-address-book-dummy.c
endif
-modest_CFLAGS = $(MAEMO_LAUNCHER_CFLAGS)
-modest_LDFLAGS = -Wl,--version-script=export.map
+libmodest_la_CFLAGS = $(MAEMO_LAUNCHER_CFLAGS)
+libmodest_la_LIBADD = \
+ $(MAEMO_LAUNCHER_LIBS) \
+ $(MODEST_GSTUFF_LIBS) \
+ $(MODEST_MOZEMBED_LIBS) \
+ $(MODEST_PLATFORM_LIBS) \
+ $(MODEST_HILDON_WIDGETS_LIBS) \
+ $(MODEST_HILDON_HELP_LIBS) \
+ $(MODEST_HILDON_NOTIFY_LIBS) \
+ $(MODEST_OGS_LIBS) \
+ ${easysetupmaybe} \
+ widgets/libmodest-widgets.la \
+ $(MODEST_PLATFORM)/libmodest-ui.la
+libmodest_la_LDFLAGS = -rdynamic -export-dynamic -no-undefined -Wl,--version-script=export.map
+
+if MODEST_HAVE_DBUS_API
+libmodest_la_LIBADD += dbus_api/libmodest-dbus-api.la
+endif
+
+
+modest_includedir = $(includedir)/modest-plugin-1.0/
+modest_include_HEADERS = $(modest_public_headers)
+
+modest_SOURCES = modest-main.c
-modest_UNWANTED = -export-dynamic -Wl,--export-dynamic
-modest_LDADD = \
- $(filter-out $(modest_UNWANTED), \
+modest_DEPENDENCIES = \
+ libmodest.la
+
+modest_CFLAGS = $(MAEMO_LAUNCHER_CFLAGS)
+modest_LDADD = \
$(MAEMO_LAUNCHER_LIBS) \
$(MODEST_GSTUFF_LIBS) \
$(MODEST_MOZEMBED_LIBS) \
$(MODEST_HILDON_NOTIFY_LIBS) \
$(MODEST_OGS_LIBS) \
${easysetupmaybe} \
- $(MODEST_PLATFORM)/libmodest-ui.la \
- widgets/libmodest-widgets.la)
+ libmodest.la
+modest_LDFLAGS = -rdynamic -export-dynamic -no-undefined -Wl,--version-script=export.map
+
+# modest_UNWANTED = -export-dynamic -Wl,--export-dynamic
-if MODEST_HAVE_DBUS_API
-modest_LDADD += dbus_api/libmodest-dbus-api.la
-endif
EXTRA_DIST=modest-marshal.list
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = modest-plugin-1.0.pc
+
+DISTCLEANFILES = $(pkgconfig_DATA)
\ No newline at end of file
_end;
_IO_stdin_used;
__data_start;
+ modest_account_settings_*;
+ modest_account_mgr_*;
+ modest_account_protocol_*;
+ modest_easysetup_wizard_*;
+ modest_pair_*;
+ modest_platform_*;
+ modest_plugin_*;
+ modest_protocol_*;
+ modest_server_account_settings_*;
+ modest_validating_entry_*;
local: *;
};
static void
on_edit_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
{
- ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE (self);
+ ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE (self);
gchar* account_name = modest_account_view_get_selected_account (priv->account_view);
if (!account_name)
return;
+ /* Check whether any connections are active, and cancel them if
+ * the user wishes.
+ */
if (check_for_active_account (self, account_name)) {
- modest_tny_account_store_show_account_settings_dialog (modest_runtime_get_account_store (), account_name);
-
+ ModestAccountProtocol *proto;
+ ModestProtocolType proto_type;
+
+ /* Get proto */
+ proto_type = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
+ account_name);
+ proto = (ModestAccountProtocol *)
+ modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+ proto_type);
+
+ /* Create and show the dialog */
+ if (proto && MODEST_IS_ACCOUNT_PROTOCOL (proto)) {
+ ModestAccountSettingsDialog *dialog =
+ modest_account_protocol_get_account_settings_dialog (proto, account_name);
+ gtk_widget_show (GTK_WIDGET (dialog));
+ }
}
-
g_free (account_name);
}
libmodest_ui_la_SOURCES= \
modest-account-view-window.c \
- modest-account-settings-dialog.c \
+ modest-default-account-settings-dialog.c \
modest-icon-names.h \
modest-maemo-global-settings-dialog.c \
modest-maemo-global-settings-dialog.h \
+ modest-maemo-security-options-view.c \
modest-main-window.c \
modest-main-window-ui.h \
modest-hildon-includes.h \
#include <gtk/gtkcellrenderertext.h>
#include <glib/gi18n.h>
#include <modest-text-utils.h>
+#include "modest-protocol-registry.h"
+#include "modest-runtime.h"
#include <stdlib.h>
#include <string.h> /* For memcpy() */
}
enum MODEL_COLS {
- MODEL_COL_NAME = 0,
- MODEL_COL_ID = 1 /* a string, not an int. */
+ MODEL_COL_ID, /* a string, not an int. */
+ MODEL_COL_NAME,
+ MODEL_COL_ID_TYPE
};
* with a string for the name, and a string for the ID (e.g. "vodafone.it"), and the mcc
* This must match our MODEL_COLS enum constants.
*/
- priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
+ priv->model = GTK_TREE_MODEL (gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT));
/* Setup the combo box: */
GtkComboBox *combobox = GTK_COMBO_BOX (self);
}
void
-easysetup_provider_combo_box_fill (EasysetupProviderComboBox *combobox, ModestPresets *presets,
+easysetup_provider_combo_box_fill (EasysetupProviderComboBox *combobox,
+ ModestPresets *presets,
gint mcc)
{
+ GtkTreeIter other_iter;
+ EasysetupProviderComboBoxPrivate *priv;
+ GtkListStore *liststore;
+ GSList *provider_ids_used_already = NULL, *provider_protos, *tmp;
+ gchar ** provider_ids = NULL;
+ gchar ** provider_names;
+ gchar ** iter_provider_names;
+ gchar ** iter_provider_ids;
+ ModestProtocolRegistry *registry;
+
g_return_if_fail (EASYSETUP_IS_PROVIDER_COMBO_BOX(combobox));
-
- EasysetupProviderComboBoxPrivate *priv = PROVIDER_COMBO_BOX_GET_PRIVATE (combobox);
-
- /* Remove any existing rows: */
- GtkListStore *liststore = GTK_LIST_STORE (priv->model);
+
+ priv = PROVIDER_COMBO_BOX_GET_PRIVATE (combobox);
+ liststore = GTK_LIST_STORE (priv->model);
gtk_list_store_clear (liststore);
-
- GSList *provider_ids_used_already = NULL;
-
- /* Add the appropriate rows for this country, from the presets file: */
- gchar ** provider_ids = NULL;
- gchar ** provider_names = modest_presets_get_providers (presets, mcc,
- TRUE /* include_globals */, &provider_ids);
- gchar ** iter_provider_names = provider_names;
- gchar ** iter_provider_ids = provider_ids;
+ provider_names = modest_presets_get_providers (presets, mcc, TRUE, &provider_ids);
+
+ iter_provider_names = provider_names;
+ iter_provider_ids = provider_ids;
+
while(iter_provider_names && *iter_provider_names && iter_provider_ids && *iter_provider_ids) {
const gchar* provider_name = *iter_provider_names;
const gchar* provider_id = *iter_provider_ids;
gtk_list_store_set(liststore, &iter,
MODEL_COL_ID, provider_id,
- MODEL_COL_NAME, provider_name, -1);
+ MODEL_COL_NAME, provider_name,
+ MODEL_COL_ID_TYPE, EASYSETUP_PROVIDER_COMBO_BOX_ID_PROVIDER,
+ -1);
provider_ids_used_already = g_slist_prepend (
provider_ids_used_already, (gpointer)g_strdup (provider_id));
g_strfreev (provider_names);
g_strfreev (provider_ids);
+ /* Add the provider protocols */
+ 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) {
+ 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);
+ }
+ tmp = g_slist_next (tmp);
+ }
+ g_slist_free (provider_protos);
/* Add the "Other" item: */
/* Note that ID 0 means "Other" for us: */
- /* TODO: We need a Logical ID for this text. */
- GtkTreeIter iter;
- gtk_list_store_prepend (liststore, &iter);
- gtk_list_store_set (liststore, &iter,
+ gtk_list_store_prepend (liststore, &other_iter);
+ gtk_list_store_set (liststore, &other_iter,
MODEL_COL_ID, 0,
MODEL_COL_NAME, _("mcen_va_serviceprovider_other"),
+ MODEL_COL_ID_TYPE, EASYSETUP_PROVIDER_COMBO_BOX_ID_OTHER,
-1);
-
+
/* Select the "Other" item: */
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &other_iter);
g_slist_foreach (provider_ids_used_already, (GFunc)g_free, NULL);
g_slist_free (provider_ids_used_already);
if (gtk_tree_model_get_iter_first (model, &others_iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &others_iter);
}
+
+EasysetupProviderComboBoxIdType
+easysetup_provider_combo_box_get_active_id_type (EasysetupProviderComboBox *combobox)
+{
+ GtkTreeIter active;
+
+ g_return_val_if_fail (EASYSETUP_IS_PROVIDER_COMBO_BOX (combobox),
+ EASYSETUP_PROVIDER_COMBO_BOX_ID_OTHER);
+
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combobox), &active)) {
+ EasysetupProviderComboBoxPrivate *priv = PROVIDER_COMBO_BOX_GET_PRIVATE (combobox);
+ EasysetupProviderComboBoxIdType id_type;
+
+ gtk_tree_model_get (priv->model, &active, MODEL_COL_ID_TYPE, &id_type, -1);
+ return id_type;
+ } else {
+ /* Fallback to other */
+ return EASYSETUP_PROVIDER_COMBO_BOX_ID_OTHER;
+ }
+}
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
EASYSETUP_TYPE_PROVIDER_COMBO_BOX, EasysetupProviderComboBoxClass))
+/** The thype of the ID
+ *
+ * this means the value of returned by get_active_provider_id will be
+ * different depending on the value returned by get_active_id_type
+ *
+ * If the selected option is a provider then the ID will be the provider ID
+ * If the selected option is "Other..." the the ID will be 0
+ * If the selected option is a provider protocol () the the ID will be protocol name
+ **/
+typedef enum {
+ EASYSETUP_PROVIDER_COMBO_BOX_ID_PROVIDER,
+ EASYSETUP_PROVIDER_COMBO_BOX_ID_OTHER,
+ EASYSETUP_PROVIDER_COMBO_BOX_ID_PLUGIN_PROTOCOL
+} EasysetupProviderComboBoxIdType;
+
typedef struct {
GtkComboBox parent;
} EasysetupProviderComboBox;
gchar* easysetup_provider_combo_box_get_active_provider_id (EasysetupProviderComboBox *combobox);
+EasysetupProviderComboBoxIdType easysetup_provider_combo_box_get_active_id_type (EasysetupProviderComboBox *combobox);
+
G_END_DECLS
#endif /* _EASYSETUP_PROVIDER_COMBO_BOX */
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <modest-runtime.h>
#include "modest-easysetup-servertype-combo-box.h"
#include <gtk/gtkliststore.h>
#include <gtk/gtkcelllayout.h>
};
static void
-easysetup_servertype_combo_box_fill (EasysetupServertypeComboBox *combobox);
-
-static void
easysetup_servertype_combo_box_init (EasysetupServertypeComboBox *self)
{
EasysetupServertypeComboBoxPrivate *priv = SERVERTYPE_COMBO_BOX_GET_PRIVATE (self);
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combobox), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
"text", MODEL_COL_NAME, NULL);
-
- easysetup_servertype_combo_box_fill (self);
-}
-
-EasysetupServertypeComboBox*
-easysetup_servertype_combo_box_new (void)
-{
- return g_object_new (EASYSETUP_TYPE_SERVERTYPE_COMBO_BOX, NULL);
}
-void easysetup_servertype_combo_box_fill (EasysetupServertypeComboBox *combobox)
+static void
+easysetup_servertype_combo_box_fill (EasysetupServertypeComboBox *combobox,
+ gboolean filter_providers)
{
- EasysetupServertypeComboBoxPrivate *priv = SERVERTYPE_COMBO_BOX_GET_PRIVATE (combobox);
+ EasysetupServertypeComboBoxPrivate *priv;
+ GtkListStore *liststore;
+ ModestProtocolRegistry *protocol_registry;
+ GSList *remote_protocols, *node;
+ GtkTreeIter iter;
/* Remove any existing rows: */
- GtkListStore *liststore = GTK_LIST_STORE (priv->model);
+ priv = SERVERTYPE_COMBO_BOX_GET_PRIVATE (combobox);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ remote_protocols = modest_protocol_registry_get_by_tag (protocol_registry, MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS);
+
+ liststore = GTK_LIST_STORE (priv->model);
gtk_list_store_clear (liststore);
+
+ for (node = remote_protocols; node != NULL; node = g_slist_next (node)) {
+ ModestProtocol* protocol;
+ gboolean add = TRUE;
+
+ protocol = (ModestProtocol *) node->data;
+
+ /* Do not include the protocols that would be listed
+ in the providers combo */
+ if (filter_providers)
+ if (modest_protocol_registry_protocol_type_is_provider (protocol_registry,
+ modest_protocol_get_type_id (protocol))) {
+ add = FALSE;
+ }
+
+ if (add) {
+ gtk_list_store_append (liststore, &iter);
+ gtk_list_store_set (liststore, &iter,
+ MODEL_COL_ID,
+ modest_protocol_get_type_id (protocol),
+ MODEL_COL_NAME,
+ modest_protocol_get_display_name (protocol),
+ -1);
+ }
+ }
- GtkTreeIter iter;
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_STORE_POP, MODEL_COL_NAME, _("mail_fi_emailtype_pop3"), -1);
-
- /* Select the POP 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_STORE_IMAP, MODEL_COL_NAME, _("mail_fi_emailtype_imap"), -1);
+ g_slist_free (remote_protocols);
+}
+
+EasysetupServertypeComboBox*
+easysetup_servertype_combo_box_new (gboolean filter_providers)
+{
+ EasysetupServertypeComboBox *combo;
+
+ combo = g_object_new (EASYSETUP_TYPE_SERVERTYPE_COMBO_BOX, NULL);
+
+ /* Fill the combo */
+ easysetup_servertype_combo_box_fill (combo, filter_providers);
+
+ return combo;
}
/**
* Returns the selected servertype,
- * or MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN if no servertype was selected.
+ * or MODEST_PROTOCOL_REGISTRY_TYPE_INVALID if no servertype was selected.
*/
-ModestTransportStoreProtocol
+ModestProtocolType
easysetup_servertype_combo_box_get_active_servertype (EasysetupServertypeComboBox *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) {
- EasysetupServertypeComboBoxPrivate *priv = SERVERTYPE_COMBO_BOX_GET_PRIVATE (combobox);
+ EasysetupServertypeComboBoxPrivate *priv;
+ ModestProtocolType servertype;
+
+ priv = SERVERTYPE_COMBO_BOX_GET_PRIVATE (combobox);
- ModestTransportStoreProtocol servertype = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+ servertype = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &servertype, -1);
return servertype;
}
- return MODEST_PROTOCOL_TRANSPORT_STORE_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
{
EasysetupServertypeComboBox* self;
- gint id;
+ ModestProtocolType id;
gboolean found;
} ForEachData;
on_model_foreach_select_id(GtkTreeModel *model,
GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
{
+ ModestProtocolType id = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
ForEachData *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);
* or MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN if no servertype was selected.
*/
gboolean
-easysetup_servertype_combo_box_set_active_servertype (EasysetupServertypeComboBox *combobox, ModestTransportStoreProtocol servertype)
+easysetup_servertype_combo_box_set_active_servertype (EasysetupServertypeComboBox *combobox, ModestProtocolType servertype)
{
- EasysetupServertypeComboBoxPrivate *priv = SERVERTYPE_COMBO_BOX_GET_PRIVATE (combobox);
+ EasysetupServertypeComboBoxPrivate *priv;
+ ForEachData *state;
+ gboolean result;
+ priv = SERVERTYPE_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 = servertype;
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);
#define _EASYSETUP_SERVERTYPE_COMBO_BOX
#include <gtk/gtkcombobox.h>
-#include "modest-protocol-info.h"
+#include "modest-protocol-registry.h"
G_BEGIN_DECLS
GType easysetup_servertype_combo_box_get_type (void);
-EasysetupServertypeComboBox* easysetup_servertype_combo_box_new (void);
+EasysetupServertypeComboBox* easysetup_servertype_combo_box_new (gboolean filter_providers);
-ModestTransportStoreProtocol easysetup_servertype_combo_box_get_active_servertype (EasysetupServertypeComboBox *combobox);
+ModestProtocolType easysetup_servertype_combo_box_get_active_servertype (EasysetupServertypeComboBox *combobox);
-gboolean easysetup_servertype_combo_box_set_active_servertype (EasysetupServertypeComboBox *combobox, ModestTransportStoreProtocol servertype);
+gboolean easysetup_servertype_combo_box_set_active_servertype (EasysetupServertypeComboBox *combobox, ModestProtocolType servertype);
G_END_DECLS
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkseparator.h>
-#include <string.h> /* For strlen(). */
#include "maemo/easysetup/modest-easysetup-country-combo-box.h"
#include "maemo/easysetup/modest-easysetup-provider-combo-box.h"
#include "maemo/easysetup/modest-easysetup-servertype-combo-box.h"
-#include "widgets/modest-serversecurity-combo-box.h"
-#include "widgets/modest-secureauth-combo-box.h"
#include "widgets/modest-validating-entry.h"
#include "modest-text-utils.h"
#include "modest-conf.h"
+#include "modest-defs.h"
#include "modest-account-mgr.h"
+#include "modest-signal-mgr.h"
#include "modest-account-mgr-helpers.h"
#include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
#include "maemo/modest-connection-specific-smtp-window.h"
#include "widgets/modest-ui-constants.h"
-#include "widgets/modest-account-settings-dialog.h"
+#include "widgets/modest-default-account-settings-dialog.h"
+#include "widgets/modest-easysetup-wizard-page.h"
#include "maemo/modest-maemo-utils.h"
#include "modest-utils.h"
#include "maemo/modest-hildon-includes.h"
+#include "maemo/modest-maemo-security-options-view.h"
+#include <modest-account-protocol.h>
/* Include config.h so that _() works: */
#ifdef HAVE_CONFIG_H
GtkWidget *combo_incoming_servertype;
GtkWidget *caption_incoming;
GtkWidget *entry_incomingserver;
- GtkWidget *combo_incoming_security;
- GtkWidget *checkbox_incoming_auth;
+
+ /* Security widgets */
+ GtkWidget *incoming_security;
+ GtkWidget *outgoing_security;
GtkWidget *page_custom_outgoing;
GtkWidget *entry_outgoingserver;
GtkWidget *button_outgoing_smtp_servers;
GtkWidget *page_complete_customsetup;
+
+ ModestProtocolType last_plugin_protocol_selected;
+ GSList *missing_data_signals;
};
static void save_to_settings (ModestEasysetupWizardDialog *self);
-
+static void real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next);
static gboolean
on_delete_event (GtkWidget *widget,
}
static void
-on_incoming_security_changed(GtkWidget* widget, ModestEasysetupWizardDialog* wizard)
-{
- ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(wizard);
- ModestConnectionProtocol protocol_security_incoming;
-
- g_return_if_fail (priv != NULL);
- protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security));
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth), modest_protocol_info_is_secure (protocol_security_incoming));
- gtk_widget_set_sensitive (priv->checkbox_incoming_auth, !modest_protocol_info_is_secure (protocol_security_incoming));
-
- on_easysetup_changed (widget, wizard);
-}
-
-static void
-modest_easysetup_wizard_dialog_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
-{
- switch (property_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-modest_easysetup_wizard_dialog_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
-{
- switch (property_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
modest_easysetup_wizard_dialog_dispose (GObject *object)
{
if (G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose)
if (priv->settings)
g_object_unref (priv->settings);
+
+ if (priv->missing_data_signals) {
+ modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
+ priv->missing_data_signals = NULL;
+ }
G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->finalize (object);
}
static void
-show_error (GtkWidget *parent_widget, const gchar* text);
-
-static void
create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self);
static void
static void on_combo_servertype_changed(GtkComboBox *combobox, gpointer user_data);
-static gint get_serverport_incoming(ModestPresetsServerType servertype_incoming,
- ModestPresetsSecurity security_incoming)
+static gint
+get_port_from_protocol (ModestProtocolType server_type,
+ gboolean alternate_port)
{
- int serverport_incoming = 0;
- /* We don't check for SMTP here as that is impossible for an incoming server. */
- if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_IMAP) {
- serverport_incoming =
- (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING_ALTERNATE_PORT) ? 993 : 143;
- } else if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_POP) {
- serverport_incoming =
- (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING_ALTERNATE_PORT) ? 995 : 110;
- }
- return serverport_incoming;
-}
-
-static GList*
-check_for_supported_auth_methods (ModestEasysetupWizardDialog* self)
-{
- GError *error = NULL;
- ModestTransportStoreProtocol protocol;
- const gchar* hostname;
- const gchar* username;
- ModestConnectionProtocol protocol_security_incoming;
- int port_num;
- GList *list_auth_methods;
- ModestEasysetupWizardDialogPrivate *priv;
-
- priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
- protocol = easysetup_servertype_combo_box_get_active_servertype (
- EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype));
- hostname = gtk_entry_get_text(GTK_ENTRY(priv->entry_incomingserver));
- username = gtk_entry_get_text(GTK_ENTRY(priv->entry_user_username));
- protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security));
- port_num = get_serverport_incoming(protocol, protocol_security_incoming);
- list_auth_methods = modest_utils_get_supported_secure_authentication_methods (protocol, hostname, port_num,
- username, GTK_WINDOW (self), &error);
-
- if (list_auth_methods) {
- /* TODO: Select the correct method */
- GList* list = NULL;
- GList* method;
- for (method = list_auth_methods; method != NULL; method = g_list_next(method)) {
- ModestAuthProtocol auth = (ModestAuthProtocol) (GPOINTER_TO_INT(method->data));
- if (modest_protocol_info_auth_is_secure(auth)) {
- list = g_list_append(list, GINT_TO_POINTER(auth));
- }
- }
-
- g_list_free(list_auth_methods);
+ int server_port = 0;
+ ModestProtocol *protocol;
+ ModestProtocolRegistry *protocol_registry;
- if (list)
- return list;
- }
-
- if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
- error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
- {
- show_error (GTK_WIDGET(self), _("mcen_ib_unableto_discover_auth_methods"));
- }
-
- if(error != NULL)
- g_error_free(error);
-
- return NULL;
-}
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, server_type);
-static gboolean check_has_supported_auth_methods(ModestEasysetupWizardDialog* self)
-{
- GList* methods = check_for_supported_auth_methods(self);
- if (!methods)
- {
- return FALSE;
+ if (alternate_port) {
+ server_port = modest_account_protocol_get_alternate_port (MODEST_ACCOUNT_PROTOCOL (protocol));
+ } else {
+ server_port = modest_account_protocol_get_port (MODEST_ACCOUNT_PROTOCOL (protocol));
}
-
- g_list_free(methods);
- return TRUE;
+ return server_port;
}
-static ModestAuthProtocol check_first_supported_auth_method(ModestEasysetupWizardDialog* self)
-{
- ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_PASSWORD;
-
- GList* methods = check_for_supported_auth_methods(self);
- if (methods)
- {
- /* Use the first one: */
- result = (ModestAuthProtocol) (GPOINTER_TO_INT(methods->data));
- g_list_free(methods);
- }
-
- return result;
-}
+/* static GList* */
+/* check_for_supported_auth_methods (ModestEasysetupWizardDialog* self) */
+/* { */
+/* GError *error = NULL; */
+/* ModestProtocolType protocol_type; */
+/* const gchar* hostname; */
+/* const gchar* username; */
+/* ModestProtocolType security_protocol_incoming_type; */
+/* ModestProtocolRegistry *registry; */
+/* int port_num; */
+/* GList *list_auth_methods; */
+/* ModestEasysetupWizardDialogPrivate *priv; */
+
+/* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self); */
+/* registry = modest_runtime_get_protocol_registry (); */
+/* protocol_type = easysetup_servertype_combo_box_get_active_servertype ( */
+/* EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype)); */
+/* hostname = gtk_entry_get_text(GTK_ENTRY(priv->entry_incomingserver)); */
+/* username = gtk_entry_get_text(GTK_ENTRY(priv->entry_user_username)); */
+/* security_protocol_incoming_type = modest_serversecurity_combo_box_get_active_serversecurity */
+/* (MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security)); */
+/* port_num = get_port_from_protocol(protocol_type, FALSE); */
+/* list_auth_methods = modest_utils_get_supported_secure_authentication_methods (protocol_type, hostname, port_num, */
+/* username, GTK_WINDOW (self), &error); */
+
+/* if (list_auth_methods) { */
+/* /\* TODO: Select the correct method *\/ */
+/* GList* list = NULL; */
+/* GList* method; */
+/* for (method = list_auth_methods; method != NULL; method = g_list_next(method)) { */
+/* ModestProtocolType auth_protocol_type = (ModestProtocolType) (GPOINTER_TO_INT(method->data)); */
+/* if (modest_protocol_registry_protocol_type_has_tag (registry, auth_protocol_type, */
+/* MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS)) { */
+/* list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type)); */
+/* } */
+/* } */
+
+/* g_list_free(list_auth_methods); */
+
+/* if (list) */
+/* return list; */
+/* } */
+
+/* if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() || */
+/* error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED) */
+/* { */
+/* modest_platform_information_banner (GTK_WIDGET(self), NULL, */
+/* _("mcen_ib_unableto_discover_auth_methods")); */
+/* } */
+
+/* if(error != NULL) */
+/* g_error_free(error); */
+
+/* return NULL; */
+/* } */
+
+/* static gboolean check_has_supported_auth_methods(ModestEasysetupWizardDialog* self) */
+/* { */
+/* GList* methods = check_for_supported_auth_methods(self); */
+/* if (!methods) */
+/* { */
+/* return FALSE; */
+/* } */
+
+/* g_list_free(methods); */
+/* return TRUE; */
+/* } */
+
+/* static ModestProtocolType check_first_supported_auth_method(ModestEasysetupWizardDialog* self) */
+/* { */
+/* ModestProtocolType result; */
+
+/* result = MODEST_PROTOCOLS_AUTH_PASSWORD; */
+
+/* GList* methods = check_for_supported_auth_methods(self); */
+/* if (methods) */
+/* { */
+/* /\* Use the first one: *\/ */
+/* result = (ModestProtocolType) (GPOINTER_TO_INT(methods->data)); */
+/* g_list_free(methods); */
+/* } */
+
+/* return result; */
+/* } */
static void
invoke_enable_buttons_vfunc (ModestEasysetupWizardDialog *wizard_dialog)
/** This is a convenience function to create a caption containing a mandatory widget.
* When the widget is edited, the enable_buttons() vfunc will be called.
*/
-static GtkWidget* create_caption_new_with_asterisk(ModestEasysetupWizardDialog *self,
- GtkSizeGroup *group,
- const gchar *value,
- GtkWidget *control,
- GtkWidget *icon,
- HildonCaptionStatus flag)
+static GtkWidget*
+create_caption_new_with_asterisk (ModestEasysetupWizardDialog *self,
+ GtkSizeGroup *group,
+ const gchar *value,
+ GtkWidget *control,
+ GtkWidget *icon,
+ HildonCaptionStatus flag)
{
GtkWidget *caption = NULL;
static void
on_entry_max (ModestValidatingEntry *self, gpointer user_data)
{
- /* ModestEasysetupWizardDialog *dialog = MODEST_EASYSETUP_WIZARD_DIALOG (user_data); */
- show_error (GTK_WIDGET (self), _CS("ckdg_ib_maximum_characters_reached"));
+ modest_platform_information_banner (GTK_WIDGET (self), NULL,
+ _CS("ckdg_ib_maximum_characters_reached"));
}
static GtkWidget*
g_list_free (list_prevent);
list_prevent = NULL;
modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
- modest_maemo_utils_on_entry_invalid_character, self);
+ modest_utils_on_entry_invalid_character, self);
/* Set max length as in the UI spec:
* The UI spec seems to want us to show a dialog if we hit the maximum. */
GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup,
_("mcen_li_emailsetup_name"), priv->entry_user_name, NULL, HILDON_CAPTION_OPTIONAL);
g_signal_connect(G_OBJECT(priv->entry_user_name), "changed",
- G_CALLBACK(on_easysetup_changed), self);
+ G_CALLBACK(on_easysetup_changed), self);
gtk_widget_show (priv->entry_user_name);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
modest_validating_entry_set_unallowed_characters (
MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
- modest_maemo_utils_on_entry_invalid_character, self);
+ modest_utils_on_entry_invalid_character, self);
g_list_free (list_prevent);
/* The username widgets: */
priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
/* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username), HILDON_GTK_INPUT_MODE_FULL);
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username),
+ HILDON_GTK_INPUT_MODE_FULL);
caption = create_caption_new_with_asterisk (self, sizegroup, _("mail_fi_username"),
- priv->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
+ priv->entry_user_username,
+ NULL, HILDON_CAPTION_MANDATORY);
gtk_widget_show (priv->entry_user_username);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
g_signal_connect(G_OBJECT(priv->entry_user_username), "changed",
- G_CALLBACK(on_easysetup_changed), self);
+ G_CALLBACK(on_easysetup_changed), self);
gtk_widget_show (caption);
/* Prevent the use of some characters in the username,
modest_validating_entry_set_unallowed_characters_whitespace (
MODEST_VALIDATING_ENTRY (priv->entry_user_username));
modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_username),
- modest_maemo_utils_on_entry_invalid_character, self);
+ modest_utils_on_entry_invalid_character, self);
/* Set max length as in the UI spec:
* The UI spec seems to want us to show a dialog if we hit the maximum. */
caption = create_caption_new_with_asterisk (self, sizegroup,
_("mail_fi_password"), priv->entry_user_password, NULL, HILDON_CAPTION_OPTIONAL);
g_signal_connect(G_OBJECT(priv->entry_user_password), "changed",
- G_CALLBACK(on_easysetup_changed), self);
+ G_CALLBACK(on_easysetup_changed), self);
gtk_widget_show (priv->entry_user_password);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
gtk_widget_show (priv->entry_user_email);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
g_signal_connect(G_OBJECT(priv->entry_user_email), "changed",
- G_CALLBACK(on_easysetup_changed), self);
+ G_CALLBACK(on_easysetup_changed), self);
gtk_widget_show (caption);
/* Set max length as in the UI spec:
return GTK_WIDGET (box);
}
-static GtkWidget* create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
+static GtkWidget*
+create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
{
GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
static void
update_incoming_server_title (ModestEasysetupWizardDialog *self)
{
- ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
- const ModestTransportStoreProtocol protocol = easysetup_servertype_combo_box_get_active_servertype (
+ ModestEasysetupWizardDialogPrivate* priv;
+ ModestProtocolType protocol_type;
+ ModestProtocolRegistry *protocol_registry;
+
+ priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+
+ protocol_type = easysetup_servertype_combo_box_get_active_servertype (
EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype));
- const gchar* type =
- (protocol == MODEST_PROTOCOL_STORE_POP ?
- _("mail_fi_emailtype_pop3") :
- _("mail_fi_emailtype_imap") );
-
+
+ /* This could happen when the combo box has still no active iter */
+ if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ gchar* incomingserver_title;
+ const gchar *protocol_display_name;
+
+ protocol_display_name = modest_protocol_get_display_name (modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type));
- gchar* incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), type);
- g_object_set (G_OBJECT (priv->caption_incoming), "label", incomingserver_title, NULL);
- g_free(incomingserver_title);
+ incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), protocol_display_name);
+ g_object_set (G_OBJECT (priv->caption_incoming), "label", incomingserver_title, NULL);
+ g_free(incomingserver_title);
+ }
}
/** Change the caption title for the incoming server,
update_incoming_server_security_choices (ModestEasysetupWizardDialog *self)
{
ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
- const ModestTransportStoreProtocol protocol = easysetup_servertype_combo_box_get_active_servertype (
- EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype));
-
- /* Fill the combo with appropriately titled choices for POP or IMAP. */
- /* The choices are the same, but the titles are different, as in the UI spec. */
- modest_serversecurity_combo_box_fill (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security), protocol);
+ EasysetupServertypeComboBox *server_type_combo;
+ ModestProtocolType protocol_type;
+ ModestSecurityOptionsView *view;
+
+ server_type_combo =
+ EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype);
+ protocol_type =
+ easysetup_servertype_combo_box_get_active_servertype (server_type_combo);
+
+ /* Fill the combo with appropriately titled choices for all
+ those protocols */
+ view = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
+ modest_security_options_view_set_server_type (view, protocol_type);
}
static void
{
ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
-
+ EasysetupServertypeComboBox *combo;
+ ModestProtocolType protocol_type;
+
priv->dirty = TRUE;
+ /* Update title */
update_incoming_server_title (self);
+
+ /* Update security options if needed */
+ combo = EASYSETUP_SERVERTYPE_COMBO_BOX (combobox);
+ protocol_type = easysetup_servertype_combo_box_get_active_servertype (combo);
update_incoming_server_security_choices (self);
+ gtk_widget_show (priv->incoming_security);
set_default_custom_servernames (self);
}
static GtkWidget*
create_page_custom_incoming (ModestEasysetupWizardDialog *self)
{
- ModestEasysetupWizardDialogPrivate* priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
- GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ ModestProtocolRegistry *protocol_registry;
+ ModestEasysetupWizardDialogPrivate* priv;
+ GtkWidget *box;
+ GtkWidget *scrolled_window;
+ GtkWidget *label;
+ GtkSizeGroup *sizegroup;
+ GtkWidget *caption;
+
+ priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+
+ box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
/* Show note that account type cannot be changed in future: */
- GtkWidget *label = gtk_label_new (_("mcen_ia_emailsetup_account_type"));
+ label = gtk_label_new (_("mcen_ia_emailsetup_account_type"));
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_widget_set_size_request (label, 600, -1);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
/* Create a size group to be used by all captions.
* Note that HildonCaption does not create a default size group if we do not specify one.
* We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
- GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
/* The incoming server widgets: */
- priv->combo_incoming_servertype = GTK_WIDGET (easysetup_servertype_combo_box_new ());
- easysetup_servertype_combo_box_set_active_servertype (
- EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype), MODEST_PROTOCOL_STORE_POP);
- GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup,
- _("mcen_li_emailsetup_type"), priv->combo_incoming_servertype, NULL, HILDON_CAPTION_MANDATORY);
+ priv->combo_incoming_servertype = GTK_WIDGET (easysetup_servertype_combo_box_new (TRUE));
+ caption = create_caption_new_with_asterisk (self, sizegroup,
+ _("mcen_li_emailsetup_type"), priv->combo_incoming_servertype, NULL, HILDON_CAPTION_MANDATORY);
gtk_widget_show (priv->combo_incoming_servertype);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
* so this default text will never be seen: */
/* (Note: Changing the title seems pointless. murrayc) */
priv->caption_incoming = create_caption_new_with_asterisk (self, sizegroup,
- "Incoming Server", priv->entry_incomingserver, NULL, HILDON_CAPTION_MANDATORY);
+ "Incoming Server",
+ priv->entry_incomingserver,
+ NULL, HILDON_CAPTION_MANDATORY);
update_incoming_server_title (self);
gtk_widget_show (priv->entry_incomingserver);
gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
g_signal_connect (G_OBJECT (priv->entry_incomingserver), "changed",
G_CALLBACK (on_entry_incoming_servername_changed), self);
- /* The secure connection widgets: */
- priv->combo_incoming_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
- update_incoming_server_security_choices (self);
- modest_serversecurity_combo_box_set_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security), MODEST_PROTOCOL_CONNECTION_NORMAL);
- caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
- priv->combo_incoming_security, NULL, HILDON_CAPTION_OPTIONAL);
- g_signal_connect (G_OBJECT (priv->combo_incoming_security), "changed",
- G_CALLBACK (on_incoming_security_changed), self);
- gtk_widget_show (priv->combo_incoming_security);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- priv->checkbox_incoming_auth = gtk_check_button_new ();
- g_signal_connect (G_OBJECT (priv->checkbox_incoming_auth), "toggled",
- G_CALLBACK (on_easysetup_changed), self);
- caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
- priv->checkbox_incoming_auth, NULL, HILDON_CAPTION_OPTIONAL);
-
- gtk_widget_show (priv->checkbox_incoming_auth);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- gtk_widget_show (GTK_WIDGET (box));
+ /* The secure connection widgets. These are only valid for
+ protocols with security */
+ priv->incoming_security =
+ modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
+ FALSE, sizegroup);
+ gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
+ FALSE, FALSE, MODEST_MARGIN_HALF);
+
+ /* Set default selection */
+ easysetup_servertype_combo_box_set_active_servertype (
+ EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype),
+ MODEST_PROTOCOLS_STORE_POP);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), box);
gtk_container_set_focus_vadjustment (GTK_CONTAINER (box),
gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window)));
+ gtk_widget_show (GTK_WIDGET (box));
gtk_widget_show (scrolled_window);
-
+
return GTK_WIDGET (scrolled_window);
}
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
set_default_custom_servernames (self);
-
- /* The secure connection widgets: */
- priv->combo_outgoing_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
- g_signal_connect (G_OBJECT (priv->combo_outgoing_security), "changed",
- G_CALLBACK (on_easysetup_changed), self);
- modest_serversecurity_combo_box_fill (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOL_TRANSPORT_SMTP);
- modest_serversecurity_combo_box_set_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOL_CONNECTION_NORMAL);
- caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
- priv->combo_outgoing_security, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (priv->combo_outgoing_security);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* The secure authentication widgets: */
- priv->combo_outgoing_auth = GTK_WIDGET (modest_secureauth_combo_box_new ());
- g_signal_connect (G_OBJECT (priv->combo_outgoing_auth), "changed",
- G_CALLBACK (on_easysetup_changed), self);
- caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
- priv->combo_outgoing_auth, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (priv->combo_outgoing_auth);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
+
+ /* The secure connection widgets. These are only valid for
+ protocols with security */
+ priv->outgoing_security =
+ modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
+ FALSE, sizegroup);
+ gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security,
+ FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (priv->outgoing_security);
GtkWidget *separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
gint response;
/* Show the Account Settings window: */
- ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
+ ModestAccountSettingsDialog *dialog = modest_default_account_settings_dialog_new ();
if (priv->pending_load_settings) {
save_to_settings (self);
priv->pending_load_settings = FALSE;
}
- modest_account_settings_dialog_set_account (dialog, priv->settings);
+ modest_account_settings_dialog_load_settings (dialog, priv->settings);
modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog));
/* Show the Account Settings window: */
show_advanced_edit(self);
}
-static GtkWidget* create_page_complete_custom (ModestEasysetupWizardDialog *self)
+static GtkWidget*
+create_page_complete_custom (ModestEasysetupWizardDialog *self)
{
GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
}
static void
+modest_easysetup_wizard_dialog_append_page (GtkNotebook *notebook,
+ GtkWidget *page,
+ const gchar *label)
+{
+ gint index;
+ /* Append page and set attributes */
+ index = gtk_notebook_append_page (notebook, page, gtk_label_new (label));
+ gtk_container_child_set (GTK_CONTAINER (notebook), page,
+ "tab-expand", TRUE, "tab-fill", TRUE,
+ NULL);
+ gtk_widget_show (page);
+}
+
+static void
+init_user_page (ModestEasysetupWizardDialogPrivate *priv)
+{
+ priv->page_user_details = NULL;
+ priv->entry_user_name = NULL;
+ priv->entry_user_username = NULL;
+ priv->entry_user_password = NULL;
+ priv->entry_user_email = NULL;
+}
+
+static void
+init_incoming_page (ModestEasysetupWizardDialogPrivate *priv)
+{
+ priv->page_custom_incoming = NULL;
+ priv->combo_incoming_servertype = NULL;
+ priv->caption_incoming = NULL;
+ priv->entry_incomingserver = NULL;
+ priv->entry_user_email = NULL;
+ priv->incoming_security = NULL;
+}
+
+static void
+init_outgoing_page (ModestEasysetupWizardDialogPrivate *priv)
+{
+ priv->page_custom_outgoing = NULL;
+ priv->entry_outgoingserver = NULL;
+ priv->combo_outgoing_security = NULL;
+ priv->combo_outgoing_auth = NULL;
+ priv->checkbox_outgoing_smtp_specific = NULL;
+ priv->button_outgoing_smtp_servers = NULL;
+ priv->outgoing_security = NULL;
+}
+
+static void
modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self)
{
gtk_container_set_border_width (GTK_CONTAINER (self), MODEST_MARGIN_HALF);
/* Initialize fields */
priv->page_welcome = create_page_welcome (self);
priv->page_account_details = create_page_account_details (self);
- priv->page_user_details = create_page_user_details (self);
- priv->page_complete_easysetup = NULL;
- priv->page_custom_incoming = NULL;
- priv->combo_incoming_servertype = NULL;
- priv->caption_incoming = NULL;
- priv->entry_incomingserver = NULL;
- priv->combo_incoming_security = NULL;
- priv->checkbox_incoming_auth = NULL;
- priv->page_custom_outgoing = NULL;
- priv->entry_outgoingserver = NULL;
- priv->combo_outgoing_security = NULL;
- priv->combo_outgoing_auth = NULL;
- priv->checkbox_outgoing_smtp_specific = NULL;
- priv->button_outgoing_smtp_servers = NULL;
- priv->page_complete_customsetup = NULL;
-
- /* Add the common pages: */
- gtk_notebook_append_page (notebook, priv->page_welcome,
- gtk_label_new (_("mcen_ti_emailsetup_welcome")));
- gtk_container_child_set (GTK_CONTAINER (notebook),
- priv->page_welcome,
- "tab-expand", TRUE,
- "tab-fill", TRUE,
- NULL);
- gtk_notebook_append_page (notebook, priv->page_account_details,
- gtk_label_new (_("mcen_ti_accountdetails")));
- gtk_container_child_set (GTK_CONTAINER (notebook),
- priv->page_account_details,
- "tab-expand", TRUE,
- "tab-fill", TRUE,
- NULL);
+ init_user_page (priv);
+ init_incoming_page (priv);
+ init_outgoing_page (priv);
- gtk_notebook_append_page (notebook, priv->page_user_details,
- gtk_label_new (_("mcen_ti_emailsetup_userdetails")));
- gtk_container_child_set (GTK_CONTAINER (notebook),
- priv->page_user_details,
- "tab-expand", TRUE,
- "tab-fill", TRUE,
- NULL);
+ priv->page_complete_easysetup = NULL;
+ priv->page_complete_customsetup = NULL;
+ priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+ priv->missing_data_signals = NULL;
+
+ /* Add the common pages */
+ modest_easysetup_wizard_dialog_append_page (notebook, priv->page_welcome,
+ _("mcen_ti_emailsetup_welcome"));
+ modest_easysetup_wizard_dialog_append_page (notebook, priv->page_account_details,
+ _("mcen_ti_accountdetails"));
- /* Create and add the easysetup-specific pages,
- * because we need _some_ final page to enable the Next and Finish buttons: */
- create_subsequent_easysetup_pages (self);
-
/* Connect to the dialog's response signal so we can enable/disable buttons
* for the newly-selected page, because the prev/next buttons cause response to be emitted.
* Note that we use g_signal_connect_after() instead of g_signal_connect()
return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
}
-static void create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
+static void
+create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
{
ModestEasysetupWizardDialogPrivate *priv;
GtkNotebook *notebook = NULL;
g_assert(notebook);
priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
-
+
+ if (!priv->page_user_details) {
+ priv->page_user_details = create_page_user_details (self);
+ }
+
/* Create the custom pages: */
if(!(priv->page_custom_incoming)) {
priv->page_custom_incoming = create_page_custom_incoming (self);
}
+ /* TODO: only if needed */
if(!(priv->page_custom_outgoing)) {
priv->page_custom_outgoing = create_page_custom_outgoing (self);
}
if(!(priv->page_complete_customsetup)) {
priv->page_complete_customsetup = create_page_complete_custom (self);
}
-
+
+ if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_user_details)))
+ modest_easysetup_wizard_dialog_append_page (notebook, priv->page_user_details,
+ _("mcen_ti_emailsetup_userdetails"));
+
if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_incoming)))
- gtk_notebook_append_page (notebook, priv->page_custom_incoming,
- gtk_label_new (_("mcen_ti_emailsetup_incomingdetails")));
+ modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_incoming,
+ _("mcen_ti_emailsetup_incomingdetails"));
if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_custom_outgoing)))
- gtk_notebook_append_page (notebook, priv->page_custom_outgoing,
- gtk_label_new (_("mcen_ti_emailsetup_outgoingdetails")));
+ modest_easysetup_wizard_dialog_append_page (notebook, priv->page_custom_outgoing,
+ _("mcen_ti_emailsetup_outgoingdetails"));
- if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_customsetup))) {
- gtk_notebook_append_page (notebook, priv->page_complete_customsetup,
- gtk_label_new (_("mcen_ti_emailsetup_complete")));
- gtk_container_child_set (GTK_CONTAINER (notebook),
- priv->page_complete_customsetup,
- "tab-expand", TRUE,
- "tab-fill", TRUE,
- NULL);
- }
+ if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_customsetup)))
+ modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_customsetup,
+ _("mcen_ti_emailsetup_complete"));
/* This is unnecessary with GTK+ 2.10: */
modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
if(!priv->page_complete_easysetup)
priv->page_complete_easysetup = create_page_complete_easysetup (self);
- if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_easysetup))) {
- gtk_notebook_append_page (notebook, priv->page_complete_easysetup,
- gtk_label_new (_("mcen_ti_emailsetup_complete")));
- gtk_container_child_set (GTK_CONTAINER (notebook),
- priv->page_complete_easysetup,
- "tab-expand", TRUE,
- "tab-fill", TRUE,
- NULL);
- }
+ if (!gtk_widget_get_parent (GTK_WIDGET (priv->page_complete_easysetup)))
+ modest_easysetup_wizard_dialog_append_page (notebook, priv->page_complete_easysetup,
+ _("mcen_ti_emailsetup_complete"));
/* This is unnecessary with GTK+ 2.10: */
modest_wizard_dialog_force_title_update (MODEST_WIZARD_DIALOG(self));
}
+
+/* */
+static void
+remove_non_common_tabs (GtkNotebook *notebook,
+ gboolean remove_user_details)
+{
+ gint starting_tab;
+ /* The first 2 tabs are the common ones (welcome tab and the
+ providers tab), so we always remove starting from the
+ end */
+
+ starting_tab = (remove_user_details) ? 2 : 3;
+ while (gtk_notebook_get_n_pages (notebook) > starting_tab)
+ gtk_notebook_remove_page (notebook, -1);
+}
+
+static void
+on_missing_mandatory_data (ModestAccountProtocol *protocol,
+ gboolean missing,
+ gpointer user_data)
+{
+ real_enable_buttons (MODEST_WIZARD_DIALOG (user_data), !missing);
+}
+
/* After the user details page,
* the following pages depend on whether "Other" was chosen
* in the provider combobox on the account page
*/
-static void create_subsequent_pages (ModestEasysetupWizardDialog *self)
+static void
+create_subsequent_pages (ModestEasysetupWizardDialog *self)
{
ModestEasysetupWizardDialogPrivate *priv;
+ EasysetupProviderComboBox *combo;
+ EasysetupProviderComboBoxIdType id_type;
+ GtkNotebook *notebook;
priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
+ combo = EASYSETUP_PROVIDER_COMBO_BOX (priv->combo_account_serviceprovider);
+ id_type = easysetup_provider_combo_box_get_active_id_type (combo);
+ g_object_get (self, "wizard-notebook", ¬ebook, NULL);
- if (easysetup_provider_combo_box_get_active_provider_id (
- EASYSETUP_PROVIDER_COMBO_BOX (priv->combo_account_serviceprovider)) == 0) {
+ if (id_type == EASYSETUP_PROVIDER_COMBO_BOX_ID_OTHER) {
/* "Other..." was selected: */
-
- /* Make sure that the easysetup pages do not exist: */
- if(priv->page_complete_easysetup) {
- gtk_widget_destroy (priv->page_complete_easysetup);
+
+ /* If we come from a rollbacked easysetup */
+ if (priv->page_complete_easysetup) {
+ remove_non_common_tabs (notebook, FALSE);
priv->page_complete_easysetup = NULL;
- }
+ }
+ /* If we come from a rollbacked plugin protocol setup */
+ if (priv->last_plugin_protocol_selected != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ remove_non_common_tabs (notebook, TRUE);
+ priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+ modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
+ priv->missing_data_signals = NULL;
+ }
+
create_subsequent_customsetup_pages (self);
- }
- else {
- /* A specific provider was selected: */
- {
- /* Make sure that the custom pages do not exist:
- * Because they will be used if they exist, when creating the account. */
- if(priv->page_custom_incoming) {
- gtk_widget_destroy (priv->page_custom_incoming);
- priv->page_custom_incoming = NULL;
- priv->combo_incoming_servertype = NULL;
- priv->caption_incoming = NULL;
- priv->entry_incomingserver = NULL;
- priv->combo_incoming_security = NULL;
- priv->checkbox_incoming_auth = NULL;
- }
+ } else {
+ /* If we come from a rollbacked custom setup */
+ if (priv->page_custom_incoming) {
+ remove_non_common_tabs (notebook, TRUE);
+ init_user_page (priv);
+ init_incoming_page (priv);
+ init_outgoing_page (priv);
+ init_user_page (priv);
+ priv->page_complete_customsetup = NULL;
+ }
+
+ /* It's a pluggable protocol and not a provider with presets */
+ if (id_type == EASYSETUP_PROVIDER_COMBO_BOX_ID_PLUGIN_PROTOCOL) {
+ ModestProtocol *protocol;
+ gchar *proto_name;
+ ModestProtocolType proto_type;
+
- if(priv->page_custom_outgoing) {
- gtk_widget_destroy (priv->page_custom_outgoing);
- priv->page_custom_outgoing = NULL;
- priv->entry_outgoingserver = NULL;
- priv->combo_outgoing_security = NULL;
- priv->combo_outgoing_auth = NULL;
- priv->checkbox_outgoing_smtp_specific = NULL;
- priv->button_outgoing_smtp_servers = NULL;
+ /* If we come from a rollbacked easy setup */
+ if (priv->last_plugin_protocol_selected ==
+ MODEST_PROTOCOL_REGISTRY_TYPE_INVALID &&
+ priv->page_complete_easysetup) {
+ remove_non_common_tabs (notebook, TRUE);
+ init_user_page (priv);
+ priv->page_complete_easysetup = NULL;
}
- if(priv->page_complete_customsetup) {
- gtk_widget_destroy (priv->page_complete_customsetup);
- priv->page_complete_customsetup = NULL;
+ proto_name = easysetup_provider_combo_box_get_active_provider_id (combo);
+ protocol = modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
+ MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
+ proto_name);
+ proto_type = modest_protocol_get_type_id (protocol);
+
+ if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
+ proto_type != priv->last_plugin_protocol_selected) {
+ ModestPairList *tabs;
+ GSList *tmp;
+
+ /* Remember the last selected plugin protocol */
+ priv->last_plugin_protocol_selected = proto_type;
+
+ /* Get tabs */
+ tabs = modest_account_protocol_get_easysetupwizard_tabs (MODEST_ACCOUNT_PROTOCOL (protocol));
+ tmp = (GSList *) tabs;
+ while (tmp) {
+ ModestPair *pair = (ModestPair *) tmp->data;
+ modest_easysetup_wizard_dialog_append_page (notebook,
+ GTK_WIDGET (pair->second),
+ (const gchar *) pair->first);
+
+ /* Connect signals */
+ priv->missing_data_signals =
+ modest_signal_mgr_connect (priv->missing_data_signals,
+ G_OBJECT (pair->second),
+ "missing-mandatory-data",
+ G_CALLBACK (on_missing_mandatory_data),
+ self);
+
+ g_free (pair->first);
+ tmp = g_slist_next (tmp);
+ /* Critical: if you don't show the page then the dialog will ignore it */
+/* gtk_widget_show (GTK_WIDGET (pair->second)); */
+ }
+ modest_pair_list_free (tabs);
+ }
+ g_free (proto_name);
+ } else {
+ if (priv->last_plugin_protocol_selected !=
+ MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ remove_non_common_tabs (notebook, TRUE);
+ init_user_page (priv);
+ priv->page_complete_easysetup = NULL;
+ priv->last_plugin_protocol_selected = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+ modest_signal_mgr_disconnect_all_and_destroy (priv->missing_data_signals);
+ priv->missing_data_signals = NULL;
+ }
+ if (!priv->page_user_details) {
+ priv->page_user_details = create_page_user_details (self);
+ modest_easysetup_wizard_dialog_append_page (notebook,
+ priv->page_user_details,
+ _("mcen_ti_emailsetup_userdetails"));
}
}
static gchar*
-util_get_default_servername_from_email_address (const gchar* email_address, ModestTransportStoreProtocol servertype)
+util_get_default_servername_from_email_address (const gchar* email_address, ModestProtocolType protocol_type)
{
+ const gchar* hostname = NULL;
+ gchar* at;
+ gchar* domain;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
+
if (!email_address)
return NULL;
- gchar* at = g_utf8_strchr (email_address, -1, '@');
+ at = g_utf8_strchr (email_address, -1, '@');
if (!at || (g_utf8_strlen (at, -1) < 2))
return NULL;
- gchar* domain = g_utf8_next_char (at);
+ domain = g_utf8_next_char (at);
if(!domain)
return NULL;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
- const gchar* hostname = NULL;
- if (servertype == MODEST_PROTOCOL_STORE_POP)
- hostname = "pop";
- else if (servertype == MODEST_PROTOCOL_STORE_IMAP)
- hostname = "imap";
- else if (servertype == MODEST_PROTOCOL_TRANSPORT_SMTP)
- hostname = "smtp";
+ if (modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS) ||
+ modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS)) {
+ hostname = modest_protocol_get_name (protocol);
+ }
if (!hostname)
return NULL;
*/
if (priv->entry_user_email
&& ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED) == 0)) {
- const ModestTransportStoreProtocol protocol = easysetup_servertype_combo_box_get_active_servertype (
+ const ModestProtocolType protocol_type = easysetup_servertype_combo_box_get_active_servertype (
EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype));
- const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(priv->entry_user_email));
-
- gchar* servername = util_get_default_servername_from_email_address (email_address, protocol);
- /* Do not set the INCOMING_CHANGED flag because of this edit */
- g_signal_handlers_block_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
- gtk_entry_set_text (GTK_ENTRY (priv->entry_incomingserver), servername);
- g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
+ /* This could happen when the combo box has still no active iter */
+ if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(priv->entry_user_email));
+ gchar* servername = util_get_default_servername_from_email_address (email_address,
+ protocol_type);
- g_free (servername);
+ /* Do not set the INCOMING_CHANGED flag because of this edit */
+ g_signal_handlers_block_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry_incomingserver), servername);
+ g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
+
+ g_free (servername);
+ }
}
/* Set a default domain for the server, based on the email address,
&& ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED) == 0)) {
const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(priv->entry_user_email));
- gchar* servername = util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOL_TRANSPORT_SMTP);
+ gchar* servername = util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOLS_TRANSPORT_SMTP);
/* Do not set the OUTGOING_CHANGED flag because of this edit */
g_signal_handlers_block_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
account_title = gtk_entry_get_text (GTK_ENTRY (priv->entry_account_title));
- if (!account_title || (strlen (account_title) == 0)) {
+ if (!account_title || (g_utf8_strlen (account_title, -1) == 0)) {
return NULL;
} else {
/* Strip it of whitespace at the start and end: */
if (!result)
return NULL;
- if (strlen (result) == 0) {
+ if (g_utf8_strlen (result, -1) == 0) {
g_free (result);
return NULL;
}
{
ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
+ ModestProtocolRegistry *protocol_registry;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
/* if are browsing pages previous to the last one, then we have pending settings in
* this wizard */
return FALSE;
}
- }
- else if (current_page == priv->page_user_details) {
+
+ /* Make sure that the subsequent pages are appropriate for the provider choice. */
+ create_subsequent_pages (self);
+
+ } else if (current_page == priv->page_user_details) {
/* Check that the email address is valud: */
const gchar* email_address = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_email));
- if ((!email_address) || (strlen(email_address) == 0))
+ if ((!email_address) || (g_utf8_strlen (email_address, -1) == 0))
return FALSE;
if (!modest_text_utils_validate_email_address (email_address, NULL)) {
return FALSE;
}
-
- /* Make sure that the subsequent pages are appropriate for the provider choice. */
- create_subsequent_pages (self);
}
-
- /* TODO: The UI Spec wants us to check that the servernames are valid,
- * but does not specify how.
- */
- if(next_page == priv->page_custom_incoming) {
+ if (next_page == priv->page_custom_incoming) {
set_default_custom_servernames (self);
- }
- else if (next_page == priv->page_custom_outgoing) {
+ } else if (next_page == priv->page_custom_outgoing) {
set_default_custom_servernames (self);
/* Check if the server supports secure authentication */
- const ModestConnectionProtocol security_incoming =
- modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security));
- if (gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth))
- && !modest_protocol_info_is_secure(security_incoming))
- {
- if (!check_has_supported_auth_methods (self))
- return FALSE;
- }
+/* if (modest_security_options_view_auth_check (security_options)) */
+/* if (!check_has_supported_auth_methods (self)) */
+/* return FALSE; */
+ gtk_widget_show (priv->outgoing_security);
}
/* If this is the last page, and this is a click on Finish,
* then attempt to create the dialog.
*/
- if(!next_page) /* This is NULL when this is a click on Finish. */
+ if(!next_page &&
+ current_page != priv->page_account_details) /* This is NULL when this is a click on Finish. */
{
if (priv->pending_load_settings) {
save_to_settings (self);
return FALSE;
const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
- if ((!text) || (strlen(text) == 0))
+ if ((!text) || (g_utf8_strlen (text, -1) == 0))
return TRUE;
else {
/* Strip it of whitespace at the start and end: */
if (!stripped)
return TRUE;
- const gboolean result = (strlen (stripped) == 0);
+ const gboolean result = (g_utf8_strlen (stripped, -1) == 0);
g_free (stripped);
return result;
}
static void
+real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next)
+{
+ GtkNotebook *notebook = NULL;
+ gboolean is_finish_tab;
+ GtkWidget *current;
+ ModestEasysetupWizardDialogPrivate *priv;
+
+ /* Get data */
+ priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (dialog);
+ g_object_get (dialog, "wizard-notebook", ¬ebook, NULL);
+
+ /* Disable the Finish button until we are on the last page,
+ * because HildonWizardDialog enables this for all but the
+ * first page */
+ current = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
+ is_finish_tab = ((current == priv->page_complete_easysetup) ||
+ (current == priv->page_complete_customsetup));
+
+ if (is_finish_tab) {
+ /* Disable Next on the last page no matter what the
+ argument say */
+ enable_next = FALSE;
+ } else {
+ /* Not the last one */
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ MODEST_WIZARD_DIALOG_FINISH,
+ FALSE);
+ }
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
+ MODEST_WIZARD_DIALOG_NEXT,
+ enable_next);
+}
+
+static void
on_enable_buttons (ModestWizardDialog *dialog, GtkWidget *current_page)
{
ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
gboolean enable_next = TRUE;
if (current_page == priv->page_welcome) {
enable_next = TRUE;
- }
- else if (current_page == priv->page_account_details) {
+ } else if (current_page == priv->page_account_details) {
/* The account details title is mandatory: */
if (entry_is_empty(priv->entry_account_title))
enable_next = FALSE;
- }
- else if (current_page == priv->page_user_details) {
+ } else if (current_page == priv->page_user_details) {
/* The user details username is mandatory: */
if (entry_is_empty(priv->entry_user_username))
enable_next = FALSE;
/* The user details email address is mandatory: */
if (enable_next && entry_is_empty (priv->entry_user_email))
enable_next = FALSE;
- }
- else if (current_page == priv->page_custom_incoming) {
+ } else if (current_page == priv->page_custom_incoming) {
/* The custom incoming server is mandatory: */
if (entry_is_empty(priv->entry_incomingserver))
enable_next = FALSE;
+ } else if (MODEST_IS_EASYSETUP_WIZARD_PAGE (current_page)) {
+ enable_next = !modest_easysetup_wizard_page_validate (
+ MODEST_EASYSETUP_WIZARD_PAGE (current_page));
}
- /* Enable the buttons,
- * identifying them via their associated response codes: */
-
- /* Disable the Finish button until we are on the last page,
- * because HildonWizardDialog enables this for all but the first page: */
- GtkNotebook *notebook = NULL;
- GtkDialog *dialog_base = GTK_DIALOG (dialog);
- g_object_get (dialog_base, "wizard-notebook", ¬ebook, NULL);
-
- gint current = gtk_notebook_get_current_page (notebook);
- gint last = gtk_notebook_get_n_pages (notebook) - 1;
- const gboolean is_last = (current == last);
-
- if(!is_last) {
- gtk_dialog_set_response_sensitive (dialog_base,
- MODEST_WIZARD_DIALOG_FINISH,
- FALSE);
- } else
- {
- /* Disable Next on the last page: */
- enable_next = FALSE;
- }
-
- gtk_dialog_set_response_sensitive (dialog_base,
- MODEST_WIZARD_DIALOG_NEXT,
- enable_next);
+ /* Enable/disable buttons */
+ real_enable_buttons (dialog, enable_next);
}
static void
g_type_class_add_private (klass, sizeof (ModestEasysetupWizardDialogPrivate));
- object_class->get_property = modest_easysetup_wizard_dialog_get_property;
- object_class->set_property = modest_easysetup_wizard_dialog_set_property;
object_class->dispose = modest_easysetup_wizard_dialog_dispose;
object_class->finalize = modest_easysetup_wizard_dialog_finalize;
base_klass->before_next = on_before_next;
base_klass->enable_buttons = on_enable_buttons;
}
-
-static void
-show_error (GtkWidget *parent_widget, const gchar* text)
-{
- //TODO: Apparently this doesn't show anything in Maemo Bora:
- hildon_banner_show_information(parent_widget, NULL, text);
-}
-
/**
* save_to_settings:
const gchar *username, *password;
gchar *store_hostname, *transport_hostname;
guint store_port, transport_port;
- ModestTransportStoreProtocol store_protocol, transport_protocol;
- ModestConnectionProtocol store_security, transport_security;
- ModestAuthProtocol store_auth_protocol, transport_auth_protocol;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocolType store_protocol, transport_protocol;
+ ModestProtocolType store_security, transport_security;
+ ModestProtocolType store_auth_protocol, transport_auth_protocol;
ModestServerAccountSettings *store_settings, *transport_settings;
const gchar *fullname, *email_address;
+ EasysetupProviderComboBox *combo;
+ EasysetupProviderComboBoxIdType id_type;
+
+ priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
+ combo = EASYSETUP_PROVIDER_COMBO_BOX (priv->combo_account_serviceprovider);
+ protocol_registry = modest_runtime_get_protocol_registry ();
/* Get details from the specified presets: */
- provider_id = easysetup_provider_combo_box_get_active_provider_id (
- EASYSETUP_PROVIDER_COMBO_BOX (priv->combo_account_serviceprovider));
+ id_type = easysetup_provider_combo_box_get_active_id_type (combo);
+ provider_id = easysetup_provider_combo_box_get_active_provider_id (combo);
+ /* Let the plugin save the settings. We do a return in order
+ to save an indentation level */
+ if (id_type == EASYSETUP_PROVIDER_COMBO_BOX_ID_PLUGIN_PROTOCOL) {
+ ModestProtocol *protocol;
+
+ protocol = modest_protocol_registry_get_protocol_by_name (
+ modest_runtime_get_protocol_registry (),
+ MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
+ provider_id);
+
+ if (protocol && MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
+ gint n_pages, i = 0;
+ GtkNotebook *notebook;
+ GList *wizard_pages = NULL;
+
+ g_object_get (self, "wizard-notebook", ¬ebook, NULL);
+ n_pages = gtk_notebook_get_n_pages (notebook);
+ for (i = 0; i < n_pages; i++) {
+ GtkWidget *page = gtk_notebook_get_nth_page (notebook, i);
+ if (MODEST_IS_EASYSETUP_WIZARD_PAGE (page))
+ wizard_pages = g_list_append (wizard_pages, page);
+ }
+ modest_account_protocol_save_wizard_settings (MODEST_ACCOUNT_PROTOCOL (protocol),
+ wizard_pages,
+ priv->settings);
+ g_list_free (wizard_pages);
+ } else {
+ g_warning ("The selected protocol is a plugin protocol "//
+ "but it's not a ModestAccountProtocol");
+ }
+
+ return;
+ }
+
/* username and password (for both incoming and outgoing): */
username = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username));
password = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password));
+ store_settings = modest_account_settings_get_store_settings (priv->settings);
+ transport_settings = modest_account_settings_get_transport_settings (priv->settings);
+
/* Incoming server: */
- /* Note: We need something as default for the ModestTransportStoreProtocol* values,
+ /* Note: We need something as default for the transport store protocol values,
* or modest_account_mgr_add_server_account will fail. */
store_port = 0;
- store_protocol = MODEST_PROTOCOL_STORE_POP;
- store_security = MODEST_PROTOCOL_CONNECTION_NORMAL;
- store_auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
+ store_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+ store_security = MODEST_PROTOCOLS_CONNECTION_NONE;
+ store_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
if (provider_id) {
- ModestPresetsServerType store_provider_server_type;
- ModestPresetsSecurity store_provider_security;
+ ModestProtocolType store_provider_server_type;
+ gboolean store_provider_use_alternate_port;
/* Use presets: */
store_hostname = modest_presets_get_server (priv->presets, provider_id,
TRUE /* store */);
store_provider_server_type = modest_presets_get_info_server_type (priv->presets,
provider_id,
TRUE /* store */);
- store_provider_security = modest_presets_get_info_server_security (priv->presets,
+ store_security = modest_presets_get_info_server_security (priv->presets,
provider_id,
TRUE /* store */);
+ store_auth_protocol = modest_presets_get_info_server_auth (priv->presets,
+ provider_id,
+ TRUE /* store */);
+ store_provider_use_alternate_port = modest_presets_get_info_server_use_alternate_port (priv->presets,
+ provider_id,
+ TRUE /* store */);
/* We don't check for SMTP here as that is impossible for an incoming server. */
- if (store_provider_server_type == MODEST_PRESETS_SERVER_TYPE_IMAP)
- store_protocol = MODEST_PROTOCOL_STORE_IMAP;
- else if (store_provider_server_type == MODEST_PRESETS_SERVER_TYPE_POP)
- store_protocol = MODEST_PROTOCOL_STORE_POP;
- else /* fallback */
- store_protocol = MODEST_PROTOCOL_STORE_POP;
+ if (store_provider_server_type == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID)
+ store_protocol = MODEST_PROTOCOLS_STORE_POP;
+ else
+ store_protocol = store_provider_server_type;
/* we check if there is a *special* port */
special_port = modest_presets_get_port (priv->presets, provider_id, TRUE /* incoming */);
if (special_port != 0)
store_port = special_port;
else
- store_port = get_serverport_incoming(store_provider_server_type, store_provider_security);
-
- if (store_provider_security & MODEST_PRESETS_SECURITY_SECURE_INCOMING)
- store_security = MODEST_PROTOCOL_CONNECTION_SSL; /* TODO: Is this what we want? */
-
- if (store_provider_security & MODEST_PRESETS_SECURITY_APOP)
- store_auth_protocol = MODEST_PROTOCOL_AUTH_PASSWORD; /* TODO: Is this what we want? */
+ store_port = get_port_from_protocol(store_provider_server_type, store_security);
+
+ modest_server_account_settings_set_security_protocol (store_settings,
+ store_security);
+ modest_server_account_settings_set_auth_protocol (store_settings,
+ store_auth_protocol);
+ if (store_port != 0)
+ modest_server_account_settings_set_port (store_settings, store_port);
} else {
/* Use custom pages because no preset was specified: */
store_hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_incomingserver) ));
store_protocol = easysetup_servertype_combo_box_get_active_servertype (
EASYSETUP_SERVERTYPE_COMBO_BOX (priv->combo_incoming_servertype));
- store_security = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security));
-
- /* The UI spec says:
- * If secure authentication is unchecked, allow sending username and password also as plain text.
- * If secure authentication is checked, require one of the secure methods during
- * connection: SSL, TLS, CRAM-MD5 etc. */
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth)) &&
- !modest_protocol_info_is_secure(store_security)) {
- store_auth_protocol = check_first_supported_auth_method (self);
- } else {
- store_auth_protocol = MODEST_PROTOCOL_AUTH_PASSWORD;
- }
+
+ modest_security_options_view_save_settings (
+ MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
+ priv->settings);
}
- /* now we store the store account settings */
- store_settings = modest_account_settings_get_store_settings (priv->settings);
+ /* now we store the common store account settings */
modest_server_account_settings_set_hostname (store_settings, store_hostname);
modest_server_account_settings_set_username (store_settings, username);
modest_server_account_settings_set_password (store_settings, password);
modest_server_account_settings_set_protocol (store_settings, store_protocol);
- modest_server_account_settings_set_security (store_settings, store_security);
- modest_server_account_settings_set_auth_protocol (store_settings, store_auth_protocol);
- if (store_port != 0)
- modest_server_account_settings_set_port (store_settings, store_port);
g_object_unref (store_settings);
g_free (store_hostname);
/* Outgoing server: */
transport_hostname = NULL;
- transport_protocol = MODEST_PROTOCOL_STORE_POP;
- transport_security = MODEST_PROTOCOL_CONNECTION_NORMAL;
- transport_auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
+ transport_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+ transport_security = MODEST_PROTOCOLS_CONNECTION_NONE;
+ transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
transport_port = 0;
if (provider_id) {
- ModestPresetsServerType transport_provider_server_type;
- ModestPresetsSecurity transport_provider_security;
+ ModestProtocolType transport_provider_server_type;
+ ModestProtocolType transport_provider_security;
- /* Use presets: */
+ /* Use presets */
transport_hostname = modest_presets_get_server (priv->presets, provider_id,
FALSE /* transport */);
FALSE /* transport */);
/* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
- transport_protocol = MODEST_PROTOCOL_TRANSPORT_SENDMAIL;
- if (transport_provider_server_type == MODEST_PRESETS_SERVER_TYPE_SMTP)
- transport_protocol = MODEST_PROTOCOL_TRANSPORT_SMTP;
-
- transport_security = MODEST_PROTOCOL_CONNECTION_NORMAL;
- if (transport_provider_security & MODEST_PRESETS_SECURITY_SECURE_SMTP) {
+ transport_protocol = transport_provider_server_type;
+ transport_security = transport_provider_security;
+ if (transport_security == MODEST_PROTOCOLS_CONNECTION_SSL) {
/* printf("DEBUG: %s: using secure SMTP\n", __FUNCTION__); */
- transport_security = MODEST_PROTOCOL_CONNECTION_SSL; /* TODO: Is this what we want? */
/* we check if there is a *special* port */
special_port = modest_presets_get_port (priv->presets, provider_id,
FALSE /* transport */);
transport_port = special_port;
else
transport_port = 465;
- transport_auth_protocol = MODEST_PROTOCOL_AUTH_PASSWORD;
+ transport_auth_protocol = MODEST_PROTOCOLS_AUTH_PASSWORD;
} else {
/* printf("DEBUG: %s: using non-secure SMTP\n", __FUNCTION__); */
- transport_auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
+ transport_auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
}
+
+ modest_server_account_settings_set_security_protocol (transport_settings,
+ transport_security);
+ modest_server_account_settings_set_auth_protocol (transport_settings,
+ transport_auth_protocol);
+ if (transport_port != 0)
+ modest_server_account_settings_set_port (transport_settings,
+ transport_port);
} else {
+ ModestProtocolRegistry *registry;
+ ModestProtocol *store_proto;
+
+ registry = modest_runtime_get_protocol_registry ();
/* Use custom pages because no preset was specified: */
transport_hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver) ));
- transport_protocol = MODEST_PROTOCOL_TRANSPORT_SMTP; /* It's always SMTP for outgoing. */
- transport_security = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security));
- transport_auth_protocol = modest_secureauth_combo_box_get_active_secureauth (
- MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth));
+
+ store_proto = modest_protocol_registry_get_protocol_by_type (registry,
+ store_protocol);
+
+ if (transport_protocol == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ /* fallback to SMTP if none was specified */
+ g_warning ("No transport protocol was specified for store %d (%s)",
+ modest_protocol_get_type_id (store_proto),
+ modest_protocol_get_display_name (store_proto));
+ transport_protocol = MODEST_PROTOCOLS_TRANSPORT_SMTP;
+ }
+
+ modest_security_options_view_save_settings (
+ MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security),
+ priv->settings);
}
-
- /* now we transport the transport account settings */
- transport_settings = modest_account_settings_get_transport_settings (priv->settings);
+
+ /* now we store the common transport account settings */
modest_server_account_settings_set_hostname (transport_settings, transport_hostname);
modest_server_account_settings_set_username (transport_settings, username);
modest_server_account_settings_set_password (transport_settings, password);
modest_server_account_settings_set_protocol (transport_settings, transport_protocol);
- modest_server_account_settings_set_security (transport_settings, transport_security);
- modest_server_account_settings_set_auth_protocol (transport_settings, transport_auth_protocol);
- if (transport_port != 0)
- modest_server_account_settings_set_port (transport_settings, transport_port);
g_object_unref (transport_settings);
g_free (transport_hostname);
email_address = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_email));
modest_account_settings_set_fullname (priv->settings, fullname);
modest_account_settings_set_email_address (priv->settings, email_address);
- /* we don't set retrieve type to preserve advanced settings if any. By default account settings
- are set to headers only */
+ /* we don't set retrieve type to preserve advanced settings if
+ any. By default account settings are set to headers only */
/* Save the connection-specific SMTP server accounts. */
modest_account_settings_set_use_connection_specific_smtp
*/
#include <string.h> /* for strcmp */
+#include <modest-protocol-registry.h>
+#include <modest-runtime.h>
#include "modest-presets.h"
#include <stdio.h>
-ModestPresetsServerType
+ModestProtocolType
modest_presets_get_info_server_type (ModestPresets *self,
const gchar *provider_id,
gboolean incoming_server)
{
- ModestPresetsServerType info = MODEST_PRESETS_SERVER_TYPE_NONE;
+ ModestProtocolType protocol_type = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
gchar *val = NULL;
g_return_val_if_fail (self && self->keyfile, 0);
+ protocol_registry = modest_runtime_get_protocol_registry ();
if (incoming_server) {
val = g_key_file_get_string (self->keyfile, provider_id,
MODEST_PRESETS_KEY_INCOMING, NULL);
if (!val)
- return info;
+ return protocol_type;
g_free (val);
val = g_key_file_get_string (self->keyfile, provider_id,
MODEST_PRESETS_KEY_MAILBOX_TYPE,NULL);
- if (val && strcmp (val, "pop") == 0)
- info = MODEST_PRESETS_SERVER_TYPE_POP;
- if (val && strcmp (val, "imap") == 0)
- info = MODEST_PRESETS_SERVER_TYPE_IMAP;
+
+ protocol = modest_protocol_registry_get_protocol_by_name (protocol_registry, MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS, val);
+ if (protocol == NULL)
+ return protocol_type;
+ protocol_type = modest_protocol_get_type_id (protocol);
} else {
val = g_key_file_get_string (self->keyfile, provider_id,
MODEST_PRESETS_KEY_OUTGOING, NULL);
if (!val)
- return info;
- info = MODEST_PRESETS_SERVER_TYPE_SMTP;
+ return protocol_type;
+
+ protocol_type = MODEST_PROTOCOLS_TRANSPORT_SMTP;
}
g_free (val);
/* debug: */
/* g_message ("provider id: %s, server type: %d", provider_id, info); */
- return info;
+ return protocol_type;
}
-ModestPresetsSecurity
+ModestProtocolType
modest_presets_get_info_server_security (ModestPresets *self, const gchar *provider_id,
gboolean incoming_server)
{
- ModestPresetsSecurity info = MODEST_PRESETS_SECURITY_NONE;
+ ModestProtocolType protocol_type = MODEST_PROTOCOLS_CONNECTION_NONE;
gchar *val = NULL;
- g_return_val_if_fail (self && self->keyfile, MODEST_PRESETS_SECURITY_NONE);
+ g_return_val_if_fail (self && self->keyfile, MODEST_PROTOCOLS_CONNECTION_NONE);
if (incoming_server) {
val = g_key_file_get_string (self->keyfile, provider_id,
MODEST_PRESETS_KEY_INCOMING, NULL);
if (val) {
g_free (val);
+
val = g_key_file_get_string (self->keyfile, provider_id,
- MODEST_PRESETS_KEY_APOP, NULL);
- if (val && strcmp(val, "true") == 0)
- info |= MODEST_PRESETS_SECURITY_APOP;
- g_free(val);
+ MODEST_PRESETS_KEY_INCOMING_SECURITY, NULL);
+ if (val && ((strcmp (val, "1") == 0) || (strcmp (val, "2") == 0))) {
+ protocol_type = MODEST_PROTOCOLS_CONNECTION_SSL;
+ }
+ g_free (val);
+ }
+ } else /* outgoing: */ {
+ val = g_key_file_get_string (self->keyfile, provider_id,
+ MODEST_PRESETS_KEY_OUTGOING, NULL);
+ if (val) {
+ g_free (val);
val = g_key_file_get_string (self->keyfile, provider_id,
+ MODEST_PRESETS_KEY_SECURE_SMTP, NULL);
+ /* printf("debug: %s: provider_id=%s, secure-smtp val=%s\n", __FUNCTION__, provider_id, val); */
+ if (val && strcmp(val,"true") == 0)
+ protocol_type = MODEST_PROTOCOLS_CONNECTION_SSL;
+ g_free(val);
+ }
+ }
+
+ return protocol_type;
+}
+
+gboolean
+modest_presets_get_info_server_use_alternate_port (ModestPresets *self, const gchar *provider_id,
+ gboolean incoming_server)
+{
+ gboolean result = FALSE;
+ gchar *val = NULL;
+
+ g_return_val_if_fail (self && self->keyfile, MODEST_PROTOCOLS_CONNECTION_NONE);
+
+ if (incoming_server) {
+ val = g_key_file_get_string (self->keyfile, provider_id,
+ MODEST_PRESETS_KEY_INCOMING, NULL);
+ if (val) {
+ g_free (val);
+
+ val = g_key_file_get_string (self->keyfile, provider_id,
MODEST_PRESETS_KEY_INCOMING_SECURITY, NULL);
- if (val && strcmp (val, "1") == 0)
- info |= MODEST_PRESETS_SECURITY_SECURE_INCOMING;
- if (val && strcmp (val, "2") == 0) {
- info |= MODEST_PRESETS_SECURITY_SECURE_INCOMING;
- info |= MODEST_PRESETS_SECURITY_SECURE_INCOMING_ALTERNATE_PORT;
+ if (val && (strcmp (val, "2") == 0)) {
+ result = TRUE;
}
g_free (val);
}
+ }
+
+ return result;
+}
+
+ModestProtocolType
+modest_presets_get_info_server_auth (ModestPresets *self, const gchar *provider_id,
+ gboolean incoming_server)
+{
+ ModestProtocolType protocol_type = MODEST_PROTOCOLS_AUTH_NONE;
+ gchar *val = NULL;
+
+ g_return_val_if_fail (self && self->keyfile, MODEST_PROTOCOLS_AUTH_NONE);
+
+ if (incoming_server) {
+ val = g_key_file_get_string (self->keyfile, provider_id,
+ MODEST_PRESETS_KEY_INCOMING, NULL);
+ if (val) {
+ g_free (val);
+ val = g_key_file_get_string (self->keyfile, provider_id,
+ MODEST_PRESETS_KEY_APOP, NULL);
+ if (val && strcmp(val, "true") == 0)
+ protocol_type = MODEST_PROTOCOLS_AUTH_PASSWORD;
+ g_free(val);
+
+ }
} else /* outgoing: */ {
val = g_key_file_get_string (self->keyfile, provider_id,
MODEST_PRESETS_KEY_OUTGOING, NULL);
MODEST_PRESETS_KEY_SECURE_SMTP, NULL);
/* printf("debug: %s: provider_id=%s, secure-smtp val=%s\n", __FUNCTION__, provider_id, val); */
if (val && strcmp(val,"true") == 0)
- info |= MODEST_PRESETS_SECURITY_SECURE_SMTP;
+ protocol_type = MODEST_PROTOCOLS_AUTH_PASSWORD;
g_free(val);
}
}
- return info;
+ return protocol_type;
}
-
/*
* at the moment, this only for mac.com, which have a special SMTP port
*/
#define __MODEST_PRESETS_H__
#include <glib.h>
+#include <modest-protocol.h>
struct _ModestPresets {
/* private data: don't touch */
};
typedef struct _ModestPresets ModestPresets;
-typedef enum _ModestPresetsServerType {
- MODEST_PRESETS_SERVER_TYPE_NONE,
- MODEST_PRESETS_SERVER_TYPE_IMAP,
- MODEST_PRESETS_SERVER_TYPE_POP,
- MODEST_PRESETS_SERVER_TYPE_SMTP
-} ModestPresetsServerType;
-
-/** These are flags, which should be ORed.
- */
-typedef enum _ModestPresetsSecurity {
- MODEST_PRESETS_SECURITY_NONE = 0,
- MODEST_PRESETS_SECURITY_APOP = 1 << 0,
- MODEST_PRESETS_SECURITY_SECURE_SMTP = 1 << 1, /* if set, port will be 465
- * instead of 25 */
- MODEST_PRESETS_SECURITY_SECURE_INCOMING = 1 << 2,
- MODEST_PRESETS_SECURITY_SECURE_INCOMING_ALTERNATE_PORT = 1 << 3, /* POP3S=>995, IMAPS=>993 */
-} ModestPresetsSecurity;
-
-/* typedef enum _ModestPresetsInfo ModestPresetsInfo; */
-
/**
* modest_presets_new:
*
* get information about some incoming or outgoing mailserver
*
- * Returns: a ModestPresetsServerType with the required information
+ * Returns: a #ModestProtocolType with the required information
*/
-ModestPresetsServerType modest_presets_get_info_server_type (ModestPresets *self,
- const gchar *provider_id,
- gboolean incoming_server);
+ModestProtocolType modest_presets_get_info_server_type (ModestPresets *self,
+ const gchar *provider_id,
+ gboolean incoming_server);
+
+/**
+ * modest_presets_get_info_server_security:
+ * @self: a valid ModestPresets instance
+ * @provider_id: ID of the provider
+ * @incoming_server: get the incoming mailserver if TRUE, get the
+ * outgoing server otherwise
+ *
+ * get information about some incoming or outgoing mailserver
+ *
+ * Returns: #ModestProtocolType with server auth
+ */
+ModestProtocolType modest_presets_get_info_server_auth (ModestPresets *self,
+ const gchar *provider_id,
+ gboolean incoming_server);
+
+/**
+ * modest_presets_get_info_server_security:
+ * @self: a valid ModestPresets instance
+ * @provider_id: ID of the provider
+ * @incoming_server: get the incoming mailserver if TRUE, get the
+ * outgoing server otherwise
+ *
+ * get information about some incoming or outgoing mailserver
+ *
+ * Returns: #ModestProtocolType with server security
+ */
+ModestProtocolType modest_presets_get_info_server_security (ModestPresets *self,
+ const gchar *provider_id,
+ gboolean incoming_server);
/**
* modest_presets_get_info_server_security:
*
* get information about some incoming or outgoing mailserver
*
- * Returns: ModestPresetsSecurity ORable flags with the required information
+ * Returns: %TRUE if we should use the alternate port.
*/
-ModestPresetsSecurity modest_presets_get_info_server_security (ModestPresets *self,
- const gchar *provider_id,
- gboolean incoming_server);
+gboolean modest_presets_get_info_server_use_alternate_port (ModestPresets *self,
+ const gchar *provider_id,
+ gboolean incoming_server);
/**
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * 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-account-settings-dialog.h"
-#include <glib/gi18n.h>
-#include <gtk/gtknotebook.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkcheckbutton.h>
-#include <gtk/gtkmessagedialog.h>
-#include <gtk/gtkstock.h>
-#include "modest-hildon-includes.h"
-
-#include "widgets/modest-serversecurity-combo-box.h"
-#include "widgets/modest-secureauth-combo-box.h"
-#include "widgets/modest-validating-entry.h"
-#include "widgets/modest-retrieve-combo-box.h"
-#include "widgets/modest-limit-retrieve-combo-box.h"
-#include "modest-text-utils.h"
-#include "modest-account-mgr.h"
-#include "modest-account-mgr-helpers.h" /* For modest_account_mgr_get_account_data(). */
-#include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
-#include "modest-protocol-info.h"
-#include "maemo/modest-connection-specific-smtp-window.h"
-#include "maemo/modest-signature-editor-dialog.h"
-#include <modest-utils.h>
-#include "maemo/modest-maemo-utils.h"
-#include "widgets/modest-ui-constants.h"
-#include <tny-account.h>
-#include <tny-status.h>
-
-#include <gconf/gconf-client.h>
-#include <string.h> /* For strlen(). */
-
-/* Include config.h so that _() works: */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define PORT_MIN 1
-#define PORT_MAX 65535
-
-G_DEFINE_TYPE (ModestAccountSettingsDialog, modest_account_settings_dialog, GTK_TYPE_DIALOG);
-
-#define ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG, ModestAccountSettingsDialogPrivate))
-
-typedef struct _ModestAccountSettingsDialogPrivate ModestAccountSettingsDialogPrivate;
-
-struct _ModestAccountSettingsDialogPrivate
-{
-};
-
-static void
-enable_buttons (ModestAccountSettingsDialog *self);
-
-static gboolean
-save_configuration (ModestAccountSettingsDialog *dialog);
-
-static const gchar * null_means_empty (const gchar * str);
-
-static const gchar *
-null_means_empty (const gchar * str)
-{
- return str ? str : "";
-}
-
-
-static void
-modest_account_settings_dialog_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
-{
- switch (property_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-modest_account_settings_dialog_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
-{
- switch (property_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-modest_account_settings_dialog_dispose (GObject *object)
-{
- if (G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->dispose)
- G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->dispose (object);
-}
-
-static void
-modest_account_settings_dialog_finalize (GObject *object)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (object);
-
- if (self->account_name)
- g_free (self->account_name);
-
- if (self->original_account_title)
- g_free (self->original_account_title);
-
- if (self->account_manager)
- g_object_unref (G_OBJECT (self->account_manager));
-
- if (self->signature_dialog)
- gtk_widget_destroy (self->signature_dialog);
-
- if (self->settings) {
- g_object_unref (self->settings);
- self->settings = NULL;
- }
-
- G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->finalize (object);
-}
-
-static void
-on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data);
-
-static void
-on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data);
-
-static void
-on_modified_combobox_changed (GtkComboBox *widget, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- self->modified = TRUE;
-}
-
-static void
-on_modified_entry_changed (GtkEditable *editable, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- self->modified = TRUE;
-}
-
-static void
-on_modified_checkbox_toggled (GtkToggleButton *togglebutton, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- self->modified = TRUE;
-}
-
-static void
-on_modified_number_editor_changed (HildonNumberEditor *number_editor, gint new_value, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- self->modified = TRUE;
-}
-
-static void
-on_number_editor_notify (HildonNumberEditor *editor, GParamSpec *arg1, gpointer user_data)
-{
- ModestAccountSettingsDialog *dialog = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- gint value = hildon_number_editor_get_value (editor);
-
- gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, value > 0);
-}
-
-/* Set a modified boolean whenever the widget is changed,
- * so we can check for it later.
- */
-static void
-connect_for_modified (ModestAccountSettingsDialog *self, GtkWidget *widget)
-{
- if (HILDON_IS_NUMBER_EDITOR (widget)) {
- g_signal_connect (G_OBJECT (widget), "notify::value",
- G_CALLBACK (on_modified_number_editor_changed), self);
- g_signal_connect (G_OBJECT (widget), "notify", G_CALLBACK (on_number_editor_notify), self);
- }
- else if (GTK_IS_ENTRY (widget)) {
- g_signal_connect (G_OBJECT (widget), "changed",
- G_CALLBACK (on_modified_entry_changed), self);
- } else if (GTK_IS_COMBO_BOX (widget)) {
- g_signal_connect (G_OBJECT (widget), "changed",
- G_CALLBACK (on_modified_combobox_changed), self);
- } else if (GTK_IS_TOGGLE_BUTTON (widget)) {
- g_signal_connect (G_OBJECT (widget), "toggled",
- G_CALLBACK (on_modified_checkbox_toggled), self);
- }
-}
-
-static void
-on_caption_entry_changed (GtkEditable *editable, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- g_assert(self);
- enable_buttons(self);
-}
-
-static void
-on_caption_combobox_changed (GtkComboBox *widget, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- g_assert(self);
- enable_buttons(self);
-}
-
-/** This is a convenience function to create a caption containing a mandatory widget.
- * When the widget is edited, the enable_buttons() vfunc will be called.
- */
-static GtkWidget* create_caption_new_with_asterisk(ModestAccountSettingsDialog *self,
- GtkSizeGroup *group,
- const gchar *value,
- GtkWidget *control,
- GtkWidget *icon,
- HildonCaptionStatus flag)
-{
- GtkWidget *caption = NULL;
-
- /* Note: Previously, the translated strings already contained the "*",
- * Comment out this code if they do again.
- */
- /* Add a * character to indicate mandatory fields,
- * as specified in our "Email UI Specification": */
- if (flag == HILDON_CAPTION_MANDATORY) {
- gchar* title = g_strdup_printf("%s*", value);
- caption = hildon_caption_new (group, title, control, icon, flag);
- g_free(title);
- }
- else
- caption = hildon_caption_new (group, value, control, icon, flag);
-
- /* Connect to the appropriate changed signal for the widget,
- * so we can ask for the prev/next buttons to be enabled/disabled appropriately:
- */
- if (GTK_IS_ENTRY (control)) {
- g_signal_connect (G_OBJECT (control), "changed",
- G_CALLBACK (on_caption_entry_changed), self);
-
- }
- else if (GTK_IS_COMBO_BOX (control)) {
- g_signal_connect (G_OBJECT (control), "changed",
- G_CALLBACK (on_caption_combobox_changed), self);
- }
-
- return caption;
-}
-
-static void
-on_entry_invalid_account_title_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
-{
- gchar *tmp, *msg;
-
- tmp = g_strndup (account_title_forbidden_chars, ACCOUNT_TITLE_FORBIDDEN_CHARS_LENGTH);
- msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
-
- hildon_banner_show_information(GTK_WIDGET (self), NULL, msg);
-
- g_free (msg);
- g_free (tmp);
-}
-
-static void
-on_entry_invalid_fullname_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
-{
- gchar *tmp, *msg;
-
- tmp = g_strndup (user_name_forbidden_chars, USER_NAME_FORBIDDEN_CHARS_LENGTH);
- msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
-
- hildon_banner_show_information(GTK_WIDGET (self), NULL, msg);
-
- g_free (msg);
- g_free (tmp);
-}
-
-
-static void
-on_entry_max (ModestValidatingEntry *self, gpointer user_data)
-{
- hildon_banner_show_information(GTK_WIDGET (self), NULL,
- _CS("ckdg_ib_maximum_characters_reached"));
-}
-
-static GtkWidget*
-create_page_account_details (ModestAccountSettingsDialog *self)
-{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
- GtkAdjustment *focus_adjustment = NULL;
-
- /* Create a size group to be used by all captions.
- * Note that HildonCaption does not create a default size group if we do not specify one.
- * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
- GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
- GtkWidget *scrollwin = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
- /* The description widgets: */
- self->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
- /* Do use auto-capitalization: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_account_title),
- HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
- GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_account_title"),
- self->entry_account_title, NULL, HILDON_CAPTION_MANDATORY);
- gtk_widget_show (self->entry_account_title);
- connect_for_modified (self, self->entry_account_title);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* Prevent the use of some characters in the account title,
- * as required by our UI specification: */
- GList *list_prevent = NULL;
- list_prevent = g_list_append (list_prevent, "\\");
- list_prevent = g_list_append (list_prevent, "/");
- list_prevent = g_list_append (list_prevent, ":");
- list_prevent = g_list_append (list_prevent, "*");
- list_prevent = g_list_append (list_prevent, "?");
- list_prevent = g_list_append (list_prevent, "\"");
- list_prevent = g_list_append (list_prevent, "<");
- list_prevent = g_list_append (list_prevent, ">");
- list_prevent = g_list_append (list_prevent, "|");
- list_prevent = g_list_append (list_prevent, "^");
- modest_validating_entry_set_unallowed_characters (
- MODEST_VALIDATING_ENTRY (self->entry_account_title), list_prevent);
- g_list_free (list_prevent);
- modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_account_title),
- on_entry_invalid_account_title_character, self);
-
- /* Set max length as in the UI spec:
- * The UI spec seems to want us to show a dialog if we hit the maximum. */
- gtk_entry_set_max_length (GTK_ENTRY (self->entry_account_title), 64);
- modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_account_title),
- on_entry_max, self);
-
- /* The retrieve combobox: */
- self->combo_retrieve = GTK_WIDGET (modest_retrieve_combo_box_new ());
- caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_retrievetype"),
- self->combo_retrieve, NULL, HILDON_CAPTION_MANDATORY);
- gtk_widget_show (self->combo_retrieve);
- connect_for_modified (self, self->combo_retrieve);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* The limit-retrieve combobox: */
- self->combo_limit_retrieve = GTK_WIDGET (modest_limit_retrieve_combo_box_new ());
- caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_limit_retrieve"),
- self->combo_limit_retrieve, NULL, HILDON_CAPTION_MANDATORY);
- gtk_widget_show (self->combo_limit_retrieve);
- connect_for_modified (self, self->combo_limit_retrieve);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* The leave-messages widgets: */
- if(!self->checkbox_leave_messages)
- self->checkbox_leave_messages = gtk_check_button_new ();
- if (!self->caption_leave_messages) {
- self->caption_leave_messages = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_leave_on_server"),
- self->checkbox_leave_messages, NULL, HILDON_CAPTION_MANDATORY);
- }
-
- gtk_widget_show (self->checkbox_leave_messages);
- connect_for_modified (self, self->checkbox_leave_messages);
- gtk_box_pack_start (GTK_BOX (box), self->caption_leave_messages, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (self->caption_leave_messages);
-
- g_object_unref (sizegroup);
-
- gtk_widget_show (GTK_WIDGET (box));
-
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollwin), box);
- gtk_widget_show (scrollwin);
-
- focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
- gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
-
- return GTK_WIDGET (scrollwin);
-}
-
-static gchar*
-get_entered_account_title (ModestAccountSettingsDialog *dialog)
-{
- const gchar* account_title =
- gtk_entry_get_text (GTK_ENTRY (dialog->entry_account_title));
- if (!account_title || (strlen (account_title) == 0))
- return NULL;
- else {
- /* Strip it of whitespace at the start and end: */
- gchar *result = g_strdup (account_title);
- result = g_strstrip (result);
-
- if (!result)
- return NULL;
-
- if (strlen (result) == 0) {
- g_free (result);
- return NULL;
- }
-
- return result;
- }
-}
-
-
-static void
-on_button_signature (GtkButton *button, gpointer user_data)
-{
- ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- gint response;
-
- /* Create the window, if necessary: */
- if (!(self->signature_dialog)) {
- self->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ());
-
- gboolean use_signature = modest_account_settings_get_use_signature (self->settings);
- const gchar *signature = modest_account_settings_get_signature(self->settings);
- gchar* account_title = get_entered_account_title (self);
- modest_signature_editor_dialog_set_settings (
- MODEST_SIGNATURE_EDITOR_DIALOG (self->signature_dialog),
- use_signature, signature, account_title);
-
- g_free (account_title);
- account_title = NULL;
- signature = NULL;
- }
-
- /* Show the window: */
- modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
- GTK_WINDOW (self->signature_dialog));
-
- response = gtk_dialog_run (GTK_DIALOG (self->signature_dialog));
- gtk_widget_hide (self->signature_dialog);
- if (response != GTK_RESPONSE_OK) {
- /* Destroy the widget now, and its data: */
- gtk_widget_destroy (self->signature_dialog);
- self->signature_dialog = NULL;
- } else {
- /* Mark modified, so we use the dialog's data later: */
- self->modified = TRUE;
- }
-}
-
-static GtkWidget*
-create_page_user_details (ModestAccountSettingsDialog *self)
-{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
- GtkAdjustment *focus_adjustment = NULL;
-
- /* Create a size group to be used by all captions.
- * Note that HildonCaption does not create a default size group if we do not specify one.
- * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
- GtkSizeGroup* sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
- GtkWidget *scrollwin = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
- /* The name widgets: */
- self->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
-
- /* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_name), HILDON_GTK_INPUT_MODE_FULL);
- /* Set max length as in the UI spec:
- * The UI spec seems to want us to show a dialog if we hit the maximum. */
- gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_name), 64);
- modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_name),
- on_entry_max, self);
- GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup,
- _("mcen_li_emailsetup_name"), self->entry_user_name, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->entry_user_name);
- connect_for_modified (self, self->entry_user_name);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
-
- /* Prevent the use of some characters in the name,
- * as required by our UI specification: */
- GList *list_prevent = NULL;
- list_prevent = g_list_append (list_prevent, "<");
- list_prevent = g_list_append (list_prevent, ">");
- modest_validating_entry_set_unallowed_characters (
- MODEST_VALIDATING_ENTRY (self->entry_user_name), list_prevent);
- g_list_free (list_prevent);
- modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_user_name),
- on_entry_invalid_fullname_character, self);
-
- /* The username widgets: */
- self->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
- /* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_username), HILDON_GTK_INPUT_MODE_FULL);
- caption = create_caption_new_with_asterisk (self, sizegroup, _("mail_fi_username"),
- self->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
- gtk_widget_show (self->entry_user_username);
- connect_for_modified (self, self->entry_user_username);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* Prevent the use of some characters in the username,
- * as required by our UI specification: */
- modest_validating_entry_set_unallowed_characters_whitespace (
- MODEST_VALIDATING_ENTRY (self->entry_user_username));
- modest_validating_entry_set_func (MODEST_VALIDATING_ENTRY (self->entry_user_username),
- modest_maemo_utils_on_entry_invalid_character,
- self);
-
- /* Set max length as in the UI spec:
- * The UI spec seems to want us to show a dialog if we hit the maximum. */
- gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_username), 64);
- modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_username),
- on_entry_max, self);
-
- /* The password widgets: */
- self->entry_user_password = gtk_entry_new ();
- /* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_password),
- HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
- gtk_entry_set_visibility (GTK_ENTRY (self->entry_user_password), FALSE);
- /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_user_password), '*'); */
- caption = create_caption_new_with_asterisk (self, sizegroup,
- _("mail_fi_password"), self->entry_user_password, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->entry_user_password);
- connect_for_modified (self, self->entry_user_password);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* The email address widgets: */
- self->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
- /* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
- caption = create_caption_new_with_asterisk (self, sizegroup,
- _("mcen_li_emailsetup_email_address"), self->entry_user_email, NULL, HILDON_CAPTION_MANDATORY);
- gtk_entry_set_text (GTK_ENTRY (self->entry_user_email), MODEST_EXAMPLE_EMAIL_ADDRESS); /* Default text. */
- gtk_widget_show (self->entry_user_email);
- connect_for_modified (self, self->entry_user_email);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* Set max length as in the UI spec:
- * The UI spec seems to want us to show a dialog if we hit the maximum. */
- gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_email), 64);
- modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_email),
- on_entry_max, self);
-
- /* Signature button: */
- if (!self->button_signature)
- self->button_signature = gtk_button_new_with_label (_("mcen_bd_edit"));
- caption = hildon_caption_new (sizegroup, _("mcen_fi_email_signature"),
- self->button_signature, NULL, HILDON_CAPTION_OPTIONAL);
- hildon_caption_set_child_expand (HILDON_CAPTION (caption), FALSE);
- gtk_widget_show (self->button_signature);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- g_object_unref (sizegroup);
-
- g_signal_connect (G_OBJECT (self->button_signature), "clicked",
- G_CALLBACK (on_button_signature), self);
-
- gtk_widget_show (GTK_WIDGET (box));
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollwin), box);
- gtk_widget_show (scrollwin);
-
- focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
- gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
-
- return GTK_WIDGET (scrollwin);
-}
-
-/** Change the caption title for the incoming server,
- * as specified in the UI spec:
- */
-static void update_incoming_server_title (ModestAccountSettingsDialog *self, ModestTransportStoreProtocol protocol)
-{
- const gchar* type =
- (protocol == MODEST_PROTOCOL_STORE_POP ?
- _("mail_fi_emailtype_pop3") :
- _("mail_fi_emailtype_imap") );
-
-
- /* Note that this produces a compiler warning,
- * because the compiler does not know that the translated string will have a %s in it.
- * I do not see a way to avoid the warning while still using these Logical IDs. murrayc. */
- gchar* incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), type);
-
- /* This is a mandatory field, so add a *. This is usually done by
- * create_caption_new_with_asterisk() but we can't use that here. */
- gchar *with_asterisk = g_strconcat (incomingserver_title, "*", NULL);
- g_free (incomingserver_title);
-
- g_object_set (G_OBJECT (self->caption_incoming), "label", with_asterisk, NULL);
- g_free(with_asterisk);
-}
-
-/** Change the caption title for the incoming server,
- * as specified in the UI spec:
- */
-static void update_incoming_server_security_choices (ModestAccountSettingsDialog *self, ModestTransportStoreProtocol protocol)
-{
- /* Fill the combo with appropriately titled choices for POP or IMAP. */
- /* The choices are the same, but the titles are different, as in the UI spec. */
- modest_serversecurity_combo_box_fill (
- MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security), protocol);
-}
-
-static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self)
-{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
-
- /* Create a size group to be used by all captions.
- * Note that HildonCaption does not create a default size group if we do not specify one.
- * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
- GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-
- /* The incoming server widgets: */
- if(!self->entry_incomingserver)
- self->entry_incomingserver = gtk_entry_new ();
- /* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
-
- if (self->caption_incoming)
- gtk_widget_destroy (self->caption_incoming);
-
- /* The caption title will be updated in update_incoming_server_title().
- * so this default text will never be seen: */
- /* (Note: Changing the title seems pointless. murrayc) */
- self->caption_incoming = create_caption_new_with_asterisk (self, sizegroup,
- "Incoming Server", self->entry_incomingserver, NULL, HILDON_CAPTION_MANDATORY);
- gtk_widget_show (self->entry_incomingserver);
- connect_for_modified (self, self->entry_incomingserver);
- gtk_box_pack_start (GTK_BOX (box), self->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (self->caption_incoming);
-
- /* The secure connection widgets: */
- /* This will be filled by update_incoming_server_security_choices(). */
- if (!self->combo_incoming_security)
- self->combo_incoming_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
- GtkWidget *caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
- self->combo_incoming_security, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->combo_incoming_security);
- connect_for_modified (self, self->combo_incoming_security);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* Show a default port number when the security method changes, as per the UI spec: */
- g_signal_connect (G_OBJECT (self->combo_incoming_security), "changed", (GCallback)on_combo_incoming_security_changed, self);
-
-
- /* The port widgets: */
- if (!self->entry_incoming_port)
- self->entry_incoming_port = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
- caption = hildon_caption_new (sizegroup, _("mcen_fi_emailsetup_port"),
- self->entry_incoming_port, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->entry_incoming_port);
- connect_for_modified (self, self->entry_incoming_port);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* The secure authentication widgets: */
- if(!self->checkbox_incoming_auth)
- self->checkbox_incoming_auth = gtk_check_button_new ();
- caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
- self->checkbox_incoming_auth, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->checkbox_incoming_auth);
- connect_for_modified (self, self->checkbox_incoming_auth);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
-
- g_object_unref (sizegroup);
- gtk_widget_show (caption);
-
- gtk_widget_show (GTK_WIDGET (box));
-
- return GTK_WIDGET (box);
-}
-
-static void
-on_toggle_button_changed (GtkToggleButton *togglebutton, gpointer user_data)
-{
- GtkWidget *widget = GTK_WIDGET (user_data);
-
- /* Enable the widget only if the toggle button is active: */
- const gboolean enable = gtk_toggle_button_get_active (togglebutton);
- gtk_widget_set_sensitive (widget, enable);
-}
-
-/* Make the sensitivity of a widget depend on a toggle button.
- */
-static void
-enable_widget_for_togglebutton (GtkWidget *widget, GtkToggleButton* button)
-{
- g_signal_connect (G_OBJECT (button), "toggled",
- G_CALLBACK (on_toggle_button_changed), widget);
-
- /* Set the starting sensitivity: */
- on_toggle_button_changed (button, widget);
-}
-
-static void
-on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
-{
- ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- ModestConnectionSpecificSmtpWindow *smtp_win;
-
- /* Create the window if necessary: */
- smtp_win = modest_connection_specific_smtp_window_new ();
- modest_connection_specific_smtp_window_fill_with_connections (smtp_win, self->account_manager);
-
- /* Show the window: */
- modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (smtp_win));
- gtk_widget_show (GTK_WIDGET (smtp_win));
- self->modified = TRUE;
-}
-
-static void
-on_combo_outgoing_auth_changed (GtkComboBox *widget, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
-
- ModestAuthProtocol protocol_security =
- modest_secureauth_combo_box_get_active_secureauth (
- MODEST_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth));
- const gboolean secureauth_used = protocol_security != MODEST_PROTOCOL_AUTH_NONE;
-
- gtk_widget_set_sensitive (self->caption_outgoing_username, secureauth_used);
- gtk_widget_set_sensitive (self->caption_outgoing_password, secureauth_used);
-}
-
-static void
-on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
-
- const gint port_number =
- modest_serversecurity_combo_box_get_active_serversecurity_port (
- MODEST_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security));
-
- if(port_number != 0) {
- hildon_number_editor_set_value (
- HILDON_NUMBER_EDITOR (self->entry_outgoing_port), port_number);
- }
-}
-
-static void
-on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
- ModestConnectionProtocol protocol_security_incoming;
- gint port_number;
-
- port_number =
- modest_serversecurity_combo_box_get_active_serversecurity_port (
- MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
-
- if(port_number != 0) {
- hildon_number_editor_set_value (
- HILDON_NUMBER_EDITOR (self->entry_incoming_port), port_number);
- }
-
- protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
- gtk_widget_set_sensitive (self->checkbox_incoming_auth, !modest_protocol_info_is_secure (protocol_security_incoming));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth), modest_protocol_info_is_secure (protocol_security_incoming));
-
-}
-
-
-static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
-{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
- GtkAdjustment *focus_adjustment = NULL;
-
- /* Put it all in a scrolled window, so that all widgets can be
- * accessed even when the on-screen keyboard is visible: */
- GtkWidget *scrollwin = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
- /* Create a size group to be used by all captions.
- * Note that HildonCaption does not create a default size group if we do not specify one.
- * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
- GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-
- /* The outgoing server widgets: */
- if (!self->entry_outgoingserver)
- self->entry_outgoingserver = gtk_entry_new ();
- /* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
- GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup,
- _("mcen_li_emailsetup_smtp"), self->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->entry_outgoingserver);
- connect_for_modified (self, self->entry_outgoingserver);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* The secure authentication widgets: */
- if (!self->combo_outgoing_auth)
- self->combo_outgoing_auth = GTK_WIDGET (modest_secureauth_combo_box_new ());
- caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
- self->combo_outgoing_auth, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->combo_outgoing_auth);
- connect_for_modified (self, self->combo_outgoing_auth);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* Dim the outgoing username and password when no secure authentication is used, as per the UI spec: */
- g_signal_connect (G_OBJECT (self->combo_outgoing_auth), "changed", (GCallback)on_combo_outgoing_auth_changed, self);
-
- /* The username widgets: */
- self->entry_outgoing_username = GTK_WIDGET (modest_validating_entry_new ());
- /* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoing_username), HILDON_GTK_INPUT_MODE_FULL);
- self->caption_outgoing_username = create_caption_new_with_asterisk (self, sizegroup, _("mail_fi_username"),
- self->entry_outgoing_username, NULL, HILDON_CAPTION_MANDATORY);
- gtk_widget_show (self->entry_outgoing_username);
- connect_for_modified (self, self->entry_outgoing_username);
- gtk_box_pack_start (GTK_BOX (box), self->caption_outgoing_username, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (self->caption_outgoing_username);
-
- /* Prevent the use of some characters in the username,
- * as required by our UI specification: */
- modest_validating_entry_set_unallowed_characters_whitespace (
- MODEST_VALIDATING_ENTRY (self->entry_outgoing_username));
-
- /* Set max length as in the UI spec:
- * The UI spec seems to want us to show a dialog if we hit the maximum. */
- gtk_entry_set_max_length (GTK_ENTRY (self->entry_outgoing_username), 64);
- modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_outgoing_username),
- on_entry_max, self);
-
- /* The password widgets: */
- self->entry_outgoing_password = gtk_entry_new ();
- /* Auto-capitalization is the default, so let's turn it off: */
- hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoing_password),
- HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
- gtk_entry_set_visibility (GTK_ENTRY (self->entry_outgoing_password), FALSE);
- /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_outgoing_password), '*'); */
- self->caption_outgoing_password = create_caption_new_with_asterisk (self, sizegroup,
- _("mail_fi_password"), self->entry_outgoing_password, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->entry_outgoing_password);
- connect_for_modified (self, self->entry_outgoing_password);
- gtk_box_pack_start (GTK_BOX (box), self->caption_outgoing_password, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (self->caption_outgoing_password);
-
- /* The secure connection widgets: */
- /* This will be filled and set with modest_serversecurity_combo_box_fill()
- * and modest_serversecurity_combo_box_set_active_serversecurity().
- */
- if (!self->combo_outgoing_security)
-
- self->combo_outgoing_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
- caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
- self->combo_outgoing_security, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->combo_outgoing_security);
- connect_for_modified (self, self->combo_outgoing_security);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* Show a default port number when the security method changes, as per the UI spec: */
- g_signal_connect (G_OBJECT (self->combo_outgoing_security), "changed", (GCallback)on_combo_outgoing_security_changed, self);
-
- /* The port widgets: */
- if (!self->entry_outgoing_port)
- self->entry_outgoing_port = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
- caption = hildon_caption_new (sizegroup, _("mcen_fi_emailsetup_port"),
- self->entry_outgoing_port, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->entry_outgoing_port);
- connect_for_modified (self, self->entry_outgoing_port);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- GtkWidget *separator = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (separator);
-
- /* connection-specific checkbox: */
- if (!self->checkbox_outgoing_smtp_specific) {
- self->checkbox_outgoing_smtp_specific = gtk_check_button_new ();
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific),
- FALSE);
- }
- caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_connection_smtp"),
- self->checkbox_outgoing_smtp_specific, NULL, HILDON_CAPTION_OPTIONAL);
- gtk_widget_show (self->checkbox_outgoing_smtp_specific);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
- connect_for_modified (self, self->checkbox_outgoing_smtp_specific);
-
- /* Connection-specific SMTP-Severs Edit button: */
- if (!self->button_outgoing_smtp_servers)
- self->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_edit"));
- caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_optional_smtp"),
- self->button_outgoing_smtp_servers, NULL, HILDON_CAPTION_OPTIONAL);
- hildon_caption_set_child_expand (HILDON_CAPTION (caption), FALSE);
- gtk_widget_show (self->button_outgoing_smtp_servers);
- gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (caption);
-
- /* Only enable the button when the checkbox is checked: */
- enable_widget_for_togglebutton (self->button_outgoing_smtp_servers,
- GTK_TOGGLE_BUTTON (self->checkbox_outgoing_smtp_specific));
-
- g_object_unref (sizegroup);
-
- g_signal_connect (G_OBJECT (self->button_outgoing_smtp_servers), "clicked",
- G_CALLBACK (on_button_outgoing_smtp_servers), self);
-
- gtk_widget_show (GTK_WIDGET (box));
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrollwin), box);
- gtk_widget_show(scrollwin);
-
- focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
- gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
-
- return GTK_WIDGET (scrollwin);
-}
-
-static gboolean
-check_data (ModestAccountSettingsDialog *self)
-{
- /* Check that the title is not already in use: */
- gchar* account_title = get_entered_account_title (self);
- if (!account_title)
- return FALSE; /* Should be prevented already anyway. */
-
- if (strcmp(account_title, self->original_account_title) != 0) {
- /* Check the changed title: */
- const gboolean name_in_use = modest_account_mgr_account_with_display_name_exists (self->account_manager,
- account_title);
-
- if (name_in_use) {
- /* Warn the user via a dialog: */
- hildon_banner_show_information(NULL, NULL, _("mail_ib_account_name_already_existing"));
-
- g_free (account_title);
- return FALSE;
- }
- }
-
- g_free (account_title);
- account_title = NULL;
-
- /* Check that the email address is valid: */
- const gchar* email_address = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
- if ((!email_address) || (strlen(email_address) == 0)) {
- return FALSE;
- }
-
- if (!modest_text_utils_validate_email_address (email_address, NULL)) {
- /* Warn the user via a dialog: */
- hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email"));
-
- /* Return focus to the email address entry: */
- gtk_widget_grab_focus (self->entry_user_email);
- gtk_editable_select_region (GTK_EDITABLE (self->entry_user_email), 0, -1);
- return FALSE;
- }
-
- /* make sure the domain name for the incoming server is valid */
- const gchar* hostname = gtk_entry_get_text (GTK_ENTRY (self->entry_incomingserver));
- if ((!hostname) || (strlen(hostname) == 0)) {
- return FALSE;
- }
-
- if (!modest_text_utils_validate_domain_name (hostname)) {
- /* Warn the user via a dialog: */
- hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_servername"));
-
- /* Return focus to the email address entry: */
- gtk_widget_grab_focus (self->entry_incomingserver);
- gtk_editable_select_region (GTK_EDITABLE (self->entry_incomingserver), 0, -1);
- return FALSE;
- }
-
- /* make sure the domain name for the outgoing server is valid */
- const gchar* hostname2 = gtk_entry_get_text (GTK_ENTRY (self->entry_outgoingserver));
- if ((!hostname2) || (strlen(hostname2) == 0)) {
- return FALSE;
- }
-
- if (!modest_text_utils_validate_domain_name (hostname2)) {
- /* Warn the user via a dialog: */
- hildon_banner_show_information (self->entry_outgoingserver, NULL, _("mcen_ib_invalid_servername"));
-
- /* Return focus to the email address entry: */
- gtk_widget_grab_focus (self->entry_outgoingserver);
- gtk_editable_select_region (GTK_EDITABLE (self->entry_outgoingserver), 0, -1);
- return FALSE;
- }
-
- /* Find a suitable authentication method when secure authentication is desired */
-
- const gint port_num = hildon_number_editor_get_value (
- HILDON_NUMBER_EDITOR (self->entry_incoming_port));
- const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username));
-
- const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
- if (!modest_protocol_info_is_secure(protocol_security_incoming))
- {
- if (gtk_toggle_button_get_active (
- GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth))) {
- GError *error = NULL;
-
- GList *list_auth_methods =
- modest_utils_get_supported_secure_authentication_methods (self->incoming_protocol,
- hostname, port_num, username, GTK_WINDOW (self), &error);
- if (list_auth_methods) {
- /* Use the first supported method.
- * TODO: Should we prioritize them, to prefer a particular one? */
- GList* method;
- for (method = list_auth_methods; method != NULL; method = g_list_next(method))
- {
- ModestAuthProtocol proto = (ModestAuthProtocol)(GPOINTER_TO_INT(method->data));
- // Allow secure methods, e.g MD5 only
- if (modest_protocol_info_auth_is_secure(proto))
- {
- self->protocol_authentication_incoming = proto;
- break;
- }
- }
- g_list_free (list_auth_methods);
- }
-
- if (list_auth_methods == NULL ||
- !modest_protocol_info_auth_is_secure(self->protocol_authentication_incoming))
- {
- if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
- error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
- hildon_banner_show_information(GTK_WIDGET (self), NULL,
- _("mcen_ib_unableto_discover_auth_methods"));
-
- if(error != NULL)
- g_error_free(error);
-
- /* This is a nasty hack. jschmid. */
- /* Don't let the dialog close */
- /*g_signal_stop_emission_by_name (dialog, "response");*/
- return FALSE;
- }
- }
- }
-
- return TRUE;
-}
-/*
- */
-static void
-on_response (GtkDialog *wizard_dialog,
- gint response_id,
- gpointer user_data)
-{
- ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (wizard_dialog);
- enable_buttons (self);
-
- gboolean prevent_response = FALSE;
-
- /* Warn about unsaved changes: */
- if (response_id == GTK_RESPONSE_CANCEL && self->modified) {
- GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
- _("imum_nc_wizard_confirm_lose_changes")));
- /* TODO: These button names will be ambiguous, and not specified in the UI specification. */
-
- const gint dialog_response = gtk_dialog_run (dialog);
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
- if (dialog_response != GTK_RESPONSE_OK)
- prevent_response = TRUE;
- }
- /* Check for invalid input: */
- else if (response_id != GTK_RESPONSE_CANCEL && !check_data (self)) {
- prevent_response = TRUE;
- }
-
- if (prevent_response) {
- /* This is a nasty hack. murrayc. */
- /* Don't let the dialog close */
- g_signal_stop_emission_by_name (wizard_dialog, "response");
- return;
- }
-
- if (response_id == GTK_RESPONSE_OK) {
- /* Try to save the changes if modified (NB #59251): */
- if (self->modified)
- {
- const gboolean saved = save_configuration (self);
- if (saved) {
- /* Do not show the account-saved dialog if we are just saving this
- * temporarily, because from the user's point of view it will not
- * really be saved (saved + enabled) until later
- */
- if (modest_account_settings_get_account_name (self->settings) != NULL) {
- ModestServerAccountSettings *store_settings;
- ModestServerAccountSettings *transport_settings;
- const gchar *store_account_name;
- const gchar *transport_account_name;
-
-
- store_settings = modest_account_settings_get_store_settings (self->settings);
- transport_settings = modest_account_settings_get_transport_settings (self->settings);
- store_account_name = modest_server_account_settings_get_account_name (store_settings);
- transport_account_name = modest_server_account_settings_get_account_name (transport_settings);
-
- if (store_account_name) {
- modest_account_mgr_notify_account_update (self->account_manager,
- store_account_name);
- }
- if (transport_account_name) {
- modest_account_mgr_notify_account_update (self->account_manager,
- transport_account_name);
- }
- g_object_unref (store_settings);
- g_object_unref (transport_settings);
-
- hildon_banner_show_information(NULL, NULL, _("mcen_ib_advsetup_settings_saved"));
- }
- } else {
- hildon_banner_show_information (NULL, NULL, _("mail_ib_setting_failed"));
- }
- }
- }
-}
-
-static void
-modest_account_settings_dialog_init (ModestAccountSettingsDialog *self)
-{
- /* Create the notebook to be used by the GtkDialog base class:
- * Each page of the notebook will be a page of the wizard: */
- self->notebook = GTK_NOTEBOOK (gtk_notebook_new());
- self->settings = modest_account_settings_new ();
-
- /* Get the account manager object,
- * so we can check for existing accounts,
- * and create new accounts: */
- self->account_manager = modest_runtime_get_account_mgr ();
- g_assert (self->account_manager);
- g_object_ref (self->account_manager);
-
- self->protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_PASSWORD;
-
- /* Create the common pages,
- */
- self->page_account_details = create_page_account_details (self);
- self->page_user_details = create_page_user_details (self);
- self->page_incoming = create_page_incoming (self);
- self->page_outgoing = create_page_outgoing (self);
-
- /* Add the notebook pages: */
- gtk_notebook_append_page (self->notebook, self->page_account_details,
- gtk_label_new (_("mcen_ti_account_settings_account")));
- gtk_notebook_append_page (self->notebook, self->page_user_details,
- gtk_label_new (_("mcen_ti_account_settings_userinfo")));
- gtk_notebook_append_page (self->notebook, self->page_incoming,
- gtk_label_new (_("mcen_ti_advsetup_retrieval")));
- gtk_notebook_append_page (self->notebook, self->page_outgoing,
- gtk_label_new (_("mcen_ti_advsetup_sending")));
-
- GtkDialog *dialog = GTK_DIALOG (self);
- gtk_container_add (GTK_CONTAINER (dialog->vbox), GTK_WIDGET (self->notebook));
- gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), MODEST_MARGIN_HALF);
- gtk_widget_show (GTK_WIDGET (self->notebook));
-
- /* Add the buttons: */
- gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK);
- gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL);
-
- /* Connect to the dialog's response signal: */
- /* We use connect-before
- * so we can stop the signal emission,
- * to stop the default signal handler from closing the dialog.
- */
- g_signal_connect (G_OBJECT (self), "response",
- G_CALLBACK (on_response), self);
-
- self->modified = FALSE;
-
- /* When this window is shown, hibernation should not be possible,
- * because there is no sensible way to save the state: */
- modest_window_mgr_prevent_hibernation_while_window_is_shown (
- modest_runtime_get_window_mgr (), GTK_WINDOW (self));
-
- hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_accountsettings",
- modest_maemo_utils_get_osso_context());
-}
-
-ModestAccountSettingsDialog*
-modest_account_settings_dialog_new (void)
-{
- return g_object_new (MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG, NULL);
-}
-
-/** Update the UI with the stored account details, so they can be edited.
- * @account_name: Name of the account, which should contain incoming and outgoing server accounts.
- */
-void modest_account_settings_dialog_set_account (ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings)
-{
- ModestServerAccountSettings *incoming_account;
- ModestServerAccountSettings *outgoing_account;
- const gchar *account_name;
-
- g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
-
- incoming_account = modest_account_settings_get_store_settings (settings);
- outgoing_account = modest_account_settings_get_transport_settings (settings);
-
- account_name = modest_account_settings_get_account_name (settings);
-
- /* Save the account name so we can refer to it later: */
- if (dialog->account_name)
- g_free (dialog->account_name);
- dialog->account_name = g_strdup (account_name);
-
- if (dialog->settings)
- g_object_unref (dialog->settings);
- dialog->settings = g_object_ref (settings);
-
- /* Save the account title so we can refer to it if the user changes it: */
- if (dialog->original_account_title)
- g_free (dialog->original_account_title);
- dialog->original_account_title = g_strdup (modest_account_settings_get_display_name (settings));
-
- /* Show the account data in the widgets: */
-
- /* Note that we never show the non-display name in the UI.
- * (Though the display name defaults to the non-display name at the start.) */
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_account_title),
- null_means_empty (modest_account_settings_get_display_name (settings)));
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_name),
- null_means_empty (modest_account_settings_get_fullname (settings)));
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_email),
- null_means_empty (modest_account_settings_get_email_address (settings)));
- modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), modest_server_account_settings_get_protocol (incoming_account));
- modest_retrieve_combo_box_set_active_retrieve_conf (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve),
- modest_account_settings_get_retrieve_type (settings));
- modest_limit_retrieve_combo_box_set_active_limit_retrieve (
- MODEST_LIMIT_RETRIEVE_COMBO_BOX (dialog->combo_limit_retrieve),
- modest_account_settings_get_retrieve_limit (settings));
-
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages),
- modest_account_settings_get_leave_messages_on_server (settings));
-
- /* Only show the leave-on-server checkbox for POP,
- * as per the UI spec: */
- if (modest_server_account_settings_get_protocol (incoming_account) != MODEST_PROTOCOL_STORE_POP) {
- gtk_widget_hide (dialog->caption_leave_messages);
- } else {
- gtk_widget_show (dialog->caption_leave_messages);
- }
-
- update_incoming_server_security_choices (dialog, modest_server_account_settings_get_protocol (incoming_account));
- if (incoming_account) {
- const gchar *username;
- const gchar *password;
- const gchar *hostname;
- /* Remember this for later: */
- dialog->incoming_protocol = modest_server_account_settings_get_protocol (incoming_account);;
-
- hostname = modest_server_account_settings_get_hostname (incoming_account);
- username = modest_server_account_settings_get_username (incoming_account);
- password = modest_server_account_settings_get_password (incoming_account);
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_username),
- null_means_empty (username));
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_password),
- null_means_empty (password));
-
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_incomingserver),
- null_means_empty (hostname));
-
- /* The UI spec says:
- * If secure authentication is unchecked, allow sending username and password also as plain text.
- * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc.
- * TODO: Do we need to discover which of these (SSL, TLS, CRAM-MD5) is supported?
- */
- modest_serversecurity_combo_box_set_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security),
- modest_server_account_settings_get_security (incoming_account));
-
- /* Check if we have
- - a secure protocol
- OR
- - use encrypted passwords
- */
- const ModestAuthProtocol secure_auth = modest_server_account_settings_get_auth_protocol (incoming_account);
- dialog->protocol_authentication_incoming = (secure_auth != MODEST_PROTOCOL_AUTH_NONE)?
- secure_auth:MODEST_PROTOCOL_AUTH_PASSWORD;
- ModestConnectionProtocol secure_protocol = modest_server_account_settings_get_security (incoming_account);
- if (modest_protocol_info_is_secure (secure_protocol) || modest_protocol_info_auth_is_secure(secure_auth))
- {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth),
- TRUE);
- }
- else
- {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth),
- FALSE);
- };
-
- gtk_widget_set_sensitive (dialog->checkbox_incoming_auth, !modest_protocol_info_is_secure (secure_protocol));
-
- update_incoming_server_title (dialog, dialog->incoming_protocol);
-
- const gint port_num = modest_server_account_settings_get_port (incoming_account);
- if (port_num == 0) {
- /* Show the appropriate port number: */
- on_combo_incoming_security_changed (
- GTK_COMBO_BOX (dialog->combo_incoming_security), dialog);
- } else {
- /* Keep the user-entered port-number,
- * or the already-appropriate automatic port number: */
- hildon_number_editor_set_value (
- HILDON_NUMBER_EDITOR (dialog->entry_incoming_port), port_num);
- }
- g_object_unref (incoming_account);
- }
-
- outgoing_account = modest_account_settings_get_transport_settings (settings);
- if (outgoing_account) {
- const gchar *hostname;
- const gchar *username;
- const gchar *password;
-
- /* Remember this for later: */
- dialog->outgoing_protocol =
- modest_server_account_settings_get_protocol (outgoing_account);
-
- hostname = modest_server_account_settings_get_hostname (outgoing_account);
- username = modest_server_account_settings_get_username (outgoing_account);
- password = modest_server_account_settings_get_password (outgoing_account);
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoingserver),
- null_means_empty (hostname));
-
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoing_username),
- null_means_empty (username));
- gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoing_password),
- null_means_empty (password));
-
- /* Get the secure-auth setting: */
- const ModestAuthProtocol secure_auth = modest_server_account_settings_get_auth_protocol (outgoing_account);
- modest_secureauth_combo_box_set_active_secureauth (
- MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth), secure_auth);
- on_combo_outgoing_auth_changed (GTK_COMBO_BOX (dialog->combo_outgoing_auth), dialog);
-
- modest_serversecurity_combo_box_fill (
- MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security),
- dialog->outgoing_protocol);
-
- /* Get the security setting: */
- const ModestConnectionProtocol security = modest_server_account_settings_get_security (outgoing_account);
- modest_serversecurity_combo_box_set_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), security);
-
- const gint port_num = modest_server_account_settings_get_port (outgoing_account);
- if (port_num == 0) {
- /* Show the appropriate port number: */
- on_combo_outgoing_security_changed (
- GTK_COMBO_BOX (dialog->combo_outgoing_security), dialog);
- }
- else {
- /* Keep the user-entered port-number,
- * or the already-appropriate automatic port number: */
- hildon_number_editor_set_value (
- HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port), port_num);
- }
-
- const gboolean has_specific =
- modest_account_settings_get_use_connection_specific_smtp (settings);
- gtk_toggle_button_set_active (
- GTK_TOGGLE_BUTTON (dialog->checkbox_outgoing_smtp_specific),
- has_specific);
- g_object_unref (outgoing_account);
- }
-
- /* Set window title according to account: */
- /* TODO: Is this the correct way to find a human-readable name for
- * the protocol used? */
- const gchar* proto_str = modest_protocol_info_get_transport_store_protocol_name (dialog->incoming_protocol);
- gchar *proto_name = g_utf8_strup(proto_str, -1);
- const gchar *account_title = modest_account_settings_get_display_name(settings);
-
- gchar *title = g_strdup_printf(_("mcen_ti_account_settings"), proto_name, account_title);
- g_free (proto_name);
-
- gtk_window_set_title (GTK_WINDOW (dialog), title);
- g_free (title);
-
- /* account_data->is_enabled, */
- /*account_data->is_default, */
-
- /* Unset the modified flag so we can detect changes later: */
- dialog->modified = FALSE;
-}
-
-/** Show the User Info tab.
- */
-void modest_account_settings_dialog_switch_to_user_info (ModestAccountSettingsDialog *dialog)
-{
- const gint page_num = gtk_notebook_page_num (dialog->notebook, dialog->page_user_details);
- if (page_num == -1) {
- g_warning ("%s: notebook page not found.\n", __FUNCTION__);
- }
-
- /* Ensure that the widget is visible so that gtk_notebook_set_current_page() works: */
- /* TODO: even this hack (recommened by the GTK+ documentation) doesn't seem to work. */
-
- gtk_widget_show (dialog->page_user_details);
- gtk_widget_show (GTK_WIDGET (dialog->notebook));
- gtk_widget_show (GTK_WIDGET (dialog));
- gtk_notebook_set_current_page (dialog->notebook, page_num);
-}
-
-static gboolean
-save_configuration (ModestAccountSettingsDialog *dialog)
-{
- const gchar* account_name = dialog->account_name;
- ModestServerAccountSettings *store_settings;
- ModestServerAccountSettings *transport_settings;
-
- /* Set the account data from the widgets: */
- const gchar* user_fullname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_name));
- modest_account_settings_set_fullname (dialog->settings, user_fullname);
-
- const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_email));
- modest_account_settings_set_email_address (dialog->settings, emailaddress);
-
- /* Signature: */
- if (dialog->signature_dialog) {
- gboolean use_signature = FALSE;
- gchar *signature =
- modest_signature_editor_dialog_get_settings (MODEST_SIGNATURE_EDITOR_DIALOG (dialog->signature_dialog),
- &use_signature);
-
- modest_account_settings_set_use_signature (dialog->settings, use_signature);
- modest_account_settings_set_signature (dialog->settings, signature);
- }
-
- ModestAccountRetrieveType retrieve_type = modest_retrieve_combo_box_get_active_retrieve_conf (
- MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve));
- modest_account_settings_set_retrieve_type (dialog->settings, retrieve_type);
-
- gint retrieve_limit = modest_limit_retrieve_combo_box_get_active_limit_retrieve (
- MODEST_LIMIT_RETRIEVE_COMBO_BOX (dialog->combo_limit_retrieve));
- modest_account_settings_set_retrieve_limit (dialog->settings, retrieve_limit);
-
- const gboolean leave_on_server = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages));
- modest_account_settings_set_leave_messages_on_server (dialog->settings, leave_on_server);
-
- store_settings = modest_account_settings_get_store_settings (dialog->settings);
-
- const gchar* hostname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_incomingserver));
- modest_server_account_settings_set_hostname (store_settings, hostname);
-
- const gchar* username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_username));
- modest_server_account_settings_set_username (store_settings, username);
-
- const gchar* password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_password));
- modest_server_account_settings_set_password (store_settings, password);
-
- /* port: */
- gint port_num = hildon_number_editor_get_value (
- HILDON_NUMBER_EDITOR (dialog->entry_incoming_port));
- modest_server_account_settings_set_port (store_settings, port_num);
-
- /* The UI spec says:
- * If secure authentication is unchecked, allow sending username and password also as plain text.
- * If secure authentication is checked, require one of the secure
- * methods during connection: SSL, TLS, CRAM-MD5 etc.
- */
-
- const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security));
- modest_server_account_settings_set_security (store_settings, protocol_security_incoming);
- if (modest_protocol_info_is_secure (protocol_security_incoming)) {
- modest_server_account_settings_set_auth_protocol (store_settings, FALSE);
- } else {
- modest_server_account_settings_set_auth_protocol (store_settings,
- dialog->protocol_authentication_incoming);
- }
-
- g_object_unref (store_settings);
-
- /* Outgoing: */
- transport_settings = modest_account_settings_get_transport_settings (dialog->settings);
-
- hostname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoingserver));
- modest_server_account_settings_set_hostname (transport_settings, hostname);
-
- username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_username));
- modest_server_account_settings_set_username (transport_settings, username);
-
- password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_password));
- modest_server_account_settings_set_password (transport_settings, password);
-
- const ModestConnectionProtocol protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security));
- modest_server_account_settings_set_security (transport_settings, protocol_security_outgoing);
-
- const ModestAuthProtocol protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth (
- MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth));
- modest_server_account_settings_set_auth_protocol (transport_settings, protocol_authentication_outgoing);
-
- /* port: */
- port_num = hildon_number_editor_get_value (
- HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port));
- modest_server_account_settings_set_port (transport_settings, port_num);
- g_object_unref (transport_settings);
-
-
- /* Set the changed account title last, to simplify the previous code: */
- gchar* account_title = get_entered_account_title (dialog);
- if (!account_title)
- return FALSE; /* Should be prevented already anyway. */
-
-/* if (strcmp (account_title, account_name) != 0) { */
- modest_account_settings_set_display_name (dialog->settings, account_title);
-/* } */
- g_free (account_title);
- account_title = NULL;
-
- /* Save connection-specific SMTP server accounts: */
- modest_account_settings_set_use_connection_specific_smtp
- (dialog->settings,
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbox_outgoing_smtp_specific)));
-
- /* this configuration is not persistent, we should not save */
- if (account_name != NULL)
- modest_account_mgr_save_account_settings (dialog->account_manager, dialog->settings);
-
- return TRUE;
-}
-
-static gboolean entry_is_empty (GtkWidget *entry)
-{
- if (!entry)
- return FALSE;
-
- const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
- if ((!text) || (strlen(text) == 0))
- return TRUE;
- else {
- /* Strip it of whitespace at the start and end: */
- gchar *stripped = g_strdup (text);
- stripped = g_strstrip (stripped);
-
- if (!stripped)
- return TRUE;
-
- const gboolean result = (strlen (stripped) == 0);
-
- g_free (stripped);
- return result;
- }
-}
-
-static void
-enable_buttons (ModestAccountSettingsDialog *self)
-{
- gboolean enable_ok = TRUE;
- ModestAuthProtocol outgoing_auth_protocol;
-
- /* The account details title is mandatory: */
- if (entry_is_empty(self->entry_account_title))
- enable_ok = FALSE;
-
- /* The user details username is mandatory: */
- if (enable_ok && entry_is_empty(self->entry_user_username))
- enable_ok = FALSE;
-
- /* The user details email address is mandatory: */
- if (enable_ok && entry_is_empty (self->entry_user_email))
- enable_ok = FALSE;
-
- /* The custom incoming server is mandatory: */
- if (enable_ok && entry_is_empty(self->entry_incomingserver))
- enable_ok = FALSE;
-
- /* The custom incoming server is mandatory: */
- if (enable_ok && entry_is_empty(self->entry_outgoingserver))
- enable_ok = FALSE;
-
- /* Outgoing username is mandatory if outgoing auth is secure */
- if (self->combo_outgoing_auth) {
- outgoing_auth_protocol = modest_secureauth_combo_box_get_active_secureauth (
- MODEST_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth));
- if (enable_ok &&
- outgoing_auth_protocol != MODEST_PROTOCOL_AUTH_NONE &&
- entry_is_empty (self->entry_outgoing_username))
- enable_ok = FALSE;
- }
-
- /* Enable the buttons,
- * identifying them via their associated response codes:
- */
- GtkDialog *dialog_base = GTK_DIALOG (self);
- gtk_dialog_set_response_sensitive (dialog_base,
- GTK_RESPONSE_OK,
- enable_ok);
-}
-
-void
-modest_account_settings_dialog_check_allow_changes (ModestAccountSettingsDialog *self)
-{
- ModestServerAccountSettings *incoming_settings;
- const gchar *server_account_name;
- gboolean username_known;
-
- if (!G_IS_OBJECT (self->settings))
- return;
-
- incoming_settings = modest_account_settings_get_store_settings (self->settings);
- server_account_name = modest_server_account_settings_get_account_name (incoming_settings);
-
- username_known = modest_account_mgr_get_server_account_username_has_succeeded (self->account_manager,
- server_account_name);
-
- /* Enable or disable widgets */
- gtk_widget_set_sensitive (self->entry_user_username, !username_known);
- gtk_widget_set_sensitive (self->entry_incomingserver, !username_known);
- /* gtk_widget_set_sensitive (self->entry_outgoingserver, !username_known); */
- /* gtk_widget_set_sensitive (self->entry_outgoing_username, !username_known); */
- gtk_widget_set_sensitive (self->entry_incoming_port, !username_known);
-/* gtk_widget_set_sensitive (self->entry_outgoing_port, !username_known); */
- gtk_widget_set_sensitive (self->combo_incoming_security, !username_known);
-/* gtk_widget_set_sensitive (self->combo_outgoing_security, !username_known); */
-}
-
-void
-modest_account_settings_dialog_set_modified (ModestAccountSettingsDialog *dialog, gboolean modified)
-{
- g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog));
-
- dialog->modified = modified;
-
-}
-
-static void
-modest_account_settings_dialog_class_init (ModestAccountSettingsDialogClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (ModestAccountSettingsDialogPrivate));
-
-
- object_class->get_property = modest_account_settings_dialog_get_property;
- object_class->set_property = modest_account_settings_dialog_set_property;
- object_class->dispose = modest_account_settings_dialog_dispose;
- object_class->finalize = modest_account_settings_dialog_finalize;
-}
#include <modest-runtime.h>
#include "modest-platform.h"
+#include "modest-account-protocol.h"
#include <modest-account-mgr-helpers.h>
#include <string.h>
#include "modest-tny-platform-factory.h"
/* The warning text depends on the account type: */
gchar *txt = NULL;
gint response;
-
- if (modest_account_mgr_get_store_protocol (account_mgr, account_name)
- == MODEST_PROTOCOL_STORE_POP) {
- txt = g_strdup_printf (_("emev_nc_delete_mailbox"),
- account_title);
- } else {
- txt = g_strdup_printf (_("emev_nc_delete_mailboximap"),
+ ModestProtocol *protocol;
+
+ protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+ modest_account_mgr_get_store_protocol (account_mgr, account_name));
+ txt = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_DELETE_MAILBOX, account_title);
+ if (txt == NULL) {
+ txt = g_strdup_printf (_("emev_nc_delete_mailbox"),
account_title);
}
* the user wishes.
*/
if (check_for_active_account (self, account_name)) {
- GtkWidget *dialog = modest_tny_account_store_show_account_settings_dialog (modest_runtime_get_account_store (), account_name);
-
- /* When the dialog is closed, reconnect */
- g_signal_connect (dialog, "response",
- G_CALLBACK (on_account_settings_dialog_response),
- self);
+ ModestAccountProtocol *proto;
+ ModestProtocolType proto_type;
+
+ /* Get proto */
+ proto_type = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
+ account_name);
+ proto = (ModestAccountProtocol *)
+ modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+ proto_type);
+
+ /* Create and show the dialog */
+ if (proto && MODEST_IS_ACCOUNT_PROTOCOL (proto)) {
+ ModestAccountSettingsDialog *dialog =
+ modest_account_protocol_get_account_settings_dialog (proto, account_name);
+ gtk_widget_show (GTK_WIDGET (dialog));
+ }
}
-
g_free (account_name);
}
gtk_widget_show (GTK_WIDGET (wizard));
}
-
static void
on_close_button_clicked (GtkWidget *button, gpointer user_data)
{
if (!priv->combo_outgoing_security)
priv->combo_outgoing_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
modest_serversecurity_combo_box_fill (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOL_TRANSPORT_SMTP);
+ MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOLS_TRANSPORT_SMTP);
modest_serversecurity_combo_box_set_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOL_CONNECTION_NORMAL);
+ MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOLS_CONNECTION_NONE);
caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"),
priv->combo_outgoing_security, NULL, HILDON_CAPTION_OPTIONAL);
gtk_widget_show (priv->combo_outgoing_security);
modest_serversecurity_combo_box_set_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security),
- modest_server_account_settings_get_security (server_settings));
+ modest_server_account_settings_get_security_protocol (server_settings));
modest_secureauth_combo_box_set_active_secureauth (
MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth),
modest_server_account_settings_set_hostname (server_settings,
gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver)));
modest_server_account_settings_set_protocol (server_settings,
- MODEST_PROTOCOL_TRANSPORT_SMTP);
+ MODEST_PROTOCOLS_TRANSPORT_SMTP);
modest_server_account_settings_set_username (server_settings,
gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username)));
modest_server_account_settings_set_password (server_settings,
gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password)));
- modest_server_account_settings_set_security (server_settings,
+ modest_server_account_settings_set_security_protocol (server_settings,
modest_serversecurity_combo_box_get_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security)));
modest_server_account_settings_set_auth_protocol (server_settings,
/* Get existing server account data if a server account is already specified: */
gboolean settings_were_retrieved = FALSE;
if (server_account_name && !server_settings) {
- server_settings = modest_account_mgr_load_server_settings(mgr, server_account_name);
+ server_settings = modest_account_mgr_load_server_settings(mgr, server_account_name, TRUE);
if (server_settings)
settings_were_retrieved = TRUE;
}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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 <glib/gi18n.h>
+#include <gtk/gtknotebook.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkcombobox.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkcheckbutton.h>
+#include <gtk/gtkmessagedialog.h>
+#include <gtk/gtkstock.h>
+#include "modest-hildon-includes.h"
+#include "modest-default-account-settings-dialog.h"
+#include "modest-account-mgr.h"
+#include "widgets/modest-serversecurity-combo-box.h"
+#include "widgets/modest-secureauth-combo-box.h"
+#include "widgets/modest-validating-entry.h"
+#include "widgets/modest-retrieve-combo-box.h"
+#include "widgets/modest-limit-retrieve-combo-box.h"
+#include "modest-text-utils.h"
+#include "modest-account-mgr.h"
+#include "modest-account-mgr-helpers.h" /* For modest_account_mgr_get_account_data(). */
+#include <modest-server-account-settings.h>
+#include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
+#include "maemo/modest-connection-specific-smtp-window.h"
+#include "maemo/modest-signature-editor-dialog.h"
+#include <modest-utils.h>
+#include <modest-defs.h>
+#include "maemo/modest-maemo-utils.h"
+#include "maemo/modest-maemo-security-options-view.h"
+#include "widgets/modest-ui-constants.h"
+#include <tny-account.h>
+#include <tny-status.h>
+
+#include <gconf/gconf-client.h>
+#include <string.h> /* For strlen(). */
+
+/* Include config.h so that _() works: */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define PORT_MIN 1
+#define PORT_MAX 65535
+
+static void modest_account_settings_dialog_init (gpointer g, gpointer iface_data);
+
+G_DEFINE_TYPE_EXTENDED (ModestDefaultAccountSettingsDialog,
+ modest_default_account_settings_dialog,
+ GTK_TYPE_DIALOG,
+ 0,
+ G_IMPLEMENT_INTERFACE (MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG,
+ modest_account_settings_dialog_init));
+
+#define MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG, ModestDefaultAccountSettingsDialogPrivate))
+
+typedef struct _ModestDefaultAccountSettingsDialogPrivate ModestDefaultAccountSettingsDialogPrivate;
+
+struct _ModestDefaultAccountSettingsDialogPrivate
+{
+ /* Used by derived widgets to query existing accounts,
+ * and to create new accounts: */
+ ModestAccountMgr *account_manager;
+ ModestAccountSettings *settings;
+
+ gboolean modified;
+ gchar * account_name; /* This may not change. It is not user visible. */
+ ModestProtocolType incoming_protocol; /* This may not change. */
+ ModestProtocolType outgoing_protocol; /* This may not change. */
+ gchar * original_account_title;
+
+ ModestProtocolType protocol_authentication_incoming;
+
+ GtkNotebook *notebook;
+
+ GtkWidget *page_account_details;
+ GtkWidget *entry_account_title;
+ GtkWidget *combo_retrieve;
+ GtkWidget *combo_limit_retrieve;
+ GtkWidget *caption_leave_messages;
+ GtkWidget *checkbox_leave_messages;
+
+ GtkWidget *page_user_details;
+ GtkWidget *entry_user_name;
+ GtkWidget *entry_user_username;
+ GtkWidget *entry_user_password;
+ GtkWidget *entry_user_email;
+/* GtkWidget *entry_incoming_port; */
+ GtkWidget *button_signature;
+
+ GtkWidget *page_complete_easysetup;
+
+ GtkWidget *page_incoming;
+ GtkWidget *caption_incoming;
+ GtkWidget *entry_incomingserver;
+/* GtkWidget *combo_incoming_security; */
+/* GtkWidget *checkbox_incoming_auth; */
+
+ GtkWidget *page_outgoing;
+ GtkWidget *entry_outgoingserver;
+/* GtkWidget *caption_outgoing_username; */
+/* GtkWidget *entry_outgoing_username; */
+/* GtkWidget *caption_outgoing_password; */
+/* GtkWidget *entry_outgoing_password; */
+/* GtkWidget *combo_outgoing_security; */
+/* GtkWidget *combo_outgoing_auth; */
+/* GtkWidget *entry_outgoing_port; */
+ GtkWidget *checkbox_outgoing_smtp_specific;
+ GtkWidget *button_outgoing_smtp_servers;
+
+ GtkWidget *signature_dialog;
+
+ GtkWidget *incoming_security;
+ GtkWidget *outgoing_security;
+};
+
+static void
+enable_buttons (ModestDefaultAccountSettingsDialog *self);
+
+static gboolean
+save_configuration (ModestDefaultAccountSettingsDialog *dialog);
+
+static const gchar * null_means_empty (const gchar * str);
+
+static const gchar *
+null_means_empty (const gchar * str)
+{
+ return str ? str : "";
+}
+
+static void
+modest_default_account_settings_dialog_dispose (GObject *object)
+{
+ if (G_OBJECT_CLASS (modest_default_account_settings_dialog_parent_class)->dispose)
+ G_OBJECT_CLASS (modest_default_account_settings_dialog_parent_class)->dispose (object);
+}
+
+static void
+modest_default_account_settings_dialog_finalize (GObject *object)
+{
+ ModestDefaultAccountSettingsDialog *self;
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+
+ self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (object);
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ if (priv->account_name)
+ g_free (priv->account_name);
+
+ if (priv->original_account_title)
+ g_free (priv->original_account_title);
+
+ if (priv->account_manager)
+ g_object_unref (G_OBJECT (priv->account_manager));
+
+ if (priv->signature_dialog)
+ gtk_widget_destroy (priv->signature_dialog);
+
+ if (priv->settings) {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
+ }
+
+ G_OBJECT_CLASS (modest_default_account_settings_dialog_parent_class)->finalize (object);
+}
+
+static void
+set_modified (ModestDefaultAccountSettingsDialog *self, gboolean modified)
+{
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+ priv->modified = modified;
+}
+
+static void
+on_modified_combobox_changed (GtkComboBox *widget, gpointer user_data)
+{
+ set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE);
+}
+
+static void
+on_modified_entry_changed (GtkEditable *editable, gpointer user_data)
+{
+ set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE);
+}
+
+static void
+on_modified_checkbox_toggled (GtkToggleButton *togglebutton, gpointer user_data)
+{
+ set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE);
+}
+
+static void
+on_modified_number_editor_changed (HildonNumberEditor *number_editor, gint new_value, gpointer user_data)
+{
+ set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE);
+}
+
+static void
+on_number_editor_notify (HildonNumberEditor *editor, GParamSpec *arg1, gpointer user_data)
+{
+ ModestDefaultAccountSettingsDialog *dialog = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
+ gint value = hildon_number_editor_get_value (editor);
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, value > 0);
+}
+
+/* Set a modified boolean whenever the widget is changed,
+ * so we can check for it later.
+ */
+static void
+connect_for_modified (ModestDefaultAccountSettingsDialog *self, GtkWidget *widget)
+{
+ if (HILDON_IS_NUMBER_EDITOR (widget)) {
+ g_signal_connect (G_OBJECT (widget), "notify::value",
+ G_CALLBACK (on_modified_number_editor_changed), self);
+ g_signal_connect (G_OBJECT (widget), "notify", G_CALLBACK (on_number_editor_notify), self);
+ }
+ else if (GTK_IS_ENTRY (widget)) {
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (on_modified_entry_changed), self);
+ } else if (GTK_IS_COMBO_BOX (widget)) {
+ g_signal_connect (G_OBJECT (widget), "changed",
+ G_CALLBACK (on_modified_combobox_changed), self);
+ } else if (GTK_IS_TOGGLE_BUTTON (widget)) {
+ g_signal_connect (G_OBJECT (widget), "toggled",
+ G_CALLBACK (on_modified_checkbox_toggled), self);
+ }
+}
+
+static void
+on_caption_entry_changed (GtkEditable *editable, gpointer user_data)
+{
+ ModestDefaultAccountSettingsDialog *self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
+ g_assert(self);
+ enable_buttons(self);
+}
+
+static void
+on_caption_combobox_changed (GtkComboBox *widget, gpointer user_data)
+{
+ ModestDefaultAccountSettingsDialog *self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
+ g_assert(self);
+ enable_buttons(self);
+}
+
+/** This is a convenience function to create a caption containing a mandatory widget.
+ * When the widget is edited, the enable_buttons() vfunc will be called.
+ */
+static GtkWidget*
+create_caption_new_with_asterisk(ModestDefaultAccountSettingsDialog *self,
+ GtkSizeGroup *group,
+ const gchar *value,
+ GtkWidget *control,
+ GtkWidget *icon,
+ HildonCaptionStatus flag)
+{
+ GtkWidget *caption = NULL;
+
+ /* Note: Previously, the translated strings already contained the "*",
+ * Comment out this code if they do again.
+ */
+ /* Add a * character to indicate mandatory fields,
+ * as specified in our "Email UI Specification": */
+ if (flag == HILDON_CAPTION_MANDATORY) {
+ gchar* title = g_strdup_printf("%s*", value);
+ caption = hildon_caption_new (group, title, control, icon, flag);
+ g_free(title);
+ }
+ else
+ caption = hildon_caption_new (group, value, control, icon, flag);
+
+ /* Connect to the appropriate changed signal for the widget,
+ * so we can ask for the prev/next buttons to be enabled/disabled appropriately:
+ */
+ if (GTK_IS_ENTRY (control)) {
+ g_signal_connect (G_OBJECT (control), "changed",
+ G_CALLBACK (on_caption_entry_changed), self);
+
+ }
+ else if (GTK_IS_COMBO_BOX (control)) {
+ g_signal_connect (G_OBJECT (control), "changed",
+ G_CALLBACK (on_caption_combobox_changed), self);
+ }
+
+ return caption;
+}
+
+static void
+on_entry_invalid_account_title_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
+{
+ gchar *tmp, *msg;
+
+ tmp = g_strndup (account_title_forbidden_chars, ACCOUNT_TITLE_FORBIDDEN_CHARS_LENGTH);
+ msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
+
+ modest_platform_information_banner (GTK_WIDGET (self), NULL, msg);
+
+ g_free (msg);
+ g_free (tmp);
+}
+
+static void
+on_entry_invalid_fullname_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
+{
+ gchar *tmp, *msg;
+
+ tmp = g_strndup (user_name_forbidden_chars, USER_NAME_FORBIDDEN_CHARS_LENGTH);
+ msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
+
+ modest_platform_information_banner (GTK_WIDGET (self), NULL, msg);
+
+ g_free (msg);
+ g_free (tmp);
+}
+
+
+static void
+on_entry_max (ModestValidatingEntry *self, gpointer user_data)
+{
+ modest_platform_information_banner (GTK_WIDGET (self), NULL,
+ _CS("ckdg_ib_maximum_characters_reached"));
+}
+
+static GtkWidget*
+create_page_account_details (ModestDefaultAccountSettingsDialog *self)
+{
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+ GtkWidget *box;
+ GtkAdjustment *focus_adjustment = NULL;
+ GtkSizeGroup* sizegroup;
+ GtkWidget *scrollwin;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+ box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
+ sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ scrollwin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ /* The description widgets: */
+ priv->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
+ /* Do use auto-capitalization: */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_account_title),
+ HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
+ GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_account_title"),
+ priv->entry_account_title, NULL, HILDON_CAPTION_MANDATORY);
+ gtk_widget_show (priv->entry_account_title);
+ connect_for_modified (self, priv->entry_account_title);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ /* Prevent the use of some characters in the account title,
+ * as required by our UI specification: */
+ GList *list_prevent = NULL;
+ list_prevent = g_list_append (list_prevent, "\\");
+ list_prevent = g_list_append (list_prevent, "/");
+ list_prevent = g_list_append (list_prevent, ":");
+ list_prevent = g_list_append (list_prevent, "*");
+ list_prevent = g_list_append (list_prevent, "?");
+ list_prevent = g_list_append (list_prevent, "\"");
+ list_prevent = g_list_append (list_prevent, "<");
+ list_prevent = g_list_append (list_prevent, ">");
+ list_prevent = g_list_append (list_prevent, "|");
+ list_prevent = g_list_append (list_prevent, "^");
+ modest_validating_entry_set_unallowed_characters (
+ MODEST_VALIDATING_ENTRY (priv->entry_account_title), list_prevent);
+ g_list_free (list_prevent);
+ modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
+ on_entry_invalid_account_title_character, self);
+
+ /* Set max length as in the UI spec:
+ * The UI spec seems to want us to show a dialog if we hit the maximum. */
+ gtk_entry_set_max_length (GTK_ENTRY (priv->entry_account_title), 64);
+ modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_account_title),
+ on_entry_max, self);
+
+ /* The retrieve combobox: */
+ priv->combo_retrieve = GTK_WIDGET (modest_retrieve_combo_box_new ());
+ caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_retrievetype"),
+ priv->combo_retrieve, NULL, HILDON_CAPTION_MANDATORY);
+ gtk_widget_show (priv->combo_retrieve);
+ connect_for_modified (self, priv->combo_retrieve);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ /* The limit-retrieve combobox: */
+ priv->combo_limit_retrieve = GTK_WIDGET (modest_limit_retrieve_combo_box_new ());
+ caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_limit_retrieve"),
+ priv->combo_limit_retrieve, NULL, HILDON_CAPTION_MANDATORY);
+ gtk_widget_show (priv->combo_limit_retrieve);
+ connect_for_modified (self, priv->combo_limit_retrieve);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ /* The leave-messages widgets: */
+ if(!priv->checkbox_leave_messages)
+ priv->checkbox_leave_messages = gtk_check_button_new ();
+ if (!priv->caption_leave_messages) {
+ priv->caption_leave_messages = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_leave_on_server"),
+ priv->checkbox_leave_messages, NULL, HILDON_CAPTION_MANDATORY);
+ }
+
+ gtk_widget_show (priv->checkbox_leave_messages);
+ connect_for_modified (self, priv->checkbox_leave_messages);
+ gtk_box_pack_start (GTK_BOX (box), priv->caption_leave_messages, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (priv->caption_leave_messages);
+
+ g_object_unref (sizegroup);
+
+ gtk_widget_show (GTK_WIDGET (box));
+
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollwin), box);
+ gtk_widget_show (scrollwin);
+
+ focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
+ gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
+
+ return GTK_WIDGET (scrollwin);
+}
+
+static gchar*
+get_entered_account_title (ModestDefaultAccountSettingsDialog *dialog)
+{
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+ const gchar* account_title;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
+ account_title = gtk_entry_get_text (GTK_ENTRY (priv->entry_account_title));
+
+ if (!account_title || (strlen (account_title) == 0))
+ return NULL;
+ else {
+ /* Strip it of whitespace at the start and end: */
+ gchar *result = g_strdup (account_title);
+ result = g_strstrip (result);
+
+ if (!result)
+ return NULL;
+
+ if (strlen (result) == 0) {
+ g_free (result);
+ return NULL;
+ }
+
+ return result;
+ }
+}
+
+
+static void
+on_button_signature (GtkButton *button, gpointer user_data)
+{
+ ModestDefaultAccountSettingsDialog *self;
+ gint response;
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+
+ self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ /* Create the window, if necessary: */
+ if (!(priv->signature_dialog)) {
+ priv->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ());
+
+ gboolean use_signature = modest_account_settings_get_use_signature (priv->settings);
+ const gchar *signature = modest_account_settings_get_signature(priv->settings);
+ gchar* account_title = get_entered_account_title (self);
+ modest_signature_editor_dialog_set_settings (
+ MODEST_SIGNATURE_EDITOR_DIALOG (priv->signature_dialog),
+ use_signature, signature, account_title);
+
+ g_free (account_title);
+ account_title = NULL;
+ signature = NULL;
+ }
+
+ /* Show the window: */
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+ GTK_WINDOW (priv->signature_dialog));
+
+ response = gtk_dialog_run (GTK_DIALOG (priv->signature_dialog));
+ gtk_widget_hide (priv->signature_dialog);
+ if (response != GTK_RESPONSE_OK) {
+ /* Destroy the widget now, and its data: */
+ gtk_widget_destroy (priv->signature_dialog);
+ priv->signature_dialog = NULL;
+ } else {
+ /* Mark modified, so we use the dialog's data later: */
+ priv->modified = TRUE;
+ }
+}
+
+static GtkWidget*
+create_page_user_details (ModestDefaultAccountSettingsDialog *self)
+{
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+ GtkWidget *box;
+ GtkAdjustment *focus_adjustment = NULL;
+ GtkSizeGroup* sizegroup;
+ GtkWidget *scrollwin;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
+ sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ scrollwin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ /* The name widgets: */
+ priv->entry_user_name = GTK_WIDGET (modest_validating_entry_new ());
+
+ /* Auto-capitalization is the default, so let's turn it off: */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_name), HILDON_GTK_INPUT_MODE_FULL);
+ /* Set max length as in the UI spec:
+ * The UI spec seems to want us to show a dialog if we hit the maximum. */
+ gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_name), 64);
+ modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_name),
+ on_entry_max, self);
+ GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup,
+ _("mcen_li_emailsetup_name"), priv->entry_user_name, NULL, HILDON_CAPTION_OPTIONAL);
+ gtk_widget_show (priv->entry_user_name);
+ connect_for_modified (self, priv->entry_user_name);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+
+ /* Prevent the use of some characters in the name,
+ * as required by our UI specification: */
+ GList *list_prevent = NULL;
+ list_prevent = g_list_append (list_prevent, "<");
+ list_prevent = g_list_append (list_prevent, ">");
+ modest_validating_entry_set_unallowed_characters (
+ MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
+ g_list_free (list_prevent);
+ modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
+ on_entry_invalid_fullname_character, self);
+
+ /* The username widgets: */
+ priv->entry_user_username = GTK_WIDGET (modest_validating_entry_new ());
+ /* Auto-capitalization is the default, so let's turn it off: */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username), HILDON_GTK_INPUT_MODE_FULL);
+ caption = create_caption_new_with_asterisk (self, sizegroup, _("mail_fi_username"),
+ priv->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
+ gtk_widget_show (priv->entry_user_username);
+ connect_for_modified (self, priv->entry_user_username);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ /* Prevent the use of some characters in the username,
+ * as required by our UI specification: */
+ modest_validating_entry_set_unallowed_characters_whitespace (
+ MODEST_VALIDATING_ENTRY (priv->entry_user_username));
+ modest_validating_entry_set_func (MODEST_VALIDATING_ENTRY (priv->entry_user_username),
+ modest_utils_on_entry_invalid_character,
+ self);
+
+ /* Set max length as in the UI spec:
+ * The UI spec seems to want us to show a dialog if we hit the maximum. */
+ gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
+ modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_username),
+ on_entry_max, self);
+
+ /* The password widgets: */
+ priv->entry_user_password = gtk_entry_new ();
+ /* Auto-capitalization is the default, so let's turn it off: */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password),
+ HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
+ gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE);
+ /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */
+ caption = create_caption_new_with_asterisk (self, sizegroup,
+ _("mail_fi_password"), priv->entry_user_password, NULL, HILDON_CAPTION_OPTIONAL);
+ gtk_widget_show (priv->entry_user_password);
+ connect_for_modified (self, priv->entry_user_password);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ /* The email address widgets: */
+ priv->entry_user_email = GTK_WIDGET (modest_validating_entry_new ());
+ /* Auto-capitalization is the default, so let's turn it off: */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_email), HILDON_GTK_INPUT_MODE_FULL);
+ caption = create_caption_new_with_asterisk (self, sizegroup,
+ _("mcen_li_emailsetup_email_address"), priv->entry_user_email, NULL, HILDON_CAPTION_MANDATORY);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry_user_email), MODEST_EXAMPLE_EMAIL_ADDRESS); /* Default text. */
+ gtk_widget_show (priv->entry_user_email);
+ connect_for_modified (self, priv->entry_user_email);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ /* Set max length as in the UI spec:
+ * The UI spec seems to want us to show a dialog if we hit the maximum. */
+ gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_email), 64);
+ modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (priv->entry_user_email),
+ on_entry_max, self);
+
+ /* Signature button: */
+ if (!priv->button_signature)
+ priv->button_signature = gtk_button_new_with_label (_("mcen_bd_edit"));
+ caption = hildon_caption_new (sizegroup, _("mcen_fi_email_signature"),
+ priv->button_signature, NULL, HILDON_CAPTION_OPTIONAL);
+ hildon_caption_set_child_expand (HILDON_CAPTION (caption), FALSE);
+ gtk_widget_show (priv->button_signature);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ g_object_unref (sizegroup);
+
+ g_signal_connect (G_OBJECT (priv->button_signature), "clicked",
+ G_CALLBACK (on_button_signature), self);
+
+ gtk_widget_show (GTK_WIDGET (box));
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollwin), box);
+ gtk_widget_show (scrollwin);
+
+ focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
+ gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
+
+ return GTK_WIDGET (scrollwin);
+}
+
+/* Change the caption title for the incoming server */
+static void
+update_incoming_server_title (ModestDefaultAccountSettingsDialog *self,
+ ModestProtocolType protocol_type)
+{
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
+ const gchar *protocol_display_name;
+ gchar* incomingserver_title;
+ gchar *with_asterisk;
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
+ protocol_display_name = modest_protocol_get_display_name (protocol);
+ incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"),
+ protocol_display_name);
+
+ /* This is a mandatory field, so add a *. This is usually done by
+ * create_caption_new_with_asterisk() but we can't use that here. */
+ with_asterisk = g_strconcat (incomingserver_title, "*", NULL);
+ g_free (incomingserver_title);
+
+ g_object_set (G_OBJECT (priv->caption_incoming), "label", with_asterisk, NULL);
+ g_free (with_asterisk);
+}
+
+/** Change the caption title for the incoming server,
+ * as specified in the UI spec:
+ */
+/* static void */
+/* update_incoming_server_security_choices (ModestDefaultAccountSettingsDialog *self, */
+/* ModestProtocolType protocol) */
+/* { */
+/* /\* Fill the combo with appropriately titled choices for POP or IMAP. *\/ */
+/* /\* The choices are the same, but the titles are different, as in the UI spec. *\/ */
+/* modest_serversecurity_combo_box_fill ( */
+/* MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security), protocol); */
+/* } */
+
+static GtkWidget*
+create_page_incoming (ModestDefaultAccountSettingsDialog *self)
+{
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+ GtkWidget *box;
+ GtkSizeGroup *sizegroup;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
+ /* Create a size group to be used by all captions.
+ * Note that HildonCaption does not create a default size group if we do not specify one.
+ * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
+ sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+
+ /* The incoming server widgets: */
+ if(!priv->entry_incomingserver)
+ priv->entry_incomingserver = gtk_entry_new ();
+ /* Auto-capitalization is the default, so let's turn it off: */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
+
+ if (priv->caption_incoming)
+ gtk_widget_destroy (priv->caption_incoming);
+
+ /* The caption title will be updated in update_incoming_server_title().
+ * so this default text will never be seen: */
+ /* (Note: Changing the title seems pointless. murrayc) */
+ priv->caption_incoming = create_caption_new_with_asterisk (self, sizegroup,
+ "Incoming Server", priv->entry_incomingserver, NULL, HILDON_CAPTION_MANDATORY);
+ gtk_widget_show (priv->entry_incomingserver);
+ connect_for_modified (self, priv->entry_incomingserver);
+ gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (priv->caption_incoming);
+
+ /* Incoming security widgets */
+ priv->incoming_security =
+ modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
+ TRUE, sizegroup);
+ gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
+ FALSE, FALSE, MODEST_MARGIN_HALF);
+
+ gtk_widget_show (priv->incoming_security);
+
+ g_object_unref (sizegroup);
+ gtk_widget_show (GTK_WIDGET (box));
+
+ return GTK_WIDGET (box);
+}
+
+static void
+on_toggle_button_changed (GtkToggleButton *togglebutton, gpointer user_data)
+{
+ GtkWidget *widget = GTK_WIDGET (user_data);
+
+ /* Enable the widget only if the toggle button is active: */
+ const gboolean enable = gtk_toggle_button_get_active (togglebutton);
+ gtk_widget_set_sensitive (widget, enable);
+}
+
+/* Make the sensitivity of a widget depend on a toggle button.
+ */
+static void
+enable_widget_for_togglebutton (GtkWidget *widget, GtkToggleButton* button)
+{
+ g_signal_connect (G_OBJECT (button), "toggled",
+ G_CALLBACK (on_toggle_button_changed), widget);
+
+ /* Set the starting sensitivity: */
+ on_toggle_button_changed (button, widget);
+}
+
+static void
+on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
+{
+ ModestDefaultAccountSettingsDialog * self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
+ ModestConnectionSpecificSmtpWindow *smtp_win;
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ /* Create the window if necessary: */
+ smtp_win = modest_connection_specific_smtp_window_new ();
+ modest_connection_specific_smtp_window_fill_with_connections (smtp_win, priv->account_manager);
+
+ /* Show the window: */
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (smtp_win));
+ gtk_widget_show (GTK_WIDGET (smtp_win));
+ priv->modified = TRUE;
+}
+
+/* static void */
+/* on_combo_outgoing_auth_changed (GtkComboBox *widget, gpointer user_data) */
+/* { */
+/* ModestDefaultAccountSettingsDialog *self; */
+/* ModestProtocolRegistry *protocol_registry; */
+/* ModestProtocolType protocol_security; */
+/* gboolean secureauth_used; */
+
+/* self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); */
+/* protocol_registry = modest_runtime_get_protocol_registry (); */
+
+/* protocol_security = */
+/* modest_secureauth_combo_box_get_active_secureauth ( */
+/* MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth)); */
+/* secureauth_used = modest_protocol_registry_protocol_type_is_secure (protocol_registry, protocol_security); */
+
+/* gtk_widget_set_sensitive (priv->caption_outgoing_username, secureauth_used); */
+/* gtk_widget_set_sensitive (priv->caption_outgoing_password, secureauth_used); */
+/* } */
+
+/* static void */
+/* on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data) */
+/* { */
+/* ModestDefaultAccountSettingsDialog *self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); */
+
+/* const gint port_number = */
+/* modest_serversecurity_combo_box_get_active_serversecurity_port ( */
+/* MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security)); */
+
+/* if(port_number != 0) { */
+/* hildon_number_editor_set_value ( */
+/* HILDON_NUMBER_EDITOR (priv->entry_outgoing_port), port_number); */
+/* } */
+/* } */
+
+static void
+on_missing_mandatory_data (ModestSecurityOptionsView *security_view,
+ gboolean missing,
+ gpointer user_data)
+{
+ /* Disable the OK button */
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (user_data),
+ GTK_RESPONSE_OK,
+ !missing);
+}
+
+static GtkWidget*
+create_page_outgoing (ModestDefaultAccountSettingsDialog *self)
+{
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+ GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
+ GtkAdjustment *focus_adjustment = NULL;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ /* Put it all in a scrolled window, so that all widgets can be
+ * accessed even when the on-screen keyboard is visible: */
+ GtkWidget *scrollwin = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ /* Create a size group to be used by all captions.
+ * Note that HildonCaption does not create a default size group if we do not specify one.
+ * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */
+ GtkSizeGroup *sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+
+ /* The outgoing server widgets: */
+ if (!priv->entry_outgoingserver)
+ priv->entry_outgoingserver = gtk_entry_new ();
+ /* Auto-capitalization is the default, so let's turn it off: */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
+ GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup,
+ _("mcen_li_emailsetup_smtp"), priv->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL);
+ gtk_widget_show (priv->entry_outgoingserver);
+ connect_for_modified (self, priv->entry_outgoingserver);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ /* Outgoing security widgets */
+ priv->outgoing_security =
+ modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
+ TRUE, sizegroup);
+ gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security,
+ FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (priv->outgoing_security);
+ g_signal_connect (priv->outgoing_security, "missing-mandatory-data",
+ G_CALLBACK (on_missing_mandatory_data), self);
+
+ GtkWidget *separator = gtk_hseparator_new ();
+ gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (separator);
+
+ /* connection-specific checkbox: */
+ if (!priv->checkbox_outgoing_smtp_specific) {
+ priv->checkbox_outgoing_smtp_specific = gtk_check_button_new ();
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbox_outgoing_smtp_specific),
+ FALSE);
+ }
+ caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_connection_smtp"),
+ priv->checkbox_outgoing_smtp_specific, NULL, HILDON_CAPTION_OPTIONAL);
+ gtk_widget_show (priv->checkbox_outgoing_smtp_specific);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+ connect_for_modified (self, priv->checkbox_outgoing_smtp_specific);
+
+ /* Connection-specific SMTP-Severs Edit button: */
+ if (!priv->button_outgoing_smtp_servers)
+ priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_edit"));
+ caption = hildon_caption_new (sizegroup, _("mcen_fi_advsetup_optional_smtp"),
+ priv->button_outgoing_smtp_servers, NULL, HILDON_CAPTION_OPTIONAL);
+ hildon_caption_set_child_expand (HILDON_CAPTION (caption), FALSE);
+ gtk_widget_show (priv->button_outgoing_smtp_servers);
+ gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_widget_show (caption);
+
+ /* Only enable the button when the checkbox is checked: */
+ enable_widget_for_togglebutton (priv->button_outgoing_smtp_servers,
+ GTK_TOGGLE_BUTTON (priv->checkbox_outgoing_smtp_specific));
+
+ g_object_unref (sizegroup);
+
+ g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked",
+ G_CALLBACK (on_button_outgoing_smtp_servers), self);
+
+ gtk_widget_show (GTK_WIDGET (box));
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrollwin), box);
+ gtk_widget_show(scrollwin);
+
+ focus_adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrollwin));
+ gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), focus_adjustment);
+
+ return GTK_WIDGET (scrollwin);
+}
+
+static gboolean
+check_data (ModestDefaultAccountSettingsDialog *self)
+{
+ gchar* account_title;
+ const gchar* email_address;
+ const gchar* hostname;
+ const gchar* hostname2;
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ /* Check that the title is not already in use: */
+ account_title = get_entered_account_title (self);
+ if (!account_title)
+ return FALSE; /* Should be prevented already anyway. */
+
+ if (strcmp(account_title, priv->original_account_title) != 0) {
+ gboolean name_in_use;
+
+ /* Check the changed title: */
+ name_in_use = modest_account_mgr_account_with_display_name_exists (priv->account_manager,
+ account_title);
+
+ if (name_in_use) {
+ /* Warn the user via a dialog: */
+ modest_platform_information_banner(NULL, NULL, _("mail_ib_account_name_already_existing"));
+
+ g_free (account_title);
+ return FALSE;
+ }
+ }
+
+ g_free (account_title);
+ account_title = NULL;
+
+ /* Check that the email address is valid: */
+ email_address = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_email));
+ if ((!email_address) || (strlen(email_address) == 0)) {
+ return FALSE;
+ }
+
+ if (!modest_text_utils_validate_email_address (email_address, NULL)) {
+ /* Warn the user via a dialog: */
+ modest_platform_information_banner (NULL, NULL, _("mcen_ib_invalid_email"));
+
+ /* Return focus to the email address entry: */
+ gtk_widget_grab_focus (priv->entry_user_email);
+ gtk_editable_select_region (GTK_EDITABLE (priv->entry_user_email), 0, -1);
+ return FALSE;
+ }
+
+ /* make sure the domain name for the incoming server is valid */
+ hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_incomingserver));
+ if ((!hostname) || (strlen(hostname) == 0)) {
+ return FALSE;
+ }
+
+ if (!modest_text_utils_validate_domain_name (hostname)) {
+ /* Warn the user via a dialog: */
+ modest_platform_information_banner (NULL, NULL, _("mcen_ib_invalid_servername"));
+
+ /* Return focus to the email address entry: */
+ gtk_widget_grab_focus (priv->entry_incomingserver);
+ gtk_editable_select_region (GTK_EDITABLE (priv->entry_incomingserver), 0, -1);
+ return FALSE;
+ }
+
+ /* make sure the domain name for the outgoing server is valid */
+ hostname2 = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
+ if ((!hostname2) || (strlen(hostname2) == 0)) {
+ return FALSE;
+ }
+
+ if (!modest_text_utils_validate_domain_name (hostname2)) {
+ /* Warn the user via a dialog: */
+ modest_platform_information_banner (priv->entry_outgoingserver, NULL, _("mcen_ib_invalid_servername"));
+
+ /* Return focus to the email address entry: */
+ gtk_widget_grab_focus (priv->entry_outgoingserver);
+ gtk_editable_select_region (GTK_EDITABLE (priv->entry_outgoingserver), 0, -1);
+ return FALSE;
+ }
+
+/* /\* Find a suitable authentication method when secure authentication is desired *\/ */
+/* port_num = hildon_number_editor_get_value ( */
+/* HILDON_NUMBER_EDITOR (priv->entry_incoming_port)); */
+/* username = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username)); */
+
+/* protocol_registry = modest_runtime_get_protocol_registry (); */
+
+/* protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity ( */
+/* MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security)); */
+/* if (!modest_protocol_registry_protocol_type_is_secure(protocol_registry, protocol_security_incoming)) */
+/* { */
+/* if (gtk_toggle_button_get_active ( */
+/* GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth))) { */
+/* GError *error = NULL; */
+/* GList *list_auth_methods; */
+
+/* list_auth_methods = */
+/* modest_utils_get_supported_secure_authentication_methods (priv->incoming_protocol, */
+/* hostname, port_num, username, GTK_WINDOW (self), &error); */
+/* if (list_auth_methods) { */
+/* GList* method; */
+
+/* /\* Use the first supported method. */
+/* * TODO: Should we prioritize them, to prefer a particular one? *\/ */
+/* for (method = list_auth_methods; method != NULL; method = g_list_next(method)) */
+/* { */
+/* ModestProtocolType proto = (ModestProtocolType)(GPOINTER_TO_INT(method->data)); */
+/* // Allow secure methods, e.g MD5 only */
+/* if (modest_protocol_registry_protocol_type_is_secure(protocol_registry, proto)) */
+/* { */
+/* priv->protocol_authentication_incoming = proto; */
+/* break; */
+/* } */
+/* } */
+/* g_list_free (list_auth_methods); */
+/* } */
+
+/* if (list_auth_methods == NULL || */
+/* !modest_protocol_registry_protocol_type_is_secure(protocol_registry, priv->protocol_authentication_incoming)) */
+/* { */
+/* if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() || */
+/* error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED) */
+/* modest_platform_information_banner(GTK_WIDGET (self), NULL, */
+/* _("mcen_ib_unableto_discover_auth_methods")); */
+
+/* if(error != NULL) */
+/* g_error_free(error); */
+
+/* /\* This is a nasty hack. jschmid. *\/ */
+/* /\* Don't let the dialog close *\/ */
+/* /\*g_signal_stop_emission_by_name (dialog, "response");*\/ */
+/* return FALSE; */
+/* } */
+/* } */
+/* } */
+
+ return TRUE;
+}
+
+static void
+on_response (GtkDialog *wizard_dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ ModestDefaultAccountSettingsDialog *self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (wizard_dialog);
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+ gboolean prevent_response = FALSE, sec_changed;
+ ModestSecurityOptionsView *incoming_sec, *outgoing_sec;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+ enable_buttons (self);
+
+ /* Check if security widgets changed */
+ incoming_sec = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security);
+ outgoing_sec = MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security);
+ sec_changed =
+ modest_security_options_view_changed (incoming_sec, priv->settings) ||
+ modest_security_options_view_changed (outgoing_sec, priv->settings);
+
+ /* Warn about unsaved changes: */
+ if (response_id == GTK_RESPONSE_CANCEL && (priv->modified || sec_changed)) {
+ GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
+ _("imum_nc_wizard_confirm_lose_changes")));
+ /* TODO: These button names will be ambiguous, and not specified in the UI specification. */
+
+ const gint dialog_response = gtk_dialog_run (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ if (dialog_response != GTK_RESPONSE_OK)
+ prevent_response = TRUE;
+ }
+ /* Check for invalid input: */
+ else if (response_id != GTK_RESPONSE_CANCEL && !check_data (self)) {
+ prevent_response = TRUE;
+ }
+
+ if (prevent_response) {
+ /* This is a nasty hack. murrayc. */
+ /* Don't let the dialog close */
+ g_signal_stop_emission_by_name (wizard_dialog, "response");
+ return;
+ }
+
+ if (response_id == GTK_RESPONSE_OK) {
+ /* Try to save the changes if modified (NB #59251): */
+ if (priv->modified || sec_changed) {
+ if (save_configuration (self)) {
+ /* Do not show the account-saved dialog if we are just saving this
+ * temporarily, because from the user's point of view it will not
+ * really be saved (saved + enabled) until later
+ */
+ if (modest_account_settings_get_account_name (priv->settings) != NULL) {
+ ModestServerAccountSettings *store_settings;
+ ModestServerAccountSettings *transport_settings;
+ const gchar *store_account_name;
+ const gchar *transport_account_name;
+
+
+ store_settings = modest_account_settings_get_store_settings (priv->settings);
+ transport_settings = modest_account_settings_get_transport_settings (priv->settings);
+ store_account_name = modest_server_account_settings_get_account_name (store_settings);
+ transport_account_name = modest_server_account_settings_get_account_name (transport_settings);
+
+ if (store_account_name) {
+ modest_account_mgr_notify_account_update (priv->account_manager,
+ store_account_name);
+ }
+ if (transport_account_name) {
+ modest_account_mgr_notify_account_update (priv->account_manager,
+ transport_account_name);
+ }
+ g_object_unref (store_settings);
+ g_object_unref (transport_settings);
+
+ modest_platform_information_banner(NULL, NULL, _("mcen_ib_advsetup_settings_saved"));
+ }
+ } else {
+ modest_platform_information_banner (NULL, NULL, _("mail_ib_setting_failed"));
+ }
+ }
+ }
+}
+
+static void
+modest_default_account_settings_dialog_init (ModestDefaultAccountSettingsDialog *self)
+{
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE(self);
+
+ priv->incoming_security = NULL;
+ priv->outgoing_security = NULL;
+
+ /* Create the notebook to be used by the GtkDialog base class:
+ * Each page of the notebook will be a page of the wizard: */
+ priv->notebook = GTK_NOTEBOOK (gtk_notebook_new());
+ priv->settings = modest_account_settings_new ();
+
+ /* Get the account manager object,
+ * so we can check for existing accounts,
+ * and create new accounts: */
+ priv->account_manager = modest_runtime_get_account_mgr ();
+ g_assert (priv->account_manager);
+ g_object_ref (priv->account_manager);
+
+ priv->protocol_authentication_incoming = MODEST_PROTOCOLS_AUTH_PASSWORD;
+
+ /* Create the common pages,
+ */
+ priv->page_account_details = create_page_account_details (self);
+ priv->page_user_details = create_page_user_details (self);
+ priv->page_incoming = create_page_incoming (self);
+ priv->page_outgoing = create_page_outgoing (self);
+
+ /* Add the notebook pages: */
+ gtk_notebook_append_page (priv->notebook, priv->page_account_details,
+ gtk_label_new (_("mcen_ti_account_settings_account")));
+ gtk_notebook_append_page (priv->notebook, priv->page_user_details,
+ gtk_label_new (_("mcen_ti_account_settings_userinfo")));
+ gtk_notebook_append_page (priv->notebook, priv->page_incoming,
+ gtk_label_new (_("mcen_ti_advsetup_retrieval")));
+ gtk_notebook_append_page (priv->notebook, priv->page_outgoing,
+ gtk_label_new (_("mcen_ti_advsetup_sending")));
+
+ GtkDialog *dialog = GTK_DIALOG (self);
+ gtk_container_add (GTK_CONTAINER (dialog->vbox), GTK_WIDGET (priv->notebook));
+ gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), MODEST_MARGIN_HALF);
+ gtk_widget_show (GTK_WIDGET (priv->notebook));
+
+ /* Add the buttons: */
+ gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK);
+ gtk_dialog_add_button (GTK_DIALOG(self), _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL);
+
+ /* Connect to the dialog's response signal: */
+ /* We use connect-before
+ * so we can stop the signal emission,
+ * to stop the default signal handler from closing the dialog.
+ */
+ g_signal_connect (G_OBJECT (self), "response",
+ G_CALLBACK (on_response), self);
+
+ priv->modified = FALSE;
+
+ /* When this window is shown, hibernation should not be possible,
+ * because there is no sensible way to save the state: */
+ modest_window_mgr_prevent_hibernation_while_window_is_shown (
+ modest_runtime_get_window_mgr (), GTK_WINDOW (self));
+
+ hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_accountsettings",
+ modest_maemo_utils_get_osso_context());
+}
+
+ModestAccountSettingsDialog*
+modest_default_account_settings_dialog_new (void)
+{
+ return g_object_new (MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG, NULL);
+}
+
+/** Update the UI with the stored account details, so they can be edited.
+ * @account_name: Name of the account, which should contain incoming and outgoing server accounts.
+ */
+static void
+modest_default_account_settings_dialog_load_settings (ModestAccountSettingsDialog *dialog,
+ ModestAccountSettings *settings)
+{
+ ModestServerAccountSettings *incoming_account;
+ ModestServerAccountSettings *outgoing_account;
+ ModestProtocolRegistry *protocol_registry;
+ const gchar *account_name, *server_account_name;
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+ gint page_num;
+ gboolean username_known;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog));
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+
+ incoming_account = modest_account_settings_get_store_settings (settings);
+ outgoing_account = modest_account_settings_get_transport_settings (settings);
+
+ account_name = modest_account_settings_get_account_name (settings);
+
+ /* Save the account name so we can refer to it later: */
+ if (priv->account_name)
+ g_free (priv->account_name);
+ priv->account_name = g_strdup (account_name);
+
+ if (priv->settings)
+ g_object_unref (priv->settings);
+ priv->settings = g_object_ref (settings);
+
+ /* Save the account title so we can refer to it if the user changes it: */
+ if (priv->original_account_title)
+ g_free (priv->original_account_title);
+ priv->original_account_title = g_strdup (modest_account_settings_get_display_name (settings));
+
+ /* Show the account data in the widgets: */
+
+ /* Note that we never show the non-display name in the UI.
+ * (Though the display name defaults to the non-display name at the start.) */
+ gtk_entry_set_text( GTK_ENTRY (priv->entry_account_title),
+ null_means_empty (modest_account_settings_get_display_name (settings)));
+ gtk_entry_set_text( GTK_ENTRY (priv->entry_user_name),
+ null_means_empty (modest_account_settings_get_fullname (settings)));
+ gtk_entry_set_text( GTK_ENTRY (priv->entry_user_email),
+ null_means_empty (modest_account_settings_get_email_address (settings)));
+ modest_retrieve_combo_box_set_active_retrieve_conf (MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve),
+ modest_account_settings_get_retrieve_type (settings));
+ modest_limit_retrieve_combo_box_set_active_limit_retrieve (
+ MODEST_LIMIT_RETRIEVE_COMBO_BOX (priv->combo_limit_retrieve),
+ modest_account_settings_get_retrieve_limit (settings));
+
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbox_leave_messages),
+ modest_account_settings_get_leave_messages_on_server (settings));
+
+
+ if (incoming_account) {
+ const gchar *username, *password, *hostname, *proto_str, *account_title;
+ gchar *proto_name, *title;
+ ModestProtocolType incoming_protocol;
+
+ modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve), modest_server_account_settings_get_protocol (incoming_account));
+
+ if (!modest_protocol_registry_protocol_type_has_leave_on_server (protocol_registry,
+ modest_server_account_settings_get_protocol (incoming_account))) {
+ gtk_widget_hide (priv->caption_leave_messages);
+ } else {
+ gtk_widget_show (priv->caption_leave_messages);
+ }
+
+ /* Remember this for later: */
+ incoming_protocol = modest_server_account_settings_get_protocol (incoming_account);;
+
+ hostname = modest_server_account_settings_get_hostname (incoming_account);
+ username = modest_server_account_settings_get_username (incoming_account);
+ password = modest_server_account_settings_get_password (incoming_account);
+ gtk_entry_set_text( GTK_ENTRY (priv->entry_user_username),
+ null_means_empty (username));
+ gtk_entry_set_text( GTK_ENTRY (priv->entry_user_password),
+ null_means_empty (password));
+
+ gtk_entry_set_text( GTK_ENTRY (priv->entry_incomingserver),
+ null_means_empty (hostname));
+
+ /* Load security settings */
+ modest_security_options_view_load_settings (
+ MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
+ settings);
+ gtk_widget_show (priv->incoming_security);
+
+ /* Update the incoming label */
+ update_incoming_server_title (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (dialog),
+ incoming_protocol);
+
+ /* Set window title according to account */
+ proto_str = modest_protocol_get_display_name (modest_protocol_registry_get_protocol_by_type (protocol_registry, incoming_protocol));
+ proto_name = g_utf8_strup (proto_str, -1);
+ account_title = modest_account_settings_get_display_name(settings);
+ title = g_strdup_printf(_("mcen_ti_account_settings"), proto_name, account_title);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), title);
+
+ g_free (proto_name);
+ g_free (title);
+ g_object_unref (incoming_account);
+ }
+
+ outgoing_account = modest_account_settings_get_transport_settings (settings);
+ if (outgoing_account) {
+ const gchar *hostname;
+ const gchar *username;
+ const gchar *password;
+ ModestProtocolType outgoing_protocol;
+
+ /* Remember this for later: */
+ outgoing_protocol =
+ modest_server_account_settings_get_protocol (outgoing_account);
+
+ hostname = modest_server_account_settings_get_hostname (outgoing_account);
+ username = modest_server_account_settings_get_username (outgoing_account);
+ password = modest_server_account_settings_get_password (outgoing_account);
+ gtk_entry_set_text( GTK_ENTRY (priv->entry_outgoingserver),
+ null_means_empty (hostname));
+
+ /* Load security settings */
+ modest_security_options_view_load_settings (
+ MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security),
+ settings);
+ gtk_widget_show (priv->outgoing_security);
+
+ const gboolean has_specific =
+ modest_account_settings_get_use_connection_specific_smtp (settings);
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (priv->checkbox_outgoing_smtp_specific),
+ has_specific);
+ g_object_unref (outgoing_account);
+ }
+
+ /* Switch to user page */
+ page_num = gtk_notebook_page_num (priv->notebook,priv->page_user_details);
+ gtk_notebook_set_current_page (priv->notebook, page_num);
+
+ /* Check if we allow changes or not */
+ server_account_name = modest_server_account_settings_get_account_name (incoming_account);
+ username_known =
+ modest_account_mgr_get_server_account_username_has_succeeded (priv->account_manager,
+ server_account_name);
+ gtk_widget_set_sensitive (priv->entry_user_username, !username_known);
+ gtk_widget_set_sensitive (priv->entry_incomingserver, !username_known);
+ modest_security_options_view_enable_changes (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
+ !username_known);
+
+
+ /* Unset the modified flag so we can detect changes later: */
+ priv->modified = FALSE;
+}
+
+static gboolean
+save_configuration (ModestDefaultAccountSettingsDialog *dialog)
+{
+ const gchar* user_fullname;
+ const gchar* emailaddress;
+ ModestServerAccountSettings *store_settings;
+ ModestServerAccountSettings *transport_settings;
+ ModestAccountRetrieveType retrieve_type;
+ gint retrieve_limit;
+ gboolean leave_on_server;
+ const gchar* hostname;
+ const gchar* username;
+ const gchar* password;
+ gchar* account_title;
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+ const gchar* account_name;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (dialog);
+ account_name = priv->account_name;
+
+ /* Set the account data from the widgets: */
+ user_fullname = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_name));
+ modest_account_settings_set_fullname (priv->settings, user_fullname);
+
+ emailaddress = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_email));
+ modest_account_settings_set_email_address (priv->settings, emailaddress);
+
+ /* Signature: */
+ if (priv->signature_dialog) {
+ gboolean use_signature = FALSE;
+ gchar *signature;
+ signature = modest_signature_editor_dialog_get_settings (MODEST_SIGNATURE_EDITOR_DIALOG (priv->signature_dialog),
+ &use_signature);
+
+ modest_account_settings_set_use_signature (priv->settings, use_signature);
+ modest_account_settings_set_signature (priv->settings, signature);
+ }
+
+ retrieve_type = modest_retrieve_combo_box_get_active_retrieve_conf (
+ MODEST_RETRIEVE_COMBO_BOX (priv->combo_retrieve));
+ modest_account_settings_set_retrieve_type (priv->settings, retrieve_type);
+
+ retrieve_limit = modest_limit_retrieve_combo_box_get_active_limit_retrieve (
+ MODEST_LIMIT_RETRIEVE_COMBO_BOX (priv->combo_limit_retrieve));
+ modest_account_settings_set_retrieve_limit (priv->settings, retrieve_limit);
+
+ leave_on_server = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->checkbox_leave_messages));
+ modest_account_settings_set_leave_messages_on_server (priv->settings, leave_on_server);
+
+ store_settings = modest_account_settings_get_store_settings (priv->settings);
+
+ hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_incomingserver));
+ modest_server_account_settings_set_hostname (store_settings, hostname);
+
+ username = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username));
+ modest_server_account_settings_set_username (store_settings, username);
+
+ password = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password));
+ modest_server_account_settings_set_password (store_settings, password);
+
+ /* Save security settings */
+ modest_security_options_view_save_settings (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security),
+ priv->settings);
+
+ g_object_unref (store_settings);
+
+ /* Outgoing: */
+ transport_settings = modest_account_settings_get_transport_settings (priv->settings);
+
+ hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
+ modest_server_account_settings_set_hostname (transport_settings, hostname);
+
+ /* Save security settings */
+ modest_security_options_view_save_settings (
+ MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security),
+ priv->settings);
+
+ /* Set the changed account title last, to simplify the previous code: */
+ account_title = get_entered_account_title (dialog);
+ if (!account_title)
+ return FALSE; /* Should be prevented already anyway. */
+
+/* if (strcmp (account_title, account_name) != 0) { */
+ modest_account_settings_set_display_name (priv->settings, account_title);
+/* } */
+ g_free (account_title);
+ account_title = NULL;
+
+ /* Save connection-specific SMTP server accounts: */
+ modest_account_settings_set_use_connection_specific_smtp
+ (priv->settings,
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->checkbox_outgoing_smtp_specific)));
+
+ /* this configuration is not persistent, we should not save */
+ if (account_name != NULL)
+ modest_account_mgr_save_account_settings (priv->account_manager, priv->settings);
+
+ return TRUE;
+}
+
+static gboolean entry_is_empty (GtkWidget *entry)
+{
+ if (!entry)
+ return FALSE;
+
+ const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
+ if ((!text) || (strlen(text) == 0))
+ return TRUE;
+ else {
+ /* Strip it of whitespace at the start and end: */
+ gchar *stripped = g_strdup (text);
+ stripped = g_strstrip (stripped);
+
+ if (!stripped)
+ return TRUE;
+
+ const gboolean result = (strlen (stripped) == 0);
+
+ g_free (stripped);
+ return result;
+ }
+}
+
+static void
+enable_buttons (ModestDefaultAccountSettingsDialog *self)
+{
+ gboolean enable_ok = TRUE;
+ ModestProtocolRegistry *protocol_registry;
+ ModestDefaultAccountSettingsDialogPrivate *priv;
+
+ priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+ /* The account details title is mandatory: */
+ if (entry_is_empty(priv->entry_account_title))
+ enable_ok = FALSE;
+
+ /* The user details username is mandatory: */
+ if (enable_ok && entry_is_empty(priv->entry_user_username))
+ enable_ok = FALSE;
+
+ /* The user details email address is mandatory: */
+ if (enable_ok && entry_is_empty (priv->entry_user_email))
+ enable_ok = FALSE;
+
+ /* The custom incoming server is mandatory: */
+ if (enable_ok && entry_is_empty(priv->entry_incomingserver))
+ enable_ok = FALSE;
+
+ /* The custom outgoing server is mandatory: */
+ if (enable_ok && entry_is_empty(priv->entry_outgoingserver))
+ enable_ok = FALSE;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+
+ /* Enable the buttons,
+ * identifying them via their associated response codes:
+ */
+ GtkDialog *dialog_base = GTK_DIALOG (self);
+ gtk_dialog_set_response_sensitive (dialog_base,
+ GTK_RESPONSE_OK,
+ enable_ok);
+}
+
+static void
+modest_default_account_settings_dialog_class_init (ModestDefaultAccountSettingsDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (klass, sizeof (ModestDefaultAccountSettingsDialogPrivate));
+
+ object_class->dispose = modest_default_account_settings_dialog_dispose;
+ object_class->finalize = modest_default_account_settings_dialog_finalize;
+}
+
+static void
+modest_account_settings_dialog_init (gpointer g_iface, gpointer iface_data)
+{
+ ModestAccountSettingsDialogClass *iface = (ModestAccountSettingsDialogClass *) g_iface;
+
+ iface->load_settings = modest_default_account_settings_dialog_load_settings;
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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-runtime.h"
+#include "modest-security-options-view-priv.h"
+#include "modest-maemo-security-options-view.h"
+#include "modest-text-utils.h"
+#include "modest-platform.h"
+#include "modest-account-protocol.h"
+#include "widgets/modest-ui-constants.h"
+#include "widgets/modest-validating-entry.h"
+#include "widgets/modest-serversecurity-combo-box.h"
+#include "widgets/modest-secureauth-combo-box.h"
+#include "maemo/easysetup/modest-easysetup-servertype-combo-box.h"
+#ifdef MODEST_HAVE_HILDON0_WIDGETS
+#include <hildon-widgets/hildon-caption.h>
+#include <hildon-widgets/hildon-number-editor.h>
+#else
+#include <hildon/hildon-caption.h>
+#include <hildon/hildon-number-editor.h>
+#endif /*MODEST_HAVE_HILDON0_WIDGETS*/
+
+#define PORT_MIN 1
+#define PORT_MAX 65535
+
+typedef struct _ModestMaemoSecurityOptionsViewPrivate ModestMaemoSecurityOptionsViewPrivate;
+struct _ModestMaemoSecurityOptionsViewPrivate {
+};
+
+#define MODEST_MAEMO_SECURITY_OPTIONS_VIEW_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+ MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW, \
+ ModestMaemoSecurityOptionsViewPrivate))
+
+static void modest_maemo_security_options_view_init (ModestMaemoSecurityOptionsView *obj);
+static void modest_maemo_security_options_view_finalize (GObject *obj);
+static void modest_maemo_security_options_view_class_init (ModestMaemoSecurityOptionsViewClass *klass);
+
+G_DEFINE_TYPE (ModestMaemoSecurityOptionsView,
+ modest_maemo_security_options_view,
+ MODEST_TYPE_SECURITY_OPTIONS_VIEW);
+
+static void on_entry_changed (GtkEditable *editable, gpointer user_data);
+
+/* Tracks changes in the incoming security combo box */
+static void
+on_security_changed (GtkWidget *widget,
+ ModestMaemoSecurityOptionsView *self)
+{
+ ModestSecurityOptionsViewPrivate* ppriv;
+ ModestServersecurityComboBox *combo;
+ ModestProtocolType proto_type;
+ ModestProtocolRegistry *proto_registry;
+ gboolean is_secure;
+
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ proto_registry = modest_runtime_get_protocol_registry ();
+ combo = MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view);
+ proto_type = modest_serversecurity_combo_box_get_active_serversecurity (combo);
+
+ is_secure = modest_protocol_registry_protocol_type_has_tag (proto_registry, proto_type,
+ MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS);
+
+ if (MODEST_SECURITY_OPTIONS_VIEW (self)->type == MODEST_SECURITY_OPTIONS_INCOMING) {
+ /* Activate and dim checkbutton if it's secure */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ppriv->auth_view),
+ is_secure);
+ gtk_widget_set_sensitive (ppriv->auth_view, !is_secure);
+ } else {
+
+ }
+
+ if (ppriv->full) {
+ gint port_number =
+ modest_serversecurity_combo_box_get_active_serversecurity_port (MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view));
+
+ if(port_number) {
+ hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->port_view),
+ port_number);
+ }
+ }
+}
+
+static void
+on_auth_changed (GtkWidget *widget,
+ ModestMaemoSecurityOptionsView *self)
+{
+ ModestSecurityOptionsViewPrivate* ppriv;
+ ModestSecureauthComboBox *combo;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocolType auth_proto;
+ gboolean secureauth_used;
+ GtkWidget *user_caption, *pwd_caption;
+
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ combo = MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view);
+
+ auth_proto = modest_secureauth_combo_box_get_active_secureauth (combo);
+ secureauth_used = modest_protocol_registry_protocol_type_is_secure (protocol_registry,
+ auth_proto);
+
+ /* Get captions, well dimm the whole widget */
+ user_caption = gtk_widget_get_parent (ppriv->user_entry);
+ pwd_caption = gtk_widget_get_parent (ppriv->pwd_entry);
+
+ /* Enable / disable */
+ gtk_widget_set_sensitive (user_caption, secureauth_used);
+ gtk_widget_set_sensitive (pwd_caption, secureauth_used);
+
+ /* Check if mandatory data is missing */
+ on_entry_changed (GTK_EDITABLE (ppriv->user_entry), (gpointer) self);
+}
+
+static void
+create_incoming_security (ModestSecurityOptionsView* self,
+ GtkSizeGroup *size_group)
+{
+ ModestSecurityOptionsViewPrivate *ppriv;
+ GtkWidget *combo_caption, *check_caption, *entry_caption;
+
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ /* Create widgets for incoming security */
+ ppriv->security_view = GTK_WIDGET (modest_serversecurity_combo_box_new ());
+ combo_caption = hildon_caption_new (size_group, _("mcen_li_emailsetup_secure_connection"),
+ ppriv->security_view, NULL,
+ HILDON_CAPTION_OPTIONAL);
+
+ if (ppriv->full) {
+ ppriv->port_view = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
+ entry_caption = hildon_caption_new (size_group, _("mcen_fi_emailsetup_port"),
+ ppriv->port_view, NULL,
+ HILDON_CAPTION_OPTIONAL);
+ }
+
+ ppriv->auth_view = gtk_check_button_new ();
+ check_caption =
+ hildon_caption_new (size_group, _("mcen_li_emailsetup_secure_authentication"),
+ ppriv->auth_view, NULL, HILDON_CAPTION_OPTIONAL);
+
+ /* Track changes in UI */
+ g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
+ G_CALLBACK (on_security_changed), self);
+
+ /* Pack into container */
+ gtk_box_pack_start (GTK_BOX (self), combo_caption,
+ FALSE, FALSE, MODEST_MARGIN_HALF);
+ if (ppriv->full)
+ gtk_box_pack_start (GTK_BOX (self), entry_caption,
+ FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_box_pack_start (GTK_BOX (self), check_caption,
+ FALSE, FALSE, MODEST_MARGIN_HALF);
+
+ /* Show widgets */
+ if (ppriv->full) {
+ gtk_widget_show (ppriv->port_view);
+ gtk_widget_show (entry_caption);
+ }
+ gtk_widget_show (ppriv->security_view);
+ gtk_widget_show (ppriv->auth_view);
+ gtk_widget_show (combo_caption);
+ gtk_widget_show (check_caption);
+}
+
+static void
+on_entry_max (ModestValidatingEntry *self,
+ gpointer user_data)
+{
+ modest_platform_information_banner (GTK_WIDGET (self), NULL,
+ _CS("ckdg_ib_maximum_characters_reached"));
+}
+
+/*
+ * TODO: call this whenever the auth combo changes. If we set it
+ * explicitely at the beggining to a value then there is no need to
+ * call this handler directly at the beginning
+ */
+static void
+on_entry_changed (GtkEditable *editable,
+ gpointer user_data)
+{
+ ModestSecurityOptionsView* self;
+ ModestSecurityOptionsViewPrivate *ppriv;
+ ModestProtocolType auth_proto;
+ ModestSecureauthComboBox *combo;
+ gboolean is_secure, missing;
+ ModestProtocolRegistry *protocol_registry;
+
+ self = MODEST_SECURITY_OPTIONS_VIEW (user_data);
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+
+ /* Outgoing username is mandatory if outgoing auth is secure */
+ combo = MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view);
+ auth_proto = modest_secureauth_combo_box_get_active_secureauth (combo);
+ is_secure = modest_protocol_registry_protocol_type_is_secure (protocol_registry,
+ auth_proto);
+
+ if (is_secure &&
+ !g_ascii_strcasecmp (gtk_entry_get_text (GTK_ENTRY (ppriv->user_entry)), "")) {
+ missing = TRUE;
+ } else {
+ missing = FALSE;
+ }
+
+ /* Emit a signal to notify if mandatory data is missing */
+ g_signal_emit_by_name (G_OBJECT (self), "missing_mandatory_data",
+ missing, NULL);
+}
+
+static void
+create_outgoing_security (ModestSecurityOptionsView* self,
+ GtkSizeGroup *size_group)
+{
+ ModestSecurityOptionsViewPrivate *ppriv;
+ GtkWidget *sec_caption, *auth_caption, *user_caption;
+ GtkWidget *pwd_caption, *port_caption;
+
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ /* The secure connection widgets */
+ ppriv->security_view = GTK_WIDGET (modest_serversecurity_combo_box_new ());
+ modest_serversecurity_combo_box_fill (MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view),
+ MODEST_PROTOCOLS_TRANSPORT_SMTP);
+ sec_caption = hildon_caption_new (size_group, _("mcen_li_emailsetup_secure_connection"),
+ ppriv->security_view, NULL, HILDON_CAPTION_OPTIONAL);
+
+ /* The secure authentication widgets */
+ ppriv->auth_view = GTK_WIDGET (modest_secureauth_combo_box_new ());
+ auth_caption = hildon_caption_new (size_group, _("mcen_li_emailsetup_secure_authentication"),
+ ppriv->auth_view, NULL, HILDON_CAPTION_OPTIONAL);
+
+ if (ppriv->full) {
+ gchar *user_label;
+
+ /* Username widgets */
+ ppriv->user_entry = GTK_WIDGET (modest_validating_entry_new ());
+
+ /* Auto-capitalization is the default, so let's turn it off: */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->user_entry),
+ HILDON_GTK_INPUT_MODE_FULL);
+
+ user_label = g_strdup_printf("%s*", _("mail_fi_username"));
+ user_caption = hildon_caption_new (size_group, user_label,
+ ppriv->user_entry, NULL,
+ HILDON_CAPTION_MANDATORY);
+ g_free (user_label);
+
+ /* Prevent the use of some characters. Limit the max
+ length as well */
+ modest_validating_entry_set_unallowed_characters_whitespace (
+ MODEST_VALIDATING_ENTRY (ppriv->user_entry));
+ gtk_entry_set_max_length (GTK_ENTRY (ppriv->user_entry), 64);
+ modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (ppriv->user_entry),
+ on_entry_max, self);
+
+ /* Password widgets */
+ ppriv->pwd_entry = gtk_entry_new ();
+
+ /* Auto-capitalization is the default, so let's turn it off */
+ hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->pwd_entry),
+ HILDON_GTK_INPUT_MODE_FULL |
+ HILDON_GTK_INPUT_MODE_INVISIBLE);
+ gtk_entry_set_visibility (GTK_ENTRY (ppriv->pwd_entry), FALSE);
+
+ pwd_caption = hildon_caption_new (size_group, _("mail_fi_password"),
+ ppriv->pwd_entry, NULL,
+ HILDON_CAPTION_OPTIONAL);
+
+ ppriv->port_view = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
+ port_caption = hildon_caption_new (size_group, _("mcen_fi_emailsetup_port"),
+ ppriv->port_view, NULL,
+ HILDON_CAPTION_OPTIONAL);
+ }
+
+ /* Track changes in UI */
+ g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
+ G_CALLBACK (on_security_changed), self);
+ if (ppriv->full) {
+ g_signal_connect (G_OBJECT (ppriv->auth_view), "changed",
+ G_CALLBACK (on_auth_changed), self);
+ g_signal_connect (G_OBJECT (ppriv->user_entry), "changed",
+ G_CALLBACK (on_entry_changed), self);
+ }
+
+ /* Initialize widgets */
+ modest_serversecurity_combo_box_set_active_serversecurity (
+ MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view),
+ MODEST_PROTOCOLS_CONNECTION_NONE);
+ modest_secureauth_combo_box_set_active_secureauth (
+ MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view),
+ MODEST_PROTOCOLS_AUTH_NONE);
+
+ /* Pack into container */
+ if (ppriv->full) {
+ gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_box_pack_start (GTK_BOX (self), user_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_box_pack_start (GTK_BOX (self), pwd_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_box_pack_start (GTK_BOX (self), sec_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_box_pack_start (GTK_BOX (self), port_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ } else {
+ /* The order is different */
+ gtk_box_pack_start (GTK_BOX (self), sec_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+ }
+
+ /* Show widgets */
+ if (ppriv->full) {
+ gtk_widget_show (ppriv->pwd_entry);
+ gtk_widget_show (ppriv->user_entry);
+ gtk_widget_show (ppriv->port_view);
+ gtk_widget_show (pwd_caption);
+ gtk_widget_show (user_caption);
+ gtk_widget_show (port_caption);
+ }
+ gtk_widget_show (ppriv->security_view);
+ gtk_widget_show (ppriv->auth_view);
+ gtk_widget_show (sec_caption);
+ gtk_widget_show (auth_caption);
+}
+
+GtkWidget *
+modest_maemo_security_options_view_new (ModestSecurityOptionsType type,
+ gboolean full,
+ GtkSizeGroup *size_group)
+{
+ ModestSecurityOptionsView* self;
+ ModestSecurityOptionsViewPrivate *ppriv;
+
+ self = (ModestSecurityOptionsView *)
+ g_object_new (MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW, NULL);
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ ppriv->full = full;
+ self->type = type;
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+ create_incoming_security (self, size_group);
+ else
+ create_outgoing_security (self, size_group);
+
+ return (GtkWidget *) self;
+}
+
+static void
+modest_maemo_security_options_view_load_settings (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings)
+{
+ ModestSecurityOptionsViewPrivate *ppriv;
+ ModestServerAccountSettings *server_settings;
+ gint port_number;
+
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+ server_settings = modest_account_settings_get_store_settings (settings);
+ else
+ server_settings = modest_account_settings_get_transport_settings (settings);
+ port_number = modest_server_account_settings_get_port (server_settings);
+
+ if (port_number == 0) {
+ /* Show the appropriate port number */
+ on_security_changed (ppriv->security_view,
+ MODEST_MAEMO_SECURITY_OPTIONS_VIEW (self));
+ } else if (ppriv->full) {
+ /* Keep the user-entered port-number, or the
+ * already-appropriate automatic port number */
+ hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->port_view),
+ port_number);
+ }
+ /* Frees */
+ g_object_unref (server_settings);
+}
+
+static void
+modest_maemo_security_options_view_save_settings (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings)
+{
+ ModestServerAccountSettings *server_settings;
+ ModestSecurityOptionsViewPrivate *ppriv;
+ gint server_port;
+
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+ server_settings = modest_account_settings_get_store_settings (settings);
+ else
+ server_settings = modest_account_settings_get_transport_settings (settings);
+
+ if (ppriv->full) {
+ server_port = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (ppriv->port_view));
+ } else {
+ server_port = modest_serversecurity_combo_box_get_active_serversecurity_port (MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view));
+ }
+
+ modest_server_account_settings_set_port (server_settings, server_port);
+
+ /* Frees */
+ g_object_unref (server_settings);
+}
+
+static gboolean
+modest_maemo_security_options_view_changed (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings)
+{
+ ModestServerAccountSettings *server_settings;
+ ModestSecurityOptionsViewPrivate *ppriv;
+ gint server_port;
+
+ /* If we're not showing the port number then it never changes */
+ if (!ppriv->full)
+ return FALSE;
+
+ ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+ server_settings = modest_account_settings_get_store_settings (settings);
+ else
+ server_settings = modest_account_settings_get_transport_settings (settings);
+
+ server_port =
+ hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (ppriv->port_view));
+
+ /* Frees */
+ g_object_unref (server_settings);
+
+ if (server_port != ppriv->initial_state.port)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static void
+modest_maemo_security_options_view_init (ModestMaemoSecurityOptionsView *obj)
+{
+}
+
+static void
+modest_maemo_security_options_view_finalize (GObject *obj)
+{
+ G_OBJECT_CLASS (modest_maemo_security_options_view_parent_class)->finalize (obj);
+}
+
+
+static void
+modest_maemo_security_options_view_class_init (ModestMaemoSecurityOptionsViewClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass*) klass;
+
+ modest_maemo_security_options_view_parent_class = g_type_class_peek_parent (klass);
+
+ g_type_class_add_private (gobject_class, sizeof (ModestMaemoSecurityOptionsViewPrivate));
+ gobject_class->finalize = modest_maemo_security_options_view_finalize;
+
+ MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->load_settings =
+ modest_maemo_security_options_view_load_settings;
+ MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->save_settings =
+ modest_maemo_security_options_view_save_settings;
+ MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->changed =
+ modest_maemo_security_options_view_changed;
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+#ifndef __MODEST_MAEMO_SECURITY_OPTIONS_VIEW_H__
+#define __MODEST_MAEMO_SECURITY_OPTIONS_VIEW_H__
+
+#include <glib-object.h>
+#include "modest-security-options-view.h"
+#include <gtk/gtkbox.h>
+#include <gtk/gtksizegroup.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW (modest_maemo_security_options_view_get_type())
+#define MODEST_MAEMO_SECURITY_OPTIONS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW,ModestMaemoSecurityOptionsView))
+#define MODEST_MAEMO_SECURITY_OPTIONS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW,GObject))
+#define MODEST_IS_MAEMO_SECURITY_OPTIONS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW))
+#define MODEST_IS_MAEMO_SECURITY_OPTIONS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW))
+#define MODEST_MAEMO_SECURITY_OPTIONS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MAEMO_SECURITY_OPTIONS_VIEW,ModestMaemoSecurityOptionsViewClass))
+
+typedef struct _ModestMaemoSecurityOptionsView ModestMaemoSecurityOptionsView;
+typedef struct _ModestMaemoSecurityOptionsViewClass ModestMaemoSecurityOptionsViewClass;
+
+struct _ModestMaemoSecurityOptionsView {
+ ModestSecurityOptionsView parent;
+};
+
+struct _ModestMaemoSecurityOptionsViewClass {
+ ModestSecurityOptionsViewClass parent_class;
+};
+
+/* member functions */
+GType modest_maemo_security_options_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget* modest_maemo_security_options_view_new (ModestSecurityOptionsType type,
+ gboolean full,
+ GtkSizeGroup *size_group);
+
+G_END_DECLS
+
+#endif /* __MODEST_MAEMO_SECURITY_OPTIONS_VIEW_H__ */
+
return new_menu;
}
-
-void
-modest_maemo_utils_on_entry_invalid_character (ModestValidatingEntry *self,
- const gchar* character,
- gpointer user_data)
-{
- gchar *message = NULL;
- const gchar *show_char = NULL;
-
- if (character)
- show_char = character;
- else {
- show_char = "' '";
- }
-
- message = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), show_char);
- hildon_banner_show_information(GTK_WIDGET (self), NULL, message);
-}
#include <gtk/gtk.h>
#include <stdio.h> /* for FILE* */
-#include <modest-protocol-info.h>
#include <tny-fs-stream.h>
#include <libosso.h>
#include "widgets/modest-global-settings-dialog.h"
*/
GtkWidget *modest_maemo_utils_get_manager_menubar_as_menu (GtkUIManager *manager, const gchar *item_name);
-void modest_maemo_utils_on_entry_invalid_character (ModestValidatingEntry *self,
- const gchar* character,
- gpointer user_data);
-
#endif /*__MODEST_MAEMO_UTILS_H__*/
static gboolean restore_paned_timeout_handler (gpointer *data);
-static gboolean show_retrieving_banner (gpointer user_data);
+static gboolean show_opening_banner (gpointer user_data);
static void on_window_destroy (GtkObject *widget,
gpointer userdata);
GtkWidget *updating_banner;
guint updating_banner_timeout;
- /* "Retrieving" banner for header view */
- GtkWidget *retrieving_banner;
- guint retrieving_banner_timeout;
+ /* "Opening" banner for header view */
+ GtkWidget *opening_banner;
+ guint opening_banner_timeout;
/* Display state */
osso_display_state_t display_state;
priv->sighandlers = NULL;
priv->updating_banner = NULL;
priv->updating_banner_timeout = 0;
- priv->retrieving_banner = NULL;
- priv->retrieving_banner_timeout = 0;
+ priv->opening_banner = NULL;
+ priv->opening_banner_timeout = 0;
priv->display_state = OSSO_DISPLAY_ON;
modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
priv->updating_banner = NULL;
}
- if (priv->retrieving_banner_timeout > 0) {
- g_source_remove (priv->retrieving_banner_timeout);
- priv->retrieving_banner_timeout = 0;
+ if (priv->opening_banner_timeout > 0) {
+ g_source_remove (priv->opening_banner_timeout);
+ priv->opening_banner_timeout = 0;
}
- if (priv->retrieving_banner) {
- gtk_widget_destroy (priv->retrieving_banner);
- priv->retrieving_banner = NULL;
+ if (priv->opening_banner) {
+ gtk_widget_destroy (priv->opening_banner);
+ priv->opening_banner = NULL;
}
if (priv->restore_paned_timeout > 0) {
wrap_in_scrolled_window (priv->contents_widget,
priv->details_widget);
}
- g_object_unref (selected_folderstore);
+ if (selected_folderstore)
+ g_object_unref (selected_folderstore);
modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->contents_widget),
FALSE);
}
switch (modest_mail_operation_get_type_operation (mail_op)) {
case MODEST_MAIL_OPERATION_TYPE_SEND_AND_RECEIVE:
case MODEST_MAIL_OPERATION_TYPE_RECEIVE:
- case MODEST_MAIL_OPERATION_TYPE_OPEN:
mode = TOOLBAR_MODE_TRANSFER;
if (priv->current_toolbar_mode == TOOLBAR_MODE_NORMAL)
*mode_changed = TRUE;
account is the local account or the MMC one */
op_type = modest_mail_operation_get_type_operation (mail_op);
account = modest_mail_operation_get_account (mail_op);
- if (account && op_type == MODEST_MAIL_OPERATION_TYPE_RECEIVE) {
+ if (account && op_type == MODEST_MAIL_OPERATION_TYPE_OPEN) {
gboolean is_remote;
is_remote = !(modest_tny_account_is_virtual_local_folders (account) ||
}
/* Show information banner. Remove old timeout */
- if (priv->retrieving_banner_timeout > 0) {
- g_source_remove (priv->retrieving_banner_timeout);
- priv->retrieving_banner_timeout = 0;
+ if (priv->opening_banner_timeout > 0) {
+ g_source_remove (priv->opening_banner_timeout);
+ priv->opening_banner_timeout = 0;
}
/* Create a new timeout */
- priv->retrieving_banner_timeout =
- g_timeout_add (2000, show_retrieving_banner, self);
+ priv->opening_banner_timeout =
+ g_timeout_add (2000, show_opening_banner, self);
}
/* Not every mail operation has account, noop does not */
the account was the local account or the MMC one */
op_type = modest_mail_operation_get_type_operation (mail_op);
account = modest_mail_operation_get_account (mail_op);
- if (account && op_type == MODEST_MAIL_OPERATION_TYPE_RECEIVE) {
+ if (account && op_type == MODEST_MAIL_OPERATION_TYPE_OPEN) {
gboolean is_remote;
is_remote = !(modest_tny_account_is_virtual_local_folders (account) ||
}
/* Remove old timeout */
- if (priv->retrieving_banner_timeout > 0) {
- g_source_remove (priv->retrieving_banner_timeout);
- priv->retrieving_banner_timeout = 0;
+ if (priv->opening_banner_timeout > 0) {
+ g_source_remove (priv->opening_banner_timeout);
+ priv->opening_banner_timeout = 0;
}
/* Remove the banner if exists */
- if (priv->retrieving_banner) {
- gtk_widget_destroy (priv->retrieving_banner);
- priv->retrieving_banner = NULL;
+ if (priv->opening_banner) {
+ gtk_widget_destroy (priv->opening_banner);
+ priv->opening_banner = NULL;
}
}
priv = MODEST_MAIN_WINDOW_GET_PRIVATE (window);
- if (priv->retrieving_banner_timeout > 0) {
- g_source_remove (priv->retrieving_banner_timeout);
- priv->retrieving_banner_timeout = 0;
+ if (priv->opening_banner_timeout > 0) {
+ g_source_remove (priv->opening_banner_timeout);
+ priv->opening_banner_timeout = 0;
}
- if (priv->retrieving_banner != NULL) {
- gtk_widget_destroy (priv->retrieving_banner);
- priv->retrieving_banner = NULL;
+ if (priv->opening_banner != NULL) {
+ gtk_widget_destroy (priv->opening_banner);
+ priv->opening_banner = NULL;
}
if (priv->updating_banner_timeout > 0) {
remove_banners (MODEST_MAIN_WINDOW (widget));
}
+<<<<<<< .working
+static void
+opening_banner_destroyed (gpointer data,
+ GObject *where_the_object_was)
+{
+ ModestMainWindowPrivate *priv = NULL;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE (data);
+
+ priv->opening_banner = NULL;
+}
+
+=======
static void
retrieving_banner_destroyed (gpointer data,
GObject *where_the_object_was)
priv->retrieving_banner = NULL;
}
+>>>>>>> .merge-right.r5668
static gboolean
-show_retrieving_banner (gpointer user_data)
+show_opening_banner (gpointer user_data)
{
ModestMainWindowPrivate *priv = NULL;
priv = MODEST_MAIN_WINDOW_GET_PRIVATE (user_data);
- if (priv->retrieving_banner == NULL) {
+ if (priv->opening_banner == NULL) {
/* We're outside the main lock */
gdk_threads_enter ();
- priv->retrieving_banner =
+ priv->opening_banner =
modest_platform_animation_banner (GTK_WIDGET (user_data), NULL,
- _("mcen_ib_getting_items"));
+ _("mail_me_opening"));
+
+ /* We need this because banners in Maemo could be
+ destroyed by dialogs so we need to properly update
+ our reference to it */
+ g_object_weak_ref (G_OBJECT (priv->opening_banner),
+ opening_banner_destroyed,
+ user_data);
/* We need this because banners in Maemo could be
destroyed by dialogs so we need to properly update
}
/* Remove timeout */
- priv->retrieving_banner_timeout = 0;
+ priv->opening_banner_timeout = 0;
return FALSE;
}
tmp = priv->progress_widgets;
source = modest_mail_operation_get_source(mail_op);
if (G_OBJECT (self) == source) {
- if (op_type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || op_type == MODEST_MAIL_OPERATION_TYPE_OPEN ) {
+ if (op_type == MODEST_MAIL_OPERATION_TYPE_RECEIVE ) {
set_toolbar_transfer_mode(self);
while (tmp) {
modest_progress_object_add_operation (
op_type = modest_mail_operation_get_type_operation (mail_op);
tmp = priv->progress_widgets;
- if (op_type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || op_type == MODEST_MAIL_OPERATION_TYPE_OPEN ) {
+ if (op_type == MODEST_MAIL_OPERATION_TYPE_RECEIVE ) {
while (tmp) {
modest_progress_object_remove_operation (MODEST_PROGRESS_OBJECT (tmp->data),
mail_op);
}
GtkWidget *
-modest_platform_get_account_settings_dialog (ModestAccountSettings *settings)
-{
- ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
-
- modest_account_settings_dialog_set_account (dialog, settings);
- return GTK_WIDGET (dialog);
-}
-
-GtkWidget *
modest_platform_get_account_settings_wizard (void)
{
ModestEasysetupWizardDialog *dialog = modest_easysetup_wizard_dialog_new ();
#include <modest-account-mgr-priv.h>
#include <tny-simple-list.h>
#include <modest-runtime.h>
+#include <modest-defs.h>
#include <string.h>
static const gchar * null_means_empty (const gchar * str);
return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SIGNATURE, FALSE);
}
-ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name)
+ModestProtocolType modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name)
{
- ModestTransportStoreProtocol result = MODEST_PROTOCOL_STORE_POP; /* Arbitrary default */
+ ModestProtocolType result = MODEST_PROTOCOLS_STORE_POP; /* Arbitrary default */
gchar *server_account_name = modest_account_mgr_get_string (self, name,
MODEST_ACCOUNT_STORE_ACCOUNT,
FALSE);
if (server_account_name) {
ModestServerAccountSettings* server_settings =
- modest_account_mgr_load_server_settings (self, server_account_name);
+ modest_account_mgr_load_server_settings (self, server_account_name, FALSE);
result = modest_server_account_settings_get_protocol (server_settings);
g_object_unref (server_settings);
-ModestAuthProtocol
+ModestProtocolType
modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
const gchar* account_name)
{
- ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
- gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH,
- TRUE /* server account */);
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocolType result = MODEST_PROTOCOLS_AUTH_NONE;
+ gchar* value;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH,
+ TRUE /* server account */);
if (value) {
- result = modest_protocol_info_get_auth_protocol (value);
-
+ ModestProtocol *protocol;
+
+ protocol = modest_protocol_registry_get_protocol_by_name (protocol_registry, MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS, value);
g_free (value);
+
+ if (protocol)
+ result = modest_protocol_get_type_id (protocol);
+
}
return result;
void
modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
- const gchar* account_name, ModestAuthProtocol secure_auth)
+ const gchar* account_name, ModestProtocolType secure_auth)
{
- /* Get the conf string for the enum value: */
- const gchar* str_value = NULL;
-
- str_value = modest_protocol_info_get_auth_protocol_name (secure_auth);
+ const gchar* str_value;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
+
+ /* Get the conf string for the protocol: */
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, secure_auth);
+ str_value = modest_protocol_get_name (protocol);
/* Set it in the configuration: */
modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, str_value, TRUE);
}
-ModestConnectionProtocol
+ModestProtocolType
modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
const gchar* account_name)
{
- ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
- gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY,
- TRUE /* server account */);
+ ModestProtocolType result = MODEST_PROTOCOLS_CONNECTION_NONE;
+ gchar* value;
+
+ value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY,
+ TRUE /* server account */);
if (value) {
- result = modest_protocol_info_get_connection_protocol (value);
-
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_name (protocol_registry,
+ MODEST_PROTOCOL_REGISTRY_CONNECTION_PROTOCOLS,
+ value);
g_free (value);
+
+ if (protocol)
+ result = modest_protocol_get_type_id (protocol);
}
return result;
void
modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
- const gchar* account_name, ModestConnectionProtocol security)
+ const gchar* account_name,
+ ModestProtocolType security)
{
- /* Get the conf string for the enum value: */
- const gchar* str_value = NULL;
- str_value = modest_protocol_info_get_connection_protocol_name (security);
+ const gchar* str_value;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
+
+ /* Get the conf string for the protocol type: */
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, security);
+ str_value = modest_protocol_get_name (protocol);
/* Set it in the configuration: */
modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY, str_value, TRUE);
}
ModestServerAccountSettings*
-modest_account_mgr_load_server_settings (ModestAccountMgr *self, const gchar* name)
+modest_account_mgr_load_server_settings (ModestAccountMgr *self, const gchar* name, gboolean is_transport_and_not_store)
{
ModestServerAccountSettings *settings;
+ ModestProtocol *protocol;
+ ModestProtocolRegistry *registry;
gchar *string;
g_return_val_if_fail (modest_account_mgr_account_exists (self, name, TRUE), NULL);
+ registry = modest_runtime_get_protocol_registry ();
settings = modest_server_account_settings_new ();
modest_server_account_settings_set_account_name (settings, name);
g_free (string);
string = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PROTO, TRUE);
+ if (is_transport_and_not_store) {
+ protocol = modest_protocol_registry_get_protocol_by_name (registry, MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS, string);
+ } else {
+ protocol = modest_protocol_registry_get_protocol_by_name (registry, MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS, string);
+ }
modest_server_account_settings_set_protocol (settings,
- modest_protocol_info_get_transport_store_protocol (string));
+ modest_protocol_get_type_id (protocol));
g_free (string);
modest_server_account_settings_set_port (settings,
modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_PORT, TRUE));
string = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
- modest_server_account_settings_set_auth_protocol (settings,
- modest_protocol_info_get_auth_protocol(string));
- g_free (string);
-
+ if (string) {
+ protocol = modest_protocol_registry_get_protocol_by_name (registry, MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS, string);
+ modest_server_account_settings_set_auth_protocol (settings,
+ modest_protocol_get_type_id (protocol));
+ g_free (string);
+ } else {
+ modest_server_account_settings_set_auth_protocol (settings, MODEST_PROTOCOLS_AUTH_NONE);
+ }
+
string = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SECURITY, TRUE);
- modest_server_account_settings_set_security (settings,
- modest_protocol_info_get_connection_protocol(string));
- g_free (string);
+ if (string) {
+ protocol = modest_protocol_registry_get_protocol_by_name (registry, MODEST_PROTOCOL_REGISTRY_CONNECTION_PROTOCOLS, string);
+ modest_server_account_settings_set_security_protocol (settings,
+ modest_protocol_get_type_id (protocol));
+ g_free (string);
+ } else {
+ modest_server_account_settings_set_security_protocol (settings,
+ MODEST_PROTOCOLS_CONNECTION_NONE);
+ }
string = modest_account_mgr_get_string (self, name,
MODEST_ACCOUNT_PASSWORD, TRUE);
modest_server_account_settings_set_password (settings, string);
g_free (string);
+ string = modest_account_mgr_get_string (self, name,
+ MODEST_ACCOUNT_URI, TRUE);
+ modest_server_account_settings_set_uri (settings, string);
+ g_free (string);
+
return settings;
}
{
gboolean has_errors = FALSE;
const gchar *account_name;
- const gchar *protocol;
+ const gchar *protocol_name;
const gchar *uri;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), FALSE);
+ protocol_registry = modest_runtime_get_protocol_registry ();
account_name = modest_server_account_settings_get_account_name (settings);
/* if we don't have a valid account name we cannot save */
g_return_val_if_fail (account_name, FALSE);
- protocol = modest_protocol_info_get_transport_store_protocol_name (
- modest_server_account_settings_get_protocol (settings));
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry,
+ modest_server_account_settings_get_protocol (settings));
+ protocol_name = modest_protocol_get_name (protocol);
uri = modest_server_account_settings_get_uri (settings);
if (!uri) {
- const gchar *hostname = null_means_empty (modest_server_account_settings_get_hostname (settings));
- const gchar *username = null_means_empty (modest_server_account_settings_get_username (settings));
- const gchar *password = null_means_empty (modest_server_account_settings_get_password (settings));
- gint port = modest_server_account_settings_get_port (settings);
- const gchar *auth_protocol = modest_protocol_info_get_auth_protocol_name (
- modest_server_account_settings_get_auth_protocol (settings));
- const gchar *security = modest_protocol_info_get_connection_protocol_name (
- modest_server_account_settings_get_security (settings));
+ const gchar *hostname;
+ const gchar *username;
+ const gchar *password;
+ gint port;
+ const gchar *auth_protocol_name;
+ const gchar *security_name;
+
+ hostname = null_means_empty (modest_server_account_settings_get_hostname (settings));
+ username = null_means_empty (modest_server_account_settings_get_username (settings));
+ password = null_means_empty (modest_server_account_settings_get_password (settings));
+ port = modest_server_account_settings_get_port (settings);
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry,
+ modest_server_account_settings_get_auth_protocol (settings));
+ auth_protocol_name = modest_protocol_get_name (protocol);
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry,
+ modest_server_account_settings_get_security_protocol (settings));
+ security_name = modest_protocol_get_name (protocol);
has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_HOSTNAME,
hostname, TRUE);
password, TRUE));
if (!has_errors)
(has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PROTO,
- protocol, TRUE));
+ protocol_name, TRUE));
if (!has_errors)
(has_errors = !modest_account_mgr_set_int (self, account_name, MODEST_ACCOUNT_PORT,
port, TRUE));
if (!has_errors)
(has_errors = !modest_account_mgr_set_string (self, account_name,
MODEST_ACCOUNT_AUTH_MECH,
- auth_protocol, TRUE));
+ auth_protocol_name, TRUE));
if (!has_errors)
(has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY,
- security,
+ security_name,
TRUE));
} else {
const gchar *uri = modest_server_account_settings_get_uri (settings);
uri, TRUE);
if (!has_errors)
(has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PROTO,
- protocol, TRUE));
+ protocol_name, TRUE));
}
return !has_errors;
FALSE);
if (server_account) {
ModestServerAccountSettings *store_settings;
- store_settings = modest_account_mgr_load_server_settings (self, server_account);
+ store_settings = modest_account_mgr_load_server_settings (self, server_account, FALSE);
modest_account_settings_set_store_settings (settings,
store_settings);
g_object_unref (store_settings);
FALSE);
if (server_account) {
ModestServerAccountSettings *transport_settings;
- transport_settings = modest_account_mgr_load_server_settings (self, server_account);
+ transport_settings = modest_account_mgr_load_server_settings (self, server_account, TRUE);
modest_account_settings_set_transport_settings (settings, transport_settings);
g_object_unref (transport_settings);
g_free (server_account);
*
* Returns: The protocol type.
*/
-ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name);
+ModestProtocolType modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name);
/**
* modest_account_mgr_set_connection_specific_smtp
*
* Returns: The secure authentication enum value.
*/
-ModestAuthProtocol modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
+ModestProtocolType modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
const gchar* account_name);
/**
*/
void modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
const gchar* account_name,
- ModestAuthProtocol secure_auth);
+ ModestProtocolType secure_auth);
/**
* modest_server_account_data_get_security:
*
* Gets the security method for this server account.
*
- * Returns: The security enum value.
+ * Returns: The security connection protocol.
*/
-ModestConnectionProtocol modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
- const gchar* account_name);
+ModestProtocolType modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
+ const gchar* account_name);
/**
* modest_account_mgr_set_server_account_security:
*/
void modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
const gchar* account_name,
- ModestConnectionProtocol security);
+ ModestProtocolType security);
gboolean modest_account_mgr_save_server_settings (ModestAccountMgr *self,
ModestServerAccountSettings *settings);
ModestServerAccountSettings *modest_account_mgr_load_server_settings (ModestAccountMgr *self,
- const gchar *account_name);
+ const gchar *account_name,
+ gboolean is_transport_not_store);
/**
* modest_account_mgr_get_from_string
#include <string.h>
#include <modest-marshal.h>
#include <modest-runtime.h>
+#include <modest-defs.h>
#include <modest-account-mgr.h>
#include <modest-account-mgr-priv.h>
#include <modest-account-mgr-helpers.h>
* but let's check again just in case */
if (!display_name ||
modest_account_mgr_account_with_display_name_exists (self, display_name)) {
- return FALSE;
+ display_name = _("mcen_ia_emailsetup_defaultname");
}
/* Increment the non-user visible name if necessary,
guint portnumber,
const gchar *username,
const gchar *password,
- ModestTransportStoreProtocol proto,
- ModestConnectionProtocol security,
- ModestAuthProtocol auth)
+ ModestProtocolType proto,
+ ModestProtocolType security,
+ ModestProtocolType auth)
{
ModestAccountMgrPrivate *priv;
const gchar *key;
gboolean ok = TRUE;
GError *err = NULL;
+ ModestProtocolRegistry *protocol_registry;
g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE);
g_return_val_if_fail (name, FALSE);
g_return_val_if_fail (strchr(name, '/') == NULL, FALSE);
-
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
/* hostname */
/* proto */
key = _modest_account_mgr_get_account_keyname_cached (priv, name, MODEST_ACCOUNT_PROTO, TRUE);
ok = modest_conf_set_string (priv->modest_conf, key,
- modest_protocol_info_get_transport_store_protocol_name(proto),
+ modest_protocol_get_name (modest_protocol_registry_get_protocol_by_type (protocol_registry, proto)),
&err);
if (err) {
g_printerr ("modest: failed to set %s: %s\n", key, err->message);
/* auth mechanism */
key = _modest_account_mgr_get_account_keyname_cached (priv, name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
ok = modest_conf_set_string (priv->modest_conf, key,
- modest_protocol_info_get_auth_protocol_name (auth),
+ modest_protocol_get_name (modest_protocol_registry_get_protocol_by_type (protocol_registry, auth)),
&err);
if (err) {
g_printerr ("modest: failed to set %s: %s\n", key, err->message);
gboolean
modest_account_mgr_add_server_account_uri (ModestAccountMgr * self,
const gchar *name,
- ModestTransportStoreProtocol proto,
+ ModestProtocolType proto,
const gchar *uri)
{
ModestAccountMgrPrivate *priv;
const gchar *key;
gboolean ok;
+ ModestProtocolRegistry *protocol_registry;
g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE);
g_return_val_if_fail (name, FALSE);
g_return_val_if_fail (uri, FALSE);
priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
/* proto */
key = _modest_account_mgr_get_account_keyname_cached (priv, name, MODEST_ACCOUNT_PROTO, TRUE);
ok = modest_conf_set_string (priv->modest_conf, key,
- modest_protocol_info_get_transport_store_protocol_name(proto),
+ modest_protocol_get_name (modest_protocol_registry_get_protocol_by_type (protocol_registry, proto)),
NULL);
if (!ok) {
modest_account_mgr_notify_account_update (ModestAccountMgr* self,
const gchar *server_account_name)
{
- ModestTransportStoreProtocol proto;
+ ModestProtocolType proto;
ModestAccountMgrPrivate* priv;
+ ModestProtocolRegistry *protocol_registry;
gchar *proto_name = NULL;
g_return_if_fail (self);
g_return_if_fail (server_account_name);
priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
/* Get protocol */
proto_name = modest_account_mgr_get_string (self, server_account_name,
g_free (proto_name);
g_return_if_reached ();
}
- proto = modest_protocol_info_get_transport_store_protocol (proto_name);
+ proto = modest_protocol_get_type_id (modest_protocol_registry_get_protocol_by_name (protocol_registry,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ proto_name));
g_free (proto_name);
/* there is some update in the account, so we can't
g_signal_emit (G_OBJECT(self),
signals[ACCOUNT_CHANGED_SIGNAL], 0,
server_account_name,
- (modest_protocol_info_protocol_is_store (proto)) ?
+ (modest_protocol_registry_protocol_type_has_tag (protocol_registry, proto, MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS)) ?
TNY_ACCOUNT_TYPE_STORE :
TNY_ACCOUNT_TYPE_TRANSPORT);
}
#include <glib-object.h>
#include <modest-conf.h>
-#include <modest-defs.h>
-#include <modest-protocol-info.h>
+#include <modest-protocol-registry.h>
#include <modest-account-settings.h>
G_BEGIN_DECLS
const guint portnumber,
const gchar *username,
const gchar *password,
- ModestTransportStoreProtocol proto,
- ModestConnectionProtocol security,
- ModestAuthProtocol auth);
+ ModestProtocolType proto,
+ ModestProtocolType security,
+ ModestProtocolType auth);
/**
*/
gboolean modest_account_mgr_add_server_account_uri (ModestAccountMgr *self,
const gchar *name,
- ModestTransportStoreProtocol proto,
+ ModestProtocolType proto,
const gchar* uri);
/**
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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 <tny-simple-list.h>
+#include "modest-account-protocol.h"
+#include "modest-account-mgr-helpers.h"
+#include "widgets/modest-default-account-settings-dialog.h"
+#include "modest-runtime.h"
+
+enum {
+ PROP_0,
+ PROP_PORT,
+ PROP_ALTERNATE_PORT,
+ PROP_ACCOUNT_G_TYPE,
+};
+
+typedef struct _ModestAccountProtocolPrivate ModestAccountProtocolPrivate;
+struct _ModestAccountProtocolPrivate {
+ guint port;
+ guint alternate_port;
+ TnyList *account_options;
+ GHashTable *custom_auth_mechs;
+ GType account_g_type;
+};
+
+/* 'private'/'protected' functions */
+static void modest_account_protocol_class_init (ModestAccountProtocolClass *klass);
+static void modest_account_protocol_finalize (GObject *obj);
+static void modest_account_protocol_get_property (GObject *obj,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void modest_account_protocol_set_property (GObject *obj,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void modest_account_protocol_instance_init (ModestAccountProtocol *obj);
+
+#define MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ MODEST_TYPE_ACCOUNT_PROTOCOL, \
+ ModestAccountProtocolPrivate))
+
+static TnyAccount *modest_account_protocol_create_account_default (ModestAccountProtocol *self);
+
+static ModestAccountSettingsDialog *modest_account_protocol_create_account_settings_dialog_default (ModestAccountProtocol *self);
+
+static ModestPairList* modest_account_protocol_get_easysetupwizard_tabs_default (ModestAccountProtocol *self);
+
+static void modest_account_protocol_save_settings_default (ModestAccountProtocol *self,
+ ModestAccountSettingsDialog *dialog,
+ ModestAccountSettings *settings);
+
+static void modest_account_protocol_save_wizard_settings_default (ModestAccountProtocol *self,
+ GList *wizard_pages,
+ ModestAccountSettings *settings);
+
+/* globals */
+static GObjectClass *parent_class = NULL;
+
+GType
+modest_account_protocol_get_type (void)
+{
+ static GType my_type = 0;
+
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestAccountProtocolClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_account_protocol_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof(ModestAccountProtocol),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) modest_account_protocol_instance_init,
+ NULL
+ };
+
+ my_type = g_type_register_static (MODEST_TYPE_PROTOCOL,
+ "ModestAccountProtocol",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_account_protocol_class_init (ModestAccountProtocolClass *klass)
+{
+ GObjectClass *object_class;
+ ModestAccountProtocolClass *account_class;
+
+ object_class = (GObjectClass *) klass;
+ account_class = MODEST_ACCOUNT_PROTOCOL_CLASS (klass);
+ parent_class = g_type_class_peek_parent (klass);
+ object_class->finalize = modest_account_protocol_finalize;
+ object_class->set_property = modest_account_protocol_set_property;
+ object_class->get_property = modest_account_protocol_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_PORT,
+ g_param_spec_uint ("port",
+ _("Standard port"),
+ _("The standard port for the protocol"),
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_ALTERNATE_PORT,
+ g_param_spec_uint ("alternate-port",
+ _("Alternate port"),
+ _("The alternate port for the protocol (usually used in SSL)"),
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_ACCOUNT_G_TYPE,
+ g_param_spec_gtype ("account-g-type",
+ _("Account factory GType"),
+ _("Account factory GType used for creating new instances."),
+ TNY_TYPE_ACCOUNT,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+ g_type_class_add_private (object_class,
+ sizeof(ModestAccountProtocolPrivate));
+
+ /* Virtual methods */
+ account_class->create_account_settings_dialog =
+ modest_account_protocol_create_account_settings_dialog_default;
+ account_class->get_easysetupwizard_tabs =
+ modest_account_protocol_get_easysetupwizard_tabs_default;
+ account_class->save_settings =
+ modest_account_protocol_save_settings_default;
+ account_class->save_wizard_settings =
+ modest_account_protocol_save_wizard_settings_default;
+ account_class->create_account =
+ modest_account_protocol_create_account_default;
+}
+
+static void
+modest_account_protocol_instance_init (ModestAccountProtocol *obj)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (obj);
+
+ priv->port = 0;
+ priv->alternate_port = 0;
+ priv->account_g_type = 0;
+ priv->account_options = tny_simple_list_new ();
+ priv->custom_auth_mechs = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
+}
+
+static void
+modest_account_protocol_finalize (GObject *obj)
+{
+ ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
+ ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (protocol);
+
+ if (priv->account_options)
+ g_object_unref (priv->account_options);
+ priv->account_options = NULL;
+
+ if (priv->custom_auth_mechs)
+ g_hash_table_destroy (priv->custom_auth_mechs);
+ priv->custom_auth_mechs = NULL;
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+modest_account_protocol_get_property (GObject *obj,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
+ ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (protocol);
+
+ switch (property_id) {
+ case PROP_PORT:
+ g_value_set_uint (value, priv->port);
+ break;
+ case PROP_ALTERNATE_PORT:
+ g_value_set_uint (value, priv->alternate_port);
+ break;
+ case PROP_ACCOUNT_G_TYPE:
+ g_value_set_gtype (value, priv->account_g_type);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
+ }
+
+}
+
+static void
+modest_account_protocol_set_property (GObject *obj,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ModestAccountProtocol *protocol = MODEST_ACCOUNT_PROTOCOL (obj);
+
+ switch (property_id) {
+ case PROP_PORT:
+ modest_account_protocol_set_port (protocol, g_value_get_uint (value));
+ break;
+ case PROP_ALTERNATE_PORT:
+ modest_account_protocol_set_alternate_port (protocol, g_value_get_uint (value));
+ break;
+ case PROP_ACCOUNT_G_TYPE:
+ modest_account_protocol_set_account_g_type (protocol, g_value_get_gtype (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
+ }
+
+}
+
+
+ModestProtocol*
+modest_account_protocol_new (const gchar *name, const gchar *display_name,
+ guint port, guint alternate_port,
+ GType account_g_type)
+{
+ return g_object_new (MODEST_TYPE_ACCOUNT_PROTOCOL,
+ "display-name", display_name, "name", name,
+ "port", port, "alternate-port", alternate_port,
+ "account-g-type", account_g_type,
+ NULL);
+}
+
+guint
+modest_account_protocol_get_port (ModestAccountProtocol *self)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
+
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+ return priv->port;
+}
+
+void
+modest_account_protocol_set_port (ModestAccountProtocol *self,
+ guint port)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
+
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+ priv->port = port;
+}
+
+
+guint
+modest_account_protocol_get_alternate_port (ModestAccountProtocol *self)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
+
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+ return priv->alternate_port;
+}
+
+void
+modest_account_protocol_set_alternate_port (ModestAccountProtocol *self,
+ guint alternate_port)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
+
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+ priv->alternate_port = alternate_port;
+}
+
+GType
+modest_account_protocol_get_account_g_type (ModestAccountProtocol *self)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), 0);
+
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+ return priv->account_g_type;
+}
+
+TnyList *
+modest_account_protocol_get_account_options (ModestAccountProtocol *self)
+{
+ TnyList *result;
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+
+ result = tny_list_copy (priv->account_options);
+
+ return result;
+}
+
+void
+modest_account_protocol_set_account_options (ModestAccountProtocol *self,
+ TnyList *list)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+
+ if (priv->account_options) {
+ priv->account_options = NULL;
+ }
+ priv->account_options = tny_list_copy (list);
+}
+
+gboolean
+modest_account_protocol_has_custom_secure_auth_mech (ModestAccountProtocol *self,
+ ModestProtocolType auth_protocol_type)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), FALSE);
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+
+ return g_hash_table_lookup_extended (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type), NULL, NULL);
+}
+
+const gchar *
+modest_account_protocol_get_custom_secure_auth_mech (ModestAccountProtocol *self,
+ ModestProtocolType auth_protocol_type)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+
+ return (const gchar *) g_hash_table_lookup (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type));
+}
+
+void
+modest_account_protocol_set_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type, const gchar *secure_auth_mech)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+
+ g_hash_table_replace (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type), g_strdup (secure_auth_mech));
+}
+
+void
+modest_account_protocol_unset_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+
+ g_hash_table_remove (priv->custom_auth_mechs, GINT_TO_POINTER (auth_protocol_type));
+}
+
+
+void
+modest_account_protocol_set_account_g_type (ModestAccountProtocol *self,
+ GType account_g_type)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
+
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+ priv->account_g_type = account_g_type;
+}
+
+static TnyAccount *
+modest_account_protocol_create_account_default (ModestAccountProtocol *self)
+{
+ ModestAccountProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+ priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+ if (priv->account_g_type > 0) {
+ return g_object_new (priv->account_g_type, NULL);
+ } else {
+ return NULL;
+ }
+}
+
+TnyAccount *
+modest_account_protocol_create_account (ModestAccountProtocol *self)
+{
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self), NULL);
+
+ return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account (self);
+}
+
+/* This is a template method for getting the account settings
+ dialog. It calls create_account_settings that must be implemented
+ by subclasses and then perform several common operations with the
+ dialog */
+ModestAccountSettingsDialog *
+modest_account_protocol_get_account_settings_dialog (ModestAccountProtocol *self,
+ const gchar *account_name)
+{
+ ModestAccountSettingsDialog *dialog;
+ ModestAccountSettings *settings;
+
+ dialog = MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->create_account_settings_dialog (self);
+
+ /* Load settings */
+ settings = modest_account_mgr_load_account_settings (modest_runtime_get_account_mgr (),
+ account_name);
+ modest_account_settings_dialog_load_settings (dialog, settings);
+
+ /* TODO: Those methods should be removed from the
+ interface and moved to specific implementations */
+/* modest_account_settings_dialog_switch_to_user_info (dialog); */
+/* modest_account_settings_dialog_check_allow_changes (dialog); */
+
+ /* Set modal */
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+ GTK_WINDOW (dialog));
+
+ /* TODO: review this. When the dialog is closed, reconnect */
+ /* g_signal_connect (dialog, "response", */
+ /* G_CALLBACK (on_account_settings_dialog_response), */
+ /* self); */
+
+ /* Close dialog on response */
+ g_signal_connect_swapped (dialog,
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+
+ return dialog;
+}
+
+ModestPairList*
+modest_account_protocol_get_easysetupwizard_tabs (ModestAccountProtocol *self)
+{
+ return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->get_easysetupwizard_tabs (self);
+}
+
+
+void
+modest_account_protocol_save_settings (ModestAccountProtocol *self,
+ ModestAccountSettingsDialog *dialog,
+ ModestAccountSettings *settings)
+{
+ return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->save_settings (self, dialog, settings);
+}
+
+void
+modest_account_protocol_save_wizard_settings (ModestAccountProtocol *self,
+ GList *wizard_pages,
+ ModestAccountSettings *settings)
+{
+ return MODEST_ACCOUNT_PROTOCOL_GET_CLASS (self)->save_wizard_settings (self, wizard_pages, settings);
+}
+
+/* Default implementations */
+static ModestAccountSettingsDialog *
+modest_account_protocol_create_account_settings_dialog_default (ModestAccountProtocol *self)
+{
+ return modest_default_account_settings_dialog_new ();
+}
+
+static ModestPairList*
+modest_account_protocol_get_easysetupwizard_tabs_default (ModestAccountProtocol *self)
+{
+ g_warning ("You must implement get_easysetupwizard_tabs");
+ return NULL;
+}
+
+static void
+modest_account_protocol_save_settings_default (ModestAccountProtocol *self,
+ ModestAccountSettingsDialog *dialog,
+ ModestAccountSettings *settings)
+{
+ g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog));
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ g_warning ("You must implement save_settings");
+}
+
+static void
+modest_account_protocol_save_wizard_settings_default (ModestAccountProtocol *self,
+ GList *wizard_pages,
+ ModestAccountSettings *settings)
+{
+ g_return_if_fail (MODEST_IS_ACCOUNT_PROTOCOL (self));
+ g_return_if_fail (wizard_pages);
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ g_warning ("You must implement save_wizard_settings");
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+
+/* modest-account-settings.h */
+
+#ifndef __MODEST_ACCOUNT_PROTOCOL_H__
+#define __MODEST_ACCOUNT_PROTOCOL_H__
+
+#include "widgets/modest-account-settings-dialog.h"
+#include "modest-protocol.h"
+#include "modest-pair.h"
+#include <tny-account.h>
+#include <tny-list.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_ACCOUNT_PROTOCOL (modest_account_protocol_get_type())
+#define MODEST_ACCOUNT_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocol))
+#define MODEST_ACCOUNT_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocolClass))
+#define MODEST_IS_ACCOUNT_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_PROTOCOL))
+#define MODEST_IS_ACCOUNT_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_PROTOCOL))
+#define MODEST_ACCOUNT_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocolClass))
+
+typedef struct _ModestAccountProtocol ModestAccountProtocol;
+typedef struct _ModestAccountProtocolClass ModestAccountProtocolClass;
+
+
+struct _ModestAccountProtocol {
+ ModestProtocol parent;
+};
+
+struct _ModestAccountProtocolClass {
+ ModestProtocolClass parent_class;
+
+ /* Virtual methods */
+ TnyAccount * (*create_account) (ModestAccountProtocol *self);
+ ModestAccountSettingsDialog* (*create_account_settings_dialog) (ModestAccountProtocol* self);
+ ModestPairList* (*get_easysetupwizard_tabs) (ModestAccountProtocol* self);
+ void (*save_settings) (ModestAccountProtocol *self, ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings);
+ void (*save_wizard_settings) (ModestAccountProtocol *self, GList *wizard_pages, ModestAccountSettings *settings);
+};
+
+/**
+ * modest_account_protocol_get_type:
+ *
+ * Returns: GType of the account protocol type
+ */
+GType modest_account_protocol_get_type (void) G_GNUC_CONST;
+
+/**
+ * modest_account_protocol_new:
+ *
+ * creates a new instance of #ModestAccountProtocol
+ *
+ * Returns: a #ModestAccountProtocol
+ */
+ModestProtocol* modest_account_protocol_new (const gchar *name, const gchar *display_name,
+ guint port, guint alternate_port,
+ GType account_g_type);
+
+/**
+ * modest_account_protocol_get_port:
+ * @self: a #ModestAccountProtocol
+ *
+ * get the protocol standard port
+ *
+ * Returns: a string
+ */
+guint modest_account_protocol_get_port (ModestAccountProtocol *self);
+
+/**
+ * modest_account_protocol_set_port:
+ * @self: a #ModestAccountProtocol
+ * @port: a #guint
+ *
+ * set @port as the protocol standard port
+ */
+void modest_account_protocol_set_port (ModestAccountProtocol *self,
+ guint port);
+
+/**
+ * modest_account_protocol_get_alternate_port:
+ * @self: a #ModestAccountProtocol
+ *
+ * get the protocol standard alternate_port
+ *
+ * Returns: a #guint
+ */
+guint modest_account_protocol_get_alternate_port (ModestAccountProtocol *self);
+
+/**
+ * modest_account_protocol_set_alternate_port:
+ * @self: a #ModestAccountProtocol
+ * @alternate_port: a #guint
+ *
+ * set @alternate_port as the protocol alternate port
+ */
+void modest_account_protocol_set_alternate_port (ModestAccountProtocol *self,
+ guint alternate_port);
+
+/**
+ * modest_account_protocol_set_account_options:
+ * @self: a #ModestAccountProtocol
+ * @account_options: a #TnyList of account options and their values
+ *
+ * set the account options that will be passed to TnyCamelAccount for this protocol.
+ * This replaces previous option lists for this protocol
+ */
+void modest_account_protocol_set_account_options (ModestAccountProtocol *self,
+ TnyList *account_options);
+
+/**
+ * modest_account_protocol_get_account_options:
+ * @self: a #ModestAccountProtocol
+ *
+ * obtain the account options for this account protocol.
+ *
+ * Returns: a caller-owner copy of the account options list.
+ */
+TnyList *modest_account_protocol_get_account_options (ModestAccountProtocol *self);
+
+/**
+ * modest_account_protocol_has_custom_secure_auth_mech:
+ * @self: a #ModestAccountProtocol
+ * @auth_protocol_type: a #ModestProtocolType for an auth protocol
+ *
+ * checks whether there's a custom secure auth mech camel string for @auth_protocol_type.
+ *
+ * Returns: %TRUE if registered, %FALSE otherwise
+ */
+gboolean
+modest_account_protocol_has_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
+
+/**
+ * modest_account_protocol_get_custom_secure_auth_mech:
+ * @self: a #ModestAccountProtocol
+ * @auth_protocol_type: a #ModestProtocolType for an auth protocol
+ *
+ * obtains the secure auth mech of @auth_protocol_type in protocol. Be careful as %NULL does not imply
+ * there's no custom auth mech registered (you can register %NULL). To check if it's registered, just
+ * use modest_account_protocol_has_custom_secure_auth_mech().
+ *
+ * Returns: the secure auth mech for this auth protocol type that will be passed to camel.
+ */
+const gchar *
+modest_account_protocol_get_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
+
+/**
+ * modest_account_protocol_unset_custom_secure_auth_mech:
+ * @self: a #ModestAccountProtocol
+ * @auth_protocol_type: a #ModestProtocolType for an auth protocol
+ *
+ * Unsets the secure auth meth of @auth_protocol_type in protocol.
+ */
+void
+modest_account_protocol_unset_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
+
+/**
+ * modest_account_protocol_set_custom_secure_auth_mech:
+ * @self: a #ModestAccountProtocol
+ * @auth_protocol_type: a #ModestProtocolType for an auth protocol
+ * @secure_auth_mech: a string or %NULL
+ *
+ * sets the secure auth mech of @auth_protocol_type in protocol. Be careful as %NULL does not imply
+ * there's no custom auth mech registered (you can register %NULL). If you set %NULL you're regitering %NULL as the custom secure auth
+ * mechanism instead of unsetting it.
+ */
+void
+modest_account_protocol_set_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type, const gchar *secure_auth_mech);
+
+/**
+ * modest_account_protocol_get_account_g_type:
+ * @self: a #ModestAccountProtocol
+ *
+ * get the protocol type used for factoring new TnyAccount
+ *
+ * Returns: a #GType
+ */
+GType modest_account_protocol_get_account_g_type (ModestAccountProtocol *self);
+
+/**
+ * modest_account_protocol_set_account_g_type:
+ * @self: a #ModestAccountProtocol
+ * @account_g_type: a #GType
+ *
+ * set @account_g_type as the type modest_account_protocol_create_account will
+ * instanciate
+ */
+void modest_account_protocol_set_account_g_type (ModestAccountProtocol *self,
+ GType account_g_type);
+
+/**
+ * modest_account_protocol_create_account:
+ * @self: a #ModestAccountProtocol
+ *
+ * create a new account instance for this protocol
+ *
+ * Returns: a #TnyAccount
+ */
+TnyAccount * modest_account_protocol_create_account (ModestAccountProtocol *self);
+
+/**
+ * modest_account_protocol_get_account_settings_dialog:
+ * @self: a #ModestAccountProtocol
+ * @account_name: the name of the account we're creating the dialog for
+ *
+ * retrieves the account settings dialog used to setup the account
+ * represented by this protocol
+ *
+ * Returns: a #ModestAccountSettingsDialog
+ **/
+ModestAccountSettingsDialog* modest_account_protocol_get_account_settings_dialog (ModestAccountProtocol *self,
+ const gchar *account_name);
+
+ModestPairList* modest_account_protocol_get_easysetupwizard_tabs (ModestAccountProtocol *self);
+
+/**
+ * modest_account_protocol_save_settings:
+ * @self: this #ModestAccountProtocol
+ * @dialog: a #ModestAccountSettingsDialog
+ * @settings: the #ModestAccountSettings
+ *
+ * this function stores the values held by the account settings dialog
+ * in the account settings object that is passed as argument
+ *
+ * NOTE: this function provides a default implementation that calls
+ * the save_settings method of the acocunt settings dialog. So if your
+ * implementation do not do anything more just do not redefine it
+ **/
+void modest_account_protocol_save_settings (ModestAccountProtocol *self,
+ ModestAccountSettingsDialog *dialog,
+ ModestAccountSettings *settings);
+
+/**
+ * modest_account_protocol_save_wizard_settings:
+ * @self: this #ModestAccountProtocol
+ * @wizard_pages: a list of #ModestEasysetupWizardPage
+ * @settings: the #ModestAccountSettings
+ *
+ * this function stores the data input by the users in the wizard in
+ * the account settings object passed as argument
+ **/
+void modest_account_protocol_save_wizard_settings (ModestAccountProtocol *self,
+ GList *wizard_pages,
+ ModestAccountSettings *settings);
+
+G_END_DECLS
+
+#endif /* __MODEST_ACCOUNT_PROTOCOL_H__ */
#define __MODEST_ACCOUNT_SETTINGS_H__
#include <glib-object.h>
-#include <modest-defs.h>
#include <modest-server-account-settings.h>
G_BEGIN_DECLS
#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
+#include "modest-defs.h"
#include "modest-conf.h"
#include "modest-marshal.h"
#include <stdio.h>
#define __MODEST_CONF_H__
#include <glib-object.h>
-#include "modest-defs.h"
G_BEGIN_DECLS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <modest-defs.h>
#include <modest-email-clipboard.h>
#include <modest-tny-folder.h>
#include <glib-object.h>
#include <modest-conf.h>
-#include <modest-defs.h>
#include <tny-folder.h>
G_BEGIN_DECLS
return FALSE;
}
+ modest_plugin_factory_load_all (modest_runtime_get_plugin_factory ());
+
/* do an initial guess for the device name */
init_device_name (modest_runtime_get_conf());
gchar *devname = NULL;
if (!g_file_get_contents("/etc/hostname", &devname, &len, NULL) || len < 2 || len > 254) {
- g_printerr ("modest: failed to read hostname\n");
+ g_warning ("%s: failed to read hostname\n", __FUNCTION__);
modest_conf_set_string (conf, MODEST_CONF_DEVICE_NAME,
MODEST_LOCAL_FOLDERS_DEFAULT_DISPLAY_NAME,
NULL);
{
gboolean expunge, leave_on_server;
const gchar *account_name;
- const gchar *proto;
TnyAccount *account;
- ModestTransportStoreProtocol account_proto = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+ ModestProtocolType account_proto = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
ModestMailOperation *self;
ModestMailOperationPrivate *priv;
+ ModestProtocolRegistry *protocol_registry;
self = (ModestMailOperation *) user_data;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
if (canceled || err) {
/* If canceled by the user, ignore the error given by Tinymail */
leave_on_server =
modest_account_mgr_get_leave_on_server (modest_runtime_get_account_mgr (),
account_name);
- proto = tny_account_get_proto (account);
+ account_proto = modest_tny_account_get_protocol_type (account);
g_object_unref (account);
-
- if (proto)
- account_proto = modest_protocol_info_get_transport_store_protocol (proto);
- if (((account_proto == MODEST_PROTOCOL_STORE_POP) && !leave_on_server) ||
- modest_tny_folder_is_remote_folder (folder) == FALSE)
+ if (( (modest_protocol_registry_protocol_type_has_leave_on_server (protocol_registry, account_proto) && !leave_on_server) ||
+ modest_tny_folder_is_remote_folder (folder) == FALSE))
expunge = TRUE;
else
expunge = FALSE;
TnyAccount *dst_account = NULL;
gboolean leave_on_server;
ModestMailOperationState *state;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocolType account_protocol;
g_return_if_fail (self && MODEST_IS_MAIL_OPERATION (self));
g_return_if_fail (headers && TNY_IS_LIST (headers));
g_return_if_fail (folder && TNY_IS_FOLDER (folder));
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+
priv->total = tny_list_get_length (headers);
priv->done = 0;
priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
this could cause an error if we're offline while
transferring an already downloaded message from a POP
account */
- if (modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (priv->account)) ==
- MODEST_PROTOCOL_STORE_POP) {
+ account_protocol = modest_tny_account_get_protocol_type (priv->account);
+ if (modest_protocol_registry_protocol_type_has_leave_on_server (protocol_registry, account_protocol)) {
const gchar *account_name;
account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (priv->account);
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <errno.h>
+#include <gmodule.h>
+#include "modest-module.h"
+
+G_DEFINE_TYPE (ModestModule, modest_module, G_TYPE_TYPE_MODULE);
+
+
+static gboolean modest_module_load (GTypeModule *gmodule);
+static void modest_module_unload (GTypeModule *gmodule);
+static void modest_module_init (ModestModule *module);
+static void modest_module_finalize (GObject *object);
+static void modest_module_class_init (ModestModuleClass *class);
+
+typedef GType (*ModestModuleRegisterFunc) (GTypeModule *);
+
+typedef struct _ModestModulePrivate ModestModulePrivate;
+struct _ModestModulePrivate {
+ GModule *g_module;
+ gchar *path;
+ GType type;
+};
+
+#define MODEST_MODULE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+ MODEST_TYPE_MODULE, \
+ ModestModulePrivate))
+
+static gboolean
+modest_module_load (GTypeModule *g_type_module)
+{
+ ModestModule *module = MODEST_MODULE (g_type_module);
+ ModestModulePrivate *priv = MODEST_MODULE_GET_PRIVATE (module);
+ ModestModuleRegisterFunc register_func;
+
+ /* We don't do lazy linking to fail just if we cannot link all the symbols available */
+ priv->g_module = g_module_open (priv->path, 0);
+
+ if (priv->g_module == NULL) {
+ g_warning ("%s", g_module_error());
+ return FALSE;
+ }
+
+ /* Get the register function */
+ if (!g_module_symbol (priv->g_module, "register_modest_plugin", (void *) ®ister_func)) {
+ g_warning ("%s", g_module_error());
+ g_module_close (priv->g_module);
+
+ return FALSE;
+ }
+
+ if (register_func == NULL) {
+ g_warning ("register_modest_plugin shouldn't be NULL");
+ g_module_close (priv->g_module);
+
+ return FALSE;
+ }
+
+ /* call the register function to initialize the module */
+ priv->type = register_func (g_type_module);
+ if (priv->type == 0) {
+ g_warning ("%s is not a modest plugin", priv->path);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+modest_module_unload (GTypeModule *gmodule)
+{
+ ModestModule *module = MODEST_MODULE (gmodule);
+ ModestModulePrivate *priv = MODEST_MODULE_GET_PRIVATE (module);
+
+ g_module_close (priv->g_module);
+
+ priv->g_module = NULL;
+ priv->type = 0;
+}
+
+GObject *
+modest_module_new_object (ModestModule *module)
+{
+ ModestModulePrivate *priv = MODEST_MODULE_GET_PRIVATE (module);
+
+ if (priv->type == 0) {
+ return NULL;
+ }
+
+ return g_object_new (priv->type, NULL);
+}
+
+static void
+modest_module_init (ModestModule *module)
+{
+}
+
+static void
+modest_module_finalize (GObject *object)
+{
+ ModestModule *module = MODEST_MODULE (object);
+ ModestModulePrivate *priv = MODEST_MODULE_GET_PRIVATE (module);
+
+ g_free (priv->path);
+
+ G_OBJECT_CLASS (modest_module_parent_class)->finalize (object);
+}
+
+static void
+modest_module_class_init (ModestModuleClass *class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
+
+ gobject_class->finalize = modest_module_finalize;
+
+ module_class->load = modest_module_load;
+ module_class->unload = modest_module_unload;
+
+ g_type_class_add_private (gobject_class, sizeof(ModestModulePrivate));
+}
+
+ModestModule *
+modest_module_new (const gchar *path)
+{
+ ModestModule *module;
+ ModestModulePrivate *priv;
+
+ if (path == NULL || path[0] == '\0') {
+ return NULL;
+ }
+
+ module = g_object_new (MODEST_TYPE_MODULE, NULL);
+ priv = MODEST_MODULE_GET_PRIVATE (module);
+
+ g_type_module_set_name (G_TYPE_MODULE (module), path);
+
+ priv->path = g_strdup (path);
+
+ return module;
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+#ifndef MODEST_MODULE_H
+#define MODEST_MODULE_H
+
+#include <glib-object.h>
+#include <gmodule.h>
+
+G_BEGIN_DECLS
+
+typedef struct _ModestModule ModestModule;
+typedef struct _ModestModuleClass ModestModuleClass;
+
+#define MODEST_TYPE_MODULE (modest_module_get_type ())
+#define MODEST_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEST_TYPE_MODULE, ModestModule))
+#define MODEST_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MODEST_TYPE_MODULE, ModestModuleClass))
+#define MODEST_IS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEST_TYPE_MODULE))
+#define MODEST_IS_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MODEST_TYPE_MODULE))
+#define MODEST_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MODEST_TYPE_MODULE, ModestModuleClass))
+
+struct _ModestModule {
+ GTypeModule parent_instance;
+};
+
+struct _ModestModuleClass {
+ GTypeModuleClass parent_class;
+};
+
+GType modest_module_get_type (void) G_GNUC_CONST;
+ModestModule *modest_module_new (const gchar *path);
+GObject *modest_module_new_object (ModestModule *module);
+
+G_END_DECLS
+
+#endif
DoubleConnectionInfo *info);
/**
- * modest_platform_get_account_settings_dialog:
- * @settings: a #ModestAccountSettings
- *
- * creates a dialog for editing @settings
- *
- * Returns: the newly created dialog.
- */
-GtkWidget *modest_platform_get_account_settings_dialog (ModestAccountSettings *settings);
-
-/**
* modest_platform_get_account_settings_wizard:
* @settings: a #ModestAccountSettings
*
--- /dev/null
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+plugindir=@libdir@/modest/mail-plugins
+
+Name: modest-plugin-1.0
+Description: Library for developing plugins for modest.
+Requires: glib-2.0 gobject-2.0 gtk+-2.0 gconf-2.0 gnome-vfs-2.0 libtinymail-1.0 libtinymail-camel-1.0 libtinymail-gnomevfs-1.0 libtinymailui-1.0 libtinymailui-gtk-1.0 libosso dbus-1 libtinymail-maemo-1.0 libebook-1.2 hildon-1 hildon-fm-2 hildon-help hildon-notify libnotify @hildonpkgs@
+Version: @VERSION@
+Cflags: -I${includedir}/modest-plugin-1.0 @MODEST_PLUGIN_DEFINES@
+
+ $(MODEST_GSTUFF_LIBS) \
+ $(MODEST_MOZEMBED_LIBS) \
+ $(MODEST_PLATFORM_LIBS) \
+ $(MODEST_HILDON_WIDGETS_LIBS) \
+ $(MODEST_HILDON_HELP_LIBS) \
+ $(MODEST_HILDON_NOTIFY_LIBS) \
+ $(MODEST_OGS_LIBS) \
+ ${easysetupmaybe} \
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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-plugin-factory.h"
+#include "modest-protocol-registry.h"
+#include "modest-plugin.h"
+#include "modest-module.h"
+#include <gmodule.h>
+/* include other impl specific header files */
+
+#define PLUGIN_EXT ".modest-mail-plugin"
+
+/* 'private'/'protected' functions */
+static void modest_plugin_factory_class_init (ModestPluginFactoryClass *klass);
+static void modest_plugin_factory_init (ModestPluginFactory *obj);
+static void modest_plugin_factory_finalize (GObject *obj);
+
+static ModestPlugin* modest_plugin_factory_load (const gchar *file);
+
+typedef GType (*ModestModuleRegisterFunc) (GTypeModule *);
+
+typedef struct _ModestPluginFactoryPrivate ModestPluginFactoryPrivate;
+struct _ModestPluginFactoryPrivate {
+ GSList *plugins;
+};
+
+#define MODEST_PLUGIN_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+ MODEST_TYPE_PLUGIN_FACTORY, \
+ ModestPluginFactoryPrivate))
+/* globals */
+static GObjectClass *parent_class = NULL;
+
+GType
+modest_plugin_factory_get_type (void)
+{
+ static GType my_type = 0;
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestPluginFactoryClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_plugin_factory_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof(ModestPluginFactory),
+ 1, /* n_preallocs */
+ (GInstanceInitFunc) modest_plugin_factory_init,
+ NULL
+ };
+ my_type = g_type_register_static (G_TYPE_OBJECT,
+ "ModestPluginFactory",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_plugin_factory_class_init (ModestPluginFactoryClass *klass)
+{
+ GObjectClass *gobject_class;
+ gobject_class = (GObjectClass*) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ gobject_class->finalize = modest_plugin_factory_finalize;
+
+ g_type_class_add_private (gobject_class, sizeof(ModestPluginFactoryPrivate));
+}
+
+static void
+modest_plugin_factory_init (ModestPluginFactory *obj)
+{
+ ModestPluginFactoryPrivate *priv = MODEST_PLUGIN_FACTORY_GET_PRIVATE(obj);
+
+ if (!g_module_supported ()) {
+ g_warning ("unable to initialize the plugin factory");
+ return;
+ }
+
+ priv->plugins = NULL;
+ g_module_open (NULL, 0);
+}
+
+static void
+modest_plugin_factory_finalize (GObject *obj)
+{
+ ModestPluginFactoryPrivate *priv;
+ GSList *iter;
+
+ priv = MODEST_PLUGIN_FACTORY_GET_PRIVATE (obj);
+
+ /* Free the plugin list */
+ for (iter = priv->plugins; iter; iter = g_slist_next (iter))
+ g_module_close ((GModule*) iter->data);
+
+ g_slist_free (priv->plugins);
+ priv->plugins = NULL;
+
+ G_OBJECT_CLASS(parent_class)->finalize (obj);
+}
+
+ModestPluginFactory*
+modest_plugin_factory_new (void)
+{
+ ModestPluginFactory *self;
+ ModestPluginFactoryPrivate *priv;
+
+ self = MODEST_PLUGIN_FACTORY (g_object_new (MODEST_TYPE_PLUGIN_FACTORY, NULL));
+ priv = MODEST_PLUGIN_FACTORY_GET_PRIVATE(self);
+
+/* if (priv->plugins == NULL) { */
+/* g_critical ("%s, no mail plugins detected", __FUNCTION__); */
+/* g_object_unref (self); */
+/* self = NULL; */
+/* } */
+ return self;
+}
+
+void
+modest_plugin_factory_load_all (ModestPluginFactory *self)
+{
+ ModestPluginFactoryPrivate *priv;
+ GError *error = NULL;
+ GDir *d;
+ const gchar *dirent;
+ ModestProtocolRegistry *pr;
+
+ pr = modest_plugin_get_protocol_registry ();
+
+ priv = MODEST_PLUGIN_FACTORY_GET_PRIVATE(self);
+
+ if (!g_file_test (MODEST_MAILPLUGINDIR, G_FILE_TEST_IS_DIR)) {
+ return;
+ }
+
+ d = g_dir_open (MODEST_MAILPLUGINDIR, 0, &error);
+
+ if (!d) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+
+ return;
+ }
+
+ while ((dirent = g_dir_read_name (d))) {
+ if (g_str_has_suffix (dirent, PLUGIN_EXT)) {
+ gchar *plugin_file;
+ ModestPlugin *plugin;
+
+ plugin_file = g_build_filename (MODEST_MAILPLUGINDIR, dirent, NULL);
+ plugin = modest_plugin_factory_load (plugin_file);
+ g_free (plugin_file);
+
+ if (plugin)
+ priv->plugins = g_slist_prepend (priv->plugins, plugin);
+ }
+ }
+
+ priv->plugins = g_slist_reverse (priv->plugins);
+
+ g_dir_close (d);
+}
+
+static ModestPlugin*
+modest_plugin_factory_load (const gchar *file)
+{
+ ModestPlugin *plugin;
+ GKeyFile *plugin_file = NULL;
+ gchar *plugin_name, *dir, *path;
+ GTypeModule *type_module;
+
+ g_return_val_if_fail (file != NULL, NULL);
+
+ plugin_file = g_key_file_new ();
+
+ if (!g_key_file_load_from_file (plugin_file, file, G_KEY_FILE_NONE, NULL)) {
+ g_warning ("Bad plugin file: %s", file);
+ goto error;
+ }
+
+ /* Get Location */
+ plugin_name = g_key_file_get_string (plugin_file,
+ "Modest Mail Plugin",
+ "Module",
+ NULL);
+
+ if ((plugin_name == NULL) || (*plugin_name == '\0')) {
+ g_warning ("Could not find 'Module' in %s", file);
+ goto error;
+ }
+
+ g_key_file_free (plugin_file);
+
+ /* Build path to plugin */
+ dir = g_path_get_dirname (file);
+ path = g_module_build_path (dir, plugin_name);
+ g_free (dir);
+
+ /* plugin = g_module_open (path, G_MODULE_BIND_LAZY); */
+ g_message ("PLUGIN TYPE IS %d", (gint) modest_plugin_get_type ());
+ type_module = G_TYPE_MODULE (modest_module_new (path));
+ if (type_module) {
+ g_type_module_use (type_module);
+ plugin = MODEST_PLUGIN (modest_module_new_object (MODEST_MODULE (type_module)));
+ }
+ g_free (path);
+
+ return plugin;
+error:
+ g_key_file_free (plugin_file);
+
+ return NULL;
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+#ifndef __MODEST_PLUGIN_FACTORY_H__
+#define __MODEST_PLUGIN_FACTORY_H__
+
+#include <glib-object.h>
+/* other include files */
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_PLUGIN_FACTORY (modest_plugin_factory_get_type())
+#define MODEST_PLUGIN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_PLUGIN_FACTORY,ModestPluginFactory))
+#define MODEST_PLUGIN_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_PLUGIN_FACTORY,GObjectClass))
+#define MODEST_IS_PLUGIN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_PLUGIN_FACTORY))
+#define MODEST_IS_PLUGIN_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_PLUGIN_FACTORY))
+#define MODEST_PLUGIN_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_PLUGIN_FACTORY,ModestPluginFactoryClass))
+
+typedef struct _ModestPluginFactory ModestPluginFactory;
+typedef struct _ModestPluginFactoryClass ModestPluginFactoryClass;
+
+struct _ModestPluginFactory {
+ GObject parent;
+};
+
+struct _ModestPluginFactoryClass {
+ GObjectClass parent_class;
+};
+
+/* member functions */
+GType modest_plugin_factory_get_type (void) G_GNUC_CONST;
+
+ModestPluginFactory* modest_plugin_factory_new (void);
+
+void modest_plugin_factory_load_all (ModestPluginFactory *self);
+
+G_END_DECLS
+
+#endif /* __MODEST_PLUGIN_FACTORY_H__ */
+
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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-plugin.h>
+#include <modest-runtime.h>
+
+G_DEFINE_TYPE (ModestPlugin, modest_plugin, G_TYPE_OBJECT)
+
+static void modest_plugin_class_init (ModestPluginClass *klass);
+static void modest_plugin_finalize (GObject *obj);
+
+#define MODEST_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ MODEST_TYPE_PLUGIN, \
+ ModestPluginPrivate))
+
+static GObjectClass *parent_class = NULL;
+
+/* globals */
+
+static void
+modest_plugin_class_init (ModestPluginClass *klass)
+{
+ GObjectClass *object_class;
+ object_class = (GObjectClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ object_class->finalize = modest_plugin_finalize;
+}
+
+static void
+modest_plugin_init (ModestPlugin *obj)
+{
+
+}
+
+static void
+modest_plugin_finalize (GObject *obj)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+ModestPlugin*
+modest_plugin_new (void)
+{
+ ModestPlugin *plugin;
+
+ plugin = g_object_new (MODEST_TYPE_PLUGIN, NULL);
+
+ g_type_module_use (G_TYPE_MODULE (plugin));
+ g_type_module_unuse (G_TYPE_MODULE (plugin));
+
+ return plugin;
+}
+
+ModestAccountMgr *
+modest_plugin_get_account_mgr (void)
+{
+ /* This is for avoiding including modest runtime itself */
+ return modest_runtime_get_account_mgr ();
+}
+
+ModestProtocolRegistry *
+modest_plugin_get_protocol_registry (void)
+{
+ /* This is for avoiding including modest runtime itself */
+ return modest_runtime_get_protocol_registry ();
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+#ifndef __MODEST_PLUGIN_H__
+#define __MODEST_PLUGIN_H__
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <modest-account-mgr.h>
+#include <modest-protocol-registry.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_PLUGIN (modest_plugin_get_type())
+#define MODEST_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_PLUGIN,ModestPlugin))
+#define MODEST_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_PLUGIN,ModestPluginClass))
+#define MODEST_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_PLUGIN))
+#define MODEST_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_PLUGIN))
+#define MODEST_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_PLUGIN,ModestPluginClass))
+
+typedef struct _ModestPlugin ModestPlugin;
+typedef struct _ModestPluginClass ModestPluginClass;
+
+struct _ModestPlugin {
+ GObject parent;
+};
+
+struct _ModestPluginClass {
+ GObjectClass parent_class;
+};
+
+/**
+ * modest_plugin_get_type:
+ *
+ * Returns: GType of the account store
+ */
+GType modest_plugin_get_type (void) G_GNUC_CONST;
+
+#define MODEST_PLUGIN_REGISTER_TYPE(PluginName, plugin_name) \
+ \
+static GType plugin_name##_type = 0; \
+ \
+GType \
+plugin_name##_get_type (void) \
+{ \
+ return plugin_name##_type; \
+} \
+ \
+static void plugin_name##_init (PluginName *self); \
+static void plugin_name##_class_init (PluginName##Class *klass); \
+static gpointer plugin_name##_parent_class = NULL; \
+static void plugin_name##_class_intern_init (gpointer klass) \
+{ \
+ plugin_name##_parent_class = g_type_class_peek_parent (klass); \
+ plugin_name##_class_init ((PluginName##Class *) klass); \
+} \
+ \
+G_MODULE_EXPORT GType \
+register_modest_plugin (GTypeModule *module) \
+{ \
+ static const GTypeInfo our_info = \
+ { \
+ sizeof (PluginName##Class), \
+ NULL, /* base_init */ \
+ NULL, /* base_finalize */ \
+ (GClassInitFunc) plugin_name##_class_intern_init, \
+ NULL, \
+ NULL, /* class_data */ \
+ sizeof (PluginName), \
+ 0, /* n_preallocs */ \
+ (GInstanceInitFunc) plugin_name##_init \
+ }; \
+ \
+ \
+ plugin_name##_type = g_type_module_register_type (module, \
+ MODEST_TYPE_PLUGIN, \
+ #PluginName, \
+ &our_info, \
+ 0); \
+ \
+ return plugin_name##_type; \
+}
+
+/* Global methods providing access to singletons without using modest runtime */
+ModestAccountMgr *modest_plugin_get_account_mgr (void);
+ModestProtocolRegistry *modest_plugin_get_protocol_registry (void);
+
+G_END_DECLS
+
+#endif /* __MODEST_PLUGIN_H__ */
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * 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 <glib/gi18n.h>
-#include <string.h> /* strcmp */
-#include <modest-protocol-info.h>
-#include <modest-pair.h>
-#include <modest-defs.h>
-#include <modest-text-utils.h>
-
-typedef struct {
- gint proto;
- const gchar* name;
- const gchar* display_name;
-} ProtocolInfo;
-
-static const ProtocolInfo TransportStoreProtocolMap[] = {
- { MODEST_PROTOCOL_TRANSPORT_SENDMAIL, "sendmail", N_("Sendmail") },
- { MODEST_PROTOCOL_TRANSPORT_SMTP, "smtp", N_("SMTP Server") },
-
- { MODEST_PROTOCOL_STORE_POP, "pop", N_("POP3") },
- { MODEST_PROTOCOL_STORE_IMAP, "imap", N_("IMAPv4") },
- { MODEST_PROTOCOL_STORE_MAILDIR, "maildir", N_("Maildir") },
- { MODEST_PROTOCOL_STORE_MBOX, "mbox", N_("MBox") }
-};
-
-static const ProtocolInfo SupportedStoreProtocolMap[] = {
- { MODEST_PROTOCOL_STORE_POP, "pop", N_("POP3") },
- { MODEST_PROTOCOL_STORE_IMAP, "imap", N_("IMAPv4") },
-};
-
-static const ProtocolInfo ConnectionProtocolMap[] = {
- { MODEST_PROTOCOL_CONNECTION_NORMAL, "none", N_("None") },
- { MODEST_PROTOCOL_CONNECTION_SSL, "ssl", N_("SSL") },
- { MODEST_PROTOCOL_CONNECTION_TLS, "tls", N_("TLS") },
- { MODEST_PROTOCOL_CONNECTION_TLS_OP, "tls-op", N_("TLS when possible") }
- /* op stands for optional */
-};
-
-
-/* FIXME: these names must match those of tny_camel_account_get_supported_secure_auth */
-static const ProtocolInfo AuthProtocolMap[] = {
- { MODEST_PROTOCOL_AUTH_NONE, MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE, N_("None") },
- { MODEST_PROTOCOL_AUTH_PASSWORD, MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD, N_("Password") },
- { MODEST_PROTOCOL_AUTH_CRAMMD5, MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5, N_("Cram MD5") }
-};
-
-static ModestPairList*
-get_protocol_pair_list (const ProtocolInfo* map, guint size)
-{
- g_return_val_if_fail (map, NULL);
-
- ModestPairList *proto_list = NULL;
- int i;
- for (i = 0; i != size; ++i) {
- const ProtocolInfo info = map[i];
- proto_list = g_slist_append (proto_list,
- (gpointer)modest_pair_new(
- (gpointer)info.name,
- (gpointer)info.display_name,
- FALSE));
- }
- return proto_list;
-}
-
-static gint
-get_protocol_by_name (const ProtocolInfo* map,
- guint size,
- const gchar* query_name,
- gint default_value,
- gboolean case_sensitive)
-{
- guint i;
-
- g_return_val_if_fail (map, default_value);
- g_return_val_if_fail (query_name, default_value);
-
- for(i = 0; i < size; ++i)
- if (modest_text_utils_utf8_strcmp (map[i].name, query_name,
- !case_sensitive) == 0)
- return map[i].proto;
-
- return default_value;
-}
-
-ModestPairList*
-modest_protocol_info_get_transport_store_protocol_pair_list (void)
-{
- return get_protocol_pair_list (TransportStoreProtocolMap,
- G_N_ELEMENTS(TransportStoreProtocolMap));
-}
-
-ModestPairList*
-modest_protocol_info_get_supported_store_protocol_pair_list (void)
-{
- return get_protocol_pair_list (SupportedStoreProtocolMap,
- G_N_ELEMENTS(SupportedStoreProtocolMap));
-}
-
-
-ModestPairList*
-modest_protocol_info_get_auth_protocol_pair_list (void)
-{
- return get_protocol_pair_list (AuthProtocolMap,
- G_N_ELEMENTS(AuthProtocolMap));
-}
-
-ModestPairList*
-modest_protocol_info_get_connection_protocol_pair_list (void)
-{
- return get_protocol_pair_list (ConnectionProtocolMap,
- G_N_ELEMENTS(ConnectionProtocolMap));
-}
-
-ModestTransportStoreProtocol
-modest_protocol_info_get_transport_store_protocol (const gchar* name)
-{
- g_return_val_if_fail (name, MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN);
-
- return get_protocol_by_name(TransportStoreProtocolMap,
- G_N_ELEMENTS(TransportStoreProtocolMap),
- name,
- MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN,
- TRUE);
-}
-
-ModestAuthProtocol
-modest_protocol_info_get_auth_protocol (const gchar* name)
-{
- g_return_val_if_fail (name, MODEST_PROTOCOL_AUTH_NONE);
-
- return get_protocol_by_name(AuthProtocolMap,
- G_N_ELEMENTS(AuthProtocolMap),
- name,
- MODEST_PROTOCOL_AUTH_NONE,
- FALSE);
-}
-
-ModestConnectionProtocol
-modest_protocol_info_get_connection_protocol (const gchar* name)
-{
- g_return_val_if_fail (name, MODEST_PROTOCOL_CONNECTION_NORMAL);
-
- return get_protocol_by_name(ConnectionProtocolMap,
- G_N_ELEMENTS(ConnectionProtocolMap),
- name,
- MODEST_PROTOCOL_CONNECTION_NORMAL,
- FALSE);
-}
-
-
-/* get either the name or the display_name for the protocol */
-static const gchar*
-get_protocol_string (gint proto, const ProtocolInfo* map, guint size, gboolean get_name)
-{
- g_return_val_if_fail (map, NULL);
-
- int i;
- for (i = 0; i != size; ++i) {
- ProtocolInfo info = map[i];
- if (info.proto == proto)
- return get_name ? info.name : info.display_name;
- }
- g_return_val_if_reached (NULL);
-}
-
-const gchar*
-modest_protocol_info_get_transport_store_protocol_name (ModestTransportStoreProtocol proto)
-{
- return get_protocol_string (proto, TransportStoreProtocolMap,
- G_N_ELEMENTS(TransportStoreProtocolMap), TRUE);
-}
-
-const gchar*
-modest_protocol_info_get_auth_protocol_name (ModestAuthProtocol proto)
-{
- return get_protocol_string (proto, AuthProtocolMap,
- G_N_ELEMENTS(AuthProtocolMap), TRUE);
-}
-
-const gchar*
-modest_protocol_info_get_connection_protocol_name (ModestAuthProtocol proto)
-{
- return get_protocol_string (proto, ConnectionProtocolMap,
- G_N_ELEMENTS(ConnectionProtocolMap), TRUE);
-}
-
-
-gboolean
-modest_protocol_info_protocol_is_local_store (ModestTransportStoreProtocol proto)
-{
- return proto == MODEST_PROTOCOL_STORE_MBOX || proto == MODEST_PROTOCOL_STORE_MAILDIR;
-}
-
-
-
-gboolean
-modest_protocol_info_protocol_is_store (ModestTransportStoreProtocol proto)
-{
- return proto == MODEST_PROTOCOL_STORE_MBOX || proto == MODEST_PROTOCOL_STORE_MAILDIR ||
- proto == MODEST_PROTOCOL_STORE_POP || proto == MODEST_PROTOCOL_STORE_IMAP;
-}
-
-gboolean
-modest_protocol_info_is_secure(ModestConnectionProtocol protocol)
-{
- return (protocol == MODEST_PROTOCOL_CONNECTION_SSL ||
- protocol == MODEST_PROTOCOL_CONNECTION_TLS);
-}
-
-gboolean modest_protocol_info_auth_is_secure(ModestAuthProtocol protocol)
-{
- return (protocol == MODEST_PROTOCOL_AUTH_CRAMMD5);
-}
+++ /dev/null
-/* Copyright (c) 2006, Nokia Corporation
- * 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.
- */
-
-#ifndef __MODEST_PROTOCOL_INFO_H__
-#define __MODEST_PROTOCOL_INFO_H__
-
-#include <modest-pair.h>
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-/** Transport and Store protocols. */
-typedef enum {
- MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN,
- MODEST_PROTOCOL_TRANSPORT_SENDMAIL,
- MODEST_PROTOCOL_TRANSPORT_SMTP,
-
- MODEST_PROTOCOL_STORE_POP,
- MODEST_PROTOCOL_STORE_IMAP,
- MODEST_PROTOCOL_STORE_MAILDIR,
- MODEST_PROTOCOL_STORE_MBOX
-} ModestTransportStoreProtocol;
-
-/** Secure connection methods. */
-typedef enum {
- MODEST_PROTOCOL_CONNECTION_NORMAL,
- MODEST_PROTOCOL_CONNECTION_SSL,
- MODEST_PROTOCOL_CONNECTION_TLS,
- MODEST_PROTOCOL_CONNECTION_TLS_OP
-} ModestConnectionProtocol;
-
-/** Secure authentication methods. */
-typedef enum {
- MODEST_PROTOCOL_AUTH_NONE,
- MODEST_PROTOCOL_AUTH_PASSWORD,
- MODEST_PROTOCOL_AUTH_CRAMMD5
-} ModestAuthProtocol;
-
-
-
-
-/**
- * modest_protocol_info_get_transport_store_protocol_pair_list:
- *
- * return the list of <protocol,display-name>-tupels of protocols.
- * The elements of the returned list are ModestPairs
- * This is a convenience function for use with ModestComboBox
- *
- * Returns: a list of protocols. After use, it should be freed
- * with modest_pair_list_free
- */
-ModestPairList*
-modest_protocol_info_get_transport_store_protocol_pair_list ();
-
-/**
- * modest_protocol_info_get_supported_store_protocol_pair_list:
- *
- * return the list of <protocol,display-name>-tuples of
- * store protocols.
- * The elements of the returned list are ModestPairs
- * This is a convenience function for use with ModestComboBox
- *
- * In this case it only returns the UI exposed protocols for
- * storage (IMAP, POP3).
- *
- * Returns: a list of protocols. After use, it should be freed
- * with modest_pair_list_free
- */
-ModestPairList*
-modest_protocol_info_get_supported_store_protocol_pair_list ();
-
-/**
- * modest_protocol_info_get_auth_protocol_pair_list:
- *
- * return the list of <protocol,display-name>-tupels of protocols.
- * The elements of the returned list are ModestPairs
- * This is a convenience function for use with ModestComboBox
- *
- * Returns: a list of protocols. After use, it should be freed
- * with modest_pair_list_free
- */
-ModestPairList* modest_protocol_info_get_auth_protocol_pair_list (void);
-
-
-/**
- * modest_protocol_info_get_connection_protocol_pair_list:
- *
- * return the list of <protocol,display-name>-tupels of protocols.
- * The elements of the returned list are ModestPairs
- * This is a convenience function for use with ModestComboBox
- *
- * Returns: a list of protocols. After use, it should be freed
- * with modest_pair_list_free
- */
-ModestPairList* modest_protocol_info_get_connection_protocol_pair_list (void);
-
-
-/**
- * modest_protocol_info_get_transport_store_protocol:
- * @name: the name of the #ModestTransportStoreProtocol
- *
- * return the id of the protocol with the given name
- *
- * Returns: the id of the protocol or MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN
- */
-ModestTransportStoreProtocol modest_protocol_info_get_transport_store_protocol (const gchar* name);
-
-/**
- * modest_protocol_info_get_auth_protocol:
- * @name: The name of the #ModestAuthProtocol
- *
- * Returns the ID of the protocol with the given name
- *
- * Returns: The ID of the protocol or MODEST_PROTOCOL_AUTH_NONE
- */
-ModestAuthProtocol modest_protocol_info_get_auth_protocol (const gchar* name);
-
-/**
- * modest_protocol_info_get_connection_protocol:
- * @name: The name of the #ModestConnectionProtocol
- *
- * Returns the ID of the protocol with the given name
- *
- * Returns: The ID of the protocol or MODEST_CONNECTION_PROTOCOL_NORMAL
- */
-ModestConnectionProtocol modest_protocol_info_get_connection_protocol (const gchar* name);
-
-/**
- * modest_protocol_info_get_transport_store_protocol_name:
- * @proto: the protocol you are looking for
- *
- * return the string id of the proto (such as "imap", or "smtp")
- *
- * Returns: string id of the proto as a constant string, that should NOT be modified or freed
- */
-const gchar* modest_protocol_info_get_transport_store_protocol_name (ModestTransportStoreProtocol proto);
-
-/**
- * modest_protocol_info_get_auth_protocol_name:
- * @proto: the protocol you are looking for
- *
- * return the string id of the proto (such as "password", or "cram-md5")
- *
- * Returns: string id of the proto as a constant string, that should NOT be modified or freed
- */
-const gchar* modest_protocol_info_get_auth_protocol_name (ModestAuthProtocol proto);
-
-/*
- * modest_protocol_get_auth_protocol_pair_list:
- *
- * Get the list of support authentication methods supported by modest including
- * the display names of those.
- *
- * Returns: List of method/display name pairs
- */
-ModestPairList* modest_protocol_info_get_auth_protocol_pair_list (void);
-
-/**
- * modest_protocol_info_get_auth_protocol_name:
- * @proto: the protocol you are looking for
- *
- * return the string id of the proto (such as "ssl", or "tls")
- *
- * Returns: string id of the proto as a constant string, that should NOT be modified or freed
- */
-const gchar*
-modest_protocol_info_get_connection_protocol_name (ModestAuthProtocol proto);
-
-
-/**
- * modest_protocol_info_protocol_is_local_store:
- * @proto: the protocol
- *
- * is this protocol a store protocol?
- *
- * Returns: TRUE if it is a local store, FALSE otherwise
- *
- */
-gboolean modest_protocol_info_protocol_is_store (ModestTransportStoreProtocol proto);
-
-
-/**
- * modest_protocol_info_protocol_is_local_store:
- * @proto: the protocol
- *
- * is this protocol a local store protocol?
- *
- * Returns: TRUE if it is a local store, FALSE otherwise
- *
- */
-gboolean modest_protocol_info_protocol_is_local_store (ModestTransportStoreProtocol proto);
-
-
-/**
- * modest_protocol_info_is_secure:
- * @protocol
- *
- * is the protocol connection secure (e.g encrypted)?
- *
- * Returns: TRUE if it is secure, FALSE otherwise
- *
- */
-gboolean modest_protocol_info_is_secure(ModestConnectionProtocol protocol);
-
-/**
- * modest_protocol_info_auth_is_secure:
- * @protocol
- *
- * is the protocol authentication secure (e.g encrypted)?
- *
- * Returns: TRUE if it is secure, FALSE otherwise
- *
- */
-gboolean modest_protocol_info_auth_is_secure(ModestAuthProtocol protocol);
-
-
-G_END_DECLS
-#endif /* __MODEST_PROTOCOL_INFO_H__ */
-
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * 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 <string.h>
+#include <modest-account-protocol.h>
+#include <modest-defs.h>
+#include <modest-protocol-registry.h>
+#include <tny-camel-pop-store-account.h>
+#include <tny-camel-imap-store-account.h>
+#include <tny-camel-store-account.h>
+#include <tny-camel-transport-account.h>
+#include <tny-simple-list.h>
+
+#define TAG_ALL_PROTOCOLS "__MODEST_PROTOCOL_REGISTRY_ALL_PROTOCOLS"
+
+/* These seem to be listed in
+ * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
+ */
+#define MODEST_ACCOUNT_OPTION_SSL_NEVER "never"
+/* This is a tinymail camel-lite specific option,
+ * roughly equivalent to "always" in regular camel,
+ * which is appropriate for a generic "SSL" connection option: */
+#define MODEST_ACCOUNT_OPTION_SSL_WRAPPED "wrapped"
+/* Not used in our UI so far: */
+#define MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE "when-possible"
+/* This is a tinymailcamel-lite specific option that is not in regular camel. */
+#define MODEST_ACCOUNT_OPTION_SSL_TLS "tls"
+
+/* Posssible values for tny_account_set_secure_auth_mech().
+ * These might be camel-specific.
+ * Really, tinymail should use an enum.
+ * camel_sasl_authtype() seems to list some possible values.
+ */
+
+/* Note that evolution does not offer these for IMAP: */
+#define MODEST_ACCOUNT_AUTH_PLAIN "PLAIN"
+#define MODEST_ACCOUNT_AUTH_ANONYMOUS "ANONYMOUS"
+
+/* Caeml's IMAP uses NULL instead for "Password".
+ * Also, not that Evolution offers "Password" for IMAP, but "Login" for SMTP.*/
+#define MODEST_ACCOUNT_AUTH_PASSWORD "LOGIN"
+#define MODEST_ACCOUNT_AUTH_CRAMMD5 "CRAM-MD5"
+
+/* These seem to be listed in
+ * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-provider.c
+ */
+#define MODEST_ACCOUNT_OPTION_USE_LSUB "use_lsub" /* Show only subscribed folders */
+#define MODEST_ACCOUNT_OPTION_CHECK_ALL "check_all" /* Check for new messages in all folders */
+
+/* 'private'/'protected' functions */
+static void modest_protocol_registry_class_init (ModestProtocolRegistryClass *klass);
+static void modest_protocol_registry_finalize (GObject *obj);
+static void modest_protocol_registry_instance_init (ModestProtocolRegistry *obj);
+static GHashTable * modest_protocol_registry_create_tag (ModestProtocolRegistry *obj, const gchar *tag);
+
+/* translation handlers */
+static gchar * translation_is_userdata (gpointer userdata, ...);
+
+typedef struct _ModestProtocolRegistryPrivate ModestProtocolRegistryPrivate;
+struct _ModestProtocolRegistryPrivate {
+ GHashTable *tags_table;
+ GHashTable *priorities;
+};
+
+#define MODEST_PROTOCOL_REGISTRY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ MODEST_TYPE_PROTOCOL_REGISTRY, \
+ ModestProtocolRegistryPrivate))
+
+/* globals */
+static GObjectClass *parent_class = NULL;
+
+static ModestProtocolType pop_protocol_type_id = -1;
+static ModestProtocolType imap_protocol_type_id = -1;
+static ModestProtocolType maildir_protocol_type_id = -1;
+static ModestProtocolType mbox_protocol_type_id = -1;
+static ModestProtocolType smtp_protocol_type_id = -1;
+static ModestProtocolType sendmail_protocol_type_id = -1;
+static ModestProtocolType none_connection_protocol_type_id = -1;
+static ModestProtocolType ssl_connection_protocol_type_id = -1;
+static ModestProtocolType tls_connection_protocol_type_id = -1;
+static ModestProtocolType tlsop_connection_protocol_type_id = -1;
+static ModestProtocolType none_auth_protocol_type_id = -1;
+static ModestProtocolType password_auth_protocol_type_id = -1;
+static ModestProtocolType crammd5_auth_protocol_type_id = -1;
+
+GType
+modest_protocol_registry_get_type (void)
+{
+ static GType my_type = 0;
+
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestProtocolRegistryClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_protocol_registry_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof(ModestProtocolRegistry),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) modest_protocol_registry_instance_init,
+ NULL
+ };
+
+ my_type = g_type_register_static (G_TYPE_OBJECT,
+ "ModestProtocolRegistry",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_protocol_registry_class_init (ModestProtocolRegistryClass *klass)
+{
+ GObjectClass *object_class;
+ object_class = (GObjectClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ object_class->finalize = modest_protocol_registry_finalize;
+ g_type_class_add_private (object_class,
+ sizeof(ModestProtocolRegistryPrivate));
+}
+
+static void
+modest_protocol_registry_instance_init (ModestProtocolRegistry *obj)
+{
+ ModestProtocolRegistryPrivate *priv;
+
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (obj);
+
+ priv->tags_table = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->priorities = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ modest_protocol_registry_create_tag (obj, TAG_ALL_PROTOCOLS);
+}
+
+static void
+modest_protocol_registry_finalize (GObject *obj)
+{
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+
+ModestProtocolRegistry*
+modest_protocol_registry_new ()
+{
+ return g_object_new (MODEST_TYPE_PROTOCOL_REGISTRY, NULL);
+}
+
+void
+modest_protocol_registry_add (ModestProtocolRegistry *self, ModestProtocol *protocol, gint priority, const gchar *first_tag, ...)
+{
+ va_list list;
+ GSList *tags_list = NULL, *node = NULL;
+ const gchar *va_string;
+ GHashTable *tag_table;
+ ModestProtocolRegistryPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_PROTOCOL_REGISTRY (self));
+ g_return_if_fail (MODEST_IS_PROTOCOL (protocol));
+ g_return_if_fail (first_tag != NULL);
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (self);
+
+ tag_table = g_hash_table_lookup (priv->tags_table, TAG_ALL_PROTOCOLS);
+ g_hash_table_insert (tag_table, GINT_TO_POINTER (modest_protocol_get_type_id (protocol)), g_object_ref (protocol));
+
+ g_hash_table_insert (priv->priorities, GINT_TO_POINTER (modest_protocol_get_type_id (protocol)), GINT_TO_POINTER (priority));
+
+ tags_list = g_slist_prepend (tags_list, (gpointer) first_tag);
+ va_start (list, first_tag);
+ while ((va_string = va_arg (list, const gchar *)) != NULL) {
+ tags_list = g_slist_prepend (tags_list, (gpointer) va_string);
+ }
+ va_end (list);
+
+ for (node = tags_list; node != NULL; node = g_slist_next (node)) {
+
+ tag_table = g_hash_table_lookup (priv->tags_table, node->data);
+ if (tag_table == NULL)
+ tag_table = modest_protocol_registry_create_tag (self, node->data);
+ g_hash_table_insert (tag_table, GINT_TO_POINTER (modest_protocol_get_type_id (protocol)), protocol);
+ }
+ g_slist_free (tags_list);
+}
+
+GSList *
+modest_protocol_registry_get_all (ModestProtocolRegistry *self)
+{
+ ModestProtocolRegistryPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL_REGISTRY (self), NULL);
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (self);
+
+ return modest_protocol_registry_get_by_tag (self, TAG_ALL_PROTOCOLS);
+
+}
+
+static void
+add_protocol_to_list (ModestProtocolType key, ModestProtocol *protocol, GSList **list)
+{
+ *list = g_slist_prepend (*list, protocol);
+}
+
+static gint
+compare_protocols (ModestProtocol *a, ModestProtocol *b, GHashTable *priorities)
+{
+ ModestProtocolType a_type, b_type;
+ gint result;
+
+ a_type = modest_protocol_get_type_id (a);
+ b_type = modest_protocol_get_type_id (b);
+
+ result = g_hash_table_lookup (priorities, GINT_TO_POINTER (a_type)) - g_hash_table_lookup (priorities, GINT_TO_POINTER (b_type));
+ if (result == 0) {
+ const gchar *a_display_name;
+ const gchar *b_display_name;
+
+ a_display_name = modest_protocol_get_display_name (a);
+ b_display_name = modest_protocol_get_display_name (b);
+ result = g_utf8_collate (a_display_name, b_display_name);
+ }
+ return result;
+}
+
+GSList *
+modest_protocol_registry_get_by_tag (ModestProtocolRegistry *self, const gchar *tag)
+{
+ ModestProtocolRegistryPrivate *priv;
+ GHashTable *tag_table;
+ GSList *result;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL_REGISTRY (self), NULL);
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (self);
+
+ tag_table = g_hash_table_lookup (priv->tags_table, tag);
+ if (tag_table == NULL) {
+ return NULL;
+ }
+
+ result = NULL;
+ g_hash_table_foreach (tag_table, (GHFunc) add_protocol_to_list, &result);
+
+ result = g_slist_sort_with_data (result, (GCompareDataFunc) compare_protocols, priv->priorities);
+
+ return result;
+
+}
+
+static void
+add_protocol_to_pair_list (ModestProtocolType type_id, ModestProtocol *protocol, GSList **list)
+{
+ *list = g_slist_append (*list,
+ (gpointer) modest_pair_new (
+ (gpointer) modest_protocol_get_name (protocol),
+ (gpointer) modest_protocol_get_display_name (protocol),
+ FALSE));
+}
+
+ModestPairList *
+modest_protocol_registry_get_pair_list_by_tag (ModestProtocolRegistry *self, const gchar *tag)
+{
+ ModestProtocolRegistryPrivate *priv;
+ GHashTable *tag_table;
+ GSList *result;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL_REGISTRY (self), NULL);
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (self);
+
+ tag_table = g_hash_table_lookup (priv->tags_table, tag);
+ if (tag_table == NULL) {
+ return NULL;
+ }
+
+ g_hash_table_foreach (tag_table, (GHFunc) add_protocol_to_pair_list, &result);
+
+ return result;
+}
+
+static gboolean
+find_protocol_by_name (ModestProtocolType type_id,
+ ModestProtocol *protocol,
+ const gchar *name)
+{
+ return (strcmp (name, modest_protocol_get_name (protocol)) == 0);
+}
+
+ModestProtocol *
+modest_protocol_registry_get_protocol_by_name (ModestProtocolRegistry *self, const gchar *tag, const gchar *name)
+{
+ ModestProtocolRegistryPrivate *priv;
+ GHashTable *tag_table;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL_REGISTRY (self), NULL);
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (self);
+
+ tag_table = g_hash_table_lookup (priv->tags_table, tag);
+ if (tag_table == NULL) {
+ return NULL;
+ }
+
+ return g_hash_table_find (tag_table, (GHRFunc) find_protocol_by_name, (gpointer) name);
+}
+
+ModestProtocol *
+modest_protocol_registry_get_protocol_by_type (ModestProtocolRegistry *self, ModestProtocolType type_id)
+{
+ ModestProtocolRegistryPrivate *priv;
+ GHashTable *tag_table;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL_REGISTRY (self), NULL);
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (self);
+
+ tag_table = g_hash_table_lookup (priv->tags_table, TAG_ALL_PROTOCOLS);
+ if (tag_table == NULL) {
+ return NULL;
+ }
+
+ return g_hash_table_lookup (tag_table, GINT_TO_POINTER (type_id));
+}
+
+gboolean
+modest_protocol_registry_protocol_type_has_tag (ModestProtocolRegistry *self, ModestProtocolType type_id, const gchar *tag)
+{
+ ModestProtocolRegistryPrivate *priv;
+ GHashTable *tag_table;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL_REGISTRY (self), FALSE);
+ g_return_val_if_fail (tag != NULL, FALSE);
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (self);
+
+ tag_table = g_hash_table_lookup (priv->tags_table, tag);
+ if (tag_table == NULL) {
+ return FALSE;
+ }
+
+ return (g_hash_table_lookup (tag_table, GINT_TO_POINTER (type_id))!= NULL);
+
+}
+
+static GHashTable *
+modest_protocol_registry_create_tag (ModestProtocolRegistry *self, const gchar *tag)
+{
+ ModestProtocolRegistryPrivate *priv;
+ GHashTable *tag_table;
+
+ g_assert (tag != NULL);
+ priv = MODEST_PROTOCOL_REGISTRY_GET_PRIVATE (self);
+ tag_table = g_hash_table_new (g_direct_hash, g_direct_equal);
+ g_hash_table_insert (priv->tags_table, g_strdup (tag), tag_table);
+
+ return tag_table;
+}
+
+static gchar *
+translation_is_userdata (gpointer userdata, ...)
+{
+ va_list args, dest;
+ gchar *result;
+
+ va_start(args, userdata);
+ va_copy (dest, args);
+ result = g_strdup_printf (_(userdata), dest);
+ va_end (args);
+
+ return result;
+}
+
+static gchar *
+translation_is_userdata_no_param (gpointer userdata, ...)
+{
+ gchar *result;
+
+ result = g_strdup (_(userdata));
+
+ return result;
+}
+
+
+void
+modest_protocol_registry_set_to_default (ModestProtocolRegistry *self)
+{
+ ModestProtocol *protocol;
+ TnyList *account_options;
+ TnyPair *pair;
+
+ protocol = modest_account_protocol_new ("sendmail", N_("Sendmail"),
+ 0, 0,
+ TNY_TYPE_CAMEL_TRANSPORT_ACCOUNT);
+ sendmail_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_registry_add (self, protocol, 1,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS,
+ NULL);
+
+ protocol = modest_account_protocol_new ("smtp", N_("SMTP Server"),
+ 25, 465,
+ TNY_TYPE_CAMEL_TRANSPORT_ACCOUNT);
+ smtp_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_CONNECT_ERROR, translation_is_userdata, "emev_ib_ui_smtp_server_invalid", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_AUTH_ERROR, translation_is_userdata, "emev_ni_ui_smtp_authentication_fail_error", NULL);
+ modest_protocol_registry_add (self, protocol, 2,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS,
+ NULL);
+
+ protocol = modest_account_protocol_new ("pop", _("mail_fi_emailtype_pop3"),
+ 110, 995,
+ TNY_TYPE_CAMEL_POP_STORE_ACCOUNT);
+ pop_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_CONNECT_ERROR, translation_is_userdata, "emev_ni_ui_pop3_msg_connect_error", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_AUTH_ERROR, translation_is_userdata, "emev_ni_ui_pop3_msg_connect_error", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_ACCOUNT_CONNECTION_ERROR, translation_is_userdata, "emev_ni_ui_pop3_msg_connect_error", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE, translation_is_userdata_no_param, "emev_ni_ui_pop3_msg_recv_error", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_SSL_PROTO_NAME, translation_is_userdata_no_param, "mcen_fi_advsetup_other_security_securepop3s", NULL);
+ modest_protocol_registry_add (self, protocol, 3,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_HAS_LEAVE_ON_SERVER_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_FORBID_MESSAGE_ADD,
+ NULL);
+
+ protocol = modest_account_protocol_new ("imap", _("mail_fi_emailtype_imap"),
+ 143, 993,
+ TNY_TYPE_CAMEL_IMAP_STORE_ACCOUNT);
+ imap_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_DELETE_MAILBOX, translation_is_userdata, "emev_nc_delete_mailboximap", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_CONNECT_ERROR, translation_is_userdata, "emev_ni_ui_imap_connect_server_error", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_AUTH_ERROR, translation_is_userdata, "emev_ni_ui_imap_connect_server_error", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_ACCOUNT_CONNECTION_ERROR, translation_is_userdata, "emev_ni_ui_imap_connect_server_error", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE, translation_is_userdata, "emev_ni_ui_imap_message_not_available_in_server", NULL);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_SSL_PROTO_NAME, translation_is_userdata_no_param, "mcen_fi_advsetup_other_security_secureimap4s", NULL);
+ account_options = tny_simple_list_new ();
+ pair = tny_pair_new (MODEST_ACCOUNT_OPTION_USE_LSUB, "");
+ tny_list_append (account_options, G_OBJECT (pair));
+ g_object_unref (pair);
+ pair = tny_pair_new (MODEST_ACCOUNT_OPTION_CHECK_ALL, "");
+ tny_list_append (account_options, G_OBJECT (pair));
+ g_object_unref (pair);
+ modest_account_protocol_set_account_options (MODEST_ACCOUNT_PROTOCOL (protocol), account_options);
+ g_object_unref (account_options);
+ modest_protocol_registry_add (self, protocol, 4,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS,
+ NULL);
+
+ protocol = modest_account_protocol_new ("maildir", N_("Maildir"),
+ 0, 0,
+ TNY_TYPE_CAMEL_STORE_ACCOUNT);
+ maildir_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_ACCOUNT_CONNECTION_ERROR,
+ translation_is_userdata_no_param, "emev_nc_mailbox_notavailable", NULL);
+ modest_protocol_registry_add (self, protocol, 5,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_LOCAL_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS,
+ NULL);
+
+ protocol = modest_account_protocol_new ("mbox", N_("MBox"),
+ 0, 0,
+ TNY_TYPE_CAMEL_STORE_ACCOUNT);
+ mbox_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_set_translation (protocol, MODEST_PROTOCOL_TRANSLATION_ACCOUNT_CONNECTION_ERROR,
+ translation_is_userdata_no_param, "emev_nc_mailbox_notavailable", NULL);
+ modest_protocol_registry_add (self, protocol, 6,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_LOCAL_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS,
+ NULL);
+
+ protocol = modest_protocol_new ("none", N_("None"));
+ modest_protocol_set (protocol, MODEST_PROTOCOL_SECURITY_ACCOUNT_OPTION, MODEST_ACCOUNT_OPTION_SSL_NEVER);
+ none_connection_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_registry_add (self, protocol, 7,
+ MODEST_PROTOCOL_REGISTRY_CONNECTION_PROTOCOLS,
+ NULL);
+ protocol = modest_protocol_new ("ssl", N_("SSL"));
+ modest_protocol_set (protocol, MODEST_PROTOCOL_SECURITY_ACCOUNT_OPTION, MODEST_ACCOUNT_OPTION_SSL_WRAPPED);
+ ssl_connection_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_registry_add (self, protocol, 8,
+ MODEST_PROTOCOL_REGISTRY_CONNECTION_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_USE_ALTERNATE_PORT,
+ NULL);
+ protocol = modest_protocol_new ("tls", N_("TLS"));
+ modest_protocol_set (protocol, MODEST_PROTOCOL_SECURITY_ACCOUNT_OPTION, MODEST_ACCOUNT_OPTION_SSL_TLS);
+ tls_connection_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_registry_add (self, protocol, 9,
+ MODEST_PROTOCOL_REGISTRY_CONNECTION_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS,
+ NULL);
+ protocol = modest_protocol_new ("tls-op", N_("TLS when possible"));
+ modest_protocol_set (protocol, MODEST_PROTOCOL_SECURITY_ACCOUNT_OPTION, MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE);
+ tlsop_connection_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_registry_add (self, protocol, 10,
+ MODEST_PROTOCOL_REGISTRY_CONNECTION_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS,
+ NULL);
+ protocol = modest_protocol_new (MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE, _("mcen_fi_advsetup_smtp_none"));
+ none_auth_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_set (protocol, MODEST_PROTOCOL_AUTH_ACCOUNT_OPTION, MODEST_ACCOUNT_AUTH_PLAIN);
+ modest_protocol_registry_add (self, protocol, 11,
+ MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS,
+ NULL);
+ protocol = modest_protocol_new (MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD, _("mcen_fi_advsetup_smtp_login"));
+ password_auth_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_set (protocol, MODEST_PROTOCOL_AUTH_ACCOUNT_OPTION, MODEST_ACCOUNT_AUTH_PASSWORD);
+ modest_protocol_registry_add (self, protocol, 12,
+ MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS,
+ NULL);
+ protocol = modest_protocol_new (MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5, _("mcen_fi_advsetup_smtp_cram_md5"));
+ crammd5_auth_protocol_type_id = modest_protocol_get_type_id (protocol);
+ modest_protocol_set (protocol, MODEST_PROTOCOL_AUTH_ACCOUNT_OPTION, MODEST_ACCOUNT_AUTH_CRAMMD5);
+ modest_protocol_registry_add (self, protocol, 13,
+ MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS,
+ NULL);
+
+#if 0
+ /********** WARNING: Test code ( *********/
+#include "modest-testplugin-protocol.h"
+ protocol = (ModestProtocol *)
+ modest_testplugin_protocol_new ("testplugin", _("mcen_va_testplugin"),
+ 80, 443,
+ TNY_TYPE_CAMEL_IMAP_STORE_ACCOUNT);
+ modest_protocol_registry_add (self, protocol, 50,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS,
+ MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
+ NULL);
+
+ protocol = (ModestProtocol *)
+ modest_testplugin_protocol_new ("testplugin-transport", _("mcen_va_testplugin"),
+ 80, 443,
+ TNY_TYPE_CAMEL_TRANSPORT_ACCOUNT);
+ modest_protocol_registry_add (self, protocol, 51,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS,
+ MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS,
+ NULL);
+
+ /********* WARNING: Test code ( *********/
+#endif
+
+
+ /* set the custom auth mechs. We do this after creating all the protocols, because if we don't, then we
+ * won't register the auth protocol type id's properly */
+
+ /* IMAP and POP need at least a password,
+ * which camel uses if we specify NULL.
+ * Camel use a password for IMAP or POP if we specify NULL,
+ * For IMAP, at least it will report an error if we use "Password", "Login" or "Plain".
+ * (POP is know to report an error for Login too. Probably Password and Plain too.) */
+ protocol = modest_protocol_registry_get_protocol_by_type (self, MODEST_PROTOCOLS_STORE_IMAP);
+ modest_account_protocol_set_custom_secure_auth_mech (MODEST_ACCOUNT_PROTOCOL (protocol), MODEST_PROTOCOLS_AUTH_NONE, NULL);
+ modest_account_protocol_set_custom_secure_auth_mech (MODEST_ACCOUNT_PROTOCOL (protocol), MODEST_PROTOCOLS_AUTH_PASSWORD, NULL);
+ protocol = modest_protocol_registry_get_protocol_by_type (self, MODEST_PROTOCOLS_STORE_POP);
+ modest_account_protocol_set_custom_secure_auth_mech (MODEST_ACCOUNT_PROTOCOL (protocol), MODEST_PROTOCOLS_AUTH_NONE, NULL);
+ modest_account_protocol_set_custom_secure_auth_mech (MODEST_ACCOUNT_PROTOCOL (protocol), MODEST_PROTOCOLS_AUTH_PASSWORD, NULL);
+}
+
+ModestProtocolType
+modest_protocol_registry_get_imap_type_id (void)
+{
+ return imap_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_pop_type_id (void)
+{
+ return pop_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_maildir_type_id (void)
+{
+ return maildir_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_mbox_type_id (void)
+{
+ return mbox_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_smtp_type_id (void)
+{
+ return smtp_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_sendmail_type_id (void)
+{
+ return sendmail_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_none_connection_type_id (void)
+{
+ return none_connection_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_ssl_connection_type_id (void)
+{
+ return ssl_connection_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_tls_connection_type_id (void)
+{
+ return tls_connection_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_tlsop_connection_type_id (void)
+{
+ return tlsop_connection_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_none_auth_type_id (void)
+{
+ return none_auth_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_password_auth_type_id (void)
+{
+ return password_auth_protocol_type_id;
+}
+
+ModestProtocolType
+modest_protocol_registry_get_crammd5_auth_type_id (void)
+{
+ return crammd5_auth_protocol_type_id;
+}
+
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * 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.
+ */
+
+
+/* modest-account-settings.h */
+
+#ifndef __MODEST_PROTOCOL_REGISTRY_H__
+#define __MODEST_PROTOCOL_REGISTRY_H__
+
+#include <glib-object.h>
+#include <modest-protocol.h>
+#include <modest-pair.h>
+
+G_BEGIN_DECLS
+
+#define MODEST_PROTOCOL_REGISTRY_CONNECTION_PROTOCOLS "connection"
+#define MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS "auth"
+#define MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS "transport-store"
+#define MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS "store"
+#define MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS "transport"
+#define MODEST_PROTOCOL_REGISTRY_LOCAL_STORE_PROTOCOLS "local-store"
+#define MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS "remote-store"
+#define MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS "secure"
+#define MODEST_PROTOCOL_REGISTRY_HAS_LEAVE_ON_SERVER_PROTOCOLS "leave-on-server-available"
+#define MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS "providers"
+#define MODEST_PROTOCOL_REGISTRY_USE_ALTERNATE_PORT "use-alternate-port"
+#define MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS "store-has-folders"
+#define MODEST_PROTOCOL_REGISTRY_STORE_FORBID_MESSAGE_ADD "store-forbid-message-add"
+
+/* convenience macros */
+#define MODEST_TYPE_PROTOCOL_REGISTRY (modest_protocol_registry_get_type())
+#define MODEST_PROTOCOL_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_PROTOCOL_REGISTRY,ModestProtocolRegistry))
+#define MODEST_PROTOCOL_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_PROTOCOL_REGISTRY,ModestProtocolRegistryClass))
+#define MODEST_IS_PROTOCOL_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_PROTOCOL_REGISTRY))
+#define MODEST_IS_PROTOCOL_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_PROTOCOL_REGISTRY))
+#define MODEST_PROTOCOL_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_PROTOCOL_REGISTRY,ModestProtocolRegistryClass))
+
+/* a special type, equivalent to a NULL protocol */
+#define MODEST_PROTOCOL_REGISTRY_TYPE_INVALID -1
+
+/* The minimum priority custom protocols should take for their index */
+#define MODEST_PROTOCOL_REGISTRY_USER_PRIORITY 100
+
+/* macros to access the default configured protocols */
+#define MODEST_PROTOCOLS_TRANSPORT_SMTP (modest_protocol_registry_get_smtp_type_id())
+#define MODEST_PROTOCOLS_TRANSPORT_SENDMAIL (modest_protocol_registry_get_sendmail_type_id())
+#define MODEST_PROTOCOLS_STORE_POP (modest_protocol_registry_get_pop_type_id())
+#define MODEST_PROTOCOLS_STORE_IMAP (modest_protocol_registry_get_imap_type_id())
+#define MODEST_PROTOCOLS_STORE_MAILDIR (modest_protocol_registry_get_maildir_type_id())
+#define MODEST_PROTOCOLS_STORE_MBOX (modest_protocol_registry_get_mbox_type_id())
+#define MODEST_PROTOCOLS_CONNECTION_NONE (modest_protocol_registry_get_none_connection_type_id ())
+#define MODEST_PROTOCOLS_CONNECTION_TLS (modest_protocol_registry_get_tls_connection_type_id ())
+#define MODEST_PROTOCOLS_CONNECTION_SSL (modest_protocol_registry_get_ssl_connection_type_id ())
+#define MODEST_PROTOCOLS_CONNECTION_TLSOP (modest_protocol_registry_get_tlsop_connection_type_id ())
+#define MODEST_PROTOCOLS_AUTH_NONE (modest_protocol_registry_get_none_auth_type_id ())
+#define MODEST_PROTOCOLS_AUTH_PASSWORD (modest_protocol_registry_get_password_auth_type_id ())
+#define MODEST_PROTOCOLS_AUTH_CRAMMD5 (modest_protocol_registry_get_crammd5_auth_type_id ())
+
+/* properties available */
+#define MODEST_PROTOCOL_SECURITY_ACCOUNT_OPTION "modest-security-account-option"
+#define MODEST_PROTOCOL_AUTH_ACCOUNT_OPTION "modest-auth-account-option"
+
+/* translations */
+#define MODEST_PROTOCOL_TRANSLATION_DELETE_MAILBOX "translation-delete-mailbox" /* title string */
+#define MODEST_PROTOCOL_TRANSLATION_CONNECT_ERROR "translation-connect-error" /* server name */
+#define MODEST_PROTOCOL_TRANSLATION_AUTH_ERROR "translation-auth-error" /* server name */
+#define MODEST_PROTOCOL_TRANSLATION_ACCOUNT_CONNECTION_ERROR "translation-account-connection-error" /* hostname */
+#define MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE "translation-msg-not-available" /* subject */
+#define MODEST_PROTOCOL_TRANSLATION_SSL_PROTO_NAME "translation-ssl-proto-name"
+
+
+typedef struct _ModestProtocolRegistry ModestProtocolRegistry;
+typedef struct _ModestProtocolRegistryClass ModestProtocolRegistryClass;
+
+typedef guint ModestProtocolRegistryType;
+
+struct _ModestProtocolRegistry {
+ GObject parent;
+};
+
+struct _ModestProtocolRegistryClass {
+ GObjectClass parent_class;
+};
+
+/**
+ * modest_protocol_registry_get_type:
+ *
+ * Returns: GType of the account store
+ */
+GType modest_protocol_registry_get_type (void) G_GNUC_CONST;
+
+/**
+ * modest_protocol_registry_new:
+ *
+ * creates a new instance of #ModestProtocolRegistry
+ *
+ * Returns: a #ModestProtocolRegistry
+ */
+ModestProtocolRegistry* modest_protocol_registry_new (void);
+
+/**
+ * modest_protocol_registry_add:
+ * @self: a #ModestProtocolRegistry
+ * @protocol: a #ModestProtocol
+ * @priority: priority establishes the order the protocols will be shown on listings
+ * @first_tag: a string
+ * @...: a %NULL terminated list of strings with the tags for the protocol
+ *
+ * Add @protocol to the registry @self, setting the proper identifying tags
+ */
+void modest_protocol_registry_add (ModestProtocolRegistry *self, ModestProtocol *protocol, gint priority, const gchar *first_tag, ...);
+
+/**
+ * modest_protocol_registry_get_all:
+ * @self: a #ModestProtocolRegistry
+ *
+ * obtains a list of all protocols registered in @self
+ *
+ * Returns: a newly allocated GSList of the protocols. Don't unref the protocols, only the list.
+ */
+GSList *modest_protocol_registry_get_all (ModestProtocolRegistry *self);
+
+/**
+ * modest_protocol_registry_get_by_tag:
+ * @self: a #ModestProtocolRegistry
+ * @tag: a string
+ *
+ * obtains a list of all protocols registered in @self tagged with @tag
+ *
+ * Returns: a newly allocated GSList of the protocols. Don't unref the protocol, only the list.
+ */
+GSList *modest_protocol_registry_get_by_tag (ModestProtocolRegistry *self, const gchar *tag);
+
+/**
+ * modest_protocol_registry_get_pair_list_by_tag:
+ * @self: a #ModestProtocolRegistry
+ * @tag: a string
+ *
+ * obtains a pair list of all protocols registered in @self tagged with @tag
+ *
+ * Returns: a newly allocated #ModestPairList of the protocols. Should be freed using
+ * modest_pair_list_free ()
+ */
+ModestPairList *modest_protocol_registry_get_pair_list_by_tag (ModestProtocolRegistry *self, const gchar *tag);
+
+/**
+ * modest_protocol_registry_get_protocol_by_name:
+ * @self: a #ModestProtocolRegistry
+ * @tag: a string
+ * @name: a string
+ *
+ * Obtains the protocol in registry @self, tagged with @tag and with @name
+ *
+ * Returns: the obtained #ModestProtocol, or %NULL if not found.
+ */
+ModestProtocol *modest_protocol_registry_get_protocol_by_name (ModestProtocolRegistry *self, const gchar *tag, const gchar *name);
+
+/**
+ * modest_protocol_registry_get_protocol_by_type:
+ * @self: a #ModestProtocolRegistry
+ * @type_id: a #ModestProtocolType
+ *
+ * Obtains the protocol in registry @self, identified by @type_id
+ *
+ * Returns: the obtained #ModestProtocol, or %NULL if not found.
+ */
+ModestProtocol *modest_protocol_registry_get_protocol_by_type (ModestProtocolRegistry *self, ModestProtocolType type_id);
+
+/**
+ * modest_protocol_registry_protocol_type_has_tag:
+ * @self: a #ModestProtocolRegistry
+ * @type_id: a #ModestProtocolType
+ * @tag: a string
+ *
+ * Checks if a protocol identified with @type_id has a specific @tag.
+ *
+ * Returns: %TRUE if @type_id protocol has @tag in registry @self
+ */
+gboolean modest_protocol_registry_protocol_type_has_tag (ModestProtocolRegistry *self, ModestProtocolType type_id, const gchar *tag);
+
+#define modest_protocol_registry_protocol_type_is_secure(registry,protocol_type) \
+ modest_protocol_registry_protocol_type_has_tag ((registry), (protocol_type), \
+ MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS)
+
+#define modest_protocol_registry_protocol_type_is_provider(registry,protocol_type) \
+ modest_protocol_registry_protocol_type_has_tag ((registry), (protocol_type), \
+ MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS)
+
+#define modest_protocol_registry_protocol_type_has_leave_on_server(registry,protocol_type) \
+ modest_protocol_registry_protocol_type_has_tag ((registry), (protocol_type), \
+ MODEST_PROTOCOL_REGISTRY_HAS_LEAVE_ON_SERVER_PROTOCOLS)
+
+/**
+ * @self: a #ModestProtocolRegistry
+ *
+ * Set default available protocols in Modest in @self
+ */
+void modest_protocol_registry_set_to_default (ModestProtocolRegistry *self);
+
+ModestProtocolType modest_protocol_registry_get_imap_type_id (void);
+ModestProtocolType modest_protocol_registry_get_pop_type_id (void);
+ModestProtocolType modest_protocol_registry_get_maildir_type_id (void);
+ModestProtocolType modest_protocol_registry_get_mbox_type_id (void);
+ModestProtocolType modest_protocol_registry_get_smtp_type_id (void);
+ModestProtocolType modest_protocol_registry_get_sendmail_type_id (void);
+ModestProtocolType modest_protocol_registry_get_none_connection_type_id (void);
+ModestProtocolType modest_protocol_registry_get_tls_connection_type_id (void);
+ModestProtocolType modest_protocol_registry_get_ssl_connection_type_id (void);
+ModestProtocolType modest_protocol_registry_get_tlsop_connection_type_id (void);
+ModestProtocolType modest_protocol_registry_get_none_auth_type_id (void);
+ModestProtocolType modest_protocol_registry_get_password_auth_type_id (void);
+ModestProtocolType modest_protocol_registry_get_crammd5_auth_type_id (void);
+
+G_END_DECLS
+
+#endif /* __MODEST_PROTOCOL_REGISTRY_H__ */
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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-protocol.h>
+
+enum {
+ PROP_0,
+ PROP_NAME,
+ PROP_DISPLAY_NAME,
+ PROP_TYPE_ID
+};
+
+typedef struct _ModestProtocolTranslation ModestProtocolTranslation;
+struct _ModestProtocolTranslation {
+ TranslationFunc translation_func;
+ gpointer userdata;
+ GDestroyNotify data_destroy_func;
+};
+
+typedef struct _ModestProtocolPrivate ModestProtocolPrivate;
+struct _ModestProtocolPrivate {
+ ModestProtocolType type_id;
+ gchar *name;
+ gchar *display_name;
+ GHashTable *properties;
+ GHashTable *translations;
+};
+
+/* 'private'/'protected' functions */
+static void modest_protocol_class_init (ModestProtocolClass *klass);
+static void modest_protocol_finalize (GObject *obj);
+static void modest_protocol_get_property (GObject *obj,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void modest_protocol_set_property (GObject *obj,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void modest_protocol_instance_init (ModestProtocol *obj);
+static void translation_free (ModestProtocolTranslation *translation);
+
+#define MODEST_PROTOCOL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ MODEST_TYPE_PROTOCOL, \
+ ModestProtocolPrivate))
+
+/* globals */
+static GObjectClass *parent_class = NULL;
+static ModestProtocolType next_type_id = 0;
+static GMutex *next_type_id_mutex = NULL;
+
+GType
+modest_protocol_get_type (void)
+{
+ static GType my_type = 0;
+
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestProtocolClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_protocol_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof(ModestProtocol),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) modest_protocol_instance_init,
+ NULL
+ };
+
+ my_type = g_type_register_static (G_TYPE_OBJECT,
+ "ModestProtocol",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_protocol_class_init (ModestProtocolClass *klass)
+{
+ GObjectClass *object_class;
+ object_class = (GObjectClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ next_type_id_mutex = g_mutex_new ();
+ object_class->finalize = modest_protocol_finalize;
+ object_class->set_property = modest_protocol_set_property;
+ object_class->get_property = modest_protocol_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ _("Protocol name"),
+ _("The unique name of the protocol"),
+ NULL,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_DISPLAY_NAME,
+ g_param_spec_string ("display-name",
+ _("Display name"),
+ _("The name of the protocol that user will see"),
+ NULL,
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class,
+ PROP_TYPE_ID,
+ g_param_spec_int ("type",
+ _("Protocol id"),
+ _("Protocol type unique id"),
+ G_MININT, G_MAXINT, MODEST_PROTOCOL_TYPE_INVALID,
+ G_PARAM_READABLE));
+
+ g_type_class_add_private (object_class,
+ sizeof(ModestProtocolPrivate));
+}
+
+static void
+translation_free (ModestProtocolTranslation *translation)
+{
+ if (translation->data_destroy_func)
+ translation->data_destroy_func (translation->userdata);
+ translation->data_destroy_func = NULL;
+ translation->userdata = NULL;
+ translation->translation_func = NULL;
+ g_slice_free (ModestProtocolTranslation, translation);
+}
+
+static void
+modest_protocol_instance_init (ModestProtocol *obj)
+{
+ ModestProtocolPrivate *priv;
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (obj);
+
+ priv->name = NULL;
+ priv->display_name = NULL;
+ g_mutex_lock (next_type_id_mutex);
+ priv->type_id = next_type_id;
+ next_type_id++;
+ g_mutex_unlock (next_type_id_mutex);
+
+ priv->properties = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_free);
+ priv->translations = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, (GDestroyNotify) translation_free);
+}
+
+static void
+modest_protocol_finalize (GObject *obj)
+{
+ ModestProtocol *settings = MODEST_PROTOCOL (obj);
+ ModestProtocolPrivate *priv = MODEST_PROTOCOL_GET_PRIVATE (settings);
+
+ g_free (priv->name);
+ priv->name = NULL;
+ g_free (priv->display_name);
+ priv->display_name = NULL;
+
+ g_hash_table_destroy (priv->properties);
+ priv->properties = NULL;
+
+ g_hash_table_destroy (priv->translations);
+ priv->translations = NULL;
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+modest_protocol_get_property (GObject *obj,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ModestProtocol *protocol = MODEST_PROTOCOL (obj);
+ ModestProtocolPrivate *priv = MODEST_PROTOCOL_GET_PRIVATE (protocol);
+
+ switch (property_id) {
+ case PROP_NAME:
+ g_value_set_static_string (value, priv->name);
+ break;
+ case PROP_DISPLAY_NAME:
+ g_value_set_static_string (value, priv->name);
+ break;
+ case PROP_TYPE_ID:
+ g_value_set_int (value, priv->type_id);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
+ }
+
+}
+
+static void
+modest_protocol_set_property (GObject *obj,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ModestProtocol *protocol = MODEST_PROTOCOL (obj);
+
+ switch (property_id) {
+ case PROP_NAME:
+ modest_protocol_set_name (protocol, g_value_get_string (value));
+ break;
+ case PROP_DISPLAY_NAME:
+ modest_protocol_set_display_name (protocol, g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
+ }
+
+}
+
+
+ModestProtocol*
+modest_protocol_new (const gchar *name, const gchar *display_name)
+{
+ return g_object_new (MODEST_TYPE_PROTOCOL, "display-name", display_name, "name", name, NULL);
+}
+
+const gchar*
+modest_protocol_get_name (ModestProtocol *self)
+{
+ ModestProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL (self), NULL);
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+ return priv->name;
+}
+
+void
+modest_protocol_set_name (ModestProtocol *self,
+ const gchar *name)
+{
+ ModestProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_PROTOCOL (self));
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+ g_free (priv->name);
+ priv->name = g_strdup (name);
+}
+
+const gchar*
+modest_protocol_get_display_name (ModestProtocol *self)
+{
+ ModestProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL (self), NULL);
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+ return priv->display_name;
+}
+
+void
+modest_protocol_set_display_name (ModestProtocol *self,
+ const gchar *display_name)
+{
+ ModestProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_PROTOCOL (self));
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+ g_free (priv->display_name);
+ priv->display_name = g_strdup (display_name);
+}
+
+ModestProtocolType
+modest_protocol_get_type_id (ModestProtocol *self)
+{
+ ModestProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL (self), MODEST_PROTOCOL_TYPE_INVALID);
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+ return priv->type_id;
+}
+
+void
+modest_protocol_set (ModestProtocol *self,
+ const gchar *key,
+ const gchar *value)
+{
+ ModestProtocolPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_PROTOCOL (self));
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+
+ g_hash_table_replace (priv->properties,g_strdup (key), g_strdup (value));
+}
+
+const gchar *
+modest_protocol_get (ModestProtocol *self,
+ const gchar *key)
+{
+ ModestProtocolPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL (self), NULL);
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+
+ return g_hash_table_lookup (priv->properties, key);
+}
+
+void
+modest_protocol_set_translation (ModestProtocol *self,
+ const gchar *id,
+ TranslationFunc translation_func,
+ gpointer userdata,
+ GDestroyNotify data_destroy_func)
+{
+ ModestProtocolPrivate *priv;
+ ModestProtocolTranslation *translation;
+
+ g_return_if_fail (MODEST_IS_PROTOCOL (self));
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+
+ translation = g_slice_new0 (ModestProtocolTranslation);
+ translation->translation_func = translation_func;
+ translation->userdata = userdata;
+ translation->data_destroy_func = data_destroy_func;
+
+ g_hash_table_replace (priv->translations, (gpointer) id, (gpointer) translation);
+}
+
+gchar *
+modest_protocol_get_translation (ModestProtocol *self,
+ const gchar *id,
+ ...)
+{
+ ModestProtocolPrivate *priv;
+ ModestProtocolTranslation *translation;
+ va_list orig, dest;
+ gchar *result;
+
+ g_return_val_if_fail (MODEST_IS_PROTOCOL (self), NULL);
+
+ priv = MODEST_PROTOCOL_GET_PRIVATE (self);
+
+ translation = g_hash_table_lookup (priv->translations, id);
+ if (translation == NULL)
+ return NULL;
+ g_return_val_if_fail (translation->translation_func != NULL, NULL);
+
+ va_start (orig, id);
+ G_VA_COPY (dest, orig);
+ result = translation->translation_func (translation->userdata, dest);
+ va_end (orig);
+
+ return result;
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+
+/* modest-account-settings.h */
+
+#ifndef __MODEST_PROTOCOL_H__
+#define __MODEST_PROTOCOL_H__
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_PROTOCOL (modest_protocol_get_type())
+#define MODEST_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_PROTOCOL,ModestProtocol))
+#define MODEST_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_PROTOCOL,ModestProtocolClass))
+#define MODEST_IS_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_PROTOCOL))
+#define MODEST_IS_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_PROTOCOL))
+#define MODEST_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_PROTOCOL,ModestProtocolClass))
+
+#define MODEST_PROTOCOL_TYPE_INVALID -1
+
+typedef gchar * (*TranslationFunc) (gpointer userdata, ...);
+
+typedef struct _ModestProtocol ModestProtocol;
+typedef struct _ModestProtocolClass ModestProtocolClass;
+
+typedef guint ModestProtocolType;
+
+struct _ModestProtocol {
+ GObject parent;
+};
+
+struct _ModestProtocolClass {
+ GObjectClass parent_class;
+};
+
+/**
+ * modest_protocol_get_type:
+ *
+ * Returns: GType of the account store
+ */
+GType modest_protocol_get_type (void) G_GNUC_CONST;
+
+/**
+ * modest_protocol_new:
+ *
+ * creates a new instance of #ModestProtocol
+ *
+ * Returns: a #ModestProtocol
+ */
+ModestProtocol* modest_protocol_new (const gchar *name, const gchar *display_name);
+
+/**
+ * modest_protocol_get_name:
+ * @self: a #ModestProtocol
+ *
+ * get the protocol unique name (used for storing conf and identifying the protocol with a string)
+ *
+ * Returns: a string
+ */
+const gchar* modest_protocol_get_name (ModestProtocol *self);
+
+/**
+ * modest_protocol_set_name:
+ * @self: a #ModestProtocol
+ * @name: the protocol unique name.
+ *
+ * set @name as the protocol unique name .
+ */
+void modest_protocol_set_name (ModestProtocol *self,
+ const gchar *name);
+/**
+ * modest_protocol_get_display_name:
+ * @self: a #ModestProtocol
+ *
+ * get the display name for the protocol
+ *
+ * Returns: a string
+ */
+const gchar* modest_protocol_get_display_name (ModestProtocol *self);
+
+/**
+ * modest_protocol_set_display_name:
+ * @settings: a #ModestProtocol
+ * @display_name: a string.
+ *
+ * set @display_name of the account.
+ */
+void modest_protocol_set_display_name (ModestProtocol *protocol,
+ const gchar *display_name);
+/**
+ * modest_protocol_get_type_id:
+ * @self: a #ModestProtocol
+ *
+ * get the protocol type id.
+ *
+ * Returns: a #ModestProtocolType
+ */
+ModestProtocolType modest_protocol_get_type_id (ModestProtocol *self);
+
+/**
+ * modest_protocol_get:
+ * @protocol: a #ModestProtocol
+ * @key: a string
+ *
+ * obtains the value of @key for @protocol
+ *
+ * Returns: a string
+ */
+const gchar *
+modest_protocol_get (ModestProtocol *protocol,
+ const gchar *key);
+
+/**
+ * modest_protocol_set:
+ * @protocol: a #ModestProtocol
+ * @key: a string
+ * @value: a string
+ *
+ * sets @value as the value for @key in @protocol
+ */
+void
+modest_protocol_set (ModestProtocol *protocol,
+ const gchar *key, const gchar *value);
+
+/**
+ * modest_protocol_set_translation:
+ * @protocol: a #ModestProtocol
+ * @id: the id for the translation set
+ * @translation_func: the function used to obtain the translation
+ *
+ * sets @translation_func as the way to compose the translation for @id
+ */
+void
+modest_protocol_set_translation (ModestProtocol *protocol,
+ const gchar *id,
+ TranslationFunc translation_func,
+ gpointer userdata,
+ GDestroyNotify data_destroy_func);
+
+/**
+ * modest_protocol_get_translation:
+ * @protocol: a @ModestProtocol
+ * @id: the id for the translation set
+ * @...: the parameters for the translation (pritntf style)
+ *
+ * applies the translation with parameters to obtain the full string expected.
+ *
+ * Returns: a newly allocated string
+ */
+gchar *
+modest_protocol_get_translation (ModestProtocol *protocol,
+ const gchar *id,
+ ...);
+
+G_END_DECLS
+
+#endif /* __MODEST_PROTOCOL_H__ */
return modest_singletons_get_window_mgr (_singletons);
}
+ModestPluginFactory *
+modest_runtime_get_plugin_factory (void)
+{
+ g_return_val_if_fail (_singletons, NULL);
+ return modest_singletons_get_plugin_factory (_singletons);
+}
+
+ModestProtocolRegistry *
+modest_runtime_get_protocol_registry (void)
+{
+ g_return_val_if_fail (_singletons, NULL);
+ return modest_singletons_get_protocol_registry (_singletons);
+}
+
/* http://primates.ximian.com/~federico/news-2006-04.html#memory-debugging-infrastructure*/
ModestRuntimeDebugFlags
modest_runtime_get_debug_flags ()
#include <modest-signal-mgr.h>
#include <tny-platform-factory.h>
#include "widgets/modest-window-mgr.h"
+<<<<<<< .working
#include <tny-stream-cache.h>
+=======
+#include <modest-protocol-registry.h>
+#include <tny-stream-cache.h>
+#include <modest-plugin-factory.h>
+>>>>>>> .merge-right.r5668
G_BEGIN_DECLS
**/
ModestWindowMgr* modest_runtime_get_window_mgr (void);
+/**
+ * modest_runtime_get_protocol_registry:
+ *
+ * get the #ModestProtocolRegistry singleton instance
+ *
+ * Returns: the #ModestProtocolRegistry singleton. This should NOT be unref'd.
+ **/
+ModestProtocolRegistry* modest_runtime_get_protocol_registry (void);
+
+/**
+ * modest_runtime_get_plugin_factory:
+ *
+ * get the #ModestPluginFactory singleton instance
+ *
+ * Returns: the #ModestPluginFactory singleton. This should NOT be unref'd.
+ **/
+ModestPluginFactory * modest_runtime_get_plugin_factory (void);
+
G_END_DECLS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <modest-protocol-registry.h>
#include <modest-server-account-settings.h>
/* 'private'/'protected' functions */
struct _ModestServerAccountSettingsPrivate {
gchar *hostname;
guint port;
- ModestTransportStoreProtocol protocol;
+ ModestProtocolType protocol;
gchar *username;
gchar *password;
- ModestConnectionProtocol security;
- ModestAuthProtocol auth_protocol;
+ ModestProtocolType security_protocol;
+ ModestProtocolType auth_protocol;
gchar *account_name;
gchar *uri;
};
priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (obj);
priv->hostname = NULL;
- priv->protocol = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+ priv->protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
priv->port = 0;
priv->username = NULL;
priv->password = NULL;
- priv->security = MODEST_PROTOCOL_CONNECTION_NORMAL;
- priv->auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
+ priv->security_protocol = MODEST_PROTOCOLS_CONNECTION_NONE;
+ priv->auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
priv->account_name = NULL;
priv->uri = NULL;
}
priv->username = NULL;
g_free (priv->password);
priv->password = NULL;
- priv->protocol = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+ priv->protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
priv->port = 0;
- priv->security = MODEST_PROTOCOL_CONNECTION_NORMAL;
- priv->auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
+ priv->security_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+ priv->auth_protocol = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
g_free (priv->account_name);
priv->account_name = NULL;
g_free (priv->uri);
g_free (priv->uri);
priv->uri = g_strdup (uri);
- /* we set the protocol to a NULL equivalent value. We should use uri in case
- * protocol has this value. */
- priv->protocol = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
}
const gchar*
priv->account_name = g_strdup (account_name);
}
-ModestTransportStoreProtocol
+ModestProtocolType
modest_server_account_settings_get_protocol (ModestServerAccountSettings *settings)
{
ModestServerAccountSettingsPrivate *priv;
- g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN);
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_REGISTRY_TYPE_INVALID);
priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
return priv->protocol;
void
modest_server_account_settings_set_protocol (ModestServerAccountSettings *settings,
- ModestTransportStoreProtocol protocol)
+ ModestProtocolType protocol)
{
ModestServerAccountSettingsPrivate *priv;
priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
priv->protocol = protocol;
- /* we also set the uri to NULL, as setting a protocol implies disabling uri setting type */
- g_free (priv->uri);
- priv->uri = NULL;
}
guint
priv->port = port;
}
-ModestConnectionProtocol
-modest_server_account_settings_get_security (ModestServerAccountSettings *settings)
+ModestProtocolType
+modest_server_account_settings_get_security_protocol (ModestServerAccountSettings *settings)
{
ModestServerAccountSettingsPrivate *priv;
- g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_CONNECTION_NORMAL);
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_REGISTRY_TYPE_INVALID);
priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
- return priv->security;
+ return priv->security_protocol;
}
void
-modest_server_account_settings_set_security (ModestServerAccountSettings *settings,
- ModestConnectionProtocol security)
+modest_server_account_settings_set_security_protocol (ModestServerAccountSettings *settings,
+ ModestProtocolType security_protocol)
{
ModestServerAccountSettingsPrivate *priv;
g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
- priv->security = security;
+ priv->security_protocol = security_protocol;
}
-ModestAuthProtocol
+ModestProtocolType
modest_server_account_settings_get_auth_protocol (ModestServerAccountSettings *settings)
{
ModestServerAccountSettingsPrivate *priv;
- g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_AUTH_NONE);
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_REGISTRY_TYPE_INVALID);
priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
return priv->auth_protocol;
void
modest_server_account_settings_set_auth_protocol (ModestServerAccountSettings *settings,
- ModestAuthProtocol auth_protocol)
+ ModestProtocolType auth_protocol)
{
ModestServerAccountSettingsPrivate *priv;
#define __MODEST_SERVER_ACCOUNT_SETTINGS_H__
#include <glib-object.h>
-#include <modest-defs.h>
-#include <modest-protocol-info.h>
+#include <modest-protocol.h>
G_BEGIN_DECLS
*
* get the server protocol.
*
- * Returns: a #ModestTransportStoreProtocol
+ * Returns: a #ModestProtocolType
*/
-ModestTransportStoreProtocol modest_server_account_settings_get_protocol (ModestServerAccountSettings *settings);
+ModestProtocolType modest_server_account_settings_get_protocol (ModestServerAccountSettings *settings);
/**
* modest_server_account_settings_set_protocol:
* @settings: a #ModestServerAccountSettings
- * @protocol: a #ModestTransportStoreProtocol.
+ * @protocol: a #ModestProtocolType
*
* set @server_type.
*/
void modest_server_account_settings_set_protocol (ModestServerAccountSettings *settings,
- ModestTransportStoreProtocol protocol);
+ ModestProtocolType protocol_type);
/**
* @settings: a #ModestServerAccountSettings
* @uri: a string
*
- * set @uri. When you set an @uri, then the protocol is set to %NULL. This is used for setting maildir or mbox
+ * set @uri. When you set an @uri, then the protocol is set to %MODEST_PROTOCOL_REGISTRY_TYPE_INVALID. This is used for setting maildir or mbox
* accounts.
*/
void modest_server_account_settings_set_uri (ModestServerAccountSettings *settings,
/**
- * modest_server_account_settings_get_security:
+ * modest_server_account_settings_get_security_protocol:
* @settings: a #ModestServerAccountSettings
*
* get the secure connection type, if any.
*
- * Returns: a #ModestConnectionProtocol
+ * Returns: a #ModestProtocolType
*/
-ModestConnectionProtocol modest_server_account_settings_get_security (ModestServerAccountSettings *settings);
+ModestProtocolType modest_server_account_settings_get_security_protocol (ModestServerAccountSettings *settings);
/**
- * modest_server_account_settings_set_security:
+ * modest_server_account_settings_set_security_protocol:
* @settings: a #ModestServerAccountSettings
- * @security: a #ModestConnectionProtocol
+ * @security: a #ModestProtocolType
*
* set the current security connection protocol to @security.
*/
-void modest_server_account_settings_set_security (ModestServerAccountSettings *settings,
- ModestConnectionProtocol security);
+void modest_server_account_settings_set_security_protocol (ModestServerAccountSettings *settings,
+ ModestProtocolType security_protocol);
/**
*
* get the authentication protocol
*
- * Returns: a #ModestAuthProtocol
+ * Returns: a #ModestProtocolType
*/
-ModestAuthProtocol modest_server_account_settings_get_auth_protocol (ModestServerAccountSettings *settings);
+ModestProtocolType modest_server_account_settings_get_auth_protocol (ModestServerAccountSettings *settings);
/**
* modest_server_account_settings_set_auth_protocol:
* @settings: a #ModestServerAccountSettings
- * @auth_protocol: a #ModestAuthProtocol
+ * @auth_protocol: a #ModestProtocolType
*
* set the current authentication protocol to @auth_protocol.
*/
void modest_server_account_settings_set_auth_protocol (ModestServerAccountSettings *settings,
- ModestAuthProtocol auth_protocol);
+ ModestProtocolType auth_protocol);
/**
* modest_server_account_settings_get_account_name:
#include "modest-singletons.h"
#include "modest-runtime.h"
+#include "modest-defs.h"
#include "modest-debug.h"
#include <tny-fs-stream-cache.h>
TnyPlatformFactory *platform_fact;
TnyDevice *device;
ModestWindowMgr *window_mgr;
+<<<<<<< .working
TnyStreamCache *images_cache;
+=======
+ ModestProtocolRegistry *protocol_registry;
+ ModestPluginFactory *plugin_factory;
+ TnyStreamCache *images_cache;
+>>>>>>> .merge-right.r5668
};
#define MODEST_SINGLETONS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_SINGLETONS, \
priv->platform_fact = NULL;
priv->device = NULL;
priv->window_mgr = NULL;
+<<<<<<< .working
+ priv->images_cache = NULL;
+=======
+ priv->protocol_registry = NULL;
+ priv->plugin_factory = NULL;
+
+ priv->protocol_registry = modest_protocol_registry_new ();
+ if (!priv->protocol_registry) {
+ g_printerr ("modest:cannot create protocol registry instance\n");
+ return;
+ }
+ modest_protocol_registry_set_to_default (priv->protocol_registry);
priv->images_cache = NULL;
+>>>>>>> .merge-right.r5668
priv->conf = modest_conf_new ();
if (!priv->conf) {
g_printerr ("modest: cannot create modest window manager instance\n");
return;
}
+<<<<<<< .working
images_cache_path = g_build_filename (g_get_home_dir (), MODEST_DIR, MODEST_IMAGES_CACHE_DIR, NULL);
priv->images_cache = tny_fs_stream_cache_new (images_cache_path, MODEST_IMAGES_CACHE_SIZE);
g_printerr ("modest: cannot create images cache instance\n");
return;
}
+=======
+
+ priv->plugin_factory = modest_plugin_factory_new ();
+ if (!priv->plugin_factory) {
+ g_printerr ("modest: cannot create modest mail plugin factory instance\n");
+ return;
+ }
+
+ images_cache_path = g_build_filename (g_get_home_dir (), MODEST_DIR, MODEST_IMAGES_CACHE_DIR, NULL);
+ priv->images_cache = tny_fs_stream_cache_new (images_cache_path, MODEST_IMAGES_CACHE_SIZE);
+ g_free (images_cache_path);
+ if (!priv->images_cache) {
+ g_printerr ("modest: cannot create images cache instance\n");
+ return;
+ }
+
+>>>>>>> .merge-right.r5668
}
static void
/* widget_factory will still be NULL, as it is initialized lazily */
if (!(priv->conf && priv->account_mgr && priv->email_clipboard &&
- priv->cache_mgr && priv->mail_op_queue && priv->device && priv->platform_fact)) {
+ priv->cache_mgr && priv->mail_op_queue && priv->device &&
+ priv->platform_fact && priv->plugin_factory)) {
g_printerr ("modest: failed to create singletons object\n");
g_object_unref (G_OBJECT(self));
self = NULL;
g_return_val_if_fail (self, NULL);
return MODEST_SINGLETONS_GET_PRIVATE(self)->window_mgr;
}
+<<<<<<< .working
TnyStreamCache*
modest_singletons_get_images_cache (ModestSingletons *self)
g_return_val_if_fail (self, NULL);
return MODEST_SINGLETONS_GET_PRIVATE(self)->images_cache;
}
+=======
+
+ModestProtocolRegistry*
+modest_singletons_get_protocol_registry (ModestSingletons *self)
+{
+ g_return_val_if_fail (self, NULL);
+ return MODEST_SINGLETONS_GET_PRIVATE(self)->protocol_registry;
+}
+
+TnyStreamCache*
+modest_singletons_get_images_cache (ModestSingletons *self)
+{
+ g_return_val_if_fail (self, NULL);
+ return MODEST_SINGLETONS_GET_PRIVATE(self)->images_cache;
+}
+
+ModestPluginFactory *
+modest_singletons_get_plugin_factory (ModestSingletons *self)
+{
+ g_return_val_if_fail (self, NULL);
+
+ return MODEST_SINGLETONS_GET_PRIVATE (self)->plugin_factory;
+}
+>>>>>>> .merge-right.r5668
#include <modest-mail-operation-queue.h>
#include <modest-cache-mgr.h>
#include <modest-tny-platform-factory.h>
+#include "modest-plugin-factory.h"
#include "widgets/modest-window-mgr.h"
+<<<<<<< .working
#include <tny-stream-cache.h>
+=======
+#include "modest-protocol-registry.h"
+#include <tny-stream-cache.h>
+>>>>>>> .merge-right.r5668
G_BEGIN_DECLS
**/
ModestWindowMgr* modest_singletons_get_window_mgr (ModestSingletons *self);
+<<<<<<< .working
/**
* modest_singletons_get_images_cache:
* @self: a #ModestSingletons
*/
TnyStreamCache* modest_singletons_get_images_cache (ModestSingletons *self);
+=======
+/**
+ * modest_singletons_get_protocol_registry:
+ * @self:
+ *
+ * Gets the #ModestProtocolRegistry singleton instance. Don't use this
+ * function directly, use the modest-runtime function instead.
+ *
+ * Return value: the singleton instance of #ModestProtocolRegistry
+ **/
+ModestProtocolRegistry* modest_singletons_get_protocol_registry (ModestSingletons *self);
+
+/**
+ * modest_singletons_get_images_cache:
+ * @self: a #ModestSingletons
+ *
+ * Gets the #TnyStreamCache used to store the external images cache.
+ */
+TnyStreamCache* modest_singletons_get_images_cache (ModestSingletons *self);
+
+/**
+ * modest_singletons_get_plugin_factory:
+ * @self: a #ModestSingletons
+ *
+ * Gets the #ModestMailPluginFactory singleton.
+ */
+ModestPluginFactory* modest_singletons_get_plugin_factory (ModestSingletons *self);
+
+>>>>>>> .merge-right.r5668
G_END_DECLS
#endif /* __MODEST_SINGLETONS_H__ */
#include <modest-runtime.h>
#include <modest-marshal.h>
-#include <modest-protocol-info.h>
+#include <modest-protocol-registry.h>
#include <modest-local-folder-info.h>
+#include "modest-account-protocol.h"
#include <modest-tny-account.h>
#include <modest-tny-local-folders-account.h>
#include <modest-account-mgr.h>
#include <modest-signal-mgr.h>
#include <modest-debug.h>
+#include <modest-defs.h>
#include "modest-tny-account-store.h"
#include "modest-tny-platform-factory.h"
#include <tny-gtk-lockable.h>
struct _ModestTnyAccountStorePrivate {
gchar *cache_dir;
GHashTable *password_hash;
- GHashTable *account_settings_dialog_hash;
ModestAccountMgr *account_mgr;
TnySessionCamel *session;
TnyDevice *device;
priv->password_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_free);
- /* A hash-map of modest account names to dialog pointers,
- * so we can avoid showing the account settings twice for the same modest account: */
- priv->account_settings_dialog_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
-
/* Respond to volume mounts and unmounts, such
* as the insertion/removal of the memory card: */
/* This is a singleton, so it does not need to be unrefed. */
}
static void
-on_account_settings_hide (GtkWidget *widget, gpointer user_data)
-{
- /* This is easier than using a struct for the user_data: */
- ModestTnyAccountStore *self = modest_runtime_get_account_store();
- ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
-
- gchar *account_name = (gchar *) user_data;
- if (account_name)
- g_hash_table_remove (priv->account_settings_dialog_hash, account_name);
-}
-
-static void
show_password_warning_only (const gchar *msg)
{
ModestWindow *main_window =
static void
show_wrong_password_dialog (TnyAccount *account)
{
+<<<<<<< .working
/* This is easier than using a struct for the user_data: */
ModestTnyAccountStore *self = modest_runtime_get_account_store();
GtkWidget *dialog = NULL;
+=======
+>>>>>>> .merge-right.r5668
if (g_object_get_data (G_OBJECT (account), "connection_specific") != NULL) {
modest_ui_actions_on_smtp_servers (NULL, NULL);
} else {
+ ModestAccountProtocol *proto;
+ ModestProtocolType proto_type;
const gchar *modest_account_name;
- modest_account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
- dialog = modest_tny_account_store_show_account_settings_dialog (self, modest_account_name);
+ modest_account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+
+ /* Get proto */
+ proto_type = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
+ modest_account_name);
+ proto = (ModestAccountProtocol *)
+ modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+ proto_type);
+
+ /* Create and show the dialog */
+ if (proto && MODEST_IS_ACCOUNT_PROTOCOL (proto)) {
+ ModestAccountSettingsDialog *dialog =
+ modest_account_protocol_get_account_settings_dialog (proto, modest_account_name);
+ gtk_widget_show (GTK_WIDGET (dialog));
+ }
}
/* Show an explanatory temporary banner: */
- modest_platform_information_banner (dialog, NULL, _("mcen_ib_username_pw_incorrect"));
+ modest_platform_information_banner (NULL, NULL, _("mcen_ib_username_pw_incorrect"));
}
/* This callback will be called by Tinymail when it needs the password
/* If it was already asked, it must have been wrong, so ask again */
if (already_asked || !pwd || strlen(pwd) == 0) {
+ gboolean settings_have_password;
+ ModestProtocolType protocol_type;
+
/* As per the UI spec, if no password was set in the account settings,
* ask for it now. But if the password is wrong in the account settings,
* then show a banner and the account settings dialog so it can be corrected:
*/
- ModestTransportStoreProtocol proto;
- const gboolean settings_have_password =
+ settings_have_password =
modest_account_mgr_get_server_account_has_password (priv->account_mgr, server_account_name);
+ protocol_type = modest_tny_account_get_protocol_type (account);
+
/* Show an error and after that ask for a password */
- proto = modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (account));
- if (proto == MODEST_PROTOCOL_TRANSPORT_SMTP) {
+ if (modest_protocol_registry_protocol_type_has_tag(modest_runtime_get_protocol_registry (),
+ protocol_type, MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS)) {
gchar *username = NULL, *msg = NULL;
username = modest_account_mgr_get_server_account_username (priv->account_mgr,
server_account_name);
priv->password_hash = NULL;
}
- if (priv->account_settings_dialog_hash) {
- g_hash_table_destroy (priv->account_settings_dialog_hash);
- priv->account_settings_dialog_hash = NULL;
- }
-
if (priv->outbox_of_transport) {
g_hash_table_destroy (priv->outbox_of_transport);
priv->outbox_of_transport = NULL;
gboolean question,
GError *error)
{
- ModestTransportStoreProtocol proto =
- MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+ ModestProtocolType protocol_type = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+ ModestProtocol *protocol;
const gchar* server_name = "";
gchar *prompt = NULL;
gboolean retval = TRUE;
/* Get the server name: */
if (account) {
server_name = tny_account_get_hostname (account);
- const gchar *proto_name = tny_account_get_proto (account);
- if (proto_name)
- proto = modest_protocol_info_get_transport_store_protocol (proto_name);
- else {
+ protocol_type = modest_tny_account_get_protocol_type (account);
+ if (protocol_type == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID){
g_warning("modest: %s: account with id=%s has no proto.\n", __FUNCTION__,
tny_account_get_id (account));
return FALSE;
}
+ protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+ protocol_type);
}
switch (error->code) {
case TNY_SERVICE_ERROR_UNAVAILABLE:
/* You must be working online for this operation */
case TNY_SERVICE_ERROR_CONNECT:
- switch (proto) {
- case MODEST_PROTOCOL_STORE_POP:
- prompt = g_strdup_printf (_("emev_ni_ui_pop3_msg_connect_error"),
- server_name);
- break;
- case MODEST_PROTOCOL_STORE_IMAP:
- prompt = g_strdup_printf (_("emev_ni_ui_imap_connect_server_error"),
- server_name);
- break;
- case MODEST_PROTOCOL_TRANSPORT_SMTP:
- prompt = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"),
- server_name);
- break;
- default:
+ prompt = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_CONNECT_ERROR, server_name);
+ if (!prompt) {
g_return_val_if_reached (FALSE);
}
break;
/* It seems that there's no better error to show with
* POP and IMAP because TNY_SERVICE_ERROR_AUTHENTICATE
* may appear if there's a timeout during auth */
- switch (proto) {
- case MODEST_PROTOCOL_STORE_POP:
- prompt = g_strdup_printf (_("emev_ni_ui_pop3_msg_connect_error"),
- server_name);
- break;
- case MODEST_PROTOCOL_STORE_IMAP:
- prompt = g_strdup_printf (_("emev_ni_ui_imap_connect_server_error"),
- server_name);
- break;
- case MODEST_PROTOCOL_TRANSPORT_SMTP:
- prompt = g_strdup_printf (_("emev_ni_ui_smtp_authentication_fail_error"),
- server_name);
- break;
- default:
+ prompt = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_AUTH_ERROR, server_name);
+ if (!prompt) {
g_return_val_if_reached (FALSE);
}
break;
return header_acc;
}
-GtkWidget *
-modest_tny_account_store_show_account_settings_dialog (ModestTnyAccountStore *self,
- const gchar *account_name)
-{
- ModestTnyAccountStorePrivate *priv;
- gpointer dialog_as_gpointer = NULL;
- gboolean found;
-
- priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- found = g_hash_table_lookup_extended (priv->account_settings_dialog_hash,
- account_name, NULL, (gpointer*)&dialog_as_gpointer);
-
- if (found) {
- modest_account_settings_dialog_check_allow_changes ((ModestAccountSettingsDialog *) dialog_as_gpointer);
- return (GtkWidget *) dialog_as_gpointer;
- } else {
- ModestAccountSettings *settings;
- GtkWidget *dialog;
- dialog = (GtkWidget *) modest_account_settings_dialog_new ();
- settings = modest_account_mgr_load_account_settings (priv->account_mgr, account_name);
- modest_account_settings_dialog_set_account (MODEST_ACCOUNT_SETTINGS_DIALOG (dialog), settings);
- g_object_unref (settings);
- modest_account_settings_dialog_switch_to_user_info (MODEST_ACCOUNT_SETTINGS_DIALOG (dialog));
- modest_account_settings_dialog_check_allow_changes (MODEST_ACCOUNT_SETTINGS_DIALOG (dialog));
- modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog));
-
- g_hash_table_insert (priv->account_settings_dialog_hash, g_strdup (account_name), dialog);
-
- g_signal_connect (G_OBJECT (dialog), "hide", G_CALLBACK (on_account_settings_hide),
- g_strdup (account_name));
-
- /* Show it and delete it when it closes: */
- g_signal_connect_swapped (dialog,
- "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
- gtk_widget_show (GTK_WIDGET (dialog));
-
- return dialog;
- }
-
-}
-
typedef struct {
ModestTnyAccountStore *account_store;
ModestTnyAccountStoreShutdownCallback callback;
#define __MODEST_TNY_ACCOUNT_STORE_H__
#include <glib-object.h>
-#include <modest-defs.h>
#include <tny-account-store.h>
#include <tny-session-camel.h>
#include <tny-shared.h>
TnyTransportAccount * modest_tny_account_store_new_connection_specific_transport_account (ModestTnyAccountStore *self,
const gchar *name);
-/**
- * modest_tny_account_store_show_account_settings_dialog:
- * @self: a #ModestTnyAccountStore
- * @account_name: a string
- *
- * obtains (if already created) or creates (and shows) the settings dialog for
- * @account_name
- *
- * Returns: a #ModesAccountSettingsDialog
- */
-GtkWidget *modest_tny_account_store_show_account_settings_dialog (ModestTnyAccountStore *self,
- const gchar *account_name);
-
typedef void (*ModestTnyAccountStoreShutdownCallback) (ModestTnyAccountStore *account_store, gpointer userdata);
/**
#include <tny-camel-transport-account.h>
#include <tny-camel-imap-store-account.h>
#include <tny-camel-pop-store-account.h>
+#include <modest-account-protocol.h>
#include <tny-folder-stats.h>
#include <tny-merge-folder.h>
#include <modest-debug.h>
ModestServerAccountSettings *server_settings)
{
TnyAccount *tny_account = NULL;
- ModestTransportStoreProtocol protocol;
- const gchar* proto_name;
+ ModestProtocolType protocol_type;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (server_settings, NULL);
- protocol = modest_server_account_settings_get_protocol (server_settings);
- g_return_val_if_fail (protocol != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN, NULL);
+ protocol_type = modest_server_account_settings_get_protocol (server_settings);
+ g_return_val_if_fail (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID, NULL);
- switch (protocol) {
- case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
- case MODEST_PROTOCOL_TRANSPORT_SMTP:
- tny_account = TNY_ACCOUNT (modest_transport_account_decorator_new ()); break;
- case MODEST_PROTOCOL_STORE_POP:
- tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
- case MODEST_PROTOCOL_STORE_IMAP:
- tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
- case MODEST_PROTOCOL_STORE_MAILDIR:
- case MODEST_PROTOCOL_STORE_MBOX:
- /* Note that this is not where we create the special local folders account.
- * That happens in modest_tny_account_new_for_local_folders() instead.
- */
- tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
- default:
- g_return_val_if_reached (NULL);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
+
+ if (MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
+ ModestAccountProtocol *acocunt_proto = MODEST_ACCOUNT_PROTOCOL (protocol);
+ tny_account = modest_account_protocol_create_account (acocunt_proto);
}
if (!tny_account) {
tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (tny_account), session);
/* Proto */
- proto_name = modest_protocol_info_get_transport_store_protocol_name(protocol);
- tny_account_set_proto (tny_account, proto_name);
+ tny_account_set_proto (tny_account, modest_protocol_get_name (protocol));
return tny_account;
}
/* Camel options: */
-/* These seem to be listed in
- * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store.c
- */
#define MODEST_ACCOUNT_OPTION_SSL "use_ssl"
-#define MODEST_ACCOUNT_OPTION_SSL_NEVER "never"
-/* This is a tinymail camel-lite specific option,
- * roughly equivalent to "always" in regular camel,
- * which is appropriate for a generic "SSL" connection option: */
-#define MODEST_ACCOUNT_OPTION_SSL_WRAPPED "wrapped"
-/* Not used in our UI so far: */
-#define MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE "when-possible"
-/* This is a tinymailcamel-lite specific option that is not in regular camel. */
-#define MODEST_ACCOUNT_OPTION_SSL_TLS "tls"
-
-/* These seem to be listed in
- * libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-provider.c
- */
-#define MODEST_ACCOUNT_OPTION_USE_LSUB "use_lsub" /* Show only subscribed folders */
-#define MODEST_ACCOUNT_OPTION_CHECK_ALL "check_all" /* Check for new messages in all folders */
-
-/* Posssible values for tny_account_set_secure_auth_mech().
- * These might be camel-specific.
- * Really, tinymail should use an enum.
- * camel_sasl_authtype() seems to list some possible values.
- */
-
-/* Note that evolution does not offer these for IMAP: */
-#define MODEST_ACCOUNT_AUTH_PLAIN "PLAIN"
-#define MODEST_ACCOUNT_AUTH_ANONYMOUS "ANONYMOUS"
-/* Caeml's IMAP uses NULL instead for "Password".
- * Also, not that Evolution offers "Password" for IMAP, but "Login" for SMTP.*/
-#define MODEST_ACCOUNT_AUTH_PASSWORD "LOGIN"
-#define MODEST_ACCOUNT_AUTH_CRAMMD5 "CRAM-MD5"
/**
/* Enable secure connection settings: */
TnyPair *option_security = NULL;
const gchar* auth_mech_name = NULL;
- ModestTransportStoreProtocol protocol;
- ModestConnectionProtocol security;
- ModestAuthProtocol auth_protocol;
+ ModestProtocolType protocol_type;
+ ModestProtocol *protocol;
+ ModestProtocolType security_type;
+ ModestProtocol *security;
+ ModestProtocolType auth_protocol_type;
+ ModestProtocol *auth_protocol;
+ ModestProtocolRegistry *protocol_registry;
+ const gchar *security_option_string;
const gchar *username;
const gchar *hostname;
guint port;
/* First of all delete old options */
tny_camel_account_clear_options (TNY_CAMEL_ACCOUNT (tny_account));
- protocol = modest_server_account_settings_get_protocol (server_settings);
- security = modest_server_account_settings_get_security (server_settings);
- auth_protocol = modest_server_account_settings_get_auth_protocol (server_settings);
-
- switch (security) {
- case MODEST_PROTOCOL_CONNECTION_NORMAL:
- option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL,MODEST_ACCOUNT_OPTION_SSL_NEVER);
- break;
- case MODEST_PROTOCOL_CONNECTION_SSL:
- /* Apparently, use of "IMAPS" (specified in our UI spec), implies
- * use of the "wrapped" option: */
- option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL,MODEST_ACCOUNT_OPTION_SSL_WRAPPED);
- break;
- case MODEST_PROTOCOL_CONNECTION_TLS:
- option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL,MODEST_ACCOUNT_OPTION_SSL_TLS);
- break;
- case MODEST_PROTOCOL_CONNECTION_TLS_OP:
- /* This is not actually in our UI: */
- option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL,MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE);
- break;
- default:
- break;
- }
-
- if(option_security) {
- tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
- option_security);
+ protocol_type = modest_server_account_settings_get_protocol (server_settings);
+ security_type = modest_server_account_settings_get_security_protocol (server_settings);
+ auth_protocol_type = modest_server_account_settings_get_auth_protocol (server_settings);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
+ security = modest_protocol_registry_get_protocol_by_type (protocol_registry, security_type);
+ auth_protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, auth_protocol_type);
+
+ security_option_string = modest_protocol_get (security, MODEST_PROTOCOL_SECURITY_ACCOUNT_OPTION);
+ if (security_option_string) {
+ option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL, security_option_string);
+ tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account), option_security);
g_object_unref (option_security);
}
-
+
/* Secure authentication: */
- switch (auth_protocol) {
- case MODEST_PROTOCOL_AUTH_NONE:
- /* IMAP and POP need at least a password,
- * which camel uses if we specify NULL.
- * This setting should never happen anyway. */
- if (protocol == MODEST_PROTOCOL_STORE_IMAP ||
- protocol == MODEST_PROTOCOL_STORE_POP)
- auth_mech_name = NULL;
- else
- auth_mech_name = MODEST_ACCOUNT_AUTH_PLAIN;
- break;
-
- case MODEST_PROTOCOL_AUTH_PASSWORD:
- /* Camel use a password for IMAP or POP if we specify NULL,
- * For IMAP, at least it will report an error if we use "Password", "Login" or "Plain".
- * (POP is know to report an error for Login too. Probably Password and Plain too.) */
- if (protocol == MODEST_PROTOCOL_STORE_IMAP)
- auth_mech_name = NULL;
- else if (protocol == MODEST_PROTOCOL_STORE_POP)
- auth_mech_name = NULL;
- else
- auth_mech_name = MODEST_ACCOUNT_AUTH_PASSWORD;
- break;
-
- case MODEST_PROTOCOL_AUTH_CRAMMD5:
- auth_mech_name = MODEST_ACCOUNT_AUTH_CRAMMD5;
- break;
-
- default:
- g_warning ("%s: Unhandled secure authentication setting %d for "
- "account_name=%s (%s)", __FUNCTION__, auth_protocol,
- account_name, modest_server_account_settings_get_hostname (server_settings));
- break;
+ if (MODEST_IS_ACCOUNT_PROTOCOL (protocol) &&
+ modest_account_protocol_has_custom_secure_auth_mech (MODEST_ACCOUNT_PROTOCOL (protocol), auth_protocol_type)) {
+ auth_mech_name = modest_account_protocol_get_custom_secure_auth_mech (MODEST_ACCOUNT_PROTOCOL (protocol), auth_protocol_type);
+ } else {
+ auth_mech_name = modest_protocol_get (auth_protocol, MODEST_PROTOCOL_AUTH_ACCOUNT_OPTION);
}
if (auth_mech_name)
tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
- if (modest_protocol_info_protocol_is_store(protocol) &&
- (protocol == MODEST_PROTOCOL_STORE_IMAP) ) {
- TnyPair *use_lsub, *check_all;
-
- use_lsub = tny_pair_new (MODEST_ACCOUNT_OPTION_USE_LSUB, "");
- check_all = tny_pair_new (MODEST_ACCOUNT_OPTION_CHECK_ALL, "");
- /* Other connection options, needed for IMAP. */
- tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
- use_lsub);
- tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
- check_all);
- g_object_unref (use_lsub);
- g_object_unref (check_all);
+ if (MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
+ TnyList *account_options;
+ TnyIterator *iterator;
+
+ account_options = modest_account_protocol_get_account_options (MODEST_ACCOUNT_PROTOCOL (protocol));
+ for (iterator = tny_list_create_iterator (account_options); !tny_iterator_is_done (iterator); tny_iterator_next (iterator)) {
+ TnyPair *current;
+
+ current = TNY_PAIR (tny_iterator_get_current (iterator));
+ tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
+ current);
+ g_object_unref (current);
+ }
+ g_object_unref (iterator);
+ g_object_unref (account_options);
+
+ }
+
+ if (modest_server_account_settings_get_uri (server_settings) == NULL) {
+ username = modest_server_account_settings_get_username (server_settings);
+ if (username && strlen (username) > 0)
+ tny_account_set_user (tny_account, username);
+ hostname = modest_server_account_settings_get_hostname (server_settings);
+ if (hostname && hostname[0] != '\0')
+ tny_account_set_hostname (tny_account, hostname);
+
+ /* Set the port: */
+ port = modest_server_account_settings_get_port (server_settings);
+ if (port)
+ tny_account_set_port (tny_account, port);
+ } else {
+ tny_account_set_url_string (TNY_ACCOUNT (tny_account), modest_server_account_settings_get_uri (server_settings));
}
-
- username = modest_server_account_settings_get_username (server_settings);
- if (username && strlen (username) > 0)
- tny_account_set_user (tny_account, username);
- hostname = modest_server_account_settings_get_hostname (server_settings);
- if (hostname)
- tny_account_set_hostname (tny_account, hostname);
-
- /* Set the port: */
- port = modest_server_account_settings_get_port (server_settings);
- if (port)
- tny_account_set_port (tny_account, port);
}
MODEST_DEBUG_BLOCK (
{
ModestServerAccountSettings *server_settings;
TnyAccount *tny_account;
+ ModestProtocolRegistry *protocol_registry;
TnyConnectionPolicy *policy;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (server_account_name, NULL);
+ protocol_registry = modest_runtime_get_protocol_registry ();
- server_settings = modest_account_mgr_load_server_settings (account_mgr, server_account_name);
+ server_settings = modest_account_mgr_load_server_settings (account_mgr, server_account_name, TRUE);
if (!server_settings)
return NULL;
tny_account = TNY_ACCOUNT (tny_camel_transport_account_new ());
if (tny_account) {
+ ModestProtocol *protocol;
const gchar* proto_name = NULL;
tny_account_set_id (tny_account, server_account_name);
tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (tny_account), session);
- proto_name = modest_protocol_info_get_transport_store_protocol_name
- (modest_server_account_settings_get_protocol (server_settings));
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, modest_server_account_settings_get_protocol (server_settings));
+ proto_name = modest_protocol_get_name (protocol);
tny_account_set_proto (tny_account, proto_name);
modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, server_account_name);
}
return result;
}
+ModestProtocolType
+modest_tny_account_get_protocol_type (TnyAccount *self)
+{
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
+ ModestProtocolType result;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_name (protocol_registry,
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_STORE_PROTOCOLS,
+ tny_account_get_proto (self));
+ result = protocol?modest_protocol_get_type_id (protocol):MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+
+ return result;
+}
**/
gboolean modest_tny_account_is_memory_card_account (TnyAccount *self);
+/**
+ * modest_tny_account_get_protocol_type:
+ * @self: a #TnyAccount
+ *
+ * obtains the transport/store protocol type of @self
+ *
+ * Returns: a #ModestProtocolType
+ */
+ModestProtocolType modest_tny_account_get_protocol_type (TnyAccount *self);
+
G_END_DECLS
#include <glib/gi18n.h>
#include <string.h>
#include <modest-tny-folder.h>
+#include <modest-tny-account.h>
#include <modest-tny-outbox-account.h>
#include <tny-simple-list.h>
#include <tny-camel-folder.h>
#include <tny-merge-folder.h>
-#include <modest-protocol-info.h>
#include <modest-runtime.h>
#include <modest-tny-account-store.h>
#include <modest-text-utils.h>
break;
}
} else {
- ModestTransportStoreProtocol proto;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocolType protocol_type;
TnyFolderType folder_type;
TnyAccount *account;
+ protocol_registry = modest_runtime_get_protocol_registry ();
+
account = modest_tny_folder_get_account ((TnyFolder*)folder);
if (!account)
return -1; /* no account: nothing is allowed */
- proto = modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (account));
+ protocol_type = modest_tny_account_get_protocol_type (account);
- if (proto == MODEST_PROTOCOL_STORE_IMAP) {
+ if (modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type, MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS)) {
rules = 0;
} else {
/* pop, nntp, ... */
#include <modest-address-book.h>
#include "modest-error.h"
#include "modest-ui-actions.h"
-#include "modest-protocol-info.h"
#include "modest-tny-platform-factory.h"
#include "modest-platform.h"
#include "modest-debug.h"
gint num_of_uncached_msgs,
TnyAccount *account);
-static gboolean remote_folder_is_pop (TnyFolderStore *folder);
+static gboolean remote_folder_has_leave_on_server (TnyFolderStore *folder);
static void do_create_folder (GtkWindow *window,
TnyFolderStore *parent_folder,
* This function checks whether a TnyFolderStore is a pop account
*/
static gboolean
-remote_folder_is_pop (TnyFolderStore *folder)
+remote_folder_has_leave_on_server (TnyFolderStore *folder)
{
- const gchar *proto = NULL;
- TnyAccount *account = NULL;
+ TnyAccount *account;
+ gboolean result;
g_return_val_if_fail (TNY_IS_FOLDER_STORE (folder), FALSE);
account = get_account_from_folder_store (folder);
- proto = tny_account_get_proto (account);
+ result = (modest_protocol_registry_protocol_type_has_leave_on_server (modest_runtime_get_protocol_registry (),
+ modest_tny_account_get_protocol_type (account)));
g_object_unref (account);
- return (modest_protocol_info_get_transport_store_protocol (proto) == MODEST_PROTOCOL_STORE_POP);
+ return result;
}
/* FIXME: this should be merged with the similar code in modest-account-view-window */
gpointer user_data)
{
ModestMailOperation *mail_op = NULL;
- const gchar *proto_name;
gchar *error_msg;
- ModestTransportStoreProtocol proto;
+ ModestProtocolType proto;
TnyList *not_opened_headers;
TnyConnectionStatus status;
gboolean show_open_draft = FALSE;
}
/* Get the error message depending on the protocol */
- proto_name = tny_account_get_proto (account);
- if (proto_name != NULL) {
- proto = modest_protocol_info_get_transport_store_protocol (proto_name);
- } else {
- proto = MODEST_PROTOCOL_STORE_MAILDIR;
+ proto = modest_tny_account_get_protocol_type (account);
+ if (proto == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ proto = MODEST_PROTOCOLS_STORE_MAILDIR;
}
/* Create the error messages */
if (tny_list_get_length (not_opened_headers) == 1) {
- if (proto == MODEST_PROTOCOL_STORE_POP) {
- error_msg = g_strdup (_("emev_ni_ui_pop3_msg_recv_error"));
- } else if (proto == MODEST_PROTOCOL_STORE_IMAP) {
- TnyIterator *iter = tny_list_create_iterator (not_opened_headers);
- TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
- gchar *subject = tny_header_dup_subject (header);
- error_msg = g_strdup_printf (_("emev_ni_ui_imap_message_not_available_in_server"),
- subject);
- g_free (subject);
- g_object_unref (header);
- g_object_unref (iter);
- } else {
+ ModestProtocol *protocol;
+ ModestProtocolRegistry *protocol_registry;
+ TnyIterator *iter;
+ TnyHeader *header;
+ gchar *subject;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ iter = tny_list_create_iterator (not_opened_headers);
+ header = TNY_HEADER (tny_iterator_get_current (iter));
+ subject = tny_header_dup_subject (header);
+
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, proto);
+ error_msg = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE, subject);
+ g_free (subject);
+ g_object_unref (header);
+ g_object_unref (iter);
+
+ if (error_msg == NULL) {
+ error_msg = g_strdup (_("mail_ni_ui_folder_get_msg_folder_error"));
+ }
+
+ if (modest_protocol_registry_protocol_type_has_tag (protocol_registry,
+ proto,
+ MODEST_PROTOCOL_REGISTRY_LOCAL_STORE_PROTOCOLS)) {
TnyHeader *header;
TnyFolder *folder;
TnyIterator *iter;
g_object_unref (folder);
g_object_unref (header);
g_object_unref (iter);
- error_msg = g_strdup (_("mail_ni_ui_folder_get_msg_folder_error"));
}
} else {
error_msg = g_strdup (_("mail_ni_ui_folder_get_msg_folder_error"));
if ((gpointer) local_account != (gpointer) folder_store &&
(gpointer) mmc_account != (gpointer) folder_store) {
- const char *proto_name = tny_account_get_proto (TNY_ACCOUNT (folder_store));
- ModestTransportStoreProtocol proto = MODEST_PROTOCOL_STORE_MAILDIR;
- if (proto_name != NULL) {
- proto = modest_protocol_info_get_transport_store_protocol (proto_name);
+ ModestProtocolType proto;
+ proto = modest_tny_account_get_protocol_type (TNY_ACCOUNT (folder_store));
+ if (proto == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ proto = MODEST_PROTOCOLS_STORE_MAILDIR;
}
is_local_account = FALSE;
/* New button should be dimmed on remote
POP account root */
- new_sensitive = (proto != MODEST_PROTOCOL_STORE_POP);
+ new_sensitive = (modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
+ proto,
+ MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS));
}
g_object_unref (local_account);
g_object_unref (mmc_account);
/* The transfer is possible and the user wants to */
*do_xfer = TRUE;
- if (remote_folder_is_pop (src_folder) && delete_originals) {
+ if (remote_folder_has_leave_on_server (src_folder) && delete_originals) {
const gchar *account_name;
gboolean leave_on_server;
{
ModestWindow *win = MODEST_WINDOW (parent_window);
TnyAccount *dst_account = NULL;
- const gchar *proto_str = NULL;
- gboolean dst_is_pop = FALSE;
+ gboolean dst_forbids_message_add = FALSE;
XferMsgsHelper *helper;
MoveToHelper *movehelper;
ModestMailOperation *mail_op;
}
dst_account = tny_folder_get_account (TNY_FOLDER (helper->dst_folder));
- proto_str = tny_account_get_proto (dst_account);
/* tinymail will return NULL for local folders it seems */
- dst_is_pop = proto_str &&
- (modest_protocol_info_get_transport_store_protocol (proto_str) ==
- MODEST_PROTOCOL_STORE_POP);
-
+ dst_forbids_message_add = modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
+ modest_tny_account_get_protocol_type (dst_account),
+ MODEST_PROTOCOL_REGISTRY_STORE_FORBID_MESSAGE_ADD);
g_object_unref (dst_account);
- if (dst_is_pop) {
+ if (dst_forbids_message_add) {
modest_platform_information_banner (GTK_WIDGET (win),
NULL,
ngettext("mail_in_ui_folder_move_target_error",
modest_ui_actions_on_account_connection_error (GtkWindow *parent_window,
TnyAccount *account)
{
- ModestTransportStoreProtocol proto;
- const gchar *proto_name;
+ ModestProtocolType protocol_type;
+ ModestProtocol *protocol;
gchar *error_note = NULL;
- proto_name = tny_account_get_proto (account);
- proto = modest_protocol_info_get_transport_store_protocol (proto_name);
-
- switch (proto) {
- case MODEST_PROTOCOL_STORE_POP:
- error_note = g_strdup_printf (_("emev_ni_ui_pop3_msg_connect_error"),
- tny_account_get_hostname (account));
- break;
- case MODEST_PROTOCOL_STORE_IMAP:
- error_note = g_strdup_printf (_("emev_ni_ui_imap_connect_server_error"),
- tny_account_get_hostname (account));
- break;
- case MODEST_PROTOCOL_STORE_MAILDIR:
- case MODEST_PROTOCOL_STORE_MBOX:
- error_note = g_strdup (_("emev_nc_mailbox_notavailable"));
- break;
- default:
- g_warning ("%s: This should not be reached", __FUNCTION__);
- }
+ protocol_type = modest_tny_account_get_protocol_type (account);
+ protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+ protocol_type);
- if (error_note) {
+ error_note = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_ACCOUNT_CONNECTION_ERROR, tny_account_get_hostname (account));
+ if (error_note == NULL) {
+ g_warning ("%s: This should not be reached", __FUNCTION__);
+ } else {
modest_platform_run_information_dialog (parent_window, error_note, FALSE);
g_free (error_note);
}
modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win)
{
gchar *msg = NULL;
+ gchar *subject;
TnyFolderStore *folder = NULL;
TnyAccount *account = NULL;
- ModestTransportStoreProtocol proto;
+ ModestProtocolType proto;
+ ModestProtocol *protocol;
TnyHeader *header = NULL;
if (MODEST_IS_MAIN_WINDOW (win)) {
/* Get the account type */
account = tny_folder_get_account (TNY_FOLDER (folder));
- proto = modest_protocol_info_get_transport_store_protocol (tny_account_get_proto (account));
- if (proto == MODEST_PROTOCOL_STORE_POP) {
- msg = g_strdup (_("emev_ni_ui_pop3_msg_recv_error"));
- } else if (proto == MODEST_PROTOCOL_STORE_IMAP) {
- gchar *subject;
- subject = tny_header_dup_subject (header);
- msg = g_strdup_printf (_("emev_ni_ui_imap_message_not_available_in_server"),
- subject);
- g_free (subject);
- } else {
+ proto = modest_tny_account_get_protocol_type (account);
+ protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+ proto);
+
+ subject = tny_header_dup_subject (header);
+ msg = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_MSG_NOT_AVAILABLE, subject);
+ g_free (subject);
+ if (msg == NULL) {
msg = g_strdup_printf (_("mail_ni_ui_folder_get_msg_folder_error"));
}
static gboolean _selected_folder_not_deletable (ModestMainWindow *win);
static gboolean _selected_folder_is_any_of_type (ModestWindow *win, TnyFolderType types[], guint ntypes);
static gboolean _selected_folder_is_root_or_inbox (ModestMainWindow *win);
-static gboolean _selected_folder_is_MMC_or_POP_root (ModestMainWindow *win);
static gboolean _selected_folder_is_root (ModestMainWindow *win);
static gboolean _header_view_is_all_selected (ModestMainWindow *win);
static gboolean _selected_folder_is_empty (ModestMainWindow *win);
if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (parent_folder))) {
dimmed = FALSE;
} else {
- const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (parent_folder));
- if (proto_str != NULL) {
- /* If it's POP then dim */
- dimmed = (modest_protocol_info_get_transport_store_protocol (proto_str) ==
- MODEST_PROTOCOL_STORE_POP) ? TRUE : FALSE;
+ ModestProtocolType protocol_type = modest_tny_account_get_protocol_type (TNY_ACCOUNT (parent_folder));
+ if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
+ ModestProtocolRegistry *protocol_registry;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ /* If account does not support folders (pop) then dim */
+ dimmed = (!modest_protocol_registry_protocol_type_has_tag (protocol_registry, protocol_type,
+ MODEST_PROTOCOL_REGISTRY_STORE_HAS_FOLDERS));
if (dimmed)
modest_dimming_rule_set_notification (rule, _("mail_in_ui_folder_create_error"));
}
modest_dimming_rule_set_notification (rule, _("mail_in_ui_folder_delete_error"));
}
if (!dimmed) {
- dimmed = _selected_folder_is_MMC_or_POP_root (MODEST_MAIN_WINDOW(win));
- if (dimmed)
- modest_dimming_rule_set_notification (rule, _("mail_in_ui_folder_delete_error"));
- }
- if (!dimmed) {
dimmed = _transfer_mode_enabled (win);
if (dimmed)
modest_dimming_rule_set_notification (rule, _CS("ckct_ib_unable_to_delete"));
/* Check pop and MMC accounts */
if (!result) {
- result = _selected_folder_is_MMC_or_POP_root (win);
+ result = _selected_folder_is_root (win);
}
return result;
modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
if (folder_store) {
is_account = TNY_IS_ACCOUNT (folder_store);
+
g_object_unref (folder_store);
folder_store = NULL;
}
/* Check folder type */
result = _selected_folder_is_any_of_type (MODEST_WINDOW(win), types, 1);
- /* Check pop and MMC accounts */
- if (!result) {
- result = _selected_folder_is_MMC_or_POP_root (win);
- }
-
- return result;
-}
-
-static gboolean
-_selected_folder_is_MMC_or_POP_root (ModestMainWindow *win)
-{
- GtkWidget *folder_view = NULL;
- TnyFolderStore *parent_folder = NULL;
- gboolean result = FALSE;
-
- folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
- MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
- if (!folder_view)
- return FALSE;
-
- /* Get selected folder as parent of new folder to create */
- parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
- if (!parent_folder)
- return TRUE;
-
- if (TNY_IS_ACCOUNT (parent_folder)) {
- /* If it's the local account then do not dim */
- if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (parent_folder))) {
- result = FALSE;
- } else {
- /* If it's the MMC root folder then dim it */
- if (!strcmp (tny_account_get_id (TNY_ACCOUNT (parent_folder)), MODEST_MMC_ACCOUNT_ID)) {
- result = TRUE;
- } else {
- const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (parent_folder));
- /* If it's POP then dim */
- result = (modest_protocol_info_get_transport_store_protocol (proto_str) ==
- MODEST_PROTOCOL_STORE_POP) ? TRUE : FALSE;
- }
- }
- }
- g_object_unref (parent_folder);
-
return result;
}
result = TRUE;
}
} else {
- const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (account));
- ModestTransportStoreProtocol proto;
- proto = modest_protocol_info_get_transport_store_protocol (proto_str);
+ ModestProtocolType protocol_type = modest_tny_account_get_protocol_type (TNY_ACCOUNT (account));
/* If it's a remote folder then dim */
- if (proto == MODEST_PROTOCOL_STORE_POP || proto == MODEST_PROTOCOL_STORE_IMAP) {
+ if (modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
+ protocol_type,
+ MODEST_PROTOCOL_REGISTRY_REMOTE_STORE_PROTOCOLS)) {
result = TRUE;
}
}
#include <modest-defs.h>
#include "modest-utils.h"
#include "modest-platform.h"
+<<<<<<< .working
#include "modest-account-mgr-helpers.h"
#include "modest-text-utils.h"
+=======
+#include <modest-account-protocol.h>
+#include "modest-account-mgr-helpers.h"
+#include "modest-text-utils.h"
+>>>>>>> .merge-right.r5668
#include <modest-local-folder-info.h>
#include "widgets/modest-header-view.h"
#include "widgets/modest-main-window.h"
else if (tny_list_get_length(auth_types) == 0)
g_warning ("DEBUG: %s: auth_types is an empty TnyList.\n", __FUNCTION__);
else {
- ModestPairList* pairs = modest_protocol_info_get_auth_protocol_pair_list ();
+ ModestPairList *pairs;
+ GList *result;
+ ModestProtocolRegistry *protocol_registry;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ pairs = modest_protocol_registry_get_pair_list_by_tag (protocol_registry, MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS);
/* Get the enum value for the strings: */
- GList *result = NULL;
+ result = NULL;
TnyIterator* iter = tny_list_create_iterator(auth_types);
while (!tny_iterator_is_done(iter)) {
- TnyPair *pair = TNY_PAIR(tny_iterator_get_current(iter));
- const gchar *auth_name = NULL;
+ TnyPair *pair;
+ const gchar *auth_name;
+ ModestProtocolType protocol_type;
+
+ pair = TNY_PAIR(tny_iterator_get_current(iter));
+ auth_name = NULL;
if (pair) {
auth_name = tny_pair_get_name(pair);
g_object_unref (pair);
printf("DEBUG: %s: auth_name=%s\n", __FUNCTION__, auth_name);
- ModestAuthProtocol proto = modest_protocol_info_get_auth_protocol (auth_name);
- if(proto != MODEST_PROTOCOL_AUTH_NONE)
- result = g_list_prepend(result, GINT_TO_POINTER(proto));
+ protocol_type = modest_protocol_get_type_id (modest_protocol_registry_get_protocol_by_name (protocol_registry,
+ MODEST_PROTOCOL_REGISTRY_AUTH_PROTOCOLS,
+ auth_name));
+
+ if(modest_protocol_registry_protocol_type_is_secure (protocol_registry, protocol_type))
+ result = g_list_prepend(result, GINT_TO_POINTER(protocol_type));
tny_iterator_next(iter);
}
}
GList*
-modest_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto,
+modest_utils_get_supported_secure_authentication_methods (ModestProtocolType protocol_type,
const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error)
{
- g_return_val_if_fail (proto != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN, NULL);
+ TnyAccount * tny_account = NULL;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
+
+ g_return_val_if_fail (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID, NULL);
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
/* We need a connection to get the capabilities; */
if (!modest_platform_connect_and_wait (GTK_WINDOW (parent_window), NULL))
/* Create a TnyCamelAccount so we can use
* tny_camel_account_get_supported_secure_authentication(): */
- TnyAccount * tny_account = NULL;
- switch (proto) {
- case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
- case MODEST_PROTOCOL_TRANSPORT_SMTP:
- tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break;
- case MODEST_PROTOCOL_STORE_POP:
- tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
- case MODEST_PROTOCOL_STORE_IMAP:
- tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
- case MODEST_PROTOCOL_STORE_MAILDIR:
- case MODEST_PROTOCOL_STORE_MBOX:
- tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
- default:
- tny_account = NULL;
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
+ tny_account = NULL;
+ if (MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
+ tny_account = modest_account_protocol_create_account (MODEST_ACCOUNT_PROTOCOL (protocol));
}
-
if (!tny_account) {
g_printerr ("%s could not create tny account.", __FUNCTION__);
* set_session(): */
/* TODO: Why isn't this done in account_new()? */
tny_account_set_proto (tny_account,
- modest_protocol_info_get_transport_store_protocol_name(proto));
+ modest_protocol_get_name (modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type)));
tny_account_set_hostname (tny_account, hostname);
/* Required for POP, at least */
return (guint64) size;
}
+<<<<<<< .working
static void
on_destroy_dialog (GtkDialog *dialog)
return account_name;
}
+=======
+
+static void
+on_destroy_dialog (GtkDialog *dialog)
+{
+ gtk_widget_destroy (GTK_WIDGET(dialog));
+ if (gtk_events_pending ())
+ gtk_main_iteration ();
+}
+
+static guint
+checked_modest_sort_criterium_view_add_sort_key (ModestSortCriteriumView *view, const gchar* key, guint max)
+{
+ gint sort_key;
+
+ g_return_val_if_fail (view && MODEST_IS_SORT_CRITERIUM_VIEW(view), 0);
+ g_return_val_if_fail (key, 0);
+
+ sort_key = modest_sort_criterium_view_add_sort_key (view, key);
+ if (sort_key < 0 || sort_key >= max) {
+ g_warning ("%s: out of range (%d) for %s", __FUNCTION__, sort_key, key);
+ return 0;
+ } else
+ return (guint)sort_key;
+}
+
+static void
+launch_sort_headers_dialog (GtkWindow *parent_window,
+ GtkDialog *dialog)
+{
+ ModestHeaderView *header_view = NULL;
+ GList *cols = NULL;
+ GtkSortType sort_type;
+ gint sort_key;
+ gint default_key = 0;
+ gint result;
+ gboolean outgoing = FALSE;
+ gint current_sort_colid = -1;
+ GtkSortType current_sort_type;
+ gint attachments_sort_id;
+ gint priority_sort_id;
+ GtkTreeSortable *sortable;
+
+ /* Get header window */
+ if (MODEST_IS_MAIN_WINDOW (parent_window)) {
+ header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(parent_window),
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
+ }
+ if (!header_view)
+ return;
+
+ /* Add sorting keys */
+ cols = modest_header_view_get_columns (header_view);
+ if (cols == NULL)
+ return;
+#define SORT_ID_NUM 6
+ int sort_model_ids[SORT_ID_NUM];
+ int sort_ids[SORT_ID_NUM];
+
+ outgoing = (GPOINTER_TO_INT (g_object_get_data(G_OBJECT(cols->data), MODEST_HEADER_VIEW_COLUMN))==
+ MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT);
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_sender_recipient"),
+ SORT_ID_NUM);
+ if (outgoing) {
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_TO_COLUMN;
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT;
+ } else {
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FROM_COLUMN;
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN;
+ }
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_date"),
+ SORT_ID_NUM);
+ if (outgoing) {
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_TIME_T_COLUMN;
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_SENT_DATE;
+ } else {
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN;
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_RECEIVED_DATE;
+ }
+ default_key = sort_key;
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_subject"),
+ SORT_ID_NUM);
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN;
+ if (outgoing)
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT;
+ else
+ sort_ids[sort_key] = MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN;
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_attachment"),
+ SORT_ID_NUM);
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN;
+ sort_ids[sort_key] = TNY_HEADER_FLAG_ATTACHMENTS;
+ attachments_sort_id = sort_key;
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_size"),
+ SORT_ID_NUM);
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_MESSAGE_SIZE_COLUMN;
+ sort_ids[sort_key] = 0;
+
+ sort_key = checked_modest_sort_criterium_view_add_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), _("mcen_li_sort_priority"),
+ SORT_ID_NUM);
+ sort_model_ids[sort_key] = TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN;
+ sort_ids[sort_key] = TNY_HEADER_FLAG_PRIORITY_MASK;
+ priority_sort_id = sort_key;
+
+ sortable = GTK_TREE_SORTABLE (gtk_tree_model_filter_get_model
+ (GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view)))));
+ /* Launch dialogs */
+ if (!gtk_tree_sortable_get_sort_column_id (sortable,
+ ¤t_sort_colid, ¤t_sort_type)) {
+ modest_sort_criterium_view_set_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), default_key);
+ modest_sort_criterium_view_set_sort_order (MODEST_SORT_CRITERIUM_VIEW (dialog), GTK_SORT_DESCENDING);
+ } else {
+ modest_sort_criterium_view_set_sort_order (MODEST_SORT_CRITERIUM_VIEW (dialog), current_sort_type);
+ if (current_sort_colid == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN) {
+ gpointer flags_sort_type_pointer;
+ flags_sort_type_pointer = g_object_get_data (G_OBJECT (cols->data), MODEST_HEADER_VIEW_FLAG_SORT);
+ if (GPOINTER_TO_INT (flags_sort_type_pointer) == TNY_HEADER_FLAG_PRIORITY_MASK)
+ modest_sort_criterium_view_set_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), priority_sort_id);
+ else
+ modest_sort_criterium_view_set_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), attachments_sort_id);
+ } else {
+ gint current_sort_keyid = 0;
+ while (current_sort_keyid < 6) {
+ if (sort_model_ids[current_sort_keyid] == current_sort_colid)
+ break;
+ else
+ current_sort_keyid++;
+ }
+ modest_sort_criterium_view_set_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog), current_sort_keyid);
+ }
+ }
+
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (result == GTK_RESPONSE_OK) {
+ sort_key = modest_sort_criterium_view_get_sort_key (MODEST_SORT_CRITERIUM_VIEW (dialog));
+ if (sort_key < 0 || sort_key > SORT_ID_NUM -1) {
+ g_warning ("%s: out of range (%d)", __FUNCTION__, sort_key);
+ sort_key = 0;
+ }
+
+ sort_type = modest_sort_criterium_view_get_sort_order (MODEST_SORT_CRITERIUM_VIEW (dialog));
+ if (sort_model_ids[sort_key] == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN) {
+ g_object_set_data (G_OBJECT(cols->data), MODEST_HEADER_VIEW_FLAG_SORT,
+ GINT_TO_POINTER (sort_ids[sort_key]));
+ /* This is a hack to make it resort rows always when flag fields are
+ * selected. If we do not do this, changing sort field from priority to
+ * attachments does not work */
+ modest_header_view_sort_by_column_id (header_view, 0, sort_type);
+ } else {
+ gtk_tree_view_column_set_sort_column_id (GTK_TREE_VIEW_COLUMN (cols->data),
+ sort_model_ids[sort_key]);
+ }
+
+ modest_header_view_sort_by_column_id (header_view, sort_model_ids[sort_key], sort_type);
+ gtk_tree_sortable_sort_column_changed (sortable);
+ }
+
+ modest_widget_memory_save (modest_runtime_get_conf (),
+ G_OBJECT (header_view), MODEST_CONF_HEADER_VIEW_KEY);
+
+ /* free */
+ g_list_free(cols);
+}
+
+void
+modest_utils_run_sort_dialog (GtkWindow *parent_window,
+ ModestSortDialogType type)
+{
+ GtkWidget *dialog = NULL;
+
+ /* Build dialog */
+ dialog = modest_platform_create_sort_dialog (parent_window);
+ if (dialog == NULL)
+ return;
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+ GTK_WINDOW (dialog));
+
+ /* Fill sort keys */
+ switch (type) {
+ case MODEST_SORT_HEADERS:
+ launch_sort_headers_dialog (parent_window,
+ GTK_DIALOG(dialog));
+ break;
+ }
+
+ /* Free */
+ on_destroy_dialog (GTK_DIALOG(dialog));
+}
+
+
+gchar *
+modest_images_cache_get_id (const gchar *account, const gchar *uri)
+{
+ GnomeVFSURI *vfs_uri;
+ gchar *result;
+
+ vfs_uri = gnome_vfs_uri_new (uri);
+ if (vfs_uri == NULL)
+ return NULL;
+
+ result = g_strdup_printf ("%s__%x", account, gnome_vfs_uri_hash (vfs_uri));
+ gnome_vfs_uri_unref (vfs_uri);
+
+ return result;
+}
+
+gchar *
+modest_utils_get_account_name_from_recipient (const gchar *from_header)
+{
+ gchar *account_name = NULL;
+ ModestAccountMgr *mgr = NULL;
+ GSList *accounts = NULL, *node = NULL;
+
+ g_return_val_if_fail (from_header, NULL);
+
+ mgr = modest_runtime_get_account_mgr ();
+ accounts = modest_account_mgr_account_names (mgr, TRUE);
+
+ for (node = accounts; node != NULL; node = g_slist_next (node)) {
+ gchar *from =
+ modest_account_mgr_get_from_string (mgr, node->data);
+
+ if (from) {
+ gchar *from_email =
+ modest_text_utils_get_email_address (from);
+
+ if (from_email) {
+ if (!modest_text_utils_utf8_strcmp (from_header, from_email, TRUE)) {
+ account_name = g_strdup (node->data);
+ g_free (from);
+ g_free (from_email);
+ break;
+ }
+ g_free (from_email);
+ }
+ g_free (from);
+ }
+ }
+ g_slist_foreach (accounts, (GFunc) g_free, NULL);
+ g_slist_free (accounts);
+
+ return account_name;
+}
+
+void
+modest_utils_on_entry_invalid_character (ModestValidatingEntry *self,
+ const gchar* character,
+ gpointer user_data)
+{
+ gchar *message = NULL;
+ const gchar *show_char = NULL;
+
+ if (character)
+ show_char = character;
+ else {
+ show_char = "' '";
+ }
+
+ message = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), show_char);
+ modest_platform_information_banner (GTK_WIDGET (self), NULL, message);
+ g_free (message);
+}
+>>>>>>> .merge-right.r5668
#include <gtk/gtk.h>
#include <stdio.h> /* for FILE* */
-#include <modest-protocol-info.h>
#include <tny-fs-stream.h>
+#include <modest-protocol.h>
+#include "widgets/modest-validating-entry.h"
typedef enum {
MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED
*
*/
-GList* modest_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto,
+GList* modest_utils_get_supported_secure_authentication_methods (ModestProtocolType proto,
const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error);
/** modest_show_information_note_in_main_context_and_forget:
*/
guint64 modest_utils_get_available_space (const gchar *maildir_path);
+<<<<<<< .working
/**
* modest_images_cache_get_id:
* @account: a #TnyAccount
*/
gchar *modest_utils_get_account_name_from_recipient (const gchar *from);
+=======
+/**
+ * modest_images_cache_get_id:
+ * @account: a #TnyAccount
+ * @uri: an uri string
+ *
+ * obtains the hash corresponding to an image external resource to be
+ * stored in image cache.
+ *
+ * Returns: a newly allocated string containing the hash key
+ */
+gchar *modest_images_cache_get_id (const gchar *account, const gchar *uri);
+
+
+/**
+ * modest_utils_get_account_name_from_recipient:
+ * @from: the result of a call to tny_header_dup_from
+ *
+ * returns the account name that corresponds to the given from address
+ *
+ * Returns: a newly allocated string containing the account name or
+ * %NULL in case of error
+ */
+gchar *modest_utils_get_account_name_from_recipient (const gchar *from);
+
+void modest_utils_on_entry_invalid_character (ModestValidatingEntry *self,
+ const gchar* character,
+ gpointer user_data);
+
+>>>>>>> .merge-right.r5668
#endif /*__MODEST_MAEMO_UTILS_H__*/
noinst_LTLIBRARIES=\
libmodest-widgets.la
+to_remove=\
+ modest-testplugin-easysetup-wizard-page.h \
+ modest-testplugin-account-settings-dialog.h \
+ modest-testplugin-account-settings-widget.h
+
+libmodest_widgets_public_headers = \
+ modest-account-settings-dialog.h \
+ modest-easysetup-wizard-page.h \
+ modest-folder-view.h \
+ modest-sort-criterium-view.h \
+ modest-ui-constants.h \
+ modest-validating-entry.h \
+ modest-window.h
+
+
libmodest_widgets_la_SOURCES= \
+ $(libmodest_widgets_public_headers) \
modest-account-view-window.h \
- modest-account-settings-dialog.h \
+ modest-account-settings-dialog.c \
modest-account-view.c \
modest-account-view.h \
modest-attachment-view.c \
modest-attachments-view.h \
modest-combo-box.c \
modest-combo-box.h \
+ modest-default-account-settings-dialog.h \
modest-dnd.c \
modest-dnd.h \
+ modest-easysetup-wizard-page.c \
modest-folder-view.c \
- modest-folder-view.h \
modest-global-settings-dialog.c \
modest-global-settings-dialog.h \
modest-gtkhtml-mime-part-view.c \
modest-scroll-area.c \
modest-scroll-text.c \
modest-scroll-text.h \
- modest-serversecurity-combo-box.h modest-serversecurity-combo-box.c \
- modest-secureauth-combo-box.h modest-secureauth-combo-box.c \
+ modest-security-options-view.h \
+ modest-security-options-view.c \
+ modest-serversecurity-combo-box.h \
+ modest-serversecurity-combo-box.c \
+ modest-secureauth-combo-box.h \
+ modest-secureauth-combo-box.c \
+ modest-sort-criterium-view.c \
modest-sort-criterium-view.c \
modest-sort-criterium-view.h \
modest-tny-stream-gtkhtml.c \
modest-tny-stream-gtkhtml.h \
- modest-ui-constants.h \
- modest-validating-entry.h modest-validating-entry.c \
+ modest-validating-entry.c \
modest-window.c \
- modest-window.h \
modest-window-mgr.h \
modest-window-mgr.c \
modest-wizard-dialog.h \
modest-mozembed-mime-part-view.h
endif
+libmodest_widgets_la_includedir = $(includedir)/modest-plugin-1.0/widgets/
+libmodest_widgets_la_include_HEADERS = $(libmodest_widgets_public_headers)
+
LDADD = \
$(MODEST_GSTUFF_LIBS) \
$(MODEST_MOZEMBED_LIBS) \
--- /dev/null
+/* modest-account-settings-dialog-iface.c */
+/* insert (c)/licensing information) */
+
+#include "modest-account-settings-dialog.h"
+
+static void modest_account_settings_dialog_base_init (gpointer g_class);
+
+void
+modest_account_settings_dialog_load_settings (ModestAccountSettingsDialog *self,
+ ModestAccountSettings *settings)
+{
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (self));
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ return MODEST_ACCOUNT_SETTINGS_DIALOG_GET_IFACE(self)->load_settings (self, settings);
+}
+
+static void
+modest_account_settings_dialog_base_init (gpointer g_class)
+{
+ static gboolean initialized = FALSE;
+ if (!initialized) {
+ /* create interface signals here */
+ initialized = TRUE;
+ }
+}
+GType
+modest_account_settings_dialog_get_type (void)
+{
+ static GType my_type = 0;
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestAccountSettingsDialogClass),
+ modest_account_settings_dialog_base_init, /* base init */
+ NULL, /* base finalize */
+ NULL, /* class_init */
+ NULL, /* class finalize */
+ NULL, /* class data */
+ 0,
+ 0, /* n_preallocs */
+ NULL, /* instance init */
+ };
+ my_type = g_type_register_static (G_TYPE_INTERFACE,
+ "ModestAccountSettingsDialog",
+ &my_info, 0);
+ g_type_interface_add_prerequisite (my_type, G_TYPE_OBJECT);
+ }
+ return my_type;
+}
+
-/* Copyright (c) 2007, Nokia Corporation
- * All rights reserved.
- *
- */
+/* modest-account-settings-dialog-iface.h */
+/* insert (c)/licensing information) */
-#ifndef _MODEST_ACCOUNT_SETTINGS_DIALOG
-#define _MODEST_ACCOUNT_SETTINGS_DIALOG
+#ifndef __MODEST_ACCOUNT_SETTINGS_DIALOG_H__
+#define __MODEST_ACCOUNT_SETTINGS_DIALOG_H__
-#include <gtk/gtkdialog.h>
-#include <gtk/gtknotebook.h>
-#include "modest-account-mgr.h"
+/* other include files */
+#include <glib.h>
+#include <glib-object.h>
+#include "modest-account-settings.h"
G_BEGIN_DECLS
-#define MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG modest_account_settings_dialog_get_type()
+/* convenience macros */
+#define MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG (modest_account_settings_dialog_get_type())
+#define MODEST_ACCOUNT_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG,ModestAccountSettingsDialog))
+#define MODEST_IS_ACCOUNT_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG))
+#define MODEST_ACCOUNT_SETTINGS_DIALOG_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst),MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG,ModestAccountSettingsDialogClass))
-#define MODEST_ACCOUNT_SETTINGS_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG, ModestAccountSettingsDialog))
+typedef struct _ModestAccountSettingsDialog ModestAccountSettingsDialog;
+typedef struct _ModestAccountSettingsDialogClass ModestAccountSettingsDialogClass;
-#define MODEST_ACCOUNT_SETTINGS_DIALOG_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG, ModestAccountSettingsDialogClass))
+struct _ModestAccountSettingsDialogClass {
+ GTypeInterface parent;
-#define MODEST_IS_ACCOUNT_SETTINGS_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG))
+ /* the 'vtable': declare function pointers here, eg.: */
+ void (*load_settings) (ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings);
+};
-#define MODEST_IS_ACCOUNT_SETTINGS_DIALOG_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG))
+GType modest_account_settings_dialog_get_type (void) G_GNUC_CONST;
-#define MODEST_ACCOUNT_SETTINGS_DIALOG_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- MODEST_TYPE_ACCOUNT_SETTINGS_DIALOG, ModestAccountSettingsDialogClass))
+void modest_account_settings_dialog_load_settings (ModestAccountSettingsDialog *dialog,
+ ModestAccountSettings *settings);
-typedef struct {
- GtkDialog parent;
-
- /* Used by derived widgets to query existing accounts,
- * and to create new accounts: */
- ModestAccountMgr *account_manager;
- ModestAccountSettings *settings;
-
- gboolean modified;
- gchar * account_name; /* This may not change. It is not user visible. */
- ModestTransportStoreProtocol incoming_protocol; /* This may not change. */
- ModestTransportStoreProtocol outgoing_protocol; /* This may not change. */
- gchar * original_account_title;
-
- ModestAuthProtocol protocol_authentication_incoming;
-
- GtkNotebook *notebook;
-
- GtkWidget *page_account_details;
- GtkWidget *entry_account_title;
- GtkWidget *combo_retrieve;
- GtkWidget *combo_limit_retrieve;
- GtkWidget *caption_leave_messages;
- GtkWidget *checkbox_leave_messages;
-
- GtkWidget *page_user_details;
- GtkWidget *entry_user_name;
- GtkWidget *entry_user_username;
- GtkWidget *entry_user_password;
- GtkWidget *entry_user_email;
- GtkWidget *entry_incoming_port;
- GtkWidget *button_signature;
-
- GtkWidget *page_complete_easysetup;
-
- GtkWidget *page_incoming;
- GtkWidget *caption_incoming;
- GtkWidget *entry_incomingserver;
- GtkWidget *combo_incoming_security;
- GtkWidget *checkbox_incoming_auth;
-
- GtkWidget *page_outgoing;
- GtkWidget *entry_outgoingserver;
- GtkWidget *caption_outgoing_username;
- GtkWidget *entry_outgoing_username;
- GtkWidget *caption_outgoing_password;
- GtkWidget *entry_outgoing_password;
- GtkWidget *combo_outgoing_security;
- GtkWidget *combo_outgoing_auth;
- GtkWidget *entry_outgoing_port;
- GtkWidget *checkbox_outgoing_smtp_specific;
- GtkWidget *button_outgoing_smtp_servers;
-
- GtkWidget *signature_dialog;
-
-} ModestAccountSettingsDialog;
-
-typedef struct {
- GtkDialogClass parent_class;
-
-} ModestAccountSettingsDialogClass;
-
-GType modest_account_settings_dialog_get_type (void);
-
-ModestAccountSettingsDialog* modest_account_settings_dialog_new (void);
-
-void modest_account_settings_dialog_set_account (ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings);
-
-void modest_account_settings_dialog_switch_to_user_info (ModestAccountSettingsDialog *dialog);
-
-void modest_account_settings_dialog_set_modified (ModestAccountSettingsDialog *dialog, gboolean modified);
-
-void modest_account_settings_dialog_save_password (ModestAccountSettingsDialog *dialog);
-
-void modest_account_settings_dialog_check_allow_changes (ModestAccountSettingsDialog *self);
G_END_DECLS
-#endif /* _MODEST_ACCOUNT_SETTINGS_DIALOG */
+#endif /* __MODEST_ACCOUNT_SETTINGS_DIALOG_H__ */
+
const gchar *last_updated_string = get_last_updated_string(account_mgr, settings);
if (modest_account_settings_get_enabled (settings)) {
+ ModestProtocolType protocol_type;
+ ModestProtocolRegistry *protocol_registry;
+ ModestProtocol *protocol;
const gchar *proto_name;
- proto_name = modest_protocol_info_get_transport_store_protocol_name
- (modest_server_account_settings_get_protocol (store_settings));
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol_type = modest_server_account_settings_get_protocol (store_settings);
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
+ proto_name = modest_protocol_get_name (protocol);
gtk_list_store_insert_with_values (
model, &iter, 0,
MODEST_ACCOUNT_VIEW_NAME_COLUMN, account_name,
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+#ifndef _MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG
+#define _MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG
+
+#include <gtk/gtkdialog.h>
+#include <gtk/gtknotebook.h>
+#include "widgets/modest-account-settings-dialog.h"
+#include <modest-protocol.h>
+
+G_BEGIN_DECLS
+
+#define MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG modest_default_account_settings_dialog_get_type()
+
+#define MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG, ModestDefaultAccountSettingsDialog))
+
+#define MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG, ModestDefaultAccountSettingsDialogClass))
+
+#define MODEST_IS_DEFAULT_ACCOUNT_SETTINGS_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG))
+
+#define MODEST_IS_DEFAULT_ACCOUNT_SETTINGS_DIALOG_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG))
+
+#define MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ MODEST_TYPE_DEFAULT_ACCOUNT_SETTINGS_DIALOG, ModestDefaultAccountSettingsDialogClass))
+
+typedef struct {
+ GtkDialog parent;
+
+} ModestDefaultAccountSettingsDialog;
+
+typedef struct {
+ GtkDialogClass parent_class;
+
+} ModestDefaultAccountSettingsDialogClass;
+
+GType modest_default_account_settings_dialog_get_type (void);
+
+ModestAccountSettingsDialog* modest_default_account_settings_dialog_new (void);
+
+G_END_DECLS
+
+#endif /* _MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG */
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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 "widgets/modest-easysetup-wizard-page.h"
+
+enum {
+ MISSING_MANDATORY_DATA_SIGNAL,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+static void modest_easysetup_wizard_page_base_init (gpointer g_class);
+
+gboolean
+modest_easysetup_wizard_page_validate (ModestEasysetupWizardPage *self)
+{
+ return MODEST_EASYSETUP_WIZARD_PAGE_GET_IFACE(self)->validate (self);
+}
+
+void
+modest_easysetup_wizard_page_save_settings (ModestEasysetupWizardPage *self,
+ ModestAccountSettings *settings)
+{
+ return MODEST_EASYSETUP_WIZARD_PAGE_GET_IFACE(self)->save_settings (self, settings);
+}
+
+static void
+modest_easysetup_wizard_page_base_init (gpointer g_class)
+{
+ static gboolean initialized = FALSE;
+ if (!initialized) {
+ signals[MISSING_MANDATORY_DATA_SIGNAL] =
+ g_signal_new ("missing-mandatory-data",
+ MODEST_TYPE_EASYSETUP_WIZARD_PAGE,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(ModestEasysetupWizardPageClass, missing_mandatory_data),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ initialized = TRUE;
+ }
+}
+GType
+modest_easysetup_wizard_page_get_type (void)
+{
+ static GType my_type = 0;
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestEasysetupWizardPageClass),
+ modest_easysetup_wizard_page_base_init, /* base init */
+ NULL, /* base finalize */
+ NULL, /* class_init */
+ NULL, /* class finalize */
+ NULL, /* class data */
+ 0,
+ 0, /* n_preallocs */
+ NULL, /* instance init */
+ };
+ my_type = g_type_register_static (G_TYPE_INTERFACE,
+ "ModestEasysetupWizardPage",
+ &my_info, 0);
+ g_type_interface_add_prerequisite (my_type, G_TYPE_OBJECT);
+ }
+ return my_type;
+}
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+#ifndef __MODEST_EASYSETUP_WIZARD_PAGE_H__
+#define __MODEST_EASYSETUP_WIZARD_PAGE_H__
+
+/* other include files */
+#include <glib.h>
+#include <glib-object.h>
+#include "modest-account-settings.h"
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_EASYSETUP_WIZARD_PAGE (modest_easysetup_wizard_page_get_type())
+#define MODEST_EASYSETUP_WIZARD_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_EASYSETUP_WIZARD_PAGE,ModestEasysetupWizardPage))
+#define MODEST_IS_EASYSETUP_WIZARD_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_EASYSETUP_WIZARD_PAGE))
+#define MODEST_EASYSETUP_WIZARD_PAGE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj),MODEST_TYPE_EASYSETUP_WIZARD_PAGE,ModestEasysetupWizardPageClass))
+
+typedef struct _ModestEasysetupWizardPage ModestEasysetupWizardPage;
+typedef struct _ModestEasysetupWizardPageClass ModestEasysetupWizardPageClass;
+
+struct _ModestEasysetupWizardPageClass {
+ GTypeInterface parent_class;
+
+ /* Functions to be redefined */
+ gboolean (*validate) (ModestEasysetupWizardPage* self);
+ void (*save_settings) (ModestEasysetupWizardPage* self, ModestAccountSettings *settings);
+
+ /* Signals */
+ void (*missing_mandatory_data) (ModestEasysetupWizardPage* self,
+ gboolean missing,
+ gpointer user_data);
+};
+
+GType modest_easysetup_wizard_page_get_type (void) G_GNUC_CONST;
+
+gboolean modest_easysetup_wizard_page_validate (ModestEasysetupWizardPage *self);
+
+void modest_easysetup_wizard_page_save_settings (ModestEasysetupWizardPage *self,
+ ModestAccountSettings *settings);
+
+G_END_DECLS
+
+#endif /* __MODEST_EASYSETUP_WIZARD_PAGE_H__ */
#define _MODEST_LIMIT_RETRIEVE_COMBO_BOX
#include <gtk/gtkcombobox.h>
-#include "modest-protocol-info.h"
G_BEGIN_DECLS
static GtkShadowType modest_mozembed_msg_view_get_shadow_type (ModestMsgView *self);
static TnyHeaderFlags modest_mozembed_msg_view_get_priority (ModestMsgView *self);
static void modest_mozembed_msg_view_set_priority (ModestMsgView *self, TnyHeaderFlags flags);
-static GList *modest_mozembed_msg_view_get_selected_attachments (ModestMsgView *self);
-static GList *modest_mozembed_msg_view_get_attachments (ModestMsgView *self);
+static TnyList *modest_mozembed_msg_view_get_selected_attachments (ModestMsgView *self);
+static TnyList *modest_mozembed_msg_view_get_attachments (ModestMsgView *self);
static void modest_mozembed_msg_view_grab_focus (ModestMsgView *self);
static void modest_mozembed_msg_view_remove_attachment (ModestMsgView *view, TnyMimePart *attachment);
static GtkAdjustment *modest_mozembed_msg_view_get_vadjustment_default (ModestMsgView *self);
static GtkShadowType modest_mozembed_msg_view_get_shadow_type_default (ModestMsgView *self);
static TnyHeaderFlags modest_mozembed_msg_view_get_priority_default (ModestMsgView *self);
static void modest_mozembed_msg_view_set_priority_default (ModestMsgView *self, TnyHeaderFlags flags);
-static GList *modest_mozembed_msg_view_get_selected_attachments_default (ModestMsgView *self);
-static GList *modest_mozembed_msg_view_get_attachments_default (ModestMsgView *self);
+static TnyList *modest_mozembed_msg_view_get_selected_attachments_default (ModestMsgView *self);
+static TnyList *modest_mozembed_msg_view_get_attachments_default (ModestMsgView *self);
static void modest_mozembed_msg_view_grab_focus_default (ModestMsgView *self);
static void modest_mozembed_msg_view_remove_attachment_default (ModestMsgView *view, TnyMimePart *attachment);
static GtkShadowType get_shadow_type (ModestMozembedMsgView *self);
static TnyHeaderFlags get_priority (ModestMozembedMsgView *self);
static void set_priority (ModestMozembedMsgView *self, TnyHeaderFlags flags);
-static GList *get_selected_attachments (ModestMozembedMsgView *self);
-static GList *get_attachments (ModestMozembedMsgView *self);
+static TnyList *get_selected_attachments (ModestMozembedMsgView *self);
+static TnyList *get_attachments (ModestMozembedMsgView *self);
static void grab_focus (ModestMozembedMsgView *self);
static void remove_attachment (ModestMozembedMsgView *view, TnyMimePart *attachment);
gtk_box_pack_start (GTK_BOX (main_vbox), body_box, TRUE, TRUE, 0);
if (priv->body_view) {
- gtk_widget_set_size_request (priv->body_view, -1, 1000);
- scroll_area = modest_scroll_area_new (GTK_WIDGET (obj), priv->body_view);
- gtk_container_add (GTK_CONTAINER (body_box), scroll_area);
+ /* gtk_widget_set_size_request (priv->body_view, 610, 1000); */
+ /* scroll_area = modest_scroll_area_new (GTK_WIDGET (obj), priv->body_view); */
+ /* gtk_container_add (GTK_CONTAINER (body_box), scroll_area); */
-/* gtk_container_add (GTK_CONTAINER (body_box), priv->body_view); */
-/* scroll_area = NULL; */
+ /* gtk_container_add (GTK_CONTAINER (body_box), priv->body_view); */
+ /* scroll_area = NULL; */
-/* scroll_area = gtk_scrolled_window_new (NULL, NULL); */
-/* gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_area), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); */
-/* gtk_container_add (GTK_CONTAINER (scroll_area), priv->body_view); */
-/* gtk_container_add (GTK_CONTAINER (body_box), scroll_area); */
+ scroll_area = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_area), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll_area), priv->body_view);
+ gtk_box_pack_start (GTK_BOX (body_box), scroll_area, TRUE, TRUE, 0);
+ gtk_widget_show_all (body_box);
#if HAVE_DECL_GTK_WIDGET_TAP_AND_HOLD_SETUP
gtk_widget_tap_and_hold_setup (GTK_WIDGET (priv->body_view), NULL, NULL, 0);
return result;
}
-static GList *
+static TnyList *
get_selected_attachments (ModestMozembedMsgView *self)
{
ModestMozembedMsgViewPrivate *priv;
}
-static GList *
+static TnyList *
get_attachments (ModestMozembedMsgView *self)
{
ModestMozembedMsgViewPrivate *priv;
{
TnyMsgViewIface *klass = (TnyMsgViewIface *)g;
- klass->get_msg_func = modest_msg_view_get_msg;
- klass->set_msg_func = modest_msg_view_set_msg;
- klass->set_unavailable_func = modest_msg_view_set_unavailable;
- klass->clear_func = modest_msg_view_clear;
- klass->create_mime_part_view_for_func = modest_msg_view_create_mime_part_view_for;
- klass->create_new_inline_viewer_func = modest_msg_view_create_new_inline_viewer;
+ klass->get_msg = modest_msg_view_get_msg;
+ klass->set_msg = modest_msg_view_set_msg;
+ klass->set_unavailable = modest_msg_view_set_unavailable;
+ klass->clear = modest_msg_view_clear;
+ klass->create_mime_part_view_for = modest_msg_view_create_mime_part_view_for;
+ klass->create_new_inline_viewer = modest_msg_view_create_new_inline_viewer;
return;
}
{
TnyMimePartViewIface *klass = (TnyMimePartViewIface *)g;
- klass->get_part_func = modest_msg_view_mp_get_part;
- klass->set_part_func = modest_msg_view_mp_set_part;
- klass->clear_func = modest_msg_view_mp_clear;
+ klass->get_part = modest_msg_view_mp_get_part;
+ klass->set_part = modest_msg_view_mp_set_part;
+ klass->clear = modest_msg_view_mp_clear;
return;
}
return get_priority (MODEST_MOZEMBED_MSG_VIEW (self));
}
-static GList*
+static TnyList*
modest_mozembed_msg_view_get_selected_attachments (ModestMsgView *self)
{
return MODEST_MOZEMBED_MSG_VIEW_GET_CLASS (self)->get_selected_attachments_func (self);
}
-static GList*
+static TnyList*
modest_mozembed_msg_view_get_selected_attachments_default (ModestMsgView *self)
{
return get_selected_attachments (MODEST_MOZEMBED_MSG_VIEW (self));
}
-static GList*
+static TnyList*
modest_mozembed_msg_view_get_attachments (ModestMsgView *self)
{
return MODEST_MOZEMBED_MSG_VIEW_GET_CLASS (self)->get_attachments_func (self);
}
-static GList*
+static TnyList*
modest_mozembed_msg_view_get_attachments_default (ModestMsgView *self)
{
return get_attachments (MODEST_MOZEMBED_MSG_VIEW (self));
GtkShadowType (*get_shadow_type_func) (ModestMsgView *self);
TnyHeaderFlags (*get_priority_func) (ModestMsgView *self);
void (*set_priority_func) (ModestMsgView *self, TnyHeaderFlags flags);
- GList * (*get_selected_attachments_func) (ModestMsgView *self);
- GList * (*get_attachments_func) (ModestMsgView *self);
+ TnyList * (*get_selected_attachments_func) (ModestMsgView *self);
+ TnyList * (*get_attachments_func) (ModestMsgView *self);
void (*grab_focus_func) (ModestMsgView *self);
void (*remove_attachment_func) (ModestMsgView *view, TnyMimePart *attachment);
msg = g_strdup(_("mail_me_sending"));
break;
- case MODEST_MAIL_OPERATION_TYPE_OPEN:
- msg = g_strdup(_("mail_me_opening"));
- break;
default:
msg = g_strdup("");
}
MODEL_COL_RETRIEVE_TYPE = 1 /* a gint (a ModestAccountRetrieveType) */
};
-void modest_retrieve_combo_box_fill (ModestRetrieveComboBox *combobox, ModestTransportStoreProtocol protocol);
+void modest_retrieve_combo_box_fill (ModestRetrieveComboBox *combobox, ModestProtocolType protocol);
static void
modest_retrieve_combo_box_init (ModestRetrieveComboBox *self)
* #combobox: The combo box.
* @protocol: IMAP or POP.
*/
-void modest_retrieve_combo_box_fill (ModestRetrieveComboBox *combobox, ModestTransportStoreProtocol protocol)
+void modest_retrieve_combo_box_fill (ModestRetrieveComboBox *combobox, ModestProtocolType protocol)
{
ModestRetrieveComboBoxPrivate *priv = RETRIEVE_COMBO_BOX_GET_PRIVATE (combobox);
#define _MODEST_RETRIEVE_COMBO_BOX
#include <gtk/gtkcombobox.h>
-#include "modest-protocol-info.h"
+#include "modest-protocol-registry.h"
#include <modest-account-settings.h>
G_BEGIN_DECLS
ModestRetrieveComboBox* modest_retrieve_combo_box_new (void);
-void modest_retrieve_combo_box_fill (ModestRetrieveComboBox *combobox, ModestTransportStoreProtocol protocol);
+void modest_retrieve_combo_box_fill (ModestRetrieveComboBox *combobox, ModestProtocolType protocol);
ModestAccountRetrieveType modest_retrieve_combo_box_get_active_retrieve_conf (ModestRetrieveComboBox *combobox);
*/
#include "modest-secureauth-combo-box.h"
+#include <modest-runtime.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtkcelllayout.h>
#include <gtk/gtkcellrenderertext.h>
*/
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);
+ }
}
/**
* Returns the selected secureauth,
- * or MODEST_PROTOCOL_AUTH_NONE if no secureauth was selected.
+ * or MODEST_PROTOCOL_REGISTRY_TYPE_INVALID if no secureauth was selected.
*/
-ModestAuthProtocol
+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);
- ModestAuthProtocol secureauth = MODEST_PROTOCOL_AUTH_NONE;
+ ModestProtocolType secureauth = MODEST_PROTOCOLS_AUTH_NONE;
gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &secureauth, -1);
return secureauth;
}
- return MODEST_PROTOCOL_AUTH_NONE; /* 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_AUTH_NONE 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, ModestAuthProtocol 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);
#define _MODEST_SECUREAUTH_COMBO_BOX
#include <gtk/gtkcombobox.h>
-#include "modest-protocol-info.h"
+#include "modest-protocol-registry.h"
G_BEGIN_DECLS
ModestSecureauthComboBox* modest_secureauth_combo_box_new (void);
-ModestAuthProtocol modest_secureauth_combo_box_get_active_secureauth (ModestSecureauthComboBox *combobox);
+ModestProtocolType modest_secureauth_combo_box_get_active_secureauth (ModestSecureauthComboBox *combobox);
gboolean modest_secureauth_combo_box_set_active_secureauth (ModestSecureauthComboBox *combobox,
- ModestAuthProtocol secureauth);
+ ModestProtocolType secureauth);
G_END_DECLS
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+#ifndef __MODEST_SECURITY_OPTIONS_VIEW_PRIV_H__
+#define __MODEST_SECURITY_OPTIONS_VIEW_PRIV_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "modest-account-settings.h"
+#include "modest-protocol.h"
+
+G_BEGIN_DECLS
+
+typedef struct _ModestSecurityOptionsState {
+ ModestProtocolType security;
+ ModestProtocolType auth;
+ gint port;
+ const gchar *user;
+ const gchar *pwd;
+} ModestSecurityOptionsState;
+
+typedef struct _ModestSecurityOptionsViewPrivate ModestSecurityOptionsViewPrivate;
+struct _ModestSecurityOptionsViewPrivate {
+ /* Common widgets */
+ GtkWidget *security_view;
+ GtkWidget *port_view;
+ GtkWidget *auth_view;
+
+ /* outgoing specific widgets */
+ GtkWidget *user_entry;
+ GtkWidget *pwd_entry;
+
+ gboolean full; /* full=TRUE means all options */
+ gboolean changed;
+
+ ModestSecurityOptionsState initial_state;
+};
+
+#define MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+ MODEST_TYPE_SECURITY_OPTIONS_VIEW, \
+ ModestSecurityOptionsViewPrivate))
+
+G_END_DECLS
+
+#endif /* __MODEST_SECURITY_OPTIONS_VIEW_PRIV_H__ */
+
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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 <string.h>
+#include <gtk/gtkvbox.h>
+#include "modest-utils.h"
+#include "modest-runtime.h"
+#include "modest-platform.h"
+#include "modest-security-options-view.h"
+#include "modest-security-options-view-priv.h"
+#include "widgets/modest-serversecurity-combo-box.h"
+#include "widgets/modest-secureauth-combo-box.h"
+
+/* list my signals */
+enum {
+ MISSING_MANDATORY_DATA_SIGNAL,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+void
+modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings)
+{
+ ModestSecurityOptionsViewPrivate *priv;
+ ModestServerAccountSettings *server_settings;
+ ModestProtocolType server_proto, secure_protocol, secure_auth;
+ ModestServersecurityComboBox *combo;
+
+ priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ /* Save initial settings */
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+ server_settings = modest_account_settings_get_store_settings (settings);
+ else
+ server_settings = modest_account_settings_get_transport_settings (settings);
+
+ server_proto = modest_server_account_settings_get_protocol (server_settings);
+ secure_protocol = modest_server_account_settings_get_security_protocol (server_settings);
+ secure_auth = modest_server_account_settings_get_auth_protocol (server_settings);
+
+ priv->initial_state.security = secure_protocol;
+ priv->initial_state.auth = secure_auth;
+ priv->initial_state.port = modest_server_account_settings_get_port (server_settings);
+
+ /* Update UI */
+ combo = MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view);
+ modest_security_options_view_set_server_type (self, server_proto);
+ modest_serversecurity_combo_box_set_active_serversecurity (combo, secure_protocol);
+
+/* update_incoming_server_title (dialog, dialog->incoming_protocol); */
+
+ /* Username and password */
+ if (priv->full && self->type == MODEST_SECURITY_OPTIONS_OUTGOING) {
+ priv->initial_state.user =
+ modest_server_account_settings_get_username (server_settings);
+ priv->initial_state.pwd =
+ modest_server_account_settings_get_password (server_settings);
+
+ if (priv->initial_state.user)
+ gtk_entry_set_text(GTK_ENTRY (priv->user_entry),
+ priv->initial_state.user);
+ if (priv->initial_state.pwd)
+ gtk_entry_set_text(GTK_ENTRY (priv->pwd_entry),
+ priv->initial_state.pwd);
+ }
+
+ /* Set auth */
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING) {
+ /* Active the authentication checkbox */
+ if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (),
+ secure_auth))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->auth_view),
+ TRUE);
+ } else {
+ modest_secureauth_combo_box_set_active_secureauth (
+ MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view), secure_auth);
+ }
+
+ MODEST_SECURITY_OPTIONS_VIEW_GET_CLASS (self)->load_settings (self, settings);
+
+ /* Free */
+ g_object_unref (server_settings);
+}
+
+void
+modest_security_options_view_save_settings (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings)
+{
+ ModestServerAccountSettings *server_settings;
+ ModestProtocolType security_proto, auth_protocol;
+ ModestSecurityOptionsViewPrivate *priv;
+ ModestProtocolRegistry *proto_registry;
+
+ priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+ proto_registry = modest_runtime_get_protocol_registry ();
+
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+ server_settings = modest_account_settings_get_store_settings (settings);
+ else
+ server_settings = modest_account_settings_get_transport_settings (settings);
+
+ /* initialize */
+ security_proto = MODEST_PROTOCOLS_CONNECTION_NONE;
+ auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
+
+ /* Get data */
+ security_proto = modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING) {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view))) {
+ if (!modest_protocol_registry_protocol_type_is_secure (proto_registry,
+ security_proto)) {
+ /* TODO */
+ /* auth_protocol = check_first_supported_auth_method (self); */
+ auth_protocol = MODEST_PROTOCOLS_AUTH_PASSWORD;
+ } else {
+ auth_protocol = MODEST_PROTOCOLS_AUTH_PASSWORD;
+ }
+ }
+ } else {
+ auth_protocol = modest_secureauth_combo_box_get_active_secureauth (
+ MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view));
+ }
+
+ /* Save settings */
+ modest_server_account_settings_set_security_protocol (server_settings,
+ security_proto);
+ modest_server_account_settings_set_auth_protocol (server_settings,
+ auth_protocol);
+
+ if (priv->full && self->type == MODEST_SECURITY_OPTIONS_OUTGOING) {
+ const gchar *username, *password;
+
+ username = gtk_entry_get_text (GTK_ENTRY (priv->user_entry));
+ password = gtk_entry_get_text (GTK_ENTRY (priv->pwd_entry));
+
+ modest_server_account_settings_set_username (server_settings, username);
+ modest_server_account_settings_set_password (server_settings, password);
+ }
+
+ MODEST_SECURITY_OPTIONS_VIEW_GET_CLASS (self)->save_settings (self, settings);
+
+
+ /* Free */
+ g_object_unref (server_settings);
+}
+
+void
+modest_security_options_view_set_server_type (ModestSecurityOptionsView* self,
+ ModestProtocolType server_type)
+{
+ ModestSecurityOptionsViewPrivate *priv;
+ ModestServersecurityComboBox *combo;
+
+ priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+ combo = MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view);
+
+ modest_serversecurity_combo_box_fill (combo, server_type);
+ modest_serversecurity_combo_box_set_active_serversecurity (combo,
+ MODEST_PROTOCOLS_CONNECTION_NONE);
+}
+
+static void
+get_current_state (ModestSecurityOptionsView* self,
+ ModestSecurityOptionsState *state)
+{
+ ModestSecurityOptionsViewPrivate *priv;
+ ModestProtocolRegistry *proto_registry;
+
+ priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+ proto_registry = modest_runtime_get_protocol_registry ();
+
+ /* Get security */
+ state->security =
+ modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+
+ /* Get auth */
+ if (self->type == MODEST_SECURITY_OPTIONS_OUTGOING) {
+ state->auth = modest_secureauth_combo_box_get_active_secureauth (MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view));
+ if (priv->full) {
+ }
+ } else {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view)))
+ state->auth = priv->initial_state.auth;
+ else
+ state->auth = MODEST_PROTOCOLS_AUTH_NONE;
+ }
+}
+
+gboolean
+modest_security_options_view_changed (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings)
+{
+ ModestSecurityOptionsViewPrivate *priv;
+ ModestSecurityOptionsState state = {0};
+
+ priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ get_current_state (self, &state);
+
+ if (state.security != priv->initial_state.security ||
+ state.auth != priv->initial_state.auth)
+ return TRUE;
+
+ if (priv->full && self->type == MODEST_SECURITY_OPTIONS_OUTGOING) {
+ const gchar *username, *password;
+
+ username = gtk_entry_get_text (GTK_ENTRY (priv->user_entry));
+ password = gtk_entry_get_text (GTK_ENTRY (priv->pwd_entry));
+
+ if (!priv->initial_state.user && strcmp (username, ""))
+ return TRUE;
+ if (!priv->initial_state.pwd && strcmp (password, ""))
+ return TRUE;
+
+ if ((priv->initial_state.user &&
+ strcmp (priv->initial_state.user, username)) ||
+ (priv->initial_state.pwd &&
+ strcmp (priv->initial_state.pwd, password)))
+ return TRUE;
+ }
+
+ /* Check subclass */
+ return MODEST_SECURITY_OPTIONS_VIEW_GET_CLASS (self)->changed (self, settings);
+}
+
+void
+modest_security_options_view_enable_changes (ModestSecurityOptionsView* self,
+ gboolean enable)
+{
+ ModestSecurityOptionsViewPrivate *priv;
+
+ priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+ gtk_widget_set_sensitive (priv->port_view, enable);
+ gtk_widget_set_sensitive (priv->security_view, enable);
+}
+
+gboolean
+modest_security_options_view_auth_check (ModestSecurityOptionsView* self)
+{
+ ModestSecurityOptionsViewPrivate *priv;
+ ModestProtocolType security_incoming_type;
+ gboolean auth_active, is_secure;
+ ModestProtocolRegistry *protocol_registry;
+
+ priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+ protocol_registry = modest_runtime_get_protocol_registry ();
+
+ /* Check if the server supports secure authentication */
+ security_incoming_type =
+ modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+
+ auth_active =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view));
+ is_secure =
+ modest_protocol_registry_protocol_type_has_tag (protocol_registry,
+ security_incoming_type,
+ MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS);
+
+ if (auth_active && !is_secure)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+GList*
+modest_security_options_view_get_supported_auth_methods (ModestSecurityOptionsView *self,
+ const gchar *hostname,
+ const gchar *username,
+ ModestProtocolType server_type)
+{
+ GtkWindow *window;
+ GError *error = NULL;
+ GList *list_auth_methods, *retval = NULL;
+ ModestSecurityOptionsViewPrivate *priv;
+ ModestAccountSettings current_settings;
+ ModestServerAccountSettings *server_settings;
+
+ priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ window = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW));
+
+ /* Get current settings */
+ modest_security_options_view_save_settings (self, ¤t_settings);
+
+ if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+ server_settings = modest_account_settings_get_store_settings (¤t_settings);
+ else
+ server_settings = modest_account_settings_get_transport_settings (¤t_settings);
+
+ list_auth_methods =
+ modest_utils_get_supported_secure_authentication_methods (server_type,
+ hostname,
+ modest_server_account_settings_get_port (server_settings),
+ username,
+ window,
+ &error);
+
+ if (list_auth_methods) {
+ GList *list = NULL, *method = NULL;
+ ModestProtocolRegistry *registry = modest_runtime_get_protocol_registry ();
+
+ for (method = list_auth_methods; method != NULL; method = g_list_next(method)) {
+ ModestProtocolType auth_protocol_type =
+ (ModestProtocolType) (GPOINTER_TO_INT(method->data));
+ if (modest_protocol_registry_protocol_type_is_secure (registry,
+ auth_protocol_type)) {
+ list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type));
+ }
+ }
+ g_list_free(list_auth_methods);
+ if (list) {
+ retval = list;
+ goto end;
+ }
+ }
+
+ if(error == NULL ||
+ error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
+ error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED) {
+ modest_platform_information_banner (GTK_WIDGET(self),
+ NULL,
+ _("mcen_ib_unableto_discover_auth_methods"));
+ }
+
+ if(error != NULL)
+ g_error_free(error);
+
+ end:
+ /* Frees */
+ g_object_unref (server_settings);
+
+ return retval;
+}
+
+static void
+modest_security_options_view_init (ModestSecurityOptionsView *self)
+{
+ ModestSecurityOptionsViewPrivate *priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+ memset (&(priv->initial_state), 0, sizeof (ModestSecurityOptionsState));
+
+ priv->security_view = NULL;
+ priv->port_view = NULL;
+ priv->auth_view = NULL;
+ priv->user_entry = NULL;
+ priv->pwd_entry = NULL;
+}
+
+static void
+modest_security_options_view_class_init (ModestSecurityOptionsViewClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass*) klass;
+
+ g_type_class_add_private (gobject_class, sizeof (ModestSecurityOptionsViewPrivate));
+
+ /* Register signals */
+ signals[MISSING_MANDATORY_DATA_SIGNAL] =
+ g_signal_new ("missing_mandatory_data",
+ MODEST_TYPE_SECURITY_OPTIONS_VIEW,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(ModestSecurityOptionsViewClass, missing_mandatory_data),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+}
+
+/* Type definition */
+G_DEFINE_ABSTRACT_TYPE (ModestSecurityOptionsView,
+ modest_security_options_view,
+ GTK_TYPE_VBOX);
--- /dev/null
+/* Copyright (c) 2008, Nokia Corporation
+ * 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.
+ */
+
+#ifndef __MODEST_SECURITY_OPTIONS_VIEW_H__
+#define __MODEST_SECURITY_OPTIONS_VIEW_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "modest-account-settings.h"
+#include "modest-protocol.h"
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_SECURITY_OPTIONS_VIEW (modest_security_options_view_get_type())
+#define MODEST_SECURITY_OPTIONS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_SECURITY_OPTIONS_VIEW,ModestSecurityOptionsView))
+#define MODEST_SECURITY_OPTIONS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_SECURITY_OPTIONS_VIEW,ModestSecurityOptionsViewClass))
+#define MODEST_IS_SECURITY_OPTIONS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_SECURITY_OPTIONS_VIEW))
+#define MODEST_IS_SECURITY_OPTIONS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_SECURITY_OPTIONS_VIEW))
+#define MODEST_SECURITY_OPTIONS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_SECURITY_OPTIONS_VIEW,ModestSecurityOptionsViewClass))
+
+typedef enum {
+ MODEST_SECURITY_OPTIONS_INCOMING,
+ MODEST_SECURITY_OPTIONS_OUTGOING,
+} ModestSecurityOptionsType;
+
+typedef struct _ModestSecurityOptionsView ModestSecurityOptionsView;
+typedef struct _ModestSecurityOptionsViewClass ModestSecurityOptionsViewClass;
+
+struct _ModestSecurityOptionsView {
+ GtkVBox parent;
+
+ /* Incoming or outgoing */
+ ModestSecurityOptionsType type;
+};
+
+struct _ModestSecurityOptionsViewClass {
+ GtkVBoxClass parent_class;
+
+ void (*load_settings) (ModestSecurityOptionsView* self, ModestAccountSettings *settings);
+ void (*save_settings) (ModestSecurityOptionsView* self, ModestAccountSettings *settings);
+ gboolean (*changed) (ModestSecurityOptionsView* self, ModestAccountSettings *settings);
+
+ /* Signals */
+ void (*missing_mandatory_data) (ModestSecurityOptionsView* self,
+ gboolean missing,
+ gpointer user_data);
+};
+
+GType modest_security_options_view_get_type (void) G_GNUC_CONST;
+
+void modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings);
+
+void modest_security_options_view_save_settings (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings);
+
+void modest_security_options_view_set_server_type (ModestSecurityOptionsView* self,
+ ModestProtocolType server_type);
+
+gboolean modest_security_options_view_changed (ModestSecurityOptionsView* self,
+ ModestAccountSettings *settings);
+
+void modest_security_options_view_enable_changes (ModestSecurityOptionsView* self,
+ gboolean enable);
+
+/**
+ * modest_security_options_view_auth_check:
+ * @self: a #ModestSecurityOptionsView
+ *
+ * checks if the supported authentication methods for the server
+ * should be checked. This happens when the user have checked the
+ * "require auth" option but is not selecting a secure protocol (like
+ * TLS or SSL)
+ *
+ * Returns: TRUE if require auth is true and no security protocol is
+ * selected
+ **/
+gboolean modest_security_options_view_auth_check (ModestSecurityOptionsView* self);
+
+G_END_DECLS
+
+#endif /* __MODEST_SECURITY_OPTIONS_VIEW_H__ */
+
#include "modest-serversecurity-combo-box.h"
+#include <modest-runtime.h>
+#include <modest-account-protocol.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtkcelllayout.h>
#include <gtk/gtkcellrenderertext.h>
struct _ModestServersecurityComboBoxPrivate
{
GtkTreeModel *model;
- ModestConnectionProtocol protocol;
+ ModestProtocolType protocol;
};
static void
* #combobox: The combo box.
* @protocol: IMAP or POP.
*/
-void modest_serversecurity_combo_box_fill (ModestServersecurityComboBox *combobox, ModestTransportStoreProtocol protocol)
+void modest_serversecurity_combo_box_fill (ModestServersecurityComboBox *combobox, ModestProtocolType protocol_type)
{
- ModestServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
- priv->protocol = protocol; /* Remembered for later. */
+ ModestServersecurityComboBoxPrivate *priv;
+ ModestProtocol *protocol;
+
+ priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
+ priv->protocol = protocol_type; /* Remembered for later. */
+ protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+ protocol_type);
/* Remove any existing rows: */
GtkListStore *liststore = GTK_LIST_STORE (priv->model);
GtkTreeIter iter;
gtk_list_store_append (liststore, &iter);
/* TODO: This logical ID is not in the .po file: */
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_CONNECTION_NORMAL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_none"), -1);
-
- /* Select the None item: */
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint) MODEST_PROTOCOLS_CONNECTION_NONE, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_none"), -1);
gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_CONNECTION_TLS, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_normal"), -1);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOLS_CONNECTION_TLS, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_normal"), -1);
/* Add security choices with protocol-specific names, as in the UI spec:
* (Note: Changing the title seems pointless. murrayc) */
- if(protocol == MODEST_PROTOCOL_STORE_POP) {
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_CONNECTION_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_securepop3s"), -1);
- } else if(protocol == MODEST_PROTOCOL_STORE_IMAP) {
+ gchar *protocol_name = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_SSL_PROTO_NAME);
+ if (protocol_name) {
gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_CONNECTION_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_secureimap4s"), -1);
- } else if(protocol == MODEST_PROTOCOL_TRANSPORT_SMTP) {
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOLS_CONNECTION_SSL, MODEL_COL_NAME, protocol_name, -1);
+ g_free (protocol_name);
+ } else {
+ /* generic fallback */
gtk_list_store_append (liststore, &iter);
- gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOL_CONNECTION_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_ssl"), -1);
+ gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOLS_CONNECTION_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_ssl"), -1);
}
}
-static gint get_port_for_security (ModestTransportStoreProtocol protocol, ModestConnectionProtocol security)
+static gint get_port_for_security (ModestProtocolType protocol_type, ModestProtocolType security_type)
{
/* See the UI spec, section Email Wizards, Incoming Details [MSG-WIZ001]: */
gint result = 0;
+ ModestProtocol *protocol, *security;
+ ModestProtocolRegistry *protocol_registry;
+ gboolean use_alternate_port;
+
+ protocol_registry = modest_runtime_get_protocol_registry ();
+ protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
+ security = modest_protocol_registry_get_protocol_by_type (protocol_registry, security_type);
+
+ g_return_val_if_fail ((security != NULL && protocol != NULL), 0);
+
+ use_alternate_port = modest_protocol_registry_protocol_type_has_tag (protocol_registry, security_type,
+ MODEST_PROTOCOL_REGISTRY_USE_ALTERNATE_PORT);
/* Get the default port number for this protocol with this security: */
- if(protocol == MODEST_PROTOCOL_STORE_POP) {
- if ((security == MODEST_PROTOCOL_CONNECTION_NORMAL) || (security == MODEST_PROTOCOL_CONNECTION_TLS))
- result = 110;
- else if (security == MODEST_PROTOCOL_CONNECTION_SSL)
- result = 995;
- } else if (protocol == MODEST_PROTOCOL_STORE_IMAP) {
- if ((security == MODEST_PROTOCOL_CONNECTION_NORMAL) || (security == MODEST_PROTOCOL_CONNECTION_TLS))
- result = 143;
- else if (security == MODEST_PROTOCOL_CONNECTION_SSL)
- result = 993;
- } else if (protocol == MODEST_PROTOCOL_TRANSPORT_SMTP) {
- if ((security == MODEST_PROTOCOL_CONNECTION_NORMAL) || (security == MODEST_PROTOCOL_CONNECTION_TLS))
- result = 25;
- else if (security == MODEST_PROTOCOL_CONNECTION_SSL)
- result = 465;
+ if (use_alternate_port) {
+ result = modest_account_protocol_get_alternate_port (MODEST_ACCOUNT_PROTOCOL (protocol));
+ } else {
+ result = modest_account_protocol_get_port (MODEST_ACCOUNT_PROTOCOL (protocol));
}
return result;
/**
* Returns the selected serversecurity,
- * or MODEST_PROTOCOL_CONNECTION_NORMAL if no serversecurity was selected.
+ * or MODEST_PROTOCOLS_CONNECTION_NONE if no serversecurity was selected.
*/
-ModestConnectionProtocol
+ModestProtocolType
modest_serversecurity_combo_box_get_active_serversecurity (ModestServersecurityComboBox *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) {
ModestServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
- ModestConnectionProtocol serversecurity = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ ModestProtocolType serversecurity = MODEST_PROTOCOLS_CONNECTION_NONE;
gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &serversecurity, -1);
return serversecurity;
}
- return MODEST_PROTOCOL_CONNECTION_NORMAL; /* Failed. */
+ return MODEST_PROTOCOLS_CONNECTION_NONE; /* Failed. */
}
/**
{
ModestServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
- const ModestConnectionProtocol security = modest_serversecurity_combo_box_get_active_serversecurity
+ ModestProtocolType security = modest_serversecurity_combo_box_get_active_serversecurity
(combobox);
return get_port_for_security (priv->protocol, security);
}
typedef struct
{
ModestServersecurityComboBox* self;
- gint id;
+ ModestProtocolType id;
gboolean found;
} ForEachData;
ForEachData *state = (ForEachData*)(user_data);
/* Select the item if it has the matching ID: */
- guint id = 0;
+ ModestProtocolType id = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
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 serversecurity,
- * or MODEST_PROTOCOL_CONNECTION_NORMAL if no serversecurity was selected.
+ * or MODEST_PROTOCOLS_CONNECTION_NONE if no serversecurity was selected.
*/
gboolean
modest_serversecurity_combo_box_set_active_serversecurity (ModestServersecurityComboBox *combobox,
- ModestConnectionProtocol serversecurity)
+ ModestProtocolType serversecurity)
{
ModestServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox);
#define _MODEST_SERVERSECURITY_COMBO_BOX
#include <gtk/gtkcombobox.h>
-#include "modest-protocol-info.h"
+#include "modest-protocol-registry.h"
G_BEGIN_DECLS
ModestServersecurityComboBox* modest_serversecurity_combo_box_new (void);
-void modest_serversecurity_combo_box_fill (ModestServersecurityComboBox *combobox, ModestTransportStoreProtocol protocol);
+void modest_serversecurity_combo_box_fill (ModestServersecurityComboBox *combobox, ModestProtocolType protocol);
-ModestConnectionProtocol modest_serversecurity_combo_box_get_active_serversecurity (ModestServersecurityComboBox *combobox);
+ModestProtocolType modest_serversecurity_combo_box_get_active_serversecurity (ModestServersecurityComboBox *combobox);
gboolean modest_serversecurity_combo_box_set_active_serversecurity (ModestServersecurityComboBox *combobox,
- ModestConnectionProtocol serversecurity);
+ ModestProtocolType serversecurity);
gint modest_serversecurity_combo_box_get_active_serversecurity_port (ModestServersecurityComboBox *combobox);
#include "modest-tny-platform-factory.h"
#include "modest-runtime.h"
#include "modest-window-mgr.h"
+#include "modest-defs.h"
#include <string.h> /* for strcmp */
#include <gdk/gdkkeysyms.h>
#endif /*MODEST_PLATFORM_MAEMO*/
#include "modest-wizard-dialog.h"
-
-#include <libintl.h>
-
-#ifdef MODEST_PLATFORM_MAEMO
-/* Specify the hildon-libs translation domain,
- * so we can reuse its translations
- * instead of repeating them in our own translations.
- */
-/* #define _(String) dgettext(PACKAGE, String) */
-
-#define _(String) dgettext("hildon-libs", String)
-#else
-#define _(String) gettext(String)
-#endif
+#include "modest-debug.h"
+#include "modest-text-utils.h"
static GtkDialogClass *parent_class;
/* Add response buttons: finish, previous, next, cancel */
#ifdef MODEST_PLATFORM_MAEMO
- gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_finish"), MODEST_WIZARD_DIALOG_FINISH);
- gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_previous"), MODEST_WIZARD_DIALOG_PREVIOUS);
- gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_next"), MODEST_WIZARD_DIALOG_NEXT);
- gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_cancel"), MODEST_WIZARD_DIALOG_CANCEL);
+ gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_finish"), MODEST_WIZARD_DIALOG_FINISH);
+ gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_previous"), MODEST_WIZARD_DIALOG_PREVIOUS);
+ gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_next"), MODEST_WIZARD_DIALOG_NEXT);
+ gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_cancel"), MODEST_WIZARD_DIALOG_CANCEL);
#else
gtk_dialog_add_button (dialog, GTK_STOCK_SAVE, MODEST_WIZARD_DIALOG_FINISH);
gtk_dialog_add_button (dialog, GTK_STOCK_GO_BACK, MODEST_WIZARD_DIALOG_PREVIOUS);
* but the Modest UI spec does not want this. */
/*
if (current == 0) {
- str = g_strdup_printf (_("ecdg_ti_wizard_welcome"),
+ str = g_strdup_printf (_HL("ecdg_ti_wizard_welcome"),
priv->wizard_name, pages);
} else {
*/
* but the Modest UI spec does not want this.
*/
/*
- str = g_strdup_printf (_("ecdg_ti_wizard_step"),
+ str = g_strdup_printf (_HL("ecdg_ti_wizard_step"),
priv->wizard_name, current + 1, pages, steps);
*/
- str = g_strdup_printf (_("%s: %s"),
+ str = g_strdup_printf (_HL("%s: %s"),
priv->wizard_name, steps);
/* } */
case MODEST_WIZARD_DIALOG_NEXT:
if (invoke_before_next_vfunc (wizard_dialog))
- gtk_notebook_next_page (notebook); /* go to next page */
+ gtk_notebook_next_page (notebook); /* go to next page */
break;
GtkWidget* next_page_widget = NULL;
if ((current_page_num + 1) < gtk_notebook_get_n_pages (priv->notebook))
next_page_widget = gtk_notebook_get_nth_page (priv->notebook, current_page_num + 1);
+
+ MODEST_DEBUG_BLOCK (
+ g_debug ("Switching to page %d (%s)",
+ gtk_notebook_page_num (priv->notebook, next_page_widget),
+ gtk_notebook_get_tab_label_text (priv->notebook, next_page_widget));
+
+ {
+ GtkWidget *p;
+ gint i;
+ g_debug ("\t***************");
+ for (i=0; i<gtk_notebook_get_n_pages(priv->notebook);i++) {
+ p = gtk_notebook_get_nth_page (priv->notebook, i);
+ g_debug ("\t%d - %s", i, gtk_notebook_get_tab_label_text (priv->notebook, p));
+ }
+ g_debug ("\t***************");
+ }
+ );
/* Ask the vfunc implementation whether navigation should be allowed: */
return (*(klass->before_next))(wizard_dialog, current_page_widget, next_page_widget);