Imap: unify naming
authorRichard Russon <rich@flatcap.org>
Tue, 23 Oct 2018 22:58:19 +0000 (23:58 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 25 Oct 2018 20:38:43 +0000 (21:38 +0100)
imap/command.c
imap/imap.c
imap/imap.h
imap/imap_private.h
imap/message.c
imap/message.h
imap/util.c

index 8f2a736776edd70db2553a7fbe1e2cf7df53ecc3..a3ef7ec939a4bcbbc8d5153899a13d4fa3e8799d 100644 (file)
@@ -258,7 +258,7 @@ static void cmd_parse_expunge(struct ImapAccountData *adata, const char *s)
      * It needs to resort using SORT_ORDER anyway, so setting to INT_MAX
      * makes the code simpler and possibly more efficient. */
     e->index = INT_MAX;
-    IMAP_EDATA(e)->msn = 0;
+    imap_edata_get(e)->msn = 0;
   }
 
   /* decrement seqno of those above. */
@@ -266,7 +266,7 @@ static void cmd_parse_expunge(struct ImapAccountData *adata, const char *s)
   {
     e = adata->msn_index[cur];
     if (e)
-      IMAP_EDATA(e)->msn--;
+      imap_edata_get(e)->msn--;
     adata->msn_index[cur - 1] = e;
   }
 
@@ -322,13 +322,13 @@ static void cmd_parse_vanished(struct ImapAccountData *adata, char *s)
     if (!e)
       continue;
 
-    unsigned int exp_msn = IMAP_EDATA(e)->msn;
+    unsigned int exp_msn = imap_edata_get(e)->msn;
 
     /* imap_expunge_mailbox() will rewrite e->index.
      * It needs to resort using SORT_ORDER anyway, so setting to INT_MAX
      * makes the code simpler and possibly more efficient. */
     e->index = INT_MAX;
-    IMAP_EDATA(e)->msn = 0;
+    imap_edata_get(e)->msn = 0;
 
     if ((exp_msn < 1) || (exp_msn > adata->max_msn))
     {
@@ -350,7 +350,7 @@ static void cmd_parse_vanished(struct ImapAccountData *adata, char *s)
       {
         e = adata->msn_index[cur];
         if (e)
-          IMAP_EDATA(e)->msn--;
+          imap_edata_get(e)->msn--;
         adata->msn_index[cur - 1] = e;
       }
 
@@ -405,7 +405,7 @@ static void cmd_parse_fetch(struct ImapAccountData *adata, char *s)
     return;
   }
 
-  mutt_debug(2, "Message UID %u updated\n", IMAP_EDATA(e)->uid);
+  mutt_debug(2, "Message UID %u updated\n", imap_edata_get(e)->uid);
   /* skip FETCH */
   s = imap_next_word(s);
   s = imap_next_word(s);
@@ -454,7 +454,7 @@ static void cmd_parse_fetch(struct ImapAccountData *adata, char *s)
         mutt_debug(1, "Illegal UID.  Skipping update.\n");
         return;
       }
