Commit graph

105 commits

Author SHA1 Message Date
Michael Gratton
ddb3a899fb Geary.Imap: Add Quirks object to collect all IMAP service quirk config 2020-05-04 10:53:31 +10:00
Michael Gratton
13d43d41b2 Update Geary.Imap.ClientSession connect timeout handling
Allow specifying the connect greeting timeout length, ensure that
any connect errors are in place before releasing the connect waiter,
add unit test to ensure it works properly.
2020-03-27 08:29:14 +11:00
Michael Gratton
c85a89eb48 Workaround type initialisation deadlock in GObject
Ensure some types that are prone to deadlocking are initialised up
front.

Workaround for GNOME/geary#592 GNOME/glib#541
2020-02-02 21:03:34 +11: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
2e00e9b7f7 Remove the Geary.Engine.instance singleton 🎉 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
Michael Gratton
b88278c2af Fix build warning 2019-08-28 09:58:15 +10:00
Michael Gratton
66a664f98d Clean up ImapDB.Account ctor/open API a bit
Move args from open_async to ctor and use these to determine and store
DB file and attachment paths as properties. This allows constructing
the DB instance up front and markig it as non-nullable, simplifies
calling patterns and hence allows removing one use of the deprecated
Engine singleton, and by moving in the local data deletion
implementation from ImapEngine.GenericAccount, also allows removing a
static helper method.
2019-06-13 16:55:23 +10:00
Kristian Klausen
48c93655cf Remove trailing whitespace
find . -name '*.vala' -type f -exec sed -i 's/ *$//g' {} +
The following files was ignored:
test/client/composer/composer-web-view-test.vala
test/engine/util-html-test.vala

Fix #271
2019-02-28 23:05:31 +01:00
Michael Gratton
a268615df1 Use a substantially lower socket timeout when validating services
This avoids leaving the user hanging too long when adding/updating
accounts.

Fixes #227
2019-02-19 18:10:43 +11:00
Michael Gratton
e94e4665c5 Remove now-unsed validation code from Geary.Engine
Also, clean up class doc comment to better reflect reality.
2019-01-09 15:22:19 +11:00
Michael Gratton
3f04e5eb19 Tidy up all of the various untrusted_host signals
Remove it from Geary.Engine, since it just adds complexity without
making API client use any easier. Replace the TLS negotiate method on
the remaining versions of the signal with the Endpoint, since it's handy
to have and the negotiation method can be obtained from that if needed.
2019-01-09 15:22:19 +11:00
Michael Gratton
19d2fdfcbc Update Geary.Endpoint API and source
Use a generic GSocketConnectable to specify the remote endpoint,
simplify TLS cert management callbacks.
2019-01-09 15:22:19 +11:00
Michael Gratton
20a53f2d51 Rework how auth failures are propagated by the IMAP stack
Rather than using cascading signals to indicate an auth error, have
ImapClientSession throw an appropriate exception, and catch that as
needed in ImapClientService and the Engine's validation code.
2019-01-01 22:29:07 +11:00
Michael Gratton
ebe4e190ac Fix credentials not being updated in the engine when changed in editor
Add a method to Accounts.Manager to update credentials for local
accounts. Update Geary.ClientService to enable both an endpoint and
service config to be updated when changed, and simplify how that gets
done. Update Accounts.EditorServerPane to ensure these get called.
2018-12-27 10:34:43 +10:30
Michael Gratton
95ebdd65d2 Tidy up ClientService API a bit
Require endpoint to always be present so it is never null, and hence
passed in through account creation. Rename props to be a bit more
descriptive.
2018-12-27 10:20:58 +10:30
Michael Gratton
1bccd51a25 Clean up AccountInformation and ServiceInformation APIs
Remove remaining crufty properties left over from pulling accounts out
of the engine, rename imap/smtp to incoming/outgoing since maybe one
day other protocols or implementations will be supported. Remove the
old pairs of properties for TLS and SMTP auth, replace the
SmtpCredentials enum with something that is also independent of
protocol.
2018-12-09 11:06:20 +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 Gratton
140ecc8839 Fix some unhandled exception warnings 2018-12-02 12:49:33 +11:00
Michael Gratton
8d606e57a8 Implement initial server editing and validation 2018-12-01 00:26:24 +11:00
Michael Gratton
4691dc4e25 Require IMAP creds when validating a SMTP service
We can't rely on getting the IMAP creds from the account, since we may
be validating updated services and the IMAP creds may be different then
those on the account.
2018-11-30 23:49:30 +11:00
Michael Gratton
038cf7c997 Update to Account.set_endpoints set only one specific endpoint
This will allow updating the endpoint for only a single service instead
of both if only one has changed.
2018-11-30 23:49:30 +11:00
Michael Gratton
1055036c02 Provide a means to get the default port for a specific service config
Use this to set the default for new accounts before passing to the
engine for validation.
2018-11-30 23:49:30 +11:00
Michael Gratton
41402c9108 Tidy up Account and derived class's constructors
Get the account's id (renamed fron "name") from the account's config and
construct the id internally. Construct the ImapDB.Account instance
internally as well since it doesn't require any input from the engine.
2018-11-30 23:49:30 +11:00
Michael Gratton
e760b074a2 Move endpoints from account config to implementation objects (1/3)
This removes Endpoint from ServiceInformation and moves it to a new
ClientService class, since ServiceInformation is for apps to provide
configuration, and Endpoints are effectively implementation detail. The
new ClientService class is in effect an analoge to ServiceInformation
in the same way as Account is to AccountInformation, and so this is a
better place to store an account's endpoints. Two instances have been
added to Account as `incoming` and `outgoing` properties instead of imap
and SMTP to be a bit more generic and with an eye to supporting other
protocols in the future.

