From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 405B46DE119D for ; Sat, 19 Aug 2017 18:07:50 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[AWL=0.011, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6ST5PkauW9F8 for ; Sat, 19 Aug 2017 18:07:49 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 1288A6DE1149 for ; Sat, 19 Aug 2017 18:07:48 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1djEf0-0004Ln-89; Sat, 19 Aug 2017 21:04:14 -0400 Received: (nullmailer pid 30244 invoked by uid 1000); Sun, 20 Aug 2017 01:07:40 -0000 From: David Bremner To: notmuch@notmuchmail.org, notmuch@freelists.org Subject: [PATCH 1/3] lib/message: split n_m_maildir_flags_tags, store maildir flags Date: Sat, 19 Aug 2017 22:07:25 -0300 Message-Id: <20170820010727.30117-2-david@tethera.net> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170820010727.30117-1-david@tethera.net> References: <20170820010727.30117-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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 Aug 2017 01:07:50 -0000 In a future commit this will allow querying maildir flags seperately from tags to allow resolving certain conflicts. --- lib/message.cc | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 539d3320..18f830dd 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -36,6 +36,7 @@ struct _notmuch_message { notmuch_string_list_t *tag_list; notmuch_string_list_t *filename_term_list; notmuch_string_list_t *filename_list; + char *maildir_flags; char *author; notmuch_message_file_t *message_file; notmuch_string_list_t *property_term_list; @@ -123,6 +124,7 @@ _notmuch_message_create_for_document (const void *talloc_owner, message->tag_list = NULL; message->filename_term_list = NULL; message->filename_list = NULL; + message->maildir_flags = NULL; message->message_file = NULL; message->author = NULL; message->property_term_list = NULL; @@ -1513,17 +1515,22 @@ _filename_is_in_maildir (const char *filename) return NULL; } -notmuch_status_t -notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) +static void +_ensure_maildir_flags (notmuch_message_t *message, notmuch_bool_t force) { const char *flags; - notmuch_status_t status; notmuch_filenames_t *filenames; const char *filename, *dir; char *combined_flags = talloc_strdup (message, ""); - unsigned i; int seen_maildir_info = 0; + if (message->maildir_flags) { + if (force) { + talloc_free (message->maildir_flags); + message->maildir_flags = NULL; + } + } + for (filenames = notmuch_message_get_filenames (message); notmuch_filenames_valid (filenames); notmuch_filenames_move_to_next (filenames)) @@ -1549,11 +1556,21 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) seen_maildir_info = 1; } } + if (seen_maildir_info) + message->maildir_flags = combined_flags; +} +notmuch_status_t +notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) +{ + notmuch_status_t status; + unsigned i; + + _ensure_maildir_flags (message, TRUE); /* If none of the filenames have any maildir info field (not even * an empty info with no flags set) then there's no information to * go on, so do nothing. */ - if (! seen_maildir_info) + if (! message->maildir_flags) return NOTMUCH_STATUS_SUCCESS; status = notmuch_message_freeze (message); @@ -1561,7 +1578,7 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) return status; for (i = 0; i < ARRAY_SIZE(flag2tag); i++) { - if ((strchr (combined_flags, flag2tag[i].flag) != NULL) + if ((strchr (message->maildir_flags, flag2tag[i].flag) != NULL) ^ flag2tag[i].inverse) { @@ -1574,8 +1591,6 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) } status = notmuch_message_thaw (message); - talloc_free (combined_flags); - return status; } -- 2.13.2