Commit graph

460 commits

Author SHA1 Message Date
Michael Gratton
da6ac828bd Move Geary.JS package into client as Util.JS
The only reason it was in the engine was so it could be used by both
the client and the web extension, without worrying about the
webkit2gtk and webkit2gtk_web_extension packages conflicting. However
it didn't really belong there, and added a dependency for the engine
on javascriptcoregtk which doesn't belong. So this fixes all that.
2019-07-21 10:00:32 +10:00
Michael Gratton
6f1834d696 Port JavaScript code from JS to JSC APIs
JSC is WebKitGTK's supported API going forward and is more
straight-forward than the old JS API, so this simplifies the code and
removes a number of deprecated calls.
2019-07-21 09:01:58 +10:00
Michael Gratton
f14b16fe7a Move WebKitUtil namespace to Util.WebKit 2019-07-20 09:13:43 +10:00
Michael Gratton
7cc3e6633e Make adding MIME parts to a new RFC822 message async
This will allow us to schedule some long-running work on a background
thread.
2019-07-19 20:41:34 +10:00
Michael Gratton
b955bc433e Hardcode PartTest's source encoding since it shouldn't change 2019-07-18 15:05:03 +10:00
Michael Gratton
2cb0a83342 Don't munge Base64 encoded text parts when saving to disk
Avoid doing character encoding conversion and CRLF stripping when saving
text parts to disk. This prevents UTF-8 encoded text attachments from
being broken when base64 encoded and no encoding is specified.

See #362
2019-07-18 14:38:38 +10:00
Michael Gratton
faf84db9f4 Actually ensure the engine PartTest suite is run 2019-07-18 14:37:23 +10:00
Michael Gratton
6a871c25c6 Remove Geary.RFC822.Part.get_effective_content_type
Just make the `content_type` property non-nullable and set a default
in the ctor instead, since it's unlikely to ever be null despite the
GMime API suggesting it could be. Update call sites to use the property
instead.
2019-07-18 14:37:10 +10:00
Michael Gratton
b6ec51bc3a Don't consider substrings when checking distinct mailbox names
RFC822.MailboxAddress.has_distinct_name() really needs to not do
sub-string checks since it will cause addresses like
`"foo-bar@baz" <bar@baz>` to not have a distinct name. To keep the fix
for #491 in effect, also adds special case checking for sinlge quotes.

Add some more tests to cover these cases.

Partially reverts commit 6e137eb649

See discussion in GNOME/geary!252
2019-07-17 18:11:17 +10:00
Michael Gratton
bed1bad3ea Fix "'test@example.com' <test@example.com>" marked as spoofed
Make RFC833.MailboxAddress.has_distinct_name() consider substrings
rather than straight-up string comparison.

See #491
2019-07-06 14:38:05 +10:00
Michael Gratton
b0ca8c9e0a Switch to using GLib structured logging
This converts the logging infrastructure to using structured logging
calls, adds and sets a structured logging writer.
2019-06-30 16:15:03 +10:00
Michael Gratton
6e137eb649 Make RFC822.MailboxAddress.has_distinct_name is case-insensitive
This prevents mailboxes being marked as spoofed when the name part and
address part are equal but with different case.
2019-06-27 10:35:26 +10:00
Michael Gratton
7b124abd2e Fix engine test failure under flatpak
Geary.ImapDb.Database/utf8_case_insensitive_collation depends on a well
known UTF-8 collation order, but distros only ship C.UTF-8 by default
and Flatpak doesn't ship that, so support en_US.UTF-8 as a fallback.

See https://gitlab.com/freedesktop-sdk/freedesktop-sdk/issues/812
2019-06-26 12:46:08 +10:00
Michael Gratton
4e1aa32514 Ensure Geary.ContactStoreImpl handles non english searches
Fix DB impl actually do UTF-8 case-insensitive search matching. Add
some unit tests.
2019-06-22 14:11:10 +10:00
Michael Gratton
788a06144f Ensure test drivers all have sane locales set 2019-06-22 14:08:03 +10:00
Michael Gratton
3007ac51da Do prefix-only searching in ContactStoreImpl to impove results 2019-06-13 16:56:03 +10:00
Michael Gratton
71cb7fcdfe Add Geary.ContactStore.search method, impementation and tests 2019-06-13 16:56:03 +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
Michael Gratton
5e13dd0abd Replace Db.PrepareDelegate with a subclass virtual function hook
While slightly less flexible, it fits the Engine's needs and simplifies
the DB API.
2019-06-13 16:35:17 +10:00
Michael Gratton
03b5fcee8a Pass email to a contact harvester instance when persisting it
Add a ContactHarvester arg to ImapDB.Folder.create_or_merge_email and
call it on the resulting email. Add and update a new harvester
property to MinimalFolder and pass that in as needed.
2019-06-13 16:33:44 +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
91caff487b Add support for uint args in expected calls in MockObject 2019-06-13 16:31:26 +10:00
Michael Gratton
bc64cd9847 Provide a way to access actual args for an expected mock call 2019-06-13 16:30:42 +10:00
Michael Gratton
cb8150ce03 Remove existing contact harvesting mechanism
Remove contact harvesting from DB version 005 (version 0.1.1), allowing
the implementation of both ContactStoreImpl and ImapDB.Database to be
cleaned up. Remove contact collection from ImapDB.Folder, reducing the
numer of Gee objects created when creating/merging messages. Finally,
remove the MessageAddresses object now that it is unused.
2019-06-13 16:28:59 +10:00
Michael Gratton
809f664319 ContactStoreImpl unit tests 2019-06-13 16:28:55 +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
Rafael Fontenelle
2509c5c4f0 Fix misspellings 2019-05-22 20:47:08 +00:00
Jonathan Haas
bfe504fed3 Make sure we match the whole link text as URL and not only some part. Add some symbols to be invalid in domains. Add 3 tests. 2019-04-27 11:52:51 +02:00
Michael Gratton
534b4e27d9 Don't MIME-encode RFC822 mailbox local parts
This is explicilty disallowed by RFC 2074 §5 and not accepted by mail
servers.

