aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog14
-rw-r--r--camel/camel-filter-driver.c19
-rw-r--r--camel/camel-filter-driver.h2
-rw-r--r--camel/camel-filter-search.c71
-rw-r--r--camel/camel-filter-search.h3
5 files changed, 70 insertions, 39 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 1ddf48f6b4..ac20408330 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,17 @@
+2002-09-19 Not Zed <NotZed@Ximian.com>
+
+ * camel-filter-search.c (camel_filter_search_match): Take new
+ session arg. Update callers.
+ (symbols[]): changed get-source to header-source
+ (header_source): Chagned from get_source. Now a boolean, returns
+ true if source matches one of the arguments. Uses the provider
+ url comparison directly for accurate checking. Makes 'filter on
+ source' work.
+
+ * camel-filter-driver.c (camel_filter_driver_new): Take new arg,
+ session.
+ (camel_filter_driver_finalise): Free session.
+
2002-09-19 Jeffrey Stedfast <fejj@ximian.com>
* providers/imap/camel-imap-folder.c (parse_fetch_response): Don't
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index eef5c2fa9e..7b229d5633 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -72,7 +72,9 @@ struct _filter_rule {
struct _CamelFilterDriverPrivate {
GHashTable *globals; /* global variables */
-
+
+ CamelSession *session;
+
CamelFolder *defaultfolder; /* defualt folder */
CamelFilterStatusFunc *statusfunc; /* status callback */
@@ -256,7 +258,9 @@ camel_filter_driver_finalise (CamelObject *obj)
g_free(node->name);
g_free(node);
}
-
+
+ camel_object_unref(p->session);
+
g_free (p);
}
@@ -266,9 +270,14 @@ camel_filter_driver_finalise (CamelObject *obj)
* Return value: A new CamelFilterDriver object
**/
CamelFilterDriver *
-camel_filter_driver_new (void)
+camel_filter_driver_new (CamelSession *session)
{
- return CAMEL_FILTER_DRIVER (camel_object_new(camel_filter_driver_get_type ()));
+ CamelFilterDriver *d = (CamelFilterDriver *)camel_object_new(camel_filter_driver_get_type());
+
+ d->priv->session = session;
+ camel_object_ref((CamelObject *)session);
+
+ return d;
}
void
@@ -1226,7 +1235,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
data.p = p;
data.source_url = original_source_url;
- result = camel_filter_search_match (get_message_cb, &data, p->info,
+ result = camel_filter_search_match (p->session, get_message_cb, &data, p->info,
original_source_url ? original_source_url : source_url,
node->match, p->ex);
diff --git a/camel/camel-filter-driver.h b/camel/camel-filter-driver.h
index 36e3f902fb..8295859cb0 100644
--- a/camel/camel-filter-driver.h
+++ b/camel/camel-filter-driver.h
@@ -71,7 +71,7 @@ typedef void (CamelFilterPlaySoundFunc) (CamelFilterDriver *driver, const char
typedef void (CamelFilterSystemBeepFunc) (CamelFilterDriver *driver, void *data);
CamelType camel_filter_driver_get_type (void);
-CamelFilterDriver *camel_filter_driver_new (void);
+CamelFilterDriver *camel_filter_driver_new (CamelSession *);
/* modifiers */
void camel_filter_driver_set_logfile (CamelFilterDriver *d, FILE *logfile);
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index 2f2fb52724..9a42b5e002 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -52,6 +52,8 @@
#include "e-util/e-sexp.h"
#include "camel-mime-message.h"
+#include "camel-provider.h"
+#include "camel-session.h"
#include "camel-filter-search.h"
#include "camel-exception.h"
#include "camel-multipart.h"
@@ -64,6 +66,7 @@
#define d(x)
typedef struct {
+ CamelSession *session;
CamelFilterSearchGetMessageFunc get_message;
void *get_message_data;
CamelMimeMessage *message;
@@ -90,7 +93,7 @@ static ESExpResult *system_flag (struct _ESExp *f, int argc, struct _ESExpResult
static ESExpResult *get_sent_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms);
static ESExpResult *get_received_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms);
static ESExpResult *get_current_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms);
-static ESExpResult *get_source (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms);
+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);
@@ -118,7 +121,7 @@ static struct {
{ "get-sent-date", (ESExpFunc *) get_sent_date, 0 },
{ "get-received-date", (ESExpFunc *) get_received_date, 0 },
{ "get-current-date", (ESExpFunc *) get_current_date, 0 },
- { "get-source", (ESExpFunc *) get_source, 0 },
+ { "header-source", (ESExpFunc *) header_source, 0 },
{ "get-size", (ESExpFunc *) get_size, 0 },
{ "pipe-message", (ESExpFunc *) pipe_message, 0 },
};
@@ -444,40 +447,40 @@ get_current_date (struct _ESExp *f, int argc, struct _ESExpResult **argv, Filter
}
static ESExpResult *
-get_source (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms)
+header_source (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessageSearch *fms)
{
CamelMimeMessage *message;
ESExpResult *r;
- char *src = NULL;
- char *tmp;
-
+ const char *src;
+ int truth = FALSE, i;
+ CamelProvider *provider;
+ CamelURL *uria, *urib;
+
if (fms->source) {
- CamelURL *url;
-
- url = camel_url_new (fms->source, NULL);
- if (url) {
- src = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
- camel_url_free (url);
- }
+ src = fms->source;
} else {
- message = camel_filter_search_get_message (fms, f);
- src = g_strdup (camel_mime_message_get_source (message));
- }
-
- /* This is an abusive hack */
- if (src && (tmp = strstr (src, "://"))) {
- tmp += 3;
- tmp = strchr (tmp, '/');
- if (tmp)
- *tmp = '\0';
+ message = camel_filter_search_get_message(fms, f);
+ src = camel_mime_message_get_source(message);
}
-
- if (src) {
- r = e_sexp_result_new (f, ESEXP_RES_STRING);
- r->value.string = src;
- } else {
- r = e_sexp_result_new (f, ESEXP_RES_UNDEFINED);
+
+ if (src
+ && (provider = camel_session_get_provider(fms->session, src, NULL))
+ && provider->url_equal) {
+ uria = camel_url_new(src, NULL);
+ if (uria) {
+ for (i=0;i<argc && !truth;i++) {
+ if (argv[i]->type == ESEXP_RES_STRING
+ && (urib = camel_url_new(argv[i]->value.string, NULL))) {
+ truth = provider->url_equal(uria, urib);
+ camel_url_free(urib);
+ }
+ }
+ camel_url_free(uria);
+ }
}
+
+ r = e_sexp_result_new(f, ESEXP_RES_BOOL);
+ r->value.bool = truth;
return r;
}
@@ -608,7 +611,9 @@ pipe_message (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMess
/**
* camel_filter_search_match:
- * @message:
+ * @session:
+ * @get_message: function to retrieve the message if necessary
+ * @data: data for above
* @info:
* @source:
* @expression:
@@ -617,7 +622,8 @@ pipe_message (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMess
* Returns one of CAMEL_SEARCH_MATCHED, CAMEL_SEARCH_NOMATCH, or CAMEL_SEARCH_ERROR.
**/
int
-camel_filter_search_match (CamelFilterSearchGetMessageFunc get_message, void *data,
+camel_filter_search_match (CamelSession *session,
+ CamelFilterSearchGetMessageFunc get_message, void *data,
CamelMessageInfo *info, const char *source,
const char *expression, CamelException *ex)
{
@@ -626,7 +632,8 @@ camel_filter_search_match (CamelFilterSearchGetMessageFunc get_message, void *da
ESExpResult *result;
gboolean retval;
int i;
-
+
+ fms.session = session;
fms.get_message = get_message;
fms.get_message_data = data;
fms.message = NULL;
diff --git a/camel/camel-filter-search.h b/camel/camel-filter-search.h
index d54c3c03b7..51b988362f 100644
--- a/camel/camel-filter-search.h
+++ b/camel/camel-filter-search.h
@@ -42,7 +42,8 @@ enum {
typedef CamelMimeMessage * (*CamelFilterSearchGetMessageFunc) (void *data, CamelException *ex);
-int camel_filter_search_match (CamelFilterSearchGetMessageFunc get_message, void *data,
+int camel_filter_search_match (CamelSession *session,
+ CamelFilterSearchGetMessageFunc get_message, void *data,
CamelMessageInfo *info, const char *source,
const char *expression, CamelException *ex);