aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-10-26 08:16:31 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-10-26 08:16:31 +0800
commit3a69bfad533e0fde9f36ad9fa7f8bfa52b15c694 (patch)
tree00c7b34b2dd1f08b6a6c434b99823d3607fdf305 /mail
parent4eeed4e227b3acd9dc3983427f7cfff775468e51 (diff)
downloadgsoc2013-evolution-3a69bfad533e0fde9f36ad9fa7f8bfa52b15c694.tar
gsoc2013-evolution-3a69bfad533e0fde9f36ad9fa7f8bfa52b15c694.tar.gz
gsoc2013-evolution-3a69bfad533e0fde9f36ad9fa7f8bfa52b15c694.tar.bz2
gsoc2013-evolution-3a69bfad533e0fde9f36ad9fa7f8bfa52b15c694.tar.lz
gsoc2013-evolution-3a69bfad533e0fde9f36ad9fa7f8bfa52b15c694.tar.xz
gsoc2013-evolution-3a69bfad533e0fde9f36ad9fa7f8bfa52b15c694.tar.zst
gsoc2013-evolution-3a69bfad533e0fde9f36ad9fa7f8bfa52b15c694.zip
Don't forget to unref the FilterDriver.
2000-10-25 Jeffrey Stedfast <fejj@helixcode.com> * mail-ops.c (do_send_mail): Don't forget to unref the FilterDriver. * mail-callbacks.c (apply_filters): New callback for applying on-demand filters. (removed the old on-demand filters callback). * mail-ops.c (do_filter_ondemand): Rewrote to apply "incoming" filters to all selected messages. (mail_do_filter_ondemand): No longer takes a FilterContext argument or a destination folder argument (why did we ever need this last one??) but now takes a uids argument. * folder-browser-factory.c: Add a MessageApplyFilters menu item. svn path=/trunk/; revision=6190
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog16
-rw-r--r--mail/folder-browser-factory.c1
-rw-r--r--mail/mail-callbacks.c24
-rw-r--r--mail/mail-ops.c119
-rw-r--r--mail/mail-ops.h5
-rw-r--r--mail/mail.h3
6 files changed, 92 insertions, 76 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index ea8e01e1ea..61b22d9f3d 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,19 @@
+2000-10-25 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * mail-ops.c (do_send_mail): Don't forget to unref the
+ FilterDriver.
+
+ * mail-callbacks.c (apply_filters): New callback for applying
+ on-demand filters. (removed the old on-demand filters callback).
+
+ * mail-ops.c (do_filter_ondemand): Rewrote to apply "incoming"
+ filters to all selected messages.
+ (mail_do_filter_ondemand): No longer takes a FilterContext
+ argument or a destination folder argument (why did we ever need
+ this last one??) but now takes a uids argument.
+
+ * folder-browser-factory.c: Add a MessageApplyFilters menu item.
+
2000-10-25 Iain Holmes <iain@helixcode.com>
* mail-summary.[ch]: Updated for the new ExecutiveSummary code.
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index 22254bacc6..87ae4957a3 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -62,6 +62,7 @@ BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("MessageDelete", delete_msg),
BONOBO_UI_UNSAFE_VERB ("MessageMove", move_msg),
BONOBO_UI_UNSAFE_VERB ("MessageCopy", copy_msg),
+ BONOBO_UI_UNSAFE_VERB ("MessageApplyFilters", apply_filters),
BONOBO_UI_UNSAFE_VERB ("MessageVFolderSubj", vfolder_subject),
BONOBO_UI_UNSAFE_VERB ("MessageVFolderSndr", vfolder_sender),
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index e2b8c8b4be..1b088fe4df 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -547,6 +547,19 @@ copy_msg (GtkWidget *widget, gpointer user_data)
}
void
+apply_filters (GtkWidget *widget, gpointer user_data)
+{
+ FolderBrowser *fb = FOLDER_BROWSER (user_data);
+ MessageList *ml = fb->message_list;
+ GPtrArray *uids;
+
+ uids = g_ptr_array_new ();
+ message_list_foreach (ml, enumerate_msg, uids);
+
+ mail_do_filter_ondemand (fb->folder, uids);
+}
+
+void
select_all (BonoboUIComponent *uih, void *user_data, const char *path)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
@@ -883,14 +896,3 @@ edit_message (BonoboUIComponent *uih, void *user_data, const char *path)
{
edit_msg (NULL, user_data);
}
-
-void
-run_filter_ondemand (BonoboUIComponent *uih, gpointer user_data, const char *path)
-{
- struct fb_ondemand_closure *oc = (struct fb_ondemand_closure *) user_data;
-
- if (oc->fb->folder == NULL)
- return;
-
- mail_do_filter_ondemand (oc->fb->filter_context, oc->fb->folder, oc->fb->folder);
-}
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 99feb2059f..158a23a953 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -55,15 +55,15 @@ describe_fetch_mail (gpointer in_data, gboolean gerund)
{
fetch_mail_input_t *input = (fetch_mail_input_t *) in_data;
char *name;
-
+
/*source = camel_session_get_store (session, input->source_url, NULL);
*if (source) {
* name = camel_service_get_name (CAMEL_SERVICE (source), FALSE);
* camel_object_unref (CAMEL_OBJECT (source));
*} else
*/
- name = input->source_url;
-
+ name = input->source_url;
+
if (gerund)
return g_strdup_printf (_("Fetching email from %s"), name);
else
@@ -75,7 +75,7 @@ setup_fetch_mail (gpointer in_data, gpointer op_data, CamelException *ex)
{
fetch_mail_input_t *input = (fetch_mail_input_t *) in_data;
fetch_mail_data_t *data = (fetch_mail_data_t *) op_data;
-
+
data->empty = FALSE;
if (input->destination)
camel_object_ref (CAMEL_OBJECT (input->destination));
@@ -87,14 +87,14 @@ mail_load_evolution_rule_context ()
gchar *userrules;
gchar *systemrules;
FilterContext *fc;
-
+
userrules = g_strdup_printf ("%s/filters.xml", evolution_dir);
systemrules = g_strdup_printf ("%s/evolution/filtertypes.xml", EVOLUTION_DATADIR);
fc = filter_context_new ();
rule_context_load ((RuleContext *)fc, systemrules, userrules);
g_free (userrules);
g_free (systemrules);
-
+
return fc;
}
@@ -119,7 +119,7 @@ mail_op_report_status (FilterDriver *driver, enum filter_status_t status, const
/* use the 'standard' logging function, data is already the fd */
if (data)
- filter_driver_status_log(driver, status, desc, msg, data);
+ filter_driver_status_log (driver, status, desc, msg, data);
}
static void
@@ -139,7 +139,7 @@ do_fetch_mail (gpointer in_data, gpointer op_data, CamelException *ex)
camel_folder_refresh_info (folder, ex);
camel_object_unref (CAMEL_OBJECT (folder));
}
-
+
data->empty = FALSE;
return;
}
@@ -170,10 +170,10 @@ do_fetch_mail (gpointer in_data, gpointer op_data, CamelException *ex)
if (!strncmp (input->source_url, "mbox:", 5)) {
char *path = mail_tool_do_movemail (input->source_url, ex);
-
+
if (path && !camel_exception_is_set (ex)) {
filter_driver_filter_mbox (filter, path, FILTER_SOURCE_INCOMING, ex);
-
+
/* ok? zap the output file */
if (!camel_exception_is_set (ex)) {
unlink (path);
@@ -296,11 +296,9 @@ mail_do_fetch_mail (const gchar *source_url, gboolean keep_on_server,
/* why do we have this separate code, it is basically a copy of the code above,
should be consolidated */
-typedef struct filter_ondemand_input_s
-{
- FilterContext *context;
+typedef struct filter_ondemand_input_s {
CamelFolder *source;
- CamelFolder *destination;
+ GPtrArray *uids;
} filter_ondemand_input_t;
static gchar *
@@ -316,12 +314,8 @@ static void
setup_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex)
{
filter_ondemand_input_t *input = (filter_ondemand_input_t *) in_data;
-
- gtk_object_ref (GTK_OBJECT (input->context));
- if (input->source)
- camel_object_ref (CAMEL_OBJECT (input->source));
- if (input->destination)
- camel_object_ref (CAMEL_OBJECT (input->destination));
+
+ camel_object_ref (CAMEL_OBJECT (input->source));
}
static void
@@ -329,42 +323,52 @@ do_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex)
{
filter_ondemand_input_t *input = (filter_ondemand_input_t *) in_data;
FilterDriver *driver;
- GPtrArray *uids, *new_uids;
- char *filename;
+ FilterContext *context;
FILE *logfile = NULL;
int i;
mail_tool_camel_lock_up ();
if (camel_folder_get_message_count (input->source) == 0) {
- mail_tool_camel_lock_down();
+ mail_tool_camel_lock_down ();
return;
}
-
- /* setup filter driver */
- driver = filter_driver_new (input->context, mail_tool_filter_get_folder_func, NULL);
- /* -- we want no default destination this time */
+
+ /* create the filter context */
+ context = mail_load_evolution_rule_context ();
+
+ if (((RuleContext *)context)->error) {
+ gtk_object_unref (GTK_OBJECT (context));
+
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ "Cannot apply filters: failed to load filter rules.");
+
+ mail_tool_camel_lock_down ();
+ return;
+ }
+
+ /* setup filter driver - no default destination */
+ 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_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++) {
- 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_set_status_func (driver, mail_op_report_status, logfile);
- camel_folder_free_uids (input->source, uids);
- g_ptr_array_free(new_uids, TRUE);
+ for (i = 0; i < input->uids->len; i++) {
+ CamelMimeMessage *message;
+ CamelMessageInfo *info;
+
+ message = camel_folder_get_message (input->source, input->uids->pdata[i], ex);
+ info = (CamelMessageInfo *) camel_folder_get_message_info (input->source, input->uids->pdata[i]);
+
+ /* filter the message - use "incoming" rules since we don't want special "demand" filters? */
+ filter_driver_filter_message (driver, message, info, "", FILTER_SOURCE_INCOMING, ex);
+ }
if (logfile)
fclose (logfile);
@@ -377,15 +381,14 @@ static void
cleanup_filter_ondemand (gpointer in_data, gpointer op_data, CamelException *ex)
{
filter_ondemand_input_t *input = (filter_ondemand_input_t *) in_data;
+ int i;
if (input->source)
camel_object_unref (CAMEL_OBJECT (input->source));
- if (input->destination)
- camel_object_unref (CAMEL_OBJECT (input->destination));
-
- if (input->context)
- gtk_object_unref (GTK_OBJECT (input->context));
+ for (i = 0; i < input->uids->len; i++)
+ g_free (input->uids->pdata[i]);
+ g_ptr_array_free (input->uids, TRUE);
}
static const mail_operation_spec op_filter_ondemand = {
@@ -397,18 +400,15 @@ static const mail_operation_spec op_filter_ondemand = {
};
void
-mail_do_filter_ondemand (FilterContext *context, CamelFolder *source, CamelFolder *destination)
+mail_do_filter_ondemand (CamelFolder *source, GPtrArray *uids)
{
filter_ondemand_input_t *input;
- g_return_if_fail (IS_FILTER_CONTEXT (context));
g_return_if_fail (source == NULL || CAMEL_IS_FOLDER (source));
- g_return_if_fail (destination == NULL || CAMEL_IS_FOLDER (destination));
-
+
input = g_new (filter_ondemand_input_t, 1);
- input->context = context;
input->source = source;
- input->destination = destination;
+ input->uids = uids;
mail_operation_queue (&op_filter_ondemand, input, TRUE);
}
@@ -419,7 +419,7 @@ typedef struct send_mail_input_s
{
gchar *xport_uri;
CamelMimeMessage *message;
-
+
/* If done_folder != NULL, will add done_flags to
* the flags of the message done_uid in done_folder. */
@@ -475,7 +475,7 @@ do_send_mail (gpointer in_data, gpointer op_data, CamelException *ex)
CamelMessageInfo *info;
CamelTransport *xport;
FilterContext *context;
- char *x_mailer, *user, *system;
+ char *x_mailer;
mail_tool_camel_lock_up ();
x_mailer = g_strdup_printf ("Evolution %s (Developer Preview)", VERSION);
@@ -516,12 +516,7 @@ do_send_mail (gpointer in_data, gpointer op_data, CamelException *ex)
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);
+ context = mail_load_evolution_rule_context ();
if (!((RuleContext *)context)->error) {
FilterDriver *driver;
@@ -539,6 +534,8 @@ do_send_mail (gpointer in_data, gpointer op_data, CamelException *ex)
filter_driver_filter_message (driver, input->message, info, "", FILTER_SOURCE_OUTGOING, ex);
+ gtk_object_unref (GTK_OBJECT (driver));
+
if (logfile)
fclose (logfile);
}
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 0a093b25ce..1be4dc68bc 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -32,8 +32,9 @@
void mail_do_fetch_mail (const gchar *source_url, gboolean keep_on_server,
CamelFolder *destination,
gpointer hook_func, gpointer hook_data);
-void mail_do_filter_ondemand (FilterContext *context, CamelFolder *source,
- CamelFolder *destination);
+
+void mail_do_filter_ondemand (CamelFolder *source, GPtrArray *uids);
+
void mail_do_send_mail (const char *xport_uri,
CamelMimeMessage *message,
CamelFolder *done_folder,
diff --git a/mail/mail.h b/mail/mail.h
index b92766df31..54d1c6b123 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -82,6 +82,7 @@ void reply_to_all (GtkWidget *widget, gpointer user_data);
void delete_msg (GtkWidget *widget, gpointer user_data);
void move_msg (GtkWidget *widget, gpointer user_data);
void copy_msg (GtkWidget *widget, gpointer user_data);
+void apply_filters (GtkWidget *widget, gpointer user_data);
void print_msg (GtkWidget *widget, gpointer user_data);
void print_preview_msg (GtkWidget *widget, gpointer user_data);
void edit_msg (GtkWidget *widget, gpointer user_data);
@@ -108,8 +109,6 @@ void composer_postpone_cb (EMsgComposer *composer, gpointer data);
void mail_print_preview_msg (MailDisplay *md);
void mail_print_msg (MailDisplay *md);
-void run_filter_ondemand (BonoboUIComponent *uih, gpointer user_data, const char *path);
-
/* mail view */
GtkWidget *mail_view_create (CamelFolder *source, const char *uid, CamelMimeMessage *msg);