From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id DE9D56DE0C6B for ; Mon, 11 Dec 2017 18:52:36 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.028 X-Spam-Level: X-Spam-Status: No, score=-0.028 tagged_above=-999 required=5 tests=[AWL=-0.028] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GTTGor0XFOwC for ; Mon, 11 Dec 2017 18:52:35 -0800 (PST) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id 85B3C6DE0B6D for ; Mon, 11 Dec 2017 18:52:33 -0800 (PST) Received: from fifthhorseman.net (unknown [38.109.115.130]) by che.mayfirst.org (Postfix) with ESMTPSA id 31CE8F9A0 for ; Mon, 11 Dec 2017 21:52:33 -0500 (EST) Received: by fifthhorseman.net (Postfix, from userid 1000) id DDC97208C5; Mon, 11 Dec 2017 21:52:27 -0500 (EST) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH 1/5] lib: expose notmuch_message_get_database() Date: Mon, 11 Dec 2017 21:52:21 -0500 Message-Id: <20171212025225.11854-2-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171212025225.11854-1-dkg@fifthhorseman.net> References: <20171212025225.11854-1-dkg@fifthhorseman.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2017 02:52:37 -0000 We've had _notmuch_message_database() internally for a while, and it's useful. It turns out to be useful on the other side of the library interface as well (i'll use it later in this series for "notmuch show"), so we expose it publicly now. --- lib/index.cc | 10 +++++----- lib/message-property.cc | 4 ++-- lib/message.cc | 14 +++++++------- lib/notmuch-private.h | 2 -- lib/notmuch.h | 8 ++++++++ 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/index.cc b/lib/index.cc index 0ad683fa..22ca9ec1 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -385,7 +385,7 @@ _index_mime_part (notmuch_message_t *message, const char *charset; if (! part) { - _notmuch_database_log (_notmuch_message_database (message), + _notmuch_database_log (notmuch_message_get_database (message), "Warning: Not indexing empty mime part.\n"); return; } @@ -411,7 +411,7 @@ _index_mime_part (notmuch_message_t *message, g_mime_multipart_get_part (multipart, i)); continue; } else if (i != GMIME_MULTIPART_SIGNED_CONTENT) { - _notmuch_database_log (_notmuch_message_database (message), + _notmuch_database_log (notmuch_message_get_database (message), "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n"); } } @@ -424,7 +424,7 @@ _index_mime_part (notmuch_message_t *message, GMIME_MULTIPART_ENCRYPTED (part)); } else { if (i != GMIME_MULTIPART_ENCRYPTED_VERSION) { - _notmuch_database_log (_notmuch_message_database (message), + _notmuch_database_log (notmuch_message_get_database (message), "Warning: Unexpected extra parts of multipart/encrypted.\n"); } } @@ -447,7 +447,7 @@ _index_mime_part (notmuch_message_t *message, } if (! (GMIME_IS_PART (part))) { - _notmuch_database_log (_notmuch_message_database (message), + _notmuch_database_log (notmuch_message_get_database (message), "Warning: Not indexing unknown mime part: %s.\n", g_type_name (G_OBJECT_TYPE (part))); return; @@ -528,7 +528,7 @@ _index_encrypted_mime_part (notmuch_message_t *message, if (!indexopts || (notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_FALSE)) return; - notmuch = _notmuch_message_database (message); + notmuch = notmuch_message_get_database (message); GMimeCryptoContext* crypto_ctx = NULL; #if (GMIME_MAJOR_VERSION < 3) diff --git a/lib/message-property.cc b/lib/message-property.cc index 35eaf3c6..2e44a386 100644 --- a/lib/message-property.cc +++ b/lib/message-property.cc @@ -44,7 +44,7 @@ _notmuch_message_modify_property (notmuch_message_t *message, const char *key, c notmuch_status_t status; char *term = NULL; - status = _notmuch_database_ensure_writable (_notmuch_message_database (message)); + status = _notmuch_database_ensure_writable (notmuch_message_get_database (message)); if (status) return status; @@ -92,7 +92,7 @@ _notmuch_message_remove_all_properties (notmuch_message_t *message, const char * notmuch_status_t status; const char * term_prefix; - status = _notmuch_database_ensure_writable (_notmuch_message_database (message)); + status = _notmuch_database_ensure_writable (notmuch_message_get_database (message)); if (status) return status; diff --git a/lib/message.cc b/lib/message.cc index d5db89b6..0886b22d 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -268,7 +268,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch, doc_id = _notmuch_database_generate_doc_id (notmuch); } catch (const Xapian::Error &error) { - _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred creating message: %s\n", + _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred creating message: %s\n", error.get_msg().c_str()); notmuch->exception_reported = true; *status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION; @@ -495,7 +495,7 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message) return; message->message_file = _notmuch_message_file_open_ctx ( - _notmuch_message_database (message), message, filename); + notmuch_message_get_database (message), message, filename); } const char * @@ -525,7 +525,7 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header) return talloc_strdup (message, value.c_str ()); } catch (Xapian::Error &error) { - _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading header: %s\n", + _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred when reading header: %s\n", error.get_msg().c_str()); message->notmuch->exception_reported = true; return NULL; @@ -646,7 +646,7 @@ _notmuch_message_remove_indexed_terms (notmuch_message_t *message) notmuch_database_t *notmuch = message->notmuch; if (!notmuch->exception_reported) { - _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred creating message: %s\n", + _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred creating message: %s\n", error.get_msg().c_str()); notmuch->exception_reported = true; } @@ -1042,7 +1042,7 @@ notmuch_message_get_date (notmuch_message_t *message) try { value = message->doc.get_value (NOTMUCH_VALUE_TIMESTAMP); } catch (Xapian::Error &error) { - _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading date: %s\n", + _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred when reading date: %s\n", error.get_msg().c_str()); message->notmuch->exception_reported = true; return 0; @@ -1908,7 +1908,7 @@ notmuch_message_destroy (notmuch_message_t *message) } notmuch_database_t * -_notmuch_message_database (notmuch_message_t *message) +notmuch_message_get_database (notmuch_message_t *message) { return message->notmuch; } @@ -1985,7 +1985,7 @@ notmuch_message_reindex (notmuch_message_t *message, /* strdup it because the metadata may be invalidated */ orig_thread_id = talloc_strdup (message, orig_thread_id); - notmuch = _notmuch_message_database (message); + notmuch = notmuch_message_get_database (message); ret = _notmuch_database_ensure_writable (notmuch); if (ret) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 1093429c..426c02a8 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -532,8 +532,6 @@ _notmuch_message_id_parse (void *ctx, const char *message_id, const char **next) void _notmuch_message_add_reply (notmuch_message_t *message, notmuch_message_t *reply); -notmuch_database_t * -_notmuch_message_database (notmuch_message_t *message); void _notmuch_message_remove_unprefixed_terms (notmuch_message_t *message); diff --git a/lib/notmuch.h b/lib/notmuch.h index 39759b7a..bcf9b68a 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -1345,6 +1345,14 @@ notmuch_messages_destroy (notmuch_messages_t *messages); notmuch_tags_t * notmuch_messages_collect_tags (notmuch_messages_t *messages); +/** + * Get the database associated with this message. + * + * @since libnotmuch 5.1 (notmuch 0.26) + */ +notmuch_database_t * +notmuch_message_get_database (notmuch_message_t *message); + /** * Get the message ID of 'message'. * -- 2.15.1