From 0510eea5b04c8f0cb044133fde310179d98ab293 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 3 Mar 2013 23:55:07 +0200 Subject: [PATCH] [PATCH v2 3/6] cli: config: keep track of whether the config is newly created --- 83/74aacf3596f08a34f0f9246bcc89a33a94d580 | 140 ++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 83/74aacf3596f08a34f0f9246bcc89a33a94d580 diff --git a/83/74aacf3596f08a34f0f9246bcc89a33a94d580 b/83/74aacf3596f08a34f0f9246bcc89a33a94d580 new file mode 100644 index 000000000..2d6daf337 --- /dev/null +++ b/83/74aacf3596f08a34f0f9246bcc89a33a94d580 @@ -0,0 +1,140 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 55641431FDE + for ; Sun, 3 Mar 2013 13:55:34 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id wadRa9PmoXdI for ; + Sun, 3 Mar 2013 13:55:33 -0800 (PST) +Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com + [209.85.217.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id C9865431E62 + for ; Sun, 3 Mar 2013 13:55:22 -0800 (PST) +Received: by mail-lb0-f180.google.com with SMTP id q12so3500335lbc.11 + for ; Sun, 03 Mar 2013 13:55:21 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to + :references:in-reply-to:references:x-gm-message-state; + bh=GbaZLqNuib6Un31BxcZvVhJmQJXcNymuaP73EOwI0fA=; + b=EDLpd923COAOwexqQjM7YekH+37VS7u1D/4Jy7YFyd2nGAU1ks2cb2fAQSRRG4Usg4 + YbeloGP7+9SQCwwKXbu3Qg0tWT90M0WJNVePWzgB0DHEX1ntqQtmLgXHXYAmTrEjKN24 + W0UjQ7w+U5AWrMmrnQOMfmy7xvaBeTq48+0jheoVv4CLMu2UP4SsZvAXVpqXcB+3t9sk + EYklm2qdHFecr2HTqkqQJ2ZN6paBVjfQBvsj3ZgdYKwPUGzic9W4SBE1mSKN/CEg9e4k + flHkcgWwnPDI6fLFgE5KAqMTh4JqAPBEO8KEP85DXJAPNQSFmkbk3Rz7ajU+fzggtQFk + lpxA== +X-Received: by 10.152.46.12 with SMTP id r12mr15878857lam.15.1362347721311; + Sun, 03 Mar 2013 13:55:21 -0800 (PST) +Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi. + [80.223.81.27]) + by mx.google.com with ESMTPS id oy10sm10731246lab.8.2013.03.03.13.55.19 + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 03 Mar 2013 13:55:20 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH v2 3/6] cli: config: keep track of whether the config is newly + created +Date: Sun, 3 Mar 2013 23:55:07 +0200 +Message-Id: + <1a1e9d8e37f178b8e1c9e41162366f6b9f326c99.1362347362.git.jani@nikula.org> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: +References: +In-Reply-To: +References: +X-Gm-Message-State: + ALoCoQmdfPAuHRwPJjpBZBChr9FVyHfvGsv9iOJF3ULYjBn84tjol02BhQE2s6HdbwcnYS7Ycb8M +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Sun, 03 Mar 2013 21:55:34 -0000 + +Keep track of whether the config is newly created, and add +notmuch_config_is_new() accessor function to query this. + +This is to support anyone with a config handle to check this, instead +of just whoever called notmuch_config_open(). +--- + notmuch-client.h | 3 +++ + notmuch-config.c | 11 +++++++++++ + 2 files changed, 14 insertions(+) + +diff --git a/notmuch-client.h b/notmuch-client.h +index 5f28836..07367e0 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -256,6 +256,9 @@ notmuch_config_close (notmuch_config_t *config); + int + notmuch_config_save (notmuch_config_t *config); + ++notmuch_bool_t ++notmuch_config_is_new (notmuch_config_t *config); ++ + const char * + notmuch_config_get_database_path (notmuch_config_t *config); + +diff --git a/notmuch-config.c b/notmuch-config.c +index b5c2066..e733e92 100644 +--- a/notmuch-config.c ++++ b/notmuch-config.c +@@ -104,6 +104,7 @@ static const char search_config_comment[] = + struct _notmuch_config { + char *filename; + GKeyFile *key_file; ++ notmuch_bool_t is_new; + + char *database_path; + char *user_name; +@@ -266,6 +267,7 @@ notmuch_config_open (void *ctx, + + config->key_file = g_key_file_new (); + ++ config->is_new = FALSE; + config->database_path = NULL; + config->user_name = NULL; + config->user_primary_email = NULL; +@@ -435,6 +437,8 @@ notmuch_config_open (void *ctx, + if (is_new_ret) + *is_new_ret = is_new; + ++ config->is_new = is_new; ++ + return config; + } + +@@ -482,6 +486,13 @@ notmuch_config_save (notmuch_config_t *config) + return 0; + } + ++notmuch_bool_t ++notmuch_config_is_new (notmuch_config_t *config) ++{ ++ return config->is_new; ++} ++ ++ + static const char ** + _config_get_list (notmuch_config_t *config, + const char *section, const char *key, +-- +1.7.10.4 + -- 2.26.2