* Fixed a compilation error in OSSO1.1 due to a change in an enum value since Bora
pmo-trunk-r1838
static GtkWidget* create_updating_page (ModestGnomeGlobalSettingsDialog *self);
static GtkWidget* create_composing_page (ModestGnomeGlobalSettingsDialog *self);
+static ModestConnectedVia current_connection (void);
typedef struct _ModestGnomeGlobalSettingsDialogPrivate ModestGnomeGlobalSettingsDialogPrivate;
struct _ModestGnomeGlobalSettingsDialogPrivate {
gobject_class->finalize = modest_gnome_global_settings_dialog_finalize;
g_type_class_add_private (gobject_class, sizeof(ModestGnomeGlobalSettingsDialogPrivate));
+
+ MODEST_GLOBAL_SETTINGS_DIALOG_CLASS (klass)->current_connection_func = current_connection;
}
static void
return vbox;
}
+
+static ModestConnectedVia
+current_connection (void)
+{
+ return MODEST_CONNECTED_VIA_ANY;
+}
#endif /*MODEST_HILDON_VERSION_0*/
#include <glib/gi18n.h>
+#include <string.h>
#include <gtk/gtkbox.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkhseparator.h>
+#include "modest-runtime.h"
#include "widgets/modest-global-settings-dialog-priv.h"
#include "widgets/modest-combo-box.h"
#include "maemo/modest-maemo-global-settings-dialog.h"
#include "widgets/modest-ui-constants.h"
+#include <tny-account-store.h>
+#include <tny-maemo-conic-device.h>
#define MSG_SIZE_MAX_VAL 5000
#define MSG_SIZE_DEF_VAL 1000
static void modest_maemo_global_settings_dialog_init (ModestMaemoGlobalSettingsDialog *obj);
static void modest_maemo_global_settings_dialog_finalize (GObject *obj);
+static ModestConnectedVia current_connection (void);
+
/* list my signals */
enum {
/* MY_SIGNAL_1, */
gobject_class->finalize = modest_maemo_global_settings_dialog_finalize;
g_type_class_add_private (gobject_class, sizeof(ModestMaemoGlobalSettingsDialogPrivate));
+
+ MODEST_GLOBAL_SETTINGS_DIALOG_CLASS (klass)->current_connection_func = current_connection;
}
static void
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (self)->vbox), MODEST_MARGIN_HALF);
/* Load current config */
- _modest_global_settings_dialog_load_conf (ppriv);
+ _modest_global_settings_dialog_load_conf (MODEST_GLOBAL_SETTINGS_DIALOG (self));
gtk_widget_show_all (ppriv->notebook);
}
gpointer user_data)
{
ModestGlobalSettingsDialogPrivate *ppriv;
- GtkWidget *caption;
+ GtkWidget *caption1, *caption2;
ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (user_data);
- caption = gtk_widget_get_ancestor (ppriv->connect_via, HILDON_TYPE_CAPTION);
-
- if (gtk_toggle_button_get_active (togglebutton))
- gtk_widget_set_sensitive (caption, TRUE);
- else
- gtk_widget_set_sensitive (caption, FALSE);
+ caption1 = gtk_widget_get_ancestor (ppriv->connect_via, HILDON_TYPE_CAPTION);
+ caption2 = gtk_widget_get_ancestor (ppriv->update_interval, HILDON_TYPE_CAPTION);
+
+ if (gtk_toggle_button_get_active (togglebutton)) {
+ gtk_widget_set_sensitive (caption1, TRUE);
+ gtk_widget_set_sensitive (caption2, TRUE);
+ } else {
+ gtk_widget_set_sensitive (caption1, FALSE);
+ gtk_widget_set_sensitive (caption2, FALSE);
+ }
}
static gboolean
gint new_val;
switch (type) {
+#ifdef MODEST_HILDON_VERSION_0
case MAXIMUM_VALUE_EXCEED:
+#else
+ case HILDON_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED:
+#endif
msg = g_strdup_printf (_("ckct_ib_maximum_value"), MSG_SIZE_MAX_VAL);
new_val = MSG_SIZE_MAX_VAL;
break;
+#ifdef MODEST_HILDON_VERSION_0
case MINIMUM_VALUE_EXCEED:
+#else
+ case HILDON_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED:
+#endif
msg = g_strdup_printf (_("ckct_ib_minimum_value"), MSG_SIZE_MIN_VAL);
new_val = MSG_SIZE_MIN_VAL;
break;
+#ifdef MODEST_HILDON_VERSION_0
case ERRONEOUS_VALUE:
+#else
+ case HILDON_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE:
+#endif
msg = g_strdup_printf (_("ckct_ib_set_a_value_within_range"),
MSG_SIZE_MIN_VAL,
MSG_SIZE_MAX_VAL);
return TRUE;
}
+
+static ModestConnectedVia
+current_connection (void)
+{
+ TnyAccountStore *account_store;
+ TnyDevice *device;
+ gboolean retval;
+ const gchar *bearer_type, *iap_id;
+ ConIcIap *iap;
+
+ account_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store ());
+ device = tny_account_store_get_device (account_store);
+
+ /* Get iap id */
+ iap_id = tny_maemo_conic_device_get_current_iap_id (TNY_MAEMO_CONIC_DEVICE (device));
+ iap = tny_maemo_conic_device_get_iap (TNY_MAEMO_CONIC_DEVICE (device), iap_id);
+ bearer_type = con_ic_iap_get_bearer_type (iap);
+
+ if (!strcmp (bearer_type, CON_IC_BEARER_WLAN_INFRA) ||
+ !strcmp (bearer_type, CON_IC_BEARER_WLAN_ADHOC))
+ retval = MODEST_CONNECTED_VIA_WLAN;
+ else
+ retval = MODEST_CONNECTED_VIA_ANY;
+
+ g_object_unref (iap);
+ g_object_unref (device);
+
+ return retval;
+}
conf = modest_runtime_get_conf ();
+ modest_widget_memory_restore (conf, G_OBJECT(self),
+ MODEST_CONF_MAIN_WINDOW_KEY);
modest_widget_memory_restore (conf, G_OBJECT(priv->main_paned),
MODEST_CONF_MAIN_PANED_KEY);
modest_widget_memory_restore (conf, G_OBJECT(priv->header_view),
MODEST_CONF_HEADER_VIEW_KEY);
- modest_widget_memory_restore (conf, G_OBJECT(self),
- MODEST_CONF_MAIN_WINDOW_KEY);
}
**/
gboolean modest_platform_set_update_interval (guint minutes);
-GtkWidget* modest_platform_get_global_settings_dialog ();
+/**
+ * modest_platform_get_global_settings_dialog:
+ * @void:
+ *
+ * returns the global settings dialog
+ *
+ * Return value: a new #ModestGlobalSettingsDialog dialog
+ **/
+GtkWidget* modest_platform_get_global_settings_dialog (void);
G_END_DECLS
ModestWindow *win)
{
GtkWidget *dialog;
- gint response;
dialog = modest_platform_get_global_settings_dialog ();
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (win));
gtk_widget_show (dialog);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- if (response == GTK_RESPONSE_ACCEPT) {
- g_message ("YES");
- }
+ gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
ModestPairList* _modest_global_settings_dialog_get_update_interval (void);
ModestPairList* _modest_global_settings_dialog_get_msg_formats (void);
-void _modest_global_settings_dialog_load_conf (ModestGlobalSettingsDialogPrivate *priv);
-gboolean _modest_global_settings_dialog_save_conf (ModestGlobalSettingsDialogPrivate *priv);
-
G_END_DECLS
#endif /* __MODEST_GLOBAL_SETTINGS_DIALOG_PRIV_H__ */
static void get_current_settings (ModestGlobalSettingsDialogPrivate *priv,
ModestGlobalSettingsState *state);
+static ModestConnectedVia current_connection_default (void);
+
/* list my signals */
enum {
/* MY_SIGNAL_1, */
gobject_class->finalize = modest_global_settings_dialog_finalize;
g_type_class_add_private (gobject_class, sizeof(ModestGlobalSettingsDialogPrivate));
+
+ klass->current_connection_func = current_connection_default;
}
static void
}
void
-_modest_global_settings_dialog_load_conf (ModestGlobalSettingsDialogPrivate *priv)
+_modest_global_settings_dialog_load_conf (ModestGlobalSettingsDialog *self)
{
ModestConf *conf;
gboolean checked;
gint combo_id, value;
GError *error = NULL;
+ ModestGlobalSettingsDialogPrivate *priv;
+ priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
conf = modest_runtime_get_conf ();
/* Autoupdate */
}
gboolean
-_modest_global_settings_dialog_save_conf (ModestGlobalSettingsDialogPrivate *priv)
+_modest_global_settings_dialog_save_conf (ModestGlobalSettingsDialog *self)
{
ModestConf *conf;
ModestGlobalSettingsState current_state;
GError *error = NULL;
+ ModestGlobalSettingsDialogPrivate *priv;
+
+ priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
conf = modest_runtime_get_conf ();
MODEST_TNY_MSG_REPLY_TYPE_CITE, NULL);
RETURN_FALSE_ON_ERROR(error);
+ /* 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;
}
if (changed) {
gboolean saved;
- saved = _modest_global_settings_dialog_save_conf (priv);
- if (saved)
+ saved = _modest_global_settings_dialog_save_conf (MODEST_GLOBAL_SETTINGS_DIALOG (dialog));
+ if (saved) {
modest_platform_run_information_dialog (GTK_WINDOW (user_data),
_("mcen_ib_advsetup_settings_saved"));
- else
+ } else {
modest_platform_run_information_dialog (GTK_WINDOW (user_data),
_("mail_ib_setting_failed"));
+ }
}
} else {
if (changed) {
}
}
}
+
+static ModestConnectedVia
+current_connection_default (void)
+{
+ g_warning ("You must implement %s", __FUNCTION__);
+ g_return_val_if_reached (-1);
+}
#define MODEST_IS_GLOBAL_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_GLOBAL_SETTINGS_DIALOG))
#define MODEST_GLOBAL_SETTINGS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_GLOBAL_SETTINGS_DIALOG,ModestGlobalSettingsDialogClass))
+/* Global settings */
+typedef enum _ModestConnectedVia {
+ MODEST_CONNECTED_VIA_WLAN = 1,
+ MODEST_CONNECTED_VIA_ANY,
+} ModestConnectedVia;
+
+typedef enum _ModestUpdateInterval {
+ MODEST_UPDATE_INTERVAL_5_MIN = 5,
+ MODEST_UPDATE_INTERVAL_10_MIN = 10,
+ MODEST_UPDATE_INTERVAL_15_MIN = 15,
+ MODEST_UPDATE_INTERVAL_30_MIN = 30,
+ MODEST_UPDATE_INTERVAL_1_HOUR = 60,
+ MODEST_UPDATE_INTERVAL_2_HOUR = 120
+} ModestUpdateInterval;
+
typedef struct _ModestGlobalSettingsDialog ModestGlobalSettingsDialog;
typedef struct _ModestGlobalSettingsDialogClass ModestGlobalSettingsDialogClass;
struct _ModestGlobalSettingsDialogClass {
GtkDialogClass parent_class;
-};
-/* Global settings */
-typedef enum _ModestConnectedVia {
- MODEST_CONNECTED_VIA_WLAN,
- MODEST_CONNECTED_VIA_ANY
-} ModestConnectedVia;
-
-typedef enum _ModestUpdateInterval {
- 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
-} ModestUpdateInterval;
+ /* Returns the current connection method. Assumes that the device is online */
+ ModestConnectedVia (*current_connection_func) (void);
+};
/* member functions */
GType modest_global_settings_dialog_get_type (void) G_GNUC_CONST;
+/* Do *NOT* use this functions directly. They must be only used by
+ subclasses. We put them here and not in the -priv header file
+ because recursive dependencies */
+void _modest_global_settings_dialog_load_conf (ModestGlobalSettingsDialog *self);
+gboolean _modest_global_settings_dialog_save_conf (ModestGlobalSettingsDialog *self);
+
+
G_END_DECLS
#endif /* __MODEST_GLOBAL_SETTINGS_DIALOG_H__ */