aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filter/ChangeLog9
-rw-r--r--filter/filter-driver.c123
-rw-r--r--filter/filter-message-search.c17
3 files changed, 33 insertions, 116 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 03e1ecd565..c2e1e0b85a 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,12 @@
+2000-09-07 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * filter-driver.c (filter_driver_run): Rewrote - this shouldn't
+ need to be an async function
+
+ * filter-message-search.c (match_all): Modified to look at the
+ boolean value being fed to it and just to return that instead of
+ always returning TRUE
+
2000-09-07 Lauris Kaplinski <lauris@helixcode.com>
* filter-editor.c, filter-filter.c, filter-folder.c, filter-option.c:
diff --git a/filter/filter-driver.c b/filter/filter-driver.c
index bc8dbd8ca2..cc1d08863b 100644
--- a/filter/filter-driver.c
+++ b/filter/filter-driver.c
@@ -40,24 +40,6 @@
#define d(x) x
-/* mail-thread filter input data type */
-typedef struct {
- FilterDriver *driver;
- CamelMimeMessage *message;
- CamelFolder *inbox;
- enum _filter_source_t sourcetype;
- gboolean self_destruct;
- gpointer unhook_func;
- gpointer unhook_data;
-} filter_mail_input_t;
-
-/* mail-thread filter functions */
-static gchar *describe_filter_mail (gpointer in_data, gboolean gerund);
-static void setup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex);
-static void do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex);
-static void cleanup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex);
-
-
struct _FilterDriverPrivate {
GHashTable *globals; /* global variables */
@@ -391,86 +373,20 @@ free_key (gpointer key, gpointer value, gpointer user_data)
}
#endif
-static const mail_operation_spec op_filter_mail =
-{
- describe_filter_mail,
- 0,
- setup_filter_mail,
- do_filter_mail,
- cleanup_filter_mail
-};
-
void
filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, CamelFolder *inbox,
enum _filter_source_t sourcetype, gboolean self_destruct,
gpointer unhook_func, gpointer unhook_data)
{
- filter_mail_input_t *input;
-
- input = g_new (filter_mail_input_t, 1);
- input->driver = driver;
- input->message = message;
- input->inbox = inbox;
- input->sourcetype = sourcetype;
- input->self_destruct = self_destruct;
- input->unhook_func = unhook_func;
- input->unhook_data = unhook_data;
-
- mail_operation_queue (&op_filter_mail, input, TRUE);
-}
-
-static gchar *
-describe_filter_mail (gpointer in_data, gboolean gerund)
-{
- filter_mail_input_t *input = (filter_mail_input_t *) in_data;
-
- if (gerund)
- return g_strdup_printf ("Filtering messages into \"%s\"",
- mail_tool_get_folder_name (input->inbox));
- else
- return g_strdup_printf ("Filter messages into \"%s\"",
- mail_tool_get_folder_name (input->inbox));
-}
-
-static void
-setup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
-{
- filter_mail_input_t *input = (filter_mail_input_t *) in_data;
-
- if (!input->driver) {
- camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
- "Bad filter driver passed to filter_mail");
- return;
- }
-
- if (!CAMEL_IS_MIME_MESSAGE (input->message)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
- "Bad mime message passed to filter_mail");
- return;
- }
-
- if (!CAMEL_IS_FOLDER (input->inbox)) {
- camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM,
- "Bad Inbox passed to filter_mail");
- return;
- }
-
- camel_object_ref (CAMEL_OBJECT (input->message));
- camel_object_ref (CAMEL_OBJECT (input->inbox));
-}
-
-static void
-do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
-{
- filter_mail_input_t *input = (filter_mail_input_t *) in_data;
- FilterDriver *driver = input->driver;
- CamelMimeMessage *message = input->message;
- CamelFolder *inbox = input->inbox;
struct _FilterDriverPrivate *p = _PRIVATE (driver);
ESExpResult *r;
GString *fsearch, *faction;
FilterFilter *rule;
+ gtk_object_ref (GTK_OBJECT (driver));
+ camel_object_ref (CAMEL_OBJECT (message));
+ camel_object_ref (CAMEL_OBJECT (inbox));
+
p->ex = camel_exception_new ();
p->terminated = FALSE;
p->deleted = FALSE;
@@ -491,9 +407,9 @@ do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
while ((rule = (FilterFilter *)rule_context_next_rule ((RuleContext *)p->context, (FilterRule *)rule))) {
gboolean matched;
- if (((FilterRule *)rule)->source != input->sourcetype) {
+ if (((FilterRule *)rule)->source != sourcetype) {
d(fprintf (stderr, "skipping rule %s - wrong source type (%d %d)\n", ((FilterRule *)rule)->name,
- ((FilterRule *)rule)->source, input->sourcetype));
+ ((FilterRule *)rule)->source, sourcetype));
continue;
}
@@ -530,12 +446,12 @@ do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
if (!p->deleted && g_hash_table_size (p->folders) == 0) {
/* copy it to the default inbox */
mail_tool_camel_lock_up ();
- camel_folder_append_message (input->inbox, p->message, p->info, p->ex);
+ camel_folder_append_message (inbox, p->message, p->info, p->ex);
/* warn that inbox was changed */
- if (input->unhook_func)
- camel_object_unhook_event (CAMEL_OBJECT (input->inbox), "folder_changed",
- input->unhook_func, input->unhook_data);
+ if (unhook_func)
+ camel_object_unhook_event (CAMEL_OBJECT (inbox), "folder_changed",
+ unhook_func, unhook_data);
mail_tool_camel_lock_down ();
}
@@ -548,21 +464,10 @@ do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
camel_folder_thaw (inbox);
mail_tool_camel_lock_down ();
- /* transfer any exceptions over to our async exception */
- if (camel_exception_is_set (p->ex))
- camel_exception_xfer (ex, p->ex);
-
camel_exception_free (p->ex);
-}
-
-static void
-cleanup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex)
-{
- filter_mail_input_t *input = (filter_mail_input_t *) in_data;
-
- camel_object_unref (CAMEL_OBJECT (input->message));
- camel_object_unref (CAMEL_OBJECT (input->inbox));
- if (input->self_destruct)
- gtk_object_unref (GTK_OBJECT (input->driver));
+ camel_object_unref (CAMEL_OBJECT (message));
+ camel_object_unref (CAMEL_OBJECT (inbox));
+ if (self_destruct)
+ gtk_object_unref (GTK_OBJECT (driver));
}
diff --git a/filter/filter-message-search.c b/filter/filter-message-search.c
index a55a7f5c4d..4fad81cdf5 100644
--- a/filter/filter-message-search.c
+++ b/filter/filter-message-search.c
@@ -52,11 +52,11 @@ static struct {
{ "match-all", (ESExpFunc *) match_all, 0 },
{ "body-contains", (ESExpFunc *) body_contains, 0 },
{ "header-contains", (ESExpFunc *) header_contains, 0 },
- { "user-tag", (ESExpFunc *) user_tag, 1 },
- { "user-flag", (ESExpFunc *) user_flag, 1 },
- { "get-sent-date", (ESExpFunc *) get_sent_date, 1 },
- { "get-received-date", (ESExpFunc *) get_received_date, 1 },
- { "get-current-date", (ESExpFunc *) get_current_date, 1 }
+ { "user-tag", (ESExpFunc *) user_tag, 0 },
+ { "user-flag", (ESExpFunc *) user_flag, 0 },
+ { "get-sent-date", (ESExpFunc *) get_sent_date, 0 },
+ { "get-received-date", (ESExpFunc *) get_received_date, 0 },
+ { "get-current-date", (ESExpFunc *) get_current_date, 0 }
};
static ESExpResult *
@@ -84,12 +84,15 @@ header_contains (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterM
static ESExpResult *
match_all (struct _ESExp *f, int argc, struct _ESExpTerm **argv, FilterMessageSearch *fms)
{
+ /* FIXME: is this right? I dunno */
/* match-all: when dealing with single messages is a no-op */
ESExpResult *r;
- /* FIXME: is this right?? */
r = e_sexp_result_new (ESEXP_RES_BOOL);
- r->value.bool = TRUE;
+ if (argv[0]->type == ESEXP_RES_BOOL)
+ r->value.bool = argv[0]->value.bool;
+ else
+ r->value.bool = FALSE;
return r;
}