Commit graph

34 commits

Author SHA1 Message Date
Michael Gratton
2030b2dec7 test: Break out engine mock objects into their own name-space
Engine mocks don't need to be in the `Geary` namespace, and including
them there makes it difficult to use them in client tests, so put them
all in their own name-space and corresponding directory.
2020-08-13 19:51:33 +10:00
Michael Gratton
0ae633d88f Update existing tests to work with ValaUnit 2020-06-30 17:31:07 +10:00
Michael Gratton
6e7631b8d3 Geary.RFC822: Clean up message data interfaces and classes
Split Geary.RFC822.MessageData interface up into DecodedMessageData and
EncodedMessageData so the difference between the two is clear and they
can't be used interchangeably.

Add `DecodedMessageData::to_rfc822_string` to provide a common interface
for round-tripping decoded data.

Update all classes to implement one of these and follow the same general
API patterns.
2020-05-06 14:58:56 +10:00
Michael Gratton
991c9ef5d7 Geary.App.ConversationMonitor: Fix more races when starting/stopping
Ensure that if stopping the conversation monitor while it is waiting
for the folder to open that the folder isn't closed, and if an error
is thrown when opening the folder that it gets thrown by
::start_monitoring anyway.

Hopefully fixes #741
2020-04-24 15:30:04 +10:00
Michael Gratton
196f05e595 test/test-case.vala: Rename TestCase async calls to match AsyncCallWaiter's 2020-04-10 12:58:09 +10:00
Michael Gratton
8dcab7f306 Geary.SpecialFolderType: Rename class and related properties, signals
The `SpecialFolderType` was somewhat mis-named, since the special use
does not (in most cases) confer any special type, rather it's simply
defines what a particular folder is used /for/.

As such, rename the enum to to `Geary.Folder.SpecialUse`, moving it in
to the `Folder` class, since it relates specifically to folders, also
rename `Folder::special_folder_type` and
`Folder::special_folder_type_changed` reflect the above and not
duplicate the type name, and similarly rename
`Account::folders_special_type`.

Update the many call sites.
2020-03-31 16:15:57 +11:00
Michael Gratton
e4cbff8bfa De-cruftify Geary.Collection utility functions
Remove functions that have as-convenient methods in up-tp-date Gee,
rename ::get_first to ::first so it reads better and add API docs,
replace ::to_array_list with ::copy, since that's what's actually
needed.
2019-11-19 19:22:38 +11:00
Michael Gratton
c002285fef Geary.App.ConversationMonitor: Fix re-entrancy issues
Avoid some issues if a monitor is closed as it is still being opened,
clean up the API and implementation a bit.
2019-11-07 11:58:56 +11: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 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
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
9619d18eda Ensure conversations that have no email in the base folder are dropped
If a least one email in a conversation that is in the base folder but
also in another is removed from the base folder, the conversation may
not be removed from the monitor despite possibly not having any email
in the base folder, since the email may not have been completely removed
from the conversation.

This was particulary being seen with GMail accounts where even single
message conversations were not disappering when trashed because the
converation's email was still in All Mail.

This fix does a few things: Avoids hitting the database when checking
a conversation still has email in the base folder, when it does check
only ensures that email are in the base folder, not *any* folder, and
updates ConversationSet::remove_all_emails_by_identifier to do this
check iternally, clean up its API and implementation and avoids having
to use out args calling it.
2019-02-16 16:26:10 +11:00
Michael Gratton
67bf1183e6 Add base_folder property back to ConversationSet
Athough it was removed a while back, add it back since it is not only
needed when adding conversations, but also when removing email from
conversations to be able to detect when a conversation should be
dropped.
2019-02-16 16:10:47 +11:00
James Magahern
30e9e8950b Merge branch 'master' into buzzert/deleted_flags
* master: (212 commits)
  Import standard GNOME Flatpak CI config rather than copy/pasting it
  Update Gitlab CI Flatpak build with standard template
  Fix build with new FolderPath API
  Only collapse runs of space, tab, carriage return, and newline
  Do not add non openable folders entry in sidemenu. Bug 712902
  Reducing padding in conversation viewer list
  Fix build warnings
  Fix possible critical when removing an account is removed
  Fix local accounts for special-case providers not configured correctly
  Rework GenericAccount::ensure_special_folder_asyc yet again
  Add some useful debugging to GenericAcount
  Fix ambiguous test in AccountInformation.set_special_folder
  Fix pathological FolderPath.is_equal() case, add unit test
  Revamp Geary.FolderPath implementation
  Add additional FolderPath unit tests
  Convert Geary.FolderRoot to be an actual root, not just a top-level
  Stop duplicate inboxes being created, not being listed
  Ensure MinimalFolder remote open forces closed on hard errors
  Ensure accounts don't accidentially create multiple inbox-type folders
  Remove unwanted debuging cruft
  ...
