aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-filter-search.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/camel-filter-search.c')
-rw-r--r--camel/camel-filter-search.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 8af3392e71..746c248352 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -91,6 +91,7 @@ static ESExpResult *get_current_date (struct _ESExp *f, int argc, struct _ESExpR
static ESExpResult *header_source (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms);
static ESExpResult *get_size (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms);
static ESExpResult *pipe_message (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms);
+static ESExpResult *junk_test (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms);
/* builtin functions */
static struct {
@@ -119,6 +120,7 @@ static struct {
{ "header-source", (ESExpFunc *) header_source, 0 },
{ "get-size", (ESExpFunc *) get_size, 0 },
{ "pipe-message", (ESExpFunc *) pipe_message, 0 },
+ { "junk-test", (ESExpFunc *) junk_test, 0 },
};
@@ -563,7 +565,7 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa
camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream);
camel_stream_flush (stream);
- camel_object_unref (stream);
+ camel_object_unref (CAMEL_OBJECT (stream));
result = waitpid (pid, &status, 0);
@@ -609,6 +611,23 @@ pipe_message (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMess
return r;
}
+static ESExpResult *
+junk_test (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms)
+{
+ ESExpResult *r;
+ gboolean retval = FALSE;
+
+ if (fms->session->junk_plugin != NULL) {
+ retval = camel_junk_plugin_check_junk (fms->session->junk_plugin, camel_filter_search_get_message (fms, f));
+
+ fprintf (stderr, "junk filter => %s\n", retval ? "*JUNK*" : "clean");
+ }
+ r = e_sexp_result_new (f, ESEXP_RES_BOOL);
+ r->value.number = retval;
+
+ return r;
+}
+
/**
* camel_filter_search_match:
@@ -676,13 +695,13 @@ camel_filter_search_match (CamelSession *session,
e_sexp_unref (sexp);
if (fms.message)
- camel_object_unref (fms.message);
+ camel_object_unref (CAMEL_OBJECT (fms.message));
return retval;
error:
if (fms.message)
- camel_object_unref (fms.message);
+ camel_object_unref (CAMEL_OBJECT (fms.message));
e_sexp_unref (sexp);