]> granicus.if.org Git - neomutt/commitdiff
imap: Move Context to ImapMboxData
authorMehdi Abaakouk <sileht@sileht.net>
Thu, 20 Dec 2018 07:50:59 +0000 (08:50 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 20 Dec 2018 12:40:17 +0000 (12:40 +0000)
imap/command.c
imap/imap.c
imap/imap_private.h
imap/message.c

index 0299cea7e80252d10a5a905b937f15bd60f5bb03..a7a2f67f281ac7856e7f479a4405910002d9995c 100644 (file)
@@ -165,7 +165,7 @@ static void cmd_handle_fatal(struct ImapAccountData *adata)
 
   if (adata->state >= IMAP_SELECTED && (mdata->reopen & IMAP_REOPEN_ALLOW))
   {
-    mx_fastclose_mailbox(adata->ctx);
+    mx_fastclose_mailbox(mdata->ctx);
     mutt_socket_close(adata->conn);
     mutt_error(_("Mailbox %s@%s closed"), adata->conn->account.user,
                adata->conn->account.host);
index 8efc3c915361fd34e76cdbb87c522170c2a95249..09cbab5df9a7e59ac12df33d7b0b91646eb02d9b 100644 (file)
@@ -793,7 +793,7 @@ void imap_expunge_mailbox(struct Mailbox *m)
 
   old_sort = Sort;
   Sort = SORT_ORDER;
-  mutt_sort_headers(adata->ctx, false);
+  mutt_sort_headers(mdata->ctx, false);
 
   for (int i = 0; i < m->msg_count; i++)
   {
@@ -853,9 +853,9 @@ void imap_expunge_mailbox(struct Mailbox *m)
 
   /* We may be called on to expunge at any time. We can't rely on the caller
    * to always know to rethread */
-  mx_update_tables(adata->ctx, false);
+  mx_update_tables(mdata->ctx, false);
   Sort = old_sort;
-  mutt_sort_headers(adata->ctx, true);
+  mutt_sort_headers(mdata->ctx, true);
 }
 
 /**
@@ -1980,11 +1980,11 @@ static int imap_mbox_open(struct Mailbox *m, struct Context *ctx)
   struct ImapMboxData *mdata = imap_mdata_get(m);
 
   // NOTE(sileht): looks like we have two not obvious loop here
-  // ctx->mailbox->account->adata->ctx
+  // ctx->mailbox->account->mdata->ctx
   // mailbox->account->adata->mailbox
   // this is used only by imap_mbox_close() to detect if the
   // adata/mailbox is a normal or append one, looks a bit dirty
-  adata->ctx = ctx;
+  mdata->ctx = ctx;
   adata->mailbox = m;
 
   /* clear mailbox status */
@@ -2251,20 +2251,21 @@ static int imap_mbox_close(struct Context *ctx)
   struct Mailbox *m = ctx->mailbox;
 
   struct ImapAccountData *adata = imap_adata_get(m);
+  struct ImapMboxData *mdata = imap_mdata_get(m);
 
   /* Check to see if the mailbox is actually open */
-  if (!adata)
+  if (!adata || !mdata)
     return 0;
 
   /* imap_mbox_open_append() borrows the struct ImapAccountData temporarily,
-   * just for the connection, but does not set adata->ctx to the
+   * just for the connection, but does not set mdata->ctx to the
    * open-append ctx.
    *
    * So when these are equal, it means we are actually closing the
    * mailbox and should clean up adata.  Otherwise, we don't want to
    * touch adata - it's still being used.
    */
-  if (ctx == adata->ctx)
+  if (ctx == mdata->ctx)
   {
     if (adata->status != IMAP_FATAL && adata->state >= IMAP_SELECTED)
     {
@@ -2279,7 +2280,7 @@ static int imap_mbox_close(struct Context *ctx)
     }
 
     adata->mailbox = NULL;
-    adata->ctx = NULL;
+    mdata->ctx = NULL;
 
     imap_mdata_cache_reset(m->mdata);
   }
index 384ab15b8cd70bc708f78f820ece814ccd747ff8..599f962ca3096c65476e6581a41d9bda36865c13 100644 (file)
@@ -214,7 +214,6 @@ struct ImapAccountData
   struct Buffer *cmdbuf;
 
   char delim;
-  struct Context *ctx;
   struct Mailbox *mailbox;     /* Current selected mailbox */
 };
 
@@ -250,6 +249,8 @@ struct ImapMboxData
   unsigned int max_msn;        /**< the largest MSN fetched so far */
   struct BodyCache *bcache;
 
+  struct Context *ctx;
+
 #ifdef USE_HCACHE
   header_cache_t *hcache;
 #endif
index 0434f6789e23753c234ba18ab68b0360ba053fae..8bd7dae04586eb8233bb003d0d29de2540dc14f9 100644 (file)
@@ -1817,7 +1817,7 @@ char *imap_set_flags(struct Mailbox *m, struct Email *e, char *s, int *server_ch
   m->readonly = false;
 
   /* This is redundant with the following two checks. Removing:
-   * mutt_set_flag (adata->ctx, e, MUTT_NEW, !(edata->read || edata->old));
+   * mutt_set_flag (m, e, MUTT_NEW, !(edata->read || edata->old));
    */
   set_changed_flag(m, e, local_changes, server_changes, MUTT_OLD, old_edata.old,
                    edata->old, e->old);