[evolution-ews] Implement 'exists' ESExp function in the book backend
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Implement 'exists' ESExp function in the book backend
- Date: Mon, 11 Feb 2019 13:22:11 +0000 (UTC)
commit cea0858c1398fe4e65902939473c72ac3f225d44
Author: Milan Crha <mcrha redhat com>
Date: Mon Feb 11 14:20:48 2019 +0100
Implement 'exists' ESExp function in the book backend
It had been missing in the autocompletion query parser, which could,
when used, cause runtime warning on the factory console. Apart of
adding it, a better parser error checking had been added as well.
src/addressbook/e-book-backend-ews.c | 41 +++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index fd75a008..6811cb21 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -2768,6 +2768,20 @@ ebb_ews_func_beginswith (struct _ESExp *f,
return r;
}
+static ESExpResult *
+ebb_ews_func_exists (struct _ESExp *f,
+ gint argc,
+ struct _ESExpResult **argv,
+ gpointer data)
+{
+ ESExpResult *r;
+
+ r = e_sexp_result_new (f, ESEXP_RES_BOOL);
+ r->value.boolean = FALSE;
+
+ return r;
+}
+
static struct {
const gchar *name;
ESExpFunc *func;
@@ -2780,6 +2794,7 @@ static struct {
{ "is", ebb_ews_func_is, 0},
{ "beginswith", ebb_ews_func_beginswith, 0},
{ "endswith", ebb_ews_func_endswith, 0},
+ { "exists", ebb_ews_func_exists, 0}
};
/* FIXME build a complete filter from the query that can be used by find_items */
@@ -2787,7 +2802,6 @@ static gboolean
ebb_ews_build_restriction (const gchar *query,
gchar **auto_comp_str)
{
- ESExpResult *r;
ESExp *sexp;
EBookBackendEwsSExpData *sdata;
gboolean autocompletion = FALSE;
@@ -2807,18 +2821,25 @@ ebb_ews_build_restriction (const gchar *query,
}
e_sexp_input_text (sexp, query, strlen (query));
- e_sexp_parse (sexp);
+ if (e_sexp_parse (sexp) == -1) {
+ const gchar *errstr = e_sexp_get_error (sexp);
- r = e_sexp_eval (sexp);
- if (r) {
- autocompletion = sdata->is_autocompletion;
- if (autocompletion)
- *auto_comp_str = sdata->auto_comp_str;
- else
- g_free (sdata->auto_comp_str);
+ g_printerr ("%s: Failed to parse query '%s': %s\n", G_STRFUNC, query, errstr ? errstr :
"Unknown error");
+ } else {
+ ESExpResult *r;
+
+ r = e_sexp_eval (sexp);
+ if (r) {
+ autocompletion = sdata->is_autocompletion;
+ if (autocompletion)
+ *auto_comp_str = sdata->auto_comp_str;
+ else
+ g_free (sdata->auto_comp_str);
+ }
+
+ e_sexp_result_free (sexp, r);
}
- e_sexp_result_free (sexp, r);
g_object_unref (sexp);
g_free (sdata);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]