[geary/wip/714104-refine-account-dialog: 175/180] Explicitly pass service info to Engine validation methods
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/714104-refine-account-dialog: 175/180] Explicitly pass service info to Engine validation methods
- Date: Mon, 19 Nov 2018 10:18:58 +0000 (UTC)
commit 37996e41d8d016d63547c657d4966871e81035fc
Author: Michael Gratton <mike vee net>
Date: Sat Nov 17 12:13:40 2018 +1100
Explicitly pass service info to Engine validation methods
This allows validating service info classes that have not yet been added
an account, e.g. when editing an existing account.
src/client/accounts/accounts-editor-add-pane.vala | 12 +++++++++---
src/engine/api/geary-engine.vala | 24 ++++++++++++-----------
2 files changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/src/client/accounts/accounts-editor-add-pane.vala
b/src/client/accounts/accounts-editor-add-pane.vala
index 7d208b75..a1b80089 100644
--- a/src/client/accounts/accounts-editor-add-pane.vala
+++ b/src/client/accounts/accounts-editor-add-pane.vala
@@ -184,7 +184,9 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane {
bool smtp_valid = false;
try {
- yield this.engine.validate_imap(account, cancellable);
+ yield this.engine.validate_imap(
+ account, account.imap, cancellable
+ );
imap_valid = true;
} catch (Geary.ImapError.UNAUTHENTICATED err) {
debug("Error authenticating IMAP service: %s", err.message);
@@ -202,7 +204,9 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane {
if (imap_valid) {
debug("Validating SMTP...");
try {
- yield this.engine.validate_smtp(account, cancellable);
+ yield this.engine.validate_smtp(
+ account, account.smtp, cancellable
+ );
smtp_valid = true;
} catch (Geary.SmtpError.AUTHENTICATION_FAILED err) {
debug("Error authenticating SMTP service: %s", err.message);
@@ -225,7 +229,9 @@ internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane {
is_valid = imap_valid && smtp_valid;
} else {
try {
- yield this.engine.validate_imap(account, cancellable);
+ yield this.engine.validate_imap(
+ account, account.imap, cancellable
+ );
is_valid = true;
} catch (Geary.ImapError.UNAUTHENTICATED err) {
debug("Error authenticating provider: %s", err.message);
diff --git a/src/engine/api/geary-engine.vala b/src/engine/api/geary-engine.vala
index eb401221..977589c5 100644
--- a/src/engine/api/geary-engine.vala
+++ b/src/engine/api/geary-engine.vala
@@ -229,12 +229,13 @@ public class Geary.Engine : BaseObject {
* Determines if an account's IMAP service can be connected to.
*/
public async void validate_imap(AccountInformation account,
+ ServiceInformation service,
GLib.Cancellable? cancellable = null)
throws GLib.Error {
check_opened();
- if (account.imap.port == 0) {
- account.imap.port = account.imap.use_ssl
+ if (service.port == 0) {
+ service.port = service.use_ssl
? Imap.IMAP_TLS_PORT
: Imap.IMAP_PORT;
}
@@ -247,7 +248,7 @@ public class Geary.Engine : BaseObject {
// validate IMAP, which requires logging in and establishing
// an AUTHORIZED cx state
Geary.Imap.ClientSession? imap_session = new Imap.ClientSession(
- account.imap.endpoint
+ service.endpoint
);
// XXX initiate_session_async doesn't seem to actually throw
@@ -261,7 +262,7 @@ public class Geary.Engine : BaseObject {
try {
yield imap_session.connect_async(cancellable);
yield imap_session.initiate_session_async(
- account.imap.credentials, cancellable
+ service.credentials, cancellable
);
} catch (GLib.Error err) {
login_err = err;
@@ -290,17 +291,18 @@ public class Geary.Engine : BaseObject {
* Determines if an account's SMTP service can be connected to.
*/
public async void validate_smtp(AccountInformation account,
+ ServiceInformation service,
GLib.Cancellable? cancellable = null)
throws GLib.Error {
check_opened();
- if (account.smtp.port == 0) {
- if (account.smtp.use_ssl) {
- account.smtp.port = Smtp.SUBMISSION_TLS_PORT;
- } else if (account.smtp.smtp_noauth) {
- account.smtp.port = Smtp.SMTP_PORT;
+ if (service.port == 0) {
+ if (service.use_ssl) {
+ service.port = Smtp.SUBMISSION_TLS_PORT;
+ } else if (service.smtp_noauth) {
+ service.port = Smtp.SMTP_PORT;
} else {
- account.smtp.port = Smtp.SUBMISSION_PORT;
+ service.port = Smtp.SUBMISSION_PORT;
}
}
@@ -310,7 +312,7 @@ public class Geary.Engine : BaseObject {
);
Geary.Smtp.ClientSession? smtp_session = new Geary.Smtp.ClientSession(
- account.smtp.endpoint
+ service.endpoint
);
GLib.Error? login_err = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]