aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-10-24 10:53:01 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-10-24 10:53:01 +0800
commit0887fc650f5b6f37cbbaa84d3edd121fd83ba85d (patch)
tree3d057dcf550ab7642327d483ef63e332e66fc4d4
parent04780422995146b73e64c37ad79f42516c77d52e (diff)
downloadgsoc2013-evolution-0887fc650f5b6f37cbbaa84d3edd121fd83ba85d.tar
gsoc2013-evolution-0887fc650f5b6f37cbbaa84d3edd121fd83ba85d.tar.gz
gsoc2013-evolution-0887fc650f5b6f37cbbaa84d3edd121fd83ba85d.tar.bz2
gsoc2013-evolution-0887fc650f5b6f37cbbaa84d3edd121fd83ba85d.tar.lz
gsoc2013-evolution-0887fc650f5b6f37cbbaa84d3edd121fd83ba85d.tar.xz
gsoc2013-evolution-0887fc650f5b6f37cbbaa84d3edd121fd83ba85d.tar.zst
gsoc2013-evolution-0887fc650f5b6f37cbbaa84d3edd121fd83ba85d.zip
Apply outgoing filters to the message.
2000-10-23 Jeffrey Stedfast <fejj@helixcode.com> * mail-ops.c (do_send_mail): Apply outgoing filters to the message. svn path=/trunk/; revision=6140
-rw-r--r--mail/ChangeLog5
-rw-r--r--mail/mail-autofilter.c19
-rw-r--r--mail/mail-callbacks.c4
-rw-r--r--mail/mail-ops.c65
4 files changed, 64 insertions, 29 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 770d4edf4a..3dfad4a451 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,8 @@
+2000-10-23 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * mail-ops.c (do_send_mail): Apply outgoing filters to the
+ message.
+
2000-10-23 Christopher James Lahey <clahey@helixcode.com>
* message-list.c: Fixed a possible error in row numberings. This
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 4070f5fc4e..22b506d683 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -269,26 +269,25 @@ filter_rule_from_message(FilterContext *context, CamelMimeMessage *msg, int flag
}
void
-filter_gui_add_from_message(CamelMimeMessage *msg, int flags)
+filter_gui_add_from_message (CamelMimeMessage *msg, int flags)
{
FilterContext *fc;
char *userrules, *systemrules;
FilterRule *rule;
extern char *evolution_dir;
-
- fc = filter_context_new();
- userrules = g_strdup_printf("%s/filters.xml", evolution_dir);
- systemrules = g_strdup_printf("%s/evolution/filtertypes.xml", EVOLUTION_DATADIR);
- rule_context_load((RuleContext *)fc, systemrules, userrules);
- rule = filter_rule_from_message(fc, msg, flags);
- /* FIXME: with demand filters being abandoned, do we still care about source? */
+ fc = filter_context_new ();
+ userrules = g_strdup_printf ("%s/filters.xml", evolution_dir);
+ systemrules = g_strdup_printf ("%s/evolution/filtertypes.xml", EVOLUTION_DATADIR);
+ rule_context_load ((RuleContext *)fc, systemrules, userrules);
+ rule = filter_rule_from_message (fc, msg, flags);
+
filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
- rule_context_add_rule_gui((RuleContext *)fc, rule, _("Add Filter Rule"), userrules);
+ rule_context_add_rule_gui ((RuleContext *)fc, rule, _("Add Filter Rule"), userrules);
g_free (userrules);
g_free (systemrules);
- gtk_object_unref((GtkObject *)fc);
+ gtk_object_unref (GTK_OBJECT (fc));
}
void
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 18bcbecf70..e6f6e4c59e 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -702,7 +702,7 @@ filter_edit (BonoboUIComponent *uih, void *user_data, const char *path)
char *user, *system;
GtkWidget *w;
- fc = filter_context_new();
+ fc = filter_context_new ();
user = g_strdup_printf ("%s/filters.xml", evolution_dir);
system = g_strdup_printf ("%s/evolution/filtertypes.xml", EVOLUTION_DATADIR);
rule_context_load ((RuleContext *)fc, system, user);
@@ -731,7 +731,7 @@ filter_edit (BonoboUIComponent *uih, void *user_data, const char *path)
void
vfolder_edit_vfolders (BonoboUIComponent *uih, void *user_data, const char *path)
{
- vfolder_edit();
+ vfolder_edit ();
}
void
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 59a6e0cde3..99feb2059f 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -99,7 +99,8 @@ mail_load_evolution_rule_context ()
}
static void
-mail_op_report_status(FilterDriver *driver, enum filter_status_t status, const char *desc, CamelMimeMessage *msg, void *data)
+mail_op_report_status (FilterDriver *driver, enum filter_status_t status, const char *desc,
+ CamelMimeMessage *msg, void *data)
{
printf("reporting status: %s\n", desc);
@@ -351,24 +352,24 @@ do_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex)
filter_driver_set_status_func(driver, mail_op_report_status, logfile);
/* build the uid list - all uid's not deleted already */
uids = camel_folder_get_uids (input->source);
- new_uids = g_ptr_array_new();
- for (i=0;i<uids->len;i++) {
+ new_uids = g_ptr_array_new ();
+ for (i = 0; i < uids->len; i++) {
const CamelMessageInfo *info = camel_folder_get_message_info(input->source, uids->pdata[i]);
if (info && (info->flags & CAMEL_MESSAGE_DELETED) == 0) {
g_ptr_array_add(new_uids, uids->pdata[i]);
}
}
-
+
/* run the filter */
- filter_driver_filter_folder(driver, input->source, FILTER_SOURCE_DEMAND, new_uids, TRUE, ex);
-
+ filter_driver_filter_folder (driver, input->source, FILTER_SOURCE_DEMAND, new_uids, TRUE, ex);
+
camel_folder_free_uids (input->source, uids);
g_ptr_array_free(new_uids, TRUE);
-
+
if (logfile)
- fclose(logfile);
-
- gtk_object_unref((GtkObject *)driver);
+ fclose (logfile);
+
+ gtk_object_unref (GTK_OBJECT (driver));
mail_tool_camel_lock_down ();
}
@@ -471,12 +472,13 @@ do_send_mail (gpointer in_data, gpointer op_data, CamelException *ex)
{
send_mail_input_t *input = (send_mail_input_t *) in_data;
extern CamelFolder *sent_folder;
+ CamelMessageInfo *info;
CamelTransport *xport;
- char *x_mailer;
+ FilterContext *context;
+ char *x_mailer, *user, *system;
mail_tool_camel_lock_up ();
- x_mailer = g_strdup_printf ("Evolution %s (Developer Preview)",
- VERSION);
+ x_mailer = g_strdup_printf ("Evolution %s (Developer Preview)", VERSION);
camel_medium_add_header (CAMEL_MEDIUM (input->message), "X-Mailer",
x_mailer);
g_free (x_mailer);
@@ -508,14 +510,43 @@ do_send_mail (gpointer in_data, gpointer op_data, CamelException *ex)
mail_tool_camel_lock_down ();
}
+ /* now lets run it through the outgoing filters */
+
+ info = g_new0 (CamelMessageInfo, 1);
+ info->flags = CAMEL_MESSAGE_SEEN;
+
+ /* setup filter driver */
+ context = filter_context_new ();
+ user = g_strdup_printf ("%s/filters.xml", evolution_dir);
+ system = g_strdup_printf ("%s/evolution/filtertypes.xml", EVOLUTION_DATADIR);
+ rule_context_load ((RuleContext *)context, system, user);
+ g_free (user);
+ g_free (system);
+
+ if (!((RuleContext *)context)->error) {
+ FilterDriver *driver;
+ FILE *logfile;
+
+ driver = filter_driver_new (context, mail_tool_filter_get_folder_func, NULL);
+
+ if (TRUE /* perform_logging */) {
+ char *filename;
+
+ filename = g_strdup_printf ("%s/evolution-filter-log", evolution_dir);
+ logfile = fopen (filename, "a+");
+ g_free (filename);
+ }
+
+ filter_driver_filter_message (driver, input->message, info, "", FILTER_SOURCE_OUTGOING, ex);
+
+ if (logfile)
+ fclose (logfile);
+ }
+
/* now to save the message in Sent */
if (sent_folder) {
- CamelMessageInfo *info;
-
mail_tool_camel_lock_up ();
- info = g_new0 (CamelMessageInfo, 1);
- info->flags = CAMEL_MESSAGE_SEEN;
camel_folder_append_message (sent_folder, input->message, info, ex);
g_free (info);