This is possble to implement now non-generic providers are populating
ServiceInformation classes rather than Endpoints directly, and reduces
the complexity of the code needed to manage endpoints since all of the
untrusted_host callback complexity in AccountInformation and the Engine
can be removed, and will also allow simplifing credentials and SMTP
codepaths somewhat.

This work has been broken up in to thee parts to make the changes
clearer.
2018-11-30 23:49:30 +11:00
Michael Gratton
ed14156e17 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.
2018-11-30 23:49:30 +11:00
Michael Gratton
f43cb75669 Move IMAP & SMTP default port consts up into public API
Don't make Engine API clients go looking in obscure internal classes to
find them.
2018-11-30 23:49:30 +11:00
Michael Gratton
468a7a674b Get basic new account verification working. 2018-11-30 23:49:30 +11:00
Michael Gratton
370aefd285 Update IMAP and SMTP port constant names.
Make the them a bit more regular and refer to TLS rather than
SSL.
2018-11-30 23:49:30 +11:00
Michael Gratton
1f00e67bf9 Modernise how Endpoints are constructed, used and managed.
Use the new TlsNegotiationMethod enum rather than Endpoint's flags
and simply require StartTLS negotiation if requested. Move the
endpoint cache into the Engine, since that actually uses it and is
looking for something to do these days. Have service-specific
providers setup a ServiceInformation instead of endpoints, so their
service info shows up in the accounts editor.

Update call sites etc.
2018-11-30 23:49:30 +11:00
Michael James Gratton
49781e63ea Rework the Engine's account validation process.
Split up account validation up into IMAP and SMTP validation so clients
can manually manage it. Don't bother trying to validate email address and
nick names, that can and should be done by clients.
2018-11-30 23:49:30 +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
538809c0eb Rework GOA account management to allow tracking disabled accounts.
* src/client/accounts/account-manager.vala (AccountManager): Keep track
  of disabled and unavailable accounts as well as enabled accounts. If an
  known GOA account cannot be properly loaded, keep it around as a
  disabled account. When GOA accounts are removed, just disable them
  instead.
2018-06-12 13:25:05 +10:00
Michael James Gratton
a165d9682d Ensure SMTP credentials are null when both noauth and use_imap is set. 2018-06-12 13:25:05 +10:00
Michael James Gratton
ee1dcb5a4c Move Endpoint prop from account to service info.
Since one of the main uses of Geary.Service to get endpoints, also
replace use of Service with ServiceInformation.

* src/engine/api/geary-service-information.vala (ServiceInformation): Add
  an endpoint property, allowing instances to be passed around whenever
  an endpoint is needed, rather than needing to switch on service type in
  AccountInformation.

