<<< Date Index >>>     <<< Thread Index >>>

[PATCH] IMAP logout command



The attached patch for mutt 1.5.15 adds the ability to log out of all
IMAP servers.  Currently the only way to close IMAP connections is to
quit mutt.

This patch is useful for mobile users who leave mutt running on their
laptop and change locations (and therefore networks).  By binding this
to a keyboard shortcut, you can logout of all IMAP connections before
putting your laptop to sleep.  IMAP connections can then be reopened
later.

--- mutt-1.5.15.old/PATCHES     2007-03-15 08:49:37.000000000 -0700
+++ mutt-1.5.15/PATCHES 2007-04-21 21:34:31.000000000 -0700
@@ -0,0 +1 @@
+patch-1.5.15.gs.imap_logout.1
--- mutt-1.5.15.old/OPS 2007-04-01 14:58:55.000000000 -0700
+++ mutt-1.5.15/OPS     2007-04-21 20:57:05.000000000 -0700
@@ -102,6 +102,7 @@
 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
+OP_MAIN_IMAP_LOGOUT_ALL "logout from all IMAP servers"
 OP_MAIN_FETCH_MAIL "retrieve mail from POP server"
 OP_MAIN_FIRST_MESSAGE "move to the first message"
 OP_MAIN_LAST_MESSAGE "move to the last message"
--- mutt-1.5.15.old/curs_main.c 2007-04-03 10:41:14.000000000 -0700
+++ mutt-1.5.15/curs_main.c     2007-04-21 21:42:43.000000000 -0700
@@ -995,6 +995,19 @@
        if (Context && Context->magic == M_IMAP)
          imap_check_mailbox (Context, &index_hint, 1);
         break;
+
+      case OP_MAIN_IMAP_LOGOUT_ALL:
+       if (Context)
+       {
+         if (mx_close_mailbox (Context, &index_hint) == 0)
+         {
+           FREE (&Context);
+           imap_logout_all();
+         }
+       }
+       set_option (OPTSEARCHINVALID);
+       menu->redraw = REDRAW_FULL;
+       break;
 #endif
       
       case OP_MAIN_SYNC_FOLDER:
--- mutt-1.5.15.old/functions.h 2007-04-01 14:58:55.000000000 -0700
+++ mutt-1.5.15/functions.h     2007-04-21 20:56:39.000000000 -0700
@@ -107,6 +107,7 @@
 #endif
 #ifdef USE_IMAP
   { "imap-fetch-mail",         OP_MAIN_IMAP_FETCH,             NULL },
+  { "imap-logout-all",         OP_MAIN_IMAP_LOGOUT_ALL,        NULL },
 #endif
   { "display-toggle-weed",             OP_DISPLAY_HEADERS,             "h" },
   { "next-undeleted",          OP_MAIN_NEXT_UNDELETED,         "j" },
@@ -188,6 +189,7 @@
   { "group-reply",     OP_GROUP_REPLY,                 "g" },
 #ifdef USE_IMAP
   { "imap-fetch-mail",  OP_MAIN_IMAP_FETCH,            NULL },
+  { "imap-logout-all",  OP_MAIN_IMAP_LOGOUT_ALL,       NULL },
 #endif
   { "display-toggle-weed",     OP_DISPLAY_HEADERS,             "h" },
   { "next-undeleted",  OP_MAIN_NEXT_UNDELETED,         "j" },