]> granicus.if.org Git - neomutt/commitdiff
move magic
authorRichard Russon <rich@flatcap.org>
Thu, 30 Aug 2018 16:19:13 +0000 (17:19 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 4 Sep 2018 00:25:00 +0000 (01:25 +0100)
25 files changed:
commands.c
compose.c
compress.c
context.h
copy.c
curs_main.c
editmsg.c
flags.c
imap/util.c
mailbox.c
maildir/mh.c
mbox/mbox.c
monitor.c
mutt_attach.c
mx.c
nntp/newsrc.c
nntp/nntp.c
notmuch/mutt_notmuch.c
pager.c
pattern.c
recvattach.c
send.c
sendlib.c
sort.c
status.c

index 5c4277c25c098657ad7a2e593e06b7e237f9637a..131b996357f70bb66b9745313eaba1177758ffca 100644 (file)
@@ -182,7 +182,7 @@ int mutt_display_message(struct Header *cur)
 
   chflags = (Weed ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM | CH_DISPLAY;
 #ifdef USE_NOTMUCH
-  if (Context->magic == MUTT_NOTMUCH)
+  if (Context->mailbox->magic == MUTT_NOTMUCH)
     chflags |= CH_VIRTUAL;
 #endif
   res = mutt_copy_message_ctx(fpout, Context, cur, cmflags, chflags);
@@ -968,7 +968,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt)
   mutt_message(_("Copying to %s..."), buf);
 
 #ifdef USE_IMAP
-  if ((Context->magic == MUTT_IMAP) && !(decode || decrypt) &&
+  if ((Context->mailbox->magic == MUTT_IMAP) && !(decode || decrypt) &&
       (imap_path_probe(buf, NULL) == MUTT_IMAP))
   {
     switch (imap_copy_messages(Context, h, buf, delete))
@@ -1025,7 +1025,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt)
       int rc = 0;
 
 #ifdef USE_NOTMUCH
-      if (Context->magic == MUTT_NOTMUCH)
+      if (Context->mailbox->magic == MUTT_NOTMUCH)
         nm_longrun_init(Context, true);
 #endif
       for (int i = 0; i < Context->mailbox->msg_count; i++)
@@ -1050,7 +1050,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt)
 #endif
       }
 #ifdef USE_NOTMUCH
-      if (Context->magic == MUTT_NOTMUCH)
+      if (Context->mailbox->magic == MUTT_NOTMUCH)
         nm_longrun_done(Context);
 #endif
       if (rc != 0)
@@ -1061,7 +1061,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt)
     }
 
     const bool need_mailbox_cleanup =
-        ((savectx->magic == MUTT_MBOX) || (savectx->magic == MUTT_MMDF));
+        ((savectx->mailbox->magic == MUTT_MBOX) || (savectx->mailbox->magic == MUTT_MMDF));
 
     mx_mbox_close(&savectx, NULL);
 
index bbe63b0a2267e9340e4b31c07839757c75021054..89afa58b0578c29748d858e0dcadb2dc41001727 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -1419,7 +1419,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen,
 
         if (Context)
 #ifdef USE_NNTP
