From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KGJLEYZIHWAeTAAA0tVLHw (envelope-from ) for ; Fri, 05 Feb 2021 13:30:46 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qAE/DYZIHWCRJwAA1q6Kng (envelope-from ) for ; Fri, 05 Feb 2021 13:30:46 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CBEC6940309 for ; Fri, 5 Feb 2021 13:30:45 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 1A2CA26876; Fri, 5 Feb 2021 08:28:29 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id F00501FD07 for ; Fri, 5 Feb 2021 08:27:36 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id E8AFC6067F; Fri, 5 Feb 2021 08:27:36 -0500 (EST) Received: (nullmailer pid 3258433 invoked by uid 1000); Fri, 05 Feb 2021 13:27:02 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 29/39] lib: add NOTMUCH_STATUS_NO_CONFIG Date: Fri, 5 Feb 2021 09:26:44 -0400 Message-Id: <20210205132654.3258292-30-david@tethera.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205132654.3258292-1-david@tethera.net> References: <20210205132654.3258292-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: CYXGUFKOMIR6YFLO44MFLK5V2SXGCFF2 X-Message-ID-Hash: CYXGUFKOMIR6YFLO44MFLK5V2SXGCFF2 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.04 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: CBEC6940309 X-Spam-Score: -1.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: Ij7rzYcfL5I/ This will allow client code to provide more meaningful diagnostics. In particular it will enable "notmuch new" to continue suggsting the user run "notmuch setup" to create a config after "notmuch new" is transitioned to the new configuration framework. --- bindings/python-cffi/notmuch2/_build.py | 1 + bindings/python-cffi/notmuch2/_errors.py | 4 +++- lib/notmuch.h | 4 ++++ lib/open.cc | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bindings/python-cffi/notmuch2/_build.py b/bindings/python-cffi/notmuch2/_build.py index d3bb9104..93828627 100644 --- a/bindings/python-cffi/notmuch2/_build.py +++ b/bindings/python-cffi/notmuch2/_build.py @@ -50,6 +50,7 @@ ffibuilder.cdef( NOTMUCH_STATUS_MALFORMED_CRYPTO_PROTOCOL, NOTMUCH_STATUS_FAILED_CRYPTO_CONTEXT_CREATION, NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL, + NOTMUCH_STATUS_NO_CONFIG, NOTMUCH_STATUS_LAST_STATUS } notmuch_status_t; typedef enum { diff --git a/bindings/python-cffi/notmuch2/_errors.py b/bindings/python-cffi/notmuch2/_errors.py index 13369445..c97d99cb 100644 --- a/bindings/python-cffi/notmuch2/_errors.py +++ b/bindings/python-cffi/notmuch2/_errors.py @@ -50,6 +50,8 @@ class NotmuchError(Exception): PathError, capi.lib.NOTMUCH_STATUS_ILLEGAL_ARGUMENT: IllegalArgumentError, + capi.lib.NOTMUCH_STATUS_NO_CONFIG: + NoConfigError, } return types[status] @@ -94,7 +96,7 @@ class UnsupportedOperationError(NotmuchError): pass class UpgradeRequiredError(NotmuchError): pass class PathError(NotmuchError): pass class IllegalArgumentError(NotmuchError): pass - +class NoConfigError(NotmuchError): pass class ObjectDestroyedError(NotmuchError): """The object has already been destroyed and it's memory freed. diff --git a/lib/notmuch.h b/lib/notmuch.h index 5ec14c38..4f384e58 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -208,6 +208,10 @@ typedef enum _notmuch_status { * something that notmuch doesn't know how to handle. */ NOTMUCH_STATUS_UNKNOWN_CRYPTO_PROTOCOL, + /** + * Unable to load a config file + */ + NOTMUCH_STATUS_NO_CONFIG, /** * Not an actual status value. Just a way to find out how many * valid status values there are. diff --git a/lib/open.cc b/lib/open.cc index 6e8e0f6f..06d079e4 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -106,7 +106,7 @@ _load_key_file (const char *path, *key_file = g_key_file_new (); if (! g_key_file_load_from_file (*key_file, path, G_KEY_FILE_NONE, NULL)) { - status = NOTMUCH_STATUS_FILE_ERROR; + status = NOTMUCH_STATUS_NO_CONFIG; } DONE: -- 2.30.0