diff options
-rw-r--r-- | filter/ChangeLog | 8 | ||||
-rw-r--r-- | filter/filter-driver.c | 15 | ||||
-rw-r--r-- | filter/filter-driver.h | 14 |
3 files changed, 26 insertions, 11 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index c2e1e0b85a..06c225a92d 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,5 +1,13 @@ 2000-09-07 Jeffrey Stedfast <fejj@helixcode.com> + * filter-driver.c (filter_driver_run): Modified to return a + boolean value specifying whether or not the message was filtered + into a folder other than the default. The default mailbox can now + also be specified as NULL if the message shouldn't be appended to + it in the case that it's not filtered into some other folder. + +2000-09-07 Jeffrey Stedfast <fejj@helixcode.com> + * filter-driver.c (filter_driver_run): Rewrote - this shouldn't need to be an async function diff --git a/filter/filter-driver.c b/filter/filter-driver.c index 0108ed02c6..a6d9d1f3be 100644 --- a/filter/filter-driver.c +++ b/filter/filter-driver.c @@ -373,7 +373,7 @@ free_key (gpointer key, gpointer value, gpointer user_data) } #endif -void +gboolean filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, CamelFolder *inbox, enum _filter_source_t sourcetype, gpointer unhook_func, gpointer unhook_data, @@ -383,10 +383,12 @@ filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, ESExpResult *r; GString *fsearch, *faction; FilterFilter *rule; + gboolean filtered = FALSE; gtk_object_ref (GTK_OBJECT (driver)); camel_object_ref (CAMEL_OBJECT (message)); - camel_object_ref (CAMEL_OBJECT (inbox)); + if (inbox) + camel_object_ref (CAMEL_OBJECT (inbox)); p->ex = camel_exception_new (); p->terminated = FALSE; @@ -444,7 +446,7 @@ filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, g_string_free (fsearch, TRUE); g_string_free (faction, TRUE); - if (!p->deleted && g_hash_table_size (p->folders) == 0) { + if (!p->deleted && g_hash_table_size (p->folders) == 0 && inbox) { /* copy it to the default inbox */ mail_tool_camel_lock_up (); camel_folder_append_message (inbox, p->message, p->info, p->ex); @@ -454,6 +456,8 @@ filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, camel_object_unhook_event (CAMEL_OBJECT (inbox), "folder_changed", unhook_func, unhook_data); mail_tool_camel_lock_down (); + } else { + filtered = TRUE; } /* close all folders that were opened for appending */ @@ -471,7 +475,10 @@ filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, camel_exception_free (p->ex); camel_object_unref (CAMEL_OBJECT (message)); - camel_object_unref (CAMEL_OBJECT (inbox)); + if (inbox) + camel_object_unref (CAMEL_OBJECT (inbox)); if (self_destruct) gtk_object_unref (GTK_OBJECT (driver)); + + return filtered; } diff --git a/filter/filter-driver.h b/filter/filter-driver.h index 02b9f9e2b3..a2ac96989c 100644 --- a/filter/filter-driver.h +++ b/filter/filter-driver.h @@ -53,19 +53,19 @@ FilterDriver *filter_driver_new (FilterContext *ctx, FilterGetFolderFunc fe /*void filter_driver_set_global(FilterDriver *, const char *name, const char *value);*/ -/* apply rules to a folder, unmatched messages goto inbox, if not NULL */ -void filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, - CamelFolder *inbox, enum _filter_source_t sourcetype, - gpointer unhook_func, gpointer unhook_data, - gboolean self_destruct, CamelException *ex); +/* filter a message - returns TRUE if the message was filtered into some location other than inbox */ +gboolean filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, + CamelFolder *inbox, enum _filter_source_t sourcetype, + gpointer unhook_func, gpointer unhook_data, + gboolean self_destruct, CamelException *ex); #if 0 /* generate the search query/action string for a filter option */ void filter_driver_expand_option (FilterDriver *d, GString *s, GString *action, struct filter_option *op); /* get info about rules (options) */ -int filter_driver_rule_count(FilterDriver *d); -struct filter_option *filter_driver_rule_get(FilterDriver *d, int n); +int filter_driver_rule_count (FilterDriver *d); +struct filter_option *filter_driver_rule_get (FilterDriver *d, int n); #endif #endif /* ! _FILTER_DRIVER_H */ |