Commit 15285ebe authored by Michael Gratton's avatar Michael Gratton 🤞

Merge branch 'wip/fix-error-on-goa-account-disabled' into 'master'

Fix an error being thrown when an active GOA account is disabled

See merge request !165
parents 833f1d5c 1e826e9f
Pipeline #65705 passed with stages
in 18 minutes and 42 seconds
...@@ -784,11 +784,10 @@ public class Accounts.Manager : GLib.Object { ...@@ -784,11 +784,10 @@ public class Accounts.Manager : GLib.Object {
} }
private bool is_valid_goa_account(Goa.Object handle) { private bool is_valid_goa_account(Goa.Object handle) {
// Goa.Account.mail_disabled doesn't seem to reflect if we get
// get a valid mail object here, so just rely on that instead.
Goa.Mail? mail = handle.get_mail(); Goa.Mail? mail = handle.get_mail();
return ( return (
mail != null && mail != null &&
!handle.get_account().mail_disabled &&
!Geary.String.is_empty(mail.imap_host) && !Geary.String.is_empty(mail.imap_host) &&
!Geary.String.is_empty(mail.smtp_host) !Geary.String.is_empty(mail.smtp_host)
); );
...@@ -838,15 +837,18 @@ public class Accounts.Manager : GLib.Object { ...@@ -838,15 +837,18 @@ public class Accounts.Manager : GLib.Object {
} }
private async void update_goa_account(Geary.AccountInformation account, private async void update_goa_account(Geary.AccountInformation account,
bool is_available,
GLib.Cancellable? cancellable) { GLib.Cancellable? cancellable) {
GoaMediator mediator = (GoaMediator) account.mediator; GoaMediator mediator = (GoaMediator) account.mediator;
try { try {
yield mediator.update(account, cancellable); yield mediator.update(account, cancellable);
// Update will clear the creds, so make sure they get if (is_available) {
// refreshed // Update will clear the creds, so make sure they get
yield account.load_outgoing_credentials(cancellable); // refreshed
yield account.load_incoming_credentials(cancellable); yield account.load_outgoing_credentials(cancellable);
yield account.load_incoming_credentials(cancellable);
}
} catch (GLib.Error err) { } catch (GLib.Error err) {
report_problem( report_problem(
new Geary.AccountProblemReport( new Geary.AccountProblemReport(
...@@ -856,9 +858,7 @@ public class Accounts.Manager : GLib.Object { ...@@ -856,9 +858,7 @@ public class Accounts.Manager : GLib.Object {
)); ));
} }
// XXX need to notify the engine that creds may have changed set_available(account, is_available);
set_available(account, mediator.is_available);
} }
...@@ -929,7 +929,11 @@ public class Accounts.Manager : GLib.Object { ...@@ -929,7 +929,11 @@ public class Accounts.Manager : GLib.Object {
// We already know about this account, so check that it is // We already know about this account, so check that it is
// still valid. If not, the account should be disabled, // still valid. If not, the account should be disabled,
// not deleted, since it may be re-enabled at some point. // not deleted, since it may be re-enabled at some point.
this.update_goa_account.begin(state.account, null); this.update_goa_account.begin(
state.account,
is_valid_goa_account(account),
null
);
} else { } else {
// We haven't created an account for this GOA account // We haven't created an account for this GOA account
// before, so try doing so now. // before, so try doing so now.
......
...@@ -10,15 +10,6 @@ ...@@ -10,15 +10,6 @@
public class GoaMediator : Geary.CredentialsMediator, Object { public class GoaMediator : Geary.CredentialsMediator, Object {
public bool is_available {
get {
// Goa.Account.mail_disabled doesn't seem to reflect if we
// get can get a valid mail object or not, so just rely on
// actually getting one instead.
return this.handle.get_mail() != null;
}
}
private Goa.Object handle; private Goa.Object handle;
...@@ -111,7 +102,7 @@ public class GoaMediator : Geary.CredentialsMediator, Object { ...@@ -111,7 +102,7 @@ public class GoaMediator : Geary.CredentialsMediator, Object {
// password" or "GOA credentials need renewing" or // password" or "GOA credentials need renewing" or
// something. Connect to the GOA service and wait until we // something. Connect to the GOA service and wait until we
// hear that needs attention is no longer true. // hear that needs attention is no longer true.
return this.is_available; return false;
} }
private Geary.Credentials.Method get_auth_method() throws GLib.Error { private Geary.Credentials.Method get_auth_method() throws GLib.Error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment