diff --git a/src/client/accounts/add-edit-page.vala b/src/client/accounts/add-edit-page.vala index 319ed329..39f159a4 100644 --- a/src/client/accounts/add-edit-page.vala +++ b/src/client/accounts/add-edit-page.vala @@ -156,7 +156,11 @@ public class AddEditPage : Gtk.Box { private string smtp_username_store; private string smtp_password_store; - + + // Storage options + private Gtk.Box storage_container; + private Gtk.ComboBoxText combo_storage_length; + private bool edited_imap_port = false; private bool edited_smtp_port = false; @@ -193,6 +197,18 @@ public class AddEditPage : Gtk.Box { other_info = (Gtk.Alignment) builder.get_object("container: other_info"); + // Storage options. + storage_container = (Gtk.Box) builder.get_object("storage container"); + combo_storage_length = (Gtk.ComboBoxText) builder.get_object("combo: storage"); + combo_storage_length.set_row_separator_func(combo_storage_separator_delegate); + combo_storage_length.append("14", _("2 weeks back")); // IDs are # of days + combo_storage_length.append("30", _("1 month back")); + combo_storage_length.append("90", _("3 months back")); + combo_storage_length.append("180", _("6 months back")); + combo_storage_length.append("365", _("1 year back")); + combo_storage_length.append(".", "."); // Separator + combo_storage_length.append("-1", _("Everything")); + // IMAP info widgets. entry_imap_host = (Gtk.Entry) builder.get_object("entry: imap host"); entry_imap_port = (Gtk.Entry) builder.get_object("entry: imap port"); @@ -266,6 +282,7 @@ public class AddEditPage : Gtk.Box { info.default_smtp_server_ssl, info.default_smtp_server_starttls, info.default_smtp_server_noauth, + info.prefetch_period_days, result); } @@ -289,6 +306,7 @@ public class AddEditPage : Gtk.Box { bool initial_default_smtp_ssl = true, bool initial_default_smtp_starttls = false, bool initial_default_smtp_noauth = false, + int prefetch_period_days = Geary.AccountInformation.DEFAULT_PREFETCH_PERIOD_DAYS, Geary.Engine.ValidationResult result = Geary.Engine.ValidationResult.OK) { // Set defaults @@ -318,6 +336,8 @@ public class AddEditPage : Gtk.Box { set_validation_result(result); + set_storage_length(prefetch_period_days); + if (Geary.String.is_empty(real_name)) entry_real_name.grab_focus(); else @@ -513,6 +533,7 @@ public class AddEditPage : Gtk.Box { account_information.default_smtp_server_ssl = smtp_ssl; account_information.default_smtp_server_starttls = smtp_starttls; account_information.default_smtp_server_noauth = smtp_noauth; + account_information.prefetch_period_days = get_storage_length(); if (smtp_noauth) account_information.smtp_credentials = null; @@ -537,6 +558,7 @@ public class AddEditPage : Gtk.Box { base.show_all(); welcome_box.visible = mode == PageMode.WELCOME; entry_nickname.visible = label_nickname.visible = mode != PageMode.WELCOME; + storage_container.visible = mode == PageMode.EDIT; if (mode == PageMode.WELCOME) nickname = Geary.AccountInformation.DEFAULT_NICKNAME; @@ -649,5 +671,23 @@ public class AddEditPage : Gtk.Box { string real_name = Environment.get_real_name(); return real_name == "Unknown" ? "" : real_name; } + + // Sets the storage length combo box. The days parameter should correspond to one of the pre-set + // values; arbitrary numbers will put the combo box into an undetermined state. + private void set_storage_length(int days) { + combo_storage_length.set_active_id(days.to_string()); + } + + // Returns number of days. + private int get_storage_length() { + return int.parse(combo_storage_length.get_active_id()); + } + + private bool combo_storage_separator_delegate(Gtk.TreeModel model, Gtk.TreeIter iter) { + GLib.Value v; + model.get_value(iter, 0, out v); + + return v.get_string() == "."; + } } diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala index 7878f64b..7dae08a4 100644 --- a/src/engine/api/geary-account-information.vala +++ b/src/engine/api/geary-account-information.vala @@ -10,6 +10,7 @@ public class Geary.AccountInformation : Object { private const string NICKNAME_KEY = "nickname"; private const string SERVICE_PROVIDER_KEY = "service_provider"; private const string ORDINAL_KEY = "ordinal"; + private const string PREFETCH_PERIOD_DAYS_KEY = "prefetch_period_days"; private const string IMAP_USERNAME_KEY = "imap_username"; private const string IMAP_REMEMBER_PASSWORD_KEY = "imap_remember_password"; private const string SMTP_USERNAME_KEY = "smtp_username"; @@ -27,6 +28,7 @@ public class Geary.AccountInformation : Object { public const string SETTINGS_FILENAME = "geary.ini"; public const string DEFAULT_NICKNAME = _("Default"); + public const int DEFAULT_PREFETCH_PERIOD_DAYS = 14; public static int default_ordinal = 0; @@ -38,6 +40,7 @@ public class Geary.AccountInformation : Object { public string email { get; set; } public Geary.ServiceProvider service_provider { get; set; } public bool imap_server_pipeline { get; set; default = true; } + public int prefetch_period_days { get; set; } // Order for display purposes. public int ordinal { get; set; } @@ -79,7 +82,10 @@ public class Geary.AccountInformation : Object { smtp_remember_password = get_bool_value(key_file, GROUP, SMTP_REMEMBER_PASSWORD_KEY, true); service_provider = Geary.ServiceProvider.from_string(get_string_value(key_file, GROUP, SERVICE_PROVIDER_KEY, Geary.ServiceProvider.GMAIL.to_string())); + prefetch_period_days = get_int_value(key_file, GROUP, PREFETCH_PERIOD_DAYS_KEY, + DEFAULT_PREFETCH_PERIOD_DAYS); ordinal = get_int_value(key_file, GROUP, ORDINAL_KEY, default_ordinal++); + if (ordinal >= default_ordinal) default_ordinal = ordinal + 1; @@ -365,11 +371,12 @@ public class Geary.AccountInformation : Object { key_file.set_value(GROUP, REAL_NAME_KEY, real_name); key_file.set_value(GROUP, NICKNAME_KEY, nickname); key_file.set_value(GROUP, SERVICE_PROVIDER_KEY, service_provider.to_string()); - key_file.set_value(GROUP, ORDINAL_KEY, ordinal.to_string()); + key_file.set_integer(GROUP, ORDINAL_KEY, ordinal); key_file.set_value(GROUP, IMAP_USERNAME_KEY, imap_credentials.user); key_file.set_boolean(GROUP, IMAP_REMEMBER_PASSWORD_KEY, imap_remember_password); key_file.set_value(GROUP, SMTP_USERNAME_KEY, smtp_credentials.user); key_file.set_boolean(GROUP, SMTP_REMEMBER_PASSWORD_KEY, smtp_remember_password); + key_file.set_integer(GROUP, PREFETCH_PERIOD_DAYS_KEY, prefetch_period_days); key_file.set_boolean(GROUP, IMAP_PIPELINE, imap_server_pipeline); diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala index 32763a2d..ddbdb7ef 100644 --- a/src/engine/imap-db/imap-db-account.vala +++ b/src/engine/imap-db/imap-db-account.vala @@ -116,7 +116,7 @@ private class Geary.ImapDB.Account : Object { // create the folder object Db.Statement stmt = cx.prepare( "INSERT INTO FolderTable (name, parent_id, last_seen_total, last_seen_status_total, " - + "uid_validity, uid_next, attributes) VALUES (?, ?, ?, ?, ?, ?)"); + + "uid_validity, uid_next, attributes) VALUES (?, ?, ?, ?, ?, ?, ?)"); stmt.bind_string(0, path.basename); stmt.bind_rowid(1, parent_id); stmt.bind_int(2, Numeric.int_floor(properties.select_examine_messages, 0)); diff --git a/src/engine/imap-engine/imap-engine-account-synchronizer.vala b/src/engine/imap-engine/imap-engine-account-synchronizer.vala index 9138cdb3..75750bf2 100644 --- a/src/engine/imap-engine/imap-engine-account-synchronizer.vala +++ b/src/engine/imap-engine/imap-engine-account-synchronizer.vala @@ -5,7 +5,6 @@ */ private class Geary.ImapEngine.AccountSynchronizer { - private const int SYNC_DEPTH_DAYS = 15; private const int FETCH_DATE_RECEIVED_CHUNK_COUNT = 25; public GenericAccount account { get; private set; } @@ -165,7 +164,7 @@ private class Geary.ImapEngine.AccountSynchronizer { // generate the current epoch for synchronization (could cache this value, obviously, but // doesn't seem like this biggest win in this class) DateTime epoch = new DateTime.now_local(); - epoch = epoch.add_days(0 - SYNC_DEPTH_DAYS); + epoch = epoch.add_days(0 - account.information.prefetch_period_days); if (!yield process_folder_async(folder, made_available.remove(folder), epoch)) break; diff --git a/ui/login.glade b/ui/login.glade index 8f07f9e7..abc5fad8 100644 --- a/ui/login.glade +++ b/ui/login.glade @@ -739,18 +739,6 @@ - - - - - - - - - - - - @@ -760,5 +748,78 @@ 3 + + + False + 10 + vertical + + + True + False + 8 + 0 + 4 + 6 + Storage + + + + + + False + True + 0 + + + + + True + False + + + True + False + 0 + 12 + _Download mail: + True + + + 0 + 0 + 1 + 1 + + + + + True + False + 0 + 0 + 1 + + + 1 + 0 + 1 + 1 + + + + + False + True + 1 + + + + + False + True + 4 + +