diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-09-28 06:20:05 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-09-28 06:20:05 +0800 |
commit | 6f2839b4d1869b990e6b855e2eb2c363e04db9aa (patch) | |
tree | 37c316cf184b69aaf4058765c18d8e5a7cb95ccf /filter | |
parent | 9deac0edb915ff7c83bd5a26f2bc36b3ea52cffb (diff) | |
download | gsoc2013-evolution-6f2839b4d1869b990e6b855e2eb2c363e04db9aa.tar.gz gsoc2013-evolution-6f2839b4d1869b990e6b855e2eb2c363e04db9aa.tar.zst gsoc2013-evolution-6f2839b4d1869b990e6b855e2eb2c363e04db9aa.zip |
Now takes an argument to specify the log file (or NULL if logging is not
2000-09-27 Jeffrey Stedfast <fejj@helixcode.com>
* filter-driver.c (filter_driver_run): Now takes an argument to
specify the log file (or NULL if logging is not to be performed).
svn path=/trunk/; revision=5605
Diffstat (limited to 'filter')
-rw-r--r-- | filter/ChangeLog | 5 | ||||
-rw-r--r-- | filter/filter-driver.c | 36 | ||||
-rw-r--r-- | filter/filter-driver.h | 3 |
3 files changed, 42 insertions, 2 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index 1652ab72e0..8cdf28d743 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,8 @@ +2000-09-27 Jeffrey Stedfast <fejj@helixcode.com> + + * filter-driver.c (filter_driver_run): Now takes an argument to + specify the log file (or NULL if logging is not to be performed). + 2000-09-19 Dan Winship <danw@helixcode.com> * Makefile.am (gladedir, filterdir): Use $(datadir), not diff --git a/filter/filter-driver.c b/filter/filter-driver.c index 7fa612c338..a7737d7be3 100644 --- a/filter/filter-driver.c +++ b/filter/filter-driver.c @@ -29,6 +29,8 @@ #include <gnome.h> #include <gtkhtml/gtkhtml.h> +#include <time.h> + #include <gnome-xml/tree.h> #include <gnome-xml/parser.h> @@ -60,6 +62,8 @@ struct _FilterDriverPrivate { CamelMimeMessage *message; /* input message */ CamelMessageInfo *info; /* message summary info */ + FILE *logfile; /* log file */ + CamelException *ex; /* evaluator */ @@ -244,6 +248,8 @@ do_delete (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver if (!p->terminated) { d(fprintf (stderr, "doing delete\n")); p->deleted = TRUE; + if (p->logfile) + fprintf (p->logfile, "Action = Deleted\n"); } return NULL; @@ -257,6 +263,8 @@ mark_forward (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriv if (!p->terminated) { d(fprintf (stderr, "marking message for forwarding\n")); /* FIXME: do stuff here */ + if (p->logfile) + fprintf (p->logfile, "Action = Forwarded\n"); } return NULL; @@ -286,6 +294,8 @@ do_copy (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver *d mail_tool_camel_lock_up (); camel_folder_append_message (outbox, p->message, p->info, p->ex); + if (p->logfile) + fprintf (p->logfile, "Action = Copied to folder %s\n", outbox->full_name); mail_tool_camel_lock_down (); } } @@ -316,6 +326,8 @@ do_colour (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver d(fprintf (stderr, "setting colour tag\n")); if (argc > 0 && argv[0]->type == ESEXP_RES_STRING) { camel_tag_set (&p->info->user_tags, "colour", argv[0]->value.string); + if (p->logfile) + fprintf (p->logfile, "Action = Set color to %s\n", argv[0]->value.string); } } @@ -334,6 +346,8 @@ do_score (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterDriver * value = g_strdup_printf ("%d", argv[0]->value.number); camel_tag_set (&p->info->user_tags, "score", value); + if (p->logfile) + fprintf (p->logfile, "Action = Set score to %d\n", argv[0]->value.number); g_free (value); } } @@ -403,7 +417,8 @@ free_key (gpointer key, gpointer value, gpointer user_data) gboolean filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, CamelMessageInfo *info, - CamelFolder *inbox, enum _filter_source_t sourcetype, CamelException *ex) + CamelFolder *inbox, enum _filter_source_t sourcetype, + FILE *logfile, CamelException *ex) { struct _FilterDriverPrivate *p = _PRIVATE (driver); ESExpResult *r; @@ -422,6 +437,7 @@ filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, CamelMessage p->copied = FALSE; p->message = message; p->info = info; + p->logfile = logfile; fsearch = g_string_new (""); faction = g_string_new (""); @@ -454,11 +470,29 @@ filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, CamelMessage #ifndef NO_WARNINGS #warning "Must check expression parsed and executed properly?" #endif + if (logfile) { + /* write log header */ + time_t t; + char date[50]; + + time (&t); + strftime (date, 49, "%a, %d %b %Y %H:%M:%S", localtime (&t)); + fprintf (logfile, "Applied filter \"%s\" to message from %s - \"%s\" at %s\n", + fsearch->str, camel_mime_message_get_from (message), + camel_mime_message_get_subject (message), date); + } + + /* perform necessary filtering actions */ e_sexp_input_text (p->eval, faction->str, strlen (faction->str)); e_sexp_parse (p->eval); r = e_sexp_eval (p->eval); e_sexp_result_free (r); + if (logfile) { + /* spacer between filters */ + fprintf (logfile, "\n"); + } + if (p->terminated) break; } diff --git a/filter/filter-driver.h b/filter/filter-driver.h index d6a8e2057b..36a5561ed1 100644 --- a/filter/filter-driver.h +++ b/filter/filter-driver.h @@ -55,7 +55,8 @@ FilterDriver *filter_driver_new (FilterContext *ctx, FilterGetFolderFunc fe /* filter a message - returns TRUE if the message was filtered into some location other than inbox */ gboolean filter_driver_run (FilterDriver *driver, CamelMimeMessage *message, CamelMessageInfo *info, - CamelFolder *inbox, enum _filter_source_t sourcetype, CamelException *ex); + CamelFolder *inbox, enum _filter_source_t sourcetype, + FILE *logfile, CamelException *ex); #if 0 /* generate the search query/action string for a filter option */ |