Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Fri, 14 Oct 2005 10:15:33 +0000 (10:15 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Fri, 14 Oct 2005 10:15:33 +0000 (10:15 +0000)
- accept patch #443 to rebuild all header caches slightly modified: don't add -r command line option but generic <rebuild-cache> function

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@548 e385b8ad-14ed-0310-8656-cc95a2468c6d

OPS
UPGRADING
VERSION.svn
curs_main.c
functions.h
menu.c
mx.c
mx.h

diff --git a/OPS b/OPS
index 4bf0ab2..cb979bd 100644 (file)
--- a/OPS
+++ b/OPS
@@ -114,6 +114,7 @@ OP_MAIN_CHANGE_GROUP "open a different newsgroup"
 OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode"
 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
 OP_MAIN_DELETE_PATTERN "delete messages matching a pattern"
+OP_REBUILD_CACHE "rebuild header caching databases"
 OP_RECONSTRUCT_THREAD "reconstruct thread containing current message"
 OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server"
 OP_MAIN_FETCH_MAIL "retrieve mail from POP server"
index 7c6450f..8296e4a 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -10,6 +10,10 @@ This document is not the place for verbose documentation; it only offers
 the necessary keywords to look them up in the manual, ChangeLog or other
 sources of information.
 
+2005-10-14:
+
+  The generic <rebuild-cache> function has been added.
+
 2005-10-13:
 
   The $list_reply variable has been removed and replaced by
index 2d78492..a16667d 100644 (file)
@@ -1 +1 @@
-547
+548
index 05c8441..83e1808 100644 (file)
@@ -2341,6 +2341,10 @@ int mutt_index_menu (void)
       mutt_what_key ();
       break;
 
+    case OP_REBUILD_CACHE:
+      mx_rebuild_cache ();
+      break;
+
     case OP_SIDEBAR_SCROLL_UP:
     case OP_SIDEBAR_SCROLL_DOWN:
     case OP_SIDEBAR_NEXT:
index a0dec4d..ae914d7 100644 (file)
@@ -54,6 +54,7 @@ struct binding_t OpGeneric[] = {
   {"current-middle", OP_CURRENT_MIDDLE, NULL},
   {"current-bottom", OP_CURRENT_BOTTOM, NULL},
   {"what-key", OP_WHAT_KEY, NULL},
+  {"rebuild-cache", OP_REBUILD_CACHE, NULL},
   {NULL, 0, NULL}
 };
 
diff --git a/menu.c b/menu.c
index 39e5f0d..83578a5 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -996,6 +996,10 @@ int mutt_menuLoop (MUTTMENU * menu)
       mutt_what_key ();
       break;
 
+    case OP_REBUILD_CACHE:
+      mx_rebuild_cache ();
+      break;
+
     case OP_REDRAW:
       clearok (stdscr, TRUE);
       menu->redraw = REDRAW_FULL;
diff --git a/mx.c b/mx.c
index 27947b4..4bbbaf1 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -13,6 +13,7 @@
 #endif
 
 #include "mutt.h"
+#include "buffy.h"
 #include "ascii.h"
 #include "mx.h"
 #include "mbox.h"
 #include "nntp/mx_nntp.h"
 #endif
 
-#ifdef BUFFY_SIZE
-#include "buffy.h"
-#endif
-
 #ifdef USE_DOTLOCK
 #include "dotlock.h"
 #endif
@@ -1436,3 +1433,46 @@ void mx_init (void) {
 #undef EXITWITHERR
 #endif /* DEBUG */
 }
+
+int mx_rebuild_cache (void) {
+#ifndef USE_HCACHE
+  mutt_error (_("Support for header caching was not build in."));
+  return (1);
+#else
+  int i = 0, magic = 0, imap = 0;
+  CONTEXT* ctx = NULL;
+  char* buf = NULL;
+  BUFFY* b = NULL;
+
+  if (list_empty(Incoming)) {
+    mutt_error (_("No mailboxes defined."));
+    return (1);
+  }
+
+  ReadInc = 0;
+
+  for (i = 0; i < Incoming->length; i++) {
+    b = (BUFFY*) Incoming->data[i];
+    magic = mx_get_magic (b->path);
+    if (magic != M_MAILDIR && magic != M_MH && magic != M_IMAP)
+      continue;
+    if (magic == M_IMAP)
+      imap = 1;
+    buf = str_dup (b->path);
+    mutt_pretty_mailbox (buf);
+    mutt_message (_("Rebuilding cache for %s..."), buf);
+    if ((ctx = mx_open_mailbox (b->path,
+                                M_READONLY | M_QUIET | M_NOSORT | M_COUNT,
+                                NULL)) != NULL)
+      mx_close_mailbox (ctx, 0);
+    mem_free (&buf);
+  }
+
+  if (imap)
+    imap_logout_all ();
+
+  mutt_clear_error ();
+
+  return (0);
+#endif
+}
diff --git a/mx.h b/mx.h
index 4e09442..74f02f1 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -171,4 +171,6 @@ void mx_update_tables (CONTEXT *, int);
 int mx_lock_file (const char *, int, int, int, int);
 int mx_unlock_file (const char *path, int fd, int dot);
 
+int mx_rebuild_cache (void);
+
 #endif /* !_MX_H */