Commit graph

77 commits

Author SHA1 Message Date
Michael Gratton
cb16bdc59d Remove default Geary.EmailIdentifier::hash and ::equal_to impls
Make subclasses implement these themselves and remove the unique string
property, to be (hopefully) more efficient and easier for subclasses
to specialise.
2019-12-12 10:47:52 +11:00
Michael Gratton
c93cfc38b1 Clean up Engine search API
Clean up search API so that query string parsing and error handling can
be pushed out to the client.

Rename Geary.Account::open_search factory method to ::new_search_query
to better reflect what it actually does.

Update Geary.SearchFolder::search to be async so it can throw errors and
the caller can catch them, require SearchQuery objects instead of plain
text query strings.

Add Geary.SearchQuery::owner property so that the query's account can be
sanity checked.

Update API documentation to reflect this.
2019-12-12 10:47:52 +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
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
43803239a4 Replace Geary.Account::send_email w/ Smtp.ClientService methods
Remove Geary.Account::send_email and the sending progress monitor in
favour of exposing Geary.Smtp.ClientService as a public class and so
allowing clients to acccess those symbols from Geary.Account::outgoing.

Also make ::send_email a convenience class for doing a save/queue and
expose those operations, so clients can managage the two seperately if
desired (e.g. for undoing sending).

Finally, make Outbox.Folder public since it's exposed by the SMTP
service and maybe clients want to do something more detailed with it
anyway?
2019-11-17 20:00:01 +11:00
Michael Gratton
cc4389f41d Make Geary.ComposedEmail implement Geary.EmailHeaderSet
This allows it to be used in exchange with the Geary.Email and
RFC822.Message classes in places.
2019-11-17 19:59:19 +11:00
Chris Heywood
eaa98883a7 Tests for ComposedEmail.contains_inline_img_src and replace_inline_img_src 2019-11-17 16:40:13 +11:00
Michael Gratton
09f6fc094a Improve Geary.Account API for listing folders
Make both Account.list_folders and Account.get_special_folder not throw
any errors - either the folders exist, or they don't. Update call sites.
2019-11-05 11:35:31 +11:00
Michael Gratton
6871c1cd90 Make remote folder synchronisation a top-level API method
Add Geary.Folder::synchronise_remote method to allow clients to
explicitly check for new mail in a folder. Move code from
ImapEngine.AccountSynchronizer as the basic implementation, but also
ensure pending replay queue notifications are processed before the
process is complete.
2019-08-26 13:32:53 +10:00
Michael Gratton
983e8ce74e Mark Geary.Account.open_search as async and throwing an error
This lets us make the DB stemmer lookup async when constructing a
search query async and cancellable. Fix call sites.
2019-08-18 22:00:40 +10:00
Rico Tzschichholz
5c909334b7 Add missing generic arguments in engine tests to fix valac criticals
See https://gitlab.gnome.org/GNOME/vala/issues/835
2019-08-15 08:36:46 +02:00
Michael Gratton
71cb7fcdfe Add Geary.ContactStore.search method, impementation and tests 2019-06-13 16:56:03 +10:00
Michael Gratton
65ab37938f Implement new contact harvester for the engine
Replaces harvesting code in ImapDB code so as to be stand-alone and
reusable. Implement harvesting policy to only harvest from a set of
whitelisted special folder types (so junk and trash is not harvested)
and only harvest valid, non-spoofed, addresses.
2019-06-13 16:32:47 +10:00
Michael Gratton
0b734f7ba2 Don't load all engine contacts on startup
Prepare for doing composer autocomplete via queries by not loading all
contacts at startup in the engine. Update Geary.ContactStore API to that
end, and convert Geary.Account.get_contact_store accessor method to a
property.
2019-06-13 16:28:35 +10:00
Michael Gratton
f7488453d0 Make it easier to obtain folders from path objects from Geary.Account
Replace async folder accessors with sync versions, add a means of
obtaining a folder path from its serialised form.
2019-04-17 09:06:24 +10:00
Michael Gratton
01a154bc5f Make it possible to distinguish between different folder roots
Add a label to Geary.FolderRoot so it different instances can be
differenciated.
2019-04-17 09:06:24 +10:00
Michael James Gratton
dd3a7a1bc8 Add API for (de)serialising FolderPath and EmailIdentifier
Supports (de)serialising via GLib.Variant for use as GLib.Action targets
transmission via DBus, etc.
2019-04-17 09:06:24 +10:00
Michael Gratton
3a44628da9 Fix ConversationMonitor sometimes not loading more from remote
If a FillWindowOperation didn't load a full amount of messages, it just
assumed that there were no more to load. This is not true however when
loading locally, the folder's vector isn't fully expanded, and it gets
to the end of the vector.

This patch fixes the operation to also queue another fill if the
monitor's folder message window is smaller than the folder's total
message count.

Fixes #289
2019-04-04 16:57:53 +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
2ad91f5f4d Fix failing test after icon change 2019-02-24 21:50:27 +11:00
Michael Gratton
b41ef0a5b7 Merge branch 'wip/259-arm64-test-failure' into 'master'
Assert FolderPath comparisons properly in unit tests

Closes #259

