unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ethan Glasser-Camp <glasse@cs.rpi.edu>
To: notmuch@notmuchmail.org
Cc: Ethan Glasser-Camp <ethan@betacantrips.com>
Subject: [RFC PATCH 01/13] Create configuration paramater database.type
Date: Wed, 15 Feb 2012 17:01:54 -0500	[thread overview]
Message-ID: <1329343326-16410-2-git-send-email-glasse@cs.rpi.edu> (raw)
In-Reply-To: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>

From: Ethan Glasser-Camp <ethan@betacantrips.com>

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 <ethan@betacantrips.com>
---
 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

  reply	other threads:[~2012-02-15 22:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-15 22:01 [RFC PATCH 00/13] Modular message store code Ethan Glasser-Camp
2012-02-15 22:01 ` Ethan Glasser-Camp [this message]
2012-02-15 22:01 ` [RFC PATCH 02/13] Add the concept of a mailstore in its absolute minimal sense Ethan Glasser-Camp
2012-02-15 22:01 ` [RFC PATCH 03/13] Introduce mailstore in the python bindings Ethan Glasser-Camp
2012-02-15 22:01 ` [RFC PATCH 04/13] Replace remaining places where fopen occurs Ethan Glasser-Camp
2012-02-15 22:01 ` [RFC PATCH 05/13] notmuch_database_add_message calculates sha1 of messages using mailstore Ethan Glasser-Camp
2012-02-15 22:01 ` [RFC PATCH 06/13] Pass mailstore to _notmuch_message_index_file Ethan Glasser-Camp
2012-02-15 22:02 ` [RFC PATCH 07/13] notmuch-new: pull out useful bits of add_files_recursive Ethan Glasser-Camp
2012-02-15 22:02 ` [RFC PATCH 08/13] count_files and add_files shall be generic Ethan Glasser-Camp
2012-02-15 22:02 ` [RFC PATCH 09/13] Mailstore also provides a "rename" function Ethan Glasser-Camp
2012-02-15 22:02 ` [RFC PATCH 10/13] Introduce concept of mailstore "constructor" Ethan Glasser-Camp
2012-02-15 22:02 ` [RFC PATCH 11/13] Add a close function to mailstore Ethan Glasser-Camp
2012-02-15 22:02 ` [RFC PATCH 12/13] Close files using notmuch_mailstore_close instead of fclose Ethan Glasser-Camp
2012-02-15 22:02 ` [RFC PATCH 13/13] First crack at a CouchDB mailstore Ethan Glasser-Camp
2012-02-16  0:56 ` [RFC PATCH 00/13] Modular message store code Mark Walters
2012-03-01 13:51   ` Ethan Glasser-Camp
2012-02-16  7:47 ` Stewart Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329343326-16410-2-git-send-email-glasse@cs.rpi.edu \
    --to=glasse@cs.rpi.edu \
    --cc=ethan@betacantrips.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).