Commit Graph

102 Commits

Author SHA1 Message Date
Reto Brunner da6fb1a155 maildir/notmuch: don't re-encode readers 2020-01-05 16:02:46 -05:00
Reto Brunner 3d85f75d9c imap: decode reader prior to returning them 2020-01-05 16:02:45 -05:00
Reto Brunner 9096049f75 FetchBodyParts: decode source in the workers
Previously the workers returned a mixture of decoded / encoded parts.
This lead to a whole bunch of issues.
This commit changes the msgviewer and the commands to assume parts to already
be decoded
2020-01-05 16:02:45 -05:00
Reto Brunner 63391b7dca Add labels to index format (%g)
Exposes the notmuch tags accordingly, stubs it for the maildir worker.
2019-12-27 10:20:29 -07:00
Reto Brunner 40ceee969b notmuch: emit LabelList event 2019-12-21 11:20:11 -05:00
Reto Brunner 2705d8460d add LabelList event 2019-12-21 11:20:11 -05:00
Leszek Cimała e84e402e48 decode(RFC 2047) imap headers to fix encoding in subject & filenames
Me again,
this time fixing encoding of subjects and attachments. It was problem in
IMAP backend. While other backends user MessageInfo() function which
generates MessageInfo decoded via go-message methodes, IMAP worker is
creating MessageInfo directly, so all non-utf8 subjects and filenames
were in raw form.

This patch fixes it. Not sure if we should care about errors (if
DecodeHeader fails it returns raw string back).

>From what I see, this should solve all encoding problem (tested only
IMAP). So, now I can focus on features. ;-)

Have a great weekend!
Leszek
2019-12-07 14:30:33 -05:00
Srivathsan Murali 59c24523af Parse Reply-To header while parsing envelope 2019-11-17 13:24:23 -05:00
Kevin Kuehler 8a848303fe worker/imap: Fix seqMap race condition
When deleting a message, sometimes FetchDirectoryContents will fire.
FetchDirectoryContents will return a smaller set of UIDs since messages
have been deleted. This operation races with fetching from the seqMap in
client.ExpungeUpdate. Only recreate the seqMap if it can grow so that
messages will continue to be expunged.

Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
2019-11-10 17:19:23 -05:00
Reto Brunner 6dc537fbe3 Notmuch: be resilient to config errors
Right now notmuch panics if something goes wrong in the configure event.
This patch checks for that and returns an error instead, so that we can at least
get the UI up and running (and all the other accounts)

The experience will be completely degraded until another configure event occurs.
2019-11-01 11:02:01 -04:00
Matt Snider cd39e8f90c notmuch: ignore comments and blank lines when processing query-map file
A segmentation fault occurs when using the notmuch backend and a `query-map`
file that contains blank lines or comments.
2019-11-01 11:02:01 -04:00
Frode Aannevik 550ef0bc1f Fix: oauthbearer runtime error
Configure an oauthbearer source without a token_endpoint
parameter would panic due to nil pointer dereference

  Example
    source=imaps+oauthbearer://frode.aa%40gmail.com@imap.gmail.com:993
    source-cred-cmd=pass oatuh2 frode.aa@gmail.com

token_endpoint is not required as it will use the provided
password as access_token when it is not set
2019-10-16 11:04:41 -04:00
Jeffas d2a18e267c Change search flags
This changes the search flags for maildir and imap backends.

They now no longer use -t for searching all text. This seems to make
more sense as being the targeted recipient. I have similarly added Cc
for -c. The text search now resides under -a for all text.
2019-09-20 15:06:54 -04:00
Reto Brunner 3ec9fd216d notmuch: add sort functionality 2019-09-20 15:01:07 -04:00
Jeffas 90d26da58a Add sorting functionality
There is a command and config option. The criteria are a list of the
sort criterion and each can be individually reversed.

This only includes support for sorting in the maildir backend currently.
The other backends are not supported in this patch.
2019-09-20 14:56:02 -04:00
Jeffas 43435ba06c Add directory info messages
This populates the directory info model properly when requested,
allowing the fields to be relied upon elsewhere.

