[evolution-data-server] Bug #535978 - Filtering on IMAP accounts causes message to be downloaded
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #535978 - Filtering on IMAP accounts causes message to be downloaded
- Date: Tue, 7 Feb 2012 14:16:02 +0000 (UTC)
commit fa5668b3193c55220c192c620a7d2c227664a146
Author: Milan Crha <mcrha redhat com>
Date: Tue Feb 7 15:15:35 2012 +0100
Bug #535978 - Filtering on IMAP accounts causes message to be downloaded
camel/camel-filter-search.c | 58 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 2cd3525..0e55982 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -138,6 +138,62 @@ camel_filter_search_get_message (FilterMessageSearch *fms,
return fms->message;
}
+static gboolean
+check_header_in_message_info (CamelMessageInfo *info,
+ gint argc,
+ struct _CamelSExpResult **argv,
+ camel_search_match_t how,
+ gboolean *matched)
+{
+ struct _KnownHeaders {
+ const gchar *header_name;
+ guint info_key;
+ } known_headers[] = {
+ { "Subject", CAMEL_MESSAGE_INFO_SUBJECT },
+ { "From", CAMEL_MESSAGE_INFO_FROM },
+ { "To", CAMEL_MESSAGE_INFO_TO },
+ { "Cc", CAMEL_MESSAGE_INFO_CC }
+ };
+ camel_search_t type = CAMEL_SEARCH_TYPE_ENCODED;
+ const gchar *name, *value;
+ gboolean found = FALSE;
+ gint ii;
+
+ g_return_val_if_fail (argc > 1, FALSE);
+ g_return_val_if_fail (argv != NULL, FALSE);
+ g_return_val_if_fail (matched != NULL, FALSE);
+
+ if (!info)
+ return FALSE;
+
+ name = argv[0]->value.string;
+ g_return_val_if_fail (name != NULL, FALSE);
+
+ value = NULL;
+
+ for (ii = 0; ii < G_N_ELEMENTS (known_headers); ii++) {
+ found = g_ascii_strcasecmp (name, known_headers[ii].header_name) == 0;
+ if (found) {
+ value = camel_message_info_ptr (info, known_headers[ii].info_key);
+ if (known_headers[ii].info_key == CAMEL_MESSAGE_INFO_FROM ||
+ known_headers[ii].info_key == CAMEL_MESSAGE_INFO_TO ||
+ known_headers[ii].info_key == CAMEL_MESSAGE_INFO_CC)
+ type = CAMEL_SEARCH_TYPE_ADDRESS_ENCODED;
+ break;
+ }
+ }
+
+ if (!found)
+ return FALSE;
+
+ for (ii = 1; ii < argc && !*matched; ii++) {
+ if (argv[ii]->type == CAMEL_SEXP_RES_STRING)
+ *matched = camel_search_header_match (value, argv[ii]->value.string, how, type, NULL);
+ }
+
+ return TRUE;
+}
+
static CamelSExpResult *
check_header (struct _CamelSExp *f,
gint argc,
@@ -165,7 +221,7 @@ check_header (struct _CamelSExp *f,
matched = camel_search_header_match (list, argv[i]->value.string, how, CAMEL_SEARCH_TYPE_MLIST, NULL);
}
}
- } else {
+ } else if (!check_header_in_message_info (fms->info, argc, argv, how, &matched)) {
CamelMimeMessage *message;
CamelMimePart *mime_part;
struct _camel_header_raw *header;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]