diff options
author | Dan Winship <danw@src.gnome.org> | 2001-07-02 23:04:27 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-07-02 23:04:27 +0800 |
commit | 5bd925e997d1b3cb74bdcb44b7bfc61c262a282b (patch) | |
tree | e354ab0ce6a85f40d9cb13814acf505dd0694329 /mail/mail-session.c | |
parent | faac871501ee1935cdbaf044e2f8ac4dc00eadc2 (diff) | |
download | gsoc2013-evolution-5bd925e997d1b3cb74bdcb44b7bfc61c262a282b.tar.gz gsoc2013-evolution-5bd925e997d1b3cb74bdcb44b7bfc61c262a282b.tar.zst gsoc2013-evolution-5bd925e997d1b3cb74bdcb44b7bfc61c262a282b.zip |
Implement this, based on code that used to be in mail-ops.c
* mail-session.c (get_filter_driver): Implement this, based on
code that used to be in mail-ops.c
* mail-ops.c (mail_load_filter_context, setup_filter_driver):
Moved into MailSession::get_filter_driver.
(filter_get_folder): Moved to mail-session.c
(mail_filter_folder, mail_filter_on_demand, mail_fetch_mail,
mail_send_mail, mail_send_queue): Remove FilterContext args, use
camel_session_get_filter_driver.
* mail-send-recv.c (mail_send_receive, mail_receive_uri):
Remove FilterContexts
svn path=/trunk/; revision=10682
Diffstat (limited to 'mail/mail-session.c')
-rw-r--r-- | mail/mail-session.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/mail/mail-session.c b/mail/mail-session.c index 88a69f8097..9a3e519d5e 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -30,8 +30,12 @@ #include <libgnomeui/gnome-dialog-util.h> #include <libgnomeui/gnome-messagebox.h> #include <libgnomeui/gnome-stock.h> +#include "camel/camel-filter-driver.h" +#include "filter/filter-context.h" +#include "filter/filter-filter.h" #include "mail.h" #include "mail-session.h" +#include "mail-tools.h" #include "mail-mt.h" CamelSession *session; @@ -48,6 +52,7 @@ typedef struct _MailSession { GHashTable *passwords; gboolean interaction_enabled; + FILE *filter_logfile; } MailSession; typedef struct _MailSessionClass { @@ -66,6 +71,9 @@ static gboolean alert_user (CamelSession *session, CamelSessionAlertType type, static guint register_timeout (CamelSession *session, guint32 interval, CamelTimeoutCallback cb, gpointer camel_data); static gboolean remove_timeout (CamelSession *session, guint handle); +static CamelFilterDriver *get_filter_driver (CamelSession *session, + const char *type, + CamelException *ex); static char *decode_base64 (char *base64); @@ -102,6 +110,7 @@ class_init (MailSessionClass *mail_session_class) camel_session_class->alert_user = alert_user; camel_session_class->register_timeout = register_timeout; camel_session_class->remove_timeout = remove_timeout; + camel_session_class->get_filter_driver = get_filter_driver; } static CamelType @@ -280,6 +289,64 @@ remove_timeout (CamelSession *session, guint handle) return TRUE; } +static CamelFolder * +get_folder (CamelFilterDriver *d, const char *uri, void *data, CamelException *ex) +{ + return mail_tool_uri_to_folder(uri, ex); +} + +static CamelFilterDriver * +get_filter_driver (CamelSession *session, const char *type, CamelException *ex) +{ + CamelFilterDriver *driver; + RuleContext *fc; + GString *fsearch, *faction; + FilterRule *rule = NULL; + char *user, *system, *filename; + + user = g_strdup_printf ("%s/filters.xml", evolution_dir); + system = EVOLUTION_DATADIR "/evolution/filtertypes.xml"; + fc = (RuleContext *)filter_context_new (); + rule_context_load (fc, system, user); + g_free (user); + + driver = camel_filter_driver_new (); + camel_filter_driver_set_folder_func (driver, get_folder, NULL); + + if (TRUE /* perform_logging FIXME */) { + MailSession *ms = (MailSession *)session; + + if (ms->filter_logfile == NULL) { + filename = g_strdup_printf ("%s/evolution-filter-log", + evolution_dir); + ms->filter_logfile = fopen (filename, "a+"); + g_free (filename); + } + if (ms->filter_logfile) + camel_filter_driver_set_logfile (driver, ms->filter_logfile); + } + + fsearch = g_string_new (""); + faction = g_string_new (""); + + while ((rule = rule_context_next_rule (fc, rule, type))) { + g_string_truncate (fsearch, 0); + g_string_truncate (faction, 0); + + filter_rule_build_code (rule, fsearch); + filter_filter_build_action ((FilterFilter *)rule, faction); + + camel_filter_driver_add_rule (driver, rule->name, + fsearch->str, faction->str); + } + + g_string_free (fsearch, TRUE); + g_string_free (faction, TRUE); + + gtk_object_unref (GTK_OBJECT (fc)); + return driver; +} + static char * decode_base64 (char *base64) |