]> granicus.if.org Git - neomutt/commitdiff
pop: refactor Email->edata
authorRichard Russon <rich@flatcap.org>
Sat, 12 Oct 2019 00:04:32 +0000 (01:04 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 14 Oct 2019 10:40:28 +0000 (11:40 +0100)
Use a wrapper function around Email->edata, like the other backends.

pop/pop.c
pop/pop_lib.c
pop/pop_private.h

index 74328d15ff2063adb34a73fac4e4493e51c97793..65104db03ac9dce899c0ad1b4c23c87102074f30 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -273,7 +273,7 @@ static int fetch_uidl(const char *line, void *data)
   int i;
   for (i = 0; i < m->msg_count; i++)
   {
-    struct PopEmailData *edata = m->emails[i]->edata;
+    struct PopEmailData *edata = pop_edata_get(m->emails[i]);
     if (mutt_str_strcmp(line, edata->uid) == 0)
       break;
   }
@@ -321,7 +321,7 @@ static int msg_cache_check(const char *id, struct BodyCache *bcache, void *data)
 
   for (int i = 0; i < m->msg_count; i++)
   {
-    struct PopEmailData *edata = m->emails[i]->edata;
+    struct PopEmailData *edata = pop_edata_get(m->emails[i]);
     /* if the id we get is known for a header: done (i.e. keep in cache) */
     if (edata->uid && (mutt_str_strcmp(edata->uid, id) == 0))
       return 0;
@@ -452,7 +452,7 @@ static int pop_fetch_headers(struct Mailbox *m)
     {
       if (!m->quiet)
         mutt_progress_update(&progress, i + 1 - old_count, -1);
-      struct PopEmailData *edata = m->emails[i]->edata;
+      struct PopEmailData *edata = pop_edata_get(m->emails[i]);
 #ifdef USE_HCACHE
       void *data = mutt_hcache_fetch(hc, edata->uid, strlen(edata->uid));
       if (data)
@@ -965,7 +965,7 @@ static int pop_mbox_sync(struct Mailbox *m, int *index_hint)
 
     for (i = 0, j = 0, rc = 0; (rc == 0) && (i < m->msg_count); i++)
     {
-      struct PopEmailData *edata = m->emails[i]->edata;
+      struct PopEmailData *edata = pop_edata_get(m->emails[i]);
       if (m->emails[i]->deleted && (m->emails[i]->refno != -1))
       {
         j++;
@@ -1059,7 +1059,7 @@ static int pop_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
   struct Progress progress;
   struct PopAccountData *adata = pop_adata_get(m);
   struct Email *e = m->emails[msgno];
-  struct PopEmailData *edata = e->edata;
+  struct PopEmailData *edata = pop_edata_get(e);
   bool bcache = true;
 
   /* see if we already have the message in body cache */
index 175b02ec5f3b3a1f038621d4fe77e7463602164a..4090c9b639f84c67e8950b95ed5a7910345250ef 100644 (file)
@@ -247,6 +247,17 @@ static int pop_capabilities(struct PopAccountData *adata, int mode)
   return 0;
 }
 
+/**
+ * pop_edata_get - Get the private data for this Email
+ * @retval ptr Private Email data
+ */
+struct PopEmailData *pop_edata_get(struct Email *e)
+{
+  if (!e)
+    return NULL;
+  return e->edata;
+}
+
 /**
  * pop_connect - Open connection
  * @param adata POP Account data
@@ -561,7 +572,7 @@ static int check_uidl(const char *line, void *data)
   struct Mailbox *m = data;
   for (int i = 0; i < m->msg_count; i++)
   {
-    struct PopEmailData *edata = m->emails[i]->edata;
+    struct PopEmailData *edata = pop_edata_get(m->emails[i]);
     if (mutt_str_strcmp(edata->uid, endp) == 0)
     {
       m->emails[i]->refno = index;
index 966389a316526f2a443219efab066e70d447bf8c..f94d17cee65f46f7703a5f38c7c4ae0ea861d681 100644 (file)
@@ -29,6 +29,7 @@
 #include "conn/conn.h"
 #include "mutt/mutt.h"
 
+struct Email;
 struct Mailbox;
 struct Progress;
 
@@ -143,5 +144,6 @@ int pop_fetch_data(struct PopAccountData *adata, const char *query,
 int pop_reconnect(struct Mailbox *m);
 void pop_logout(struct Mailbox *m);
 struct PopAccountData *pop_adata_get(struct Mailbox *m);
+struct PopEmailData *pop_edata_get(struct Email *e);
 
 #endif /* MUTT_POP_POP_PRIVATE_H */