Add IMAP STARTTLS radio buttons: Closes #5361.

This commit is contained in:
Matthew Pirocchi 2012-08-14 16:03:30 -07:00
parent fe46262903
commit b2e320a6fc
3 changed files with 119 additions and 43 deletions

View file

@ -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;

View file

@ -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();

View file

@ -157,7 +157,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="label" translatable="yes">N_ame:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">real_name</property>
</object>
@ -306,27 +306,6 @@
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="imap ssl">
<property name="label" translatable="yes">SS_L/TLS encryption</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">12</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label: smtp">
<property name="visible">True</property>
@ -341,7 +320,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">5</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
@ -358,7 +337,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -373,7 +352,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -390,7 +369,7 @@
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">4</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -406,7 +385,7 @@
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">4</property>
<property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@ -423,19 +402,18 @@
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="top_attach">7</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="smtp starttls">
<property name="label" translatable="yes">ST_ARTTLS authentication</property>
<property name="label" translatable="yes">STARTTLS aut_hentication</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -450,7 +428,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
<property name="top_attach">9</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
@ -473,7 +451,73 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="top_attach">8</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="imap none">
<property name="label" translatable="yes">_No encryption</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="imap starttls">
<property name="label" translatable="yes">STARTTLS a_uthentication</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">imap none</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="imap ssl">
<property name="label" translatable="yes">SS_L/TLS encryption</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">imap none</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>