diff --git a/src/client/ui/geary-login.vala b/src/client/ui/geary-login.vala index 758da454..6e5f57d3 100644 --- a/src/client/ui/geary-login.vala +++ b/src/client/ui/geary-login.vala @@ -16,7 +16,9 @@ public class LoginDialog { private Gtk.Alignment other_info; private Gtk.Entry entry_imap_host; private Gtk.Entry entry_imap_port; - private Gtk.CheckButton check_imap_ssl; + private Gtk.RadioButton radio_imap_none; + private Gtk.RadioButton radio_imap_ssl; + private Gtk.RadioButton radio_imap_starttls; private Gtk.Entry entry_smtp_host; private Gtk.Entry entry_smtp_port; private Gtk.RadioButton radio_smtp_none; @@ -34,15 +36,17 @@ public class LoginDialog { initial_account_information.credentials.pass, initial_account_information.remember_password, initial_account_information.service_provider, initial_account_information.default_imap_server_host, initial_account_information.default_imap_server_port, initial_account_information.default_imap_server_ssl, - initial_account_information.default_smtp_server_host, initial_account_information.default_smtp_server_port, - initial_account_information.default_smtp_server_ssl, initial_account_information.default_smtp_server_starttls); + initial_account_information.default_imap_server_starttls, initial_account_information.default_smtp_server_host, + initial_account_information.default_smtp_server_port, initial_account_information.default_smtp_server_ssl, + initial_account_information.default_smtp_server_starttls); } public LoginDialog(string? initial_real_name = null, string? initial_username = null, string? initial_password = null, bool initial_remember_password = true, int initial_service_provider = -1, string? initial_default_imap_host = null, uint16 initial_default_imap_port = Geary.Imap.ClientConnection.DEFAULT_PORT_SSL, - bool initial_default_imap_ssl = true, string? initial_default_smtp_host = null, + bool initial_default_imap_ssl = true, bool initial_default_imap_starttls = false, + string? initial_default_smtp_host = null, uint16 initial_default_smtp_port = Geary.Smtp.ClientConnection.DEFAULT_PORT_SSL, bool initial_default_smtp_ssl = true, bool initial_default_smtp_starttls = false) { Gtk.Builder builder = GearyApplication.instance.create_builder("login.glade"); @@ -58,9 +62,13 @@ public class LoginDialog { check_remember_password = builder.get_object("remember_password") as Gtk.CheckButton; other_info = builder.get_object("other_info") as Gtk.Alignment; + entry_imap_host = builder.get_object("imap host") as Gtk.Entry; entry_imap_port = builder.get_object("imap port") as Gtk.Entry; - check_imap_ssl = builder.get_object("imap ssl") as Gtk.CheckButton; + radio_imap_none = builder.get_object("imap none") as Gtk.RadioButton; + radio_imap_ssl = builder.get_object("imap ssl") as Gtk.RadioButton; + radio_imap_starttls = builder.get_object("imap starttls") as Gtk.RadioButton; + entry_smtp_host = builder.get_object("smtp host") as Gtk.Entry; entry_smtp_port = builder.get_object("smtp port") as Gtk.Entry; radio_smtp_none = builder.get_object("smtp none") as Gtk.RadioButton; @@ -83,9 +91,13 @@ public class LoginDialog { entry_username.set_text(initial_username ?? ""); entry_password.set_text(initial_password ?? ""); check_remember_password.active = initial_remember_password; + entry_imap_host.set_text(initial_default_imap_host ?? ""); entry_imap_port.set_text(initial_default_imap_port.to_string()); - check_imap_ssl.active = initial_default_imap_ssl; + radio_imap_none.active = true; + radio_imap_ssl.active = initial_default_imap_ssl; + radio_imap_starttls.active = initial_default_imap_starttls; + entry_smtp_host.set_text(initial_default_smtp_host ?? ""); entry_smtp_port.set_text(initial_default_smtp_port.to_string()); radio_smtp_none.active = true; @@ -107,7 +119,9 @@ public class LoginDialog { entry_smtp_host.changed.connect(on_changed); entry_smtp_port.changed.connect(on_changed); - check_imap_ssl.toggled.connect(on_check_imap_ssl_toggled); + radio_imap_none.toggled.connect(on_radio_imap_toggled); + radio_imap_ssl.toggled.connect(on_radio_imap_toggled); + radio_imap_starttls.toggled.connect(on_radio_imap_toggled); radio_smtp_none.toggled.connect(on_radio_smtp_toggled); radio_smtp_ssl.toggled.connect(on_radio_smtp_toggled); @@ -143,7 +157,8 @@ public class LoginDialog { account_information.service_provider = get_service_provider(); account_information.default_imap_server_host = entry_imap_host.text.strip(); account_information.default_imap_server_port = (uint16) int.parse(entry_imap_port.text.strip()); - account_information.default_imap_server_ssl = check_imap_ssl.active; + account_information.default_imap_server_ssl = radio_imap_ssl.active; + account_information.default_imap_server_starttls = radio_imap_starttls.active; account_information.default_smtp_server_host = entry_smtp_host.text.strip(); account_information.default_smtp_server_port = (uint16) int.parse(entry_smtp_port.text.strip()); account_information.default_smtp_server_ssl = radio_smtp_ssl.active; @@ -180,15 +195,23 @@ public class LoginDialog { } } - private void on_check_imap_ssl_toggled() { + private void on_radio_imap_toggled() { if (edited_imap_port) return; - entry_imap_port.text = (check_imap_ssl.active ? Geary.Imap.ClientConnection.DEFAULT_PORT_SSL : - Geary.Imap.ClientConnection.DEFAULT_PORT).to_string(); + entry_imap_port.text = get_default_imap_port().to_string(); edited_imap_port = false; } + private uint16 get_default_imap_port() { + if (radio_imap_ssl.active) + return Geary.Imap.ClientConnection.DEFAULT_PORT_SSL; + if (radio_imap_starttls.active) + return Geary.Imap.ClientConnection.DEFAULT_PORT; + + return Geary.Imap.ClientConnection.DEFAULT_PORT; + } + private void on_radio_smtp_toggled() { if (edited_smtp_port) return; diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala index 7efc093c..55c87aa6 100644 --- a/src/engine/api/geary-account-information.vala +++ b/src/engine/api/geary-account-information.vala @@ -12,10 +12,12 @@ public class Geary.AccountInformation : Object { private const string IMAP_HOST = "imap_host"; private const string IMAP_PORT = "imap_port"; private const string IMAP_SSL = "imap_ssl"; + private const string IMAP_STARTTLS = "imap_starttls"; private const string IMAP_PIPELINE = "imap_pipeline"; private const string SMTP_HOST = "smtp_host"; private const string SMTP_PORT = "smtp_port"; private const string SMTP_SSL = "smtp_ssl"; + private const string SMTP_STARTTLS = "smtp_starttls"; public const string SETTINGS_FILENAME = "geary.ini"; @@ -29,6 +31,7 @@ public class Geary.AccountInformation : Object { public string default_imap_server_host { get; set; } public uint16 default_imap_server_port { get; set; } public bool default_imap_server_ssl { get; set; } + public bool default_imap_server_starttls { get; set; } public string default_smtp_server_host { get; set; } public uint16 default_smtp_server_port { get; set; } public bool default_smtp_server_ssl { get; set; } @@ -65,11 +68,13 @@ public class Geary.AccountInformation : Object { default_imap_server_port = get_uint16_value(key_file, GROUP, IMAP_PORT, Imap.ClientConnection.DEFAULT_PORT_SSL); default_imap_server_ssl = get_bool_value(key_file, GROUP, IMAP_SSL, true); + default_imap_server_starttls = get_bool_value(key_file, GROUP, IMAP_STARTTLS, false); default_smtp_server_host = get_string_value(key_file, GROUP, SMTP_HOST); default_smtp_server_port = get_uint16_value(key_file, GROUP, SMTP_PORT, Geary.Smtp.ClientConnection.DEFAULT_PORT_SSL); default_smtp_server_ssl = get_bool_value(key_file, GROUP, SMTP_SSL, true); + default_smtp_server_starttls = get_bool_value(key_file, GROUP, SMTP_STARTTLS, false); } } } @@ -118,6 +123,8 @@ public class Geary.AccountInformation : Object { Endpoint.Flags imap_flags = Endpoint.Flags.GRACEFUL_DISCONNECT; if (default_imap_server_ssl) imap_flags |= Endpoint.Flags.SSL; + if (default_imap_server_starttls) + imap_flags |= Endpoint.Flags.STARTTLS; return new Endpoint(default_imap_server_host, default_imap_server_port, imap_flags, Imap.ClientConnection.RECOMMENDED_TIMEOUT_SEC); @@ -239,10 +246,12 @@ public class Geary.AccountInformation : Object { key_file.set_value(GROUP, IMAP_HOST, default_imap_server_host); key_file.set_integer(GROUP, IMAP_PORT, default_imap_server_port); key_file.set_boolean(GROUP, IMAP_SSL, default_imap_server_ssl); + key_file.set_boolean(GROUP, IMAP_STARTTLS, default_imap_server_starttls); key_file.set_value(GROUP, SMTP_HOST, default_smtp_server_host); key_file.set_integer(GROUP, SMTP_PORT, default_smtp_server_port); key_file.set_boolean(GROUP, SMTP_SSL, default_smtp_server_ssl); + key_file.set_boolean(GROUP, SMTP_STARTTLS, default_smtp_server_starttls); } string data = key_file.to_data(); diff --git a/ui/login.glade b/ui/login.glade index 6b40bc78..790ab799 100644 --- a/ui/login.glade +++ b/ui/login.glade @@ -157,7 +157,7 @@ True False 0 - _Name: + N_ame: True real_name @@ -306,27 +306,6 @@ 1 - - - SS_L/TLS encryption - False - True - True - False - 12 - False - True - 0 - True - True - - - 0 - 2 - 4 - 1 - - True @@ -341,7 +320,7 @@ 0 - 3 + 5 4 1 @@ -358,7 +337,7 @@ 0 - 4 + 6 1 1 @@ -373,7 +352,7 @@ 1 - 4 + 6 1 1 @@ -390,7 +369,7 @@ 2 - 4 + 6 1 1 @@ -406,7 +385,7 @@ 3 - 4 + 6 1 1 @@ -423,19 +402,18 @@ False True 0 - True True 0 - 5 + 7 4 1 - ST_ARTTLS authentication + STARTTLS aut_hentication False True True @@ -450,7 +428,7 @@ 0 - 7 + 9 4 1 @@ -473,7 +451,73 @@ 0 - 6 + 8 + 4 + 1 + + + + + _No encryption + False + True + True + False + 12 + 12 + False + True + 0 + True + + + 0 + 2 + 4 + 1 + + + + + STARTTLS a_uthentication + False + True + True + False + 12 + 12 + False + True + 0 + True + imap none + + + 0 + 4 + 4 + 1 + + + + + SS_L/TLS encryption + False + True + True + False + 12 + 12 + False + True + 0 + True + True + imap none + + + 0 + 3 4 1