]> granicus.if.org Git - neomutt/commitdiff
eliminate Context from backends
authorRichard Russon <rich@flatcap.org>
Thu, 6 Sep 2018 22:51:41 +0000 (23:51 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 9 Sep 2018 15:11:20 +0000 (16:11 +0100)
16 files changed:
browser.c
compose.c
compress.c
curs_main.c
imap/imap.c
imap/message.c
imap/util.c
maildir/mh.c
main.c
mx.c
nntp/newsrc.c
nntp/nntp.c
nntp/nntp.h
notmuch/mutt_notmuch.h
pop/pop.c
sendlib.c

index c5fed1b8eec10f697445ce21dbbb4fd57615154e..26150e1132a1f3e447eb71c843117f669fd26b16 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -2158,9 +2158,9 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int
             break;
 
           if (i == OP_CATCHUP)
-            nntp_data = mutt_newsgroup_catchup(CurrentNewsSrv, ff->name);
+            nntp_data = mutt_newsgroup_catchup(Context, CurrentNewsSrv, ff->name);
           else
-            nntp_data = mutt_newsgroup_uncatchup(CurrentNewsSrv, ff->name);
+            nntp_data = mutt_newsgroup_uncatchup(Context, CurrentNewsSrv, ff->name);
 
           if (nntp_data)
           {
index 3029106f86071a89b561ab8ecdf0a650a753f4ff..415d67445ce1c9d65364d11d69734e1e2ee3f52b 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -1408,7 +1408,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen,
         OptNews = false;
         if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE)
         {
-          CurrentNewsSrv = nntp_select_server(NewsServer, false);
+          CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
           if (!CurrentNewsSrv)
             break;
 
index 4af95ab6c6f238306f00c11c97ae30afcebfda09..d41376fdca7f2b653f3fe786f1e3cfe397e5ae4c 100644 (file)
@@ -59,7 +59,7 @@ struct Header;
 /**
  * struct CompressInfo - Private data for compress
  *
- * This object gets attached to the mailbox's Context.
+ * This object gets attached to the Mailbox.
  */
 struct CompressInfo
 {
index 5ed63927f528bfa6724ee4469dc89788a7c8b4e3..c4fb790aed7140d32640d0de6b940f9b3c152ed9 100644 (file)
@@ -2210,7 +2210,7 @@ int mutt_index_menu(void)
           if (op == OP_MAIN_CHANGE_GROUP || op == OP_MAIN_CHANGE_GROUP_READONLY)
           {
             OptNews = true;
-            CurrentNewsSrv = nntp_select_server(NewsServer, false);
+            CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
             if (!CurrentNewsSrv)
               break;
             if (flags)
@@ -3010,7 +3010,7 @@ int mutt_index_menu(void)
         if (Context && Context->mailbox->magic == MUTT_NNTP)
         {
           struct NntpData *nntp_data = Context->mailbox->data;
-          if (mutt_newsgroup_catchup(nntp_data->nserv, nntp_data->group))
+          if (mutt_newsgroup_catchup(Context, nntp_data->nserv, nntp_data->group))
             menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
         }
         break;
index ddc9b12328dce67352af55149bab2cf971272965..fe4302ddf3a9c98a07d78efc65816b13019dd036 100644 (file)
@@ -2372,7 +2372,7 @@ static int imap_msg_open_new(struct Context *ctx, struct Message *msg, struct He
 
 /**
  * imap_mbox_check - Implements MxOps::mbox_check()
- * @param ctx        Context
+ * @param ctx        Mailbox
  * @param index_hint Remember our place in the index
  * @retval >0 Success, e.g. #MUTT_REOPENED
  * @retval -1 Failure
@@ -2391,7 +2391,7 @@ static int imap_mbox_check(struct Context *ctx, int *index_hint)
 
 /**
  * imap_sync_mailbox - Sync all the changes to the server
- * @param ctx     Context
+ * @param ctx     Mailbox
  * @param expunge if true do expunge
  * @retval  0 Success
  * @retval -1 Error
index 7daf19a0b4bf6c12d7c1215b420ecaa354d52315..7c855487baf5199005f13f597af284ec70523631 100644 (file)
@@ -601,7 +601,7 @@ static void imap_fetch_msn_seqset(struct Buffer *b, struct ImapData *idata,
 
 /**
  * set_changed_flag - Have the flags of an email changed
- * @param[in]  ctx            Context
+ * @param[in]  ctx            Mailbox
  * @param[in]  h              Email Header
  * @param[in]  local_changes  Has the local mailbox been changed?
  * @param[out] server_changes Set to 1 if the flag has changed
@@ -1587,7 +1587,7 @@ int imap_msg_commit(struct Context *ctx, struct Message *msg)
 
 /**
  * imap_append_message - Write an email back to the server
- * @param ctx Context
+ * @param ctx Mailbox
  * @param msg Message to save
  * @retval  0 Success
  * @retval -1 Failure
@@ -1722,7 +1722,7 @@ fail:
 
 /**
  * imap_copy_messages - Server COPY messages to another folder
- * @param ctx    Context
+ * @param ctx    Mailbox
  * @param h      Header of the email
  * @param dest   Destination folder
  * @param delete Delete the original?
index 04b2855a944805aa217e5c857a29b17a24699e9c..801a7dfe4de9fc3ecb9fc4ed5bc706f4c3ddf37c 100644 (file)
@@ -1103,7 +1103,7 @@ int imap_wait_keepalive(pid_t pid)
 
 /**
  * imap_allow_reopen - Allow re-opening a folder upon expunge
- * @param ctx Context
+ * @param ctx Mailbox
  */
 void imap_allow_reopen(struct Context *ctx)
 {
@@ -1118,7 +1118,7 @@ void imap_allow_reopen(struct Context *ctx)
 
 /**
  * imap_disallow_reopen - Disallow re-opening a folder upon expunge
- * @param ctx Context
+ * @param ctx Mailbox
  */
 void imap_disallow_reopen(struct Context *ctx)
 {
index 81e194260c1a17add780c5fae7e3dbbca593ee2a..8183dfcfc3cb58e9437f5d74ea011f77c8a15458 100644 (file)
@@ -1022,7 +1022,7 @@ static int maildir_parse_dir(struct Mailbox *mailbox, struct Maildir ***last,
 }
 
 /**
- * maildir_add_to_context - Add the Maildir list to the Context
+ * maildir_add_to_context - Add the Maildir list to the Mailbox
  * @param ctx Mailbox
  * @param md  Maildir list to copy
  * @retval true If there's new mail
@@ -1063,7 +1063,7 @@ static bool maildir_add_to_context(struct Context *ctx, struct Maildir *md)
 }
 
 /**
- * maildir_move_to_context - Copy the Maildir list to the Context
+ * maildir_move_to_context - Copy the Maildir list to the Mailbox
  * @param ctx Mailbox
  * @param md  Maildir list to copy, then free
  * @retval 1 If there's new mail
@@ -2276,7 +2276,7 @@ static char *maildir_canon_filename(const char *src, char *buf, size_t buflen)
 }
 
 /**
- * maildir_update_tables - Update the Context Header tables
+ * maildir_update_tables - Update the Header tables
  * @param ctx        Mailbox
  * @param index_hint Current email in index
  */
diff --git a/main.c b/main.c
index 45cd5f05180c9ad41bafc315c3777ee856cfc65e..b7a3fd997e50a97276f1611eacfb67f7736904f1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1144,7 +1144,7 @@ int main(int argc, char *argv[], char *envp[])
       if (flags & MUTT_NEWS)
       {
         OptNews = true;
-        CurrentNewsSrv = nntp_select_server(NewsServer, false);
+        CurrentNewsSrv = nntp_select_server(Context, NewsServer, false);
         if (!CurrentNewsSrv)
           goto main_curses; // TEST38: neomutt -G (unset news_server)
       }
diff --git a/mx.c b/mx.c
index 93ac1bb4843e864db14440036304f924f8305ec2..ab5053f045ec3bdf7d84ad10616dbb235881707e 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -527,7 +527,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint)
         return -1;
       }
       else if (rc == MUTT_YES)
-        mutt_newsgroup_catchup(nntp_data->nserv, nntp_data->group);
+        mutt_newsgroup_catchup(Context, nntp_data->nserv, nntp_data->group);
     }
   }
 #endif
index 324b81df5310971a8c63028cf5ced88894873cb9..86c318081346e9e4060b2c3031332a16c8cc9d0d 100644 (file)
@@ -999,6 +999,7 @@ const char *nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char
 
 /**
  * nntp_select_server - Open a connection to an NNTP server
+ * @param ctx        Mailbox
  * @param server     Server URI
  * @param leave_lock Leave the server locked?
  * @retval ptr  NNTP server
@@ -1009,7 +1010,7 @@ const char *nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char
  * system has broken mtimes, this might mean the file is reloaded every time,
  * which we'd have to fix.
  */
-struct NntpServer *nntp_select_server(char *server, bool leave_lock)
+struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool leave_lock)
 {
   char file[PATH_MAX];
 #ifdef USE_HCACHE
@@ -1072,7 +1073,7 @@ struct NntpServer *nntp_select_server(char *server, bool leave_lock)
       return NULL;
 
     /* check for new newsgroups */
-    if (!leave_lock && nntp_check_new_groups(Context->mailbox, nserv) < 0)
+    if (!leave_lock && nntp_check_new_groups(ctx->mailbox, nserv) < 0)
       rc = -1;
 
     /* .newsrc has been externally modified */
@@ -1118,7 +1119,7 @@ struct NntpServer *nntp_select_server(char *server, bool leave_lock)
   {
     /* try to load list of newsgroups from cache */
     if (nserv->cacheable && active_get_cache(nserv) == 0)
-      rc = nntp_check_new_groups(Context->mailbox, nserv);
+      rc = nntp_check_new_groups(ctx->mailbox, nserv);
 
     /* load list of newsgroups from server */
     else
@@ -1300,12 +1301,14 @@ struct NntpData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *grou
 
 /**
  * mutt_newsgroup_catchup - Catchup newsgroup
+ * @param ctx   Mailbox
  * @param nserv NNTP server
  * @param group Newsgroup
  * @retval ptr  NNTP data
  * @retval NULL Error
  */
-struct NntpData *mutt_newsgroup_catchup(struct NntpServer *nserv, char *group)
+struct NntpData *mutt_newsgroup_catchup(struct Context *ctx,
+                                        struct NntpServer *nserv, char *group)
 {
   struct NntpData *nntp_data = NULL;
 
@@ -1324,22 +1327,24 @@ struct NntpData *mutt_newsgroup_catchup(struct NntpServer *nserv, char *group)
     nntp_data->newsrc_ent[0].last = nntp_data->last_message;
   }
   nntp_data->unread = 0;
-  if (Context && Context->mailbox->data == nntp_data)
+  if (ctx && ctx->mailbox->data == nntp_data)
   {
-    for (unsigned int i = 0; i < Context->mailbox->msg_count; i++)
-      mutt_set_flag(Context, Context->mailbox->hdrs[i], MUTT_READ, 1);
+    for (unsigned int i = 0; i < ctx->mailbox->msg_count; i++)
+      mutt_set_flag(ctx, ctx->mailbox->hdrs[i], MUTT_READ, 1);
   }
   return nntp_data;
 }
 
 /**
  * mutt_newsgroup_uncatchup - Uncatchup newsgroup
+ * @param ctx   Mailbox
  * @param nserv NNTP server
  * @param group Newsgroup
  * @retval ptr  NNTP data
  * @retval NULL Error
  */
-struct NntpData *mutt_newsgroup_uncatchup(struct NntpServer *nserv, char *group)
+struct NntpData *mutt_newsgroup_uncatchup(struct Context *ctx,
+                                          struct NntpServer *nserv, char *group)
 {
   struct NntpData *nntp_data = NULL;
 
@@ -1357,11 +1362,11 @@ struct NntpData *mutt_newsgroup_uncatchup(struct NntpServer *nserv, char *group)
     nntp_data->newsrc_ent[0].first = 1;
     nntp_data->newsrc_ent[0].last = nntp_data->first_message - 1;
   }
-  if (Context && Context->mailbox->data == nntp_data)
+  if (ctx && ctx->mailbox->data == nntp_data)
   {
-    nntp_data->unread = Context->mailbox->msg_count;
-    for (unsigned int i = 0; i < Context->mailbox->msg_count; i++)
-      mutt_set_flag(Context, Context->mailbox->hdrs[i], MUTT_READ, 0);
+    nntp_data->unread = ctx->mailbox->msg_count;
+    for (unsigned int i = 0; i < ctx->mailbox->msg_count; i++)
+      mutt_set_flag(ctx, ctx->mailbox->hdrs[i], MUTT_READ, 0);
   }
   else
   {
index 73b26384301489c939469a98b83387aea3382a0e..e24487bd7088c850119c935857df0fd4e0662e1e 100644 (file)
@@ -1531,7 +1531,7 @@ static int nntp_mbox_open(struct Context *ctx)
   group = url.path;
   url.path = strchr(url.path, '\0');
   url_tostring(&url, server, sizeof(server), 0);
-  nserv = nntp_select_server(server, true);
+  nserv = nntp_select_server(ctx, server, true);
   url_free(&url);
   if (!nserv)
     return -1;
@@ -1775,22 +1775,22 @@ static int nntp_msg_close(struct Context *ctx, struct Message *msg)
 
 /**
  * nntp_post - Post article
- * @param mailbox Mailbox
- * @param msg     Message to post
+ * @param ctx Mailbox
+ * @param msg Message to post
  * @retval  0 Success
  * @retval -1 Failure
  */
-int nntp_post(struct Mailbox *mailbox, const char *msg)
+int nntp_post(struct Context *ctx, const char *msg)
 {
   struct NntpData *nntp_data = NULL;
   struct NntpData nntp_tmp = { 0 };
   char buf[LONG_STRING];
 
-  if (mailbox && (mailbox->magic == MUTT_NNTP))
-    nntp_data = mailbox->data;
+  if (ctx && (ctx->mailbox->magic == MUTT_NNTP))
+    nntp_data = ctx->mailbox->data;
   else
   {
-    CurrentNewsSrv = nntp_select_server(NewsServer, false);
+    CurrentNewsSrv = nntp_select_server(ctx, NewsServer, false);
     if (!CurrentNewsSrv)
       return -1;
 
index cedee4fe346bea6629d4acbc98a9ab9bf137ffb0..18f20ea55eed275487b95516145d97d0e990054e 100644 (file)
@@ -150,14 +150,14 @@ struct NntpData
   struct BodyCache *bcache;
 };
 
-struct NntpServer *nntp_select_server(char *server, bool leave_lock);
+struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool leave_lock);
 struct NntpData *mutt_newsgroup_subscribe(struct NntpServer *nserv, char *group);
 struct NntpData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *group);
-struct NntpData *mutt_newsgroup_catchup(struct NntpServer *nserv, char *group);
-struct NntpData *mutt_newsgroup_uncatchup(struct NntpServer *nserv, char *group);
+struct NntpData *mutt_newsgroup_catchup(struct Context *ctx, struct NntpServer *nserv, char *group);
+struct NntpData *mutt_newsgroup_uncatchup(struct Context *ctx, struct NntpServer *nserv, char *group);
 int nntp_active_fetch(struct NntpServer *nserv, bool new);
 int nntp_newsrc_update(struct NntpServer *nserv);
-int nntp_post(struct Mailbox *mailbox, const char *msg);
+int nntp_post(struct Context *ctx, const char *msg);
 int nntp_check_msgid(struct Context *ctx, const char *msgid);
 int nntp_check_children(struct Context *ctx, const char *msgid);
 int nntp_newsrc_parse(struct NntpServer *nserv);
index 0e52b63257ec7a3c6243439c0c5f9698d88c8b40..bf804e4bd4dc1077d6ff71546ea0aab7d9da739f 100644 (file)
@@ -74,7 +74,7 @@ void nm_debug_check(struct Mailbox *mailbox);
 int nm_get_all_tags(struct Mailbox *mailbox, char **tag_list, int *tag_count);
 
 /*
- * functions usable outside notmuch Context
+ * functions usable outside of notmuch
  */
 int nm_nonctx_get_count(char *path, int *all, int *new);
 int nm_path_probe(const char *path, const struct stat *st);
index e2db606270d70d0c363b4276e4f15881ecd6c13e..392b028e619787df54765c134ddd1f487b2a9bca 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -195,7 +195,7 @@ static int pop_read_header(struct PopData *pop_data, struct Header *h)
 /**
  * fetch_uidl - parse UIDL
  * @param line String to parse
- * @param data Mailbox Context
+ * @param data Mailbox
  * @retval  0 Success
  * @retval -1 Failure
  */
@@ -305,7 +305,7 @@ static header_cache_t *pop_hcache_open(struct PopData *pop_data, const char *pat
 
 /**
  * pop_fetch_headers - Read headers
- * @param ctx Context
+ * @param ctx Mailbox
  * @retval  0 Success
  * @retval -1 Connection lost
  * @retval -2 Invalid command or execution error
@@ -477,7 +477,7 @@ static int pop_fetch_headers(struct Context *ctx)
 
 /**
  * pop_mbox_open - open POP mailbox, fetch only headers
- * @param ctx Mailbox Context
+ * @param ctx Mailbox
  * @retval  0 Success
  * @retval -1 Failure
  */
@@ -571,7 +571,7 @@ static void pop_clear_cache(struct PopData *pop_data)
 
 /**
  * pop_mbox_close - close POP mailbox
- * @param ctx Mailbox Context
+ * @param ctx Mailbox
  * @retval 0 Always
  */
 static int pop_mbox_close(struct Context *ctx)
@@ -601,7 +601,7 @@ static int pop_mbox_close(struct Context *ctx)
 
 /**
  * pop_msg_open - fetch message from POP server
- * @param ctx   Mailbox Context
+ * @param ctx   Mailbox
  * @param msg   Message
  * @param msgno Message number
  * @retval  0 Success
@@ -752,7 +752,7 @@ static int pop_msg_open(struct Context *ctx, struct Message *msg, int msgno)
 
 /**
  * pop_msg_close - Close POP Message
- * @param ctx Mailbox Context
+ * @param ctx Mailbox
  * @param msg Message
  * @retval 0   Success
  * @retval EOF Error, see errno
@@ -764,7 +764,7 @@ static int pop_msg_close(struct Context *ctx, struct Message *msg)
 
 /**
  * pop_mbox_sync - update POP mailbox, delete messages from server
- * @param ctx        Mailbox Context
+ * @param ctx        Mailbox
  * @param index_hint Current Message
  * @retval  0 Success
  * @retval -1 Failure
@@ -849,7 +849,7 @@ static int pop_mbox_sync(struct Context *ctx, int *index_hint)
 
 /**
  * pop_mbox_check - Check for new messages and fetch headers
- * @param ctx        Mailbox Context
+ * @param ctx        Mailbox
  * @param index_hint Current Message
  * @retval  0 Success
  * @retval -1 Failure
index fb3769c4978e7559cde35763eb81628d9530c3fe..27f01f9df8316a9166d1a3e54e605788a133c365 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -2716,7 +2716,7 @@ int mutt_invoke_sendmail(struct Address *from, struct Address *to, struct Addres
                         NONULL(Inews), nntp_format_str, 0, 0);
     if (!*cmd)
     {
-      i = nntp_post(Context->mailbox, msg);
+      i = nntp_post(Context, msg);
       unlink(msg);
       return i;
     }