From 130bb0e5710983ce14d1151f2611beaff6891379 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Tue, 22 Aug 2000 20:09:11 +0000 Subject: Automatically connect services when given a valid URL (should hopefully disconnect, too); remove the old movemail folder correctly. svn path=/trunk/; revision=4965 --- filter/ChangeLog | 8 ++++++++ filter/filter-driver.c | 26 ++++++++++++++++++++++++-- filter/filter-driver.h | 3 ++- 3 files changed, 34 insertions(+), 3 deletions(-) (limited to 'filter') diff --git a/filter/ChangeLog b/filter/ChangeLog index 39ff8bf6f7..98816b6bbe 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,11 @@ +2000-08-18 Peter Williams + + * filter-driver.c (do_filter_mail): Unlink a new parameter, path_to_unlink, + if it is empty once the mail is filtered. Fixes a race in + mail_tool_filter_contents_into. + + * filter-driver.h: Update the prototype. + 2000-08-14 Ettore Perazzoli * vfolder-editor.c (rule_add): Add translation marks and use stock diff --git a/filter/filter-driver.c b/filter/filter-driver.c index e3e1c7df5e..5cedee6e85 100644 --- a/filter/filter-driver.c +++ b/filter/filter-driver.c @@ -48,6 +48,7 @@ typedef struct { gboolean self_destruct; gpointer unhook_func; gpointer unhook_data; + gchar *path_to_unlink; } filter_mail_input_t; /* mail-thread filter functions */ @@ -418,7 +419,8 @@ static const mail_operation_spec op_filter_mail = void filter_driver_run (FilterDriver *d, CamelFolder *source, CamelFolder *inbox, enum _filter_source_t sourcetype, - gboolean self_destruct, gpointer unhook_func, gpointer unhook_data) + gboolean self_destruct, gpointer unhook_func, gpointer unhook_data, + const char *path_to_unlink) { filter_mail_input_t *input; @@ -430,6 +432,7 @@ filter_driver_run (FilterDriver *d, CamelFolder *source, CamelFolder *inbox, input->self_destruct = self_destruct; input->unhook_func = unhook_func; input->unhook_data = unhook_data; + input->path_to_unlink = g_strdup (path_to_unlink); mail_operation_queue (&op_filter_mail, input, TRUE); } @@ -618,9 +621,25 @@ do_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex) close_folders (d); g_hash_table_destroy (p->folders); mail_tool_camel_lock_up (); - camel_folder_sync (p->source, TRUE, ex); + camel_folder_sync (source, TRUE, ex); + if (inbox != source) + camel_folder_sync (inbox, FALSE, ex); camel_folder_thaw (inbox); mail_tool_camel_lock_down (); + + if (input->path_to_unlink) { + struct stat sb; + + if (stat (input->path_to_unlink, &sb) < 0) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Couldn't stat(2) movemail folder %s"), + input->path_to_unlink); + return; + } + + if (sb.st_size == 0) + unlink (input->path_to_unlink); + } } static void @@ -631,6 +650,9 @@ cleanup_filter_mail (gpointer in_data, gpointer op_data, CamelException *ex) camel_object_unref (CAMEL_OBJECT (input->source)); camel_object_unref (CAMEL_OBJECT (input->inbox)); + if (input->path_to_unlink) + g_free (input->path_to_unlink); + if (input->self_destruct) gtk_object_unref (GTK_OBJECT (input->driver)); } diff --git a/filter/filter-driver.h b/filter/filter-driver.h index 1ef62b7118..984780b927 100644 --- a/filter/filter-driver.h +++ b/filter/filter-driver.h @@ -57,7 +57,8 @@ FilterDriver *filter_driver_new (FilterContext *ctx, FilterGetFolderFunc fe /* apply rules to a folder, unmatched messages goto inbox, if not NULL */ void filter_driver_run(FilterDriver *d, CamelFolder *source, CamelFolder *inbox, enum _filter_source_t sourcetype, - gboolean self_destruct, gpointer unhook_func, gpointer unhook_data); + gboolean self_destruct, gpointer unhook_func, gpointer unhook_data, + const char *path_to_unlink); #if 0 /* generate the search query/action string for a filter option */ -- cgit v1.2.3