From 1ecabb0dc4b97d18725d4bbbeb66fb0f4465ece1 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Thu, 10 Aug 2000 18:46:39 +0000 Subject: Fix the infinite movemail svn path=/trunk/; revision=4696 --- mail/ChangeLog | 6 ++++++ mail/mail-callbacks.c | 2 +- mail/mail-ops.c | 1 + mail/mail-tools.c | 30 +++++++++++++++++++++++++++++- mail/mail-tools.h | 13 +++++++------ 5 files changed, 44 insertions(+), 8 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 0b40c4553f..e2d38a2a1c 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,9 @@ +2000-08-10 Peter Williams + + * mail-tools.c (mail_tool_filter_contents_into): Delete the source + folder if told to and if it's empty + (mail_tool_get_local_movemail_path): New function. + 2000-08-10 Dan Winship * mail-callbacks.c (reply_to_all): Fix a bug in the async changes. diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index b12f148062..fb0a0d5c5c 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -184,7 +184,7 @@ composer_send_cb (EMsgComposer *composer, gpointer data) ciaddr = camel_internet_address_new (); camel_internet_address_add (ciaddr, id->name, id->address); from = camel_address_encode (CAMEL_ADDRESS (ciaddr)); - camel_object_unref (ciaddr); + camel_object_unref (CAMEL_OBJECT (ciaddr)); } /* Get the message */ diff --git a/mail/mail-ops.c b/mail/mail-ops.c index d235c6b2d9..bd080d7f01 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -117,6 +117,7 @@ do_fetch_mail (gpointer in_data, gpointer op_data, CamelException * ex) } mail_tool_filter_contents_into (search_folder, input->destination, + TRUE, input->hook_func, input->hook_data, ex); camel_object_unref (CAMEL_OBJECT (search_folder)); diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 8091b55fd3..10e70a6a6f 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -123,6 +123,12 @@ mail_tool_get_local_inbox_url (void) return g_strdup_printf ("mbox://%s/local/Inbox", evolution_dir); } +gchar * +mail_tool_get_local_movemail_path (void) +{ + return g_strdup_printf ("%s/local/Inbox/movemail", evolution_dir); +} + CamelFolder * mail_tool_get_local_inbox (CamelException *ex) { @@ -158,7 +164,7 @@ mail_tool_do_movemail (const gchar *source_url, CamelException *ex) /* Set up our destination. */ dest_url = mail_tool_get_local_inbox_url(); - dest_path = g_strdup_printf ("%s/local/Inbox/movemail", evolution_dir); + dest_path = mail_tool_get_local_movemail_path(); /* Create a new movemail mailbox file of 0 size */ @@ -461,6 +467,7 @@ static CamelFolder *get_folder_func (FilterDriver *d, const char *uri, void *dat void mail_tool_filter_contents_into (CamelFolder *source, CamelFolder *dest, + gboolean delete_source, gpointer hook_func, gpointer hook_data, CamelException *ex) { @@ -483,6 +490,27 @@ mail_tool_filter_contents_into (CamelFolder *source, CamelFolder *dest, hook_func, hook_data); filter_driver_run (filter, source, dest, TRUE, hook_func, hook_data); + + camel_folder_sync (CAMEL_FOLDER (source), TRUE, ex); + camel_folder_sync (CAMEL_FOLDER (dest), TRUE, ex); + + if (delete_source) { + gchar *path = mail_tool_get_local_movemail_path(); + struct stat sb; + + if (stat (path, &sb) < 0) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + "Couldn't stat movemail folder %s", + path); + g_free (path); + return; + } + + if (sb.st_size == 0) + unlink (path); + + g_free (path); + } } CamelFolder * diff --git a/mail/mail-tools.h b/mail/mail-tools.h index 6d189c2ea5..03b2af8a9f 100644 --- a/mail/mail-tools.h +++ b/mail/mail-tools.h @@ -36,16 +36,16 @@ CamelFolder * mail_tool_get_folder_from_urlname (const gchar *url, const gchar *name, CamelException *ex); /* Get the url for the local inbox */ -gchar * -mail_tool_get_local_inbox_url (void); +gchar *mail_tool_get_local_inbox_url (void); + +/* Get the filename for our movemail folder */ +gchar *mail_tool_get_local_movemail_path (void); /* Get the CamelFolder for the local inbox */ -CamelFolder * -mail_tool_get_local_inbox (CamelException *ex); +CamelFolder *mail_tool_get_local_inbox (CamelException *ex); /* Get the "inbox" for a url (uses global session) */ -CamelFolder * -mail_tool_get_inbox (const gchar *url, CamelException *ex); +CamelFolder *mail_tool_get_inbox (const gchar *url, CamelException *ex); /* Does a camel_movemail into the local movemail folder * and returns the movemail folder that was created. */ @@ -81,6 +81,7 @@ mail_tool_fetch_mail_into_searchable (const char *source_url, gboolean keep_on_s /* Filter source into dest using the default filters. */ void mail_tool_filter_contents_into (CamelFolder *source, CamelFolder *dest, + gboolean delete_source, gpointer hook_func, gpointer hook_data, CamelException *ex); -- cgit v1.2.3