From: Peter Wang Date: Sun, 20 Jan 2013 00:49:45 +0000 (+1100) Subject: [PATCH v3 01/20] cli: add stub for insert command X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=590c4999bc402d6c83db3d8430d18c7dd1691f82;p=notmuch-archives.git [PATCH v3 01/20] cli: add stub for insert command --- diff --git a/d6/12e056325f24e60055f0c5e7fc39ee08f1503f b/d6/12e056325f24e60055f0c5e7fc39ee08f1503f new file mode 100644 index 000000000..2d35f57f9 --- /dev/null +++ b/d6/12e056325f24e60055f0c5e7fc39ee08f1503f @@ -0,0 +1,175 @@ +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 B2FE1431FD6 + for ; Sat, 19 Jan 2013 16:50:41 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, 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 XObZwNJscWfN for ; + Sat, 19 Jan 2013 16:50:40 -0800 (PST) +Received: from mail-da0-f47.google.com (mail-da0-f47.google.com + [209.85.210.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 2E560431FB6 + for ; Sat, 19 Jan 2013 16:50:40 -0800 (PST) +Received: by mail-da0-f47.google.com with SMTP id s35so2162804dak.34 + for ; Sat, 19 Jan 2013 16:50:38 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to + :references:mime-version:content-type:content-transfer-encoding; + bh=rH20fsxEfTcU/1UXvdaNpQTYJGGtR9D/WwNSv9grl4s=; + b=LZVtn0Vbbbv8o1B+LCFZJmfWrtKG0UdciQ3g2ptmksTTqBneD8X6uyohTQ6rxXzkWq + NBGcomp15Ldnv6w3TmbXSgoO4eP+MFEUpnif6ez8DJomKqh3k/odQpVc42gscmcXLBzG + DJivG+/7kHcMViTIMKHfw+JOIQa0GQt2H9KHgyVZBz2dp/TlAJTs96FlU4GskREWC7bt + vdd5xHo5VFbBwNFBCg4OO/fFZl47sw9t8fBKHCUbV2MD/Mb2DThXtexolX2QGy++jc+K + +kauFBk1QDXCxhZe7eEUis4IDZ3SqRmNrwkEP8L9RAOh+B0AOHhojGoNiaWBEO6aO5ld + HEOg== +X-Received: by 10.66.84.232 with SMTP id c8mr36576008paz.8.1358643038139; + Sat, 19 Jan 2013 16:50:38 -0800 (PST) +Received: from localhost (215.42.233.220.static.exetel.com.au. + [220.233.42.215]) + by mx.google.com with ESMTPS id a9sm6265419pav.24.2013.01.19.16.50.35 + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 19 Jan 2013 16:50:37 -0800 (PST) +From: Peter Wang +To: notmuch@notmuchmail.org +Subject: [PATCH v3 01/20] cli: add stub for insert command +Date: Sun, 20 Jan 2013 11:49:45 +1100 +Message-Id: <1358643004-14522-2-git-send-email-novalazy@gmail.com> +X-Mailer: git-send-email 1.7.12.1 +In-Reply-To: <1358643004-14522-1-git-send-email-novalazy@gmail.com> +References: <1358643004-14522-1-git-send-email-novalazy@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +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, 20 Jan 2013 00:50:41 -0000 + +The notmuch insert command should read a message from standard input +and deliver it to a Maildir folder, and then incorporate the message +into the notmuch database. Essentially it moves the functionality of +notmuch-deliver into notmuch. + +Though it could be used as an alternative to notmuch new, the reason +I want this is to allow my notmuch frontend to add postponed or sent +messages to the mail store and notmuch database, without resorting to +another tool (e.g. notmuch-deliver) nor directly modifying the maildir. +--- + Makefile.local | 1 + + notmuch-client.h | 3 +++ + notmuch-insert.c | 43 +++++++++++++++++++++++++++++++++++++++++++ + notmuch.c | 3 +++ + 4 files changed, 50 insertions(+) + create mode 100644 notmuch-insert.c + +diff --git a/Makefile.local b/Makefile.local +index c274f07..bb2381d 100644 +--- a/Makefile.local ++++ b/Makefile.local +@@ -261,6 +261,7 @@ notmuch_client_srcs = \ + notmuch-config.c \ + notmuch-count.c \ + notmuch-dump.c \ ++ notmuch-insert.c \ + notmuch-new.c \ + notmuch-reply.c \ + notmuch-restore.c \ +diff --git a/notmuch-client.h b/notmuch-client.h +index 5f28836..af7d094 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -175,6 +175,9 @@ int + notmuch_dump_command (void *ctx, int argc, char *argv[]); + + int ++notmuch_insert_command (void *ctx, int argc, char *argv[]); ++ ++int + notmuch_new_command (void *ctx, int argc, char *argv[]); + + int +diff --git a/notmuch-insert.c b/notmuch-insert.c +new file mode 100644 +index 0000000..c1d359c +--- /dev/null ++++ b/notmuch-insert.c +@@ -0,0 +1,43 @@ ++/* notmuch - Not much of an email program, (just index and search) ++ * ++ * Copyright © 2013 Peter Wang ++ * ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program. If not, see http://www.gnu.org/licenses/ . ++ * ++ * Author: Peter Wang ++ */ ++ ++#include "notmuch-client.h" ++ ++int ++notmuch_insert_command (void *ctx, int argc, char *argv[]) ++{ ++ notmuch_config_t *config; ++ notmuch_database_t *notmuch; ++ const char *db_path; ++ ++ config = notmuch_config_open (ctx, NULL, NULL); ++ if (config == NULL) ++ return 1; ++ ++ db_path = notmuch_config_get_database_path (config); ++ ++ if (notmuch_database_open (notmuch_config_get_database_path (config), ++ NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) ++ return 1; ++ ++ notmuch_database_destroy (notmuch); ++ ++ return 1; ++} +diff --git a/notmuch.c b/notmuch.c +index 4fc0973..1c3b893 100644 +--- a/notmuch.c ++++ b/notmuch.c +@@ -53,6 +53,9 @@ static command_t commands[] = { + { "new", notmuch_new_command, + "[options...]", + "Find and import new messages to the notmuch database." }, ++ { "insert", notmuch_insert_command, ++ "[options...] [--] [+|- ...] < message", ++ "Add a new message into the maildir and notmuch database." }, + { "search", notmuch_search_command, + "[options...] [...]", + "Search for messages matching the given search terms." }, +-- +1.7.12.1 +