2019-01-20 12:59:06 -08: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
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
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 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
James Magahern
b4b377d1fa Also fix the new marked_as_deleted test to account for these changes 2018-10-17 23:51:18 -07:00
James Magahern
3e1efb4f8b Moves flag change handling from list-store to conversation-monitor.
Also adds a unit test for such behavior.
2018-10-10 02:01:56 -07:00
James Magahern
022a0b0435 Fixes broken tests and adds new test 2018-10-07 19:05:12 -07:00
Michael James Gratton
4cc7cf1769 Fix empty folder/no matching search UI not showing up.
This fixes a regression introduced by commit 0ea1fe6c3.

* src/engine/app/app-conversation-monitor.vala (ConversationMonitor):
  Signal scan_complete from the same method call that we signal
  scan_started, so that a) we know it will get fired, even if no messages
  are loaded (the issue introduced by 0ea1fe6c3) and b) so we can get rid
  of the inside_scan complexity.
2018-07-08 15:11:44 +10:00
Michael James Gratton
f0ac998684 Allow blacklisting folders when obtaining email from conversations.
Add an optional blacklist arg to Conversations.get_email and
get_earliest_sent_email and similar methods that specifies folders that
email returned should not be contained within. Also add unit tests.
2018-07-07 11:43:51 +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
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
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
Michael James Gratton
3c436db0e1 Substantially clean up source and API for main Conversation-related classes. 2017-12-18 14:49:04 +11:00
Michael James Gratton
5856a1d288 Allow updating Conversation email paths by via ConversationSet.
* src/engine/app/conversation-monitor/app-conversation-set.vala
  (ConversationSet.add_email): Check to see if the email already exists
  in the conversation, and if so merge its paths rather than just
  returning.
  (ConversationSet.merge_conversations_async): Simplify removing
  conversations to be merged rather than manually handling it, meaning
  email will be unconditionally removed rather than potentially being
  conditionally removed via remove_all_emails_by_identifier.
  (ConversationSet.remove_email_by_identifier): Simply update an email's
  paths in the conversation if it has more than one, rather than removing
  it.
2017-12-18 14:49:04 +11:00
Michael James Gratton
5c1aecb685 Make Geary.App.ConversationSet unit testable, add unit tests.
* src/engine/app/conversation-monitor/app-conversation-set.vala
  (ConversationSet.add_all_emails_async): Replace monitor arg with a
  multiset of email paths, update call site to do the path lookup on the
  caller's side instead. Add unit tests.
  (ConversationSet.merge_conversations_async): Remove monitor arg with a
  multiset of email paths, get paths for emails to be merged from the
  conversations themselves, since they should be up to date.
  (Conversation.remove_all_emails_by_identifier): Add unit tests.
2017-12-18 14:49:04 +11:00
Michael James Gratton
57f40ffec3 Make Geary.App.Conversation unit testable, add some tests.
* src/engine/app/app-conversation.vala (Conversation): We currently can't
  easily unit test Conversation instances since the ctor requires a
  ConversationMonitor argument, which is complicated. Replace the monitor
  arg with a base folder (which is what it actually needs the monitor for
  anyway) and remove the signals in favour of adding and modifying the
  API to allow folder paths to be explicitly updated. Remove
  clear_owner() method and dtor now it's useless. Update call sites. Add
  unit tests to make sure the add/remove and multi-path related code
  still works at least.
2017-12-18 14:49:04 +11:00