lib: expose notmuch_message_get_database()

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.
This commit is contained in:
Daniel Kahn Gillmor 2018-05-11 02:57:52 -04:00 committed by David Bremner
parent 8a1eeecdfe
commit 9088db76d8
5 changed files with 22 additions and 16 deletions

View file

@ -385,7 +385,7 @@ _index_mime_part (notmuch_message_t *message,
const char *charset; const char *charset;
if (! part) { if (! part) {
_notmuch_database_log (_notmuch_message_database (message), _notmuch_database_log (notmuch_message_get_database (message),
"Warning: Not indexing empty mime part.\n"); "Warning: Not indexing empty mime part.\n");
return; return;
} }
@ -411,7 +411,7 @@ _index_mime_part (notmuch_message_t *message,
g_mime_multipart_get_part (multipart, i)); g_mime_multipart_get_part (multipart, i));
continue; continue;
} else if (i != GMIME_MULTIPART_SIGNED_CONTENT) { } 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"); "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)); GMIME_MULTIPART_ENCRYPTED (part));
} else { } else {
if (i != GMIME_MULTIPART_ENCRYPTED_VERSION) { 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"); "Warning: Unexpected extra parts of multipart/encrypted.\n");
} }
} }
@ -447,7 +447,7 @@ _index_mime_part (notmuch_message_t *message,
} }
if (! (GMIME_IS_PART (part))) { 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", "Warning: Not indexing unknown mime part: %s.\n",
g_type_name (G_OBJECT_TYPE (part))); g_type_name (G_OBJECT_TYPE (part)));
return; return;
@ -528,7 +528,7 @@ _index_encrypted_mime_part (notmuch_message_t *message,
if (!indexopts || (notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_FALSE)) if (!indexopts || (notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_FALSE))
return; return;
notmuch = _notmuch_message_database (message); notmuch = notmuch_message_get_database (message);
GMimeCryptoContext* crypto_ctx = NULL; GMimeCryptoContext* crypto_ctx = NULL;
#if (GMIME_MAJOR_VERSION < 3) #if (GMIME_MAJOR_VERSION < 3)

View file

@ -44,7 +44,7 @@ _notmuch_message_modify_property (notmuch_message_t *message, const char *key, c
notmuch_status_t status; notmuch_status_t status;
char *term = NULL; char *term = NULL;
status = _notmuch_database_ensure_writable (_notmuch_message_database (message)); status = _notmuch_database_ensure_writable (notmuch_message_get_database (message));
if (status) if (status)
return status; return status;
@ -92,7 +92,7 @@ _notmuch_message_remove_all_properties (notmuch_message_t *message, const char *
notmuch_status_t status; notmuch_status_t status;
const char * term_prefix; 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) if (status)
return status; return status;

View file

@ -268,7 +268,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch,
doc_id = _notmuch_database_generate_doc_id (notmuch); doc_id = _notmuch_database_generate_doc_id (notmuch);
} catch (const Xapian::Error &error) { } 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()); error.get_msg().c_str());
notmuch->exception_reported = true; notmuch->exception_reported = true;
*status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION; *status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
@ -512,7 +512,7 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)
return; return;
message->message_file = _notmuch_message_file_open_ctx ( message->message_file = _notmuch_message_file_open_ctx (
_notmuch_message_database (message), message, filename); notmuch_message_get_database (message), message, filename);
} }
const char * const char *
@ -542,7 +542,7 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header)
return talloc_strdup (message, value.c_str ()); return talloc_strdup (message, value.c_str ());
} catch (Xapian::Error &error) { } 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()); error.get_msg().c_str());
message->notmuch->exception_reported = true; message->notmuch->exception_reported = true;
return NULL; return NULL;
@ -663,7 +663,7 @@ _notmuch_message_remove_indexed_terms (notmuch_message_t *message)
notmuch_database_t *notmuch = message->notmuch; notmuch_database_t *notmuch = message->notmuch;
if (!notmuch->exception_reported) { 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()); error.get_msg().c_str());
notmuch->exception_reported = true; notmuch->exception_reported = true;
} }
@ -1059,7 +1059,7 @@ notmuch_message_get_date (notmuch_message_t *message)
try { try {
value = message->doc.get_value (NOTMUCH_VALUE_TIMESTAMP); value = message->doc.get_value (NOTMUCH_VALUE_TIMESTAMP);
} catch (Xapian::Error &error) { } 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()); error.get_msg().c_str());
message->notmuch->exception_reported = true; message->notmuch->exception_reported = true;
return 0; return 0;
@ -1925,7 +1925,7 @@ notmuch_message_destroy (notmuch_message_t *message)
} }
notmuch_database_t * notmuch_database_t *
_notmuch_message_database (notmuch_message_t *message) notmuch_message_get_database (notmuch_message_t *message)
{ {
return message->notmuch; return message->notmuch;
} }
@ -2002,7 +2002,7 @@ notmuch_message_reindex (notmuch_message_t *message,
/* strdup it because the metadata may be invalidated */ /* strdup it because the metadata may be invalidated */
orig_thread_id = talloc_strdup (message, orig_thread_id); 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); ret = _notmuch_database_ensure_writable (notmuch);
if (ret) if (ret)

View file

@ -532,8 +532,6 @@ _notmuch_message_id_parse (void *ctx, const char *message_id, const char **next)
void void
_notmuch_message_add_reply (notmuch_message_t *message, _notmuch_message_add_reply (notmuch_message_t *message,
notmuch_message_t *reply); notmuch_message_t *reply);
notmuch_database_t *
_notmuch_message_database (notmuch_message_t *message);
void void
_notmuch_message_remove_unprefixed_terms (notmuch_message_t *message); _notmuch_message_remove_unprefixed_terms (notmuch_message_t *message);

View file

@ -1345,6 +1345,14 @@ notmuch_messages_destroy (notmuch_messages_t *messages);
notmuch_tags_t * notmuch_tags_t *
notmuch_messages_collect_tags (notmuch_messages_t *messages); notmuch_messages_collect_tags (notmuch_messages_t *messages);
/**
* Get the database associated with this message.
*
* @since libnotmuch 5.2 (notmuch 0.27)
*/
notmuch_database_t *
notmuch_message_get_database (notmuch_message_t *message);
/** /**
* Get the message ID of 'message'. * Get the message ID of 'message'.
* *