summaryrefslogtreecommitdiffstats
path: root/curs_main.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-05-29 10:54:56 -0700
committerKevin McCarthy <kevin@8t8.us>2020-05-31 14:45:34 -0700
commit44711a243ee8fe7dc5e206d0175a5026599275ef (patch)
tree0d3f5ae23bd57227a799afce4fd7dd9b4e67b460 /curs_main.c
parent878e261adce03ec65d1e552d1be661deb88c8951 (diff)
Try to automatically reconnect to an open IMAP mailbox on error.
For the Context, change cmd_handle_fatal() to flag idata->status on the error, but not close the mailbox and disconnect. Then have imap_check_mailbox() reconnect when IMAP_REOPEN_ALLOW is set (so the index is prepared to rebuild with all new headers). Try to merge flag, envelope, and attach_del changes back in. Replace the existing Context pointer with the new values, and swap out the idata passed in on success, so we don't continue to work with the wrong idata. The imap_check_mailbox() changes are purposely coded loosely to try and catch all sorts of errors - not just polling and imap_idle errors. Create a new check_mailbox() return code to indicate a reconnect. Display a more appropriate message in the index, but otherwise treat it the same as a REOPEN.
Diffstat (limited to 'curs_main.c')
-rw-r--r--curs_main.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/curs_main.c b/curs_main.c
index 5b5c4793..59588faf 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -481,6 +481,10 @@ static void update_index (MUTTMENU *menu, CONTEXT *ctx, int check,
{
int j;
+ /* for purposes of updating the index, MUTT_RECONNECTED is the same */
+ if (check == MUTT_RECONNECTED)
+ check = MUTT_REOPENED;
+
/* take note of the current message */
if (oldcount)
{
@@ -689,13 +693,22 @@ int mutt_index_menu (void)
set_option (OPTSEARCHINVALID);
}
- else if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED || check == MUTT_FLAGS)
+ else if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED ||
+ check == MUTT_FLAGS || check == MUTT_RECONNECTED)
{
update_index (menu, Context, check, oldcount, index_hint);
/* notify the user of new mail */
if (check == MUTT_REOPENED)
mutt_error _("Mailbox was externally modified. Flags may be wrong.");
+ else if (check == MUTT_RECONNECTED)
+ {
+ /* L10N:
+ Message printed on status line in index after mx_check_mailbox(),
+ when IMAP has an error and Mutt successfully reconnects.
+ */
+ mutt_error _("Mailbox reconnected. Some changes may have been lost.");
+ }
else if (check == MUTT_NEW_MAIL)
{
mutt_message _("New mail in this mailbox.");
@@ -1070,7 +1083,8 @@ int mutt_index_menu (void)
done = 1;
else
{
- if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED)
+ if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED ||
+ check == MUTT_RECONNECTED)
update_index (menu, Context, check, oldcount, index_hint);
menu->redraw = REDRAW_FULL; /* new mail arrived? */
@@ -1191,7 +1205,8 @@ int mutt_index_menu (void)
if ((check = mx_close_mailbox (Context, &index_hint)) != 0)
{
- if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED)
+ if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED ||
+ check == MUTT_RECONNECTED)
update_index (menu, Context, check, oldcount, index_hint);
set_option (OPTSEARCHINVALID);
menu->redraw = REDRAW_FULL;
@@ -1246,7 +1261,8 @@ int mutt_index_menu (void)
}
set_option (OPTSEARCHINVALID);
}
- else if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED)
+ else if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED ||
+ check == MUTT_RECONNECTED)
update_index (menu, Context, check, oldcount, index_hint);
/*
@@ -1376,7 +1392,8 @@ int mutt_index_menu (void)
if (!monitor_remove_rc)
mutt_monitor_add (NULL);
#endif
- if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED)
+ if (check == MUTT_NEW_MAIL || check == MUTT_REOPENED ||
+ check == MUTT_RECONNECTED)
update_index (menu, Context, check, oldcount, index_hint);
FREE (&new_last_folder);