See merge request GNOME/geary!136
2019-02-24 04:46:54 +00:00
Michael Gratton
ca846edf59 Improve AccountInformation.service_label generation
If the primary email address matches the incoming host name, use that.
Else use a prefix of the hostname but only if it is more that two domain
parts long. E.g. don't shorten "other.com" to "com".

Fixes #261
2019-02-22 16:56:32 +11:00
Michael Gratton
9c3fdbfb5c Assert FolderPath comparisons properly in unit tests
Fixes #259, Debian FTB failure on arm64.
2019-02-22 15:46:14 +11:00
Michael Gratton
4d57ab9b62 Default Outlook accounts to not save sent mail
See #65
2019-02-20 14:06:02 +11:00
Michael Gratton
5475290272 Allow both accounts and services to have provider-specific defaults
This updates both AccountInformation and ServiceInformation to
implicitly apply provide-specific defaults, allowing the same
mechanism to provide defaults for accounts, and meaning that API
clients do not need to do this themselves any more. Add unit tests.
2019-02-20 13:55:17 +11:00
Michael Gratton
af676e0572 Fix FolderPath mis-sorting doubly-disjoint paths
E.g. a>d should be less than b>c, not the other way around.

Fixes #224
2019-02-19 17:31:11 +11:00
Michael Gratton
e1fd9daa83 Fix pathological FolderPath.is_equal() case, add unit test 2019-01-15 00:20:37 +11:00
Michael Gratton
ddbe6e0b09 Revamp Geary.FolderPath implementation
Convert getters that look like properties into actual properties,
remove unused and redundant public and internal API, convert
implementation to use a tree that aucyally maintains references between
steps, rather than each creating a new list of path steps and
manipulating that.
2019-01-15 00:20:37 +11:00
Michael Gratton
423a1dcbf0 Add additional FolderPath unit tests 2019-01-15 00:19:46 +11:00
Michael Gratton
5a22e8e4a2 Convert Geary.FolderRoot to be an actual root, not just a top-level
Instead of each top-level IMAP folder being a FolderRoot object, then
children of that being FolderPath objects, this makes FolderRoot an
"empty" FolderPath, so that both top-level and descendant folders are
plain FolderPath objects. Aside from being more technically correct,
this means that empty namespace roots can now be used interchangably
with non-empty namespace roots (addressing issue #181), and custom
folder implementations no longer need to provide their own trivial,
custom FolderRoot.

To support this, a notion of an IMAP root and a local root have been
added from which all remote and local folder paths are now derived,
existing places that assume top-level == root have been fixed, and
unit tests have been added.
2019-01-15 00:18:45 +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
20447c814f Provide common account and service status tracking via Account
Similarly to ClientService, add a `current_status` property that denotes
the account's operational state, so that clients can just set a notify
on that to be informed of all account status changes. Keep the property
updated by watching for changes to the client service's status property.
2019-01-01 22:29:07 +11:00
Michael Gratton
827db39fe2 Provide common service status tracking via ClientService
This adds a `current_status` property to ClientService to track the
service's operational state, wich can be monitored by both the engine
and clients for changes. Hook up subclasses to keep that update, and
move connectivity management in to ClientService to provide a common
implementation.
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
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 Gratton
fa5ecf0c22 Tidy up account info sender mailbox implementation
This finishes conversion from the old approach (primary+aliase list) to
the new (a single ordered list). API is simplified a bit, and some
convenience properties are added.
2018-12-02 12:43:38 +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
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
9884faba84 Add general impls for converting enum values to nicks and back.
Use this for service provider related enums.
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 Gratton
69ac6eb48f Remove Geary.Folder.wait_for_remote_async()
This doesn't make any sense for local-only folders, and only gets used
for internal implementation details for IMAP folders, so remove the
public API and replace its use internally.
2018-11-10 23:38:54 +11:00
Michael Gratton
8d1b5b565c Add Geary.Account.is_online property
This will be useful for displaying this status to the user in the
future, and allows removing MinimalFolder.is_remote_available, which is
hopelessly innacturate in the face of network problems.
2018-11-10 09:25:05 +11:00
Michael James Gratton
0e6d499808 Fix AccountInformation.has_email_address, add tests. 2018-07-02 21:22:15 +10:00
Michael James Gratton
13c92c3f7e Convert Credentials and CredentialsMediator to refer to tokens, tidy up.
* src/engine/api/geary-credentials.vala (Credentials): Refer to auth
  tokens, not passwords, so we can use the same object for OAuth2
  auth. Update call sites.

* src/engine/api/geary-credentials-mediator.vala (CredentialsMediator):
  Refer to auth tokens, not passwords, so we can use the same object for
  OAuth2 auth. Remove saving and clearing methods from the interface
  since that's only supported for password storage, not SSO like
  GOA. Update implementations and call sites.

* src/engine/api/geary-account-information.vala (AccountInformation):
  Replace many byzantine auth management methods with just a few for
  handling loading and prompting. Remove ServiceFlag enum now it is no
  longer used. Clean up call sites.

* src/client/accounts/account-manager.vala (AccountInformation): Manage
  initial saving and final deletion of libsecret based accounts here,
  rather than all over the code base.
2018-06-12 13:25:05 +10:00
Michael James Gratton
acac68afed Make ServiceInformation.mediator a required, read-only property. 2018-06-12 13:25:05 +10:00