Re: [evolution-patches] fix for bug #46512 (mailer doesn't force messages out of Outbox)



new patch

On Thu, 2003-08-14 at 15:10, Dan Winship wrote:
> On Thu, 2003-08-14 at 15:01, Jeffrey Stedfast wrote:
> > *sigh* got sidetracked and forgot the whole point of this patch which
> > was to append to local Sent if appending to remote Sent failed.
> 
> Should probably explain that to the user when it happens.
> 
> It would also be nice if the other errors mentioned when they occurred
> ("while running outgoing filters", "while appending to Sent folder",
> etc)
> 
> -- Dan
> _______________________________________________
> Evolution-patches mailing list
> Evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
? 42630.patch
? 45523.patch
? PLAN
? crash.txt
? mail-actions.h
? mb.patch
? message-tree.c
? message-tree.h
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.2789
diff -u -r1.2789 ChangeLog
--- ChangeLog	14 Aug 2003 21:06:59 -0000	1.2789
+++ ChangeLog	14 Aug 2003 21:07:12 -0000
@@ -1,3 +1,12 @@
+2003-08-14  Jeffrey Stedfast  <fejj ximian com>
+
+	* mail-ops.c (mail_send_message): Don't abort at the first failure
+	after sending (filtering, appending to Sent, syncing). Instead,
+	keep a running tab of exceptions and then set a culmulative
+	exception at the end to report to our caller. Also, if we fail to
+	append to the account Sent folder, try again with the local Sent
+	folder. Fixes bug #46512.
+
 2003-08-13  Suresh Chandrasekharan <suresh chandrasekharan sun com>
 	
 	* e-searching-tokenizer.c (searcher_next_token): Fix for 45818 (
Index: mail-ops.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-ops.c,v
retrieving revision 1.394
diff -u -r1.394 mail-ops.c
--- mail-ops.c	11 Aug 2003 18:07:44 -0000	1.394
+++ mail-ops.c	14 Aug 2003 21:07:12 -0000
@@ -459,7 +459,8 @@
 	char *transport_url = NULL;
 	char *sent_folder_uri = NULL;
 	const char *resent_from;
-	CamelFolder *folder;
+	CamelFolder *folder = NULL;
+	GString *err = NULL;
 	XEvolution *xev;
 	int i;
 	
@@ -538,52 +539,75 @@
 	info = camel_message_info_new ();
 	info->flags = CAMEL_MESSAGE_SEEN;
 	
+	if (sent_folder_uri) {
+		folder = mail_tool_uri_to_folder (sent_folder_uri, 0, ex);
+		camel_exception_clear (ex);
+		g_free (sent_folder_uri);
+	}
+	
+	if (!folder) {
+		camel_object_ref (sent_folder);
+		folder = sent_folder;
+	}
+	
 	if (driver) {
 		camel_filter_driver_filter_message (driver, message, info,
 						    NULL, NULL, NULL, "", ex);
 		
 		if (camel_exception_is_set (ex)) {
-			ExceptionId id;
-			
-			id = camel_exception_get_id (ex);
-			camel_exception_setv (ex, id, "%s\n%s", camel_exception_get_description (ex),
-					      _("However, the message was successfully sent."));
-			
-			camel_message_info_free (info);
-			g_free (sent_folder_uri);
+			if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL)
+				goto exit;
 			
-			return;
+			/* save this error */
+			err = g_string_new ("");
+			g_string_append_printf (err, _("Failed to apply outgoing filters: %s"),
+						camel_exception_get_description (ex));
 		}
 	}
 	
-	if (sent_folder_uri) {
-		folder = mail_tool_uri_to_folder (sent_folder_uri, 0, NULL);
-		g_free (sent_folder_uri);
-		if (!folder) {
-			/* FIXME */
+ retry_append:
+	camel_exception_clear (ex);
+	camel_folder_append_message (folder, message, info, NULL, ex);
+	if (camel_exception_is_set (ex)) {
+		if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL)
+			goto exit;
+		
+		if (err == NULL)
+			err = g_string_new ("");
+		else
+			g_string_append (err, "\n\n");
+		
+		if (folder != sent_folder) {
+			const char *name;
+			
+			camel_object_get (folder, NULL, CAMEL_OBJECT_DESCRIPTION, (char **) &name, 0);
+			g_string_append_printf (err, _("Failed to append to %s: %s\n"
+						"Appending to local `Sent' folder instead."),
+						name, camel_exception_get_description (ex));
 			camel_object_ref (sent_folder);
+			camel_object_unref (folder);
 			folder = sent_folder;
+			
+			goto retry_append;
+		} else {
+			g_string_append_printf (err, _("Failed to append to local `Sent' folder: %s"),
+						camel_exception_get_description (ex));
 		}
-	} else {
-		camel_object_ref (sent_folder);
-		folder = sent_folder;
 	}
 	
-	if (folder) {
-		camel_folder_append_message (folder, message, info, NULL, ex);
-		if (camel_exception_is_set (ex)) {
-			ExceptionId id;
-			
-			id = camel_exception_get_id (ex);
-			camel_exception_setv (ex, id, "%s\n%s", camel_exception_get_description (ex),
-					      _("However, the message was successfully sent."));
-		}
-		
-		camel_folder_sync (folder, FALSE, NULL);
-		camel_object_unref (folder);
+	if (err != NULL) {
+		/* set the culmulative exception report */
+		camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, err->str);
 	}
+		
+ exit:
 	
+	camel_folder_sync (folder, FALSE, NULL);
 	camel_message_info_free (info);
+	camel_object_unref (folder);
+	
+	if (err != NULL)
+		g_string_free (err, TRUE);
 }
 
 /* ********************************************************************** */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]