Commit graph

57 commits

Author SHA1 Message Date
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
Michael James Gratton
054d53a498 Move CredentalsMethod enum and property to Credentals.
* src/engine/api/geary-credentials.vala (Credentals): Move
  CredentalsMethod enum here, rename to Method. Add supported_method
  property, make all props read-only. Update call sites.
2018-06-12 13:25:05 +10:00
Michael James Gratton
863a11e780 Rename Geary.Service to Protocol, move into ServiceInformation source. 2018-06-12 13:25:05 +10:00
Michael James Gratton
677b1cec86 Rename ServiceInformation.service to protocol to reduce redundancy. 2018-06-12 13:25:05 +10:00
Michael James Gratton
2dcc6c7e4f Fix critical when editing account settings.
Ensure when getting a temp copy of an AccountInformation, that its
IMAP and SMTP ServiceInformation members are also copied.
2018-05-28 14:06:39 +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
Oskar Viljasaar
5108a21def Implement GOA support for password-based accounts 2018-05-25 15:48:46 +10:00
Michael James Gratton
4e0950f9bc Introduce a ConfigFile class to improve config management.
ConfigFile is a GLib.KeyFile-like class (and is backed by a KeyFile) that
nonetheless provides convenient a high-level API for getting and setting
grouped config values and asynchronous loading and saving.

* src/engine/util/util-config-file.vala: New ConfigFile class.

* src/engine/api/geary-service-information.vala (ServiceInformation):
  Require ConfigFile groups rather than KeyFile instances for loading and
  saving. Update subclasses and unit tests.

* src/client/accounts/account-manager.vala (AccountManager): Move generic
  account key consts here from Config. Instead of using KeyFile directly,
  use ConfigFile groups for loading and saving settings. Rename load and
  save methods to be a bit more consistent with the class's role, and
  make save_account() throw its errors so they can be reported to the
  user. Update call sites.

* src/client/accounts/local-service-information.vala
  (LocalServiceInformation): Move service-specific config key consts
  here, use new ConfigFile groups for loading and saving.

* src/engine/api/geary-config.vala: Removed, all config consts have been
  moved to the classes using them and KeyFile convenience methods
  subsumed by ConfigFile.
2018-05-25 15:42:56 +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
ebf499927c Make KeyFile arg mandatory when loading/saving service information.
* src/engine/api/geary-service-information.vala (ServiceInformation):
  Make KeyFile arg mandator for load and save methods, since it will
  always need to be provided. Update subclasses.

* src/client/accounts/local-service-information.vala
  (LocalServiceInformation): Remove from Geary package since it's not an
  engine class. Update call sites.
2018-05-24 15:38:42 +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
a2a95686b4 Support default content types for both displayed and attached entities.
This replaces the const ContentType.DEFAULT_CONTENT_TYPE string and
related code with static defaults for both displayed and attached MIME
entities.

* src/engine/mime/mime-content-type.vala (ContentType): Replace
  DEFAULT_CONTENT_TYPE const with static DISPLAY_DEFAULT and
  ATTACHMENT_DEFAULT static instances. Remove is_default() since that no
  longer makes sense. Update call sites and unit tests.

* src/engine/mime/mime-content-parameters.vala (ContentParameters): Make
  the class immutable so it is safe to be used as a component of the
  static ContentType DISPLAY_DEFAULT and ATTACHMENT_DEFAULT members.
2018-05-10 13:53:24 +10:00
Michael James Gratton
037af00740 Improve how attachments are saved to the db and disk.
This mostly aims to make the Geary.Attachment and ImapDB.Attachment
objects usable more generally for managing attachments, allowing
these to be instantiated once, persisted, and then reused, rather than
going through a number of representations (GMime, SQlite, Geary) and
having to be saved and re-loaded.

* src/engine/api/geary-attachment.vala (Attachment): Remove id property
  and allow both file and filesize properties to be set after instances
  are constructed. Update call sites.

* src/engine/api/geary-email.vala (Email): Remove get_attachment_by_id
  since it unused.

* src/engine/imap-db/imap-db-attachment.vala (Attachment): Chase
  Geary.Attachment API changes, move object-specific persistence code
  into methods on the actual object class itself and modernise a
  bit. Rename static methods to be a bit more terse. Update call sites
  and add unit tests.

* src/engine/imap-db/imap-db-folder.vala (Folder): Rather than saving
  attachments to the db then reloading them to add them to their email
  objects, just instantiate Attachment instances once, save and then add
  them.

* src/engine/imap-db/imap-db-gc.vala (GC): Replace custom SQL with
  existing accessor for listing attachments.

* src/engine/util/util-stream.vala (MimeOutputStream): New adaptor class
  for GMime streams to GIO output streams.
2018-05-10 13:53:24 +10:00
Michael James Gratton
057e733eb1 Fix a crash saving an attachment with unknown content type.
* src/engine/api/geary-attachment.vala (Attachment): Add a null check for
  the extension before using it, add a test case to cover it.
2018-04-27 12:29:06 +10:00
Michael James Gratton
3bf2ac181a Add unit tests for ConversationMonitor, fix a few issues.
* src/engine/app/app-conversation-monitor.vala (ConversationMonitor):
  Don't check the folder blacklist for external folder signals when the
  signal is received, do it when the operation is executed so it's fresh.

* src/engine/app/conversation-monitor/app-fill-window-operation.vala
  (FillWindowOperation): Only re-fill the conversation if we get a full
  load, anything else means we hit the end of the folder.

* test/engine/app/app-conversation-monitor-test.vala: New unit tests
  for ConversationMonitor.

* test/engine/api/geary-account-mock.vala,
  test/engine/api/geary-folder-mock.vala: Mix in MockObject mock up all
  method calls.

* test/engine/api/geary-email-identifier-mock.vala: Fix the comparator
  method when the other instance is null.
2018-04-07 10:02:24 +10:00
Michael James Gratton
0ea1fe6c35 Don't use the database for internal ConversationMonitor bookkeeping.
This replaces the use of Geary.Folder.find_boundaries_async in
ConversationMonitor with a simple sorted set of known in-folder message
ids. This is both easy and fast, reduces needless DB load when loading
conversations, and also allows allows removing what is otherwise
single-use implementation overhead in classes deriving from Folder.

* src/engine/app/app-conversation-monitor.vala (ConversationMonitor):
  Replace get_lowest_email_id_async() with window_lowest property, update
  call sites. Implement the property by using a sorted set of known
  listed email ids from the base folder. Update the set as messages in
  the base folder are listed. Rename notify_emails_removed to just
  removed and remove ids from the set if any messages from the base
  folder are removed.

* src/engine/api/geary-folder.vala (Folder): Remove
  get_lowest_email_id_async since it is now unused, do same for all
  subclasses.
2018-04-07 10:02:24 +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
f0651803bb Fix conversation-related test warnings and occasionally failing test.
* test/engine/api/geary-email-properties-test.vala: Add new mock
  EmailProperties object.

* test/engine/app/app-conversation-test.vala (ConversationTest): Set
  email sent and received dates to suppress warnings adding them to
  Conversation instances.

* test/engine/app/app-conversation-set-test.vala (ConversationSetTest):
  Set email sent and received dates to suppress warnings adding them to
  Conversation instances, handle both casees when merging two
  conversations, that the first was merged to the second and vice versa.
2018-02-08 18:25:32 +11:00