Modified webpage: now tinymail repository is in gitorious.
[modest] / src / widgets / modest-global-settings-dialog.c
index cdcddff..59cd35c 100644 (file)
  */
 
 #include <glib/gi18n.h>
-#include "modest-global-settings-dialog.h"
+#include <gtk/gtk.h>
+#include <string.h>
+#include "widgets/modest-global-settings-dialog.h"
+#include "widgets/modest-global-settings-dialog-priv.h"
 #include "modest-defs.h"
+#include "modest-conf.h"
+#include "modest-runtime.h"
 #include "modest-ui-constants.h"
-#include "widgets/modest-combo-box.h"
+#include "modest-tny-msg.h"
+#include "modest-platform.h"
+#ifdef MODEST_TOOLKIT_HILDON2
+#include "modest-hildon-includes.h"
+#include <hildon/hildon-number-editor.h>
+#endif
 /* include other impl specific header files */
 
+#define RETURN_FALSE_ON_ERROR(error) if (error) { g_clear_error (&error); return FALSE; }
+
 /* 'private'/'protected' functions */
 static void modest_global_settings_dialog_class_init (ModestGlobalSettingsDialogClass *klass);
 static void modest_global_settings_dialog_init       (ModestGlobalSettingsDialog *obj);
 static void modest_global_settings_dialog_finalize   (GObject *obj);
 
-enum {
-       MODEST_CONNECTED_VIA_WLAN,
-       MODEST_CONNECTED_VIA_ANY
-};
+static void on_response (GtkDialog *dialog,
+                        gint arg1,
+                        gpointer user_data);
+static gboolean on_delete_event (GtkWidget *widget,
+                                GdkEvent  *event,
+                                gpointer   user_data);
 
-enum {
-       MODEST_UPDATE_INTERVAL_5_MIN,
-       MODEST_UPDATE_INTERVAL_10_MIN,
-       MODEST_UPDATE_INTERVAL_15_MIN,
-       MODEST_UPDATE_INTERVAL_30_MIN,
-       MODEST_UPDATE_INTERVAL_1_HOUR,
-       MODEST_UPDATE_INTERVAL_2_HOUR
-};
+static void get_current_settings (ModestGlobalSettingsDialogPrivate *priv,
+                                 ModestGlobalSettingsState *state);
+
+static ModestConnectedVia current_connection_default (void);
+
+static gboolean modest_global_settings_dialog_save_settings_default (ModestGlobalSettingsDialog *self);
 
 /* list my signals  */
 enum {
@@ -60,19 +72,6 @@ enum {
        LAST_SIGNAL
 };
 
-static GtkWidget* create_updating_page  (void);
-static GtkWidget* create_composing_page (void);
-
-typedef struct _ModestGlobalSettingsDialogPrivate ModestGlobalSettingsDialogPrivate;
-struct _ModestGlobalSettingsDialogPrivate {
-       GtkWidget *notebook;
-       GtkWidget *updating_page;
-       GtkWidget *composing_page;
-       gboolean   modified;
-};
-#define MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
-                                                           MODEST_TYPE_GLOBAL_SETTINGS_DIALOG, \
-                                                           ModestGlobalSettingsDialogPrivate))
 /* globals */
 static GtkDialogClass *parent_class = NULL;
 
