Commit graph

16 commits

Author SHA1 Message Date
Michael Gratton
0ae633d88f Update existing tests to work with ValaUnit 2020-06-30 17:31:07 +10:00
Michael Gratton
dccb81fcb1 Rework Geary.Engine lifecycle managment
Now that its singleton is gone, and since it's ::open_asyc and
::close_async methods don't do anything async, just merge the former
with the class's ctor and make the latter non-async.

Explicitly construct an instance in Application.Client and ensure it
is closed there as well instead of in the controller, for consistency.
2019-11-19 09:41:09 +11:00
Michael Gratton
ecfd772c07 Clean up Geary.Engine account API and implementation
Keep a single ordered list of accounts around, construct accounts
when their config is first added, and prefer accessing accounts by
config rather than id.
2019-11-19 09:41:04 +11:00
Kristian Klausen
9ef6d7ccec Replace all tab indentation with 4 spaces
find . -name '*.vala' -type f -exec sed -i.orig 's/\t/    /g' {} +
and a few manual adjustment.

Fix #271
2019-02-27 19:19:58 +01:00
Michael Gratton
8fe6d4f85a Move CredentialsMediator back to AccountInformation
In practice, the same mediator is always being used for both services,
and by removing it from ServiceInformation we can provide default
instances for both IMAP and SMTP, meaning we can load account config
before service config, making handling loading for both much tidier.
2018-12-08 13:53:37 +11:00
Michael Gratton
123f51dbb2 Enable config file versioning
This (way too large patch) enables versioning in config files, and
provides a mechanism by which to load older versions from a newer
version of Geary. It also properly introduces a new v1 config format
that adds several groups to geary.ini to make it easier to read and to
distinguish between incoming/outgoig services rather than IMAP/SMTP.

To do this, a few things that should have happened in seperate patches
were also done:

 * Make AccountInformation's imap and smtp properties mutable (they
 aren't stateful any more anyway), make ServiceInformation non-abstract
 again and remove the subclasses (to get config versioning happening
 without an explosion of a classes, it all has to be handled from the
 AccountManager anyway), and some other misc things.
2018-12-08 13:53:01 +11:00
Michael James Gratton
74fa29b73f Tidy up Geary.AccountInformation creation.
Pass service provider to ctor so we can make the service provider
property immutable. Fill in service label in ctor so it's always set to
something useful. Move creating orphans from Engine to AccountManager
since it exists only to assign an internal id for new accounts, so it
should handled by the account manager anyway.
2018-11-30 23:49:30 +11:00
Michael James Gratton
f79f5ee255 Fix not being able to re-add account previously removed from the engine. 2018-11-30 23:49:30 +11:00
Michael James Gratton
e6891f528a Clean up Engine's account added/removed signals.
* src/engine/api/geary-engine.vala (Engine): Move account_added and
  account_removed signals to AccountRemoved since the engine isn't
  tracking this any more. Remove bool param from add_account for the same
  reason and update call sites.
2018-05-28 00:55:59 +10:00
Michael James Gratton
4fdeb9db47 Ensure AccountInformation objects always have valid IMAP/SMTP services.
* src/engine/api/geary-engine.vala (Engine): Require a ServiceInformation
  object for IMAP and SMTP when creating orphan info objects. Update call
  sites.

* src/client/accounts/account-manager.vala (AccountManager): provide
  factory methods for constructing local service info objects. Use these
  when re-constituting accounts. Use a singleton SecretMediator object
  instance as a bonus.

* src/client/accounts/add-edit-page.vala (AddEditPage): Get
  ServiceInformation objects from the account manager, pass an instance
  of GearyApplication through so it has access to the manager. Update
  call chains back to GearyController to pass the app instance through.
2018-05-24 16:52:54 +10:00
Michael James Gratton
91e85a6647 Make EngineTest a bit more robust. 2018-05-24 15:52:36 +10:00
Michael James Gratton
0d3f10f51f Clean up user directory management.
Instead of passing in user config and data base dirs to the Engine from
the app, then pulling them out from the engine again from the app, just
store them in AccountManager, since that's where they are needed.

* src/client/accounts/account-manager.vala (AccountManager): Store user
  config and data base dirs directly rather than getting them from the
  engine. Split account directory creation out into a separate method so
  they aren't re-made every time the config is saved.

* src/engine/api/geary-engine.vala (Engine): Remove user config and data
  dir properties and open_async args. Update call sites and unit tests.

* src/client/application/geary-controller.vala (GearyController): Chase
  AccountManager and Engine API changes. Ensure account dirs are created
  when an new account is added.

* src/engine/api/geary-account-information.vala (AccountInformation):
  Explicitly track copies rather relying on account dirs being
  null. Don't require dirs be set in the default ctor, since they won't
  be known, provide a method for updating them later on instead.
2018-05-24 15:34:29 +10:00
Michael James Gratton
9f3ec5bfcb Update unit tests to work with ServiceInfo API changes. 2018-05-23 17:53:23 +10:00
Michael James Gratton
15748cef03 Tidy up unit test infrastructure and mock classes.
* test/api/*.vala: Renamed files that contained mock objects to *-mock.vala,
  not *-test.vala.

* test/testcase.vala: Renamed to test-case.vala for consistency, remove
  TestCase class from Gee package since that's really not true. Clean up
  code for consistency.

* test/meson.build, test/CMakeLists.txt: Split TestCase compilation out
  into a separate test lib.
2018-04-07 09:41:18 +10:00
Michael James Gratton
50f73ff252 Allow test fixtures and test methods to throw errors by default.
* test/testcase.vala (TestCase): Add a generic throws clause to both
  TestMethod and set_up and tear_down, update subclasses.
2018-04-07 09:41:18 +10:00
Michael James Gratton
e8dcad9a43 Add unit tests for adding accounts.
* src/engine/api/geary-engine.vala (Engine::create_orphan_account): Fix
  sense of test when determining the next account id to use. Add unit
  tests.
  (Engine::add_account): Made public so it can be used in public test.
2017-02-23 11:33:12 +11:00