[evolution-data-server/intel-work-3-12] EBookSqlite: Added support for transliterated regex queries.
- From: Mateusz Polrola <mpolrola src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/intel-work-3-12] EBookSqlite: Added support for transliterated regex queries.
- Date: Tue, 14 Oct 2014 12:56:21 +0000 (UTC)
commit 74f8d0c4144f23136674963586f87d0d7d60c3e8
Author: Mateusz Polrola <mateusz polrola gmail com>
Date: Thu Sep 25 14:06:15 2014 +0200
EBookSqlite: Added support for transliterated regex queries.
addressbook/libebook-contacts/e-book-query.c | 13 +++++++++++
addressbook/libebook-contacts/e-book-query.h | 1 +
addressbook/libedata-book/e-book-backend-sexp.c | 1 +
addressbook/libedata-book/e-book-sqlite.c | 27 +++++++++++++++++++++-
4 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-book-query.c b/addressbook/libebook-contacts/e-book-query.c
index 39b7c20..518fb31 100644
--- a/addressbook/libebook-contacts/e-book-query.c
+++ b/addressbook/libebook-contacts/e-book-query.c
@@ -670,6 +670,15 @@ func_regex_raw (struct _ESExp *f,
}
static ESExpResult *
+func_regex_translit (struct _ESExp *f,
+ gint argc,
+ struct _ESExpResult **argv,
+ gpointer data)
+{
+ return func_field_test (E_BOOK_QUERY_REGEX_TRANSLIT, f, argc, argv, data);
+}
+
+static ESExpResult *
func_translit_contains (struct _ESExp *f,
gint argc,
struct _ESExpResult **argv,
@@ -768,6 +777,7 @@ static const struct {
{ "eqphone", func_eqphone, 0 },
{ "eqphone_national", func_eqphone_national, 0 },
{ "eqphone_short", func_eqphone_short, 0 },
+ { "regex_translit", func_regex_translit, 0 },
{ "regex_normal", func_regex_normal, 0 },
{ "regex_raw", func_regex_raw, 0 },
{ "translit_is", func_translit_is, 0 },
@@ -854,6 +864,8 @@ field_test_name (EBookQueryTest field_test)
return "regex_normal";
case E_BOOK_QUERY_REGEX_RAW:
return "regex_raw";
+ case E_BOOK_QUERY_REGEX_TRANSLIT:
+ return "regex_translit";
case E_BOOK_QUERY_TRANSLIT_IS:
return "translit_is";
case E_BOOK_QUERY_TRANSLIT_CONTAINS:
@@ -884,6 +896,7 @@ is_phone_test (EBookQueryTest field_test)
case E_BOOK_QUERY_ENDS_WITH:
case E_BOOK_QUERY_REGEX_NORMAL:
case E_BOOK_QUERY_REGEX_RAW:
+ case E_BOOK_QUERY_REGEX_TRANSLIT:
case E_BOOK_QUERY_TRANSLIT_IS:
case E_BOOK_QUERY_TRANSLIT_CONTAINS:
case E_BOOK_QUERY_TRANSLIT_BEGINS_WITH:
diff --git a/addressbook/libebook-contacts/e-book-query.h b/addressbook/libebook-contacts/e-book-query.h
index 25c1e6b..1c74f4a 100644
--- a/addressbook/libebook-contacts/e-book-query.h
+++ b/addressbook/libebook-contacts/e-book-query.h
@@ -80,6 +80,7 @@ typedef enum {
E_BOOK_QUERY_REGEX_NORMAL,
E_BOOK_QUERY_REGEX_RAW,
+ E_BOOK_QUERY_REGEX_TRANSLIT,
E_BOOK_QUERY_TRANSLIT_IS,
E_BOOK_QUERY_TRANSLIT_CONTAINS,
diff --git a/addressbook/libedata-book/e-book-backend-sexp.c b/addressbook/libedata-book/e-book-backend-sexp.c
index 842b2ab..6b3f9bd 100644
--- a/addressbook/libedata-book/e-book-backend-sexp.c
+++ b/addressbook/libedata-book/e-book-backend-sexp.c
@@ -1256,6 +1256,7 @@ static struct {
{ "eqphone_national", func_eqphone_national, 0 },
{ "eqphone_short", func_eqphone_short, 0 },
{ "regex_normal", func_regex_normal, 0 },
+ { "regex_translit", func_regex_normal, 0 },
{ "regex_raw", func_regex_raw, 0 },
{ "exists", func_exists, 0 },
{ "exists_vcard", func_exists_vcard, 0 },
diff --git a/addressbook/libedata-book/e-book-sqlite.c b/addressbook/libedata-book/e-book-sqlite.c
index e0e7964..23d8d59 100644
--- a/addressbook/libedata-book/e-book-sqlite.c
+++ b/addressbook/libedata-book/e-book-sqlite.c
@@ -3856,6 +3856,7 @@ enum {
(query) == E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER ? "eqphone-short" : \
(query) == E_BOOK_QUERY_REGEX_NORMAL ? "regex-normal" : \
(query) == E_BOOK_QUERY_REGEX_RAW ? "regex-raw" : \
+ (query) == E_BOOK_QUERY_REGEX_TRANSLIT ? "regex-translit" : \
(query) == E_BOOK_QUERY_TRANSLIT_IS ? "translit-is" : \
(query) == E_BOOK_QUERY_TRANSLIT_CONTAINS ? "translit-contains" : \
(query) == E_BOOK_QUERY_TRANSLIT_BEGINS_WITH ? "translit-begins-with" : \
@@ -4217,6 +4218,7 @@ static const struct {
{ "eqphone_short", FALSE, E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER },
{ "regex_normal", FALSE, E_BOOK_QUERY_REGEX_NORMAL },
{ "regex_raw", FALSE, E_BOOK_QUERY_REGEX_RAW },
+ { "regex_translit", FALSE, E_BOOK_QUERY_REGEX_TRANSLIT },
{ "translit_is", FALSE, E_BOOK_QUERY_TRANSLIT_IS },
{ "translit_contains", FALSE, E_BOOK_QUERY_TRANSLIT_CONTAINS },
{ "translit_beginswith", FALSE, E_BOOK_QUERY_TRANSLIT_BEGINS_WITH },
@@ -4692,6 +4694,7 @@ query_preflight_check (PreflightContext *context,
case E_BOOK_QUERY_TRANSLIT_CONTAINS:
case E_BOOK_QUERY_TRANSLIT_BEGINS_WITH:
case E_BOOK_QUERY_TRANSLIT_ENDS_WITH:
+ case E_BOOK_QUERY_REGEX_TRANSLIT:
/* These only only searchable in the summary with the E_BOOK_INDEX_TRANSLIT index */
if (test->field == NULL ||
@@ -4754,8 +4757,9 @@ query_preflight_substitute_full_name (PreflightContext *context,
continue;
/* If it's transliterated, we won't do this */
- if (element->query >= E_BOOK_QUERY_TRANSLIT_IS &&
- element->query <= E_BOOK_QUERY_TRANSLIT_ENDS_WITH)
+ if ((element->query >= E_BOOK_QUERY_TRANSLIT_IS &&
+ element->query <= E_BOOK_QUERY_TRANSLIT_ENDS_WITH) ||
+ element->query == E_BOOK_QUERY_REGEX_TRANSLIT)
need_translit = TRUE;
family_name = summary_field_get (ebsql, E_CONTACT_FAMILY_NAME);
@@ -5166,6 +5170,24 @@ field_test_query_regex_normal (EBookSqlite *ebsql,
}
static void
+field_test_query_regex_translit (EBookSqlite *ebsql,
+ GString *string,
+ QueryFieldTest *test)
+{
+ SummaryField *field = test->field;
+ gchar *normal, *translit;
+
+ translit = e_transliterator_transliterate (ebsql->priv->transliterator, test->value);
+ normal = e_util_utf8_normalize (translit);
+
+ ebsql_string_append_column (string, field, EBSQL_SUFFIX_TRANSLIT);
+ ebsql_string_append_printf (string, " REGEXP %Q", normal);
+
+ g_free (translit);
+ g_free (normal);
+}
+
+static void
field_test_query_translit_is (EBookSqlite *ebsql,
GString *string,
QueryFieldTest *test)
@@ -5290,6 +5312,7 @@ static const GenerateFieldTest field_test_func_table[] = {
field_test_query_eqphone_short, /* E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER */
field_test_query_regex_normal, /* E_BOOK_QUERY_REGEX_NORMAL */
NULL /* Requires fallback */, /* E_BOOK_QUERY_REGEX_RAW */
+ field_test_query_regex_translit, /* E_BOOK_QUERY_REGEX_TRANSLIT */
field_test_query_translit_is, /* E_BOOK_QUERY_TRANSLIT_IS */
field_test_query_translit_contains,/* E_BOOK_QUERY_TRANSLIT_CONTAINS */
field_test_query_translit_begins_with,/* E_BOOK_QUERY_TRANSLIT_BEGINS_WITH */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]