@@ -113,105 +112,43 @@ modest_global_settings_dialog_class_init (ModestGlobalSettingsDialogClass *klass
        gobject_class->finalize = modest_global_settings_dialog_finalize;
 
        g_type_class_add_private (gobject_class, sizeof(ModestGlobalSettingsDialogPrivate));
+
+       klass->current_connection_func = current_connection_default;
+       klass->save_settings_func = modest_global_settings_dialog_save_settings_default;
 }
 
 static void
 modest_global_settings_dialog_init (ModestGlobalSettingsDialog *self)
 {
        ModestGlobalSettingsDialogPrivate *priv;
-/*     GdkGeometry *geometry; */
 
        priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
 
-       priv->modified = FALSE;
        priv->notebook = gtk_notebook_new ();
-       priv->updating_page = create_updating_page ();
-       priv->composing_page = create_composing_page ();
-    
-       /* Add the notebook pages: */
-       gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), priv->updating_page, 
-               gtk_label_new (_("mcen_ti_options_updating")));
-       gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), priv->composing_page, 
-               gtk_label_new (_("mcen_ti_options_composing")));
-               
-       gtk_container_add (GTK_CONTAINER (GTK_DIALOG (self)->vbox), priv->notebook);
-       gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (self)->vbox), MODEST_MARGIN_HALF);
-       gtk_widget_show_all (priv->notebook);
-        
-       /* Add the buttons: */
-       gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK);
-       gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_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->default_account_selector = NULL;
+       priv->accounts_list = NULL;
+
+       /* Connect to the dialog's "response" and "delete-event" signals */
+       g_signal_connect (G_OBJECT (self), "response", G_CALLBACK (on_response), self);
+       g_signal_connect (G_OBJECT (self), "delete-event", G_CALLBACK (on_delete_event), self);
 
        /* Set title */
        gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_options"));
-
-       /* Set geometry */
-/*     geometry = g_malloc0(sizeof (GdkGeometry)); */
-/*     geometry->max_width = MODEST_DIALOG_WINDOW_MAX_WIDTH; */
-/*     geometry->min_width = MODEST_DIALOG_WINDOW_MIN_WIDTH; */
-/*     geometry->max_height = MODEST_DIALOG_WINDOW_MAX_HEIGHT; */
-/*     geometry->min_height = MODEST_DIALOG_WINDOW_MIN_HEIGHT; */
-/*     gtk_window_set_geometry_hints (GTK_WINDOW (self), */
-/*                                    GTK_WIDGET (self), */
-/*                                    geometry, */
-/*                                    GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); */
-       gtk_widget_set_size_request (GTK_WIDGET (self), 
-                                    MODEST_DIALOG_WINDOW_MAX_WIDTH, 
-                                    MODEST_DIALOG_WINDOW_MAX_HEIGHT);
 }
 
 static void
 modest_global_settings_dialog_finalize (GObject *obj)
 {
-/*     free/unref instance resources here */
-       G_OBJECT_CLASS(parent_class)->finalize (obj);
-}
+       ModestGlobalSettingsDialogPrivate *priv = 
+               MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (obj);
 
-GtkWidget*
-modest_global_settings_dialog_new (void)
-{
-       return GTK_WIDGET(g_object_new(MODEST_TYPE_GLOBAL_SETTINGS_DIALOG, NULL));
-}
+       /* These had to stay alive as long as the comboboxes that used them: */
+       modest_pair_list_free (priv->connect_via_list);
+       modest_pair_list_free (priv->update_interval_list);
+       modest_pair_list_free (priv->msg_format_list);
+       modest_pair_list_free (priv->accounts_list);
 
