Closes #6402 Prefetch UI options. Also fixes SQL bug in prefetcher for new accounts
This commit is contained in:
parent
81e3896c07
commit
9b8090f524
5 changed files with 124 additions and 17 deletions
|
|
@ -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() == ".";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -739,18 +739,6 @@
|
|||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
@ -760,5 +748,78 @@
|
|||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="storage container">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label: storage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">8</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="xpad">4</property>
|
||||
<property name="ypad">6</property>
|
||||
<property name="label" translatable="yes">Storage</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label: sync">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="xpad">12</property>
|
||||
<property name="label" translatable="yes">_Download mail:</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="combo: storage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<property name="entry_text_column">0</property>
|
||||
<property name="id_column">1</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue