[evolution-data-server/email-factory-3-4: 14/22] Add auto_fetch param to avoid autofetching next mails. In Daemon we download in reverse order and th
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/email-factory-3-4: 14/22] Add auto_fetch param to avoid autofetching next mails. In Daemon we download in reverse order and th
- Date: Tue, 17 Jan 2012 13:51:30 +0000 (UTC)
commit 7a4324d5bd44c6a53046cb8bdda2303bb90e213f
Author: Srinivasa Ragavan <sragavan gnome org>
Date: Mon Jan 9 12:55:14 2012 +0530
Add auto_fetch param to avoid autofetching next mails. In Daemon we
download in reverse order and this havocs network usage.
camel/providers/pop3/camel-pop3-folder.c | 14 ++++++-
camel/providers/pop3/camel-pop3-settings.c | 64 +++++++++++++++++++++++++++-
camel/providers/pop3/camel-pop3-settings.h | 5 ++
3 files changed, 81 insertions(+), 2 deletions(-)
---
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 31d76ed..af86fdc 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -333,6 +333,9 @@ pop3_folder_get_message_sync (CamelFolder *folder,
gchar buffer[1];
gint i, last;
CamelStream *stream = NULL;
+ CamelService *service;
+ CamelSettings *settings;
+ gboolean auto_fetch;
g_return_val_if_fail (uid != NULL, NULL);
@@ -341,6 +344,15 @@ pop3_folder_get_message_sync (CamelFolder *folder,
pop3_folder = CAMEL_POP3_FOLDER (folder);
pop3_store = CAMEL_POP3_STORE (parent_store);
+ service = CAMEL_SERVICE (parent_store);
+ settings = camel_service_get_settings (service);
+
+ g_object_get (
+ settings,
+ "auto-fetch", &auto_fetch,
+ NULL);
+
+
fi = g_hash_table_lookup (pop3_folder->uids_fi, uid);
if (fi == NULL) {
g_set_error (
@@ -399,7 +411,7 @@ pop3_folder_get_message_sync (CamelFolder *folder,
pcr = camel_pop3_engine_command_new(pop3_store->engine, CAMEL_POP3_COMMAND_MULTI, cmd_tocache, fi, cancellable, NULL, "RETR %u\r\n", fi->id);
/* Also initiate retrieval of some of the following messages, assume we'll be receiving them */
- if (pop3_store->cache != NULL) {
+ if (auto_fetch && pop3_store->cache != NULL) {
/* This should keep track of the last one retrieved, also how many are still
* oustanding incase of random access on large folders */
i = fi->index + 1;
diff --git a/camel/providers/pop3/camel-pop3-settings.c b/camel/providers/pop3/camel-pop3-settings.c
index aba2d05..e7bcf05 100644
--- a/camel/providers/pop3/camel-pop3-settings.c
+++ b/camel/providers/pop3/camel-pop3-settings.c
@@ -27,6 +27,7 @@ struct _CamelPOP3SettingsPrivate {
gboolean delete_expunged;
gboolean disable_extensions;
gboolean keep_on_server;
+ gboolean auto_fetch;
};
enum {
@@ -39,7 +40,8 @@ enum {
PROP_KEEP_ON_SERVER,
PROP_PORT,
PROP_SECURITY_METHOD,
- PROP_USER
+ PROP_USER,
+ PROP_AUTO_FETCH
};
G_DEFINE_TYPE_WITH_CODE (
@@ -108,6 +110,10 @@ pop3_settings_set_property (GObject *object,
camel_network_settings_set_user (
CAMEL_NETWORK_SETTINGS (object),
g_value_get_string (value));
+ case PROP_AUTO_FETCH:
+ camel_pop3_settings_set_auto_fetch (
+ CAMEL_POP3_SETTINGS (object),
+ g_value_get_boolean (value));
return;
}
@@ -183,6 +189,11 @@ pop3_settings_get_property (GObject *object,
camel_network_settings_dup_user (
CAMEL_NETWORK_SETTINGS (object)));
return;
+ case PROP_AUTO_FETCH:
+ g_value_set_boolean (
+ value,
+ camel_pop3_settings_get_auto_fetch (
+ CAMEL_POP3_SETTINGS (object)));
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -263,6 +274,18 @@ camel_pop3_settings_class_init (CamelPOP3SettingsClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (
+ object_class,
+ PROP_KEEP_ON_SERVER,
+ g_param_spec_boolean (
+ "auto-fetch",
+ "Auto Fetch mails",
+ "Automatically fetch additional mails that may be downloaded later.",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
/* Inherited from CamelNetworkSettings. */
g_object_class_override_property (
object_class,
@@ -462,3 +485,42 @@ camel_pop3_settings_set_keep_on_server (CamelPOP3Settings *settings,
g_object_notify (G_OBJECT (settings), "keep-on-server");
}
+/**
+ * camel_pop3_settings_get_auto_fetch :
+ * @settings: a #CamelPOP3Settings
+ *
+ * Returns whether to download additional mails that may be downloaded later on
+ *
+ * Returns: whether to download additional mails
+ *
+ * Since: 3.4
+ **/
+gboolean
+camel_pop3_settings_get_auto_fetch (CamelPOP3Settings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_POP3_SETTINGS (settings), FALSE);
+
+ return settings->priv->auto_fetch;
+}
+
+/**
+ * camel_pop3_settings_set_auto_fetch :
+ * @settings: a #CamelPOP3Settings
+ * @keep_on_server: whether to download additional mails
+ *
+ * Sets whether to download additional mails that may be downloaded later on
+ *
+ * Since: 3.4
+ **/
+void
+camel_pop3_settings_set_auto_fetch (CamelPOP3Settings *settings,
+ gboolean auto_fetch)
+{
+ g_return_if_fail (CAMEL_IS_POP3_SETTINGS (settings));
+
+ settings->priv->auto_fetch = auto_fetch;
+
+ g_object_notify (G_OBJECT (settings), "auto_fetch");
+}
+
+
diff --git a/camel/providers/pop3/camel-pop3-settings.h b/camel/providers/pop3/camel-pop3-settings.h
index 29812bf..c531ad4 100644
--- a/camel/providers/pop3/camel-pop3-settings.h
+++ b/camel/providers/pop3/camel-pop3-settings.h
@@ -76,6 +76,11 @@ gboolean camel_pop3_settings_get_keep_on_server
void camel_pop3_settings_set_keep_on_server
(CamelPOP3Settings *settings,
gboolean keep_on_server);
+gboolean camel_pop3_settings_get_auto_fetch
+ (CamelPOP3Settings *settings);
+void camel_pop3_settings_set_auto_fetch
+ (CamelPOP3Settings *settings,
+ gboolean auto_fetch);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]