aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-12-15 07:23:06 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-12-15 07:23:06 +0800
commit097aa981dad92fa08c17e717ceb1834a86437531 (patch)
tree9d9439e96081af1ed529f2a47109aa7f6b690605 /camel
parent4ca6b8bf00f22c1876720d39acb4e8a5b6a0a39c (diff)
downloadgsoc2013-evolution-097aa981dad92fa08c17e717ceb1834a86437531.tar.gz
gsoc2013-evolution-097aa981dad92fa08c17e717ceb1834a86437531.tar.zst
gsoc2013-evolution-097aa981dad92fa08c17e717ceb1834a86437531.zip
Reset the filtered_count to zero.
2001-12-14 Jeffrey Stedfast <fejj@ximian.com> * camel-filter-driver.c (camel_filter_driver_reset_filtered_count): Reset the filtered_count to zero. (camel_filter_driver_get_filtered_count): Return the private filtered_count value. (camel_filter_driver_filter_message): Increment the filtered_count. (camel_filter_driver_set_shell_exec_func): New function to set the shell-exec func. (shell_exec): New ESExp filter action callback. svn path=/trunk/; revision=15087
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog13
-rw-r--r--camel/camel-filter-driver.c79
-rw-r--r--camel/camel-filter-driver.h46
3 files changed, 106 insertions, 32 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 0b4da1ddd1..b0b483b3c5 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,18 @@
2001-12-14 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-filter-driver.c
+ (camel_filter_driver_reset_filtered_count): Reset the
+ filtered_count to zero.
+ (camel_filter_driver_get_filtered_count): Return the private
+ filtered_count value.
+ (camel_filter_driver_filter_message): Increment the
+ filtered_count.
+ (camel_filter_driver_set_shell_exec_func): New function to set the
+ shell-exec func.
+ (shell_exec): New ESExp filter action callback.
+
+2001-12-14 Jeffrey Stedfast <fejj@ximian.com>
+
* camel-pgp-mime.c (camel_pgp_mime_part_verify): Removed
x-inline-pgp-hack kludge because it doesn't work.
(camel_pgp_mime_part_decrypt): Same.
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index 1b9c30efb6..221947601c 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -67,11 +67,16 @@ struct _filter_rule {
struct _CamelFilterDriverPrivate {
GHashTable *globals; /* global variables */
-
- CamelFolder *defaultfolder; /* defualt folder */
- CamelFilterStatusFunc *statusfunc; /* status callback */
- void *statusdata; /* status callback data */
+ int filtered_count; /* count of the number of messages filtered so far */
+
+ CamelFolder *defaultfolder; /* defualt folder */
+
+ CamelFilterStatusFunc *statusfunc; /* status callback */
+ void *statusdata; /* status callback data */
+
+ CamelFilterShellExecFunc *execfunc; /* execute shell command callback */
+ void *execdata; /* execute shell command data */
/* for callback */
CamelFilterGetFolderFunc get_folder;
@@ -120,6 +125,7 @@ static ESExpResult *do_stop (struct _ESExp *f, int argc, struct _ESExpResult **a
static ESExpResult *do_colour (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *);
static ESExpResult *do_score (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *);
static ESExpResult *do_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *);
+static ESExpResult *shell_exec (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *);
/* these are our filter actions - each must have a callback */
static struct {
@@ -135,24 +141,26 @@ static struct {
{ "stop", (ESExpFunc *) do_stop, 0 },
{ "set-colour", (ESExpFunc *) do_colour, 0 },
{ "set-score", (ESExpFunc *) do_score, 0 },
- { "set-system-flag", (ESExpFunc *) do_flag, 0 }
+ { "set-system-flag", (ESExpFunc *) do_flag, 0 },
+ { "shell-exec", (ESExpFunc *) shell_exec, 0 }
};
static CamelObjectClass *camel_filter_driver_parent;
-guint
+CamelType
camel_filter_driver_get_type (void)
{
static CamelType type = CAMEL_INVALID_TYPE;
if (type == CAMEL_INVALID_TYPE) {
- type = camel_type_register(CAMEL_OBJECT_TYPE, "CamelFilterDriver",
- sizeof(CamelFilterDriver),
- sizeof(CamelFilterDriverClass),
- (CamelObjectClassInitFunc)camel_filter_driver_class_init,
- NULL,
- (CamelObjectInitFunc)camel_filter_driver_init,
- (CamelObjectFinalizeFunc)camel_filter_driver_finalise);
+ type = camel_type_register (CAMEL_OBJECT_TYPE,
+ "CamelFilterDriver",
+ sizeof (CamelFilterDriver),
+ sizeof (CamelFilterDriverClass),
+ (CamelObjectClassInitFunc) camel_filter_driver_class_init,
+ NULL,
+ (CamelObjectInitFunc) camel_filter_driver_init,
+ (CamelObjectFinalizeFunc) camel_filter_driver_finalise);
}
return type;
@@ -241,6 +249,22 @@ camel_filter_driver_new (void)
}
void
+camel_filter_driver_reset_filtered_count (CamelFilterDriver *driver)
+{
+ struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+
+ p->filtered_count = 0;
+}
+
+int
+camel_filter_driver_get_filtered_count (CamelFilterDriver *driver)
+{
+ struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+
+ return p->filtered_count;
+}
+
+void
camel_filter_driver_set_folder_func (CamelFilterDriver *d, CamelFilterGetFolderFunc get_folder, void *data)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
@@ -267,6 +291,15 @@ camel_filter_driver_set_status_func (CamelFilterDriver *d, CamelFilterStatusFunc
}
void
+camel_filter_driver_set_shell_exec_func (CamelFilterDriver *d, CamelFilterShellExecFunc *func, void *data)
+{
+ struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+
+ p->execfunc = func;
+ p->execdata = data;
+}
+
+void
camel_filter_driver_set_default_folder (CamelFilterDriver *d, CamelFolder *def)
{
struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
@@ -508,6 +541,22 @@ do_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriv
return NULL;
}
+static ESExpResult *
+shell_exec (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
+{
+ struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+
+ d(fprintf (stderr, "executing shell command\n"));
+
+ if (p->execfunc && argc == 1 && argv[0]->type == ESEXP_RES_STRING) {
+ p->execfunc (driver, argv[0]->value.string, p->execdata);
+ camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Executing shell command: [%s]",
+ argv[0]->value.string);
+ }
+
+ return NULL;
+}
+
static CamelFolder *
open_folder (CamelFilterDriver *driver, const char *folder_url)
{
@@ -907,7 +956,7 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
result = camel_filter_search_match (p->message, p->info,
original_source_url ? original_source_url : source_url,
node->match, p->ex);
-
+
switch (result) {
case CAMEL_SEARCH_ERROR:
goto error;
@@ -964,6 +1013,8 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
if (freeinfo)
camel_message_info_free (info);
+ p->filtered_count++;
+
return 0;
error:
diff --git a/camel/camel-filter-driver.h b/camel/camel-filter-driver.h
index 267c0a3eda..d003cc4a48 100644
--- a/camel/camel-filter-driver.h
+++ b/camel/camel-filter-driver.h
@@ -55,34 +55,44 @@ enum camel_filter_status_t {
CAMEL_FILTER_STATUS_END, /* end of message */
};
-typedef CamelFolder * (*CamelFilterGetFolderFunc) (CamelFilterDriver *, const char *uri, void *data, CamelException *ex);
+typedef CamelFolder * (*CamelFilterGetFolderFunc) (CamelFilterDriver *driver, const char *uri,
+ void *data, CamelException *ex);
/* report status */
-typedef void (CamelFilterStatusFunc)(CamelFilterDriver *driver, enum camel_filter_status_t status, int pc, const char *desc, void *data);
+typedef void (CamelFilterStatusFunc) (CamelFilterDriver *driver, enum camel_filter_status_t status,
+ int pc, const char *desc, void *data);
-guint camel_filter_driver_get_type (void);
+typedef void (CamelFilterShellExecFunc) (CamelFilterDriver *driver, const char *command, void *data);
+
+CamelType camel_filter_driver_get_type (void);
CamelFilterDriver *camel_filter_driver_new (void);
/* modifiers */
-void camel_filter_driver_set_folder_func (CamelFilterDriver *d, CamelFilterGetFolderFunc fetcher, void *data);
-void camel_filter_driver_set_logfile (CamelFilterDriver *d, FILE *logfile);
-void camel_filter_driver_set_status_func (CamelFilterDriver *d, CamelFilterStatusFunc *func,
- void *data);
-void camel_filter_driver_set_default_folder (CamelFilterDriver *d, CamelFolder *def);
-void camel_filter_driver_add_rule (CamelFilterDriver *d, const char *name, const char *match,
- const char *action);
+void camel_filter_driver_reset_filtered_count (CamelFilterDriver *driver);
+int camel_filter_driver_get_filtered_count (CamelFilterDriver *driver);
+
+void camel_filter_driver_set_logfile (CamelFilterDriver *d, FILE *logfile);
+
+void camel_filter_driver_set_status_func (CamelFilterDriver *d, CamelFilterStatusFunc *func, void *data);
+void camel_filter_driver_set_shell_exec_func (CamelFilterDriver *d, CamelFilterShellExecFunc *func, void *data);
+void camel_filter_driver_set_folder_func (CamelFilterDriver *d, CamelFilterGetFolderFunc fetcher, void *data);
+
+void camel_filter_driver_set_default_folder (CamelFilterDriver *d, CamelFolder *def);
+
+void camel_filter_driver_add_rule (CamelFilterDriver *d, const char *name, const char *match,
+ const char *action);
/*void camel_filter_driver_set_global(CamelFilterDriver *, const char *name, const char *value);*/
-int camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage *message,
- CamelMessageInfo *info, const char *uri,
- CamelFolder *source, const char *source_url,
- const char *original_source_url, CamelException *ex);
+int camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage *message,
+ CamelMessageInfo *info, const char *uri,
+ CamelFolder *source, const char *source_url,
+ const char *original_source_url, CamelException *ex);
-int camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox,
- const char *original_source_url, CamelException *ex);
+int camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const char *mbox,
+ const char *original_source_url, CamelException *ex);
-int camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folder, CamelUIDCache *cache,
- GPtrArray *uids, gboolean remove, CamelException *ex);
+int camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folder, CamelUIDCache *cache,
+ GPtrArray *uids, gboolean remove, CamelException *ex);
#if 0
/* generate the search query/action string for a filter option */