diff options
-rw-r--r-- | camel/ChangeLog | 12 | ||||
-rw-r--r-- | camel/camel-folder-search.c | 31 | ||||
-rw-r--r-- | camel/camel-folder-search.h | 5 | ||||
-rw-r--r-- | camel/camel-folder-summary.c | 50 | ||||
-rw-r--r-- | camel/camel-folder-summary.h | 3 |
5 files changed, 98 insertions, 3 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 25fc1a75bc..21e7e294e8 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,15 @@ +2000-12-01 Jeffrey Stedfast <fejj@helixcode.com> + + * camel-folder-search.h: Added system_flag to CamelFolderSearchClass + + * camel-folder-summary.c (camel_system_flag_get): Convenience + function to return whether or not a flag is set using a string as + the flag name. + (camel_system_flag): Return the integer value of the flag string. + + * camel-folder-search.c (search_system_flag): New ESExp callback + for allowing vfoldering on CamelMessageInfo flags. + 2000-12-01 Dan Winship <danw@helixcode.com> * camel-service.c (camel_service_disconnect): Don't diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c index 0376dd9fef..f887986e3b 100644 --- a/camel/camel-folder-search.c +++ b/camel/camel-folder-search.c @@ -55,6 +55,7 @@ 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_system_flag(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); @@ -77,6 +78,7 @@ 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->system_flag = search_system_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; @@ -170,9 +172,10 @@ 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 }, + { "system-flag", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, system_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 } + { "get-current-date", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, get_current_date), 1 }, }; void @@ -728,7 +731,8 @@ search_body_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, Cam return r; } -static ESExpResult *search_user_flag(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search) +static ESExpResult * +search_user_flag(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search) { ESExpResult *r; int i; @@ -756,6 +760,29 @@ static ESExpResult *search_user_flag(struct _ESExp *f, int argc, struct _ESExpRe return r; } +static ESExpResult * +search_system_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search) +{ + ESExpResult *r; + + r(printf ("executing system-flag\n")); + + if (search->current) { + gboolean truth = FALSE; + + if (argc == 1) + truth = camel_system_flag_get (search->current->flags, argv[0]->value.string); + + r = e_sexp_result_new (ESEXP_RES_BOOL); + r->value.bool = truth; + } else { + r = e_sexp_result_new (ESEXP_RES_ARRAY_PTR); + r->value.ptrarray = g_ptr_array_new (); + } + + return r; +} + static ESExpResult *search_user_tag(struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFolderSearch *search) { ESExpResult *r; diff --git a/camel/camel-folder-search.h b/camel/camel-folder-search.h index 3f04881fde..13f07ac71f 100644 --- a/camel/camel-folder-search.h +++ b/camel/camel-folder-search.h @@ -77,7 +77,10 @@ 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); - + + /* (system-flag "flagname") Returns the value of a system flag. Can only be used in match-all */ + ESExpResult * (*system_flag)(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); diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index b7b9b9c421..8ea51a7bbf 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -2138,6 +2138,56 @@ void camel_tag_list_free(CamelTag **list) *list = NULL; } +struct flag_names_t { + char *name; + guint32 value; +} flag_names[] = { + { "answered", CAMEL_MESSAGE_ANSWERED }, + { "deleted", CAMEL_MESSAGE_DELETED }, + { "draft", CAMEL_MESSAGE_DELETED }, + { "flagged", CAMEL_MESSAGE_FLAGGED }, + { "seen", CAMEL_MESSAGE_SEEN }, + { "attachments", CAMEL_MESSAGE_ATTACHMENTS }, + { NULL, 0 } +}; + +/** + * camel_system_flag: + * @name: + * + * Returns the integer value of the flag string. + **/ +guint32 +camel_system_flag (const char *name) +{ + struct flag_names_t *flag; + + g_return_val_if_fail (name != NULL, 0); + + for (flag = flag_names; *flag->name; flag++) + if (!g_strcasecmp (name, flag->name)) + return flag->value; + + return 0; +} + +/** + * camel_system_flag_get: + * @flags: + * @name: + * + * Find the state of the flag @name in @flags. + * + * Return value: The state of the flag (TRUE or FALSE). + **/ +gboolean +camel_system_flag_get (guint32 flags, const char *name) +{ + g_return_val_if_fail (name != NULL, FALSE); + + return flags & camel_system_flag (name); +} + /** * camel_message_info_new: diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h index eb8d839822..bc47484699 100644 --- a/camel/camel-folder-summary.h +++ b/camel/camel-folder-summary.h @@ -268,6 +268,9 @@ void camel_flag_set(CamelFlag **list, const char *name, gboolean state); int camel_flag_list_size(CamelFlag **list); void camel_flag_list_free(CamelFlag **list); +guint32 camel_system_flag (const char *name); +gboolean camel_system_flag_get (guint32 flags, const char *name); + /* message tag operations */ const char *camel_tag_get(CamelTag **list, const char *name); void camel_tag_set(CamelTag **list, const char *name, const char *value); |