dovecot-2.0: lib-storage: Added MAILBOX_GLOB search arg. Query b...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Apr 28 22:09:22 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/3c9770bae39e
changeset: 11197:3c9770bae39e
user: Timo Sirainen <tss at iki.fi>
date: Wed Apr 28 18:09:43 2010 +0300
description:
lib-storage: Added MAILBOX_GLOB search arg. Query builders now use it instead of MAILBOX.
diffstat:
src/lib-storage/index/index-search.c | 7 +++++++
src/lib-storage/mail-search-register-human.c | 2 +-
src/lib-storage/mail-search-register-imap.c | 2 +-
src/lib-storage/mail-search.c | 21 +++++++++++++++++++--
src/lib-storage/mail-search.h | 7 +++++--
5 files changed, 33 insertions(+), 6 deletions(-)
diffs (149 lines):
diff -r 6b38d832839f -r 3c9770bae39e src/lib-storage/index/index-search.c
--- a/src/lib-storage/index/index-search.c Wed Apr 28 17:50:30 2010 +0300
+++ b/src/lib-storage/index/index-search.c Wed Apr 28 18:09:43 2010 +0300
@@ -7,6 +7,7 @@
#include "utc-offset.h"
#include "str.h"
#include "time-util.h"
+#include "imap-match.h"
#include "message-address.h"
#include "message-date.h"
#include "message-search.h"
@@ -285,6 +286,11 @@
if (strcasecmp(str, "INBOX") == 0)
return strcasecmp(arg->value.str, "INBOX") == 0;
return strcmp(str, arg->value.str) == 0;
+ case SEARCH_MAILBOX_GLOB:
+ if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME,
+ &str) < 0)
+ return -1;
+ return imap_match(arg->value.mailbox_glob, str) == IMAP_MATCH_YES;
default:
return -1;
}
@@ -1176,6 +1182,7 @@
case SEARCH_TEXT_FAST:
case SEARCH_GUID:
case SEARCH_MAILBOX:
+ case SEARCH_MAILBOX_GLOB:
return TRUE;
}
return FALSE;
diff -r 6b38d832839f -r 3c9770bae39e src/lib-storage/mail-search-register-human.c
--- a/src/lib-storage/mail-search-register-human.c Wed Apr 28 17:50:30 2010 +0300
+++ b/src/lib-storage/mail-search-register-human.c Wed Apr 28 18:09:43 2010 +0300
@@ -128,7 +128,7 @@
static struct mail_search_arg *
human_search_mailbox(struct mail_search_build_context *ctx)
{
- return mail_search_build_str(ctx, SEARCH_MAILBOX);
+ return mail_search_build_str(ctx, SEARCH_MAILBOX_GLOB);
}
static const struct mail_search_register_arg human_register_args[] = {
diff -r 6b38d832839f -r 3c9770bae39e src/lib-storage/mail-search-register-imap.c
--- a/src/lib-storage/mail-search-register-imap.c Wed Apr 28 17:50:30 2010 +0300
+++ b/src/lib-storage/mail-search-register-imap.c Wed Apr 28 18:09:43 2010 +0300
@@ -426,7 +426,7 @@
}
CALLBACK_STR(x_guid, SEARCH_GUID);
-CALLBACK_STR(x_mailbox, SEARCH_MAILBOX);
+CALLBACK_STR(x_mailbox, SEARCH_MAILBOX_GLOB);
const struct mail_search_register_arg imap_register_args[] = {
/* argument set operations */
diff -r 6b38d832839f -r 3c9770bae39e src/lib-storage/mail-search.c
--- a/src/lib-storage/mail-search.c Wed Apr 28 17:50:30 2010 +0300
+++ b/src/lib-storage/mail-search.c Wed Apr 28 18:09:43 2010 +0300
@@ -2,9 +2,10 @@
#include "lib.h"
#include "array.h"
-#include "buffer.h"
+#include "imap-match.h"
#include "mail-index.h"
#include "mail-storage.h"
+#include "mail-namespace.h"
#include "mail-search-build.h"
#include "mail-search.h"
@@ -92,6 +93,15 @@
keywords);
break;
+ case SEARCH_MAILBOX_GLOB: {
+ struct mail_namespace *ns =
+ mailbox_get_namespace(args->box);
+
+ arg->value.mailbox_glob =
+ imap_match_init(default_pool, arg->value.str,
+ TRUE, ns->sep);
+ break;
+ }
case SEARCH_INTHREAD:
thread_args = arg->value.search_args;
if (thread_args == NULL) {
@@ -150,6 +160,12 @@
break;
mailbox_keywords_unref(args->box, &arg->value.keywords);
break;
+ case SEARCH_MAILBOX_GLOB:
+ if (arg->value.mailbox_glob == NULL)
+ break;
+
+ imap_match_deinit(&arg->value.mailbox_glob);
+ break;
case SEARCH_INTHREAD:
i_assert(arg->value.search_args->refcount > 0);
if (args->refcount == 0 &&
@@ -296,9 +312,9 @@
case SEARCH_TEXT_FAST:
case SEARCH_GUID:
case SEARCH_MAILBOX:
+ case SEARCH_MAILBOX_GLOB:
new_arg->value.str = p_strdup(pool, arg->value.str);
break;
-
case SEARCH_MODSEQ:
new_arg->value.modseq =
p_new(pool, struct mail_search_modseq, 1);
@@ -770,6 +786,7 @@
case SEARCH_TEXT_FAST:
case SEARCH_GUID:
case SEARCH_MAILBOX:
+ 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
full i18n case-insensitivity (or the active comparator
diff -r 6b38d832839f -r 3c9770bae39e src/lib-storage/mail-search.h
--- a/src/lib-storage/mail-search.h Wed Apr 28 17:50:30 2010 +0300
+++ b/src/lib-storage/mail-search.h Wed Apr 28 18:09:43 2010 +0300
@@ -42,7 +42,8 @@
SEARCH_MODSEQ,
SEARCH_INTHREAD,
SEARCH_GUID,
- SEARCH_MAILBOX
+ SEARCH_MAILBOX,
+ SEARCH_MAILBOX_GLOB
};
enum mail_search_date_type {
@@ -86,6 +87,7 @@
struct mail_search_modseq *modseq;
struct mail_search_args *search_args;
struct mail_search_result *search_result;
+ struct imap_match_glob *mailbox_glob;
} value;
void *context;
@@ -166,7 +168,8 @@
mail_search_args_analyze(struct mail_search_arg *args,
bool *have_headers, bool *have_body);
-/* Simplify/optimize search arguments */
+/* Simplify/optimize search arguments. Afterwards all OR/SUB args are
+ guaranteed to have not=FALSE. */
void mail_search_args_simplify(struct mail_search_args *args);
#endif
More information about the dovecot-cvs
mailing list