]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added support for searching with mailbox GUID.
authorTimo Sirainen <tss@iki.fi>
Fri, 30 Apr 2010 12:32:50 +0000 (15:32 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 30 Apr 2010 12:32:50 +0000 (15:32 +0300)
--HG--
branch : HEAD

src/lib-storage/index/index-search.c
src/lib-storage/mail-search-register-human.c
src/lib-storage/mail-search.c
src/lib-storage/mail-search.h

index 7f90b4c038f8def1c7a9297c5758184bc9a4d909..00792f4369f2a72901a219e39208571a4620904e 100644 (file)
@@ -218,6 +218,7 @@ static int search_arg_match_cached(struct index_search_context *ctx,
        time_t date;
        int tz_offset;
        bool have_tz_offset;
+       uint8_t guid[MAIL_GUID_128_SIZE];
 
        switch (arg->type) {
        /* internal dates */
@@ -286,6 +287,12 @@ static int search_arg_match_cached(struct index_search_context *ctx,
                if (strcasecmp(str, "INBOX") == 0)
                        return strcasecmp(arg->value.str, "INBOX") == 0;
                return strcmp(str, arg->value.str) == 0;
+       case SEARCH_MAILBOX_GUID:
+               if (mailbox_get_guid(ctx->mail->box, guid) < 0)
+                       return -1;
+
+               return strcmp(mail_guid_128_to_string(guid),
+                             arg->value.str) == 0;
        case SEARCH_MAILBOX_GLOB:
                if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME,
                                     &str) < 0)
@@ -1182,6 +1189,7 @@ static bool search_arg_is_static(struct mail_search_arg *arg)
        case SEARCH_TEXT_FAST:
        case SEARCH_GUID:
        case SEARCH_MAILBOX:
+       case SEARCH_MAILBOX_GUID:
        case SEARCH_MAILBOX_GLOB:
                return TRUE;
        }
index ffcce6ea9c5945b4814061734455dc87df38016d..077e46468911cc684bd78cd52d7533052ff16b1b 100644 (file)
@@ -131,6 +131,12 @@ human_search_mailbox(struct mail_search_build_context *ctx)
        return mail_search_build_str(ctx, SEARCH_MAILBOX_GLOB);
 }
 
+static struct mail_search_arg *
+human_search_mailbox_guid(struct mail_search_build_context *ctx)
+{
+       return mail_search_build_str(ctx, SEARCH_MAILBOX_GUID);
+}
+
 static const struct mail_search_register_arg human_register_args[] = {
        { "OR", human_search_or },
 
@@ -154,7 +160,8 @@ static const struct mail_search_register_arg human_register_args[] = {
 
        /* Other Dovecot extensions: */
        { "GUID", human_search_guid },
-       { "MAILBOX", human_search_mailbox }
+       { "MAILBOX", human_search_mailbox },
+       { "MAILBOX-GUID", human_search_mailbox_guid }
 };
 
 struct mail_search_register *
index ed3bf2df9031a4c2d695c321849c70b70599e153..bb5de76b455505aa6d38d6cfc2c886b6551c71eb 100644 (file)
@@ -312,6 +312,7 @@ mail_search_arg_dup_one(pool_t pool, const struct mail_search_arg *arg)
        case SEARCH_TEXT_FAST:
        case SEARCH_GUID:
        case SEARCH_MAILBOX:
+       case SEARCH_MAILBOX_GUID:
        case SEARCH_MAILBOX_GLOB:
                new_arg->value.str = p_strdup(pool, arg->value.str);
                break;
@@ -845,6 +846,7 @@ static bool mail_search_arg_one_equals(const struct mail_search_arg *arg1,
        case SEARCH_TEXT_FAST:
        case SEARCH_GUID:
        case SEARCH_MAILBOX:
+       case SEARCH_MAILBOX_GUID:
        case SEARCH_MAILBOX_GLOB:
                /* don't bother doing case-insensitive comparison. it must not
                   be done for guid/mailbox, and for others we should support
index 976798424d119e9c6d208bc90c0161df27537a20..4e5021dee62ec63e57eae0cd83ae2e805a24fdcf 100644 (file)
@@ -43,6 +43,7 @@ enum mail_search_arg_type {
        SEARCH_INTHREAD,
        SEARCH_GUID,
        SEARCH_MAILBOX,
+       SEARCH_MAILBOX_GUID,
        SEARCH_MAILBOX_GLOB
 };