[evolution-data-server/gnome-3-32] I#114 - [IMAPx] Option to enable full folder update on metered networks
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-32] I#114 - [IMAPx] Option to enable full folder update on metered networks
- Date: Thu, 9 May 2019 10:09:59 +0000 (UTC)
commit 1632bf4ef3fb8debc60b2bc31f21a301256350cd
Author: Milan Crha <mcrha redhat com>
Date: Thu May 9 12:11:47 2019 +0200
I#114 - [IMAPx] Option to enable full folder update on metered networks
Related to https://gitlab.gnome.org/GNOME/evolution-data-server/issues/114
src/camel/providers/imapx/camel-imapx-server.c | 13 +++++
src/camel/providers/imapx/camel-imapx-settings.c | 74 +++++++++++++++++++++++-
src/camel/providers/imapx/camel-imapx-settings.h | 5 ++
3 files changed, 91 insertions(+), 1 deletion(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index d5178ea88..20f09aba2 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -5450,12 +5450,25 @@ static gboolean
camel_imapx_server_skip_old_flags_update (CamelStore *store)
{
CamelSession *session;
+ CamelSettings *settings;
GNetworkMonitor *network_monitor;
gboolean skip_old_flags_update = FALSE;
if (!CAMEL_IS_STORE (store))
return FALSE;
+ settings = camel_service_ref_settings (CAMEL_SERVICE (store));
+ if (settings) {
+ gboolean allow_update;
+
+ allow_update = camel_imapx_settings_get_full_update_on_metered_network (CAMEL_IMAPX_SETTINGS
(settings));
+
+ g_object_unref (settings);
+
+ if (allow_update)
+ return FALSE;
+ }
+
session = camel_service_ref_session (CAMEL_SERVICE (store));
if (!session)
return skip_old_flags_update;
diff --git a/src/camel/providers/imapx/camel-imapx-settings.c
b/src/camel/providers/imapx/camel-imapx-settings.c
index 6e720fd5c..883a38f14 100644
--- a/src/camel/providers/imapx/camel-imapx-settings.c
+++ b/src/camel/providers/imapx/camel-imapx-settings.c
@@ -50,6 +50,7 @@ struct _CamelIMAPXSettingsPrivate {
gboolean use_subscriptions;
gboolean ignore_other_users_namespace;
gboolean ignore_shared_folders_namespace;
+ gboolean full_update_on_metered_network;
CamelSortType fetch_order;
};
@@ -81,7 +82,8 @@ enum {
PROP_USE_SHELL_COMMAND,
PROP_USE_SUBSCRIPTIONS,
PROP_IGNORE_OTHER_USERS_NAMESPACE,
- PROP_IGNORE_SHARED_FOLDERS_NAMESPACE
+ PROP_IGNORE_SHARED_FOLDERS_NAMESPACE,
+ PROP_FULL_UPDATE_ON_METERED_NETWORK
};
G_DEFINE_TYPE_WITH_CODE (
@@ -253,6 +255,12 @@ imapx_settings_set_property (GObject *object,
CAMEL_IMAPX_SETTINGS (object),
g_value_get_boolean (value));
return;
+
+ case PROP_FULL_UPDATE_ON_METERED_NETWORK:
+ camel_imapx_settings_set_full_update_on_metered_network (
+ CAMEL_IMAPX_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -446,6 +454,13 @@ imapx_settings_get_property (GObject *object,
camel_imapx_settings_get_ignore_shared_folders_namespace (
CAMEL_IMAPX_SETTINGS (object)));
return;
+
+ case PROP_FULL_UPDATE_ON_METERED_NETWORK:
+ g_value_set_boolean (
+ value,
+ camel_imapx_settings_get_full_update_on_metered_network (
+ CAMEL_IMAPX_SETTINGS (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -787,6 +802,19 @@ camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FULL_UPDATE_ON_METERED_NETWORK,
+ g_param_spec_boolean (
+ "full-update-on-metered-network",
+ "Full Update On Metered Network",
+ "Whether can do full folder update even on metered network",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -1886,3 +1914,47 @@ camel_imapx_settings_set_use_subscriptions (CamelIMAPXSettings *settings,
g_object_notify (G_OBJECT (settings), "use-subscriptions");
}
+/**
+ * camel_imapx_settings_get_full_update_on_metered_network:
+ * @settings: a #CamelIMAPXSettings
+ *
+ * Returns whether to allow full folder update on metered network. With
+ * this off the folder update skips updates of the known messages, which
+ * can lead to not removing removed messages or not updating flags of
+ * the old messages. The option is meant to save bandwidth usage on
+ * the metered network.
+ *
+ * Returns: whether to allow full folder update on metered network
+ *
+ * Since: 3.32.3
+ **/
+gboolean
+camel_imapx_settings_get_full_update_on_metered_network (CamelIMAPXSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
+
+ return settings->priv->full_update_on_metered_network;
+}
+
+/**
+ * camel_imapx_settings_set_full_update_on_metered_network:
+ * @settings: a #CamelIMAPXSettings
+ * @full_update_on_metered_network: whether to allow it
+ *
+ * Sets whether to allow full folder update on metered network.
+ *
+ * Since: 3.32.3
+ **/
+void
+camel_imapx_settings_set_full_update_on_metered_network (CamelIMAPXSettings *settings,
+ gboolean full_update_on_metered_network)
+{
+ g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
+
+ if (settings->priv->full_update_on_metered_network == full_update_on_metered_network)
+ return;
+
+ settings->priv->full_update_on_metered_network = full_update_on_metered_network;
+
+ g_object_notify (G_OBJECT (settings), "full-update-on-metered-network");
+}
diff --git a/src/camel/providers/imapx/camel-imapx-settings.h
b/src/camel/providers/imapx/camel-imapx-settings.h
index 4de7306af..3e32c617e 100644
--- a/src/camel/providers/imapx/camel-imapx-settings.h
+++ b/src/camel/providers/imapx/camel-imapx-settings.h
@@ -171,6 +171,11 @@ gboolean camel_imapx_settings_get_use_subscriptions
void camel_imapx_settings_set_use_subscriptions
(CamelIMAPXSettings *settings,
gboolean use_subscriptions);
+gboolean camel_imapx_settings_get_full_update_on_metered_network
+ (CamelIMAPXSettings *settings);
+void camel_imapx_settings_set_full_update_on_metered_network
+ (CamelIMAPXSettings *settings,
+ gboolean full_update_on_metered_network);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]