[geary/mjog/mutiple-main-windows: 4/14] Promote AccountContext to a top-level internal class
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/mutiple-main-windows: 4/14] Promote AccountContext to a top-level internal class
- Date: Mon, 18 Nov 2019 04:31:58 +0000 (UTC)
commit 0dce50457ad5892fd828aed3eb8a1f0b58f3af94
Author: Michael Gratton <mike vee net>
Date: Wed Nov 13 14:04:05 2019 +1100
Promote AccountContext to a top-level internal class
This class should only be shared amounst application objects, so
make it and accessors on Controller internal.
src/client/application/application-controller.vala | 197 +++++++++++----------
.../application/application-main-window.vala | 14 +-
2 files changed, 108 insertions(+), 103 deletions(-)
---
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index b00a4875..e3957f39 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -31,99 +31,6 @@ public class Application.Controller : Geary.BaseObject {
}
- /**
- * Collects objects and state related to a single open account.
- */
- public class AccountContext : Geary.BaseObject {
-
- /** The account for this context. */
- public Geary.Account account { get; private set; }
-
- /** The account's Inbox folder */
- public Geary.Folder? inbox = null;
-
- /** The account's email store */
- public Geary.App.EmailStore emails { get; private set; }
-
- /** The account's contact store */
- public ContactStore contacts { get; private set; }
-
- /** The account's application command stack. */
- public CommandStack commands {
- get { return this.controller_stack; }
- }
-
- /** A cancellable tied to the life-cycle of the account. */
- public Cancellable cancellable {
- get; private set; default = new Cancellable();
- }
-
- /** The account's application command stack. */
- internal ControllerCommandStack controller_stack {
- get; protected set; default = new ControllerCommandStack();
- }
-
- /** Determines if the account has an authentication problem. */
- internal bool authentication_failed {
- get; private set; default = false;
- }
-
- /** Determines if the account is prompting for a pasword. */
- internal bool authentication_prompting {
- get; private set; default = false;
- }
-
- /** Determines if currently prompting for a password. */
- internal uint authentication_attempts {
- get; private set; default = 0;
- }
-
- /** Determines if any TLS certificate errors have been seen. */
- internal bool tls_validation_failed {
- get; private set; default = false;
- }
-
- /** Determines if currently prompting about TLS certificate errors. */
- internal bool tls_validation_prompting {
- get; private set; default = false;
- }
-
-
- public AccountContext(Geary.Account account,
- Geary.App.EmailStore emails,
- Application.ContactStore contacts) {
- this.account = account;
- this.emails = emails;
- this.contacts = contacts;
- }
-
- /** Returns the current effective status for the account. */
- public Geary.Account.Status get_effective_status() {
- Geary.Account.Status current = this.account.current_status;
- Geary.Account.Status effective = 0;
- if (current.is_online()) {
- effective |= ONLINE;
- }
- if (current.has_service_problem()) {
- // Only retain this flag if the problem isn't auth or
- // cert related, that is handled elsewhere.
- Geary.ClientService.Status incoming =
- account.incoming.current_status;
- Geary.ClientService.Status outgoing =
- account.outgoing.current_status;
- if (incoming != AUTHENTICATION_FAILED &&
- incoming != TLS_VALIDATION_FAILED &&
- outgoing != AUTHENTICATION_FAILED &&
- outgoing != TLS_VALIDATION_FAILED) {
- effective |= SERVICE_PROBLEM;
- }
- }
- return effective;
- }
-
- }
-
-
/** Determines if the controller is open. */
public bool is_open {
get {
@@ -307,10 +214,15 @@ public class Application.Controller : Geary.BaseObject {
}
/** Returns a context for an account, if any. */
- public AccountContext? get_context_for_account(Geary.AccountInformation account) {
+ internal AccountContext? get_context_for_account(Geary.AccountInformation account) {
return this.accounts.get(account);
}
+ /** Returns a read-only collection of contexts each active account. */
+ internal Gee.Collection<AccountContext> get_account_contexts() {
+ return this.accounts.values.read_only_view;
+ }
+
/** Closes all windows and accounts, releasing held resources. */
public async void close() {
this.application.engine.account_available.disconnect(
@@ -1928,6 +1840,99 @@ public class Application.Controller : Geary.BaseObject {
}
+/**
+ * Collects application state related to a single open account.
+ */
+internal class Application.AccountContext : Geary.BaseObject {
+
+ /** The account for this context. */
+ public Geary.Account account { get; private set; }
+
+ /** The account's Inbox folder */
+ public Geary.Folder? inbox = null;
+
+ /** The account's email store */
+ public Geary.App.EmailStore emails { get; private set; }
+
+ /** The account's contact store */
+ public ContactStore contacts { get; private set; }
+
+ /** The account's application command stack. */
+ public CommandStack commands {
+ get { return this.controller_stack; }
+ }
+
+ /** A cancellable tied to the life-cycle of the account. */
+ public Cancellable cancellable {
+ get; private set; default = new Cancellable();
+ }
+
+ /** The account's application command stack. */
+ internal ControllerCommandStack controller_stack {
+ get; protected set; default = new ControllerCommandStack();
+ }
+
+ /** Determines if the account has an authentication problem. */
+ internal bool authentication_failed {
+ get; private set; default = false;
+ }
+
+ /** Determines if the account is prompting for a pasword. */
+ internal bool authentication_prompting {
+ get; private set; default = false;
+ }
+
+ /** Determines if currently prompting for a password. */
+ internal uint authentication_attempts {
+ get; private set; default = 0;
+ }
+
+ /** Determines if any TLS certificate errors have been seen. */
+ internal bool tls_validation_failed {
+ get; private set; default = false;
+ }
+
+ /** Determines if currently prompting about TLS certificate errors. */
+ internal bool tls_validation_prompting {
+ get; private set; default = false;
+ }
+
+
+ public AccountContext(Geary.Account account,
+ Geary.App.EmailStore emails,
+ Application.ContactStore contacts) {
+ this.account = account;
+ this.emails = emails;
+ this.contacts = contacts;
+ }
+
+ /** Returns the current effective status for the account. */
+ public Geary.Account.Status get_effective_status() {
+ Geary.Account.Status current = this.account.current_status;
+ Geary.Account.Status effective = 0;
+ if (current.is_online()) {
+ effective |= ONLINE;
+ }
+ if (current.has_service_problem()) {
+ // Only retain this flag if the problem isn't auth or
+ // cert related, that is handled elsewhere.
+ Geary.ClientService.Status incoming =
+ account.incoming.current_status;
+ Geary.ClientService.Status outgoing =
+ account.outgoing.current_status;
+ if (incoming != AUTHENTICATION_FAILED &&
+ incoming != TLS_VALIDATION_FAILED &&
+ outgoing != AUTHENTICATION_FAILED &&
+ outgoing != TLS_VALIDATION_FAILED) {
+ effective |= SERVICE_PROBLEM;
+ }
+ }
+ return effective;
+ }
+
+}
+
+
/** Base class for all application controller commands. */
internal class Application.ControllerCommandStack : CommandStack {
@@ -2674,14 +2679,14 @@ private class Application.SendComposerCommand : ComposerCommand {
}
private Client application;
- private Controller.AccountContext context;
+ private AccountContext context;
private Geary.Smtp.ClientService smtp;
private Geary.TimeoutManager commit_timer;
private Geary.EmailIdentifier? saved = null;
public SendComposerCommand(Client application,
- Controller.AccountContext context,
+ AccountContext context,
Composer.Widget composer) {
base(composer);
this.application = application;
diff --git a/src/client/application/application-main-window.vala
b/src/client/application/application-main-window.vala
index 10c84a91..255c105d 100644
--- a/src/client/application/application-main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -210,7 +210,7 @@ public class Application.MainWindow :
public StatusBar status_bar { get; private set; default = new StatusBar(); }
private MonitoredSpinner spinner = new MonitoredSpinner();
- private Application.Controller.AccountContext? context = null;
+ private AccountContext? context = null;
private GLib.SimpleActionGroup edit_actions = new GLib.SimpleActionGroup();
@@ -975,7 +975,7 @@ public class Application.MainWindow :
/** Un-does the last executed application command, if any. */
private async void undo() {
- Controller.AccountContext? selected = this.context;
+ AccountContext? selected = this.context;
if (selected != null) {
selected.commands.undo.begin(
selected.cancellable,
@@ -992,7 +992,7 @@ public class Application.MainWindow :
/** Re-does the last undone application command, if any. */
private async void redo() {
- Controller.AccountContext? selected = this.context;
+ AccountContext? selected = this.context;
if (selected != null) {
selected.commands.redo.begin(
selected.cancellable,
@@ -1008,7 +1008,7 @@ public class Application.MainWindow :
}
private void update_command_actions() {
- Controller.AccountContext? selected = this.context;
+ AccountContext? selected = this.context;
get_edit_action(Action.Edit.UNDO).set_enabled(
selected != null && selected.commands.can_undo
);
@@ -1131,7 +1131,7 @@ public class Application.MainWindow :
this.main_toolbar.copy_folder_menu.clear();
this.main_toolbar.move_folder_menu.clear();
- Controller.AccountContext? context = this.context;
+ AccountContext? context = this.context;
if (context != null) {
context.commands.executed.disconnect(on_command_execute);
context.commands.undone.disconnect(on_command_undo);
@@ -1194,7 +1194,7 @@ public class Application.MainWindow :
// last email was removed but the conversation monitor
// hasn't signalled its removal yet. In this case,
// just don't load it since it will soon disappear.
- Controller.AccountContext? context = this.context;
+ AccountContext? context = this.context;
if (context != null && convo.get_count() > 0) {
try {
yield this.conversation_viewer.load_conversation(
@@ -1484,7 +1484,7 @@ public class Application.MainWindow :
Gee.MultiMap<Geary.EmailIdentifier, Type>? selected_operations = null;
if (this.selected_folder != null) {
- Controller.AccountContext? context =
+ AccountContext? context =
this.application.controller.get_context_for_account(
this.selected_folder.account.information
);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]