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 428346DE1E4D for ; Sat, 18 Feb 2017 06:46:50 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 LckPxiqJTrXo for ; Sat, 18 Feb 2017 06:46:45 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id A71366DE1E2E for ; Sat, 18 Feb 2017 06:46:40 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cf6Gx-0004ZG-Dc; Sat, 18 Feb 2017 09:46:03 -0500 Received: (nullmailer pid 23034 invoked by uid 1000); Sat, 18 Feb 2017 14:46:33 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 7/8] lib: add notmuch_message_get_database to public API Date: Sat, 18 Feb 2017 10:45:50 -0400 Message-Id: <20170218144551.22925-8-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170218144551.22925-1-david@tethera.net> References: <20170218144551.22925-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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: Sat, 18 Feb 2017 14:46:50 -0000 This is to facilitate error handling, specifically retrieval of log messages from the notmuch database struct. --- lib/index.cc | 6 +++--- lib/message-property.cc | 4 ++-- lib/message.cc | 12 ++++++------ lib/notmuch-private.h | 2 -- lib/notmuch.h | 6 ++++++ 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/index.cc b/lib/index.cc index 8c145540..709b2ac4 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -314,7 +314,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; } @@ -345,7 +345,7 @@ _index_mime_part (notmuch_message_t *message, if (i == 1) continue; if (i > 1) - _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"); } if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) { @@ -369,7 +369,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; diff --git a/lib/message-property.cc b/lib/message-property.cc index e81843d3..54918be7 100644 --- a/lib/message-property.cc +++ b/lib/message-property.cc @@ -52,7 +52,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; @@ -99,7 +99,7 @@ notmuch_message_remove_all_properties (notmuch_message_t *message, const char *k 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 9ba24e8c..fee8fc24 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -260,7 +260,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; @@ -396,7 +396,7 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message) if (!message->in_reply_to) message->in_reply_to = talloc_strdup (message, ""); } catch (const Xapian::Error &error) { - _notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred fetching message metadata\n", + _notmuch_database_log(notmuch_message_get_database (message), "A Xapian exception occurred fetching message metadata\n", error.get_msg().c_str()); message->notmuch->exception_reported = TRUE; return NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION; @@ -480,7 +480,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 * @@ -510,7 +510,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; @@ -976,7 +976,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; @@ -1818,7 +1818,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; } diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 7b35fc5b..2cad0795 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -503,8 +503,6 @@ _notmuch_query_count_documents (notmuch_query_t *query, void _notmuch_message_add_reply (notmuch_message_t *message, notmuch_message_t *reply); -notmuch_database_t * -_notmuch_message_database (notmuch_message_t *message); /* sha1.c */ diff --git a/lib/notmuch.h b/lib/notmuch.h index 2e8ccb05..5fd85105 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -1662,6 +1662,12 @@ void notmuch_message_destroy (notmuch_message_t *message); /** + * Return the notmuch database of this message. + */ +notmuch_database_t * +notmuch_message_get_database (notmuch_message_t *message); + +/** * @name Message Properties * * This interface provides the ability to attach arbitrary (key,value) -- 2.11.0