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 B8913431FBC for ; Sun, 1 Jul 2012 09:46:07 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 1.061 X-Spam-Level: * X-Spam-Status: No, score=1.061 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_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_LOW=-0.7, 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 gB2xCOqmtyvR for ; Sun, 1 Jul 2012 09:46:07 -0700 (PDT) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id BBD09431FAF for ; Sun, 1 Jul 2012 09:46:06 -0700 (PDT) Received: by wgbdt14 with SMTP id dt14so3720895wgb.2 for ; Sun, 01 Jul 2012 09:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=YHzkxLnuVlTBuioDrrEwI0x6FOi3UmhIQIDC0yQ+AB8=; b=uMXdbO7bTW2qk5jMSTzBvoPoKvlULSNIH7C4kNd0Pnkd+bamxi0j/0qolEeT1FQ/cV haym2FOwjfBjYfZQ1AY+dZz3zr0S/UGQgP2MeZeyFpQnCKtHu9+tvONy/9GSGgC8vIWo 9kXeeEDNvFZy7R2MPB3GFhIPyv28X0zzbEY2/kJyns/jqRCuLPKbMnE5afGuL2+YyLRc M4M3QQKYv8fl4AMNZ4v/m7eOzm+UDHGiIvNHNvhYIYOHQy29WH9K3EwMPK6ZsvlzvgnR HMrVpNLBzjMWlMynDEmMsKRQQnBtbd7AJ6Bg27NCwqUdecCWGOviYR3TMqzYgTa72aeJ 0pEg== Received: by 10.216.226.32 with SMTP id a32mr439540weq.190.1341161165346; Sun, 01 Jul 2012 09:46:05 -0700 (PDT) Received: from localhost ([195.24.209.21]) by mx.google.com with ESMTPS id fw4sm19720264wib.0.2012.07.01.09.45.48 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Jul 2012 09:46:04 -0700 (PDT) From: Ethan Glasser-Camp To: notmuch@notmuchmail.org Subject: [PATCH v2 4/8] new: add "scan" option Date: Sun, 1 Jul 2012 12:39:46 -0400 Message-Id: <1341160790-14525-5-git-send-email-ethan@betacantrips.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341160790-14525-1-git-send-email-ethan@betacantrips.com> References: <1341160790-14525-1-git-send-email-ethan@betacantrips.com> 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: Sun, 01 Jul 2012 16:46:07 -0000 The new.scan option is a list of URLs that can be "scanned". The fact that the database maildir is scanned "automagically" is a little weird, but it doesn't do any harm unless you decide to put mail there that you really don't want indexed. Signed-off-by: Ethan Glasser-Camp --- I added text here to respond to Mark Walters's confusion regarding how I implemented scanning. notmuch-client.h | 9 +++++++++ notmuch-config.c | 33 ++++++++++++++++++++++++++++++++- notmuch-new.c | 18 ++++++++++++++++++ test/config | 1 + 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/notmuch-client.h b/notmuch-client.h index 0c17b79..20349b2 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -257,6 +257,15 @@ notmuch_config_set_new_ignore (notmuch_config_t *config, const char *new_ignore[], size_t length); +const char ** +notmuch_config_get_new_scan (notmuch_config_t *config, + size_t *length); + +void +notmuch_config_set_new_scan (notmuch_config_t *config, + const char *new_scan[], + size_t length); + notmuch_bool_t notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config); diff --git a/notmuch-config.c b/notmuch-config.c index 3e37a2d..387f855 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -50,7 +50,13 @@ static const char new_config_comment[] = "\t that will not be searched for messages by \"notmuch new\".\n" "\n" "\t NOTE: *Every* file/directory that goes by one of those names will\n" - "\t be ignored, independent of its depth/location in the mail store.\n"; + "\t be ignored, independent of its depth/location in the mail store.\n" + "\n" + "\tscan A list (separated by ';') of mail URLs to scan.\n" + "\t Each URL denotes a \"root\" which will be searched for mail files.\n" + "\t How this search is performed depends on the scheme of the URL (the\n" + "\t part before the first colon).\n" + "\t The maildir located at database.path, above, will automatically be added.\n"; static const char user_config_comment[] = " User configuration\n" @@ -113,6 +119,8 @@ struct _notmuch_config { size_t new_tags_length; const char **new_ignore; size_t new_ignore_length; + const char **new_scan; + size_t new_scan_length; notmuch_bool_t maildir_synchronize_flags; const char **search_exclude_tags; size_t search_exclude_tags_length; @@ -274,6 +282,8 @@ notmuch_config_open (void *ctx, config->new_tags_length = 0; config->new_ignore = NULL; config->new_ignore_length = 0; + config->new_scan = NULL; + config->new_scan_length = 0; config->maildir_synchronize_flags = TRUE; config->search_exclude_tags = NULL; config->search_exclude_tags_length = 0; @@ -375,6 +385,10 @@ notmuch_config_open (void *ctx, notmuch_config_set_new_ignore (config, NULL, 0); } + if (notmuch_config_get_new_scan (config, &tmp) == NULL) { + notmuch_config_set_new_scan (config, NULL, 0); + } + if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) { if (is_new) { const char *tags[] = { "deleted", "spam" }; @@ -631,6 +645,14 @@ notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length) &(config->new_ignore_length), length); } +const char ** +notmuch_config_get_new_scan (notmuch_config_t *config, size_t *length) +{ + return _config_get_list (config, "new", "scan", + &(config->new_scan), + &(config->new_scan_length), length); +} + void notmuch_config_set_user_other_email (notmuch_config_t *config, const char *list[], @@ -658,6 +680,15 @@ notmuch_config_set_new_ignore (notmuch_config_t *config, &(config->new_ignore)); } +void +notmuch_config_set_new_scan (notmuch_config_t *config, + const char *list[], + size_t length) +{ + _config_set_list (config, "new", "scan", list, length, + &(config->new_scan)); +} + const char ** notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length) { diff --git a/notmuch-new.c b/notmuch-new.c index 938ae29..8377750 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -607,6 +607,16 @@ add_files (notmuch_database_t *notmuch, return ret; } +/* Call out to the appropriate add_files function, based on the URI. */ +static notmuch_status_t +add_files_uri (unused(notmuch_database_t *notmuch), + unused(const char *uri), + unused(add_files_state_t *state)) +{ + /* Stub for now */ + return NOTMUCH_STATUS_SUCCESS; +} + static void setup_progress_printing_timer (void) { @@ -832,6 +842,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) int ret = 0; struct stat st; const char *db_path; + const char **new_scan; + size_t new_scan_length, new_scan_i; char *dot_notmuch_path; struct sigaction action; _filename_node_t *f; @@ -930,6 +942,12 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) timer_is_active = TRUE; } + new_scan = notmuch_config_get_new_scan (config, &new_scan_length); + + for (new_scan_i = 0; new_scan_i < new_scan_length; new_scan_i++) { + add_files_uri (notmuch, new_scan[new_scan_i], &add_files_state); + } + ret = add_files (notmuch, db_path, &add_files_state); if (ret) goto DONE; diff --git a/test/config b/test/config index 93ecb13..b0ad0c1 100755 --- a/test/config +++ b/test/config @@ -52,6 +52,7 @@ user.primary_email=test_suite@notmuchmail.org user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org new.tags=unread;inbox; new.ignore= +new.scan= search.exclude_tags= maildir.synchronize_flags=true foo.string=this is another string value -- 1.7.9.5