[evolution-data-server/openismus-work-3-8] EBookQuery: Added transliteration queries.



commit c99eba0e63db40451aa32a5d9a642c8153629a5f
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Tue Aug 27 13:47:21 2013 +0200

    EBookQuery: Added transliteration queries.
    
    Transliterated queries come in the regular IS, CONTAINS, BEGINS_WITH and
    ENDS_WITH variations. They will transliterate the query input and the
    fields which they are testing all into Latin script, so that queries
    are script insensitive as much as possible.

 addressbook/libebook-contacts/e-book-query.c |   52 ++++++++++++++++++++++++++
 addressbook/libebook-contacts/e-book-query.h |   11 +++++-
 2 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-book-query.c b/addressbook/libebook-contacts/e-book-query.c
index 39e59a8..d09adcc 100644
--- a/addressbook/libebook-contacts/e-book-query.c
+++ b/addressbook/libebook-contacts/e-book-query.c
@@ -638,6 +638,42 @@ func_regex_raw (struct _ESExp *f,
 }
 
 static ESExpResult *
+func_translit_contains (struct _ESExp *f,
+                       gint argc,
+                       struct _ESExpResult **argv,
+                       gpointer data)
+{
+       return func_field_test (E_BOOK_QUERY_TRANSLIT_CONTAINS, f, argc, argv, data);
+}
+
+static ESExpResult *
+func_translit_is (struct _ESExp *f,
+                 gint argc,
+                 struct _ESExpResult **argv,
+                 gpointer data)
+{
+       return func_field_test (E_BOOK_QUERY_TRANSLIT_IS, f, argc, argv, data);
+}
+
+static ESExpResult *
+func_translit_beginswith (struct _ESExp *f,
+                         gint argc,
+                         struct _ESExpResult **argv,
+                         gpointer data)
+{
+       return func_field_test (E_BOOK_QUERY_TRANSLIT_BEGINS_WITH, f, argc, argv, data);
+}
+
+static ESExpResult *
+func_translit_endswith (struct _ESExp *f,
+                       gint argc,
+                       struct _ESExpResult **argv,
+                       gpointer data)
+{
+       return func_field_test (E_BOOK_QUERY_TRANSLIT_ENDS_WITH, f, argc, argv, data);
+}
+
+static ESExpResult *
 func_exists (struct _ESExp *f,
              gint argc,
              struct _ESExpResult **argv,
@@ -702,6 +738,10 @@ static const struct {
        { "eqphone_short", func_eqphone_short, 0 },
        { "regex_normal", func_regex_normal, 0 },
        { "regex_raw", func_regex_raw, 0 },
+       { "translit_is", func_translit_is, 0 },
+       { "translit_contains", func_translit_contains, 0 },
+       { "translit_beginswith", func_translit_beginswith, 0 },
+       { "translit_endswith", func_translit_endswith, 0 },
        { "exists", func_exists, 0 },
        { "exists_vcard", func_exists_vcard, 0 }
 };
@@ -782,6 +822,14 @@ field_test_name (EBookQueryTest field_test)
                return "regex_normal";
        case E_BOOK_QUERY_REGEX_RAW:
                return "regex_raw";
+       case E_BOOK_QUERY_TRANSLIT_IS:
+               return "translit_is";
+       case E_BOOK_QUERY_TRANSLIT_CONTAINS:
+               return "translit_contains";
+       case E_BOOK_QUERY_TRANSLIT_BEGINS_WITH:
+               return "translit_beginswith";
+       case E_BOOK_QUERY_TRANSLIT_ENDS_WITH:
+               return "translit_endswith";
        }
 
        return NULL;
@@ -802,6 +850,10 @@ 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_TRANSLIT_IS:
+       case E_BOOK_QUERY_TRANSLIT_CONTAINS:
+       case E_BOOK_QUERY_TRANSLIT_BEGINS_WITH:
+       case E_BOOK_QUERY_TRANSLIT_ENDS_WITH:
                break;
        }
 
diff --git a/addressbook/libebook-contacts/e-book-query.h b/addressbook/libebook-contacts/e-book-query.h
index 67771e8..ad63ce8 100644
--- a/addressbook/libebook-contacts/e-book-query.h
+++ b/addressbook/libebook-contacts/e-book-query.h
@@ -34,6 +34,10 @@ typedef struct _EBookQuery EBookQuery;
  * @E_BOOK_QUERY_REGEX_RAW: A regular expression query against raw contact data, this is usually slower than
  * a %E_BOOK_QUERY_REGEX_NORMAL as it implies that #EVCards must be parsed in order to get the raw data
  * for comparison.
+ * @E_BOOK_QUERY_TRANSLIT_IS: Like %E_BOOK_QUERY_IS, but transliterates text to Latin script before the 
comparison
+ * @E_BOOK_QUERY_TRANSLIT_CONTAINS: Like %E_BOOK_QUERY_CONTAINS, but transliterates text to Latin script 
before the comparison
+ * @E_BOOK_QUERY_TRANSLIT_BEGINS_WITH: Like %E_BOOK_QUERY_BEGINS_WITH, but transliterates text to Latin 
script before the comparison
+ * @E_BOOK_QUERY_TRANSLIT_ENDS_WITH: Like %E_BOOK_QUERY_ENDS_WITH, but transliterates text to Latin script 
before the comparison
  *
  * The kind of test a query created by e_book_query_field_test() shall perform.
  *
@@ -50,7 +54,12 @@ typedef enum {
   E_BOOK_QUERY_EQUALS_SHORT_PHONE_NUMBER,
 
   E_BOOK_QUERY_REGEX_NORMAL,
-  E_BOOK_QUERY_REGEX_RAW
+  E_BOOK_QUERY_REGEX_RAW,
+
+  E_BOOK_QUERY_TRANSLIT_IS,
+  E_BOOK_QUERY_TRANSLIT_CONTAINS,
+  E_BOOK_QUERY_TRANSLIT_BEGINS_WITH,
+  E_BOOK_QUERY_TRANSLIT_ENDS_WITH
 
   /*
     Consider these "coming soon".


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]