[geary/wip/714104-refine-account-dialog: 172/180] Move IMAP & SMTP default port consts up into public API
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/714104-refine-account-dialog: 172/180] Move IMAP & SMTP default port consts up into public API
- Date: Mon, 19 Nov 2018 10:18:43 +0000 (UTC)
commit 61be50e9e3c687e77e2ef388ef8ac0b5c9bd2abc
Author: Michael Gratton <mike vee net>
Date: Thu Nov 15 01:02:19 2018 +1100
Move IMAP & SMTP default port consts up into public API
Don't make Engine API clients go looking in obscure internal classes to
find them.
.../accounts/accounts-editor-servers-pane.vala | 10 ++++-----
src/client/accounts/add-edit-page.vala | 14 ++++++-------
src/client/accounts/goa-service-information.vala | 10 ++++-----
src/console/main.vala | 6 ++++--
src/engine/api/geary-engine.vala | 10 ++++-----
src/engine/api/geary-service-information.vala | 24 ++++++++++++++++++++++
.../gmail/imap-engine-gmail-account.vala | 4 ++--
.../outlook/imap-engine-outlook-account.vala | 4 ++--
.../yahoo/imap-engine-yahoo-account.vala | 4 ++--
.../imap/transport/imap-client-connection.vala | 6 ------
src/engine/smtp/smtp-client-connection.vala | 9 --------
src/mailer/main.vala | 11 ++++++----
12 files changed, 63 insertions(+), 49 deletions(-)
---
diff --git a/src/client/accounts/accounts-editor-servers-pane.vala
b/src/client/accounts/accounts-editor-servers-pane.vala
index 75f11098..b10e640e 100644
--- a/src/client/accounts/accounts-editor-servers-pane.vala
+++ b/src/client/accounts/accounts-editor-servers-pane.vala
@@ -305,22 +305,22 @@ private class Accounts.ServiceHostRow :
Geary.TlsNegotiationMethod security = this.service.transport_security;
switch (this.service.protocol) {
case Geary.Protocol.IMAP:
- if (!(port == Geary.Imap.ClientConnection.IMAP_PORT &&
+ if (!(port == Geary.Imap.IMAP_PORT &&
(security == Geary.TlsNegotiationMethod.NONE ||
security == Geary.TlsNegotiationMethod.START_TLS)) &&
- !(port == Geary.Imap.ClientConnection.IMAP_TLS_PORT &&
+ !(port == Geary.Imap.IMAP_TLS_PORT &&
security == Geary.TlsNegotiationMethod.TRANSPORT)) {
custom_port = true;
}
break;
case Geary.Protocol.SMTP:
- if (!(port == Geary.Smtp.ClientConnection.SMTP_PORT &&
+ if (!(port == Geary.Smtp.SMTP_PORT &&
(security == Geary.TlsNegotiationMethod.NONE ||
security == Geary.TlsNegotiationMethod.START_TLS)) &&
- !(port == Geary.Smtp.ClientConnection.SUBMISSION_PORT &&
+ !(port == Geary.Smtp.SUBMISSION_PORT &&
(security == Geary.TlsNegotiationMethod.NONE ||
security == Geary.TlsNegotiationMethod.START_TLS)) &&
- !(port == Geary.Smtp.ClientConnection.SUBMISSION_TLS_PORT &&
+ !(port == Geary.Smtp.SUBMISSION_TLS_PORT &&
security == Geary.TlsNegotiationMethod.TRANSPORT)) {
custom_port = true;
}
diff --git a/src/client/accounts/add-edit-page.vala b/src/client/accounts/add-edit-page.vala
index 75d507e8..07d399f1 100644
--- a/src/client/accounts/add-edit-page.vala
+++ b/src/client/accounts/add-edit-page.vala
@@ -416,11 +416,11 @@ public class AddEditPage : Gtk.Box {
bool initial_save_sent_mail = true,
bool allow_save_sent_mail = true,
string? initial_default_imap_host = null,
- uint16 initial_default_imap_port = Geary.Imap.ClientConnection.IMAP_TLS_PORT,
+ uint16 initial_default_imap_port = Geary.Imap.IMAP_TLS_PORT,
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.SUBMISSION_PORT,
+ uint16 initial_default_smtp_port = Geary.Smtp.SUBMISSION_PORT,
bool initial_default_smtp_ssl = false,
bool initial_default_smtp_starttls = true,
bool initial_default_smtp_use_imap_credentials = false,
@@ -559,12 +559,12 @@ public class AddEditPage : Gtk.Box {
private uint16 get_default_imap_port() {
switch (combo_imap_encryption.active) {
case Encryption.SSL:
- return Geary.Imap.ClientConnection.IMAP_TLS_PORT;
+ return Geary.Imap.IMAP_TLS_PORT;
case Encryption.NONE:
case Encryption.STARTTLS:
default:
- return Geary.Imap.ClientConnection.IMAP_PORT;
+ return Geary.Imap.IMAP_PORT;
}
}
@@ -614,14 +614,14 @@ public class AddEditPage : Gtk.Box {
private uint16 get_default_smtp_port() {
switch (combo_smtp_encryption.active) {
case Encryption.SSL:
- return Geary.Smtp.ClientConnection.SUBMISSION_TLS_PORT;
+ return Geary.Smtp.SUBMISSION_TLS_PORT;
case Encryption.STARTTLS:
- return Geary.Smtp.ClientConnection.SUBMISSION_PORT;
+ return Geary.Smtp.SUBMISSION_PORT;
case Encryption.NONE:
default:
- return Geary.Smtp.ClientConnection.SMTP_PORT;
+ return Geary.Smtp.SMTP_PORT;
}
}
diff --git a/src/client/accounts/goa-service-information.vala
b/src/client/accounts/goa-service-information.vala
index 06e81f2a..a27ba67e 100644
--- a/src/client/accounts/goa-service-information.vala
+++ b/src/client/accounts/goa-service-information.vala
@@ -31,8 +31,8 @@ public class GoaServiceInformation : Geary.ServiceInformation {
if (this.port == 0) {
this.port = this.use_ssl
- ? Geary.Imap.ClientConnection.IMAP_TLS_PORT
- : Geary.Imap.ClientConnection.IMAP_PORT;
+ ? Geary.Imap.IMAP_TLS_PORT
+ : Geary.Imap.IMAP_PORT;
}
this.credentials = new Geary.Credentials(
@@ -50,11 +50,11 @@ public class GoaServiceInformation : Geary.ServiceInformation {
if (this.port == 0) {
if (this.use_ssl) {
- this.port = Geary.Smtp.ClientConnection.SUBMISSION_TLS_PORT;
+ this.port = Geary.Smtp.SUBMISSION_TLS_PORT;
} else if (this.smtp_noauth) {
- this.port = Geary.Smtp.ClientConnection.SMTP_PORT;
+ this.port = Geary.Smtp.SMTP_PORT;
} else {
- this.port = Geary.Smtp.ClientConnection.SUBMISSION_PORT;
+ this.port = Geary.Smtp.SUBMISSION_PORT;
}
}
diff --git a/src/console/main.vala b/src/console/main.vala
index e373a748..6a2bbd61 100644
--- a/src/console/main.vala
+++ b/src/console/main.vala
@@ -11,6 +11,8 @@ errordomain CommandException {
STATE
}
+const int IMAP_TIMEOUT_SEC = 60 * 15;
+
class ImapConsole : Gtk.Window {
private const int KEEPALIVE_SEC = 60 * 10;
@@ -310,9 +312,9 @@ class ImapConsole : Gtk.Window {
cx = new Geary.Imap.ClientConnection(
new Geary.Endpoint(
args[0],
- Geary.Imap.ClientConnection.IMAP_TLS_PORT,
+ Geary.Imap.IMAP_TLS_PORT,
method,
- Geary.Imap.ClientConnection.DEFAULT_TIMEOUT_SEC
+ IMAP_TIMEOUT_SEC
)
);
diff --git a/src/engine/api/geary-engine.vala b/src/engine/api/geary-engine.vala
index b577e909..eb401221 100644
--- a/src/engine/api/geary-engine.vala
+++ b/src/engine/api/geary-engine.vala
@@ -235,8 +235,8 @@ public class Geary.Engine : BaseObject {
if (account.imap.port == 0) {
account.imap.port = account.imap.use_ssl
- ? Imap.ClientConnection.IMAP_TLS_PORT
- : Imap.ClientConnection.IMAP_PORT;
+ ? Imap.IMAP_TLS_PORT
+ : Imap.IMAP_PORT;
}
account.untrusted_host.connect(on_untrusted_host);
@@ -296,11 +296,11 @@ public class Geary.Engine : BaseObject {
if (account.smtp.port == 0) {
if (account.smtp.use_ssl) {
- account.smtp.port = Smtp.ClientConnection.SUBMISSION_TLS_PORT;
+ account.smtp.port = Smtp.SUBMISSION_TLS_PORT;
} else if (account.smtp.smtp_noauth) {
- account.smtp.port = Smtp.ClientConnection.SMTP_PORT;
+ account.smtp.port = Smtp.SMTP_PORT;
} else {
- account.smtp.port = Smtp.ClientConnection.SUBMISSION_PORT;
+ account.smtp.port = Smtp.SUBMISSION_PORT;
}
}
diff --git a/src/engine/api/geary-service-information.vala b/src/engine/api/geary-service-information.vala
index 1c2315fa..f14d7651 100644
--- a/src/engine/api/geary-service-information.vala
+++ b/src/engine/api/geary-service-information.vala
@@ -33,6 +33,30 @@ public enum Geary.Protocol {
}
+namespace Geary.Smtp {
+
+ /** Default clear-text SMTP network port */
+ public const uint16 SMTP_PORT = 25;
+
+ /** Default clear-text SMTP submission network port */
+ public const uint16 SUBMISSION_PORT = 587;
+
+ /** Default transport-layer-encrypted SMTP submission network port */
+ public const uint16 SUBMISSION_TLS_PORT = 465;
+
+}
+
+
+namespace Geary.Imap {
+
+ /** Default clear-text IMAP network port */
+ public const uint16 IMAP_PORT = 143;
+
+ /** Default transport-layer-encrypted IMAP network port */
+ public const uint16 IMAP_TLS_PORT = 993;
+
+}
+
/** The method used to negotiate a TLS session, if any. */
public enum Geary.TlsNegotiationMethod {
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
b/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
index db902f37..0fac7b4f 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
@@ -19,13 +19,13 @@ private class Geary.ImapEngine.GmailAccount : Geary.ImapEngine.GenericAccount {
switch (service.protocol) {
case Protocol.IMAP:
service.host = "imap.gmail.com";
- service.port = Imap.ClientConnection.IMAP_TLS_PORT;
+ service.port = Imap.IMAP_TLS_PORT;
service.use_ssl = true;
break;
case Protocol.SMTP:
service.host = "smtp.gmail.com";
- service.port = Smtp.ClientConnection.SUBMISSION_TLS_PORT;
+ service.port = Smtp.SUBMISSION_TLS_PORT;
service.use_ssl = true;
break;
}
diff --git a/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
b/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
index 39d36498..379a89b9 100644
--- a/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
+++ b/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
@@ -11,13 +11,13 @@ private class Geary.ImapEngine.OutlookAccount : Geary.ImapEngine.GenericAccount
switch (service.protocol) {
case Protocol.IMAP:
service.host = "imap-mail.outlook.com";
- service.port = Imap.ClientConnection.IMAP_TLS_PORT;
+ service.port = Imap.IMAP_TLS_PORT;
service.use_ssl = true;
break;
case Protocol.SMTP:
service.host = "smtp-mail.outlook.com";
- service.port = Smtp.ClientConnection.SUBMISSION_PORT;
+ service.port = Smtp.SUBMISSION_PORT;
service.use_ssl = false;
service.use_starttls = true;
break;
diff --git a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
index 5c11b3ff..0ca75e39 100644
--- a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
+++ b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
@@ -14,13 +14,13 @@ private class Geary.ImapEngine.YahooAccount : Geary.ImapEngine.GenericAccount {
switch (service.protocol) {
case Protocol.IMAP:
service.host = "imap.mail.yahoo.com";
- service.port = Imap.ClientConnection.IMAP_TLS_PORT;
+ service.port = Imap.IMAP_TLS_PORT;
service.use_ssl = true;
break;
case Protocol.SMTP:
service.host = "smtp.mail.yahoo.com";
- service.port = Smtp.ClientConnection.SUBMISSION_TLS_PORT;
+ service.port = Smtp.SUBMISSION_TLS_PORT;
service.use_ssl = true;
break;
}
diff --git a/src/engine/imap/transport/imap-client-connection.vala
b/src/engine/imap/transport/imap-client-connection.vala
index 40158ec0..af147940 100644
--- a/src/engine/imap/transport/imap-client-connection.vala
+++ b/src/engine/imap/transport/imap-client-connection.vala
@@ -8,12 +8,6 @@
public class Geary.Imap.ClientConnection : BaseObject {
- /** Default clear-text IMAP network port */
- public const uint16 IMAP_PORT = 143;
-
- /** Default transport-layer-encrypted IMAP network port */
- public const uint16 IMAP_TLS_PORT = 993;
-
/**
* Default socket timeout duration.
*
diff --git a/src/engine/smtp/smtp-client-connection.vala b/src/engine/smtp/smtp-client-connection.vala
index 0369263f..56e40ca3 100644
--- a/src/engine/smtp/smtp-client-connection.vala
+++ b/src/engine/smtp/smtp-client-connection.vala
@@ -6,15 +6,6 @@
public class Geary.Smtp.ClientConnection {
- /** Default clear-text SMTP network port */
- public const uint16 SMTP_PORT = 25;
-
- /** Default clear-text SMTP submission network port */
- public const uint16 SUBMISSION_PORT = 587;
-
- /** Default transport-layer-encrypted SMTP submission network port */
- public const uint16 SUBMISSION_TLS_PORT = 465;
-
public const uint DEFAULT_TIMEOUT_SEC = 20;
public Geary.Smtp.Capabilities? capabilities { get; private set; default = null; }
diff --git a/src/mailer/main.vala b/src/mailer/main.vala
index 628305eb..6344a6f9 100644
--- a/src/mailer/main.vala
+++ b/src/mailer/main.vala
@@ -99,6 +99,8 @@ const OptionEntry[] options = {
{ null }
};
+const int SMTP_TIMEOUT_SEC = 30;
+
bool verify_required(string? arg, string name) {
if (!Geary.String.is_empty(arg))
return true;
@@ -139,17 +141,18 @@ int main(string[] args) {
if (arg_gmail) {
endpoint = new Geary.Endpoint(
"smtp.gmail.com",
- Geary.Smtp.ClientConnection.SUBMISSION_PORT,
+ Geary.Smtp.SUBMISSION_PORT,
Geary.TlsNegotiationMethod.START_TLS,
- Geary.Smtp.ClientConnection.DEFAULT_TIMEOUT_SEC
+ SMTP_TIMEOUT_SEC
);
} else {
Geary.TlsNegotiationMethod method = Geary.TlsNegotiationMethod.TRANSPORT;
if (arg_no_tls) {
method = Geary.TlsNegotiationMethod.START_TLS;
}
- endpoint = new Geary.Endpoint(arg_hostname, (uint16) arg_port, method,
- Geary.Smtp.ClientConnection.DEFAULT_TIMEOUT_SEC);
+ endpoint = new Geary.Endpoint(
+ arg_hostname, (uint16) arg_port, method, SMTP_TIMEOUT_SEC
+ );
}
stdout.printf("Enabling debug: %s\n", arg_debug.to_string());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]