This also sends the dirinfo when new messages come in.
2019-09-18 19:34:30 -04:00
Jeffas c97d0d6320 Add basic searching to the maildir backend
Basic searching is supported with the following:
- read messages
- unread messages
- from addresses
- text in body
- text in subject
- text in all

The implementation loops through all messages in the selected directory.
It tries to be smart by detecting which parts of each message the search
query needs to use and only loads these from the filesystem.
2019-09-16 12:40:26 -04:00
Reto Brunner edfab1b201 notmuch: implement ModifyLabels 2019-09-16 12:19:15 -04:00
Reto Brunner 3f452ca283 notmuch: sync maildir flags
Syncs back special notmuch tag like unread to the underlying maildir store
2019-09-16 12:19:14 -04:00
Reto Brunner 83207c1e1d notmuch: extract all notmuch db operations.
For some reason the current code frequently segfaults due to an
invalid C memory address. This commit mediates that by never keeping an object
alive longer than absolutely necessary.
2019-09-16 12:19:13 -04:00
Reto Brunner a93b4de6f3 Add modify-labels command
This adds the event type as well as the command implementation, but no backend
supports it yet.
2019-09-12 16:17:24 -04:00
Jeffas 32381592fc Add new search behaviour for imap
This patch adds search behaviour to allow searching in the body of the
messages, the entire text (body + header), and searching just the from
header.
2019-09-11 12:24:27 -04:00
Wagner Riffel baa70469c3 all: rewrite references to strings.Index to strings.Contains
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2019-09-04 16:30:57 -10:00
Reto Brunner f13f9a8684 notmuch: add search / filter capabilities 2019-08-29 08:44:11 +09:00
Reto Brunner 94b9d557de extract search criteria parsing into the backends 2019-08-29 08:44:10 +09:00
Reto Brunner a2c5233f71 Notmuch: use adhoc write connection.
Notmuch only allows a single write connection, all other clients trying to
modify the db block. Hence we should only open one when we actually need it.

Apparently we also need to refresh the RO DB connection upon modification,
else we get stale message tag results
2019-08-26 09:56:44 +09:00
Wagner Riffel 90453b5db4 imap worker: do not copy mailbox status mutex
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2019-08-26 09:54:57 +09:00
Ben Burwell a1749411e6 maildir: Preserve flags when copying messages 2019-08-08 12:50:54 +09:00
Reto Brunner c38ddf8d30 Add notmuch backend
This commit introduces the notmuch backend.
The backend is conditionally compiled in if the "notmuch" tag is provided.

Most of the message types are implemented, with the notable exceptions
of DeleteMessages as well as any copy / move / append type.
Reason being, that those aren't normally applicable in a notmuch based workflow.

Changes v2 --> v3, based on review comments
* Use account config for configuration
2019-08-08 10:10:34 +09:00
Reto Brunner 07a4b0fef0 Extract message parsing to common worker module
Things like FetchEntityPartReader etc can be reused by most workers
working with raw email files from disk (or any reader for that matter).

This patch extract that common functionality in a separate package.
2019-08-08 10:10:31 +09:00
Jelle Besseling aeca428c14 Don't print imap errors to ui
This fixes ~sircmpwn/aerc2#245. This sets up the imap client to send
error messages to the logger of the worker. Errors now end up in the
bottom status line.

https://todo.sr.ht/~sircmpwn/aerc2/245
2019-08-08 09:47:15 +09:00
Ben Burwell 04ccbd09b1 Clean maildirs when opened
This removes old aborted deliveries from the tmp directory.
2019-08-02 09:26:07 -04:00
Nicolai Dagestad d526786c93 Fix error handling in maildir worker 2019-07-19 17:33:33 -04:00
Reto Brunner 6fed04bb9f Register worker in init.
This allows backends which can't always be compiled due to missing
dependencies (say libnotmuch) to be compiled conditionally with buildflags.
2019-07-19 15:37:55 -04:00
Ben Burwell 6473848d87 maildir: Watch for new messages
When a directory is opened, start watching its "new" subdirectory for
incoming messages using the fsnotify library. When creation events are
detected, run the Unseen routine to move the message from new to cur and
add new UIDs to the store, updating the UI's list of directory contents
as we go.
2019-07-17 17:29:11 -04:00
Ben Burwell eb0481b9cc Fix header decoding
Email headers can be encoded with different charsets, which is signalled
using a special character sequence. The go-message package provides two
different methods for accessing header values, Get(key) (actually
inherited from the embedded textproto.Header) which returns the raw
header value and Text(key), which returns the header's value decoded as
UTF-8.

