[RFC PATCH 01/13] Create configuration paramater database.type
authorEthan Glasser-Camp <glasse@cs.rpi.edu>
Wed, 15 Feb 2012 22:01:54 +0000 (17:01 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:33 +0000 (09:44 -0800)
2c/e6181239ef6aaf91484af82130b22360ec7f65 [new file with mode: 0644]

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