]> granicus.if.org Git - neomutt/commitdiff
mbox_check: use mailbox notifications
authorRichard Russon <rich@flatcap.org>
Mon, 24 Dec 2018 11:50:31 +0000 (11:50 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 5 Jan 2019 14:44:35 +0000 (14:44 +0000)
maildir/maildir.c
maildir/mh.c
mbox/mbox.c
nntp/nntp.c
notmuch/mutt_notmuch.c
pop/pop.c

index 65003edf7a7b8ddf8e011eab6def31a393b7e1f5..5a63e8d01f4089ab6c8734d9eff5229636d9eecb 100644 (file)
@@ -516,7 +516,7 @@ int maildir_mbox_check(struct Context *ctx, int *index_hint)
 
   /* If we didn't just get new mail, update the tables. */
   if (occult)
-    maildir_update_tables(ctx, index_hint);
+    mutt_mailbox_changed(m, MBN_RESORT);
 
   /* do any delayed parsing we need to do. */
   maildir_delayed_parsing(m, &md, NULL);
@@ -524,7 +524,7 @@ int maildir_mbox_check(struct Context *ctx, int *index_hint)
   /* Incorporate new messages */
   num_new = maildir_move_to_context(m, &md);
   if (num_new > 0)
-    mx_update_context(ctx);
+    mutt_mailbox_changed(m, MBN_INVALID);
 
   mutt_buffer_pool_release(&buf);
 
index 72aba93b31696757ae815b76a659e1e03997d2ac..5d93776fbbd9d9b0708f771790a571dfdba8f1c5 100644 (file)
@@ -705,12 +705,12 @@ int mh_mbox_check(struct Context *ctx, int *index_hint)
 
   /* If we didn't just get new mail, update the tables. */
   if (occult)
-    maildir_update_tables(ctx, index_hint);
+    mutt_mailbox_changed(m, MBN_RESORT);
 
   /* Incorporate new messages */
   num_new = maildir_move_to_context(m, &md);
   if (num_new > 0)
-    mx_update_context(ctx);
+    mutt_mailbox_changed(m, MBN_INVALID);
 
   if (occult)
     return MUTT_REOPENED;
index bd133d96dc8f12706bcfd4a862acfbe0aec2e199..99e121b197a0f2195689641f06d778f7bf173319 100644 (file)
@@ -549,18 +549,16 @@ static int mbox_parse_mailbox(struct Mailbox *m)
 
 /**
  * reopen_mailbox - Close and reopen a mailbox
- * @param ctx        Mailbox
+ * @param m          Mailbox
  * @param index_hint Current email
  * @retval >0 Success, e.g. #MUTT_REOPENED, #MUTT_NEW_MAIL
  * @retval -1 Error
  */
-static int reopen_mailbox(struct Context *ctx, int *index_hint)
+static int reopen_mailbox(struct Mailbox *m, int *index_hint)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   struct MboxAccountData *adata = mbox_adata_get(m);
   if (!adata)
     return -1;
@@ -586,7 +584,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
 
     old_sort = Sort;
     Sort = SORT_ORDER;
-    mutt_sort_headers(ctx, true);
+    mutt_mailbox_changed(m, MBN_RESORT);
     Sort = old_sort;
   }
 
@@ -594,10 +592,10 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
   old_msgcount = 0;
 
   /* simulate a close */
+  mutt_mailbox_changed(m, MBN_CLOSED);
   mutt_hash_free(&m->id_hash);
   mutt_hash_free(&m->subj_hash);
   mutt_hash_free(&m->label_hash);
