diff options
author | Peter Williams <peterw@src.gnome.org> | 2000-08-15 03:07:06 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2000-08-15 03:07:06 +0800 |
commit | 1f10ac10737d23e1e2a1243b4baccb5839f02e5d (patch) | |
tree | cef44eb2f4cc9422460abc176e1a09f8fdfa4790 | |
parent | a22313c0a44338909cb84ca2b262d8b8217d65bc (diff) | |
download | gsoc2013-evolution-1f10ac10737d23e1e2a1243b4baccb5839f02e5d.tar gsoc2013-evolution-1f10ac10737d23e1e2a1243b4baccb5839f02e5d.tar.gz gsoc2013-evolution-1f10ac10737d23e1e2a1243b4baccb5839f02e5d.tar.bz2 gsoc2013-evolution-1f10ac10737d23e1e2a1243b4baccb5839f02e5d.tar.lz gsoc2013-evolution-1f10ac10737d23e1e2a1243b4baccb5839f02e5d.tar.xz gsoc2013-evolution-1f10ac10737d23e1e2a1243b4baccb5839f02e5d.tar.zst gsoc2013-evolution-1f10ac10737d23e1e2a1243b4baccb5839f02e5d.zip |
Infrastructure for date-based queries
svn path=/trunk/; revision=4838
-rw-r--r-- | camel/ChangeLog | 10 | ||||
-rw-r--r-- | camel/camel-folder-search.c | 66 | ||||
-rw-r--r-- | camel/camel-folder-search.h | 9 | ||||
-rw-r--r-- | e-util/ChangeLog | 5 | ||||
-rw-r--r-- | e-util/e-sexp.c | 2 |
5 files changed, 89 insertions, 3 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 89b4ac747d..7342d2220a 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,13 @@ +2000-08-14 Peter Williams <peterw@helixcode.com> + + * camel-folder-search.c (search_get_sent_date): New search function; + returns the time_t when the message was sent. + (search_get_receive_date): Same for when it was received. + (search_get_current_date): Gets the current time for use with the + above two. Is this in the right place? + + * camel-folder-search.h: Add the new functions above to the class. + 2000-08-13 Dan Winship <danw@helixcode.com> * providers/nntp/Makefile.am (libcamelnntpinclude_HEADERS): Add diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c index 47bdc0b5ef..1c68f369ee 100644 --- a/camel/camel-folder-search.c +++ b/camel/camel-folder-search.c @@ -30,8 +30,8 @@ #include "camel-folder-search.h" #include "string-utils.h" -#define d(x) -#define r(x) +#define d(x) x +#define r(x) x struct _CamelFolderSearchPrivate { }; @@ -43,6 +43,9 @@ static ESExpResult *search_match_all(struct _ESExp *f, int argc, struct _ESExpTe static ESExpResult *search_body_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search); static ESExpResult *search_user_flag(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); static ESExpResult *search_user_tag(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); +static ESExpResult *search_get_sent_date(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); +static ESExpResult *search_get_received_date(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); +static ESExpResult *search_get_current_date(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); static ESExpResult *search_dummy(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search); @@ -62,6 +65,9 @@ camel_folder_search_class_init (CamelFolderSearchClass *klass) klass->header_contains = search_header_contains; klass->user_tag = search_user_tag; klass->user_flag = search_user_flag; + klass->get_sent_date = search_get_sent_date; + klass->get_received_date = search_get_received_date; + klass->get_current_date = search_get_current_date; } static void @@ -128,6 +134,9 @@ struct { { "header-contains", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_contains), 1 }, { "user-tag", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, user_tag), 1 }, { "user-flag", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, user_flag), 1 }, + { "get-sent-date", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, get_sent_date), 1 }, + { "get-received-date", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, get_received_date), 1 }, + { "get-current-date", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, get_current_date), 1 } }; void @@ -534,3 +543,56 @@ static ESExpResult *search_user_tag(struct _ESExp *f, int argc, struct _ESExpRes return r; } + +static ESExpResult * +search_get_sent_date(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s) +{ + ESExpResult *r; + + r(printf("executing get-sent-date\n")); + + /* are we inside a match-all? */ + if (s->current) { + r = e_sexp_result_new (ESEXP_RES_INT); + + r->value.number = s->current->date_sent; + } else { + r = e_sexp_result_new (ESEXP_RES_ARRAY_PTR); + r->value.ptrarray = g_ptr_array_new (); + } + + return r; +} + +static ESExpResult * +search_get_received_date(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s) +{ + ESExpResult *r; + + r(printf("executing get-received-date\n")); + + /* are we inside a match-all? */ + if (s->current) { + r = e_sexp_result_new (ESEXP_RES_INT); + + r->value.number = s->current->date_received; + } else { + r = e_sexp_result_new (ESEXP_RES_ARRAY_PTR); + r->value.ptrarray = g_ptr_array_new (); + } + + return r; +} + +static ESExpResult * +search_get_current_date(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s) +{ + ESExpResult *r; + + r(printf("executing get-current-date\n")); + + r = e_sexp_result_new (ESEXP_RES_INT); + r->value.number = time (NULL); + return r; +} + diff --git a/camel/camel-folder-search.h b/camel/camel-folder-search.h index d1f165d842..aca9ff27f7 100644 --- a/camel/camel-folder-search.h +++ b/camel/camel-folder-search.h @@ -75,6 +75,15 @@ struct _CamelFolderSearchClass { /* (user-tag "flagname") Returns the value of a user tag. Can only be used in match-all */ ESExpResult * (*user_tag)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); + + /* (get-sent-date) Retrieve the date that the message was sent on as a time_t */ + ESExpResult * (*get_sent_date)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); + + /* (get-received-date) Retrieve the date that the message was received on as a time_t */ + ESExpResult * (*get_received_date)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); + + /* (get-current-date) Retrieve 'now' as a time_t */ + ESExpResult * (*get_current_date)(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *s); }; guint camel_folder_search_get_type (void); diff --git a/e-util/ChangeLog b/e-util/ChangeLog index e724f696d0..a3e431c12e 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,8 @@ +2000-08-14 Peter Williams <peterw@helixcode.com> + + * e-sexp.c (scanner_config): Add "-" to be an acceptable + first character for an operation -- yaaay subtraction! + 2000-08-11 Peter Williams <peterw@helixcode.com> * e-html-utils.c (e_text_to_html): Fix the tab expansion diff --git a/e-util/e-sexp.c b/e-util/e-sexp.c index 613f5f0c38..cc0452b6b2 100644 --- a/e-util/e-sexp.c +++ b/e-util/e-sexp.c @@ -92,7 +92,7 @@ static GScannerConfig scanner_config = { ( " \t\r\n") /* cset_skip_characters */, ( G_CSET_a_2_z - "_+<=>" + "_+-<=>" G_CSET_A_2_Z) /* cset_identifier_first */, ( G_CSET_a_2_z "_0123456789-<>" |