aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-09-14 09:44:18 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-09-14 09:44:18 +0800
commit0676d2890e8def5d8876da6784df4e673b0703a1 (patch)
treee8eefa6b292df016f38d82f2a6f96ad1af966cdf
parentc109102df34ceb19c72fbc8c410c9ec158c6b3a5 (diff)
downloadgsoc2013-evolution-0676d2890e8def5d8876da6784df4e673b0703a1.tar
gsoc2013-evolution-0676d2890e8def5d8876da6784df4e673b0703a1.tar.gz
gsoc2013-evolution-0676d2890e8def5d8876da6784df4e673b0703a1.tar.bz2
gsoc2013-evolution-0676d2890e8def5d8876da6784df4e673b0703a1.tar.lz
gsoc2013-evolution-0676d2890e8def5d8876da6784df4e673b0703a1.tar.xz
gsoc2013-evolution-0676d2890e8def5d8876da6784df4e673b0703a1.tar.zst
gsoc2013-evolution-0676d2890e8def5d8876da6784df4e673b0703a1.zip
Don't reuse the exception if it has already been set.
2001-09-13 Jeffrey Stedfast <fejj@ximian.com> * camel-filter-driver.c (camel_filter_driver_filter_folder): Don't reuse the exception if it has already been set. (camel_filter_driver_filter_message): Same here. Also use the new return value from camel_filter_search_match(). * camel-filter-search.c (camel_filter_search_match): Return an integer (matched, no-match, or error). svn path=/trunk/; revision=12819
-rw-r--r--camel/ChangeLog8
-rw-r--r--camel/camel-filter-driver.c25
-rw-r--r--camel/camel-filter-search.c19
-rw-r--r--camel/camel-filter-search.h10
-rw-r--r--camel/camel.c2
5 files changed, 49 insertions, 15 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index b4b8ef8338..c5b5f3467f 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,13 @@
2001-09-13 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-filter-driver.c (camel_filter_driver_filter_folder): Don't
+ reuse the exception if it has already been set.
+ (camel_filter_driver_filter_message): Same here. Also use the new
+ return value from camel_filter_search_match().
+
+ * camel-filter-search.c (camel_filter_search_match): Return an
+ integer (matched, no-match, or error).
+
* providers/local/camel-mbox-folder.c (mbox_append_message): Do
error-checking based on function return values rather than
exceptions as it's possible for them to be NULL.
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index 31bc40f4b6..e7a430cdff 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -812,7 +812,7 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
if (p->defaultfolder) {
report_status (driver, CAMEL_FILTER_STATUS_PROGRESS, 100, _("Syncing folder"));
- camel_folder_sync (p->defaultfolder, FALSE, ex);
+ camel_folder_sync (p->defaultfolder, FALSE, camel_exception_is_set (ex) ? NULL : ex);
}
if (i == uids->len)
@@ -853,10 +853,11 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
CamelException *ex)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
- ESExpResult *r;
struct _filter_rule *node;
gboolean freeinfo = FALSE;
gboolean filtered = FALSE;
+ ESExpResult *r;
+ int result;
if (info == NULL) {
struct _header_raw *h = CAMEL_MIME_PART (message)->headers;
@@ -881,12 +882,15 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
camel_mime_message_set_source (message, original_source_url);
node = (struct _filter_rule *)p->rules.head;
- while (node->next) {
+ result = CAMEL_SEARCH_NOMATCH;
+ while (node->next && result != CAMEL_SEARCH_ERROR) {
d(fprintf (stderr, "applying rule %s\naction %s\n", node->match, node->action));
- if (camel_filter_search_match (p->message, p->info,
- original_source_url ? original_source_url : source_url,
- node->match, p->ex)) {
+ result = camel_filter_search_match (p->message, p->info,
+ original_source_url ? original_source_url : source_url,
+ node->match, p->ex);
+
+ if (result == CAMEL_SEARCH_MATCHED) {
filtered = TRUE;
camel_filter_driver_log (driver, FILTER_LOG_START, node->name);
@@ -925,10 +929,13 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
uids = g_ptr_array_new ();
g_ptr_array_add (uids, (char *) p->uid);
- camel_folder_copy_messages_to (p->source, uids, p->defaultfolder, p->ex);
+ camel_folder_copy_messages_to (p->source, uids, p->defaultfolder,
+ result == CAMEL_SEARCH_ERROR ? NULL : p->ex);
g_ptr_array_free (uids, TRUE);
- } else
- camel_folder_append_message (p->defaultfolder, p->message, p->info, p->ex);
+ } else {
+ camel_folder_append_message (p->defaultfolder, p->message, p->info,
+ result == CAMEL_SEARCH_ERROR ? NULL : p->ex);
+ }
}
if (freeinfo)
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 9cbb87cce6..d6d60e2cf3 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -438,7 +438,18 @@ get_size (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageS
return r;
}
-gboolean
+
+/**
+ * camel_filter_search_match:
+ * @message:
+ * @info:
+ * @source:
+ * @expression:
+ * @ex:
+ *
+ * Returns one of CAMEL_SEARCH_MATCHED, CAMEL_SEARCH_NOMATCH, or CAMEL_SEARCH_ERROR.
+ **/
+int
camel_filter_search_match (CamelMimeMessage *message, CamelMessageInfo *info,
const char *source, const char *expression, CamelException *ex)
{
@@ -478,9 +489,9 @@ camel_filter_search_match (CamelMimeMessage *message, CamelMessageInfo *info,
}
if (result->type == ESEXP_RES_BOOL)
- retval = result->value.bool;
+ retval = result->value.bool ? CAMEL_SEARCH_MATCHED : CAMEL_SEARCH_NOMATCH;
else
- retval = FALSE;
+ retval = CAMEL_SEARCH_NOMATCH;
e_sexp_result_free (sexp, result);
e_sexp_unref (sexp);
@@ -489,5 +500,5 @@ camel_filter_search_match (CamelMimeMessage *message, CamelMessageInfo *info,
error:
e_sexp_unref (sexp);
- return FALSE;
+ return CAMEL_SEARCH_ERROR;
}
diff --git a/camel/camel-filter-search.h b/camel/camel-filter-search.h
index 1482f70539..eb1ad2e47d 100644
--- a/camel/camel-filter-search.h
+++ b/camel/camel-filter-search.h
@@ -34,8 +34,14 @@ extern "C" {
#include <camel/camel-mime-message.h>
#include <camel/camel-folder-summary.h>
-gboolean camel_filter_search_match(CamelMimeMessage *message, CamelMessageInfo *info,
- const char *source, const char *expression, CamelException *ex);
+enum {
+ CAMEL_SEARCH_ERROR = -1,
+ CAMEL_SEARCH_NOMATCH = 0,
+ CAMEL_SEARCH_MATCHED = 1,
+};
+
+int camel_filter_search_match (CamelMimeMessage *message, CamelMessageInfo *info,
+ const char *source, const char *expression, CamelException *ex);
#ifdef __cplusplus
}
diff --git a/camel/camel.c b/camel/camel.c
index 4a7c8fd7bf..854fe1e896 100644
--- a/camel/camel.c
+++ b/camel/camel.c
@@ -27,6 +27,8 @@
#include <config.h>
#endif
+#include <signal.h>
+
#ifdef HAVE_NSS
#include <nspr.h>
#include <prthread.h>