-  mutt_clear_threads(ctx);
   FREE(&m->v2r);
   if (m->readonly)
   {
@@ -616,7 +614,6 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
   m->email_max = 0; /* force allocation of new headers */
   m->msg_count = 0;
   m->vcount = 0;
-  ctx->vsize = 0;
   m->msg_tagged = 0;
   m->msg_deleted = 0;
   m->msg_new = 0;
@@ -1018,7 +1015,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
   {
     if (mbox_mbox_open(m) < 0)
       return -1;
-    mx_update_context(ctx);
+    mutt_mailbox_changed(m, MBN_INVALID);
   }
 
   struct stat st;
@@ -1081,7 +1078,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
             mmdf_parse_mailbox(m);
 
           if (m->msg_count > old_msg_count)
-            mx_update_context(ctx);
+            mutt_mailbox_changed(m, MBN_INVALID);
 
           /* Only unlock the folder if it was locked inside of this routine.
            * It may have been locked elsewhere, like in
@@ -1109,9 +1106,9 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
 
   if (modified)
   {
-    if (reopen_mailbox(ctx, index_hint) != -1)
+    if (reopen_mailbox(m, index_hint) != -1)
     {
-      mx_update_context(ctx);
+      mutt_mailbox_changed(m, MBN_INVALID);
       if (unlock)
       {
         mbox_unlock_mailbox(m);
index bced2fe5156b05de1c5d3701c1711d7f0b091ac8..8220ef5f31b33b69f8bbeaaebc568a1af284575f 100644 (file)
@@ -1522,7 +1522,7 @@ static int nntp_group_poll(struct NntpMboxData *mdata, bool update_stat)
 
 /**
  * check_mailbox - Check current newsgroup for new articles
- * @param ctx Mailbox
+ * @param m Mailbox
  * @retval #MUTT_REOPENED Articles have been renumbered or removed from server
  * @retval #MUTT_NEW_MAIL New articles found
  * @retval  0             No change
@@ -1530,13 +1530,11 @@ static int nntp_group_poll(struct NntpMboxData *mdata, bool update_stat)
  *
  * Leave newsrc locked
  */
-static int check_mailbox(struct Context *ctx)
+static int check_mailbox(struct Mailbox *m)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   struct NntpMboxData *mdata = m->mdata;
   struct NntpAccountData *adata = mdata->adata;
   time_t now = time(NULL);
@@ -1698,9 +1696,7 @@ static int check_mailbox(struct Context *ctx)
 
   /* some headers were removed, context must be updated */
   if (ret == MUTT_REOPENED)
-  {
-    mx_update_context(ctx);
-  }
+    mutt_mailbox_changed(m, MBN_INVALID);
 
   /* fetch headers of new articles */
   if (mdata->last_message > mdata->last_loaded)
@@ -1721,7 +1717,7 @@ static int check_mailbox(struct Context *ctx)
     if (rc == 0)
     {
       if (m->msg_count > old_msg_count)
-        mx_update_context(ctx);
+        mutt_mailbox_changed(m, MBN_INVALID);
       mdata->last_loaded = mdata->last_message;
     }
     if (ret == 0 && m->msg_count > oldmsgcount)
@@ -2597,7 +2593,7 @@ static int nntp_mbox_check(struct Context *ctx, int *index_hint)
 
   struct Mailbox *m = ctx->mailbox;
 
-  int ret = check_mailbox(ctx);
+  int ret = check_mailbox(m);
   if (ret == 0)
   {
     struct NntpMboxData *mdata = m->mdata;
@@ -2627,7 +2623,7 @@ static int nntp_mbox_sync(struct Context *ctx, int *index_hint)
 
   /* check for new articles */
   mdata->adata->check_time = 0;
-  rc = check_mailbox(ctx);
+  rc = check_mailbox(m);
   if (rc)
     return rc;
 
index 4f2a7b7ea085dbd957a124b6bf28458c05c58ece..8a051d1979ae7505cdb4c9ec7c53c29f8f35967d 100644 (file)
@@ -2277,7 +2277,7 @@ static int nm_mbox_check(struct Context *ctx, int *index_hint)
   }
 
   if (m->msg_count > mdata->oldmsgcount)
-    mx_update_context(ctx);
+    mutt_mailbox_changed(m, MBN_INVALID);
 done:
   if (q)
     notmuch_query_destroy(q);
index 3ec37eeeb1dbcd34e7bb91f1e549e5e42b5f2b97..cdd0cd8812badadbabc5a4023a4b6498c3f05a4d 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -917,7 +917,7 @@ static int pop_mbox_check(struct Context *ctx, int *index_hint)
   int ret = pop_fetch_headers(m);
   pop_clear_cache(adata);
   if (m->msg_count > old_msg_count)
-    mx_update_context(ctx);
+    mutt_mailbox_changed(m, MBN_INVALID);
 
   if (ret < 0)
     return -1;