]> granicus.if.org Git - neomutt/commitdiff
imap tidy
authorRichard Russon <rich@flatcap.org>
Fri, 28 Dec 2018 14:16:29 +0000 (14:16 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 5 Jan 2019 14:44:35 +0000 (14:44 +0000)
imap/imap.c
imap/imap.h
mutt_parse.c
mx.c

index 38699564e2c1d0fb65b827661024bfc56ab33b2b..db2f4d77565ebfa68b96ea318717314c2c514c6f 100644 (file)
@@ -591,7 +591,7 @@ int imap_create_mailbox(struct ImapAccountData *adata, char *mailbox)
  * @retval <0 Failure
  *
  * TODO: ACL checks. Right now we assume if it exists we can mess with it.
- * TODO: This method should take a Context as parameter to be able to reuse the
+ * TODO: This method should take a Mailbox as parameter to be able to reuse the
  * existing connection.
  */
 int imap_access(const char *path)
@@ -1614,15 +1614,15 @@ out:
 
 /**
  * imap_sync_mailbox - Sync all the changes to the server
- * @param ctx     Mailbox
+ * @param m       Mailbox
  * @param expunge if true do expunge
  * @param close   if true we move imap state to CLOSE
  * @retval  0 Success
  * @retval -1 Error
  */
-int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close)
+int imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
   struct Email *e = NULL;
@@ -1630,8 +1630,6 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close)
   int oldsort;
   int rc;
 
-  struct Mailbox *m = ctx->mailbox;
-
   struct ImapAccountData *adata = imap_adata_get(m);
   struct ImapMboxData *mdata = imap_mdata_get(m);
 
@@ -1705,7 +1703,7 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close)
         mutt_message(ngettext("Saving changed message... [%d/%d]",
                               "Saving changed messages... [%d/%d]", m->msg_count),
                      i + 1, m->msg_count);
-        mutt_save_message_ctx(e, true, false, false, ctx->mailbox);
+        mutt_save_message_ctx(e, true, false, false, m);
         e->xlabel_changed = false;
       }
     }
index 921feab4775197d744e2fea97732b2141e494d43..4446842285aaa18dfa6db184c1a18351fd01e2bf 100644 (file)
@@ -55,7 +55,6 @@
 #include "mx.h"
 
 struct BrowserState;
-struct Context;
 struct Email;
 struct Pattern;
 
@@ -79,7 +78,7 @@ extern short ImapPipelineDepth;
 int imap_access(const char *path);
 int imap_check_mailbox(struct Mailbox *m, bool force);
 int imap_delete_mailbox(struct Mailbox *m, char *path);
-int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close);
+int imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close);
 int imap_path_status(const char *path, bool queue);
 int imap_mailbox_status(struct Mailbox *m, bool queue);
 int imap_search(struct Mailbox *m, const struct Pattern *pat);
index c858e612c42b8c74fd1626f5e0de1a8fcde47720..cc130afce721b1db6b950bc3844f903d44e20686 100644 (file)
@@ -44,34 +44,32 @@ struct Context;
 
 /**
  * mutt_parse_mime_message - Parse a MIME email
- * @param m   Mailbox
- * @param cur Email
+ * @param m Mailbox
+ * @param e Email
  */
-void mutt_parse_mime_message(struct Mailbox *m, struct Email *cur)
+void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
 {
-  struct Message *msg = NULL;
-
   do
   {
-    if (cur->content->type != TYPE_MESSAGE && cur->content->type != TYPE_MULTIPART)
+    if ((e->content->type != TYPE_MESSAGE) && (e->content->type != TYPE_MULTIPART))
       break; /* nothing to do */
 
-    if (cur->content->parts)
+    if (e->content->parts)
       break; /* The message was parsed earlier. */
 
-    msg = mx_msg_open(m, cur->msgno);
+    struct Message *msg = mx_msg_open(m, e->msgno);
     if (msg)
     {
-      mutt_parse_part(msg->fp, cur->content);
+      mutt_parse_part(msg->fp, e->content);
 
       if (WithCrypto)
-        cur->security = crypt_query(cur->content);
+        e->security = crypt_query(e->content);
 
       mx_msg_close(m, &msg);
     }
   } while (false);
 
-  cur->attach_valid = false;
+  e->attach_valid = false;
 }
 
 /**
diff --git a/mx.c b/mx.c
index 46a67737327b80d085f411ff610308957b6cc3d6..2afe4ef50d54f5843a596cd94facdb515a5e06bc 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -434,18 +434,16 @@ void mx_fastclose_mailbox(struct Mailbox *m)
 
 /**
  * sync_mailbox - save changes to disk
- * @param ctx        Mailbox
+ * @param m          Mailbox
  * @param index_hint Current email
  * @retval  0 Success
  * @retval -1 Failure
  */
-static int sync_mailbox(struct Context *ctx, int *index_hint)
+static int sync_mailbox(struct Mailbox *m, int *index_hint)
 {
-  if (!ctx || !ctx->mailbox || !ctx->mailbox->mx_ops || !ctx->mailbox->mx_ops->mbox_sync)
+  if (!m || !m->mx_ops || !m->mx_ops->mbox_sync)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   if (!m->quiet)
   {
     /* L10N: Displayed before/as a mailbox is being synced */
@@ -749,7 +747,7 @@ int mx_mbox_close(struct Context **pctx)
   /* allow IMAP to preserve the deleted flag across sessions */
   if (m->magic == MUTT_IMAP)
   {
-    int check = imap_sync_mailbox(ctx, (purge != MUTT_NO), true);
+    int check = imap_sync_mailbox(ctx->mailbox, (purge != MUTT_NO), true);
     if (check != 0)
       return check;
   }
@@ -768,7 +766,7 @@ int mx_mbox_close(struct Context **pctx)
 
     if (m->changed || (m->msg_deleted != 0))
     {
-      int check = sync_mailbox(ctx, NULL);
+      int check = sync_mailbox(ctx->mailbox, NULL);
       if (check != 0)
         return check;
     }
@@ -898,10 +896,10 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint)
 
 #ifdef USE_IMAP
   if (m->magic == MUTT_IMAP)
-    rc = imap_sync_mailbox(ctx, purge, false);
+    rc = imap_sync_mailbox(ctx->mailbox, purge, false);
   else
 #endif
-    rc = sync_mailbox(ctx, index_hint);
+    rc = sync_mailbox(ctx->mailbox, index_hint);
   if (rc == 0)
   {
 #ifdef USE_IMAP