1 Return-Path: <glasse@cs.rpi.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 499BD429E4D
\r
6 for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:05:21 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.54 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 RCVD_IN_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_MED=-2.3,
\r
14 RCVD_IN_SORBS_WEB=0.614] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id l8jycoFcKWZ4 for <notmuch@notmuchmail.org>;
\r
18 Wed, 15 Feb 2012 14:05:17 -0800 (PST)
\r
19 Received: from cliffclavin.cs.rpi.edu (cliffclavin.cs.rpi.edu
\r
20 [128.113.126.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
21 (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS
\r
22 id D6089431E62 for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:05:16 -0800
\r
24 X-Hash: SCtCte|89dfd227c9662973caf8391b7d228905169bd57f|97dc102990e8867edb52cd10b7e2ee4b
\r
25 X-Countries: Cameroon, United States
\r
26 X-SMTP-From: accepted <glasse@cs.rpi.edu> [195.24.209.20] [195.24.209.20]
\r
27 (localhost) {Cameroon}
\r
28 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cs.rpi.edu; h=from
\r
29 :to:cc:subject:date:message-id:in-reply-to:references
\r
30 :mime-version:content-type:content-transfer-encoding; s=default;
\r
31 i=glasse@cs.rpi.edu; t=1329343514; x=1329948314; l=35856; bh=OT
\r
32 sr0oOTFdwKst/jNUR1YAEfm8s=; b=dO/rdBc0sonb8IjwP6uYCMDQX5mU+46QaW
\r
33 GDHTdq1M0LxCMl0Re2zWsOs975MGeb5e4IhxwJyQW83BRasSMVPX1wRbdUy0p45f
\r
34 I2zFDTGORHlhbphVpOsz9nb/IJTLQkOCoKwjiVkBziFlFtUbd33OlJ5v+ky/+Uqs
\r
36 DomainKey-Signature: a=rsa-sha1; c=nofws; d=cs.rpi.edu; h=from:to:cc
\r
37 :subject:date:message-id:in-reply-to:references:mime-version
\r
38 :content-type:content-transfer-encoding; q=dns; s=default; b=DQm
\r
39 VIkdWCj7voYXR1hMb3ZXdLVLbsPuBzB7PR8EGSkCSb2wlVOpH0TcxYqEW2syBAcY
\r
40 LdudrqeN8Y4mqsk0+iJdgGAh+lm4oxWBR1n1R1eW8aUqULD7I6xeNyDtpQeJcrHn
\r
41 On4Pmbrv/0f4VPPosFot7q/pf5zQywrZqlzA3RVY=
\r
42 X-Spam-Info: -2.6; ALL_TRUSTED,AWL,BAYES_00,SARE_SUB_ENC_UTF8
\r
43 X-Spam-Scanned-By: cliffclavin.cs.rpi.edu using SpamAssassin 3.2.5 (hard limit
\r
45 Authentication-Results: cliffclavin.cs.rpi.edu;
\r
46 DKIM=neutral (none) header.from=glasse@cs.rpi.edu;
\r
48 Mechanism '?all' matched) smtp.mail=glasse@cs.rpi.edu
\r
49 X-Auth-Passed: cliffclavin.cs.rpi.edu:q1FM3qv2008742 Auth:glasse
\r
50 X-Virus-Scanned-By: cliffclavin.cs.rpi.edu
\r
51 Received: from localhost ([195.24.209.20]) (authenticated bits=0)
\r
52 by cliffclavin.cs.rpi.edu (8.14.3/8.14.3) with ESMTP id q1FM3qv2008742
\r
53 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);
\r
54 Wed, 15 Feb 2012 17:04:06 -0500 (EST)
\r
55 (envelope-from glasse@cs.rpi.edu)
\r
56 From: Ethan Glasser-Camp <glasse@cs.rpi.edu>
\r
57 To: notmuch@notmuchmail.org
\r
58 Subject: [RFC PATCH 02/13] Add the concept of a mailstore in its absolute minimal sense
\r
59 Date: Wed, 15 Feb 2012 17:01:55 -0500
\r
60 Message-Id: <1329343326-16410-3-git-send-email-glasse@cs.rpi.edu>
\r
61 X-Mailer: git-send-email 1.7.5.4
\r
62 In-Reply-To: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>
\r
63 References: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>
\r
65 Content-Type: text/plain; charset=UTF-8
\r
66 Content-Transfer-Encoding: 8bit
\r
67 X-Scanned-By: MIMEDefang 2.67 on 128.113.126.25
\r
68 Cc: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
69 X-BeenThere: notmuch@notmuchmail.org
\r
70 X-Mailman-Version: 2.1.13
\r
72 List-Id: "Use and development of the notmuch mail system."
\r
73 <notmuch.notmuchmail.org>
\r
74 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
76 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
77 List-Post: <mailto:notmuch@notmuchmail.org>
\r
78 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
79 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
80 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
81 X-List-Received-Date: Wed, 15 Feb 2012 22:05:21 -0000
\r
83 From: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
85 This introduces (and uses) the mailstore parameter to the
\r
86 notmuch_message_file_open API, and passes this through wherever it
\r
87 will be needed. This requires touching a lot of places just to change
\r
88 one API. We end up adding it to the notmuch_database_t struct because
\r
89 it is needed for notmuch_database_upgrade.
\r
91 This doesn't touch the Python bindings, which require a certain amount
\r
92 of effort. (Therefore, the Python tests will be broken until the next commit.)
\r
94 Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
96 lib/Makefile.local | 1 +
\r
97 lib/database-private.h | 1 +
\r
98 lib/database.cc | 10 +++++---
\r
99 lib/mailstore.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
\r
100 lib/message-file.c | 10 +++++---
\r
101 lib/message.cc | 11 +++++---
\r
102 lib/notmuch-private.h | 7 ++++-
\r
103 lib/notmuch.h | 21 ++++++++++++++--
\r
104 lib/thread.cc | 24 +++++++++++--------
\r
105 notmuch-client.h | 6 +++++
\r
106 notmuch-config.c | 12 +++++++++
\r
107 notmuch-count.c | 3 +-
\r
108 notmuch-dump.c | 3 +-
\r
109 notmuch-new.c | 8 +++++-
\r
110 notmuch-reply.c | 45 ++++++++++++++++++++++++------------
\r
111 notmuch-restore.c | 3 +-
\r
112 notmuch-search.c | 3 +-
\r
113 notmuch-show.c | 56 ++++++++++++++++++++++++++++++---------------
\r
114 notmuch-tag.c | 3 +-
\r
115 test/symbol-test.cc | 3 +-
\r
116 20 files changed, 220 insertions(+), 69 deletions(-)
\r
117 create mode 100644 lib/mailstore.c
\r
119 diff --git a/lib/Makefile.local b/lib/Makefile.local
\r
120 index 54c4dea..461e5cd 100644
\r
121 --- a/lib/Makefile.local
\r
122 +++ b/lib/Makefile.local
\r
123 @@ -51,6 +51,7 @@ libnotmuch_c_srcs = \
\r
124 $(dir)/filenames.c \
\r
125 $(dir)/string-list.c \
\r
127 + $(dir)/mailstore.c \
\r
128 $(dir)/message-file.c \
\r
129 $(dir)/messages.c \
\r
131 diff --git a/lib/database-private.h b/lib/database-private.h
\r
132 index 88532d5..1cb8c43 100644
\r
133 --- a/lib/database-private.h
\r
134 +++ b/lib/database-private.h
\r
136 struct _notmuch_database {
\r
137 notmuch_bool_t exception_reported;
\r
139 + notmuch_mailstore_t *mailstore;
\r
142 notmuch_bool_t needs_upgrade;
\r
143 diff --git a/lib/database.cc b/lib/database.cc
\r
144 index c928d02..e3c8095 100644
\r
145 --- a/lib/database.cc
\r
146 +++ b/lib/database.cc
\r
147 @@ -521,7 +521,7 @@ parse_references (void *ctx,
\r
150 notmuch_database_t *
\r
151 -notmuch_database_create (const char *path)
\r
152 +notmuch_database_create (notmuch_mailstore_t *mailstore, const char *path)
\r
154 notmuch_database_t *notmuch = NULL;
\r
155 char *notmuch_path = NULL;
\r
156 @@ -556,7 +556,7 @@ notmuch_database_create (const char *path)
\r
160 - notmuch = notmuch_database_open (path,
\r
161 + notmuch = notmuch_database_open (mailstore, path,
\r
162 NOTMUCH_DATABASE_MODE_READ_WRITE);
\r
163 notmuch_database_upgrade (notmuch, NULL, NULL);
\r
165 @@ -579,7 +579,8 @@ _notmuch_database_ensure_writable (notmuch_database_t *notmuch)
\r
168 notmuch_database_t *
\r
169 -notmuch_database_open (const char *path,
\r
170 +notmuch_database_open (notmuch_mailstore_t *mailstore,
\r
171 + const char *path,
\r
172 notmuch_database_mode_t mode)
\r
174 void *local = talloc_new (NULL);
\r
175 @@ -619,6 +620,7 @@ notmuch_database_open (const char *path,
\r
176 notmuch = talloc_zero (NULL, notmuch_database_t);
\r
177 notmuch->exception_reported = FALSE;
\r
178 notmuch->path = talloc_strdup (notmuch, path);
\r
179 + notmuch->mailstore = mailstore;
\r
181 if (notmuch->path[strlen (notmuch->path) - 1] == '/')
\r
182 notmuch->path[strlen (notmuch->path) - 1] = '\0';
\r
183 @@ -1636,7 +1638,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
187 - message_file = notmuch_message_file_open (filename);
\r
188 + message_file = notmuch_message_file_open (notmuch->mailstore, filename);
\r
189 if (message_file == NULL)
\r
190 return NOTMUCH_STATUS_FILE_ERROR;
\r
192 diff --git a/lib/mailstore.c b/lib/mailstore.c
\r
193 new file mode 100644
\r
194 index 0000000..290da70
\r
196 +++ b/lib/mailstore.c
\r
198 +/* mailstore.c - mail storage backends
\r
200 + * Copyright © 2009 Carl Worth
\r
202 + * This program is free software: you can redistribute it and/or modify
\r
203 + * it under the terms of the GNU General Public License as published by
\r
204 + * the Free Software Foundation, either version 3 of the License, or
\r
205 + * (at your option) any later version.
\r
207 + * This program is distributed in the hope that it will be useful,
\r
208 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
209 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
210 + * GNU General Public License for more details.
\r
212 + * You should have received a copy of the GNU General Public License
\r
213 + * along with this program. If not, see http://www.gnu.org/licenses/ .
\r
216 +#include <stdio.h>
\r
218 +#include "notmuch-private.h"
\r
220 +typedef struct _notmuch_mailstore {
\r
221 + FILE *(*open) (struct _notmuch_mailstore *mailstore, const char *filename);
\r
222 +} _notmuch_mailstore;
\r
225 +_maildir_open_function (unused (notmuch_mailstore_t *mailstore),
\r
226 + const char *filename)
\r
228 + return fopen (filename, "r");
\r
231 +/* A mailstore is defined as:
\r
233 + * - A function used to "open" a mail message. This takes the
\r
234 + * "filename" for the file and should return a FILE *.
\r
236 + * - TODO: A way to scan for new messages?
\r
238 + * - TODO: A "constructor"?
\r
240 +_notmuch_mailstore
\r
241 +notmuch_mailstore_maildir = { _maildir_open_function };
\r
243 +_notmuch_mailstore *
\r
244 +notmuch_mailstore_get_by_name (const char *name)
\r
246 + if (strcmp (name, "maildir") == 0)
\r
247 + return ¬much_mailstore_maildir;
\r
253 +notmuch_mailstore_open (notmuch_mailstore_t *mailstore, const char *filename)
\r
255 + return mailstore->open (mailstore, filename);
\r
257 diff --git a/lib/message-file.c b/lib/message-file.c
\r
258 index 915aba8..61f4d04 100644
\r
259 --- a/lib/message-file.c
\r
260 +++ b/lib/message-file.c
\r
261 @@ -94,7 +94,8 @@ _notmuch_message_file_destructor (notmuch_message_file_t *message)
\r
262 /* Create a new notmuch_message_file_t for 'filename' with 'ctx' as
\r
263 * the talloc owner. */
\r
264 notmuch_message_file_t *
\r
265 -_notmuch_message_file_open_ctx (void *ctx, const char *filename)
\r
266 +_notmuch_message_file_open_ctx (void *ctx, notmuch_mailstore_t *mailstore,
\r
267 + const char *filename)
\r
269 notmuch_message_file_t *message;
\r
271 @@ -104,7 +105,7 @@ _notmuch_message_file_open_ctx (void *ctx, const char *filename)
\r
273 talloc_set_destructor (message, _notmuch_message_file_destructor);
\r
275 - message->file = fopen (filename, "r");
\r
276 + message->file = notmuch_mailstore_open (mailstore, filename);
\r
277 if (message->file == NULL)
\r
280 @@ -126,9 +127,10 @@ _notmuch_message_file_open_ctx (void *ctx, const char *filename)
\r
283 notmuch_message_file_t *
\r
284 -notmuch_message_file_open (const char *filename)
\r
285 +notmuch_message_file_open (notmuch_mailstore_t *mailstore,
\r
286 + const char *filename)
\r
288 - return _notmuch_message_file_open_ctx (NULL, filename);
\r
289 + return _notmuch_message_file_open_ctx (NULL, mailstore, filename);
\r
293 diff --git a/lib/message.cc b/lib/message.cc
\r
294 index 0075425..762a18f 100644
\r
295 --- a/lib/message.cc
\r
296 +++ b/lib/message.cc
\r
297 @@ -395,7 +395,8 @@ notmuch_message_get_message_id (notmuch_message_t *message)
\r
301 -_notmuch_message_ensure_message_file (notmuch_message_t *message)
\r
302 +_notmuch_message_ensure_message_file (notmuch_mailstore_t *mailstore,
\r
303 + notmuch_message_t *message)
\r
305 const char *filename;
\r
307 @@ -406,11 +407,13 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)
\r
308 if (unlikely (filename == NULL))
\r
311 - message->message_file = _notmuch_message_file_open_ctx (message, filename);
\r
312 + message->message_file = _notmuch_message_file_open_ctx (message, mailstore,
\r
317 -notmuch_message_get_header (notmuch_message_t *message, const char *header)
\r
318 +notmuch_message_get_header (notmuch_mailstore_t *mailstore,
\r
319 + notmuch_message_t *message, const char *header)
\r
323 @@ -427,7 +430,7 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header)
\r
324 return talloc_strdup (message, value.c_str ());
\r
326 /* Otherwise fall back to parsing the file */
\r
327 - _notmuch_message_ensure_message_file (message);
\r
328 + _notmuch_message_ensure_message_file (mailstore, message);
\r
329 if (message->message_file == NULL)
\r
332 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
333 index 7bf153e..0f01437 100644
\r
334 --- a/lib/notmuch-private.h
\r
335 +++ b/lib/notmuch-private.h
\r
336 @@ -331,11 +331,14 @@ typedef struct _notmuch_message_file notmuch_message_file_t;
\r
337 * Returns NULL if any error occurs.
\r
339 notmuch_message_file_t *
\r
340 -notmuch_message_file_open (const char *filename);
\r
341 +notmuch_message_file_open (notmuch_mailstore_t *mailstore,
\r
342 + const char *filename);
\r
344 /* Like notmuch_message_file_open but with 'ctx' as the talloc owner. */
\r
345 notmuch_message_file_t *
\r
346 -_notmuch_message_file_open_ctx (void *ctx, const char *filename);
\r
347 +_notmuch_message_file_open_ctx (void *ctx,
\r
348 + notmuch_mailstore_t *mailstore,
\r
349 + const char *filename);
\r
351 /* Close a notmuch message previously opened with notmuch_message_open. */
\r
353 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
354 index 7929fe7..7ebe034 100644
\r
355 --- a/lib/notmuch.h
\r
356 +++ b/lib/notmuch.h
\r
357 @@ -123,6 +123,7 @@ typedef struct _notmuch_message notmuch_message_t;
\r
358 typedef struct _notmuch_tags notmuch_tags_t;
\r
359 typedef struct _notmuch_directory notmuch_directory_t;
\r
360 typedef struct _notmuch_filenames notmuch_filenames_t;
\r
361 +typedef struct _notmuch_mailstore notmuch_mailstore_t;
\r
363 /* Create a new, empty notmuch database located at 'path'.
\r
365 @@ -144,7 +145,7 @@ typedef struct _notmuch_filenames notmuch_filenames_t;
\r
366 * an error message on stderr).
\r
368 notmuch_database_t *
\r
369 -notmuch_database_create (const char *path);
\r
370 +notmuch_database_create (notmuch_mailstore_t *mailstore, const char *path);
\r
373 NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
\r
374 @@ -172,7 +173,8 @@ typedef enum {
\r
375 * an error message on stderr).
\r
377 notmuch_database_t *
\r
378 -notmuch_database_open (const char *path,
\r
379 +notmuch_database_open (notmuch_mailstore_t *mailstore,
\r
380 + const char *path,
\r
381 notmuch_database_mode_t mode);
\r
383 /* Close the given notmuch database, freeing all associated
\r
384 @@ -409,6 +411,18 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
\r
386 notmuch_database_get_all_tags (notmuch_database_t *db);
\r
388 +/* Return a mail storage backend based on the given name.
\r
390 + * Storage backends are required in order to manipulate message files.
\r
392 +notmuch_mailstore_t *
\r
393 +notmuch_mailstore_get_by_name (const char *name);
\r
395 +/* Get an input stream for a filename.
\r
398 +notmuch_mailstore_open (notmuch_mailstore_t *mailstore, const char *filename);
\r
400 /* Create a new query for 'database'.
\r
402 * Here, 'database' should be an open database, (see
\r
403 @@ -929,7 +943,8 @@ notmuch_message_get_date (notmuch_message_t *message);
\r
404 * header line matching 'header'. Returns NULL if any error occurs.
\r
407 -notmuch_message_get_header (notmuch_message_t *message, const char *header);
\r
408 +notmuch_message_get_header (notmuch_mailstore_t *mailstore,
\r
409 + notmuch_message_t *message, const char *header);
\r
411 /* Get the tags for 'message', returning a notmuch_tags_t object which
\r
412 * can be used to iterate over all tags.
\r
413 diff --git a/lib/thread.cc b/lib/thread.cc
\r
414 index 0435ee6..73edf83 100644
\r
415 --- a/lib/thread.cc
\r
416 +++ b/lib/thread.cc
\r
417 @@ -213,7 +213,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
\r
421 -_thread_add_message (notmuch_thread_t *thread,
\r
422 +_thread_add_message (notmuch_mailstore_t *mailstore,
\r
423 + notmuch_thread_t *thread,
\r
424 notmuch_message_t *message)
\r
426 notmuch_tags_t *tags;
\r
427 @@ -231,7 +232,7 @@ _thread_add_message (notmuch_thread_t *thread,
\r
428 xstrdup (notmuch_message_get_message_id (message)),
\r
431 - from = notmuch_message_get_header (message, "from");
\r
432 + from = notmuch_message_get_header (mailstore, message, "from");
\r
434 list = internet_address_list_parse_string (from);
\r
436 @@ -253,7 +254,7 @@ _thread_add_message (notmuch_thread_t *thread,
\r
438 if (! thread->subject) {
\r
439 const char *subject;
\r
440 - subject = notmuch_message_get_header (message, "subject");
\r
441 + subject = notmuch_message_get_header (mailstore, message, "subject");
\r
442 thread->subject = talloc_strdup (thread, subject ? subject : "");
\r
445 @@ -267,13 +268,14 @@ _thread_add_message (notmuch_thread_t *thread,
\r
449 -_thread_set_subject_from_message (notmuch_thread_t *thread,
\r
450 +_thread_set_subject_from_message (notmuch_mailstore_t *mailstore,
\r
451 + notmuch_thread_t *thread,
\r
452 notmuch_message_t *message)
\r
454 const char *subject;
\r
455 const char *cleaned_subject;
\r
457 - subject = notmuch_message_get_header (message, "subject");
\r
458 + subject = notmuch_message_get_header (mailstore, message, "subject");
\r
462 @@ -300,7 +302,8 @@ _thread_set_subject_from_message (notmuch_thread_t *thread,
\r
463 * oldest or newest matching subject is applied to the thread as a
\r
466 -_thread_add_matched_message (notmuch_thread_t *thread,
\r
467 +_thread_add_matched_message (notmuch_mailstore_t *mailstore,
\r
468 + notmuch_thread_t *thread,
\r
469 notmuch_message_t *message,
\r
470 notmuch_sort_t sort)
\r
472 @@ -312,13 +315,13 @@ _thread_add_matched_message (notmuch_thread_t *thread,
\r
473 if (date < thread->oldest || ! thread->matched_messages) {
\r
474 thread->oldest = date;
\r
475 if (sort == NOTMUCH_SORT_OLDEST_FIRST)
\r
476 - _thread_set_subject_from_message (thread, message);
\r
477 + _thread_set_subject_from_message (mailstore, thread, message);
\r
480 if (date > thread->newest || ! thread->matched_messages) {
\r
481 thread->newest = date;
\r
482 if (sort != NOTMUCH_SORT_OLDEST_FIRST)
\r
483 - _thread_set_subject_from_message (thread, message);
\r
484 + _thread_set_subject_from_message (mailstore, thread, message);
\r
487 thread->matched_messages++;
\r
488 @@ -467,11 +470,12 @@ _notmuch_thread_create (void *ctx,
\r
489 if (doc_id == seed_doc_id)
\r
490 message = seed_message;
\r
492 - _thread_add_message (thread, message);
\r
493 + _thread_add_message (notmuch->mailstore, thread, message);
\r
495 if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {
\r
496 _notmuch_doc_id_set_remove (match_set, doc_id);
\r
497 - _thread_add_matched_message (thread, message, sort);
\r
498 + _thread_add_matched_message (notmuch->mailstore, thread,
\r
502 _notmuch_message_close (message);
\r
503 diff --git a/notmuch-client.h b/notmuch-client.h
\r
504 index 4518cb0..c1c30a2 100644
\r
505 --- a/notmuch-client.h
\r
506 +++ b/notmuch-client.h
\r
507 @@ -68,14 +68,17 @@ struct notmuch_show_params;
\r
508 typedef struct notmuch_show_format {
\r
509 const char *message_set_start;
\r
510 void (*part) (const void *ctx,
\r
511 + notmuch_mailstore_t *mailstore,
\r
512 struct mime_node *node, int indent,
\r
513 const struct notmuch_show_params *params);
\r
514 const char *message_start;
\r
515 void (*message) (const void *ctx,
\r
516 + notmuch_mailstore_t *mailstore,
\r
517 notmuch_message_t *message,
\r
519 const char *header_start;
\r
520 void (*header) (const void *ctx,
\r
521 + notmuch_mailstore_t *mailstore,
\r
522 notmuch_message_t *message);
\r
523 void (*header_message_part) (GMimeMessage *message);
\r
524 const char *header_end;
\r
525 @@ -226,6 +229,9 @@ void
\r
526 notmuch_config_set_database_type (notmuch_config_t *config,
\r
527 const char *database_type);
\r
529 +notmuch_mailstore_t *
\r
530 +notmuch_config_get_mailstore (notmuch_config_t *config);
\r
533 notmuch_config_get_user_name (notmuch_config_t *config);
\r
535 diff --git a/notmuch-config.c b/notmuch-config.c
\r
536 index b8bee69..f611b26 100644
\r
537 --- a/notmuch-config.c
\r
538 +++ b/notmuch-config.c
\r
539 @@ -584,6 +584,18 @@ notmuch_config_set_database_type (notmuch_config_t *config,
\r
540 config->database_type = NULL;
\r
543 +notmuch_mailstore_t *
\r
544 +notmuch_config_get_mailstore (notmuch_config_t *config)
\r
546 + /* This is just a stub since there's only one mailstore.
\r
548 + * When there are multiple mailstore types and "constructors" for
\r
549 + * them, this may have to be much more complicated.
\r
551 + const char *type = notmuch_config_get_database_type (config);
\r
552 + return notmuch_mailstore_get_by_name (type);
\r
556 notmuch_config_get_user_name (notmuch_config_t *config)
\r
558 diff --git a/notmuch-count.c b/notmuch-count.c
\r
559 index 63459fb..0c7beef 100644
\r
560 --- a/notmuch-count.c
\r
561 +++ b/notmuch-count.c
\r
562 @@ -57,7 +57,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
563 if (config == NULL)
\r
566 - notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
567 + notmuch = notmuch_database_open (notmuch_config_get_mailstore (config),
\r
568 + notmuch_config_get_database_path (config),
\r
569 NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
570 if (notmuch == NULL)
\r
572 diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
573 index a735875..f7729dd 100644
\r
574 --- a/notmuch-dump.c
\r
575 +++ b/notmuch-dump.c
\r
576 @@ -36,7 +36,8 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
577 if (config == NULL)
\r
580 - notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
581 + notmuch = notmuch_database_open (notmuch_config_get_mailstore (config),
\r
582 + notmuch_config_get_database_path (config),
\r
583 NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
584 if (notmuch == NULL)
\r
586 diff --git a/notmuch-new.c b/notmuch-new.c
\r
587 index 8dbebb3..355dde4 100644
\r
588 --- a/notmuch-new.c
\r
589 +++ b/notmuch-new.c
\r
590 @@ -808,6 +808,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
592 notmuch_config_t *config;
\r
593 notmuch_database_t *notmuch;
\r
594 + notmuch_mailstore_t *mailstore;
\r
595 add_files_state_t add_files_state;
\r
597 struct timeval tv_now, tv_start;
\r
598 @@ -843,6 +844,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
599 add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
600 add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
601 db_path = notmuch_config_get_database_path (config);
\r
602 + mailstore = notmuch_config_get_mailstore (config);
\r
605 ret = notmuch_run_hook (db_path, "pre-new");
\r
606 @@ -861,10 +863,12 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
609 printf ("Found %d total files (that's not much mail).\n", count);
\r
610 - notmuch = notmuch_database_create (db_path);
\r
611 + notmuch = notmuch_database_create (mailstore,
\r
613 add_files_state.total_files = count;
\r
615 - notmuch = notmuch_database_open (db_path,
\r
616 + notmuch = notmuch_database_open (mailstore,
\r
618 NOTMUCH_DATABASE_MODE_READ_WRITE);
\r
619 if (notmuch == NULL)
\r
621 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
622 index 6b244e6..cb1dd6e 100644
\r
623 --- a/notmuch-reply.c
\r
624 +++ b/notmuch-reply.c
\r
625 @@ -256,14 +256,15 @@ scan_address_string (const char *recipients,
\r
626 * in either the 'To' or 'Cc' header of the message?
\r
629 -reply_to_header_is_redundant (notmuch_message_t *message)
\r
630 +reply_to_header_is_redundant (notmuch_mailstore_t *mailstore,
\r
631 + notmuch_message_t *message)
\r
633 const char *reply_to, *to, *cc, *addr;
\r
634 InternetAddressList *list;
\r
635 InternetAddress *address;
\r
636 InternetAddressMailbox *mailbox;
\r
638 - reply_to = notmuch_message_get_header (message, "reply-to");
\r
639 + reply_to = notmuch_message_get_header (mailstore, message, "reply-to");
\r
640 if (reply_to == NULL || *reply_to == '\0')
\r
643 @@ -279,8 +280,8 @@ reply_to_header_is_redundant (notmuch_message_t *message)
\r
644 mailbox = INTERNET_ADDRESS_MAILBOX (address);
\r
645 addr = internet_address_mailbox_get_addr (mailbox);
\r
647 - to = notmuch_message_get_header (message, "to");
\r
648 - cc = notmuch_message_get_header (message, "cc");
\r
649 + to = notmuch_message_get_header (mailstore, message, "to");
\r
650 + cc = notmuch_message_get_header (mailstore, message, "cc");
\r
652 if ((to && strstr (to, addr) != 0) ||
\r
653 (cc && strstr (cc, addr) != 0))
\r
654 @@ -319,10 +320,13 @@ add_recipients_from_message (GMimeMessage *reply,
\r
655 { "cc", NULL, GMIME_RECIPIENT_TYPE_CC },
\r
656 { "bcc", NULL, GMIME_RECIPIENT_TYPE_BCC }
\r
658 + notmuch_mailstore_t *mailstore;
\r
659 const char *from_addr = NULL;
\r
661 unsigned int n = 0;
\r
663 + mailstore = notmuch_config_get_mailstore (config);
\r
665 /* Some mailing lists munge the Reply-To header despite it being A Bad
\r
666 * Thing, see http://www.unicom.com/pw/reply-to-harmful.html
\r
668 @@ -334,7 +338,7 @@ add_recipients_from_message (GMimeMessage *reply,
\r
669 * that the address in the Reply-To header will always appear in
\r
672 - if (reply_to_header_is_redundant (message)) {
\r
673 + if (reply_to_header_is_redundant (mailstore, message)) {
\r
674 reply_to_map[0].header = "from";
\r
675 reply_to_map[0].fallback = NULL;
\r
677 @@ -342,10 +346,10 @@ add_recipients_from_message (GMimeMessage *reply,
\r
678 for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
\r
679 const char *recipients;
\r
681 - recipients = notmuch_message_get_header (message,
\r
682 + recipients = notmuch_message_get_header (mailstore, message,
\r
683 reply_to_map[i].header);
\r
684 if ((recipients == NULL || recipients[0] == '\0') && reply_to_map[i].fallback)
\r
685 - recipients = notmuch_message_get_header (message,
\r
686 + recipients = notmuch_message_get_header (mailstore, message,
\r
687 reply_to_map[i].fallback);
\r
689 n += scan_address_string (recipients, config, reply,
\r
690 @@ -374,6 +378,7 @@ add_recipients_from_message (GMimeMessage *reply,
\r
691 static const char *
\r
692 guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message)
\r
694 + notmuch_mailstore_t *mailstore;
\r
695 const char *received,*primary,*by;
\r
696 const char **other;
\r
698 @@ -387,6 +392,7 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
\r
700 primary = notmuch_config_get_user_primary_email (config);
\r
701 other = notmuch_config_get_user_other_email (config, &other_len);
\r
702 + mailstore = notmuch_config_get_mailstore (config);
\r
704 /* sadly, there is no standard way to find out to which email
\r
705 * address a mail was delivered - what is in the headers depends
\r
706 @@ -403,7 +409,8 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
\r
707 * If none of these work, we give up and return NULL
\r
709 for (i = 0; i < sizeof(to_headers)/sizeof(*to_headers); i++) {
\r
710 - tohdr = xstrdup(notmuch_message_get_header (message, to_headers[i]));
\r
711 + tohdr = xstrdup(notmuch_message_get_header (mailstore,
\r
712 + message, to_headers[i]));
\r
713 if (tohdr && *tohdr) {
\r
714 /* tohdr is potentialy a list of email addresses, so here we
\r
715 * check if one of the email addresses is a substring of tohdr
\r
716 @@ -428,7 +435,7 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
\r
717 * The Received: header is special in our get_header function
\r
718 * and is always concatenated.
\r
720 - received = notmuch_message_get_header (message, "received");
\r
721 + received = notmuch_message_get_header (mailstore, message, "received");
\r
722 if (received == NULL)
\r
725 @@ -515,10 +522,12 @@ notmuch_reply_format_default(void *ctx,
\r
726 GMimeMessage *reply;
\r
727 notmuch_messages_t *messages;
\r
728 notmuch_message_t *message;
\r
729 + notmuch_mailstore_t *mailstore;
\r
730 const char *subject, *from_addr = NULL;
\r
731 const char *in_reply_to, *orig_references, *references;
\r
732 const notmuch_show_format_t *format = &format_reply;
\r
734 + mailstore = notmuch_config_get_mailstore (config);
\r
735 for (messages = notmuch_query_search_messages (query);
\r
736 notmuch_messages_valid (messages);
\r
737 notmuch_messages_move_to_next (messages))
\r
738 @@ -532,7 +541,7 @@ notmuch_reply_format_default(void *ctx,
\r
742 - subject = notmuch_message_get_header (message, "subject");
\r
743 + subject = notmuch_message_get_header (mailstore, message, "subject");
\r
745 if (strncasecmp (subject, "Re:", 3))
\r
746 subject = talloc_asprintf (ctx, "Re: %s", subject);
\r
747 @@ -560,7 +569,8 @@ notmuch_reply_format_default(void *ctx,
\r
748 g_mime_object_set_header (GMIME_OBJECT (reply),
\r
749 "In-Reply-To", in_reply_to);
\r
751 - orig_references = notmuch_message_get_header (message, "references");
\r
752 + orig_references = notmuch_message_get_header (mailstore,
\r
753 + message, "references");
\r
754 references = talloc_asprintf (ctx, "%s%s%s",
\r
755 orig_references ? orig_references : "",
\r
756 orig_references ? " " : "",
\r
757 @@ -574,8 +584,8 @@ notmuch_reply_format_default(void *ctx,
\r
760 printf ("On %s, %s wrote:\n",
\r
761 - notmuch_message_get_header (message, "date"),
\r
762 - notmuch_message_get_header (message, "from"));
\r
763 + notmuch_message_get_header (mailstore, message, "date"),
\r
764 + notmuch_message_get_header (mailstore, message, "from"));
\r
766 show_message_body (message, format, params);
\r
768 @@ -595,9 +605,12 @@ notmuch_reply_format_headers_only(void *ctx,
\r
769 GMimeMessage *reply;
\r
770 notmuch_messages_t *messages;
\r
771 notmuch_message_t *message;
\r
772 + notmuch_mailstore_t *mailstore;
\r
773 const char *in_reply_to, *orig_references, *references;
\r
774 char *reply_headers;
\r
776 + mailstore = notmuch_config_get_mailstore (config);
\r
778 for (messages = notmuch_query_search_messages (query);
\r
779 notmuch_messages_valid (messages);
\r
780 notmuch_messages_move_to_next (messages))
\r
781 @@ -618,7 +631,8 @@ notmuch_reply_format_headers_only(void *ctx,
\r
782 "In-Reply-To", in_reply_to);
\r
785 - orig_references = notmuch_message_get_header (message, "references");
\r
786 + orig_references = notmuch_message_get_header (mailstore, message,
\r
789 /* We print In-Reply-To followed by References because git format-patch treats them
\r
790 * specially. Git does not interpret the other headers specially
\r
791 @@ -720,7 +734,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
\r
795 - notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
796 + notmuch = notmuch_database_open (notmuch_config_get_mailstore (config),
\r
797 + notmuch_config_get_database_path (config),
\r
798 NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
799 if (notmuch == NULL)
\r
801 diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
802 index 87d9772..b382b7b 100644
\r
803 --- a/notmuch-restore.c
\r
804 +++ b/notmuch-restore.c
\r
805 @@ -40,7 +40,8 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
806 if (config == NULL)
\r
809 - notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
810 + notmuch = notmuch_database_open (notmuch_config_get_mailstore (config),
\r
811 + notmuch_config_get_database_path (config),
\r
812 NOTMUCH_DATABASE_MODE_READ_WRITE);
\r
813 if (notmuch == NULL)
\r
815 diff --git a/notmuch-search.c b/notmuch-search.c
\r
816 index d504051..8ba3c48 100644
\r
817 --- a/notmuch-search.c
\r
818 +++ b/notmuch-search.c
\r
819 @@ -470,7 +470,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
\r
820 if (config == NULL)
\r
823 - notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
824 + notmuch = notmuch_database_open (notmuch_config_get_mailstore (config),
\r
825 + notmuch_config_get_database_path (config),
\r
826 NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
827 if (notmuch == NULL)
\r
829 diff --git a/notmuch-show.c b/notmuch-show.c
\r
830 index d930f94..81d4cf0 100644
\r
831 --- a/notmuch-show.c
\r
832 +++ b/notmuch-show.c
\r
833 @@ -24,7 +24,8 @@ static void
\r
834 format_headers_message_part_text (GMimeMessage *message);
\r
837 -format_part_text (const void *ctx, mime_node_t *node,
\r
838 +format_part_text (const void *ctx, notmuch_mailstore_t *mailstore,
\r
839 + mime_node_t *node,
\r
840 int indent, const notmuch_show_params_t *params);
\r
842 static const notmuch_show_format_t format_text = {
\r
843 @@ -36,10 +37,12 @@ static const notmuch_show_format_t format_text = {
\r
846 format_message_json (const void *ctx,
\r
847 + notmuch_mailstore_t *mailstore,
\r
848 notmuch_message_t *message,
\r
849 unused (int indent));
\r
851 format_headers_json (const void *ctx,
\r
852 + notmuch_mailstore_t *mailstore,
\r
853 notmuch_message_t *message);
\r
856 @@ -83,6 +86,7 @@ static const notmuch_show_format_t format_json = {
\r
859 format_message_mbox (const void *ctx,
\r
860 + notmuch_mailstore_t *mailstore,
\r
861 notmuch_message_t *message,
\r
862 unused (int indent));
\r
864 @@ -149,14 +153,15 @@ _get_tags_as_string (const void *ctx, notmuch_message_t *message)
\r
866 /* Get a nice, single-line summary of message. */
\r
867 static const char *
\r
868 -_get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
869 +_get_one_line_summary (const void *ctx, notmuch_mailstore_t *mailstore,
\r
870 + notmuch_message_t *message)
\r
874 const char *relative_date;
\r
877 - from = notmuch_message_get_header (message, "from");
\r
878 + from = notmuch_message_get_header (mailstore, message, "from");
\r
880 date = notmuch_message_get_date (message);
\r
881 relative_date = notmuch_time_relative_date (ctx, date);
\r
882 @@ -168,7 +173,8 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
886 -format_message_json (const void *ctx, notmuch_message_t *message, unused (int indent))
\r
887 +format_message_json (const void *ctx, unused (notmuch_mailstore_t *mailstore),
\r
888 + notmuch_message_t *message, unused (int indent))
\r
890 notmuch_tags_t *tags;
\r
892 @@ -262,6 +268,7 @@ _is_from_line (const char *line)
\r
895 format_message_mbox (const void *ctx,
\r
896 + notmuch_mailstore_t *mailstore,
\r
897 notmuch_message_t *message,
\r
898 unused (int indent))
\r
900 @@ -285,7 +292,7 @@ format_message_mbox (const void *ctx,
\r
904 - from = notmuch_message_get_header (message, "from");
\r
905 + from = notmuch_message_get_header (mailstore, message, "from");
\r
906 from = _extract_email_address (ctx, from);
\r
908 date = notmuch_message_get_date (message);
\r
909 @@ -327,7 +334,7 @@ format_headers_message_part_text (GMimeMessage *message)
\r
913 -format_headers_json (const void *ctx, notmuch_message_t *message)
\r
914 +format_headers_json (const void *ctx, notmuch_mailstore_t *mailstore, notmuch_message_t *message)
\r
916 const char *headers[] = {
\r
917 "Subject", "From", "To", "Cc", "Bcc", "Date"
\r
918 @@ -339,7 +346,7 @@ format_headers_json (const void *ctx, notmuch_message_t *message)
\r
920 for (i = 0; i < ARRAY_SIZE (headers); i++) {
\r
922 - value = notmuch_message_get_header (message, name);
\r
923 + value = notmuch_message_get_header (mailstore, message, name);
\r
927 @@ -719,7 +726,8 @@ format_part_content_raw (GMimeObject *part)
\r
931 -format_part_text (const void *ctx, mime_node_t *node,
\r
932 +format_part_text (const void *ctx, notmuch_mailstore_t *mailstore,
\r
933 + mime_node_t *node,
\r
934 int indent, const notmuch_show_params_t *params)
\r
936 /* The disposition and content-type metadata are associated with
\r
937 @@ -768,7 +776,8 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
939 printf ("\fheader{\n");
\r
940 if (node->envelope_file)
\r
941 - printf ("%s\n", _get_one_line_summary (ctx, node->envelope_file));
\r
942 + printf ("%s\n", _get_one_line_summary (ctx, mailstore,
\r
943 + node->envelope_file));
\r
944 printf ("Subject: %s\n", g_mime_message_get_subject (message));
\r
945 printf ("From: %s\n", g_mime_message_get_sender (message));
\r
946 recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
\r
947 @@ -800,7 +809,8 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
950 for (i = 0; i < node->nchildren; i++)
\r
951 - format_part_text (ctx, mime_node_child (node, i), indent, params);
\r
952 + format_part_text (ctx, mailstore, mime_node_child (node, i),
\r
955 if (GMIME_IS_MESSAGE (node->part))
\r
956 printf ("\fbody}\n");
\r
957 @@ -811,6 +821,7 @@ format_part_text (const void *ctx, mime_node_t *node,
\r
959 show_message (void *ctx,
\r
960 const notmuch_show_format_t *format,
\r
961 + notmuch_mailstore_t *mailstore,
\r
962 notmuch_message_t *message,
\r
964 notmuch_show_params_t *params)
\r
965 @@ -823,7 +834,7 @@ show_message (void *ctx,
\r
966 &root) == NOTMUCH_STATUS_SUCCESS &&
\r
967 (part = mime_node_seek_dfs (root, (params->part < 0 ?
\r
968 0 : params->part))))
\r
969 - format->part (local, part, indent, params);
\r
970 + format->part (local, mailstore, part, indent, params);
\r
971 talloc_free (local);
\r
974 @@ -831,11 +842,11 @@ show_message (void *ctx,
\r
975 if (params->part <= 0) {
\r
976 fputs (format->message_start, stdout);
\r
977 if (format->message)
\r
978 - format->message(ctx, message, indent);
\r
979 + format->message(ctx, mailstore, message, indent);
\r
981 fputs (format->header_start, stdout);
\r
982 if (format->header)
\r
983 - format->header(ctx, message);
\r
984 + format->header(ctx, mailstore, message);
\r
985 fputs (format->header_end, stdout);
\r
987 fputs (format->body_start, stdout);
\r
988 @@ -854,6 +865,7 @@ show_message (void *ctx,
\r
990 show_messages (void *ctx,
\r
991 const notmuch_show_format_t *format,
\r
992 + notmuch_mailstore_t *mailstore,
\r
993 notmuch_messages_t *messages,
\r
995 notmuch_show_params_t *params)
\r
996 @@ -882,7 +894,7 @@ show_messages (void *ctx,
\r
997 next_indent = indent;
\r
999 if (match || params->entire_thread) {
\r
1000 - show_message (ctx, format, message, indent, params);
\r
1001 + show_message (ctx, format, mailstore, message, indent, params);
\r
1002 next_indent = indent + 1;
\r
1004 fputs (format->message_set_sep, stdout);
\r
1005 @@ -890,6 +902,7 @@ show_messages (void *ctx,
\r
1007 show_messages (ctx,
\r
1010 notmuch_message_get_replies (message),
\r
1013 @@ -905,6 +918,7 @@ show_messages (void *ctx,
\r
1014 /* Formatted output of single message */
\r
1016 do_show_single (void *ctx,
\r
1017 + notmuch_mailstore_t *mailstore,
\r
1018 notmuch_query_t *query,
\r
1019 const notmuch_show_format_t *format,
\r
1020 notmuch_show_params_t *params)
\r
1021 @@ -966,7 +980,7 @@ do_show_single (void *ctx,
\r
1025 - show_message (ctx, format, message, 0, params);
\r
1026 + show_message (ctx, format, mailstore, message, 0, params);
\r
1030 @@ -976,6 +990,7 @@ do_show_single (void *ctx,
\r
1031 /* Formatted output of threads */
\r
1033 do_show (void *ctx,
\r
1034 + notmuch_mailstore_t *mailstore,
\r
1035 notmuch_query_t *query,
\r
1036 const notmuch_show_format_t *format,
\r
1037 notmuch_show_params_t *params)
\r
1038 @@ -1003,7 +1018,7 @@ do_show (void *ctx,
\r
1039 fputs (format->message_set_sep, stdout);
\r
1040 first_toplevel = 0;
\r
1042 - show_messages (ctx, format, messages, 0, params);
\r
1043 + show_messages (ctx, format, mailstore, messages, 0, params);
\r
1045 notmuch_thread_destroy (thread);
\r
1047 @@ -1027,6 +1042,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
1049 notmuch_config_t *config;
\r
1050 notmuch_database_t *notmuch;
\r
1051 + notmuch_mailstore_t *mailstore;
\r
1052 notmuch_query_t *query;
\r
1053 char *query_string;
\r
1054 int opt_index, ret;
\r
1055 @@ -1122,7 +1138,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
1059 - notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
1060 + mailstore = notmuch_config_get_mailstore (config);
\r
1061 + notmuch = notmuch_database_open (mailstore,
\r
1062 + notmuch_config_get_database_path (config),
\r
1063 NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
1064 if (notmuch == NULL)
\r
1066 @@ -1134,9 +1152,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
1069 if (params.part >= 0)
\r
1070 - ret = do_show_single (ctx, query, format, ¶ms);
\r
1071 + ret = do_show_single (ctx, mailstore, query, format, ¶ms);
\r
1073 - ret = do_show (ctx, query, format, ¶ms);
\r
1074 + ret = do_show (ctx, mailstore, query, format, ¶ms);
\r
1076 notmuch_query_destroy (query);
\r
1077 notmuch_database_close (notmuch);
\r
1078 diff --git a/notmuch-tag.c b/notmuch-tag.c
\r
1079 index 36b9b09..5e8d74a 100644
\r
1080 --- a/notmuch-tag.c
\r
1081 +++ b/notmuch-tag.c
\r
1082 @@ -187,7 +187,8 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
\r
1083 if (config == NULL)
\r
1086 - notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
1087 + notmuch = notmuch_database_open (notmuch_config_get_mailstore (config),
\r
1088 + notmuch_config_get_database_path (config),
\r
1089 NOTMUCH_DATABASE_MODE_READ_WRITE);
\r
1090 if (notmuch == NULL)
\r
1092 diff --git a/test/symbol-test.cc b/test/symbol-test.cc
\r
1093 index 1548ca4..36c6ddb 100644
\r
1094 --- a/test/symbol-test.cc
\r
1095 +++ b/test/symbol-test.cc
\r
1100 - (void) notmuch_database_open("fakedb", NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
1101 + (void) notmuch_database_open (notmuch_mailstore_get_by_name ("maildir"),
\r
1102 + "fakedb", NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
1105 (void) new Xapian::WritableDatabase("./nonexistant", Xapian::DB_OPEN);
\r