-/* 
- * Adds the two widgets to a new row in the table
- */
-static void
-add_to_table (GtkTable *table,
-             GtkWidget *left,
-             GtkWidget *right)
-{
-       guint n_rows = 0;
-
-       g_object_get (G_OBJECT (table), "n-rows", &n_rows,NULL);
-
-       /* Create label */
-       gtk_misc_set_alignment (GTK_MISC (left), 1.0, 0.0);
-
-       /* Create value */
-/*     gtk_misc_set_alignment (GTK_MISC (right), 0.0, 0.0); */
-
-       /* Attach label and value */
-       gtk_table_attach (table, 
-                         left, 0, 1, 
-                         n_rows, n_rows + 1, 
-                         GTK_SHRINK|GTK_FILL, 
-                         GTK_SHRINK|GTK_FILL, 
-                         0, 0);
-       gtk_table_attach (table, 
-                         right, 1, 2, 
-                         n_rows, n_rows + 1, 
-                         GTK_EXPAND|GTK_FILL, 
-                         GTK_SHRINK|GTK_FILL, 
-                         0, 0);
+       G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
 /*
@@ -220,26 +157,32 @@ add_to_table (GtkTable *table,
 static void
 add_to_modest_pair_list (const gint num, const gchar *str, GSList **list)
 {
-       guint *number;
+       gint *number;
        ModestPair *pair;
 
-       number = g_malloc0 (sizeof (guint));
+       number = g_malloc0 (sizeof (gint));
        *number = num;
-       pair = modest_pair_new (number, g_strdup (str), TRUE);
+       pair = modest_pair_new (number, g_strdup (str), FALSE);
        *list = g_slist_prepend (*list, pair);
 }
 
-/*
- * Gets a list of pairs 
- */
-static ModestPairList *
-get_connected_via (void)
+ModestPairList *
+_modest_global_settings_dialog_get_connected_via (void)
 {
        GSList *list = NULL;
-
-       add_to_modest_pair_list (MODEST_CONNECTED_VIA_WLAN, 
-                                _("mcen_va_options_connectiontype_wlan"), 
-                                &list);
+       const gchar *message;
+
+#ifndef MODEST_TOOLKIT_GTK
+       const gchar *env_var = getenv ("OSSO_PRODUCT_HARDWARE");
+       /* Check if WIMAX is available */
+       if (env_var && !strncmp (env_var, "RX-48", 5))
+               message = _("mcen_va_options_connectiontype_wlan_wimax");
+       else
+               message = _("mcen_va_options_connectiontype_wlan");
+#else
+       message = _("mcen_va_options_connectiontype_wlan");
+#endif
+       add_to_modest_pair_list (MODEST_CONNECTED_VIA_WLAN_OR_WIMAX, message, &list);
        add_to_modest_pair_list (MODEST_CONNECTED_VIA_ANY, 
                                 _("mcen_va_options_connectiontype_all"), 
                                 &list);
@@ -250,114 +193,48 @@ get_connected_via (void)
 /*
  * Gets a list of pairs of update intervals
  */
-static ModestPairList *
-get_update_interval (void)
+ModestPairList *
+_modest_global_settings_dialog_get_update_interval (void)
 {
        GSList *list = NULL;
 
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_5_MIN, 
-                                _("mcen_va_options_updateinterval_5min"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_5_MIN,
+                                _("mcen_va_options_updateinterval_5min"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_10_MIN, 
-                                _("mcen_va_options_updateinterval_10min"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_10_MIN,
+                                _("mcen_va_options_updateinterval_10min"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_15_MIN, 
-                                _("mcen_va_options_updateinterval_15min"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_15_MIN,
+                                _("mcen_va_options_updateinterval_15min"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_30_MIN, 
-                                _("mcen_va_options_updateinterval_30min"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_30_MIN,
+                                _("mcen_va_options_updateinterval_30min"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_1_HOUR, 
-                                _("mcen_va_options_updateinterval_1h"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_1_HOUR,
+                                _("mcen_va_options_updateinterval_1h"),
                                 &list);
-       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_2_HOUR, 
-                                _("mcen_va_options_updateinterval_2h"), 
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_2_HOUR,
+                                _("mcen_va_options_updateinterval_2h"),
+                                &list);
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_4_HOUR,
+                                _("mcen_va_options_updateinterval_4h"),
+                                &list);
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_8_HOUR,
+                                _("mcen_va_options_updateinterval_8h"),
+                                &list);
+       add_to_modest_pair_list (MODEST_UPDATE_INTERVAL_24_HOUR,
+                                _("mcen_va_options_updateinterval_24h"),
                                 &list);
 
-       return (ModestPairList *) g_slist_reverse (list);
-}
-
-/* 
- * We need this because the translations are comming without ":" 
- */
-static GtkWidget *
-create_label (const gchar *text)
-{
-       gchar *label_name;
-       GtkWidget *label;
-
-       label_name = g_strdup_printf ("%s:", text);
-       label = gtk_label_new (label_name);
-       g_free (label_name);
-
-       return label;
-}
 
-/*
- * Creates the updating page
- */
-static GtkWidget*
-create_updating_page (void)
-{
-       GtkWidget *vbox, *table_update, *table_limit;
-       GtkWidget *label, *check, *combo, *spin;
-       ModestPairList *list;
-
-       vbox = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
-       table_update = gtk_table_new (3, 2, FALSE);
-       table_limit = gtk_table_new (2, 2, FALSE);
-       /* FIXME: set proper values */
-       gtk_table_set_row_spacings (GTK_TABLE (table_update), 6);
-       gtk_table_set_col_spacings (GTK_TABLE (table_update), 12);
-       gtk_table_set_row_spacings (GTK_TABLE (table_limit), 6);
-       gtk_table_set_col_spacings (GTK_TABLE (table_limit), 12);
-
-       /* Autoupdate */
-       label = create_label (_("mcen_fi_options_autoupdate"));
-       check = gtk_check_button_new ();
-       add_to_table (GTK_TABLE (table_update), label, check);
-
-       /* Connected via */
-       label = create_label (_("mcen_fi_options_connectiontype"));
-       list = get_connected_via ();
-       combo = modest_combo_box_new (list, g_int_equal);
-       modest_pair_list_free (list);
-       add_to_table (GTK_TABLE (table_update), label, combo);
-
-       /* Update interval */
-       label = create_label (_("mcen_fi_options_updateinterval"));
-       list = get_update_interval ();
-       combo = modest_combo_box_new (list, g_int_equal);
-       modest_pair_list_free (list);
-       add_to_table (GTK_TABLE (table_update), label, combo);
-
-       /* Add to vbox */
-       gtk_box_pack_start (GTK_BOX (vbox), table_update, FALSE, FALSE, MODEST_MARGIN_HALF);
-
-       /* Separator */
-       gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, MODEST_MARGIN_HALF);
-
-       /* Limits */
-       label = create_label (_("mcen_fi_advsetup_sizelimit"));
-       spin = gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (1000, 1, 5000, 1, 1, 16)), 
-                                   1, 0);
-       add_to_table (GTK_TABLE (table_limit), label, spin);
-
-       label = create_label (_("mcen_fi_options_playsound"));
-       check = gtk_check_button_new ();
-       add_to_table (GTK_TABLE (table_limit), label, check);
-
-       /* Add to vbox */
-       gtk_box_pack_start (GTK_BOX (vbox), table_limit, FALSE, FALSE, MODEST_MARGIN_HALF);
-
-       return vbox;
+       return (ModestPairList *) g_slist_reverse (list);
 }
 
 /*
  * Gets a list of pairs 
  */
-static ModestPairList *
-get_msg_formats (void)
+ModestPairList *
+_modest_global_settings_dialog_get_msg_formats (void)
 {
        GSList *list = NULL;
 
@@ -371,36 +248,194 @@ get_msg_formats (void)
        return (ModestPairList *) g_slist_reverse (list);
 }
 
+static void
+get_current_settings (ModestGlobalSettingsDialogPrivate *priv,
+                     ModestGlobalSettingsState *state)
+{
+       gint *id;
+
+       /* Get values from UI */
+       state->notifications = modest_togglable_get_active (priv->notifications);
+       state->add_to_contacts = modest_togglable_get_active (priv->add_to_contacts);
+       state->auto_update = modest_togglable_get_active (priv->auto_update);
+       id = modest_selector_get_active_id (priv->connect_via);
+       state->default_account = modest_selector_get_active_id (priv->default_account_selector);
+       state->connect_via = *id;
+
+       id = modest_selector_get_active_id (priv->update_interval);
+       state->update_interval = *id;
+       id = modest_selector_get_active_id (priv->msg_format);
+       state->play_sound = priv->initial_state.play_sound;
+       state->prefer_formatted_text = (*id == MODEST_FILE_FORMAT_FORMATTED_TEXT) ? TRUE : FALSE;
+}
 
-/*
- * Creates the composing page
- */
-static GtkWidget* 
-create_composing_page (void)
+static gboolean
+modest_global_settings_dialog_save_settings_default (ModestGlobalSettingsDialog *self)
+{
+       ModestConf *conf;
+       ModestGlobalSettingsState current_state = {0,};
+       GError *error = NULL;
+       ModestGlobalSettingsDialogPrivate *priv;
+
+       priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
+
+       conf = modest_runtime_get_conf ();
+
+       get_current_settings (priv, &current_state);
+
+       /* Save configuration */
+       modest_conf_set_bool (conf, MODEST_CONF_NOTIFICATIONS, current_state.notifications, &error);
+       RETURN_FALSE_ON_ERROR(error);
+       modest_conf_set_bool (conf, MODEST_CONF_AUTO_ADD_TO_CONTACTS, current_state.add_to_contacts, &error);
+       RETURN_FALSE_ON_ERROR(error);
+       modest_conf_set_bool (conf, MODEST_CONF_AUTO_UPDATE, current_state.auto_update, &error);
+       RETURN_FALSE_ON_ERROR(error);
+       modest_conf_set_int (conf, MODEST_CONF_UPDATE_WHEN_CONNECTED_BY, current_state.connect_via, NULL);
+       RETURN_FALSE_ON_ERROR(error);
+       modest_conf_set_int (conf, MODEST_CONF_UPDATE_INTERVAL, current_state.update_interval, NULL);
+       RETURN_FALSE_ON_ERROR(error);
+       modest_conf_set_bool (conf, MODEST_CONF_PLAY_SOUND_MSG_ARRIVE, current_state.play_sound, NULL);
+       RETURN_FALSE_ON_ERROR(error);
+       modest_conf_set_bool (conf, MODEST_CONF_PREFER_FORMATTED_TEXT, current_state.prefer_formatted_text, NULL);
+       RETURN_FALSE_ON_ERROR(error);
+       if (current_state.default_account &&
+           (!priv->initial_state.default_account ||
+            strcmp (current_state.default_account, priv->initial_state.default_account)!= 0)) {
+               modest_account_mgr_set_default_account (modest_runtime_get_account_mgr (),
+                                                       current_state.default_account);
+       }
+
+       /* Apply changes */
+       if (priv->initial_state.auto_update != current_state.auto_update ||
+           priv->initial_state.connect_via != current_state.connect_via ||
+           priv->initial_state.update_interval != current_state.update_interval) {
+
+               TnyAccountStore *account_store;
+               TnyDevice *device;
+               
+               if (!current_state.auto_update) {
+                       modest_platform_set_update_interval (0);
+                       /* To avoid a new indentation level */
+                       goto exit;
+               }
+               
+               account_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store ());
+               device = tny_account_store_get_device (account_store);
+               
+               if (tny_device_is_online (device)) {
+                       /* If connected via any then set update interval */
+                       if (current_state.connect_via == MODEST_CONNECTED_VIA_ANY) {
+                               modest_platform_set_update_interval (current_state.update_interval);
+                       } else {
+                               /* Set update interval only if we
+                                  selected the same connect_via
+                                  method than the one already used by
+                                  the device */
+                               ModestConnectedVia connect_via =
+                                       MODEST_GLOBAL_SETTINGS_DIALOG_GET_CLASS(self)->current_connection_func ();
+                               
+                               if (current_state.connect_via == connect_via)
+                                       modest_platform_set_update_interval (current_state.update_interval);
+                               else
+                                       modest_platform_set_update_interval (0);
+                       }
+               } else {
+                       /* Disable autoupdate in offline mode */
+                       modest_platform_set_update_interval (0);
+               }
+               g_object_unref (device);
+       }
+       
+exit:
+       return TRUE;
+}
+
+static gboolean
+settings_changed (ModestGlobalSettingsState initial_state,
+                 ModestGlobalSettingsState current_state)
 {
-       GtkWidget *vbox, *table;
-       GtkWidget *label, *check, *combo;
-       ModestPairList *list;
-
-       vbox = gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
-       table = gtk_table_new (2, 2, FALSE);
-       /* FIXME: set proper values */
-       gtk_table_set_row_spacings (GTK_TABLE (table), 6);
-       gtk_table_set_col_spacings (GTK_TABLE (table), 12);
-
-       /* Update interval */
-       label = create_label (_("mcen_fi_options_messageformat"));
-       list = get_msg_formats ();
-       combo = modest_combo_box_new (list, g_int_equal);
-       modest_pair_list_free (list);
-       add_to_table (GTK_TABLE (table), label, combo);
-
-       label = create_label (_("mcen_va_options_include_original_inreply"));
-       check = gtk_check_button_new ();
-       add_to_table (GTK_TABLE (table), label, check);
-
-       /* Add to vbox */
-       gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, MODEST_MARGIN_HALF);
-
-       return vbox;
+       if (initial_state.auto_update != current_state.auto_update ||
+           initial_state.notifications != current_state.notifications ||
+           initial_state.add_to_contacts != current_state.add_to_contacts ||
+           initial_state.connect_via != current_state.connect_via ||
+           initial_state.update_interval != current_state.update_interval ||
+           initial_state.play_sound != current_state.play_sound ||
+           initial_state.prefer_formatted_text != current_state.prefer_formatted_text ||
+           (current_state.default_account &&
+            (!initial_state.default_account || 
+             strcmp (current_state.default_account, initial_state.default_account)!= 0)))
+               return TRUE;
+       else
+               return FALSE;
+}
+
+static gboolean
+on_delete_event (GtkWidget *widget,
+                 GdkEvent  *event,
+                 gpointer   user_data)
+{
+       ModestGlobalSettingsDialogPrivate *priv;
+       ModestGlobalSettingsState current_state;
+
+       priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data);
+
+       /* If settings changed, them the response method already asked
+          the user, because it's always executed before (see
+          GtkDialog code). If it's not then simply close */
+       get_current_settings (priv, &current_state);
+       return settings_changed (priv->initial_state, current_state);
+}
+
+static void
+on_response (GtkDialog *dialog,
+            gint arg1,
+            gpointer user_data)
+{
+       ModestGlobalSettingsDialogPrivate *priv;
+       ModestGlobalSettingsState current_state = {0,};
+       gboolean changed = FALSE;
+
+       priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data);
+
+       get_current_settings (priv, &current_state);
+       changed = settings_changed (priv->initial_state, current_state);
+
+       if (arg1 == GTK_RESPONSE_OK) {
+               if (changed) {
+                       gboolean saved;
+
+                       saved = modest_global_settings_dialog_save_settings (MODEST_GLOBAL_SETTINGS_DIALOG (dialog));
+                       if (saved) {
+                               modest_platform_information_banner (NULL, NULL,
+                                                                   _("mcen_ib_advsetup_settings_saved"));
+                       } else {
+                               modest_platform_information_banner (NULL, NULL,
+                                                                   _("mail_ib_setting_failed"));
+                       }
+               }
+       } else {
+               if (changed) {
+                       gint response;
+                       response = modest_platform_run_confirmation_dialog (GTK_WINDOW (user_data),
+                                                                           _("imum_nc_wizard_confirm_lose_changes"));
+                       /* Do not close if the user Cancels */
+                       if (response != GTK_RESPONSE_OK)
+                               g_signal_stop_emission_by_name (user_data, "response");
+               }
+       }
+}
+
+static ModestConnectedVia
+current_connection_default (void)
+{
+       g_warning ("You must implement %s", __FUNCTION__);
+       g_return_val_if_reached (MODEST_CONNECTED_VIA_ANY);
+}
+
+gboolean
+modest_global_settings_dialog_save_settings (ModestGlobalSettingsDialog *self)
+{
+       g_return_val_if_fail (MODEST_IS_GLOBAL_SETTINGS_DIALOG (self), FALSE);
+
+       return MODEST_GLOBAL_SETTINGS_DIALOG_GET_CLASS(self)->save_settings_func (self);
 }