Move AccountManager and related objects into Accounts package.
This makes the manager consistent with the source file naming convention and the new account UI classes.
This commit is contained in:
parent
74fa29b73f
commit
5305c27ca7
9 changed files with 44 additions and 43 deletions
|
|
@ -15,7 +15,6 @@ src/client/accounts/account-dialog-remove-fail-pane.vala
|
|||
src/client/accounts/account-dialog-spinner-pane.vala
|
||||
src/client/accounts/account-dialog.vala
|
||||
src/client/accounts/account-dialogs.vala
|
||||
src/client/accounts/account-manager.vala
|
||||
src/client/accounts/account-spinner-page.vala
|
||||
src/client/accounts/accounts-editor.vala
|
||||
src/client/accounts/accounts-editor-edit-pane.vala
|
||||
|
|
@ -23,6 +22,7 @@ src/client/accounts/accounts-editor-list-pane.vala
|
|||
src/client/accounts/accounts-editor-remove-pane.vala
|
||||
src/client/accounts/accounts-editor-row.vala
|
||||
src/client/accounts/accounts-editor-servers-pane.vala
|
||||
src/client/accounts/accounts-manager.vala
|
||||
src/client/accounts/add-edit-page.vala
|
||||
src/client/accounts/editor.vala
|
||||
src/client/accounts/goa-service-information.vala
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class AccountDialogAccountListPane : AccountDialogPane {
|
|||
ACCOUNT_ADDRESS;
|
||||
}
|
||||
|
||||
private AccountManager account_manager;
|
||||
private Accounts.Manager account_manager;
|
||||
|
||||
private Gtk.TreeView list_view;
|
||||
private Gtk.ListStore list_model = new Gtk.ListStore(3, typeof(string), typeof(string), typeof(string));
|
||||
|
|
@ -25,7 +25,7 @@ public class AccountDialogAccountListPane : AccountDialogPane {
|
|||
|
||||
public signal void delete_account(string id);
|
||||
|
||||
public AccountDialogAccountListPane(AccountManager account_manager,
|
||||
public AccountDialogAccountListPane(Accounts.Manager account_manager,
|
||||
Gtk.Stack stack) {
|
||||
base(stack);
|
||||
this.account_manager = account_manager;
|
||||
|
|
@ -142,7 +142,7 @@ public class AccountDialogAccountListPane : AccountDialogPane {
|
|||
}
|
||||
|
||||
private void on_account_added(Geary.AccountInformation account,
|
||||
AccountManager.Status status) {
|
||||
Accounts.Manager.Status status) {
|
||||
add_account_impl(account);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane {
|
|||
|
||||
protected weak Accounts.Editor editor { get; set; }
|
||||
|
||||
private AccountManager accounts { get; private set; }
|
||||
private Manager accounts { get; private set; }
|
||||
|
||||
private Application.CommandStack commands {
|
||||
get; private set; default = new Application.CommandStack();
|
||||
|
|
@ -87,7 +87,7 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane {
|
|||
|
||||
/** Adds a new account to the list. */
|
||||
internal void add_account(Geary.AccountInformation account,
|
||||
AccountManager.Status status) {
|
||||
Manager.Status status) {
|
||||
this.accounts_list.add(new AccountListRow(account, status));
|
||||
}
|
||||
|
||||
|
|
@ -144,12 +144,12 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane {
|
|||
}
|
||||
|
||||
private void on_account_added(Geary.AccountInformation account,
|
||||
AccountManager.Status status) {
|
||||
Manager.Status status) {
|
||||
add_account(account, status);
|
||||
}
|
||||
|
||||
private void on_account_status_changed(Geary.AccountInformation account,
|
||||
AccountManager.Status status) {
|
||||
Manager.Status status) {
|
||||
AccountListRow? row = get_account_row(account);
|
||||
if (row != null) {
|
||||
row.update(status);
|
||||
|
|
@ -209,7 +209,7 @@ private class Accounts.AccountListRow : EditorRow<EditorListPane> {
|
|||
|
||||
|
||||
public AccountListRow(Geary.AccountInformation account,
|
||||
AccountManager.Status status) {
|
||||
Manager.Status status) {
|
||||
this.account = account;
|
||||
|
||||
this.account_name.show();
|
||||
|
|
@ -225,8 +225,8 @@ private class Accounts.AccountListRow : EditorRow<EditorListPane> {
|
|||
update(status);
|
||||
}
|
||||
|
||||
public void update(AccountManager.Status status) {
|
||||
if (status != AccountManager.Status.UNAVAILABLE) {
|
||||
public void update(Manager.Status status) {
|
||||
if (status != Manager.Status.UNAVAILABLE) {
|
||||
this.unavailable_icon.hide();
|
||||
this.set_tooltip_text("");
|
||||
} else {
|
||||
|
|
@ -258,7 +258,7 @@ private class Accounts.AccountListRow : EditorRow<EditorListPane> {
|
|||
}
|
||||
this.account_details.set_text(details);
|
||||
|
||||
if (status == AccountManager.Status.ENABLED) {
|
||||
if (status == Manager.Status.ENABLED) {
|
||||
this.account_name.get_style_context().remove_class(
|
||||
Gtk.STYLE_CLASS_DIM_LABEL
|
||||
);
|
||||
|
|
@ -282,11 +282,11 @@ internal class Accounts.RemoveAccountCommand : Application.Command {
|
|||
|
||||
|
||||
private Geary.AccountInformation account;
|
||||
private AccountManager manager;
|
||||
private Manager manager;
|
||||
|
||||
|
||||
public RemoveAccountCommand(Geary.AccountInformation account,
|
||||
AccountManager manager) {
|
||||
Manager manager) {
|
||||
this.account = account;
|
||||
this.manager = manager;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
/**
|
||||
* Current supported credential providers.
|
||||
*/
|
||||
public enum CredentialsProvider {
|
||||
public enum Accounts.CredentialsProvider {
|
||||
/** Credentials are provided and stored by libsecret. */
|
||||
LIBSECRET,
|
||||
|
||||
|
|
@ -30,7 +30,8 @@ public enum CredentialsProvider {
|
|||
}
|
||||
}
|
||||
|
||||
public static CredentialsProvider from_string(string str) throws Error {
|
||||
public static CredentialsProvider from_string(string str)
|
||||
throws GLib.Error {
|
||||
switch (str.ascii_down()) {
|
||||
case "libsecret":
|
||||
return LIBSECRET;
|
||||
|
|
@ -46,7 +47,7 @@ public enum CredentialsProvider {
|
|||
}
|
||||
}
|
||||
|
||||
errordomain AccountError {
|
||||
public errordomain Accounts.Error {
|
||||
INVALID,
|
||||
LOCAL_REMOVED,
|
||||
GOA_REMOVED;
|
||||
|
|
@ -66,7 +67,7 @@ errordomain AccountError {
|
|||
* manager with a particular status (enabled, disabled, etc). Accounts
|
||||
* can have their enabled or disabled status updated manually,
|
||||
*/
|
||||
public class AccountManager : GLib.Object {
|
||||
public class Accounts.Manager : GLib.Object {
|
||||
|
||||
|
||||
private const string LOCAL_ID_PREFIX = "account_";
|
||||
|
|
@ -182,9 +183,9 @@ public class AccountManager : GLib.Object {
|
|||
public signal void report_problem(Geary.ProblemReport problem);
|
||||
|
||||
|
||||
public AccountManager(GearyApplication application,
|
||||
GLib.File user_config_dir,
|
||||
GLib.File user_data_dir) {
|
||||
public Manager(GearyApplication application,
|
||||
GLib.File user_config_dir,
|
||||
GLib.File user_data_dir) {
|
||||
this.application = application;
|
||||
this.user_config_dir = user_config_dir;
|
||||
this.user_data_dir = user_data_dir;
|
||||
|
|
@ -424,7 +425,7 @@ public class AccountManager : GLib.Object {
|
|||
*/
|
||||
private async Geary.AccountInformation
|
||||
load_account(string id, GLib.Cancellable? cancellable)
|
||||
throws Error {
|
||||
throws GLib.Error {
|
||||
GLib.File config_dir = this.user_config_dir.get_child(id);
|
||||
GLib.File data_dir = this.user_data_dir.get_child(id);
|
||||
|
||||
|
|
@ -470,7 +471,7 @@ public class AccountManager : GLib.Object {
|
|||
// but have a working GOA connection, so it must
|
||||
// have been removed. Not much else that we can do
|
||||
// except remove it.
|
||||
throw new AccountError.GOA_REMOVED("GOA account not found");
|
||||
throw new Error.GOA_REMOVED("GOA account not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -478,7 +479,7 @@ public class AccountManager : GLib.Object {
|
|||
// We have a GOA account, but either GOA is
|
||||
// unavailable or the account has changed. Keep it
|
||||
// around in case GOA comes back.
|
||||
throw new AccountError.INVALID("GOA not available");
|
||||
throw new Error.INVALID("GOA not available");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -545,7 +546,7 @@ public class AccountManager : GLib.Object {
|
|||
if (manager_config.exists &&
|
||||
manager_config.get_bool(REMOVED_KEY, false)) {
|
||||
this.removed.add(info);
|
||||
throw new AccountError.LOCAL_REMOVED("Account marked for removal");
|
||||
throw new Error.LOCAL_REMOVED("Account marked for removal");
|
||||
}
|
||||
|
||||
return info;
|
||||
|
|
@ -556,7 +557,7 @@ public class AccountManager : GLib.Object {
|
|||
throws GLib.Error {
|
||||
File? file = info.settings_file;
|
||||
if (file == null) {
|
||||
throw new AccountError.INVALID(
|
||||
throw new Error.INVALID(
|
||||
"Account information does not have a settings file"
|
||||
);
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ public class GearyController : Geary.BaseObject {
|
|||
|
||||
public weak GearyApplication application { get; private set; } // circular ref
|
||||
|
||||
public AccountManager? account_manager { get; private set; default = null; }
|
||||
public Accounts.Manager? account_manager { get; private set; default = null; }
|
||||
|
||||
public MainWindow? main_window { get; private set; default = null; }
|
||||
|
||||
|
|
@ -302,7 +302,7 @@ public class GearyController : Geary.BaseObject {
|
|||
}
|
||||
|
||||
// Start Geary.
|
||||
this.account_manager = new AccountManager(
|
||||
this.account_manager = new Accounts.Manager(
|
||||
this.application,
|
||||
this.application.get_user_config_directory(),
|
||||
this.application.get_user_data_directory()
|
||||
|
|
@ -3087,8 +3087,8 @@ public class GearyController : Geary.BaseObject {
|
|||
}
|
||||
|
||||
private void on_account_added(Geary.AccountInformation added,
|
||||
AccountManager.Status status) {
|
||||
if (status == AccountManager.Status.ENABLED) {
|
||||
Accounts.Manager.Status status) {
|
||||
if (status == Accounts.Manager.Status.ENABLED) {
|
||||
try {
|
||||
this.application.engine.add_account(added);
|
||||
} catch (GLib.Error err) {
|
||||
|
|
@ -3102,9 +3102,9 @@ public class GearyController : Geary.BaseObject {
|
|||
}
|
||||
|
||||
private void on_account_status_changed(Geary.AccountInformation changed,
|
||||
AccountManager.Status status) {
|
||||
Accounts.Manager.Status status) {
|
||||
switch (status) {
|
||||
case AccountManager.Status.ENABLED:
|
||||
case Accounts.Manager.Status.ENABLED:
|
||||
if (!this.application.engine.has_account(changed.id)) {
|
||||
try {
|
||||
this.application.engine.add_account(changed);
|
||||
|
|
@ -3118,8 +3118,8 @@ public class GearyController : Geary.BaseObject {
|
|||
}
|
||||
break;
|
||||
|
||||
case AccountManager.Status.UNAVAILABLE:
|
||||
case AccountManager.Status.DISABLED:
|
||||
case Accounts.Manager.Status.UNAVAILABLE:
|
||||
case Accounts.Manager.Status.DISABLED:
|
||||
if (this.application.engine.has_account(changed.id)) {
|
||||
this.close_account.begin(
|
||||
changed,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ geary_client_vala_sources = files(
|
|||
'accounts/account-dialog-remove-confirm-pane.vala',
|
||||
'accounts/account-dialog-remove-fail-pane.vala',
|
||||
'accounts/account-dialog-spinner-pane.vala',
|
||||
'accounts/account-manager.vala',
|
||||
'accounts/account-spinner-page.vala',
|
||||
'accounts/accounts-editor.vala',
|
||||
'accounts/accounts-editor-edit-pane.vala',
|
||||
|
|
@ -26,6 +25,7 @@ geary_client_vala_sources = files(
|
|||
'accounts/accounts-editor-remove-pane.vala',
|
||||
'accounts/accounts-editor-row.vala',
|
||||
'accounts/accounts-editor-servers-pane.vala',
|
||||
'accounts/accounts-manager.vala',
|
||||
'accounts/add-edit-page.vala',
|
||||
'accounts/goa-service-information.vala',
|
||||
'accounts/local-service-information.vala',
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
class AccountManagerTest : TestCase {
|
||||
class Accounts.ManagerTest : TestCase {
|
||||
|
||||
|
||||
private AccountManager? test = null;
|
||||
private Manager? test = null;
|
||||
private File? tmp = null;
|
||||
|
||||
|
||||
public AccountManagerTest() {
|
||||
public ManagerTest() {
|
||||
base("AccountManagerTest");
|
||||
add_test("create_account", create_account);
|
||||
add_test("create_orphan_account", create_orphan_account);
|
||||
|
|
@ -33,7 +33,7 @@ class AccountManagerTest : TestCase {
|
|||
GLib.File data = this.tmp.get_child("data");
|
||||
data.make_directory();
|
||||
|
||||
this.test = new AccountManager(new GearyApplication(), config, data);
|
||||
this.test = new Manager(new GearyApplication(), config, data);
|
||||
}
|
||||
|
||||
public override void tear_down() throws GLib.Error {
|
||||
|
|
@ -54,7 +54,7 @@ class AccountManagerTest : TestCase {
|
|||
|
||||
this.test.account_added.connect((added, status) => {
|
||||
was_added = (added == account);
|
||||
was_enabled = (status == AccountManager.Status.ENABLED);
|
||||
was_enabled = (status == Manager.Status.ENABLED);
|
||||
});
|
||||
|
||||
this.test.create_account.begin(
|
||||
|
|
@ -127,7 +127,7 @@ class AccountManagerTest : TestCase {
|
|||
assert(account2.id == "account_02");
|
||||
}
|
||||
|
||||
private void delete(File parent) throws Error {
|
||||
private void delete(File parent) throws GLib.Error {
|
||||
FileInfo info = parent.query_info(
|
||||
"standard::*",
|
||||
FileQueryInfoFlags.NOFOLLOW_SYMLINKS
|
||||
|
|
@ -69,7 +69,7 @@ geary_test_client_sources = [
|
|||
'engine/api/geary-credentials-mediator-mock.vala',
|
||||
'engine/api/geary-service-information-mock.vala',
|
||||
|
||||
'client/accounts/account-manager-test.vala',
|
||||
'client/accounts/accounts-manager-test.vala',
|
||||
'client/application/geary-configuration-test.vala',
|
||||
'client/components/client-web-view-test.vala',
|
||||
'client/components/client-web-view-test-case.vala',
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ int main(string[] args) {
|
|||
|
||||
// Keep this before other ClientWebView based tests since it tests
|
||||
// WebContext init
|
||||
client.add_suite(new AccountManagerTest().get_suite());
|
||||
client.add_suite(new Accounts.ManagerTest().get_suite());
|
||||
client.add_suite(new ClientWebViewTest().get_suite());
|
||||
client.add_suite(new ComposerWebViewTest().get_suite());
|
||||
client.add_suite(new ConfigurationTest().get_suite());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue