[evolution/webkit: 30/123] Display information about signature and encryption.



commit 4a39a2dce79048bbe9e46776beee40fa70408f98
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Sep 22 12:38:21 2011 +0200

    Display information about signature and encryption.
    
    Details about GPG/SMIME signature or encryption of message or
    it's part are now displayed the way they are supposed to be.

 em-format/em-format.c         |   44 +++++++++++++++++++++++++-----
 mail/em-format-html-display.c |   59 ++++++++++++++++++++++------------------
 mail/em-format-html.c         |    4 +-
 3 files changed, 71 insertions(+), 36 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index f5d0059..a0438eb 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -224,6 +224,12 @@ emf_parse_application_xpkcs7mime (EMFormat *emf,
 		g_string_append (part_id, ".encrypted");
 		em_format_parse_part (emf, opart, part_id, &encinfo, cancellable);
 		g_string_truncate (part_id, len);
+
+		/* Add a widget with details about the encryption */
+		g_string_append (part_id, ".encrypted.button");
+		em_format_parse_part_as (emf, part, part_id, &encinfo,
+			"x-evolution/message/x-secure-button", cancellable);
+		g_string_truncate (part_id, len);
 	}
 
 	g_object_unref (opart);
@@ -506,6 +512,12 @@ emf_parse_multipart_encrypted (EMFormat *emf,
 		g_string_append (part_id, ".encrypted");
 		em_format_parse_part (emf, opart, part_id, &encinfo, cancellable);
 		g_string_truncate (part_id, len);
+
+		/* Add a widget with details about the encryption */
+		g_string_append (part_id, ".encrypted.button");
+		em_format_parse_part_as (emf, part, part_id, &encinfo,
+			"x-evolution/message/x-secure-button", cancellable);
+		g_string_truncate (part_id, len);
 	}
 
 	/* TODO: Make sure when we finalize this part, it is zero'd out */
@@ -622,22 +634,28 @@ emf_parse_multipart_signed (EMFormat *emf,
 			g_clear_error (&local_error);
 			emf_parse_multipart_mixed (emf, part, part_id,info,  cancellable);
 		} else {
+			EMFormatParserInfo signinfo = {
+					info->handler,
+					validity_type | EM_FORMAT_VALIDITY_FOUND_SIGNED,
+					camel_cipher_validity_clone (valid)
+			};
+
 			gint i, nparts, len = part_id->len;
 			nparts = camel_multipart_get_number (CAMEL_MULTIPART (mps));
 			for (i = 0; i < nparts; i++) {
 				CamelMimePart *subpart;
-				EMFormatParserInfo signinfo = {
-						info->handler,
-						validity_type | EM_FORMAT_VALIDITY_FOUND_SIGNED,
-						camel_cipher_validity_clone (valid)
-				};
-
 				subpart = camel_multipart_get_part (CAMEL_MULTIPART (mps), i);
 
 				g_string_append_printf(part_id, ".signed.%d", i);
 				em_format_parse_part (emf, subpart, part_id, &signinfo, cancellable);
 				g_string_truncate (part_id, len);
 			}
+
+			/* Add a widget with details about the encryption */
+			g_string_append (part_id, ".signed.button");
+			em_format_parse_part_as (emf, part, part_id, &signinfo,
+			"x-evolution/message/x-secure-button", cancellable);
+			g_string_truncate (part_id, len);
 		}
 	}
 
