]> granicus.if.org Git - neomutt/commitdiff
fix Notmuch deprecation warning
authorRichard Russon <rich@flatcap.org>
Fri, 23 Mar 2018 23:44:43 +0000 (23:44 +0000)
committerRichard Russon <rich@flatcap.org>
Tue, 27 Mar 2018 15:22:24 +0000 (16:22 +0100)
We need to distinguish between two versions of `notmuch.h`.
Both declare that they are v5.0.0.  They are:

- libnotmuch 5.0 (Notmuch 0.25)
  - `notmuch_database_add_message()` is a normal function
  - `notmuch_database_index_file()` doesn't exist

- libnotmuch 5.1 (Notmuch 0.26)
  - `notmuch_database_add_message()` is **deprecated**
  - `notmuch_database_index_file()` exists

To work around this, we check for `notmuch_database_index_file()` specifically.

auto.def
mutt_notmuch.c

index ae89a36cd1ac80bcce562e122b5696981090e2e8..1d492ff20567dbd25ff48274fe7f957d4b84fc52 100644 (file)
--- a/auto.def
+++ b/auto.def
@@ -429,17 +429,14 @@ if {[get-define want-notmuch]} {
   }
   define USE_NOTMUCH
   msg-checking "Checking for Notmuch API version 3..."
-  if {[cctest -includes {notmuch.h} \
-              -code {
-                notmuch_database_open("/path",
-                                      NOTMUCH_DATABASE_MODE_READ_ONLY,
-                                      (notmuch_database_t**)NULL);
-              }]} {
+  if {[cctest -includes {notmuch.h} -libs {-lnotmuch} -link 1 \
+      -code { notmuch_database_open(NULL, 0, NULL); }]} {
     define NOTMUCH_API_3
     msg-result "yes"
   } else {
     msg-result "no"
   }
+  cc-check-function-in-lib notmuch_database_index_file notmuch
 }
 
 ###############################################################################
index 02829f8b1fb57a838496f93be31c96f8019bbf5a..a2939aa86b9d7320de746e96513cefdfeb58c949 100644 (file)
@@ -1425,7 +1425,11 @@ static int rename_filename(struct NmCtxData *data, const char *old,
     return -1;
 
   mutt_debug(2, "nm: rename: add '%s'\n", new);
+#ifdef HAVE_NOTMUCH_DATABASE_INDEX_FILE
+  st = notmuch_database_index_file(db, new, NULL, &msg);
+#else
   st = notmuch_database_add_message(db, new, &msg);
+#endif
 
   if ((st != NOTMUCH_STATUS_SUCCESS) && (st != NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID))
   {
@@ -1460,7 +1464,11 @@ static int rename_filename(struct NmCtxData *data, const char *old,
         {
           mutt_debug(2, "nm: rename dup %s -> %s\n", path, newpath);
           notmuch_database_remove_message(db, path);
+#ifdef HAVE_NOTMUCH_DATABASE_INDEX_FILE
+          notmuch_database_index_file(db, newpath, NULL, NULL);
+#else
           notmuch_database_add_message(db, newpath, NULL);
+#endif
         }
       }
       notmuch_message_destroy(msg);
@@ -2007,7 +2015,11 @@ int nm_record_message(struct Context *ctx, char *path, struct Header *h)
   if (trans < 0)
     goto done;
 
+#ifdef HAVE_NOTMUCH_DATABASE_INDEX_FILE
+  st = notmuch_database_index_file(db, path, NULL, &msg);
+#else
   st = notmuch_database_add_message(db, path, &msg);
+#endif
 
   if ((st != NOTMUCH_STATUS_SUCCESS) && (st != NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID))
   {