dovecot-2.1: Show SEARCH=FUZZY in IMAP capabilities only when FT...

dovecot at dovecot.org dovecot at dovecot.org
Tue Feb 28 18:50:58 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/bdc881838b00
changeset: 14208:bdc881838b00
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Feb 28 18:50:46 2012 +0200
description:
Show SEARCH=FUZZY in IMAP capabilities only when FTS backend actually supports it.

diffstat:

 configure.in                                |  2 +-
 src/imap/imap-client.c                      |  5 +++++
 src/lib-storage/mail-user.h                 |  2 ++
 src/plugins/fts-lucene/fts-backend-lucene.c |  3 ++-
 src/plugins/fts-solr/fts-backend-solr.c     |  2 +-
 src/plugins/fts/fts-api-private.h           |  4 +++-
 src/plugins/fts/fts-storage.c               |  3 +++
 7 files changed, 17 insertions(+), 4 deletions(-)

diffs (91 lines):

diff -r ba2b4f8a1bb1 -r bdc881838b00 configure.in
--- a/configure.in	Tue Feb 28 06:52:43 2012 +0200
+++ b/configure.in	Tue Feb 28 18:50:46 2012 +0200
@@ -2697,7 +2697,7 @@
 dnl IDLE doesn't really belong to banner. It's there just to make Blackberries
 dnl happy, because otherwise BIS server disables push email.
 capability_banner="IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE"
-capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SEARCH=FUZZY SPECIAL-USE"
+capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE"
 AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", IMAP capabilities)
 AC_DEFINE_UNQUOTED(CAPABILITY_BANNER_STRING, "$capability_banner", IMAP capabilities advertised in banner) 
 
diff -r ba2b4f8a1bb1 -r bdc881838b00 src/imap/imap-client.c
--- a/src/imap/imap-client.c	Tue Feb 28 06:52:43 2012 +0200
+++ b/src/imap/imap-client.c	Tue Feb 28 18:50:46 2012 +0200
@@ -82,6 +82,11 @@
 		str_append_c(client->capability_string, ' ');
 		str_append(client->capability_string, set->imap_capability + 1);
 	}
+	if (user->fuzzy_search) {
+		/* Enable FUZZY capability only when it actually has
+		   a chance of working */
+		str_append(client->capability_string, " SEARCH=FUZZY");
+	}
 
 	ident = mail_user_get_anvil_userip_ident(client->user);
 	if (ident != NULL) {
diff -r ba2b4f8a1bb1 -r bdc881838b00 src/lib-storage/mail-user.h
--- a/src/lib-storage/mail-user.h	Tue Feb 28 06:52:43 2012 +0200
+++ b/src/lib-storage/mail-user.h	Tue Feb 28 18:50:46 2012 +0200
@@ -54,6 +54,8 @@
 	unsigned int mail_debug:1;
 	/* If INBOX can't be opened, log an error, but only once. */
 	unsigned int inbox_open_error_logged:1;
+	/* Fuzzy search works for this user (FTS enabled) */
+	unsigned int fuzzy_search:1;
 };
 
 struct mail_user_module_register {
diff -r ba2b4f8a1bb1 -r bdc881838b00 src/plugins/fts-lucene/fts-backend-lucene.c
--- a/src/plugins/fts-lucene/fts-backend-lucene.c	Tue Feb 28 06:52:43 2012 +0200
+++ b/src/plugins/fts-lucene/fts-backend-lucene.c	Tue Feb 28 18:50:46 2012 +0200
@@ -552,7 +552,8 @@
 
 struct fts_backend fts_backend_lucene = {
 	.name = "lucene",
-	.flags = FTS_BACKEND_FLAG_BUILD_FULL_WORDS,
+	.flags = FTS_BACKEND_FLAG_BUILD_FULL_WORDS |
+		FTS_BACKEND_FLAG_FUZZY_SEARCH,
 
 	{
 		fts_backend_lucene_alloc,
diff -r ba2b4f8a1bb1 -r bdc881838b00 src/plugins/fts-solr/fts-backend-solr.c
--- a/src/plugins/fts-solr/fts-backend-solr.c	Tue Feb 28 06:52:43 2012 +0200
+++ b/src/plugins/fts-solr/fts-backend-solr.c	Tue Feb 28 18:50:46 2012 +0200
@@ -833,7 +833,7 @@
 
 struct fts_backend fts_backend_solr = {
 	.name = "solr",
-	.flags = 0,
+	.flags = FTS_BACKEND_FLAG_FUZZY_SEARCH,
 
 	{
 		fts_backend_solr_alloc,
diff -r ba2b4f8a1bb1 -r bdc881838b00 src/plugins/fts/fts-api-private.h
--- a/src/plugins/fts/fts-api-private.h	Tue Feb 28 06:52:43 2012 +0200
+++ b/src/plugins/fts/fts-api-private.h	Tue Feb 28 18:50:46 2012 +0200
@@ -57,7 +57,9 @@
 	   preserving original case */
 	FTS_BACKEND_FLAG_BUILD_DTCASE		= 0x02,
 	/* Send only fully indexable words rather than randomly sized blocks */
-	FTS_BACKEND_FLAG_BUILD_FULL_WORDS	= 0x04
+	FTS_BACKEND_FLAG_BUILD_FULL_WORDS	= 0x04,
+	/* Fuzzy search works */
+	FTS_BACKEND_FLAG_FUZZY_SEARCH		= 0x08
 };
 
 struct fts_backend {
diff -r ba2b4f8a1bb1 -r bdc881838b00 src/plugins/fts/fts-storage.c
--- a/src/plugins/fts/fts-storage.c	Tue Feb 28 06:52:43 2012 +0200
+++ b/src/plugins/fts/fts-storage.c	Tue Feb 28 18:50:46 2012 +0200
@@ -637,6 +637,9 @@
 		struct fts_mailbox_list *flist;
 		struct mailbox_list_vfuncs *v = list->vlast;
 
+		if ((backend->flags & FTS_BACKEND_FLAG_FUZZY_SEARCH) != 0)
+			list->ns->user->fuzzy_search = TRUE;
+
 		flist = p_new(list->pool, struct fts_mailbox_list, 1);
 		flist->module_ctx.super = *v;
 		flist->backend = backend;


More information about the dovecot-cvs mailing list