See #336
2019-04-24 20:43:39 +10:00
Michael Gratton
c306c2c5fa Correctly handle escaping UTF-8 characters in RFC822 mailboxes
Use string.get_next_char() to handle iterating over an
RFC822.MailboxAddress mailbox local part, and explicitly allow UTF-8
2, 3, and 4 byte chars without quoting, per RFC 5322.

This lets us fix the test cases that use UTF-8 chars in the local part.
2019-04-24 20:38:11 +10:00
Michael Gratton
c58d0b74e9 Add simple SMTP integration test 2019-04-24 17:18:03 +10:00
Michael Gratton
a163dea96a Merge branch 'wip/application-cleanup' into 'mainline'
Application cleanup

See merge request GNOME/geary!215
2019-04-21 06:18:14 +00:00
Michael Gratton
d4c29c72d7 Add unit tests for app path accessors 2019-04-21 11:13:01 +10:00
Michael Gratton
bc7f5c5392 Fix TNEF engine tests not being run 2019-04-20 15:06:30 +10:00
Michael Gratton
b80f6b0db4 Minor fix for MockObject 2019-04-17 09:06:24 +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
5c7c382ca5 Fix failing test when ytnef support disabled 2019-04-16 23:45:38 +10:00
Michael Gratton
4497b1275a Merge branch 'tnef-support' into 'mainline'
TNEF (winmail.dat) parsing support via libytnef

See merge request GNOME/geary!10
2019-04-16 12:38:25 +00:00
Niels De Graef
9acf5d344d Make Geary DBus-activatable. Bug 775956.
* org.gnome.Geary.service.in: create, and let it be installed by CMake.

* org.gnome.Geary.desktop.in: add `DBusActivatable=true`.

* geary-autostart.desktop.in: use `--gapplication-service` instead of
hidden.

* Change the way arguments are parsed:
  * Use the _command-line_ and _handle-local-options_ signals instead
    of _local-command-line_.
  * Remove the `--hidden` option (replaced by `--gapplication-service`)
  * Use VariantDict (which is a little cleaner)
  * Don't use global variables in Arg, but set them in
  the config instead.
  * We can no longer set a global summary due to the new option handling
  in GApplication. On IRC, I got the feedback that info like this should
  be going into a manpage.

* Since the QUIT-action can now be called without ever activating the
app, make the necessary changes to the `GearyController`:
  * `main_window` and `current_conversations` can be null.
  * use `pending_mailtos()` for the compose action as well.
  * Don't update the UNDO action if we're closing down.

* More instance variables prefixed with this (we're changing the lines
anyway, might as well do it properly).

* `Environment.set_prgname()` is already executed in GApplication.run(),
so no more need for `GearyApplication.PRGNAME`.

Signed-off-by: Niels De Graef <nielsdegraef@gmail.com>
2019-04-12 22:04:56 +10:00
Oliver Giles
18fcf0e18f TNEF (winmail.dat) parsing support via libytnef 2019-04-11 12:24:52 +03:00
Michael Gratton
ef8f97628e Merge branch 'wip/remove-ci-test-workaround' into 'mainline'
Remove CI test workaround

See merge request GNOME/geary!198

(cherry picked from commit 8654c7ae136d2467f7b5b2e85a436d9039bd64bc)

4fc688de Revert "Work around DB tests always failing on gcc150.osuosl.org CI runner"
6b4b598a Add test runner multiplier to account for slow CI runners
2019-04-09 16:16:10 +00:00
Michael Gratton
73159ba091 Add new generic LRU cache to the client 2019-04-08 10:26:04 +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
Michael Gratton
aa223d103d Replace references to master with primary
See #324
2019-04-02 13:35:25 +11:00
Michael Gratton
71d8c8b1a4 Update Imap.ClientSession now IMAP NO commands aren't treated as errors
Check the response code when logging in for the command, and handle as
appropriate.
2019-04-01 02:01:04 +11:00
Michael Gratton
cddbb28a43 Add initial integration test famework and IMAP client session tests 2019-03-31 02:05:14 +11:00
Michael Gratton
60a3f9346d Add TestCase.async_complete_full method to avoid requiring a lambda 2019-03-31 01:29:52 +11:00
Michael Gratton
9c115bec38 Clean up protocol date handling substantially
In RFC822.Date, don't use duplicate time_t and GLib.DateTime properties
-- just use the latter, fix formatting of half-hour time zones, fix
where the that class refers to ISO 8601 instead of RFC822 strings since
that is just plain wrong, and finally when parsing an RFC 822 string,
take note of the timezone offset and store that in the DateTime object,
so it is round-tripped correctly.

Stop passing time_t around everywhere else, just use the UNIX time from
the DateTimes we store for protocol objects anyway, so the time zone is
obvious.

Add unit tests.
2019-03-23 15:21:18 +11:00