Before, in the maildir backend, we were using the Get method which
sometimes resulted in encoded headers being displayed in the UI. This
patch replaces the incorrect usage of Get() with Text().
2019-07-17 15:58:15 -04:00
Drew DeVault dba16157de Fix missing format fields in maildir/container.go 2019-07-13 11:21:17 -04:00
Ben Burwell d15ba24a2f Implement maildir copy
Create a delivery in the destination directory with the content of the
source message.
2019-07-12 11:26:39 -04:00
Ben Burwell 1b8b6e218c Add maildir backend worker
Add the initial implementation of a backend for Maildir accounts. Much
of the functionality required is implemented in the go-message and
go-maildir libraries, so we use them as much as possible.

The maildir worker hooks into a new maildir:// URL scheme in the
accounts.conf file which points to a container of several maildir
directories. From there, the OpenDirectory, FetchDirectoryContents, etc
messages work on subdirectories. This is implemented as a Container
struct which handles mapping between the symbolic email folder names and
UIDs to the concrete directories and file names.
2019-07-12 11:09:50 -04:00
Daniel Bridges 06da4512b9 #190 Handle gmail duplicate folder 2019-07-11 19:38:40 -04:00
Frode Aannevik b0eaf5191c Support imaps with oauthbearer authentication (Gmail)
imaps+oauthbearer://user:token@host?token_endpoint=...

 - the config Source password is used as access token if
   no token_endpoint parameter is set
 - the config Source password is used as refresh token if
   token_endpoint parameter is set, and used to exchange
   with an access token

The implementation has only been tested with Gmail.

    source = imaps+oauthbearer://{username}:{refersh_token}@imap.gmail.com:993? \
    client_id=XX&\
    client_secret=XX&\
    token_endpoint=https%3A%2F%2Faccounts.google.com%2Fo%2Foauth2%2Ftoken

client credentials created with

    https://console.developers.google.com/apis/credentials

refresh token created with

    https://github.com/google/gmail-oauth2-tools/blob/master/python/oauth2.py

rel: https://todo.sr.ht/~sircmpwn/aerc2/42
2019-07-11 19:36:14 -04:00
Ben Burwell c610c3cd9d Factor IMAP-specific structs out of UI models
Before, we were using several IMAP-specific concepts to represent
information being displayed in the UI. Factor these structures out of
the IMAP package to make it easier for other backends to provide the
required information.
2019-07-08 16:06:28 -04:00
Ben Burwell 88c379dcba Use []uint32 instead of imap.SeqSet
A sequence-set is an IMAP-specific implementation detail. Throughout the
UI, aerc simply operates using lists of opaque identifiers. In order to
loosen the coupling between the UI and IMAP in particular, replace most
usages of imap.SeqSet with []uint32, leaving the translation to a SeqSet
to the IMAP backend as needed.
2019-07-08 16:06:26 -04:00
Ben Burwell cce7cb4808 Factor UI models out of the worker message package
Before, the information needed to display different parts of the UI was
tightly coupled to the specific messages being sent back and forth to
the backend worker. Separating out a models package allows us to be more
specific about exactly what a backend is able to and required to
provide for the UI.
2019-07-08 16:06:23 -04:00
Drew DeVault f7387f8c60 Sort out dirstore once and for all 2019-07-04 12:31:27 -04:00
Drew DeVault 198661bfbd worker/imap: rig up search directory handler 2019-06-24 16:31:37 -04:00
Drew DeVault 0e9c411751 worker/imap: implement search 2019-06-24 16:29:25 -04:00
Drew DeVault fd0265d917 imap: block until directory list is fully received
This fixes issues with INBOX mysteriously not being present at times
2019-06-14 10:49:31 -04:00
Reto Brunner 626f91c483 imap: respect the folder config option 2019-06-14 10:42:24 -04:00
Drew DeVault 6271d455eb Add :read and :unread commands 2019-06-09 14:55:42 -04:00