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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
* 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.
* 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.
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.
* 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.
* 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.
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.
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.
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.
* 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.
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.
* 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.
* 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.