-      if (uid != IMAP_EDATA(e)->uid)
+      if (uid != imap_edata_get(e)->uid)
       {
         mutt_debug(1, "UID vs MSN mismatch.  Skipping update.\n");
         return;
index 34324245f9a5ec364f9576f5452ab8063f9dcbd0..b2e1e39167c72a5212c3a2935683b0ec76726687 100644 (file)
@@ -197,23 +197,23 @@ static int make_msg_set(struct ImapAccountData *adata, struct Buffer *buf,
       switch (flag)
       {
         case MUTT_DELETED:
-          if (emails[n]->deleted != IMAP_EDATA(emails[n])->deleted)
+          if (emails[n]->deleted != imap_edata_get(emails[n])->deleted)
             match = invert ^ emails[n]->deleted;
           break;
         case MUTT_FLAG:
-          if (emails[n]->flagged != IMAP_EDATA(emails[n])->flagged)
+          if (emails[n]->flagged != imap_edata_get(emails[n])->flagged)
             match = invert ^ emails[n]->flagged;
           break;
         case MUTT_OLD:
-          if (emails[n]->old != IMAP_EDATA(emails[n])->old)
+          if (emails[n]->old != imap_edata_get(emails[n])->old)
             match = invert ^ emails[n]->old;
           break;
         case MUTT_READ:
-          if (emails[n]->read != IMAP_EDATA(emails[n])->read)
+          if (emails[n]->read != imap_edata_get(emails[n])->read)
             match = invert ^ emails[n]->read;
           break;
         case MUTT_REPLIED:
-          if (emails[n]->replied != IMAP_EDATA(emails[n])->replied)
+          if (emails[n]->replied != imap_edata_get(emails[n])->replied)
             match = invert ^ emails[n]->replied;
           break;
         case MUTT_TAG:
@@ -232,25 +232,25 @@ static int make_msg_set(struct ImapAccountData *adata, struct Buffer *buf,
       count++;
       if (setstart == 0)
       {
-        setstart = IMAP_EDATA(emails[n])->uid;
+        setstart = imap_edata_get(emails[n])->uid;
         if (!started)
         {
-          mutt_buffer_add_printf(buf, "%u", IMAP_EDATA(emails[n])->uid);
+          mutt_buffer_add_printf(buf, "%u", imap_edata_get(emails[n])->uid);
           started = true;
         }
         else
-          mutt_buffer_add_printf(buf, ",%u", IMAP_EDATA(emails[n])->uid);
+          mutt_buffer_add_printf(buf, ",%u", imap_edata_get(emails[n])->uid);
       }
       /* tie up if the last message also matches */
       else if (n == adata->mailbox->msg_count - 1)
-        mutt_buffer_add_printf(buf, ":%u", IMAP_EDATA(emails[n])->uid);
+        mutt_buffer_add_printf(buf, ":%u", imap_edata_get(emails[n])->uid);
     }
     /* End current set if message doesn't match or we've reached the end
      * of the mailbox via inactive messages following the last match. */
     else if (setstart && (emails[n]->active || n == adata->mailbox->msg_count - 1))
     {
-      if (IMAP_EDATA(emails[n - 1])->uid > setstart)
-        mutt_buffer_add_printf(buf, ":%u", IMAP_EDATA(emails[n - 1])->uid);
+      if (imap_edata_get(emails[n - 1])->uid > setstart)
+        mutt_buffer_add_printf(buf, ":%u", imap_edata_get(emails[n - 1])->uid);
       setstart = 0;
     }
   }
@@ -400,9 +400,9 @@ static int do_search(const struct Pattern *search, int allpats)
 
 /**
  * compile_search - Convert NeoMutt pattern to IMAP search
- * @param mailbox Mailbox
- * @param pat     Pattern to convert
- * @param buf     Buffer for result
+ * @param m   Mailbox
+ * @param pat Pattern to convert
+ * @param buf Buffer for result
  * @retval  0 Success
  * @retval -1 Failure
  *
@@ -410,8 +410,7 @@ static int do_search(const struct Pattern *search, int allpats)
  * that require full-text search (neomutt already has what it needs for most
  * match types, and does a better job (eg server doesn't support regexes).
  */
-static int compile_search(struct Mailbox *mailbox, const struct Pattern *pat,
-                          struct Buffer *buf)
+static int compile_search(struct Mailbox *m, const struct Pattern *pat, struct Buffer *buf)
 {
   if (do_search(pat, 0) == 0)
     return 0;
@@ -438,7 +437,7 @@ static int compile_search(struct Mailbox *mailbox, const struct Pattern *pat,
             mutt_buffer_addstr(buf, "OR ");
           clauses--;
 
-          if (compile_search(mailbox, clause, buf) < 0)
+          if (compile_search(m, clause, buf) < 0)
             return -1;
 
           if (clauses)
@@ -491,7 +490,7 @@ static int compile_search(struct Mailbox *mailbox, const struct Pattern *pat,
         break;
       case MUTT_SERVERSEARCH:
       {
-        struct ImapAccountData *adata = imap_get_adata(mailbox);
+        struct ImapAccountData *adata = imap_adata_get(m);
         if (!mutt_bit_isset(adata->capabilities, X_GM_EXT1))
         {
           mutt_error(_("Server-side custom search not supported: %s"), pat->p.str);
@@ -709,31 +708,31 @@ int imap_rename_mailbox(struct ImapAccountData *adata, struct ImapMbox *mx, cons
 
 /**
  * imap_delete_mailbox - Delete a mailbox
- * @param mailbox Mailbox
- * @param mx      Mailbox to delete
+ * @param m  Mailbox
+ * @param im Mailbox to delete
  * @retval  0 Success
  * @retval -1 Failure
  */
-int imap_delete_mailbox(struct Mailbox *mailbox, struct ImapMbox *mx)
+int imap_delete_mailbox(struct Mailbox *m, struct ImapMbox *im)
 {
   char buf[PATH_MAX], mbox[PATH_MAX];
-  struct ImapAccountData *adata = imap_get_adata(mailbox);
+  struct ImapAccountData *adata = imap_adata_get(m);
 
-  if (!mailbox || !adata)
+  if (!m || !adata)
   {
-    adata = imap_conn_find(&mx->account, ImapPassive ? MUTT_IMAP_CONN_NONEW : 0);
+    adata = imap_conn_find(&im->account, ImapPassive ? MUTT_IMAP_CONN_NONEW : 0);
     if (!adata)
     {
-      FREE(&mx->mbox);
+      FREE(&im->mbox);
       return -1;
     }
   }
   else
   {
-    adata = mailbox->mdata;
+    adata = m->mdata;
   }
 
-  imap_munge_mbox_name(adata, mbox, sizeof(mbox), mx->mbox);
+  imap_munge_mbox_name(adata, mbox, sizeof(mbox), im->mbox);
   snprintf(buf, sizeof(buf), "DELETE %s", mbox);
 
   if (imap_exec(adata, buf, 0) != 0)
@@ -856,28 +855,28 @@ void imap_expunge_mailbox(struct ImapAccountData *adata)
 
     if (e->index == INT_MAX)
     {
-      mutt_debug(2, "Expunging message UID %u.\n", IMAP_EDATA(e)->uid);
+      mutt_debug(2, "Expunging message UID %u.\n", imap_edata_get(e)->uid);
 
       e->active = false;
       adata->mailbox->size -= e->content->length;
 
       imap_cache_del(adata, e);
 #ifdef USE_HCACHE
-      imap_hcache_del(adata, IMAP_EDATA(e)->uid);
+      imap_hcache_del(adata, imap_edata_get(e)->uid);
 #endif
 
       /* free cached body from disk, if necessary */
-      cacheno = IMAP_EDATA(e)->uid % IMAP_CACHE_LEN;
-      if (adata->cache[cacheno].uid == IMAP_EDATA(e)->uid &&
+      cacheno = imap_edata_get(e)->uid % IMAP_CACHE_LEN;
+      if (adata->cache[cacheno].uid == imap_edata_get(e)->uid &&
           adata->cache[cacheno].path)
       {
         unlink(adata->cache[cacheno].path);
         FREE(&adata->cache[cacheno].path);
       }
 
-      mutt_hash_int_delete(adata->uid_hash, IMAP_EDATA(e)->uid, e);
+      mutt_hash_int_delete(adata->uid_hash, imap_edata_get(e)->uid, e);
 
-      imap_free_emaildata((void **) &e->edata);
+      imap_edata_free((void **) &e->edata);
     }
     else
     {
@@ -1272,12 +1271,12 @@ int imap_sync_message_for_copy(struct ImapAccountData *adata, struct Email *e,
 
   if (!compare_flags_for_copy(e))
   {
-    if (e->deleted == IMAP_EDATA(e)->deleted)
+    if (e->deleted == imap_edata_get(e)->deleted)
       e->changed = false;
     return 0;
   }
 
-  snprintf(uid, sizeof(uid), "%u", IMAP_EDATA(e)->uid);
+  snprintf(uid, sizeof(uid), "%u", imap_edata_get(e)->uid);
   cmd->dptr = cmd->data;
   mutt_buffer_addstr(cmd, "UID STORE ");
   mutt_buffer_addstr(cmd, uid);
@@ -1288,14 +1287,14 @@ int imap_sync_message_for_copy(struct ImapAccountData *adata, struct Email *e,
   set_flag(adata, MUTT_ACL_WRITE, e->old, "Old ", flags, sizeof(flags));
   set_flag(adata, MUTT_ACL_WRITE, e->flagged, "\\Flagged ", flags, sizeof(flags));
   set_flag(adata, MUTT_ACL_WRITE, e->replied, "\\Answered ", flags, sizeof(flags));
-  set_flag(adata, MUTT_ACL_DELETE, IMAP_EDATA(e)->deleted, "\\Deleted ", flags,
-           sizeof(flags));
+  set_flag(adata, MUTT_ACL_DELETE, imap_edata_get(e)->deleted, "\\Deleted ",
+           flags, sizeof(flags));
 
   if (mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE))
   {
     /* restore system flags */
-    if (IMAP_EDATA(e)->flags_system)
-      mutt_str_strcat(flags, sizeof(flags), IMAP_EDATA(e)->flags_system);
+    if (imap_edata_get(e)->flags_system)
+      mutt_str_strcat(flags, sizeof(flags), imap_edata_get(e)->flags_system);
     /* set custom flags */
     tags = driver_tags_get_with_hidden(&e->tags);
     if (tags)
@@ -1315,12 +1314,13 @@ int imap_sync_message_for_copy(struct ImapAccountData *adata, struct Email *e,
     set_flag(adata, MUTT_ACL_WRITE, 1, "Old ", flags, sizeof(flags));
     set_flag(adata, MUTT_ACL_WRITE, 1, "\\Flagged ", flags, sizeof(flags));
     set_flag(adata, MUTT_ACL_WRITE, 1, "\\Answered ", flags, sizeof(flags));
-    set_flag(adata, MUTT_ACL_DELETE, !IMAP_EDATA(e)->deleted, "\\Deleted ",
+    set_flag(adata, MUTT_ACL_DELETE, !imap_edata_get(e)->deleted, "\\Deleted ",
              flags, sizeof(flags));
 
     /* erase custom flags */
-    if (mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE) && IMAP_EDATA(e)->flags_remote)
-      mutt_str_strcat(flags, sizeof(flags), IMAP_EDATA(e)->flags_remote);
+    if (mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE) &&
+        imap_edata_get(e)->flags_remote)
+      mutt_str_strcat(flags, sizeof(flags), imap_edata_get(e)->flags_remote);
 
     mutt_str_remove_trailing_ws(flags);
 
@@ -1349,11 +1349,11 @@ int imap_sync_message_for_copy(struct ImapAccountData *adata, struct Email *e,
   }
 
   /* server have now the updated flags */
-  FREE(&IMAP_EDATA(e)->flags_remote);
-  IMAP_EDATA(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);
+  FREE(&imap_edata_get(e)->flags_remote);
+  imap_edata_get(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);
 
   e->active = true;
-  if (e->deleted == IMAP_EDATA(e)->deleted)
+  if (e->deleted == imap_edata_get(e)->deleted)
     e->changed = false;
 
   return 0;
@@ -1361,16 +1361,16 @@ int imap_sync_message_for_copy(struct ImapAccountData *adata, struct Email *e,
 
 /**
  * imap_check_mailbox - use the NOOP or IDLE command to poll for new mail
- * @param mailbox Mailbox
- * @param force   Don't wait
+ * @param m     Mailbox
+ * @param force Don't wait
  * @retval #MUTT_REOPENED  mailbox has been externally modified
  * @retval #MUTT_NEW_MAIL  new mail has arrived
  * @retval 0               no change
  * @retval -1              error
  */
-int imap_check_mailbox(struct Mailbox *mailbox, bool force)
+int imap_check_mailbox(struct Mailbox *m, bool force)
 {
-  struct ImapAccountData *adata = imap_get_adata(mailbox);
+  struct ImapAccountData *adata = imap_adata_get(m);
   return imap_check(adata, force);
 }
 
@@ -1685,24 +1685,24 @@ void imap_mboxcache_free(struct ImapAccountData *adata)
 
 /**
  * imap_search - Find a matching mailbox
- * @param mailbox Mailbox
+ * @param m   Mailbox
  * @param pat Pattern to match
  * @retval  0 Success
  * @retval -1 Failure
  */
-int imap_search(struct Mailbox *mailbox, const struct Pattern *pat)
+int imap_search(struct Mailbox *m, const struct Pattern *pat)
 {
   struct Buffer buf;
-  struct ImapAccountData *adata = imap_get_adata(mailbox);
-  for (int i = 0; i < mailbox->msg_count; i++)
-    mailbox->hdrs[i]->matched = false;
+  struct ImapAccountData *adata = imap_adata_get(m);
+  for (int i = 0; i < m->msg_count; i++)
+    m->hdrs[i]->matched = false;
 
   if (do_search(pat, 1) == 0)
     return 0;
 
   mutt_buffer_init(&buf);
   mutt_buffer_addstr(&buf, "UID SEARCH ");
-  if (compile_search(mailbox, pat, &buf) < 0)
+  if (compile_search(m, pat, &buf) < 0)
   {
     FREE(&buf.data);
     return -1;
@@ -1885,13 +1885,13 @@ int imap_complete(char *buf, size_t buflen, char *path)
 
 /**
  * imap_fast_trash - Use server COPY command to copy deleted messages to trash
- * @param mailbox Mailbox
- * @param dest    Mailbox to move to
+ * @param m    Mailbox
+ * @param dest Mailbox to move to
  * @retval -1 Error
  * @retval  0 Success
  * @retval  1 Non-fatal error - try fetch/append
  */
-int imap_fast_trash(struct Mailbox *mailbox, char *dest)
+int imap_fast_trash(struct Mailbox *m, char *dest)
 {
   char mbox[LONG_STRING];
   char mmbox[LONG_STRING];
@@ -1902,7 +1902,7 @@ int imap_fast_trash(struct Mailbox *mailbox, char *dest)
   struct Buffer *sync_cmd = NULL;
   int err_continue = MUTT_NO;
 
-  struct ImapAccountData *adata = imap_get_adata(mailbox);
+  struct ImapAccountData *adata = imap_adata_get(m);
 
   if (imap_parse_path(dest, &mx))
   {
@@ -1913,7 +1913,7 @@ int imap_fast_trash(struct Mailbox *mailbox, char *dest)
   /* check that the save-to folder is in the same account */
   if (!mutt_account_match(&(adata->conn->account), &(mx.account)))
   {
-    mutt_debug(3, "%s not same server as %s\n", dest, mailbox->path);
+    mutt_debug(3, "%s not same server as %s\n", dest, m->path);
     return 1;
   }
 
@@ -1923,12 +1923,12 @@ int imap_fast_trash(struct Mailbox *mailbox, char *dest)
   imap_munge_mbox_name(adata, mmbox, sizeof(mmbox), mbox);
 
   sync_cmd = mutt_buffer_new();
-  for (int i = 0; i < mailbox->msg_count; i++)
+  for (int i = 0; i < m->msg_count; i++)
   {
-    if (mailbox->hdrs[i]->active && mailbox->hdrs[i]->changed &&
-        mailbox->hdrs[i]->deleted && !mailbox->hdrs[i]->purge)
+    if (m->hdrs[i]->active && m->hdrs[i]->changed && m->hdrs[i]->deleted &&
+        !m->hdrs[i]->purge)
     {
-      rc = imap_sync_message_for_copy(adata, mailbox->hdrs[i], sync_cmd, &err_continue);
+      rc = imap_sync_message_for_copy(adata, m->hdrs[i], sync_cmd, &err_continue);
       if (rc < 0)
       {
         mutt_debug(1, "could not sync\n");
@@ -2013,7 +2013,7 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge)
   int oldsort;
   int rc;
 
-  struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+  struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
 
   if (adata->state < IMAP_SELECTED)
   {
@@ -2066,7 +2066,7 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge)
     {
       imap_cache_del(adata, e);
 #ifdef USE_HCACHE
-      imap_hcache_del(adata, IMAP_EDATA(e)->uid);
+      imap_hcache_del(adata, imap_edata_get(e)->uid);
 #endif
     }
 
@@ -2158,11 +2158,11 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge)
    * there is no need to mutate the hcache after flag-only changes. */
   for (int i = 0; i < ctx->mailbox->msg_count; i++)
   {
-    IMAP_EDATA(ctx->mailbox->hdrs[i])->deleted = ctx->mailbox->hdrs[i]->deleted;
-    IMAP_EDATA(ctx->mailbox->hdrs[i])->flagged = ctx->mailbox->hdrs[i]->flagged;
-    IMAP_EDATA(ctx->mailbox->hdrs[i])->old = ctx->mailbox->hdrs[i]->old;
-    IMAP_EDATA(ctx->mailbox->hdrs[i])->read = ctx->mailbox->hdrs[i]->read;
-    IMAP_EDATA(ctx->mailbox->hdrs[i])->replied = ctx->mailbox->hdrs[i]->replied;
+    imap_edata_get(ctx->mailbox->hdrs[i])->deleted = ctx->mailbox->hdrs[i]->deleted;
+    imap_edata_get(ctx->mailbox->hdrs[i])->flagged = ctx->mailbox->hdrs[i]->flagged;
+    imap_edata_get(ctx->mailbox->hdrs[i])->old = ctx->mailbox->hdrs[i]->old;
+    imap_edata_get(ctx->mailbox->hdrs[i])->read = ctx->mailbox->hdrs[i]->read;
+    imap_edata_get(ctx->mailbox->hdrs[i])->replied = ctx->mailbox->hdrs[i]->replied;
     ctx->mailbox->hdrs[i]->changed = false;
   }
   ctx->mailbox->changed = false;
@@ -2581,7 +2581,7 @@ static int imap_mbox_check(struct Context *ctx, int *index_hint)
   (void) index_hint;
 
   imap_allow_reopen(ctx->mailbox);
-  struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+  struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
   int rc = imap_check(adata, false);
   /* NOTE - ctx might have been changed at this point. In particular,
    * ctx->mailbox could be NULL. Beware. */
@@ -2596,7 +2596,7 @@ static int imap_mbox_check(struct Context *ctx, int *index_hint)
  */
 static int imap_mbox_close(struct Context *ctx)
 {
-  struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+  struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
   /* Check to see if the mailbox is actually open */
   if (!adata)
     return 0;
@@ -2671,7 +2671,7 @@ static int imap_tags_edit(struct Context *ctx, const char *tags, char *buf, size
 {
   char *new = NULL;
   char *checker = NULL;
-  struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+  struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
 
   /* Check for \* flags capability */
   if (!imap_has_flag(&adata->flags, NULL))
@@ -2758,7 +2758,7 @@ static int imap_tags_commit(struct Context *ctx, struct Email *e, char *buf)
   struct Buffer *cmd = NULL;
   char uid[11];
 
-  struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+  struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
 
   if (*buf == '\0')
     buf = NULL;
@@ -2766,10 +2766,10 @@ static int imap_tags_commit(struct Context *ctx, struct Email *e, char *buf)
   if (!mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE))
     return 0;
 
-  snprintf(uid, sizeof(uid), "%u", IMAP_EDATA(e)->uid);
+  snprintf(uid, sizeof(uid), "%u", imap_edata_get(e)->uid);
 
   /* Remove old custom flags */
-  if (IMAP_EDATA(e)->flags_remote)
+  if (imap_edata_get(e)->flags_remote)
   {
     cmd = mutt_buffer_new();
     if (!cmd)
@@ -2781,7 +2781,7 @@ static int imap_tags_commit(struct Context *ctx, struct Email *e, char *buf)
     mutt_buffer_addstr(cmd, "UID STORE ");
     mutt_buffer_addstr(cmd, uid);
     mutt_buffer_addstr(cmd, " -FLAGS.SILENT (");
-    mutt_buffer_addstr(cmd, IMAP_EDATA(e)->flags_remote);
+    mutt_buffer_addstr(cmd, imap_edata_get(e)->flags_remote);
     mutt_buffer_addstr(cmd, ")");
 
     /* Should we return here, or we are fine and we could
@@ -2824,8 +2824,8 @@ static int imap_tags_commit(struct Context *ctx, struct Email *e, char *buf)
   /* We are good sync them */
   mutt_debug(1, "NEW TAGS: %d\n", buf);
   driver_tags_replace(&e->tags, buf);
-  FREE(&IMAP_EDATA(e)->flags_remote);
-  IMAP_EDATA(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);
+  FREE(&imap_edata_get(e)->flags_remote);
+  imap_edata_get(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);
   return 0;
 }
 
index 676c068bd45dce367fdd8ddfc6d815c2433e378a..16111cb26dafb22a95e0d999528c36dc8affa2d9 100644 (file)
@@ -86,15 +86,15 @@ struct ImapMbox
 
 /* imap.c */
 int imap_access(const char *path);
-int imap_check_mailbox(struct Mailbox *mailbox, bool force);
-int imap_delete_mailbox(struct Mailbox *mailbox, struct ImapMbox *mx);
+int imap_check_mailbox(struct Mailbox *m, bool force);
+int imap_delete_mailbox(struct Mailbox *m, struct ImapMbox *mx);
 int imap_sync_mailbox(struct Context *ctx, bool expunge);
 int imap_mailbox_check(bool check_stats);
 int imap_status(const char *path, bool queue);
-int imap_search(struct Mailbox *mailbox, const struct Pattern *pat);
+int imap_search(struct Mailbox *m, const struct Pattern *pat);
 int imap_subscribe(char *path, bool subscribe);
 int imap_complete(char *buf, size_t buflen, char *path);
-int imap_fast_trash(struct Mailbox *mailbox, char *dest);
+int imap_fast_trash(struct Mailbox *m, char *dest);
 int imap_path_probe(const char *path, const struct stat *st);
 
 extern struct MxOps mx_imap_ops;
index ab8ad9c2684ec1f1a75105c1fd3ddd07be91fb97..9f10fd7b1cd7b43f868eb4567c1405949614c479 100644 (file)
@@ -320,7 +320,8 @@ int imap_exec(struct ImapAccountData *adata, const char *cmdstr, int flags);
 int imap_cmd_idle(struct ImapAccountData *adata);
 
 /* message.c */
-void imap_free_emaildata(void **data);
+void imap_edata_free(void **ptr);
+struct ImapEmailData *imap_edata_get(struct Email *e);
 int imap_read_headers(struct ImapAccountData *adata, unsigned int msn_begin, unsigned int msn_end, bool initial_download);
 char *imap_set_flags(struct ImapAccountData *adata, struct Email *e, char *s, int *server_changes);
 int imap_cache_del(struct ImapAccountData *adata, struct Email *e);
@@ -332,7 +333,7 @@ int imap_msg_close(struct Context *ctx, struct Message *msg);
 int imap_msg_commit(struct Context *ctx, struct Message *msg);
 
 /* util.c */
-struct ImapAccountData *imap_get_adata(struct Mailbox *m);
+struct ImapAccountData *imap_adata_get(struct Mailbox *m);
 #ifdef USE_HCACHE
 header_cache_t *imap_hcache_open(struct ImapAccountData *adata, const char *path);
 void imap_hcache_close(struct ImapAccountData *adata);
index 5f6f01ec0f0ec07709f581308d4ccd767ea055ef..e0230b0afd370b648c60aa0f73209c424fa8433a 100644 (file)
@@ -69,14 +69,41 @@ struct BodyCache;
 char *ImapHeaders; ///< Config: (imap) Additional email headers to download when getting index
 
 /**
- * new_emaildata - Create a new ImapEmailData
+ * imap_edata_free - free ImapHeader structure
+ * @retval ptr Private Email data
+ */
+void imap_edata_free(void **ptr)
+{
+  if (!ptr || !*ptr)
+    return;
+
+  struct ImapEmailData *edata = *ptr;
+  /* this should be safe even if the list wasn't used */
+  FREE(&edata->flags_system);
+  FREE(&edata->flags_remote);
+  FREE(ptr);
+}
+
+/**
+ * imap_edata_new - Create a new ImapEmailData
  * @retval ptr New ImapEmailData
  */
-static struct ImapEmailData *new_emaildata(void)
+static struct ImapEmailData *imap_edata_new(void)
 {
   return mutt_mem_calloc(1, sizeof(struct ImapEmailData));
 }
 
+/**
+ * imap_edata_get - Get the private data for this Email
+ * @retval ptr Private Email data
+ */
+struct ImapEmailData *imap_edata_get(struct Email *e)
+{
+  if (!e)
+    return NULL;
+  return e->edata;
+}
+
 /**
  * msg_cache_open - Open a message cache
  * @param adata Imap Account data
@@ -110,7 +137,7 @@ static FILE *msg_cache_get(struct ImapAccountData *adata, struct Email *e)
 
   adata->bcache = msg_cache_open(adata);
   char id[64];
-  snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, IMAP_EDATA(e)->uid);
+  snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, imap_edata_get(e)->uid);
   return mutt_bcache_get(adata->bcache, id);
 }
 
@@ -128,7 +155,7 @@ static FILE *msg_cache_put(struct ImapAccountData *adata, struct Email *e)
 
   adata->bcache = msg_cache_open(adata);
   char id[64];
-  snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, IMAP_EDATA(e)->uid);
+  snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, imap_edata_get(e)->uid);
   return mutt_bcache_put(adata->bcache, id);
 }
 
@@ -146,7 +173,7 @@ static int msg_cache_commit(struct ImapAccountData *adata, struct Email *e)
 
   adata->bcache = msg_cache_open(adata);
   char id[64];
-  snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, IMAP_EDATA(e)->uid);
+  snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, imap_edata_get(e)->uid);
 
   return mutt_bcache_commit(adata->bcache, id);
 }
@@ -377,31 +404,30 @@ static int msg_parse_fetch(struct ImapHeader *h, char *s)
 
 /**
  * msg_fetch_header - import IMAP FETCH response into an ImapHeader
- * @param mailbox Mailbox
- * @param h       ImapHeader
- * @param buf     Server string containing FETCH response
- * @param fp      Connection to server
+ * @param m   Mailbox
+ * @param ih  ImapHeader
+ * @param buf Server string containing FETCH response
+ * @param fp  Connection to server
  * @retval  0 Success
  * @retval -1 String is not a fetch response
  * @retval -2 String is a corrupt fetch response
  *
  * Expects string beginning with * n FETCH.
  */
-static int msg_fetch_header(struct Mailbox *mailbox, struct ImapHeader *h,
-                            char *buf, FILE *fp)
+static int msg_fetch_header(struct Mailbox *m, struct ImapHeader *ih, char *buf, FILE *fp)
 {
   unsigned int bytes;
   int rc = -1; /* default now is that string isn't FETCH response */
   int parse_rc;
 
-  struct ImapAccountData *adata = imap_get_adata(mailbox);
+  struct ImapAccountData *adata = imap_adata_get(m);
 
   if (buf[0] != '*')
     return rc;
 
   /* skip to message number */
   buf = imap_next_word(buf);
-  if (mutt_str_atoui(buf, &h->data->msn) < 0)
+  if (mutt_str_atoui(buf, &ih->data->msn) < 0)
     return rc;
 
   /* find FETCH tag */
@@ -417,7 +443,7 @@ static int msg_fetch_header(struct Mailbox *mailbox, struct ImapHeader *h,
 
   /* FIXME: current implementation - call msg_parse_fetch - if it returns -2,
    *   read header lines and call it again. Silly. */
-  parse_rc = msg_parse_fetch(h, buf);
+  parse_rc = msg_parse_fetch(ih, buf);
   if (!parse_rc)
     return 0;
   if (parse_rc != -2 || !fp)
@@ -434,7 +460,7 @@ static int msg_fetch_header(struct Mailbox *mailbox, struct ImapHeader *h,
     if (imap_cmd_step(adata) != IMAP_CMD_CONTINUE)
       return rc;
 
-    if (msg_parse_fetch(h, adata->buf) == -1)
+    if (msg_parse_fetch(ih, adata->buf) == -1)
       return rc;
   }
 
@@ -442,7 +468,7 @@ static int msg_fetch_header(struct Mailbox *mailbox, struct ImapHeader *h,
 
   /* subtract headers from message size - unfortunately only the subset of
    * headers we've requested. */
-  h->content_length -= bytes;
+  ih->content_length -= bytes;
 
   return rc;
 }
@@ -688,7 +714,7 @@ static int read_headers_normal_eval_cache(struct ImapAccountData *adata,
     mutt_progress_update(&progress, msgno, -1);
 
     memset(&h, 0, sizeof(h));
-    h.data = new_emaildata();
+    h.data = imap_edata_new();
     do
     {
       rc = imap_cmd_step(adata);
@@ -767,7 +793,7 @@ static int read_headers_normal_eval_cache(struct ImapAccountData *adata,
       }
     } while (mfhrc == -1);
 
-    imap_free_emaildata((void **) &h.data);
+    imap_edata_free((void **) &h.data);
 
     if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
       return -1;
@@ -817,9 +843,9 @@ static int read_headers_qresync_eval_cache(struct ImapAccountData *adata, char *
       if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
         mx_alloc_memory(ctx->mailbox);
 
-      struct ImapEmailData *edata = new_emaildata();
+      struct ImapEmailData *edata = imap_edata_new();
       e->edata = edata;
-      e->free_edata = imap_free_emaildata;
+      e->free_edata = imap_edata_free;
 
       e->index = ctx->mailbox->msg_count;
       e->active = true;
@@ -1016,7 +1042,7 @@ static int read_headers_fetch_new(struct ImapAccountData *adata, unsigned int ms
 
       rewind(fp);
       memset(&h, 0, sizeof(h));
-      h.data = new_emaildata();
+      h.data = imap_edata_new();
 
       /* this DO loop does two things:
        * 1. handles untagged messages, so we can try again on the same msg
@@ -1100,7 +1126,7 @@ static int read_headers_fetch_new(struct ImapAccountData *adata, unsigned int ms
         idx++;
       } while (mfhrc == -1);
 
-      imap_free_emaildata((void **) &h.data);
+      imap_edata_free((void **) &h.data);
 
       if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
         goto bail;
@@ -1353,7 +1379,7 @@ int imap_append_message(struct Context *ctx, struct Message *msg)
   struct ImapMbox mx;
   int rc;
 
-  struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+  struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
 
   if (imap_parse_path(ctx->mailbox->path, &mx))
     return -1;
@@ -1487,7 +1513,7 @@ int imap_copy_messages(struct Context *ctx, struct Email *e, char *dest, bool de
   int err_continue = MUTT_NO;
   int triedcreate = 0;
 
-  struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+  struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
 
   if (imap_parse_path(dest, &mx))
   {
@@ -1569,7 +1595,7 @@ int imap_copy_messages(struct Context *ctx, struct Email *e, char *dest, bool de
     else
     {
       mutt_message(_("Copying message %d to %s..."), e->index + 1, mbox);
-      mutt_buffer_add_printf(&cmd, "UID COPY %u %s", IMAP_EDATA(e)->uid, mmbox);
+      mutt_buffer_add_printf(&cmd, "UID COPY %u %s", imap_edata_get(e)->uid, mmbox);
 
       if (e->active && e->changed)
       {
@@ -1670,7 +1696,7 @@ int imap_cache_del(struct ImapAccountData *adata, struct Email *e)
 
   adata->bcache = msg_cache_open(adata);
   char id[64];
-  snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, IMAP_EDATA(e)->uid);
+  snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, imap_edata_get(e)->uid);
   return mutt_bcache_del(adata->bcache, id);
 }
 
@@ -1687,22 +1713,6 @@ int imap_cache_clean(struct ImapAccountData *adata)
   return 0;
 }
 
-/**
- * imap_free_emaildata - free ImapHeader structure
- * @param data Header data to free
- */
-void imap_free_emaildata(void **data)
-{
-  if (!data || !*data)
-    return;
-
-  struct ImapEmailData *edata = *data;
-  /* this should be safe even if the list wasn't used */
-  FREE(&edata->flags_system);
-  FREE(&edata->flags_remote);
-  FREE(data);
-}
-
 /**
  * imap_set_flags - fill the message header according to the server flags
  * @param[in]  adata          Imap Account data
@@ -1798,13 +1808,13 @@ int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno)
   bool fetched = false;
   int output_progress;
 
-  struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+  struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
   struct Email *e = ctx->mailbox->hdrs[msgno];
 
   msg->fp = msg_cache_get(adata, e);
   if (msg->fp)
   {
-    if (IMAP_EDATA(e)->parsed)
+    if (imap_edata_get(e)->parsed)
       return 0;
     else
       goto parsemsg;
@@ -1812,13 +1822,13 @@ int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno)
 
   /* we still do some caching even if imap_cachedir is unset */
   /* see if we already have the message in our cache */
-  cacheno = IMAP_EDATA(e)->uid % IMAP_CACHE_LEN;
+  cacheno = imap_edata_get(e)->uid % IMAP_CACHE_LEN;
   cache = &adata->cache[cacheno];
 
   if (cache->path)
   {
     /* don't treat cache errors as fatal, just fall back. */
-    if (cache->uid == IMAP_EDATA(e)->uid && (msg->fp = fopen(cache->path, "r")))
+    if (cache->uid == imap_edata_get(e)->uid && (msg->fp = fopen(cache->path, "r")))
       return 0;
     else
     {
@@ -1836,7 +1846,7 @@ int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno)
   msg->fp = msg_cache_put(adata, e);
   if (!msg->fp)
   {
-    cache->uid = IMAP_EDATA(e)->uid;
+    cache->uid = imap_edata_get(e)->uid;
     mutt_mktemp(path, sizeof(path));
     cache->path = mutt_str_strdup(path);
     msg->fp = mutt_file_fopen(path, "w+");
@@ -1852,7 +1862,7 @@ int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno)
    * command handler */
   e->active = false;
 
-  snprintf(buf, sizeof(buf), "UID FETCH %u %s", IMAP_EDATA(e)->uid,
+  snprintf(buf, sizeof(buf), "UID FETCH %u %s", imap_edata_get(e)->uid,
            (mutt_bit_isset(adata->capabilities, IMAP4REV1) ?
                 (ImapPeek ? "BODY.PEEK[]" : "BODY[]") :
                 "RFC822"));
@@ -1880,7 +1890,7 @@ int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno)
           pc = imap_next_word(pc);
           if (mutt_str_atoui(pc, &uid) < 0)
             goto bail;
-          if (uid != IMAP_EDATA(e)->uid)
+          if (uid != imap_edata_get(e)->uid)
           {
             mutt_error(_(
                 "The message index is incorrect. Try reopening the mailbox."));
@@ -1979,7 +1989,7 @@ parsemsg:
 
   mutt_clear_error();
   rewind(msg->fp);
-  IMAP_EDATA(e)->parsed = true;
+  imap_edata_get(e)->parsed = true;
 
   /* retry message parse if cached message is empty */
   if (!retried && ((e->lines == 0) || (e->content->length == 0)))
index f5826359c53c15fd3bfdd8590204b0d93324afec..571e936797d9bc7af97026d79d0aaf1b3534bfc3 100644 (file)
@@ -62,6 +62,4 @@ struct ImapHeader
   long content_length;
 };
 
-#define IMAP_EDATA(email) ((struct ImapEmailData *) ((email)->edata))
-
 #endif /* MUTT_IMAP_MESSAGE_H */
index a2ea02858ffcae920ed402b03a2cff267eab7e98..fa0afe84596d1c9976bb5e94669b420e5e58f742 100644 (file)
@@ -67,9 +67,48 @@ char *ImapDelimChars; ///< Config: (imap) Characters that denote separators in I
 short ImapPipelineDepth; ///< Config: (imap) Number of IMAP commands that may be queued up
 
 /**
- * imap_get_adata - Get the Account data for this mailbox
+ * imap_adata_free - Release and clear storage in an ImapAccountData structure
+ * @param ptr Imap Account data
+ */
+void imap_adata_free(void **ptr)
+{
+  if (!ptr || !*ptr)
+    return;
+
+  struct ImapAccountData *adata = *ptr;
+
+  FREE(&adata->capstr);
+  mutt_list_free(&adata->flags);
+  imap_mboxcache_free(adata);
+  mutt_buffer_free(&adata->cmdbuf);
+  FREE(&adata->buf);
+  mutt_bcache_close(&adata->bcache);
+  FREE(&adata->cmds);
+  FREE(ptr);
+}
+
+/**
+ * imap_adata_new - Allocate and initialise a new ImapAccountData structure
+ * @retval ptr New ImapAccountData
+ */
+struct ImapAccountData *imap_adata_new(void)
+{
+  struct ImapAccountData *adata = mutt_mem_calloc(1, sizeof(struct ImapAccountData));
+
+  adata->cmdbuf = mutt_buffer_new();
+  adata->cmdslots = ImapPipelineDepth + 2;
+  adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds));
+
+  STAILQ_INIT(&adata->flags);
+  STAILQ_INIT(&adata->mboxcache);
+
+  return adata;
+}
+
+/**
+ * imap_adata_get - Get the Account data for this mailbox
  */
-struct ImapAccountData *imap_get_adata(struct Mailbox *m)
+struct ImapAccountData *imap_adata_get(struct Mailbox *m)
 {
   if (!m || (m->magic != MUTT_IMAP))
     return NULL;
@@ -246,7 +285,7 @@ static void imap_msn_index_to_uid_seqset(struct Buffer *b, struct ImapAccountDat
     if (msn <= adata->max_msn)
     {
       struct Email *cur_header = adata->msn_index[msn - 1];
-      cur_uid = cur_header ? IMAP_EDATA(cur_header)->uid : 0;
+      cur_uid = cur_header ? imap_edata_get(cur_header)->uid : 0;
       if (!state || (cur_uid && ((cur_uid - 1) == last_uid)))
         match = true;
       last_uid = cur_uid;
@@ -389,7 +428,7 @@ int imap_hcache_put(struct ImapAccountData *adata, struct Email *e)
   if (!adata->hcache)
     return -1;
 
-  sprintf(key, "/%u", IMAP_EDATA(e)->uid);
+  sprintf(key, "/%u", imap_edata_get(e)->uid);
   return mutt_hcache_store(adata->hcache, key, imap_hcache_keylen(key), e, adata->uid_validity);
 }
 
@@ -715,45 +754,6 @@ void imap_error(const char *where, const char *msg)
   mutt_error("%s [%s]\n", where, msg);
 }
 
-/**
- * imap_adata_new - Allocate and initialise a new ImapAccountData structure
- * @retval ptr New ImapAccountData
- */
-struct ImapAccountData *imap_adata_new(void)
-{
-  struct ImapAccountData *adata = mutt_mem_calloc(1, sizeof(struct ImapAccountData));
-
-  adata->cmdbuf = mutt_buffer_new();
-  adata->cmdslots = ImapPipelineDepth + 2;
-  adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds));
-
-  STAILQ_INIT(&adata->flags);
-  STAILQ_INIT(&adata->mboxcache);
-
-  return adata;
-}
-
-/**
- * imap_adata_free - Release and clear storage in an ImapAccountData structure
- * @param ptr Imap Account data
- */
-void imap_adata_free(void **ptr)
-{
-  if (!ptr || !*ptr)
-    return;
-
-  struct ImapAccountData *adata = *ptr;
-
-  FREE(&adata->capstr);
-  mutt_list_free(&adata->flags);
-  imap_mboxcache_free(adata);
-  mutt_buffer_free(&adata->cmdbuf);
-  FREE(&adata->buf);
-  mutt_bcache_close(&adata->bcache);
-  FREE(&adata->cmds);
-  FREE(ptr);
-}
-
 /**
  * imap_fix_path - Fix up the imap path
  * @param adata   Imap Account data
@@ -1125,7 +1125,7 @@ void imap_allow_reopen(struct Mailbox *m)
 {
   if (!m)
     return;
-  struct ImapAccountData *adata = imap_get_adata(m);
+  struct ImapAccountData *adata = imap_adata_get(m);
   if (!adata)
     return;
 
@@ -1141,7 +1141,7 @@ void imap_disallow_reopen(struct Mailbox *m)
 {
   if (!m)
     return;
-  struct ImapAccountData *adata = imap_get_adata(m);
+  struct ImapAccountData *adata = imap_adata_get(m);
   if (!adata)
     return;