Richard Russon [Sun, 9 Sep 2018 15:20:11 +0000 (16:20 +0100)]
merge: redistribute Context and Mailbox
* fix mxapi comments
* move Context.mx_ops
* move Context.ctx->data
* move Context.{hdrs,hdrmax}
* move Context.{size,changed,readonly,quiet,closing}
* free_data
* notmuch: move mailbox data
* notmuch: let mxapi do cleanup
* notmuch: use mailbox, not context
* mbox: use Mailbox, not Context
* maildir: use Mailbox, not Context
* nntp: use Mailbox, not Context
* pop: use Mailbox, not Context
* compress: use Mailbox, not Context
* imap: use Mailbox, not Context
* add mbox private Mailbox data
* move Context.rights
* eliminate Context from backends
* Mailbox doesn't begin with 'b'
* move Context.compress
* tidy compress
* move Context.{id,subj,label}_hash
* move Context.{v2r,vcount}
* move Context.mtime
* tidy context usage
* imap: rename mailbox out of the way
Richard Russon [Mon, 3 Sep 2018 23:53:24 +0000 (00:53 +0100)]
merge: upstream CONDSTORE and QRESYNC
* Add basic CONDSTORE support when fetching initial messages.
* Add utility functions for QRESYNC support.
* Add QRESYNC support.
* Add more doc for the $imap_condstore and $imap_qresync options.
* Only sync CONDSTORE and QRESYNC on the initial download.
* Allow ctrl-c to interrupt initial IMAP header download.
* Fix nested macro warning.
* tidy upstream changes
Kevin McCarthy [Tue, 21 Aug 2018 22:51:09 +0000 (15:51 -0700)]
Fix nested macro warning.
Pull the #if/#else outside of the snprintf in imap.c. On some
platforms, snprintf is a macro itself, which leads to a warning about
undefined behavior.
Thanks to Charles Diza for pointing out the problem.
Kevin McCarthy [Wed, 15 Aug 2018 23:13:45 +0000 (16:13 -0700)]
Allow ctrl-c to interrupt initial IMAP header download.
Once the mailbox is open, it is significantly more complicated to
abort and keep Mutt from crashing. But during the initial
open/download Mutt is prepared to close the mailbox cleanly on
failure.
Kevin McCarthy [Mon, 13 Aug 2018 16:43:55 +0000 (09:43 -0700)]
Only sync CONDSTORE and QRESYNC on the initial download.
In the midst of the imap_read_headers() refactor, I forgot to put this
guard on the /MODSEQ and /UIDSEQSET storage.
Because we don't deal with flag sync issues while the mailbox is open,
or when it closes, we only want to write those values to the header
cache during the initial download.
It makes no sense to perform all the header cache work if new messages
come into an open empty mailbox, so add a parameter to flag the
initial download, rather than check for msn_begin==1.
Kevin McCarthy [Sat, 26 May 2018 23:02:04 +0000 (16:02 -0700)]
Add QRESYNC support.
Refactor imap_read_headers() to break into functions for the different
queries.
Move uid_hash population to the same place msn_index is populated.
Change the VANISHED handler to not decrement MSNs for EARLIER.
FastMail, at least, does assume there are no gaps, and really it makes
no sense for there to be. Further testing will be needed.
Kevin McCarthy [Tue, 15 May 2018 01:12:39 +0000 (18:12 -0700)]
Add basic CONDSTORE support when fetching initial messages.
Store MODSEQ in the header cache, and use that to perform a "FETCH
CHANGEDSINCE" for header updates when initially downloading messages.
Further improvements could be made to add support when syncing.
Handling MODSEQ for FLAG updates while the mailbox is open would be
complicated by the fact that Mutt supports locally modified headers,
so we couldn't accept the new (or subsequent) MODSEQ.
However, this initial step may at least provide some benefit when
opening the mailbox, which is generally the most time and data
intensive.
Richard Russon [Mon, 3 Sep 2018 15:35:14 +0000 (16:35 +0100)]
merge: upstream OAUTHBEARER
* Initial support for OAUTHBEARER for IMAP.
* Support for using OAUTHBEARER for smtp.
* Remove uninitialized warning for mutt_get_stat_timespec().
* Improve OAUTHBEARER support.
* tidy upstream changes
* reorganise smtp auth_plain
Richard Russon [Mon, 3 Sep 2018 13:19:46 +0000 (14:19 +0100)]
merge: upstream inotify
* add feature file monitoring with Linux inotify
* Change direct mutt_getch() callers to handle new mail event.
* Add new timeout functions to work with inotify monitors.
* Quick fix for ncurses buffering issue with inotify polling.
* Move mutt_getch() timeout value into curs_lib.c
* Convert context and buffy to use nanosecond timestamps.
* Work around open mailbox monitor code check issue.
* Fix MonitorContextDescriptor update on removal.
* Reset all MonitorContext state on context removal.
* tidy upstream changes
Kevin McCarthy [Wed, 27 Jun 2018 16:27:05 +0000 (09:27 -0700)]
Reset all MonitorContext state on context removal.
Reset both the descriptor and changed flag when the current context is
removed. Don't make this dependent on the context being valid or
being found by monitor_resolve(), in case the context was closed due
to some type of error condition.
Kevin McCarthy [Wed, 27 Jun 2018 02:48:25 +0000 (19:48 -0700)]
Fix MonitorContextDescriptor update on removal.
Reset the context descriptor before checking for the monitor being
shared by another mailbox. Technically, it would be set properly
during the next add, but it shouldn't be left incorrect.
Kevin McCarthy [Tue, 26 Jun 2018 00:54:43 +0000 (17:54 -0700)]
Work around open mailbox monitor code check issue.
The monitor code is too fast, and can result in all the changes for a
single directory stat update being missed.
Work around this issue by not recording stat time updates when the
check_mailbox() is triggered by the monitor. This will cause the next
subsequent check to take another look.
Kevin McCarthy [Thu, 14 Jun 2018 08:17:56 +0000 (16:17 +0800)]
Convert context and buffy to use nanosecond timestamps.
The inotify interface has an unfortunate side effect of making Mutt
react too quickly to new mail. Sometimes, the mail is only
half-delivered when the mailbox is checked. Because Mutt is using the
stat mtime - seconds resolution - this means it won't realize there
are more messages delivered during the same second.
Nanosecond resolution fields were standardized in POSIX.1-2008, so
check for and use those if they are available.
Kevin McCarthy [Wed, 6 Jun 2018 00:38:44 +0000 (17:38 -0700)]
Quick fix for ncurses buffering issue with inotify polling.
Ncurses does its own buffering for some character sequences, notable
Esc-prefixed input. Add a non-blocking check for getch() before
performing the mutt_monitor_poll() call.
This is a quick fix, which I'll clean up more later.
Kevin McCarthy [Mon, 4 Jun 2018 01:34:21 +0000 (18:34 -0700)]
Add new timeout functions to work with inotify monitors.
The ncurses timeout() function doesn't affect the new poll inside
mutt_monitor_poll(). This meant that $imap_keepalive and $timeout
were not being respected when the monitor was used.
Create mutt_getch_timeout(), which delegates to timeout() and sets a
timeout value mutt_monitor_poll() uses too.
Kevin McCarthy [Sun, 3 Jun 2018 21:05:13 +0000 (14:05 -0700)]
Change direct mutt_getch() callers to handle new mail event.
The inotify handler now returns -2 (timeout) on a new mail event.
Change the direct callers to ignore, so prompts aren't strangely
aborted.
Also, fix mutt_change_flag() to call mutt_refresh() before the
prompt. Apparently ncurses getch() was doing this for us, but now
that we are polling STDIN instead, the prompt wasn't displaying.
Richard Russon [Mon, 3 Sep 2018 01:01:42 +0000 (02:01 +0100)]
merge: upstream fixes
* Convert certificate prompts to show sha-256 instead of md5.
* Fix typo
* Clean up documentation link targets.
* Change compress examples to type "example" rather than "sect4".
Richard Russon [Sat, 1 Sep 2018 17:59:12 +0000 (18:59 +0100)]
merge: upstream fixes
* crypt-gpgme: prevent crash on bad S/MIME signature
* Void passphrase on s/mime decryption error
* smime_handle_entity() cleanup
* Mention $pgp_decode_command for $pgp_check_gpg_decrypt_status_fd
* Minor documentation fix
* Display matching new messages in a thread-limited index
* Bug fix: reset ctx->vsize in update_index_unthreaded on reopened mailbox
* Improved limit-to-all detection by skipping leading spaces of the pattern
* Add ctx->vsize = 0 in a couple of places
* Handle reopen/new_mail when closing mailbox in <imap-logout-all>
* Skip sort in mbox_sync_mailbox() when new/reopen occurs
* Add mx_ops.msg_padding_size to return the padding for a mx type
* Add message padding to ctx->vsize computation
* Fix AUXSORT usage in compare_spam
* Fix -z and -Z options to work with IMAP
* Create mutt_buffer_increase_size() function
* Always check UID vs MSN when handling FETCH
* Refactor out mutt_is_quote_line()
* Don't match $abort_noattach_regexp on quoted lines
* Remove legacy trim_incomplete_mbyte() in the pager
* Remove compare_stat() call in safe_rename()
* Display an error message if syncing fails
* Change $query_format to use mutt_format_s
* Fix alias documentation examples
* Add additional error handling to safe_rename()
* Remove extra lstats() in safe_rename() upon link success
* Add compose-to-sender functionality.
Kevin McCarthy [Wed, 22 Aug 2018 22:07:45 +0000 (15:07 -0700)]
Add compose-to-sender functionality.
This patch is loosely based on the NeoMutt feature, but adds in
support for the attach menu, reuses functionality in send.c, and has
proper mode checks.
Thanks to Enno for the opening the ticket requesting the port.
Kevin McCarthy [Wed, 29 Aug 2018 20:00:14 +0000 (13:00 -0700)]
Remove extra lstats() in safe_rename() upon link success
I originally kept the lstat()'s in order to make as few changes as
possible to the function. However, Derek Martin argues correctly that
if we are trusting the link() 0-retval, the lstats are unnecessary and
in fact can cause a performance impact over NFS.
Kevin McCarthy [Mon, 27 Aug 2018 01:43:20 +0000 (18:43 -0700)]
Add additional error handling to safe_rename()
It is apparently possible for link() to return an error but the link
to still be created. Add a double check for that case. If the files
match, unlink the src and return success.
Kevin McCarthy [Fri, 24 Aug 2018 19:56:54 +0000 (12:56 -0700)]
Display an error message if syncing fails
Ticket 36 reported an issue where a maildir was removed while the
mailbox was opened. Later, attempting to sync displayed the message
"Writing xxx...", which remained on the screen. The reporter actually
thought mutt was frozen, but it was simply that on a sync error Mutt
wasn't clearing or updating the message window.
There is some error message handling for mbox.c check_mailbox, but I
don't think that is the right place to further propogate messages.
Instead, add an error to the same place the initial "Writing..."
message is created.
Kevin McCarthy [Tue, 14 Aug 2018 21:31:34 +0000 (14:31 -0700)]
Remove compare_stat() call in safe_rename()
Some filesystems, such as sshfs, implement hard links strangely. The
hard link is created, but is represented by a different inode number
by the sshfs layer. The current maildir code goes into an infinite
loop in this case. Remove the compare_stat() and trust that a link()
return code of 0 means the link really did get created. Still, keep
the stats just as a minor check.
Kevin McCarthy [Tue, 14 Aug 2018 21:04:05 +0000 (14:04 -0700)]
Remove legacy trim_incomplete_mbyte() in the pager
Commit 4b1deb57 added the trim_incomplete_mbyte() call, but at
that time, the function was using fgets() into a fixed-sized
buffer. The function was passing in "blen - 1" to the size
parameter of fgets, so the check for blen-2 was to see if the
buffer was completely filled by the fgets.
Commit d39d9c0c converted to use a dynamic buffer, but the
trim_incomplete_mbyte() was left in. It now serves no purpose
because the entire line will be read in. Presumably the buggy
regexp lib should have been fixed by now too.