From: David Riebenbauer Date: Tue, 26 Jun 2012 18:48:48 +0000 (+0200) Subject: use the new notmuch api if available X-Git-Tag: neomutt-20160404~13^2~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=10f8a114cd04ba954d663865be9d558e72c23e09;p=neomutt use the new notmuch api if available As of notmuch 0.13 libnotmuch's api has changed. This makes use of it if the new api was detected. --- diff --git a/mutt_notmuch.c b/mutt_notmuch.c index e023ed3ff..f4c8cc089 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -187,7 +187,11 @@ static void free_ctxdata(struct nm_ctxdata *data) dprint(1, (debugfile, "nm: freeing context data %p\n", data)); if (data->db) +#ifdef NOTMUCH_API_3 + notmuch_database_destroy(data->db); +#else notmuch_database_close(data->db); +#endif data->db = NULL; FREE(&data->db_filename); @@ -368,13 +372,20 @@ static notmuch_database_t *do_database_open(const char *filename, { notmuch_database_t *db = NULL; unsigned int ct = 0; + int status = 0; dprint(1, (debugfile, "nm: db open '%s' %s (timeout %d)\n", filename, writable ? "[WRITE]" : "[READ]", NotmuchOpenTimeout)); do { +#ifdef NOTMUCH_API_3 + status = notmuch_database_open(filename, + writable ? NOTMUCH_DATABASE_MODE_READ_WRITE : + NOTMUCH_DATABASE_MODE_READ_ONLY, &db); +#else db = notmuch_database_open(filename, writable ? NOTMUCH_DATABASE_MODE_READ_WRITE : NOTMUCH_DATABASE_MODE_READ_ONLY); +#endif if (db || !NotmuchOpenTimeout || ct / 2 > NotmuchOpenTimeout) break; @@ -410,7 +421,11 @@ static int release_db(struct nm_ctxdata *data) { if (data && data->db) { dprint(1, (debugfile, "nm: db close\n")); +#ifdef NOTMUCH_API_3 + notmuch_database_destroy(data->db); +#else notmuch_database_close(data->db); +#endif data->db = NULL; data->longrun = FALSE; return 0;