[evolution/webkit: 71/177] EMFormat accept and correctly handle null CamelFolder



commit a44db25145b2b524491718ef2f7940fc070f49e7
Author: Dan VrÃtil <dvratil redhat com>
Date:   Wed Nov 30 18:40:37 2011 +0100

    EMFormat accept and correctly handle null CamelFolder

 em-format/.em-format-quote.c.kate-swp |  Bin 0 -> 94 bytes
 em-format/em-format.c                 |   25 +++++++++++++------------
 mail/e-mail-printer.c                 |   10 ++++++----
 mail/em-composer-utils.c              |   14 +-------------
 mail/em-format-html-print.c           |    3 ++-
 5 files changed, 22 insertions(+), 30 deletions(-)
---
diff --git a/em-format/.em-format-quote.c.kate-swp b/em-format/.em-format-quote.c.kate-swp
new file mode 100644
index 0000000..a76e4c6
Binary files /dev/null and b/em-format/.em-format-quote.c.kate-swp differ
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 8a67c41..0765165 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -1188,9 +1188,6 @@ emf_parse (EMFormat *emf,
 		emf->folder = g_object_ref (folder);
 	}
 
-	g_return_if_fail (emf->message);
-	g_return_if_fail (emf->folder);
-
 	part_id = g_string_new (".message");
 
 	/* Create a special PURI with entire message */
@@ -1250,7 +1247,7 @@ static EMFormatHandler type_handlers[] = {
 		{ (gchar *) "multipart/mixed", emf_parse_multipart_mixed, },
 		{ (gchar *) "multipart/signed", emf_parse_multipart_signed, },
 		{ (gchar *) "multipart/related", emf_parse_multipart_related, },
-		{ (gchar *) "multipart/digest", emf_parse_multipart_digest, EM_FORMAT_HANDLER_COMPOUND_TYPE },
+		{ (gchar *) "multipart/digest", emf_parse_multipart_digest, 0, EM_FORMAT_HANDLER_COMPOUND_TYPE },
 		{ (gchar *) "multipart/*", emf_parse_multipart_mixed, 0, EM_FORMAT_HANDLER_COMPOUND_TYPE },
 
 		/* Ignore PGP signature part */
@@ -1896,7 +1893,6 @@ em_format_parse (EMFormat *emf,
 
 	g_return_if_fail (EM_IS_FORMAT (emf));
 	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
-	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
 	class = EM_FORMAT_GET_CLASS (emf);
 	g_return_if_fail (class->parse != NULL);
@@ -2348,21 +2344,26 @@ em_format_build_mail_uri (CamelFolder *folder,
 	gchar *uri, *tmp;
 	va_list ap;
 	const gchar *name;
-        const gchar *service_uid;
+        const gchar *service_uid, *folder_name;
 	char separator;
 
-	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 	g_return_val_if_fail (message_uid && *message_uid, NULL);
 
-	store = camel_folder_get_parent_store (folder);
-        if (store)
-                service_uid = camel_service_get_uid (CAMEL_SERVICE (store));
-        else
+        if (!folder) {
+                folder_name = "generic";
                 service_uid = "generic";
+        } else {
+                folder_name = camel_folder_get_full_name (folder);
+	        store = camel_folder_get_parent_store (folder);
+                if (store)
+                        service_uid = camel_service_get_uid (CAMEL_SERVICE (store));
+                else
+                        service_uid = "generic";
+        }
 
 	tmp = g_strdup_printf ("mail://%s/%s/%s",
 			service_uid,
-			camel_folder_get_full_name (folder),
+			folder_name,
 			message_uid);
 
 	va_start (ap, first_param_name);
diff --git a/mail/e-mail-printer.c b/mail/e-mail-printer.c
index b732fa3..e53bf41 100644
--- a/mail/e-mail-printer.c
+++ b/mail/e-mail-printer.c
@@ -723,10 +723,12 @@ e_mail_printer_print (EMailPrinter *emp,
                 G_CALLBACK (emp_headers_tab_apply), emp);
 	g_signal_connect (emp->priv->operation, "done",
 		G_CALLBACK (emp_printing_done), emp);
-	g_signal_connect_swapped (cancellable, "cancelled",
-		G_CALLBACK (gtk_print_operation_cancel), emp->priv->operation);
-	g_signal_connect (emp->priv->operation, "draw-page",
-		G_CALLBACK (emp_draw_footer), NULL);
+        g_signal_connect (emp->priv->operation, "draw-page",
+                G_CALLBACK (emp_draw_footer), NULL);
+
+        if (cancellable)
+                g_signal_connect_swapped (cancellable, "cancelled",
+		        G_CALLBACK (gtk_print_operation_cancel), emp->priv->operation);
 
 	emp_run_print_operation (emp);
 }
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 7b903ee..ee4fcde 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -935,12 +935,8 @@ composer_print_done_cb (EMailPrinter *emp,
                         gpointer user_data)
 {
         EMFormat *emf = user_data;
-
-        g_object_unref (emf->folder);
         g_object_unref (emf);
-
         g_object_unref (emp);
-       
 }
 
 static void
@@ -952,20 +948,12 @@ em_utils_composer_print_cb (EMsgComposer *composer,
 {
         EMailPrinter *emp;
         EMFormatHTMLDisplay *efhd;
-        CamelFolder *folder;
-
-        /* Create a virtual temporary camel folder */
-        /* FIXME WEBKIT This throws a warning about null parent-store. 
-         * Find a better way. */
-        folder = g_object_new (CAMEL_TYPE_OFFLINE_FOLDER, 
-                        "full-name", "composer",
-                        "parent-store", NULL, NULL);
 
         efhd = g_object_new (EM_TYPE_FORMAT_HTML_DISPLAY, NULL);
         ((EMFormat *) efhd)->message_uid = g_strdup (camel_mime_message_get_message_id (message));
 
         /* Parse the message */
-        em_format_parse ((EMFormat *) efhd, message, folder, NULL);
+        em_format_parse ((EMFormat *) efhd, message, NULL, NULL);
 
         /* Use EMailPrinter and WebKit to print the message */
         emp = e_mail_printer_new ((EMFormatHTML *) efhd, action);
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index 41f81d0..520326d 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -408,7 +408,8 @@ efhp_set_orig_formatter (EMFormatHTMLPrint *efhp,
 	while (g_hash_table_iter_next (&iter, &key, &value))
 		g_hash_table_insert (emfp->mail_part_table, key, value);
 
-	emfp->folder = g_object_ref (emfs->folder);
+        if (emfs->folder)
+	        emfp->folder = g_object_ref (emfs->folder);
 	emfp->message_uid = g_strdup (emfs->message_uid);
 	emfp->message = g_object_ref (emfs->message);
 



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