[evolution-data-server/gnome-3-30] I#5 - Compare only date when searching with Sent/Received dates ][



commit 9c822b21cd7b0777e38ebacdb738350c9dc1ab23
Author: Milan Crha <mcrha redhat com>
Date:   Mon Nov 26 16:56:13 2018 +0100

    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

 src/camel/camel-filter-search.c | 62 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
---
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)
 {


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