-          if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == MUTT_NNTP))
+          if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->mailbox->magic == MUTT_NNTP))
 #endif
           {
             mutt_str_strfcpy(fname, Context->mailbox->path, sizeof(fname));
index e527f9894744181db2d26d666d741d4ca48fe85c..b1f139c262192395cf95c9aefaa45c98c1bcfade 100644 (file)
@@ -445,7 +445,7 @@ static int execute_command(struct Context *ctx, const char *command, const char
  */
 static int comp_mbox_open(struct Context *ctx)
 {
-  if (!ctx || (ctx->magic != MUTT_COMPRESSED))
+  if (!ctx || (ctx->mailbox->magic != MUTT_COMPRESSED))
     return -1;
 
   struct CompressInfo *ci = set_compress_info(ctx);
@@ -472,17 +472,17 @@ static int comp_mbox_open(struct Context *ctx)
 
   unlock_realpath(ctx);
 
-  ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
-  if (ctx->magic == MUTT_UNKNOWN)
+  ctx->mailbox->magic = mx_path_probe(ctx->mailbox->path, NULL);
+  if (ctx->mailbox->magic == MUTT_UNKNOWN)
   {
     mutt_error(_("Can't identify the contents of the compressed file"));
     goto or_fail;
   }
 
-  ci->child_ops = mx_get_ops(ctx->magic);
+  ci->child_ops = mx_get_ops(ctx->mailbox->magic);
   if (!ci->child_ops)
   {
-    mutt_error(_("Can't find mailbox ops for mailbox type %d"), ctx->magic);
+    mutt_error(_("Can't find mailbox ops for mailbox type %d"), ctx->mailbox->magic);
     goto or_fail;
   }
 
@@ -540,22 +540,22 @@ static int comp_mbox_open_append(struct Context *ctx, int flags)
       mutt_error(_("Compress command failed: %s"), ci->open);
       goto oa_fail2;
     }
-    ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
+    ctx->mailbox->magic = mx_path_probe(ctx->mailbox->path, NULL);
   }
   else
-    ctx->magic = MboxType;
+    ctx->mailbox->magic = MboxType;
 
   /* We can only deal with mbox and mmdf mailboxes */
-  if ((ctx->magic != MUTT_MBOX) && (ctx->magic != MUTT_MMDF))
+  if ((ctx->mailbox->magic != MUTT_MBOX) && (ctx->mailbox->magic != MUTT_MMDF))
   {
     mutt_error(_("Unsupported mailbox type for appending"));
     goto oa_fail2;
   }
 
-  ci->child_ops = mx_get_ops(ctx->magic);
+  ci->child_ops = mx_get_ops(ctx->mailbox->magic);
   if (!ci->child_ops)
   {
-    mutt_error(_("Can't find mailbox ops for mailbox type %d"), ctx->magic);
+    mutt_error(_("Can't find mailbox ops for mailbox type %d"), ctx->mailbox->magic);
     goto oa_fail2;
   }
 
index 10d8d788c9f83cbc52d5020b5d4471ba7693254b..8dda5f25574d96ff5cc5a733eb7105e20c11512a 100644 (file)
--- a/context.h
+++ b/context.h
@@ -77,8 +77,6 @@ struct Context
 
   struct Menu *menu; /**< needed for pattern compilation */
 
-  enum MailboxType magic; /**< mailbox type */
-
   unsigned char rights[(RIGHTSMAX + 7) / 8]; /**< ACL bits */
 
   bool locked : 1;    /**< is the mailbox locked? */
diff --git a/copy.c b/copy.c
index 8b5c1891b65b491f3505938b69bd5d40c5bf4e97..b52b404512f6b42bbfecdf5575c835782786810a 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -40,6 +40,7 @@
 #include "globals.h"
 #include "handler.h"
 #include "hdrline.h"
+#include "mailbox.h"
 #include "mutt_window.h"
 #include "muttlib.h"
 #include "mx.h"
@@ -827,15 +828,15 @@ static int append_message(struct Context *dest, FILE *fpin, struct Context *src,
   msg = mx_msg_open_new(dest, hdr, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
   if (!msg)
     return -1;
-  if (dest->magic == MUTT_MBOX || dest->magic == MUTT_MMDF)
+  if (dest->mailbox->magic == MUTT_MBOX || dest->mailbox->magic == MUTT_MMDF)
     chflags |= CH_FROM | CH_FORCE_FROM;
-  chflags |= (dest->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
+  chflags |= (dest->mailbox->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
   r = mutt_copy_message_fp(msg->fp, fpin, hdr, flags, chflags);
   if (mx_msg_commit(dest, msg) != 0)
     r = -1;
 
 #ifdef USE_NOTMUCH
-  if (msg->committed_path && dest->magic == MUTT_MAILDIR && src->magic == MUTT_NOTMUCH)
+  if (msg->committed_path && dest->mailbox->magic == MUTT_MAILDIR && src->mailbox->magic == MUTT_NOTMUCH)
     nm_update_filename(src, NULL, msg->committed_path, hdr);
 #endif
 
index 5cc9507cad03516a588f8d94d092fa7967bd50b7..720f6ad4fae6b83c91d92a60a4184b42123d32c7 100644 (file)
@@ -986,7 +986,7 @@ int mutt_index_menu(void)
   menu->help =
       mutt_compile_help(helpstr, sizeof(helpstr), MENU_MAIN,
 #ifdef USE_NNTP
-                        (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp :
+                        (Context && (Context->mailbox->magic == MUTT_NNTP)) ? IndexNewsHelp :
 #endif
                                                                      IndexHelp);
   menu->custom_menu_redraw = index_menu_redraw;
@@ -1307,7 +1307,7 @@ int mutt_index_menu(void)
         CHECK_IN_MAILBOX;
         CHECK_READONLY;
         CHECK_ATTACH;
-        if (Context->magic == MUTT_NNTP)
+        if (Context->mailbox->magic == MUTT_NNTP)
         {
           struct Header *hdr = NULL;
 
@@ -1375,7 +1375,7 @@ int mutt_index_menu(void)
         CHECK_VISIBLE;
         CHECK_READONLY;
         CHECK_ATTACH;
-        if (Context->magic == MUTT_NNTP)
+        if (Context->mailbox->magic == MUTT_NNTP)
         {
           int oldmsgcount = Context->mailbox->msg_count;
           int oldindex = CURHDR->index;
@@ -1792,12 +1792,12 @@ int mutt_index_menu(void)
 
 #ifdef USE_IMAP
       case OP_MAIN_IMAP_FETCH:
-        if (Context && Context->magic == MUTT_IMAP)
+        if (Context && Context->mailbox->magic == MUTT_IMAP)
           imap_check_mailbox(Context, true);
         break;
 
       case OP_MAIN_IMAP_LOGOUT_ALL:
-        if (Context && Context->magic == MUTT_IMAP)
+        if (Context && Context->mailbox->magic == MUTT_IMAP)
         {
           int check = mx_mbox_close(&Context, &index_hint);
           if (check != 0)
@@ -1906,7 +1906,7 @@ int mutt_index_menu(void)
 #ifdef USE_NOTMUCH
       case OP_MAIN_ENTIRE_THREAD:
       {
-        if (!Context || (Context->magic != MUTT_NOTMUCH))
+        if (!Context || (Context->mailbox->magic != MUTT_NOTMUCH))
         {
           mutt_message(_("No virtual folder, aborting"));
           break;
@@ -1980,7 +1980,7 @@ int mutt_index_menu(void)
           }
 
 #ifdef USE_NOTMUCH
-          if (Context->magic == MUTT_NOTMUCH)
+          if (Context->mailbox->magic == MUTT_NOTMUCH)
             nm_longrun_init(Context, true);
 #endif
           for (px = 0, j = 0; j < Context->mailbox->msg_count; j++)
@@ -1995,7 +1995,7 @@ int mutt_index_menu(void)
             {
               bool still_queried = false;
 #ifdef USE_NOTMUCH
-              if (Context->magic == MUTT_NOTMUCH)
+              if (Context->mailbox->magic == MUTT_NOTMUCH)
                 still_queried = nm_message_is_still_queried(Context, Context->hdrs[j]);
 #endif
               Context->hdrs[j]->quasi_deleted = !still_queried;
@@ -2003,7 +2003,7 @@ int mutt_index_menu(void)
             }
           }
 #ifdef USE_NOTMUCH
-          if (Context->magic == MUTT_NOTMUCH)
+          if (Context->mailbox->magic == MUTT_NOTMUCH)
             nm_longrun_done(Context);
 #endif
           menu->redraw = REDRAW_STATUS | REDRAW_INDEX;
@@ -2019,7 +2019,7 @@ int mutt_index_menu(void)
           {
             bool still_queried = false;
 #ifdef USE_NOTMUCH
-            if (Context->magic == MUTT_NOTMUCH)
+            if (Context->mailbox->magic == MUTT_NOTMUCH)
               still_queried = nm_message_is_still_queried(Context, CURHDR);
 #endif
             CURHDR->quasi_deleted = !still_queried;
@@ -2167,7 +2167,7 @@ int mutt_index_menu(void)
 #ifdef USE_NOTMUCH
         else if (op == OP_MAIN_CHANGE_VFOLDER)
         {
-          if (Context && (Context->magic == MUTT_NOTMUCH))
+          if (Context && (Context->mailbox->magic == MUTT_NOTMUCH))
           {
             mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
             mutt_mailbox_vfolder(buf, sizeof(buf));
@@ -2232,7 +2232,7 @@ int mutt_index_menu(void)
         /* mutt_mailbox_check() must be done with mail-reader mode! */
         menu->help = mutt_compile_help(
             helpstr, sizeof(helpstr), MENU_MAIN,
-            (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp : IndexHelp);
+            (Context && (Context->mailbox->magic == MUTT_NNTP)) ? IndexNewsHelp : IndexHelp);
 #endif
         mutt_expand_path(buf, sizeof(buf));
 #ifdef USE_SIDEBAR
@@ -2988,7 +2988,7 @@ int mutt_index_menu(void)
         CHECK_MSGCOUNT;
         CHECK_READONLY;
         CHECK_ATTACH
-        if (Context && Context->magic == MUTT_NNTP)
+        if (Context && Context->mailbox->magic == MUTT_NNTP)
         {
           struct NntpData *nntp_data = Context->data;
           if (mutt_newsgroup_catchup(nntp_data->nserv, nntp_data->group))
@@ -3160,7 +3160,7 @@ int mutt_index_menu(void)
         /* in an IMAP folder index with imap_peek=no, piping could change
          * new or old messages status to read. Redraw what's needed.
          */
-        if (Context->magic == MUTT_IMAP && !ImapPeek)
+        if (Context->mailbox->magic == MUTT_IMAP && !ImapPeek)
         {
           menu->redraw |= (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
         }
@@ -3178,7 +3178,7 @@ int mutt_index_menu(void)
         /* in an IMAP folder index with imap_peek=no, printing could change
          * new or old messages status to read. Redraw what's needed.
          */
-        if (Context->magic == MUTT_IMAP && !ImapPeek)
+        if (Context->mailbox->magic == MUTT_IMAP && !ImapPeek)
         {
           menu->redraw |= (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS;
         }
@@ -3300,7 +3300,7 @@ int mutt_index_menu(void)
             query_quadoption(FollowupToPoster,
                              _("Reply by mail as poster prefers?")) != MUTT_YES)
         {
-          if (Context && Context->magic == MUTT_NNTP &&
+          if (Context && Context->mailbox->magic == MUTT_NNTP &&
               !((struct NntpData *) Context->data)->allowed && query_quadoption(PostModerated, _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
           {
             break;
index 88c07774beeee8494e52c24d69ba9fd73e503c56..2dc269ce5b44c1c03377bbd3d9e0263b38b125ca 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -95,7 +95,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Heade
   }
 
   const int chflags =
-      CH_NOLEN | ((ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) ? 0 : CH_NOSTATUS);
+      CH_NOLEN | ((ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) ? 0 : CH_NOSTATUS);
   rc = mutt_append_message(tmpctx, ctx, cur, 0, chflags);
   oerrno = errno;
 
@@ -196,11 +196,11 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Heade
   }
 
   of = 0;
-  cf = (((tmpctx->magic == MUTT_MBOX) || (tmpctx->magic == MUTT_MMDF)) ? 0 : CH_NOSTATUS);
+  cf = (((tmpctx->mailbox->magic == MUTT_MBOX) || (tmpctx->mailbox->magic == MUTT_MMDF)) ? 0 : CH_NOSTATUS);
 
   if (fgets(buf, sizeof(buf), fp) && is_from(buf, NULL, 0, NULL))
   {
-    if ((tmpctx->magic == MUTT_MBOX) || (tmpctx->magic == MUTT_MMDF))
+    if ((tmpctx->mailbox->magic == MUTT_MBOX) || (tmpctx->mailbox->magic == MUTT_MMDF))
       cf = CH_FROM | CH_FORCE_FROM;
   }
   else
diff --git a/flags.c b/flags.c
index 4242cf5b23ae228f11126f905da81cb77b1552fc..49384be37a7609bffd66206d7623a5d24f10687a 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -85,7 +85,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Header *h, int flag, bool
 #ifdef USE_IMAP
           /* deleted messages aren't treated as changed elsewhere so that the
            * purge-on-sync option works correctly. This isn't applicable here */
-          if (ctx && ctx->magic == MUTT_IMAP)
+          if (ctx && ctx->mailbox->magic == MUTT_IMAP)
           {
             h->changed = true;
             if (upd_ctx)
@@ -102,7 +102,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Header *h, int flag, bool
           ctx->deleted--;
 #ifdef USE_IMAP
         /* see my comment above */
-        if (ctx->magic == MUTT_IMAP)
+        if (ctx->mailbox->magic == MUTT_IMAP)
         {
           h->changed = true;
           if (upd_ctx)
@@ -116,7 +116,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Header *h, int flag, bool
          * is checked in specific code in the maildir folder
          * driver.
          */
-        if (ctx->magic == MUTT_MAILDIR && upd_ctx && h->trash)
+        if (ctx->mailbox->magic == MUTT_MAILDIR && upd_ctx && h->trash)
           ctx->changed = true;
       }
       break;
index 1205a2e017305f3e49d2f1d89504b6917f4cbbb1..78d3deb5d6407cfea9dd04dbcb22a4a006ab7df7 100644 (file)
@@ -1108,7 +1108,7 @@ int imap_wait_keepalive(pid_t pid)
 void imap_allow_reopen(struct Context *ctx)
 {
   struct ImapData *idata = NULL;
-  if (!ctx || !ctx->data || ctx->magic != MUTT_IMAP)
+  if (!ctx || !ctx->data || ctx->mailbox->magic != MUTT_IMAP)
     return;
 
   idata = ctx->data;
@@ -1123,7 +1123,7 @@ void imap_allow_reopen(struct Context *ctx)
 void imap_disallow_reopen(struct Context *ctx)
 {
   struct ImapData *idata = NULL;
-  if (!ctx || !ctx->data || ctx->magic != MUTT_IMAP)
+  if (!ctx || !ctx->data || ctx->mailbox->magic != MUTT_IMAP)
     return;
 
   idata = ctx->data;
index 9cc45e1855033ebb155d11c236d42de3226b5471..951516d188b0756202b81a47a5e2ab9b722e015b 100644 (file)
--- a/mailbox.c
+++ b/mailbox.c
@@ -856,9 +856,9 @@ int mutt_mailbox_check(int force)
 #endif
 
   /* check device ID and serial number instead of comparing paths */
-  if (!Context || Context->magic == MUTT_IMAP || Context->magic == MUTT_POP
+  if (!Context || Context->mailbox->magic == MUTT_IMAP || Context->mailbox->magic == MUTT_POP
 #ifdef USE_NNTP
-      || Context->magic == MUTT_NNTP
+      || Context->mailbox->magic == MUTT_NNTP
 #endif
       || stat(Context->mailbox->path, &contex_sb) != 0)
   {
index d8d8b7eb9ccd50528fa6f9e709c0333bd8aca29e..d5ab2e549feec2835794296dbd9142023935ee3b 100644 (file)
@@ -852,7 +852,7 @@ static void maildir_update_mtime(struct Context *ctx)
   struct stat st;
   struct MhData *data = mh_data(ctx);
 
-  if (ctx->magic == MUTT_MAILDIR)
+  if (ctx->mailbox->magic == MUTT_MAILDIR)
   {
     snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "cur");
     if (stat(buf, &st) == 0)
@@ -973,8 +973,8 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last,
 
   while (((de = readdir(dirp))) && (SigInt != 1))
   {
-    if ((ctx->magic == MUTT_MH && !mh_valid_message(de->d_name)) ||
-        (ctx->magic == MUTT_MAILDIR && *de->d_name == '.'))
+    if ((ctx->mailbox->magic == MUTT_MH && !mh_valid_message(de->d_name)) ||
+        (ctx->mailbox->magic == MUTT_MAILDIR && *de->d_name == '.'))
     {
       continue;
     }
@@ -984,7 +984,7 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last,
 
     h = mutt_header_new();
     h->old = is_old;
-    if (ctx->magic == MUTT_MAILDIR)
+    if (ctx->mailbox->magic == MUTT_MAILDIR)
       maildir_parse_flags(h, de->d_name);
 
     if (count)
@@ -1262,7 +1262,7 @@ static struct Maildir *maildir_sort(struct Maildir *list, size_t len,
  */
 static void mh_sort_natural(struct Context *ctx, struct Maildir **md)
 {
-  if (!ctx || !md || !*md || ctx->magic != MUTT_MH || Sort != SORT_ORDER)
+  if (!ctx || !md || !*md || ctx->mailbox->magic != MUTT_MH || Sort != SORT_ORDER)
     return;
   mutt_debug(4, "maildir: sorting %s into natural order\n", ctx->mailbox->path);
   *md = maildir_sort(*md, (size_t) -1, md_cmp_path);
@@ -1354,7 +1354,7 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md,
       ret = 0;
     }
 
-    if (ctx->magic == MUTT_MH)
+    if (ctx->mailbox->magic == MUTT_MH)
     {
       key = p->h->path;
       keylen = strlen(key);
@@ -1374,18 +1374,18 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md,
       h->path = mutt_str_strdup(p->h->path);
       mutt_header_free(&p->h);
       p->h = h;
-      if (ctx->magic == MUTT_MAILDIR)
+      if (ctx->mailbox->magic == MUTT_MAILDIR)
         maildir_parse_flags(p->h, fn);
     }
     else
     {
 #endif
 
-      if (maildir_parse_message(ctx->magic, fn, p->h->old, p->h))
+      if (maildir_parse_message(ctx->mailbox->magic, fn, p->h->old, p->h))
       {
         p->header_parsed = 1;
 #ifdef USE_HCACHE
-        if (ctx->magic == MUTT_MH)
+        if (ctx->mailbox->magic == MUTT_MH)
         {
           key = p->h->path;
           keylen = strlen(key);
@@ -1469,7 +1469,7 @@ static int mh_read_dir(struct Context *ctx, const char *subdir)
   }
   maildir_delayed_parsing(ctx, &md, &progress);
 
-  if (ctx->magic == MUTT_MH)
+  if (ctx->mailbox->magic == MUTT_MH)
   {
     if (mh_read_sequences(&mhs, ctx->mailbox->path) < 0)
     {
@@ -1869,7 +1869,7 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He
       }
 
 #ifdef USE_NOTMUCH
-      if (ctx->magic == MUTT_NOTMUCH)
+      if (ctx->mailbox->magic == MUTT_NOTMUCH)
         nm_update_filename(ctx, hdr->path, full, hdr);
 #endif
       if (hdr)
@@ -2022,7 +2022,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno)
     snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->mailbox->path, h->path);
     mutt_str_strfcpy(partpath, h->path, sizeof(partpath));
 
-    if (ctx->magic == MUTT_MAILDIR)
+    if (ctx->mailbox->magic == MUTT_MAILDIR)
       rc = md_commit_message(ctx, dest, h);
     else
       rc = mh_commit_msg(ctx, dest, h, false);
@@ -2049,7 +2049,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno)
      * lose flag modifications.
      */
 
-    if (ctx->magic == MUTT_MH && rc == 0)
+    if (ctx->mailbox->magic == MUTT_MH && rc == 0)
     {
       char newpath[PATH_MAX];
       snprintf(newpath, sizeof(newpath), "%s/%s", ctx->mailbox->path, h->path);
@@ -2177,18 +2177,18 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno)
 {
   struct Header *h = ctx->hdrs[msgno];
 
-  if (h->deleted && (ctx->magic != MUTT_MAILDIR || !MaildirTrash))
+  if (h->deleted && (ctx->mailbox->magic != MUTT_MAILDIR || !MaildirTrash))
   {
     char path[PATH_MAX];
     snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, h->path);
-    if (ctx->magic == MUTT_MAILDIR || (MhPurge && ctx->magic == MUTT_MH))
+    if (ctx->mailbox->magic == MUTT_MAILDIR || (MhPurge && ctx->mailbox->magic == MUTT_MH))
     {
 #ifdef USE_HCACHE
       if (hc)
       {
         const char *key = NULL;
         size_t keylen;
-        if (ctx->magic == MUTT_MH)
+        if (ctx->mailbox->magic == MUTT_MH)
         {
           key = h->path;
           keylen = strlen(key);
@@ -2203,7 +2203,7 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno)
 #endif
       unlink(path);
     }
-    else if (ctx->magic == MUTT_MH)
+    else if (ctx->mailbox->magic == MUTT_MH)
     {
       /* MH just moves files out of the way when you delete them */
       if (*h->path != ',')
@@ -2216,10 +2216,10 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno)
     }
   }
   else if (h->changed || h->attach_del || h->xlabel_changed ||
-           (ctx->magic == MUTT_MAILDIR && (MaildirTrash || h->trash) &&
+           (ctx->mailbox->magic == MUTT_MAILDIR && (MaildirTrash || h->trash) &&
             (h->deleted != h->trash)))
   {
-    if (ctx->magic == MUTT_MAILDIR)
+    if (ctx->mailbox->magic == MUTT_MAILDIR)
     {
       if (maildir_sync_message(ctx, msgno) == -1)
         return -1;
@@ -2236,7 +2236,7 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno)
   {
     const char *key = NULL;
     size_t keylen;
-    if (ctx->magic == MUTT_MH)
+    if (ctx->mailbox->magic == MUTT_MH)
     {
       key = h->path;
       keylen = strlen(key);
@@ -2619,7 +2619,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint)
   char msgbuf[PATH_MAX + 64];
   struct Progress progress;
 
-  if (ctx->magic == MUTT_MH)
+  if (ctx->mailbox->magic == MUTT_MH)
     i = mh_mbox_check(ctx, index_hint);
   else
     i = maildir_mbox_check(ctx, index_hint);
@@ -2628,7 +2628,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint)
     return i;
 
 #ifdef USE_HCACHE
-  if (ctx->magic == MUTT_MAILDIR || ctx->magic == MUTT_MH)
+  if (ctx->mailbox->magic == MUTT_MAILDIR || ctx->mailbox->magic == MUTT_MH)
     hc = mutt_hcache_open(HeaderCache, ctx->mailbox->path, NULL);
 #endif
 
@@ -2653,11 +2653,11 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint)
   }
 
 #ifdef USE_HCACHE
-  if (ctx->magic == MUTT_MAILDIR || ctx->magic == MUTT_MH)
+  if (ctx->mailbox->magic == MUTT_MAILDIR || ctx->mailbox->magic == MUTT_MH)
     mutt_hcache_close(hc);
 #endif
 
-  if (ctx->magic == MUTT_MH)
+  if (ctx->mailbox->magic == MUTT_MH)
     mh_update_sequences(ctx);
 
   /* XXX race condition? */
@@ -2670,7 +2670,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint)
   {
     for (i = 0, j = 0; i < ctx->mailbox->msg_count; i++)
     {
-      if (!ctx->hdrs[i]->deleted || (ctx->magic == MUTT_MAILDIR && MaildirTrash))
+      if (!ctx->hdrs[i]->deleted || (ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash))
         ctx->hdrs[i]->index = j++;
     }
   }
@@ -2679,7 +2679,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint)
 
 err:
 #ifdef USE_HCACHE
-  if (ctx->magic == MUTT_MAILDIR || ctx->magic == MUTT_MH)
+  if (ctx->mailbox->magic == MUTT_MAILDIR || ctx->mailbox->magic == MUTT_MH)
     mutt_hcache_close(hc);
 #endif
   return -1;
index 97bb06d6731f1b3bc8f104704f4c7e5ccb08be5c..5b9f09e46d86f64ddb3c73ebde64408010cf9546 100644 (file)
@@ -480,9 +480,9 @@ static int mbox_mbox_open(struct Context *ctx)
     return -1;
   }
 
-  if (ctx->magic == MUTT_MBOX)
+  if (ctx->mailbox->magic == MUTT_MBOX)
     rc = mbox_parse_mailbox(ctx);
-  else if (ctx->magic == MUTT_MMDF)
+  else if (ctx->mailbox->magic == MUTT_MMDF)
     rc = mmdf_parse_mailbox(ctx);
   else
     rc = -1;
@@ -697,7 +697,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
   ctx->subj_hash = NULL;
   mutt_make_label_hash(ctx);
 
-  switch (ctx->magic)
+  switch (ctx->mailbox->magic)
   {
     case MUTT_MBOX:
     case MUTT_MMDF:
@@ -707,7 +707,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
       if (!ctx->fp)
         rc = -1;
       else
-        rc = ((ctx->magic == MUTT_MBOX) ? mbox_parse_mailbox : mmdf_parse_mailbox)(ctx);
+        rc = ((ctx->mailbox->magic == MUTT_MBOX) ? mbox_parse_mailbox : mmdf_parse_mailbox)(ctx);
       break;
 
     default:
@@ -869,12 +869,12 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
         mutt_debug(1, "#1 fseek() failed\n");
       if (fgets(buffer, sizeof(buffer), ctx->fp))
       {
-        if ((ctx->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buffer, 5) == 0)) ||
-            (ctx->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buffer) == 0)))
+        if ((ctx->mailbox->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buffer, 5) == 0)) ||
+            (ctx->mailbox->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buffer) == 0)))
         {
           if (fseeko(ctx->fp, ctx->size, SEEK_SET) != 0)
             mutt_debug(1, "#2 fseek() failed\n");
-          if (ctx->magic == MUTT_MBOX)
+          if (ctx->mailbox->magic == MUTT_MBOX)
             mbox_parse_mailbox(ctx);
           else
             mmdf_parse_mailbox(ctx);
@@ -1082,7 +1082,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
   /* the offset stored in the header does not include the MMDF_SEP, so make
    * sure we seek to the correct location
    */
-  if (ctx->magic == MUTT_MMDF)
+  if (ctx->mailbox->magic == MUTT_MMDF)
     offset -= (sizeof(MMDF_SEP) - 1);
 
   /* allocate space for the new offsets */
@@ -1113,7 +1113,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
     {
       j++;
 
-      if (ctx->magic == MUTT_MMDF)
+      if (ctx->mailbox->magic == MUTT_MMDF)
       {
         if (fputs(MMDF_SEP, fp) == EOF)
         {
@@ -1146,7 +1146,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
       new_offset[i - first].body = ftello(fp) - ctx->hdrs[i]->content->length + offset;
       mutt_body_free(&ctx->hdrs[i]->content->parts);
 
-      switch (ctx->magic)
+      switch (ctx->mailbox->magic)
       {
         case MUTT_MMDF:
           if (fputs(MMDF_SEP, fp) == EOF)
@@ -1200,8 +1200,8 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
   if (fseeko(ctx->fp, offset, SEEK_SET) != 0 || /* seek the append location */
       /* do a sanity check to make sure the mailbox looks ok */
       !fgets(buf, sizeof(buf), ctx->fp) ||
-      (ctx->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buf, 5) != 0)) ||
-      (ctx->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buf) != 0)))
+      (ctx->mailbox->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buf, 5) != 0)) ||
+      (ctx->mailbox->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buf) != 0)))
   {
     mutt_debug(1, "message not in expected position.\n");
     mutt_debug(1, "\tLINE: %s\n", buf);
index 8d128926885cb6b8141f2859c8776095d512f663..7c8ca865eab1ee33d8747fa38f1e12af4f1c93ee 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -294,7 +294,7 @@ static int monitor_resolve(struct MonitorInfo *info, struct Mailbox *mailbox)
   }
   else if (Context)
   {
-    info->magic = Context->magic;
+    info->magic = Context->mailbox->magic;
     info->path = Context->mailbox->realpath;
   }
   else
index 38360fca172d7e7f278c9a7cd0591ceb861ad912..e270b5d01b8ec183a89a11127f9a3dc93ade4ec8 100644 (file)
@@ -41,6 +41,7 @@
 #include "filter.h"
 #include "globals.h"
 #include "handler.h"
+#include "mailbox.h"
 #include "muttlib.h"
 #include "mx.h"
 #include "ncrypt/ncrypt.h"
@@ -812,9 +813,9 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct
         mx_mbox_close(&ctx, NULL);
         return -1;
       }
-      if ((ctx->magic == MUTT_MBOX) || (ctx->magic == MUTT_MMDF))
+      if ((ctx->mailbox->magic == MUTT_MBOX) || (ctx->mailbox->magic == MUTT_MMDF))
         chflags = CH_FROM | CH_UPDATE_LEN;
-      chflags |= (ctx->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
+      chflags |= (ctx->mailbox->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
       if ((mutt_copy_message_fp(msg->fp, fp, hn, 0, chflags) == 0) &&
           (mx_msg_commit(ctx, msg) == 0))
       {
diff --git a/mx.c b/mx.c
index 09335e2d349e1e965721befe2e31798d1313716f..f60819e5c427e1005d93382f64c88d70410e5623 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -179,12 +179,12 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags)
   struct stat sb;
 
   ctx->append = true;
-  ctx->magic = mx_path_probe(ctx->mailbox->path, NULL);
-  if (ctx->magic == MUTT_UNKNOWN)
+  ctx->mailbox->magic = mx_path_probe(ctx->mailbox->path, NULL);
+  if (ctx->mailbox->magic == MUTT_UNKNOWN)
   {
     if (flags & (MUTT_APPEND | MUTT_NEWFOLDER))
     {
-      ctx->magic = MUTT_MAILBOX_ERROR;
+      ctx->mailbox->magic = MUTT_MAILBOX_ERROR;
     }
     else
     {
@@ -193,7 +193,7 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags)
     }
   }
 
-  if (ctx->magic == MUTT_MAILBOX_ERROR)
+  if (ctx->mailbox->magic == MUTT_MAILBOX_ERROR)
   {
     if (stat(ctx->mailbox->path, &sb) == -1)
     {
@@ -201,10 +201,10 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags)
       {
 #ifdef USE_COMPRESSED
         if (mutt_comp_can_append(ctx))
-          ctx->magic = MUTT_COMPRESSED;
+          ctx->mailbox->magic = MUTT_COMPRESSED;
         else
 #endif
-          ctx->magic = MboxType;
+          ctx->mailbox->magic = MboxType;
         flags |= MUTT_APPENDNEW;
       }
       else
@@ -217,7 +217,7 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags)
       return -1;
   }
 
-  ctx->mx_ops = mx_get_ops(ctx->magic);
+  ctx->mx_ops = mx_get_ops(ctx->mailbox->magic);
   if (!ctx->mx_ops || !ctx->mx_ops->mbox_open_append)
     return -1;
 
@@ -283,14 +283,14 @@ struct Context *mx_mbox_open(const char *path, int flags)
     return ctx;
   }
 
-  ctx->magic = mx_path_probe(path, NULL);
-  ctx->mx_ops = mx_get_ops(ctx->magic);
+  ctx->mailbox->magic = mx_path_probe(path, NULL);
+  ctx->mx_ops = mx_get_ops(ctx->mailbox->magic);
 
-  if ((ctx->magic == MUTT_UNKNOWN) || (ctx->magic == MUTT_MAILBOX_ERROR) || !ctx->mx_ops)
+  if ((ctx->mailbox->magic == MUTT_UNKNOWN) || (ctx->mailbox->magic == MUTT_MAILBOX_ERROR) || !ctx->mx_ops)
   {
-    if (ctx->magic == MUTT_MAILBOX_ERROR)
+    if (ctx->mailbox->magic == MUTT_MAILBOX_ERROR)
       mutt_perror(path);
-    else if (ctx->magic == MUTT_UNKNOWN || !ctx->mx_ops)
+    else if (ctx->mailbox->magic == MUTT_UNKNOWN || !ctx->mx_ops)
       mutt_error(_("%s is not a mailbox"), path);
 
     mx_fastclose_mailbox(ctx);
@@ -431,7 +431,7 @@ static int trash_append(struct Context *ctx)
   struct stat st, stc;
   int opt_confappend, rc;
 
-  if (!Trash || !ctx->deleted || (ctx->magic == MUTT_MAILDIR && MaildirTrash))
+  if (!Trash || !ctx->deleted || (ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash))
     return 0;
 
   int delmsgcount = 0;
@@ -472,7 +472,7 @@ static int trash_append(struct Context *ctx)
   }
 
 #ifdef USE_IMAP
-  if (Context->magic == MUTT_IMAP && (imap_path_probe(Trash, NULL) == MUTT_IMAP))
+  if (Context->mailbox->magic == MUTT_IMAP && (imap_path_probe(Trash, NULL) == MUTT_IMAP))
   {
     if (imap_fast_trash(Context, Trash) == 0)
       return 0;
@@ -535,7 +535,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
   }
 
 #ifdef USE_NNTP
-  if (ctx->mailbox->msg_unread && ctx->magic == MUTT_NNTP)
+  if (ctx->mailbox->msg_unread && ctx->mailbox->magic == MUTT_NNTP)
   {
     struct NntpData *nntp_data = ctx->data;
 
@@ -563,7 +563,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
 
 #ifdef USE_NNTP
   /* don't need to move articles from newsgroup */
-  if (ctx->magic == MUTT_NNTP)
+  if (ctx->mailbox->magic == MUTT_NNTP)
     read_msgs = 0;
 #endif
 
@@ -602,7 +602,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
   /* There is no point in asking whether or not to purge if we are
    * just marking messages as "trash".
    */
-  if (ctx->deleted && !(ctx->magic == MUTT_MAILDIR && MaildirTrash))
+  if (ctx->deleted && !(ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash))
   {
     snprintf(buf, sizeof(buf),
              ngettext("Purge %d deleted message?", "Purge %d deleted messages?", ctx->deleted),
@@ -633,7 +633,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
     /* try to use server-side copy first */
     i = 1;
 
-    if ((ctx->magic == MUTT_IMAP) && (imap_path_probe(mbox, NULL) == MUTT_IMAP))
+    if ((ctx->mailbox->magic == MUTT_IMAP) && (imap_path_probe(mbox, NULL) == MUTT_IMAP))
     {
       /* tag messages for moving, and clear old tags, if any */
       for (i = 0; i < ctx->mailbox->msg_count; i++)
@@ -695,7 +695,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
   {
     if (!ctx->quiet)
       mutt_message(_("Mailbox is unchanged"));
-    if (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF)
+    if (ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF)
       mbox_reset_atime(ctx, NULL);
     mx_fastclose_mailbox(ctx);
     FREE(pctx);
@@ -714,7 +714,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
 
 #ifdef USE_IMAP
   /* allow IMAP to preserve the deleted flag across sessions */
-  if (ctx->magic == MUTT_IMAP)
+  if (ctx->mailbox->magic == MUTT_IMAP)
   {
     int check = imap_sync_mailbox(ctx, (purge != MUTT_NO));
     if (check != 0)
@@ -758,7 +758,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
       mutt_message(_("%d kept, %d deleted"), ctx->mailbox->msg_count - ctx->deleted, ctx->deleted);
   }
 
-  if (ctx->mailbox->msg_count == ctx->deleted && (ctx->magic == MUTT_MMDF || ctx->magic == MUTT_MBOX) &&
+  if (ctx->mailbox->msg_count == ctx->deleted && (ctx->mailbox->magic == MUTT_MMDF || ctx->mailbox->magic == MUTT_MBOX) &&
       !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty)
   {
     mutt_file_unlink_empty(ctx->mailbox->path);
@@ -810,7 +810,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
   for (i = 0, j = 0; i < ctx->mailbox->msg_count; i++)
   {
     if (!ctx->hdrs[i]->quasi_deleted &&
-        ((committing && (!ctx->hdrs[i]->deleted || (ctx->magic == MUTT_MAILDIR && MaildirTrash))) ||
+        ((committing && (!ctx->hdrs[i]->deleted || (ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash))) ||
          (!committing && ctx->hdrs[i]->active)))
     {
       if (i != j)
@@ -832,7 +832,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
       else if (ctx->hdrs[j]->changed)
         ctx->changed = true;
 
-      if (!committing || (ctx->magic == MUTT_MAILDIR && MaildirTrash))
+      if (!committing || (ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash))
       {
         if (ctx->hdrs[j]->deleted)
           ctx->deleted++;
@@ -853,7 +853,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
     }
     else
     {
-      if (ctx->magic == MUTT_MH || ctx->magic == MUTT_MAILDIR)
+      if (ctx->mailbox->magic == MUTT_MH || ctx->mailbox->magic == MUTT_MAILDIR)
       {
         ctx->size -= (ctx->hdrs[i]->content->length + ctx->hdrs[i]->content->offset -
                       ctx->hdrs[i]->content->hdr_offset);
@@ -929,7 +929,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint)
       if (!ctx->changed)
         return 0; /* nothing to do! */
       /* let IMAP servers hold on to D flags */
-      if (ctx->magic != MUTT_IMAP)
+      if (ctx->mailbox->magic != MUTT_IMAP)
       {
         for (int i = 0; i < ctx->mailbox->msg_count; i++)
         {
@@ -955,7 +955,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint)
   }
 
 #ifdef USE_IMAP
-  if (ctx->magic == MUTT_IMAP)
+  if (ctx->mailbox->magic == MUTT_IMAP)
     rc = imap_sync_mailbox(ctx, purge);
   else
 #endif
@@ -963,7 +963,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint)
   if (rc == 0)
   {
 #ifdef USE_IMAP
-    if (ctx->magic == MUTT_IMAP && !purge)
+    if (ctx->mailbox->magic == MUTT_IMAP && !purge)
     {
       if (!ctx->quiet)
         mutt_message(_("Mailbox checkpointed"));
@@ -977,7 +977,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint)
 
     mutt_sleep(0);
 
-    if (ctx->mailbox->msg_count == ctx->deleted && (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) &&
+    if (ctx->mailbox->msg_count == ctx->deleted && (ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) &&
         !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty)
     {
       unlink(ctx->mailbox->path);
@@ -992,10 +992,10 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint)
      * MH and maildir are safe.  mbox-style seems to need re-sorting,
      * at least with the new threading code.
      */
-    if (purge || (ctx->magic != MUTT_MAILDIR && ctx->magic != MUTT_MH))
+    if (purge || (ctx->mailbox->magic != MUTT_MAILDIR && ctx->mailbox->magic != MUTT_MH))
     {
       /* IMAP does this automatically after handling EXPUNGE */
-      if (ctx->magic != MUTT_IMAP)
+      if (ctx->mailbox->magic != MUTT_IMAP)
       {
         mx_update_tables(ctx, true);
         mutt_sort_headers(ctx, true); /* rethread from scratch */
@@ -1020,7 +1020,7 @@ struct Message *mx_msg_open_new(struct Context *ctx, struct Header *hdr, int fla
 
   if (!ctx->mx_ops || !ctx->mx_ops->msg_open_new)
   {
-    mutt_debug(1, "function unimplemented for mailbox type %d.\n", ctx->magic);
+    mutt_debug(1, "function unimplemented for mailbox type %d.\n", ctx->mailbox->magic);
     return NULL;
   }
 
@@ -1041,10 +1041,10 @@ struct Message *mx_msg_open_new(struct Context *ctx, struct Header *hdr, int fla
 
   if (ctx->mx_ops->msg_open_new(ctx, msg, hdr) == 0)
   {
-    if (ctx->magic == MUTT_MMDF)
+    if (ctx->mailbox->magic == MUTT_MMDF)
       fputs(MMDF_SEP, msg->fp);
 
-    if ((ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) && flags & MUTT_ADD_FROM)
+    if ((ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) && flags & MUTT_ADD_FROM)
     {
       if (hdr)
       {
@@ -1098,7 +1098,7 @@ struct Message *mx_msg_open(struct Context *ctx, int msgno)
 
   if (!ctx->mx_ops || !ctx->mx_ops->msg_open)
   {
-    mutt_debug(1, "function not implemented for mailbox type %d.\n", ctx->magic);
+    mutt_debug(1, "function not implemented for mailbox type %d.\n", ctx->mailbox->magic);
     return NULL;
   }
 
index 1937cfc3bc89828c7b508e675cb7cef8b62579ad..bc9bdb6ce8117f7a2e6878db8293720d378d5a17 100644 (file)
@@ -1386,7 +1386,7 @@ void nntp_mailbox(char *buf, size_t buflen)
     if (!nntp_data || !nntp_data->subscribed || !nntp_data->unread)
       continue;
 
-    if (Context && Context->magic == MUTT_NNTP &&
+    if (Context && Context->mailbox->magic == MUTT_NNTP &&
         (mutt_str_strcmp(nntp_data->group, ((struct NntpData *) Context->data)->group) == 0))
     {
       unsigned int unread = 0;
index d108c2bb4fc73183b7d9de8c43575d330407ecd9..8fca93987b57f5c824660dbda441c02d13da2293 100644 (file)
@@ -1784,7 +1784,7 @@ int nntp_post(const char *msg)
   struct NntpData *nntp_data, nntp_tmp;
   char buf[LONG_STRING];
 
-  if (Context && Context->magic == MUTT_NNTP)
+  if (Context && Context->mailbox->magic == MUTT_NNTP)
     nntp_data = Context->data;
   else
   {
@@ -2368,7 +2368,7 @@ int nntp_check_new_groups(struct NntpServer *nserv)
       }
     }
     /* select current newsgroup */
-    if (Context && Context->magic == MUTT_NNTP)
+    if (Context && Context->mailbox->magic == MUTT_NNTP)
     {
       buf[0] = '\0';
       if (nntp_query((struct NntpData *) Context->data, buf, sizeof(buf)) < 0)
@@ -2383,7 +2383,7 @@ int nntp_check_new_groups(struct NntpServer *nserv)
   if (nntp_date(nserv, &now) < 0)
     return -1;
   nntp_data.nserv = nserv;
-  if (Context && Context->magic == MUTT_NNTP)
+  if (Context && Context->mailbox->magic == MUTT_NNTP)
     nntp_data.group = ((struct NntpData *) Context->data)->group;
   else
     nntp_data.group = NULL;
index 7c01cbdebe9612f4de49d269f031f599142929a8..61b232cc079790a0aef112d492e4b36fe99cc8d7 100644 (file)
@@ -237,7 +237,7 @@ static struct NmCtxData *new_ctxdata(const char *uri)
  */
 static int init_context(struct Context *ctx)
 {
-  if (!ctx || (ctx->magic != MUTT_NOTMUCH))
+  if (!ctx || (ctx->mailbox->magic != MUTT_NOTMUCH))
     return -1;
 
   if (ctx->data)
@@ -282,7 +282,7 @@ static char *header_get_fullpath(struct Header *h, char *buf, size_t buflen)
  */
 static struct NmCtxData *get_ctxdata(struct Context *ctx)
 {
-  if (ctx && (ctx->magic == MUTT_NOTMUCH))
+  if (ctx && (ctx->mailbox->magic == MUTT_NOTMUCH))
     return ctx->data;
 
   return NULL;
@@ -1973,7 +1973,7 @@ bool nm_normalize_uri(const char *uri, char *buf, size_t buflen)
   if (!tmp_ctxdata)
     return false;
 
-  tmp_ctx.magic = MUTT_NOTMUCH;
+  tmp_ctx.mailbox->magic = MUTT_NOTMUCH;
   tmp_ctx.data = tmp_ctxdata;
 
   mutt_debug(2, "#1 () -> db_query: %s\n", tmp_ctxdata->db_query);
@@ -2492,7 +2492,7 @@ static int nm_mbox_open(struct Context *ctx)
  */
 static int nm_mbox_close(struct Context *ctx)
 {
-  if (!ctx || (ctx->magic != MUTT_NOTMUCH))
+  if (!ctx || (ctx->mailbox->magic != MUTT_NOTMUCH))
     return -1;
 
   for (int i = 0; i < ctx->mailbox->msg_count; i++)
@@ -2684,14 +2684,14 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint)
       header_get_fullpath(h, old, sizeof(old));
 
     mutt_str_strfcpy(ctx->mailbox->path, hd->folder, sizeof(ctx->mailbox->path));
-    ctx->magic = hd->magic;
+    ctx->mailbox->magic = hd->magic;
 #ifdef USE_HCACHE
     rc = mh_sync_mailbox_message(ctx, i, NULL);
 #else
     rc = mh_sync_mailbox_message(ctx, i);
 #endif
     mutt_str_strfcpy(ctx->mailbox->path, uri, sizeof(ctx->mailbox->path));
-    ctx->magic = MUTT_NOTMUCH;
+    ctx->mailbox->magic = MUTT_NOTMUCH;
 
     if (rc)
       break;
@@ -2711,7 +2711,7 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint)
   }
 
   mutt_str_strfcpy(ctx->mailbox->path, uri, sizeof(ctx->mailbox->path));
-  ctx->magic = MUTT_NOTMUCH;
+  ctx->mailbox->magic = MUTT_NOTMUCH;
 
   if (!is_longrun(data))
     release_db(data);
@@ -2740,7 +2740,7 @@ static int nm_msg_open(struct Context *ctx, struct Message *msg, int msgno)
 
   msg->fp = fopen(path, "r");
   if (!msg->fp && (errno == ENOENT) &&
-      ((ctx->magic == MUTT_MAILDIR) || (ctx->magic == MUTT_NOTMUCH)))
+      ((ctx->mailbox->magic == MUTT_MAILDIR) || (ctx->mailbox->magic == MUTT_NOTMUCH)))
   {
     msg->fp = maildir_open_find_message(folder, cur->path, NULL);
   }
diff --git a/pager.c b/pager.c
index 129894edd7a88ed577b685ab67c1e1f37cafa6c8..13d3c67cb1cf7a5d177ccf1c70eb07ebd0998451 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -2272,7 +2272,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
     mutt_str_strfcpy(tmphelp, helpstr, sizeof(tmphelp));
     mutt_compile_help(buffer, sizeof(buffer), MENU_PAGER,
 #ifdef USE_NNTP
-                      (Context && (Context->magic == MUTT_NNTP)) ? PagerNewsHelpExtra :
+                      (Context && (Context->mailbox->magic == MUTT_NNTP)) ? PagerNewsHelpExtra :
 #endif
                                                                    PagerHelpExtra);
     snprintf(helpstr, sizeof(helpstr), "%s %s", tmphelp, buffer);
@@ -3083,7 +3083,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
       case OP_POST:
         CHECK_MODE(IsHeader(extra) && !IsAttach(extra));
         CHECK_ATTACH;
-        if (extra->ctx && extra->ctx->magic == MUTT_NNTP &&
+        if (extra->ctx && extra->ctx->mailbox->magic == MUTT_NNTP &&
             !((struct NntpData *) extra->ctx->data)->allowed && query_quadoption(PostModerated, _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
         {
           break;
@@ -3095,7 +3095,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
       case OP_FORWARD_TO_GROUP:
         CHECK_MODE(IsHeader(extra) || IsMsgAttach(extra));
         CHECK_ATTACH;
-        if (extra->ctx && extra->ctx->magic == MUTT_NNTP &&
+        if (extra->ctx && extra->ctx->mailbox->magic == MUTT_NNTP &&
             !((struct NntpData *) extra->ctx->data)->allowed && query_quadoption(PostModerated, _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
         {
           break;
@@ -3121,7 +3121,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e
             query_quadoption(FollowupToPoster,
                              _("Reply by mail as poster prefers?")) != MUTT_YES)
         {
-          if (extra->ctx && extra->ctx->magic == MUTT_NNTP &&
+          if (extra->ctx && extra->ctx->mailbox->magic == MUTT_NNTP &&
               !((struct NntpData *) extra->ctx->data)->allowed && query_quadoption(PostModerated, _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES)
           {
             break;
index cd2e94a16d2caaf1f7c8c4a32d2f22980c03e521..7a57bce8d25d4e11ff47a0636b5072662f51b629 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1869,7 +1869,7 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags,
         return 0;
 #ifdef USE_IMAP
       /* IMAP search sets h->matched at search compile time */
-      if (ctx->magic == MUTT_IMAP && pat->stringmatch)
+      if (ctx->mailbox->magic == MUTT_IMAP && pat->stringmatch)
         return h->matched;
 #endif
       return pat->not ^ msg_search(ctx, pat, h->msgno);
@@ -1877,7 +1877,7 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags,
 #ifdef USE_IMAP
       if (!ctx)
         return 0;
-      if (ctx->magic == MUTT_IMAP)
+      if (ctx->mailbox->magic == MUTT_IMAP)
       {
         if (pat->stringmatch)
           return h->matched;
@@ -2242,7 +2242,7 @@ int mutt_pattern_func(int op, char *prompt)
   }
 
 #ifdef USE_IMAP
-  if (Context->magic == MUTT_IMAP && imap_search(Context, pat) < 0)
+  if (Context->mailbox->magic == MUTT_IMAP && imap_search(Context, pat) < 0)
     goto bail;
 #endif
 
@@ -2400,7 +2400,7 @@ int mutt_search_command(int cur, int op)
     for (int i = 0; i < Context->mailbox->msg_count; i++)
       Context->hdrs[i]->searched = false;
 #ifdef USE_IMAP
-    if (Context->magic == MUTT_IMAP && imap_search(Context, SearchPattern) < 0)
+    if (Context->mailbox->magic == MUTT_IMAP && imap_search(Context, SearchPattern) < 0)
       return -1;
 #endif
     OptSearchInvalid = false;
index 806d3e9295772f3694e9f739412fd886fd5402c5..e1fcc9cad6bcb174d3db19d08f67ba7391fbe08d 100644 (file)
@@ -43,6 +43,7 @@
 #include "hdrline.h"
 #include "hook.h"
 #include "keymap.h"
+#include "mailbox.h"
 #include "menu.h"
 #include "mutt_attach.h"
 #include "mutt_logging.h"
@@ -1415,7 +1416,7 @@ void mutt_view_attachments(struct Header *hdr)
         CHECK_READONLY;
 
 #ifdef USE_POP
-        if (Context->magic == MUTT_POP)
+        if (Context->mailbox->magic == MUTT_POP)
         {
           mutt_flushinp();
           mutt_error(_("Can't delete attachment from POP server"));
@@ -1424,7 +1425,7 @@ void mutt_view_attachments(struct Header *hdr)
 #endif
 
 #ifdef USE_NNTP
-        if (Context->magic == MUTT_NNTP)
+        if (Context->mailbox->magic == MUTT_NNTP)
         {
           mutt_flushinp();
           mutt_error(_("Can't delete attachment from news server"));
diff --git a/send.c b/send.c
index e21e204aaf124748914a6029417f303cd6d5f878..024ddf90ec94f6c00814dad312f546d276ae9cc9 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1727,7 +1727,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile,
       mutt_fix_reply_recipients(msg->env);
 
 #ifdef USE_NNTP
-    if ((flags & SEND_NEWS) && ctx && ctx->magic == MUTT_NNTP && !msg->env->newsgroups)
+    if ((flags & SEND_NEWS) && ctx && ctx->mailbox->magic == MUTT_NNTP && !msg->env->newsgroups)
       msg->env->newsgroups = mutt_str_strdup(((struct NntpData *) ctx->data)->group);
 #endif
 
index 140c6cfc5264d6e1679054772e460dfcad43bce3..a75eedd6a6afb7d3ce2da6fcccc02d30ddf4b79a 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -3186,7 +3186,7 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid,
   /* We need to add a Content-Length field to avoid problems where a line in
    * the message body begins with "From "
    */
-  if ((f->magic == MUTT_MMDF) || (f->magic == MUTT_MBOX))
+  if ((f->mailbox->magic == MUTT_MMDF) || (f->mailbox->magic == MUTT_MBOX))
   {
     mutt_mktemp(tempfile, sizeof(tempfile));
     tempfp = mutt_file_fopen(tempfile, "w+");
@@ -3233,7 +3233,7 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid,
   if (post && fcc)
     fprintf(msg->fp, "X-Mutt-Fcc: %s\n", fcc);
 
-  if ((f->magic == MUTT_MMDF) || (f->magic == MUTT_MBOX))
+  if ((f->mailbox->magic == MUTT_MMDF) || (f->mailbox->magic == MUTT_MBOX))
     fprintf(msg->fp, "Status: RO\n");
 
   /* mutt_rfc822_write_header() only writes out a Date: header with
diff --git a/sort.c b/sort.c
index 452bad34cdc83ec7e8f93e23e0f4476f35f32410..363b800d51b78d8ac7e603d0e913d05c11fd1a51 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -321,7 +321,7 @@ sort_t *mutt_get_sort_func(int method)
       return compare_label;
     case SORT_ORDER:
 #ifdef USE_NNTP
-      if (Context && (Context->magic == MUTT_NNTP))
+      if (Context && (Context->mailbox->magic == MUTT_NNTP))
         return nntp_compare_order;
       else
 #endif
index 88d5d9e0bd9a2593b5b0100a12ce1485ae295a65..03605912f4ee83a1c418a3ae55a04600ac5d8992 100644 (file)
--- a/status.c
+++ b/status.c
@@ -125,7 +125,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
     {
 #ifdef USE_NOTMUCH
       char *p = NULL;
-      if (Context && Context->magic == MUTT_NOTMUCH && (p = nm_get_description(Context)))
+      if (Context && Context->mailbox->magic == MUTT_NOTMUCH && (p = nm_get_description(Context)))
         mutt_str_strfcpy(tmp, p, sizeof(tmp));
       else
 #endif
@@ -269,7 +269,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
                                 2 :
                                 (Context->changed ||
                                  /* deleted doesn't necessarily mean changed in IMAP */
-                                 (Context->magic != MUTT_IMAP && Context->deleted)) ?
+                                 (Context->mailbox->magic != MUTT_IMAP && Context->deleted)) ?
                                 1 :
                                 0);
       }