* src/engine/api/geary-account-information.vala (AccountInformation):
  Remove endpoint properties and accessors. Provide an explicit means to
  hook up to endpoints on the IMAP and SMTP ServiceInformation to get
  notifications of untrusted hosts. Update call sites.

* src/engine/api/geary-engine.vala (Engine): Since we now explicitly hook
  up untrusted hosts signals on AccountInformation, don't let the same
  account be added twice.
2018-06-12 13:25:05 +10: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
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
7e089dd6f1 Merge branch 'master' into wip/768975-service-info 2018-05-23 16:34:23 +10:00
Michael James Gratton
a6945b12b0 Fix a number of objects being leaked at shutdown. 2018-02-26 23:02:50 +11:00
Michael James Gratton
ea891a39cd Only create IMAP account and folder sessions when ready, not otherwise.
This commit makes the Imap.Account and Imap.Folder classes work somewhat
more like Imap.ClientSession, in that they have become higher-level
wrappers around ClientSession which come and go as the client session
does (i.e. as the connection to the IMAP server comes and goes). Further,
partly decouple account session lifecycle in ImapEngine.GenericAccount
and the folder session in ImapEngine.MinimalFolder from those objects
being opened/closed, so that sessions are created only when open /and/
the IMAP server is available, and disconnected on close /or/ when the
underlying connection goes away.

As a result, GenericAccount and MinimalFolder no longer claims a client
session on open and try to keep it forever. Instead if needed, they wait
for the server to become contactable.

This makes Geary much more robust in the face of changing network
connections - when working offline, resuming after sleep, and so on.
2018-02-04 10:50:31 +10:30
Michael James Gratton
ef258064ac Trigger account synchronizer when account becomes ready.
* src/engine/imap-engine/imap-engine-account-synchronizer.vala
  (AccountSynchronizer): Trigger synchronizer when the account becomes
  ready, not when it opens. Ensure when synchronizer halts when a remote
  error is encountered, so when going off-line it doesn't attempt to
  continue.

* src/engine/imap-engine/imap-engine-generic-account.vala
  (GenericAccount): Make Tie AccountSynchronizer a property to tie its
  lifecycle that of its account. Stop the synchronizer when the account
  is stopped.

* src/engine/imap-engine/imap-engine.vala (ImapEngine): Remove
  now-redundant AccountSynchronizer lifecycle code, update call sites.
2017-11-12 21:34:27 +11:00
Oskar Viljasaar
9eecc90ccd Move account loading, saving and deleting client side 2017-10-27 15:55:19 +02:00
Oskar Viljasaar
c08ab44a42 Port AccountInformation over to ServiceInformation
This adds two ServiceInformation properties for IMAP and SMTP,
and removes all separate properties in AccountInformation which
are now redundant. No functional changes for now.
2017-10-11 19:51:16 -07:00
Oskar Viljasaar
1370ffba18 Miscellaneous whitespace changes. 2017-10-11 19:50:59 -07: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
Michael James Gratton
d4a95fa287 Fix error when adding third account. Bug 779048.
Patch courtesy of Rafał Masternak <rafdev@muub.net>
2017-02-23 11:33:12 +11:00
Michael James Gratton
6eac43b2e7 Make both Engine and AccountInfo a bit more unit testable.
* src/engine/api/geary-account-information.vala (AccountInformation):
  Make main constrcutor public, pass in the id rather than divining it
  from the config dir's name for both ctors. Update call sites.

* src/engine/api/geary-engine.vala (Engine): Also make the ctor public.
2017-02-23 11:33:12 +11:00
Michael James Gratton
387db95e28 Valadoc generation fixes & updates.
* configure: Allow specifying a custom valadoc executable.

* src/CMakeLists.txt: Tidy up valadoc command, include dependencies when
  in generated HTML output, enable warnings.

* src/engine/api/geary.vala: Provide boilerplate doc comment for the
  Geary namespace.

* src/engine/api/geary-email.vala, src/engine/rfc822/rfc822.vala: Don't
  use single-line doc comments, valadoc doesn't support them (see Bug
  736483).

* src/engine/api/geary-folder-path.vala: Fix errors reported by valadoc.
2017-01-02 13:49:18 +11:00