@@ -861,13 +879,19 @@ emf_parse_inlinepgp_signed (EMFormat *emf,
 
 	/* Pass it off to the real formatter */
 	len = part_id->len;
-	g_string_append (part_id, "inlinepgp_signed");
+	g_string_append (part_id, ".inlinepgp_signed");
 	signinfo.handler = info->handler;
 	signinfo.validity_type = EM_FORMAT_VALIDITY_FOUND_SIGNED | EM_FORMAT_VALIDITY_FOUND_PGP;
 	signinfo.validity = camel_cipher_validity_clone (valid);
 	em_format_parse_part (emf, opart, part_id, &signinfo, cancellable);
 	g_string_truncate (part_id, len);
 
+	/* Add a widget with details about the encryption */
+	g_string_append (part_id, ".inlinepgp_signed.button");
+	em_format_parse_part_as (emf, opart, part_id, &signinfo,
+		"x-evolution/message/x-secure-button", cancellable);
+	g_string_truncate (part_id, len);
+
 	/* Clean Up */
 	g_object_unref (dw);
 	g_object_unref (opart);
@@ -943,6 +967,12 @@ emf_parse_inlinepgp_encrypted (EMFormat *emf,
 	em_format_parse_part (emf, opart, part_id, &encinfo, cancellable);
 	g_string_truncate (part_id, len);
 
+	/* Add a widget with details about the encryption */
+	g_string_append (part_id, ".inlinepgp_encrypted.button");
+	em_format_parse_part_as (emf, opart, part_id, &encinfo,
+		"x-evolution/message/x-secure-button", cancellable);
+	g_string_truncate (part_id, len);
+
 	/* Clean Up */
 	g_object_unref (opart);
 	g_object_unref (cipher);
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 0753fb3..d4e27cb 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -104,6 +104,7 @@ static const gchar *smime_sign_colour[5] = {
 static void efhd_message_prefix 	(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
 static void efhd_message_add_bar	(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
 static void efhd_parse_attachment	(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
+static void efhd_parse_secure		(EMFormat *emf, CamelMimePart *part, GString *part_id, EMFormatParserInfo *info, GCancellable *cancellable);
 
 static GtkWidget* efhd_attachment_bar		(EMFormat *emf, EMFormatPURI *puri, GCancellable *cancellable);
 static GtkWidget* efhd_attachment_button	(EMFormat *emf, EMFormatPURI *puri, GCancellable *cancellable);
@@ -317,7 +318,7 @@ efhd_xpkcs7mime_button (EMFormat *emf,
                         EMFormatPURI *puri,
                         GCancellable *cancellable)
 {
-	GtkWidget *widget;
+	GtkWidget *box, *button, *widget;
 	EMFormatSMIMEPURI *po = (EMFormatSMIMEPURI *) puri;
 	const gchar *icon_name;
 
@@ -327,17 +328,24 @@ efhd_xpkcs7mime_button (EMFormat *emf,
 	else
 		icon_name = smime_encrypt_table[po->valid->encrypt.status].icon;
 
-	widget = gtk_button_new ();
+	box = gtk_hbox_new (FALSE, 5);
+
+	button = gtk_button_new ();
+	gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
 	g_signal_connect (
-		widget, "clicked",
+		button, "clicked",
 		G_CALLBACK (efhd_xpkcs7mime_validity_clicked), puri);
-	gtk_widget_show (widget);
 
 	widget = gtk_image_new_from_icon_name (
-		icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR);
-	gtk_widget_show (widget);
+			icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR);
+	gtk_button_set_image (GTK_BUTTON (button), widget);
 
-	return widget;
+	widget = gtk_label_new (po->description);
+	gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
+
+	gtk_widget_show_all (box);
+
+	return box;
 }
 
 static void
@@ -464,43 +472,40 @@ efhd_format_optional (EMFormat *emf,
 }
 
 static void
-efhd_format_secure (EMFormat *emf,
-		    EMFormatPURI *puri,
-		    GCancellable *cancellable)
+efhd_parse_secure (EMFormat *emf,
+		   CamelMimePart *part,
+		   GString *part_id,
+		   EMFormatParserInfo *info,
+		   GCancellable *cancellable)
 {
-	EMFormatClass *format_class;
-
-	format_class = g_type_class_peek (EM_TYPE_FORMAT);
-	format_class->format_secure (emf, puri, cancellable);
-
-	if (puri->validity
-	    && (puri->validity->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE
-		|| puri->validity->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) {
+	if (info->validity
+	    && (info->validity->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE
+		|| info->validity->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) {
 		GString *buffer;
 		EMFormatSMIMEPURI *pobj;
 
 		pobj = (EMFormatSMIMEPURI *) em_format_puri_new (
-				emf, sizeof (EMFormatSMIMEPURI), puri->part, puri->uri);
+				emf, sizeof (EMFormatSMIMEPURI), part, part_id->str);
 		pobj->puri.free = efhd_xpkcs7mime_free;
-		pobj->valid = camel_cipher_validity_clone (puri->validity);
+		pobj->valid = camel_cipher_validity_clone (info->validity);
 		pobj->puri.widget_func = efhd_xpkcs7mime_button;
 
 		em_format_add_puri (emf, (EMFormatPURI*) pobj);
 
 		buffer = g_string_new ("");
 
-		if (puri->validity->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) {
+		if (info->validity->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) {
 			gchar *signers;
 			const gchar *desc;
 			gint status;
 
-			status = puri->validity->sign.status;
+			status = info->validity->sign.status;
 			desc = smime_sign_table[status].shortdesc;
 
 			g_string_append (buffer, gettext (desc));
 
 			signers = em_format_html_format_cert_infos (
-				(CamelCipherCertInfo *) puri->validity->sign.signers.head);
+				(CamelCipherCertInfo *) info->validity->sign.signers.head);
 			if (signers && *signers) {
 				g_string_append_printf (
 					buffer, " (%s)", signers);
@@ -508,14 +513,14 @@ efhd_format_secure (EMFormat *emf,
 			g_free (signers);
 		}
 
-		if (puri->validity->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) {
+		if (info->validity->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) {
 			const gchar *desc;
 			gint status;
 
-			if (puri->validity->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)
+			if (info->validity->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)
 				g_string_append (buffer, "\n");
 
-			status = puri->validity->encrypt.status;
+			status = info->validity->encrypt.status;
 			desc = smime_encrypt_table[status].shortdesc;
 			g_string_append (buffer, gettext (desc));
 		}
@@ -714,7 +719,6 @@ efhd_class_init (EMFormatHTMLDisplayClass *class)
 	format_class->format_attachment = efhd_format_attachment;
 */
 	format_class->format_optional = efhd_format_optional;
-	format_class->format_secure = efhd_format_secure;
 
 	format_html_class = EM_FORMAT_HTML_CLASS (class);
 	format_html_class->html_widget_type = E_TYPE_MAIL_DISPLAY;
@@ -802,6 +806,7 @@ static EMFormatHandler type_builtin_table[] = {
 	{ (gchar *) "x-evolution/message/prefix", efhd_message_prefix, },
 	{ (gchar *) "x-evolution/message/attachment-bar", (EMFormatParseFunc) efhd_message_add_bar, },
 	{ (gchar *) "x-evolution/message/attachment", efhd_parse_attachment, },
+	{ (gchar *) "x-evolution/message/x-secure-button", efhd_parse_secure, },
 };
 
 static void
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 2009f53..561a5cb 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -1684,9 +1684,9 @@ em_format_html_format_cert_infos (CamelCipherCertInfo *first_cinfo)
 			append (cinfo->name);
 
 			if (cinfo->email && *cinfo->email) {
-				append (" &lt;");
+				append (" <");
 				append (cinfo->email);
-				append ("&gt;");
+				append (">");
 			}
 		} else if (cinfo->email && *cinfo->email) {
 			append (cinfo->email);



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