diff options
author | Milan Crha <mcrha@redhat.com> | 2018-11-26 16:56:13 +0100 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2018-11-26 16:56:13 +0100 |
commit | 702cfa121787ca50b4213c249c2c23a2e0edd7d6 (patch) | |
tree | 4dbdfd90747ef6595f20ca815b20ee1c5fb00fd1 | |
parent | e361a1bd922630fcc6a951845cfc17dae466199d (diff) | |
download | evolution-data-server-702cfa121787ca50b4213c249c2c23a2e0edd7d6.tar.gz |
I#5 - Compare only date when searching with Sent/Received dates ][
Missed filter's search code, which didn't know about the new
compare-date and make-time functions, causing errors int he UI
when filtering.
Related to https://gitlab.gnome.org/GNOME/evolution-data-server/issues/5
and https://gitlab.gnome.org/GNOME/evolution/issues/245
-rw-r--r-- | src/camel/camel-filter-search.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/camel/camel-filter-search.c b/src/camel/camel-filter-search.c index 903fded32..ec3ab840d 100644 --- a/src/camel/camel-filter-search.c +++ b/src/camel/camel-filter-search.c @@ -91,6 +91,8 @@ static CamelSExpResult *get_size (struct _CamelSExp *f, gint argc, struct _Camel static CamelSExpResult *pipe_message (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms); static CamelSExpResult *junk_test (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms); static CamelSExpResult *message_location (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms); +static CamelSExpResult *make_time_func (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms); +static CamelSExpResult *compare_date_func (struct _CamelSExp *f, gint argc, struct _CamelSExpResult **argv, FilterMessageSearch *fms); /* builtin functions */ static struct { @@ -122,7 +124,9 @@ static struct { { "get-size", (CamelSExpFunc) get_size, 0 }, { "pipe-message", (CamelSExpFunc) pipe_message, 0 }, { "junk-test", (CamelSExpFunc) junk_test, 0 }, - { "message-location", (CamelSExpFunc) message_location, 0 } + { "message-location", (CamelSExpFunc) message_location, 0 }, + { "make-time", (CamelSExpFunc) make_time_func, 0 }, + { "compare-date", (CamelSExpFunc) compare_date_func, 0 } }; static void @@ -1256,6 +1260,62 @@ message_location (struct _CamelSExp *f, return r; } +static CamelSExpResult * +make_time_func (CamelSExp *sexp, + gint argc, + CamelSExpResult **argv, + FilterMessageSearch *fms) +{ + CamelSExpResult *res; + + camel_filter_search_log (fms, "Calling 'make-time'"); + + res = camel_sexp_result_new (sexp, CAMEL_SEXP_RES_TIME); + res->value.time = camel_folder_search_util_make_time (argc, argv); + + return res; +} + +static CamelSExpResult * +compare_date_func (CamelSExp *sexp, + gint argc, + CamelSExpResult **argv, + FilterMessageSearch *fms) +{ + CamelSExpResult *res; + + res = camel_sexp_result_new (sexp, CAMEL_SEXP_RES_INT); + res->value.number = 0; + + if (argc == 2) { + gint64 t1, t2; + + if (argv[0]->type == CAMEL_SEXP_RES_INT) + t1 = argv[0]->value.number; + else if (argv[0]->type == CAMEL_SEXP_RES_TIME) + t1 = (gint64) argv[0]->value.time; + else { + camel_filter_search_log (fms, "compare-date result:%d (incorrect first argument type)", res->value.number); + return res; + } + + if (argv[1]->type == CAMEL_SEXP_RES_INT) + t2 = argv[1]->value.number; + else if (argv[1]->type == CAMEL_SEXP_RES_TIME) + t2 = (gint64) argv[1]->value.time; + else { + camel_filter_search_log (fms, "compare-date result:%d (incorrect second argument type)", res->value.number); + return res; + } + + res->value.number = camel_folder_search_util_compare_date (t1, t2); + } + + camel_filter_search_log (fms, "compare-date result:%d", res->value.number); + + return res; +} + static const gchar * camel_search_result_to_string (gint value) { |