From: Ethan Glasser-Camp Date: Wed, 15 Feb 2012 22:01:54 +0000 (+1900) Subject: [RFC PATCH 01/13] Create configuration paramater database.type X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=62a45af2eb4ad2b22d46e72015b40f52e0f67806;p=notmuch-archives.git [RFC PATCH 01/13] Create configuration paramater database.type --- diff --git a/2c/e6181239ef6aaf91484af82130b22360ec7f65 b/2c/e6181239ef6aaf91484af82130b22360ec7f65 new file mode 100644 index 000000000..9192cea25 --- /dev/null +++ b/2c/e6181239ef6aaf91484af82130b22360ec7f65 @@ -0,0 +1,206 @@ +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 AA258431E62 + for ; Wed, 15 Feb 2012 14:03:45 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.54 +X-Spam-Level: +X-Spam-Status: No, score=-0.54 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + RCVD_IN_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_MED=-2.3, + RCVD_IN_SORBS_WEB=0.614] 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 oFj-xM-d5f-G for ; + Wed, 15 Feb 2012 14:03:42 -0800 (PST) +Received: from cliffclavin.cs.rpi.edu (cliffclavin.cs.rpi.edu + [128.113.126.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS + id EABB7429E43 for ; Wed, 15 Feb 2012 14:03:41 -0800 + (PST) +X-Hash: + S|7ad3c2d146a8219dfc8d49189731060e3e91b1eb|659f0d3bddb7bfac13f8ae4d08f67d7f +X-Countries: Cameroon, United States +X-SMTP-From: accepted [195.24.209.20] [195.24.209.20] + (localhost) {Cameroon} +DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cs.rpi.edu; h=from + :to:cc:subject:date:message-id:in-reply-to:references; s= + default; i=glasse@cs.rpi.edu; t=1329343419; x=1329948219; l=4069; + bh=5gOw3XhAnZ/2lLrwabeVVCs9a1k=; b=HLTJgzhoH1mdfDTxrVw8gjT + KoI8F2U0nr2w+984M5H9ivTEq3pSHVLDxBc+mzPMLRz5urh/s43i3QStJMSL98Uh + taKn7EYYUhi44+dtRlzTAP8B+iFY0tpPev7aOBudTcsJ9u2F2ueLAm1r2HuiYcoX + eevnOfu2HYoEfFlvYdM8= +DomainKey-Signature: a=rsa-sha1; c=nofws; d=cs.rpi.edu; h=from:to:cc + :subject:date:message-id:in-reply-to:references; q=dns; s= + default; b=hcunpmesQ307tDAjPc8PDnBjEZWh0oFCVFlf2aSDqJNH1BB1ZQMYg + u3oNH32yZ11zSOT14XMyUqdG615veLgSKq1812XK6LILccyJ1gJsoGGTuxxA8zjz + Vay0t1rzGA+827L3BTWixuMrvmSDMf0aBIZvqggeFNzzedEGzD/taY= +X-Spam-Info: -2.7; ALL_TRUSTED,AWL,BAYES_00 +X-Spam-Scanned-By: cliffclavin.cs.rpi.edu using SpamAssassin 3.2.5 (hard limit + 15) +Authentication-Results: cliffclavin.cs.rpi.edu; + DKIM=neutral (none) header.from=glasse@cs.rpi.edu; + SPF=neutral (mfrom; + Mechanism '?all' matched) smtp.mail=glasse@cs.rpi.edu +X-Auth-Passed: cliffclavin.cs.rpi.edu:q1FM3Eie008735 Auth:glasse +X-Virus-Scanned-By: cliffclavin.cs.rpi.edu +Received: from localhost ([195.24.209.20]) (authenticated bits=0) + by cliffclavin.cs.rpi.edu (8.14.3/8.14.3) with ESMTP id q1FM3Eie008735 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); + Wed, 15 Feb 2012 17:03:30 -0500 (EST) + (envelope-from glasse@cs.rpi.edu) +From: Ethan Glasser-Camp +To: notmuch@notmuchmail.org +Subject: [RFC PATCH 01/13] Create configuration paramater database.type +Date: Wed, 15 Feb 2012 17:01:54 -0500 +Message-Id: <1329343326-16410-2-git-send-email-glasse@cs.rpi.edu> +X-Mailer: git-send-email 1.7.5.4 +In-Reply-To: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu> +References: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu> +X-Scanned-By: MIMEDefang 2.67 on 128.113.126.25 +Cc: Ethan Glasser-Camp +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: Wed, 15 Feb 2012 22:03:45 -0000 + +From: Ethan Glasser-Camp + +This will be used to allow different backends to be developed to allow +access to mail that isn't stored in Maildirs. + +Signed-off-by: Ethan Glasser-Camp +--- + notmuch-client.h | 7 ++++++ + notmuch-config.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++---- + 2 files changed, 59 insertions(+), 5 deletions(-) + +diff --git a/notmuch-client.h b/notmuch-client.h +index 60828aa..4518cb0 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -220,6 +220,13 @@ notmuch_config_set_database_path (notmuch_config_t *config, + const char *database_path); + + const char * ++notmuch_config_get_database_type (notmuch_config_t *config); ++ ++void ++notmuch_config_set_database_type (notmuch_config_t *config, ++ const char *database_type); ++ ++const char * + notmuch_config_get_user_name (notmuch_config_t *config); + + void +diff --git a/notmuch-config.c b/notmuch-config.c +index a124e34..b8bee69 100644 +--- a/notmuch-config.c ++++ b/notmuch-config.c +@@ -32,11 +32,24 @@ static const char toplevel_config_comment[] = + static const char database_config_comment[] = + " Database configuration\n" + "\n" +- " The only value supported here is 'path' which should be the top-level\n" +- " directory where your mail currently exists and to where mail will be\n" +- " delivered in the future. Files should be individual email messages.\n" +- " Notmuch will store its database within a sub-directory of the path\n" +- " configured here named \".notmuch\".\n"; ++ " Here is where you can tell notmuch where your mail currently exists\n" ++ " and where mail will be delivered in the future." ++ "\n" ++ " The following options are supported here:\n" ++ "\n" ++ "\ttype The type of mail backend. The only currently supported\n" ++ "\t value is \"maildir\".\n" ++ "\tpath For the maildir backend, the top-level maildir directory.\n" ++ "\t For all backends, the location where notmuch should store its\n" ++ "\t database. Notmuch will store its database within a sub-directory\n" ++ "\t of this path named \".notmuch\".\n" ++ "\n" ++ " Maildir backend\n" ++ "\n" ++ " This backend reads mail from a directory tree where files are\n" ++ " individual email messages.\n" ++ " The only configuration option is 'path' which should be the top-level\n" ++ " directory.\n"; + + static const char new_config_comment[] = + " Configuration for \"notmuch new\"\n" +@@ -99,6 +112,7 @@ struct _notmuch_config { + GKeyFile *key_file; + + char *database_path; ++ char *database_type; + char *user_name; + char *user_primary_email; + const char **user_other_email; +@@ -258,6 +272,7 @@ notmuch_config_open (void *ctx, + config->key_file = g_key_file_new (); + + config->database_path = NULL; ++ config->database_type = NULL; + config->user_name = NULL; + config->user_primary_email = NULL; + config->user_other_email = NULL; +@@ -320,6 +335,10 @@ notmuch_config_open (void *ctx, + talloc_free (path); + } + ++ if (notmuch_config_get_database_type (config) == NULL) { ++ notmuch_config_set_database_type (config, "maildir"); ++ } ++ + if (notmuch_config_get_user_name (config) == NULL) { + char *name = get_name_from_passwd_file (config); + notmuch_config_set_user_name (config, name); +@@ -538,6 +557,34 @@ notmuch_config_set_database_path (notmuch_config_t *config, + } + + const char * ++notmuch_config_get_database_type (notmuch_config_t *config) ++{ ++ char *type; ++ ++ if (config->database_type == NULL) { ++ type = g_key_file_get_string (config->key_file, ++ "database", "type", NULL); ++ if (type) { ++ config->database_type = talloc_strdup (config, type); ++ free (type); ++ } ++ } ++ ++ return config->database_type; ++} ++ ++void ++notmuch_config_set_database_type (notmuch_config_t *config, ++ const char *database_type) ++{ ++ g_key_file_set_string (config->key_file, ++ "database", "type", database_type); ++ ++ talloc_free (config->database_type); ++ config->database_type = NULL; ++} ++ ++const char * + notmuch_config_get_user_name (notmuch_config_t *config) + { + char *name; +-- +1.7.5.4 +