aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-11-25 06:35:33 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-11-25 06:35:33 +0800
commit2f99f8636abd7efc68bfa5de1591c594e9f532eb (patch)
tree37ad675b94242355b46e3b5f87ba116b3793a43a
parenta25373060b564e28d09c14248126b0b60f679c26 (diff)
downloadgsoc2013-evolution-2f99f8636abd7efc68bfa5de1591c594e9f532eb.tar
gsoc2013-evolution-2f99f8636abd7efc68bfa5de1591c594e9f532eb.tar.gz
gsoc2013-evolution-2f99f8636abd7efc68bfa5de1591c594e9f532eb.tar.bz2
gsoc2013-evolution-2f99f8636abd7efc68bfa5de1591c594e9f532eb.tar.lz
gsoc2013-evolution-2f99f8636abd7efc68bfa5de1591c594e9f532eb.tar.xz
gsoc2013-evolution-2f99f8636abd7efc68bfa5de1591c594e9f532eb.tar.zst
gsoc2013-evolution-2f99f8636abd7efc68bfa5de1591c594e9f532eb.zip
set session on print formatter for signatures to work.
2003-11-25 Not Zed <NotZed@Ximian.com> * em-folder-view.c (em_folder_view_print): set session on print formatter for signatures to work. * em-message-browser.c (emmb_destroy): kill warning. * em-format-html.c (efh_output_secure): same as efhd_output_secure, output the security bar, but for printing/plain html. (efh_application_xpkcs7mime): use output_secure. (em_format_html_multipart_signed_sign): removed, output_secure does what this did. * em-format-html-display.c (smime_sign_table, smime_encrypt_table): Added a short description for the mail display. (efhd_xpkcs7mime_button): only good/bad signature at this point, if only encrypted, then display 'bad' icon. (efhd_output_secure): output the security bar/button and handle multi-level enveloping properly. (efhd_application_xpkcs7mime): just call output_secure to do the security bar. (efhd_multipart_signed): same. (efhd_signature_button): removed, no longer used. (efhd_signature_check): removed, no longer used. svn path=/trunk/; revision=23483
-rw-r--r--mail/ChangeLog27
-rw-r--r--mail/em-folder-view.c1
-rw-r--r--mail/em-format-html-display.c197
-rw-r--r--mail/em-format-html.c243
-rw-r--r--mail/em-format-html.h6
-rw-r--r--mail/em-format.c2
-rw-r--r--mail/em-message-browser.c2
7 files changed, 218 insertions, 260 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 4bae234613..ba60d0ccd7 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,30 @@
+2003-11-25 Not Zed <NotZed@Ximian.com>
+
+ * em-folder-view.c (em_folder_view_print): set session on print
+ formatter for signatures to work.
+
+ * em-message-browser.c (emmb_destroy): kill warning.
+
+ * em-format-html.c (efh_output_secure): same as
+ efhd_output_secure, output the security bar, but for
+ printing/plain html.
+ (efh_application_xpkcs7mime): use output_secure.
+ (em_format_html_multipart_signed_sign): removed, output_secure
+ does what this did.
+
+ * em-format-html-display.c (smime_sign_table,
+ smime_encrypt_table): Added a short description for the mail
+ display.
+ (efhd_xpkcs7mime_button): only good/bad signature at this point,
+ if only encrypted, then display 'bad' icon.
+ (efhd_output_secure): output the security bar/button and handle
+ multi-level enveloping properly.
+ (efhd_application_xpkcs7mime): just call output_secure to do
+ the security bar.
+ (efhd_multipart_signed): same.
+ (efhd_signature_button): removed, no longer used.
+ (efhd_signature_check): removed, no longer used.
+
2003-11-24 Radek Doulik <rodo@ximian.com>
* em-format-html.c (efh_text_plain): use new colors
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index ffece26fac..602993e8f9 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -1597,6 +1597,7 @@ int em_folder_view_print(EMFolderView *emfv, int preview)
}
print = em_format_html_print_new();
+ em_format_set_session((EMFormat *)print, ((EMFormat *)emfv->preview)->session);
res = em_format_html_print_print(print, msg, (EMFormatHTML *)emfv->preview, config, preview);
g_object_unref(print);
if (config)
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index ec606ec5d7..07fe4869b4 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -589,22 +589,24 @@ efhd_complete(EMFormat *emf)
/* ********************************************************************** */
+/* TODO: rename some of this stuff, it isn't 'smime' specific */
+/* FIXME: also in em-format-html.c */
static const struct {
- const char *icon, *description;
+ const char *icon, *shortdesc, *description;
} smime_sign_table[4] = {
- { NULL, N_("This message is not signed. There is no guarantee the sender of the message is authentic.") },
- { "pgp-signature-ok.png", N_("This message is signed and is valid, the sender of this message is very likely who they claim to be.") },
- { "pgp-signature-bad.png", N_("The signature of this message cannot be verified, it may have been altered in transit.") },
- { "pgp-signature-nokey.png", N_("This message is signed with a valid signature, but the sender of the message cannot be verified.") },
+ { NULL, N_("Unsigned"), N_("This message is not signed. There is no guarantee the sender of the message is authentic.") },
+ { "pgp-signature-ok.png",N_("Valid signature"), N_("This message is signed and is valid, the sender of this message is very likely who they claim to be.") },
+ { "pgp-signature-bad.png", N_("Invalid signature"), N_("The signature of this message cannot be verified, it may have been altered in transit.") },
+ { "pgp-signature-nokey.png", N_("Valid signature, cannot verify sender"), N_("This message is signed with a valid signature, but the sender of the message cannot be verified.") },
};
static const struct {
- const char *icon, *description;
+ const char *icon, *shortdesc, *description;
} smime_encrypt_table[4] = {
- { NULL, N_("This message is not encrypted. It's content may be viewed in transit across The Internet.") },
- { "pgp-signature-ok.png", N_("This message is encrypted, but with a weak encryption algorithm. It would be difficult, but not impossible for an outsider to view the content of this message in a practical amount of time.") },
- { "pgp-signature-ok.png", N_("This message is encrypted. It would be difficult for an outsider to view the content of this message.") },
- { "pgp-signature-ok.png", N_("This message is encrypted, with a strong encryption algorithm. It would be very difficult for an outsider to view the content of this message in a practical amount of time.") },
+ { NULL, N_("Unencrypted"), N_("This message is not encrypted. It's content may be viewed in transit across The Internet.") },
+ { "pgp-signature-ok.png", N_("Encrypted, weak"), N_("This message is encrypted, but with a weak encryption algorithm. It would be difficult, but not impossible for an outsider to view the content of this message in a practical amount of time.") },
+ { "pgp-signature-ok.png", N_("Encrypted"), N_("This message is encrypted. It would be difficult for an outsider to view the content of this message.") },
+ { "pgp-signature-ok.png", N_("Encrypted, strong"), N_("This message is encrypted, with a strong encryption algorithm. It would be very difficult for an outsider to view the content of this message in a practical amount of time.") },
};
struct _smime_pobject {
@@ -683,10 +685,11 @@ efhd_xpkcs7mime_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
char *file;
const char *name;
- if (po->signature)
- name = smime_sign_table[po->valid->sign.status].icon;
+ /* FIXME: need to have it based on encryption and signing too */
+ if (po->valid->sign.status == CAMEL_CIPHER_VALIDITY_SIGN_GOOD)
+ name = "pgp-signature-ok.png";
else
- name = smime_encrypt_table[po->valid->encrypt.status].icon;
+ name = "pgp-signature-bad.png";
file = g_build_filename(EVOLUTION_ICONSDIR, name, NULL);
pixbuf = gdk_pixbuf_new_from_file(file, NULL);
@@ -710,6 +713,50 @@ efhd_xpkcs7mime_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
}
static void
+efhd_output_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid)
+{
+ CamelCipherValidity *save = ((EMFormatHTML *)emf)->valid_parent;
+
+ /* Note: this same logic is in efh_output_secure */
+
+ if (((EMFormatHTML *)emf)->valid == NULL) {
+ ((EMFormatHTML *)emf)->valid = valid;
+ } else {
+ e_dlist_addtail(&((EMFormatHTML *)emf)->valid_parent->children, (EDListNode *)valid);
+ camel_cipher_validity_envelope(((EMFormatHTML *)emf)->valid_parent, valid);
+ }
+
+ ((EMFormatHTML *)emf)->valid_parent = valid;
+ em_format_part(emf, stream, part);
+ ((EMFormatHTML *)emf)->valid_parent = save;
+
+ if (((EMFormatHTML *)emf)->valid == valid
+ && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE
+ || valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) {
+ char *classid;
+ struct _smime_pobject *pobj;
+
+ camel_stream_printf(stream, "<table border=0 width=\"100%%\" cellpadding=3 cellspacing=0 bgcolor=%s><tr>",
+ valid->sign.status == CAMEL_CIPHER_VALIDITY_SIGN_GOOD?"#88bb88":"#bb8888");
+ classid = g_strdup_printf("smime:///em-format-html/%p/icon/signed", part);
+ pobj = (struct _smime_pobject *)em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(*pobj), classid, part, efhd_xpkcs7mime_button);
+ pobj->valid = camel_cipher_validity_clone(valid);
+ pobj->object.free = efhd_xpkcs7mime_free;
+ camel_stream_printf(stream, "<td valign=top><object classid=\"%s\"></object></td><td width=100%% valign=top>", classid);
+
+ if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) {
+ camel_stream_printf(stream, "%s<br>", _(smime_sign_table[valid->sign.status].shortdesc));
+ }
+
+ if (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) {
+ camel_stream_printf(stream, "%s<br>", _(smime_encrypt_table[valid->encrypt.status].shortdesc));
+ }
+
+ camel_stream_printf(stream, "</td></tr></table>");
+ }
+}
+
+static void
efhd_application_xpkcs7mime(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
{
CamelCipherContext *context;
@@ -728,46 +775,7 @@ efhd_application_xpkcs7mime(EMFormat *emf, CamelStream *stream, CamelMimePart *p
em_format_format_error(emf, stream, ex->desc?ex->desc:_("Could not parse S/MIME message: Unknown error"));
em_format_part_as(emf, stream, part, NULL);
} else {
- CamelCipherValidity *save = ((EMFormatHTML *)emf)->enveloped_validity;
-
- if (save != NULL)
- camel_cipher_validity_envelope(valid, save);
-
- ((EMFormatHTML *)emf)->enveloped_validity = valid;
- em_format_part(emf, stream, opart);
- ((EMFormatHTML *)emf)->enveloped_validity = save;
-
- if (save != NULL
- && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE
- || valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) {
- char *classid;
- struct _smime_pobject *pobj;
-
- camel_stream_printf(stream, "<table border=1 width=\"100%%\" cellpadding=3 cellspacing=0><tr>");
-
- if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) {
- classid = g_strdup_printf("smime:///em-format-html/%p/icon/signed", part);
- pobj = (struct _smime_pobject *)em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(*pobj), classid, part, efhd_xpkcs7mime_button);
- pobj->valid = camel_cipher_validity_clone(valid);
- pobj->signature = TRUE;
- pobj->object.free = efhd_xpkcs7mime_free;
- camel_stream_printf(stream, "<td valign=top><object classid=\"%s\"></object><br>%s</td>", classid, valid->sign.description);
- g_free(classid);
- }
-
- if (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) {
- classid = g_strdup_printf("smime:///em-format-html/%p/icon/encrypted", part);
- pobj = (struct _smime_pobject *)em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(*pobj), classid, part, efhd_xpkcs7mime_button);
- pobj->valid = camel_cipher_validity_clone(valid);
- pobj->object.free = efhd_xpkcs7mime_free;
- camel_stream_printf(stream, "<td valign=top><object classid=\"%s\"></object><br>%s</td>", classid, valid->encrypt.description);
- g_free(classid);
- }
-
- camel_stream_printf(stream, "</tr></table>");
- }
-
- camel_cipher_validity_free(valid);
+ efhd_output_secure(emf, stream, opart, valid);
}
camel_object_unref(opart);
@@ -778,47 +786,11 @@ efhd_application_xpkcs7mime(EMFormat *emf, CamelStream *stream, CamelMimePart *p
/* ********************************************************************** */
static void
-efhd_signature_check(GtkWidget *w, EMFormatHTMLPObject *pobject)
-{
- d(printf("insert signature check here ... redraw ? or what ?\n"));
- /* blah, do the old way for now, force a complete re-draw */
- em_format_set_inline((EMFormat *)pobject->format, pobject->part, TRUE);
- em_format_format_clone((EMFormat *)pobject->format, ((EMFormat *)pobject->format)->message, (EMFormat *)pobject->format);
-}
-
-static gboolean
-efhd_signature_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject)
-{
- GtkWidget *icon, *button;
- GdkPixbuf *pixbuf;
-
- pixbuf = gdk_pixbuf_new_from_file(EVOLUTION_ICONSDIR "/pgp-signature-nokey.png", NULL);
- if (pixbuf == NULL)
- return FALSE;
-
- /* wtf isn't this just scaled on disk? */
- icon = gtk_image_new_from_pixbuf(gdk_pixbuf_scale_simple(pixbuf, 24, 24, GDK_INTERP_BILINEAR));
- g_object_unref(pixbuf);
- gtk_widget_show(icon);
-
- button = gtk_button_new();
- g_signal_connect(button, "clicked", G_CALLBACK (efhd_signature_check), pobject);
- /*g_signal_connect (button, "key_press_event", G_CALLBACK (inline_button_press), part);*/
-
- gtk_container_add((GtkContainer *)button, icon);
- gtk_widget_show(button);
- gtk_container_add((GtkContainer *)eb, button);
-
- return TRUE;
-}
-
-static void
efhd_multipart_signed (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
{
- char *classid;
- static int signedid;
CamelMultipartSigned *mps;
CamelMimePart *cpart;
+ CamelCipherContext *cipher = NULL;
mps = (CamelMultipartSigned *)camel_medium_get_content_object((CamelMedium *)part);
if (!CAMEL_IS_MULTIPART_SIGNED(mps)
@@ -827,31 +799,30 @@ efhd_multipart_signed (EMFormat *emf, CamelStream *stream, CamelMimePart *part,
return;
}
- em_format_part(emf, stream, cpart);
+ /* FIXME: Should be done via a plugin interface */
+ /* FIXME: duplicated in em-format-html.c */
+ if (g_ascii_strcasecmp("application/x-pkcs7-signature", mps->protocol) == 0)
+ cipher = camel_smime_context_new(emf->session);
+ else if (g_ascii_strcasecmp("application/pgp-signature", mps->protocol) == 0)
+ cipher = camel_gpg_context_new(emf->session);
- if (em_format_is_inline(emf, part)) {
- em_format_html_multipart_signed_sign(emf, stream, part);
+ if (cipher == NULL) {
+ em_format_format_error(emf, stream, _("Unsupported signature format"));
+ em_format_part_as(emf, stream, part, NULL);
} else {
- classid = g_strdup_printf("multipart-signed:///icon/%d", signedid++);
-
- /* wtf is this so fugly? */
- camel_stream_printf(stream,
- "<br><table cellspacing=0 cellpadding=0>"
- "<tr><td><table width=10 cellspacing=0 cellpadding=0>"
- "<tr><td></td></tr></table></td>"
- "<td><object classid=\"%s\"></object></td>"
- "<td><table width=3 cellspacing=0 cellpadding=0>"
- "<tr><td></td></tr></table></td>"
- "<td><font size=-1>%s</font></td></tr>"
- "<tr><td height=10>"
- "<table cellspacing=0 cellpadding=0><tr>"
- "<td height=10><a name=\"glue\"></td></tr>"
- "</table></td></tr></table>\n",
- classid,
- _("This message is digitally signed. Click the lock icon for more information."));
-
- em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_signature_button);
- g_free(classid);
+ CamelException *ex = camel_exception_new();
+ CamelCipherValidity *valid;
+
+ valid = camel_cipher_verify(cipher, part, ex);
+ if (valid == NULL) {
+ em_format_format_error(emf, stream, ex->desc?ex->desc:_("Unknown error verifying signature"));
+ em_format_part_as(emf, stream, part, NULL);
+ } else {
+ efhd_output_secure(emf, stream, cpart, valid);
+ }
+
+ camel_exception_free(ex);
+ camel_object_unref(cipher);
}
}
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index e1ef6be129..f3b9b46c5a 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -176,6 +176,7 @@ efh_finalise(GObject *o)
/* FIXME: check for leaked stuff */
em_format_html_clear_pobject(efh);
+ camel_cipher_validity_free(efh->valid);
efh_gtkhtml_destroy(efh->html, efh);
@@ -556,24 +557,75 @@ efh_object_requested(GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTML *efh)
#include "em-inline-filter.h"
#include <camel/camel-stream-null.h>
+/* FIXME: This is duplicated in em-format-html-display, should be exported or in security module */
static const struct {
- const char *icon;
+ const char *icon, *shortdesc;
} smime_sign_table[4] = {
- { NULL },
- { "pgp-signature-ok.png" },
- { "pgp-signature-bad.png" },
- { "pgp-signature-nokey.png" },
+ { "pgp-signature-nokey.png", N_("Unsigned") },
+ { "pgp-signature-ok.png", N_("Valid signature") },
+ { "pgp-signature-bad.png", N_("Invalid signature") },
+ { "pgp-signature-nokey.png", N_("Valid signature, cannot verify sender") },
};
static const struct {
- const char *icon;
+ const char *icon, *shortdesc;
} smime_encrypt_table[4] = {
- { NULL },
- { "pgp-signature-ok.png" },
- { "pgp-signature-ok.png" },
- { "pgp-signature-ok.png" },
+ { NULL, N_("Unencrypted") },
+ { "pgp-signature-ok.png", N_("Encrypted, weak"),},
+ { "pgp-signature-ok.png", N_("Encrypted") },
+ { "pgp-signature-ok.png", N_("Encrypted, strong") },
};
+/* TODO: this could probably be virtual on em-format-html
+ then we only need one version of each type handler */
+static void
+efh_output_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid)
+{
+ CamelCipherValidity *save = ((EMFormatHTML *)emf)->valid_parent;
+
+ /* Note: this same logic is in efhd_output_secure */
+ if (((EMFormatHTML *)emf)->valid == NULL) {
+ ((EMFormatHTML *)emf)->valid = valid;
+ } else {
+ e_dlist_addtail(&((EMFormatHTML *)emf)->valid_parent->children, (EDListNode *)valid);
+ camel_cipher_validity_envelope(((EMFormatHTML *)emf)->valid_parent, valid);
+ }
+
+ ((EMFormatHTML *)emf)->valid_parent = valid;
+ em_format_part(emf, stream, part);
+ ((EMFormatHTML *)emf)->valid_parent = save;
+
+ if (((EMFormatHTML *)emf)->valid == valid
+ && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE
+ || valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) {
+ char *classid;
+ CamelMimePart *iconpart;
+
+ camel_stream_printf(stream, "<table border=0 width=\"100%%\" cellpadding=3 cellspacing=0 bgcolor=%s><tr>",
+ valid->sign.status == CAMEL_CIPHER_VALIDITY_SIGN_GOOD?"#88bb88":"#bb8888");
+
+ classid = g_strdup_printf("smime:///em-format-html/%p/icon/signed", part);
+ camel_stream_printf(stream, "<td valign=\"top\"><img src=\"%s\"></td><td valign=\"top\" width=\"100%%\">", classid);
+ iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png",
+ EVOLUTION_ICONSDIR, smime_sign_table[valid->sign.status].icon);
+ if (iconpart) {
+ (void)em_format_add_puri(emf, sizeof(EMFormatPURI), classid, iconpart, efh_write_image);
+ camel_object_unref(iconpart);
+ }
+ g_free(classid);
+
+ if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) {
+ camel_stream_printf(stream, "%s<br>", _(smime_sign_table[valid->sign.status].shortdesc));
+ }
+
+ if (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) {
+ camel_stream_printf(stream, "%s<br>", _(smime_encrypt_table[valid->encrypt.status].shortdesc));
+ }
+
+ camel_stream_printf(stream, "</td></tr></table>");
+ }
+}
+
static void
efh_application_xpkcs7mime(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
{
@@ -593,54 +645,7 @@ efh_application_xpkcs7mime(EMFormat *emf, CamelStream *stream, CamelMimePart *pa
em_format_format_error(emf, stream, ex->desc?ex->desc:_("Could not parse S/MIME message: Unknown error"));
em_format_part_as(emf, stream, part, NULL);
} else {
- CamelCipherValidity *save = ((EMFormatHTML *)emf)->enveloped_validity;
-
- if (save != NULL)
- camel_cipher_validity_envelope(valid, save);
-
- ((EMFormatHTML *)emf)->enveloped_validity = valid;
- em_format_part(emf, stream, opart);
- ((EMFormatHTML *)emf)->enveloped_validity = save;
-
- if (save != NULL
- && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE
- || valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) {
- char *classid;
- CamelMimePart *iconpart;
- EMFormatPURI *iconpuri;
-
- camel_stream_printf(stream, "<table border=1 width=\"100%%\" cellpadding=3 cellspacing=0><tr>");
-
- if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) {
- classid = g_strdup_printf("smime:///em-format-html/%p/icon/signed", part);
- iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png",
- EVOLUTION_ICONSDIR, smime_sign_table[valid->sign.status].icon);
- if (iconpart) {
- iconpuri = em_format_add_puri(emf, sizeof(*iconpuri), classid, iconpart, efh_write_image);
- camel_object_unref(iconpart);
- }
-
- camel_stream_printf(stream, "<td valign=top><img src=\"%s\"><br>%s</td>", classid, valid->sign.description);
- g_free(classid);
- }
-
- if (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) {
- classid = g_strdup_printf("smime:///em-format-html/%p/icon/encrypted", part);
- iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png",
- EVOLUTION_ICONSDIR, smime_encrypt_table[valid->encrypt.status].icon);
- if (iconpart) {
- iconpuri = em_format_add_puri(emf, sizeof(*iconpuri), classid, iconpart, efh_write_image);
- camel_object_unref(iconpart);
- }
-
- camel_stream_printf(stream, "<td valign=top><img src=\"%s\"><br>%s</td>", classid, valid->encrypt.description);
- g_free(classid);
- }
-
- camel_stream_printf(stream, "</tr></table>");
- }
-
- camel_cipher_validity_free(valid);
+ efh_output_secure(emf, stream, opart, valid);
}
camel_object_unref(opart);
@@ -1011,89 +1016,12 @@ efh_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, c
}
}
-static const struct {
- const char *icon;
- const char *text;
-} signed_table[2] = {
- { "pgp-signature-bad.png", N_("This message is digitally signed but can not be proven to be authentic.") },
- { "pgp-signature-ok.png", N_("This message is digitally signed and has been found to be authentic.") }
-};
-
-void
-em_format_html_multipart_signed_sign(EMFormat *emf, CamelStream *stream, CamelMimePart *part)
-{
- CamelMultipartSigned *mps;
- CamelCipherValidity *valid = NULL;
- CamelException ex;
- const char *message = NULL;
- int good = 0;
- char *classid;
- EMFormatPURI *iconpuri;
- CamelMimePart *iconpart;
- static int iconid;
-
- mps = (CamelMultipartSigned *)camel_medium_get_content_object((CamelMedium *)part);
-
- /* FIXME: This sequence is also copied in em-format.c */
-
- camel_exception_init(&ex);
- if (emf->session == NULL) {
- message = _("Session not initialised");
- } else {
- CamelCipherContext *cipher = NULL;
-
- /* FIXME: Should be done via a plugin interface */
- if (g_ascii_strcasecmp("application/x-pkcs7-signature", mps->protocol) == 0)
- cipher = camel_smime_context_new(emf->session);
- else if (g_ascii_strcasecmp("application/pgp-signature", mps->protocol) == 0)
- cipher = camel_gpg_context_new(emf->session);
-
- if (cipher == NULL) {
- message = _("Unsupported signature format");
- } else {
- valid = camel_cipher_verify(cipher, part, &ex);
- camel_object_unref(cipher);
- if (valid) {
- good = camel_cipher_validity_get_valid(valid)?1:0;
- message = camel_cipher_validity_get_description(valid);
- } else {
- message = camel_exception_get_description(&ex);
- }
- }
- }
-
- classid = g_strdup_printf("multipart-signed:///em-format-html/%p/icon/%d", part, iconid++);
- iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png", EVOLUTION_ICONSDIR, signed_table[good].icon);
- if (iconpart) {
- iconpuri = em_format_add_puri(emf, sizeof(*iconpuri), classid, iconpart, efh_write_image);
- camel_object_unref(iconpart);
- }
-
- camel_stream_printf(stream, "<table><tr valign=top>"
- "<td><img src=\"%s\"></td>"
- "<td>%s<br><br>",
- classid,
- _(signed_table[good].text));
- g_free(classid);
-
- if (message) {
- char *tmp = camel_text_to_html(message, ((EMFormatHTML *)emf)->text_html_flags, 0);
-
- camel_stream_printf(stream, "<font size=-1%s>%s</font>", good?"":" color=red", tmp);
- g_free(tmp);
- }
-
- camel_stream_write_string(stream, "</td></tr></table>");
-
- camel_exception_clear(&ex);
- camel_cipher_validity_free(valid);
-}
-
static void
efh_multipart_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
{
CamelMimePart *cpart;
CamelMultipartSigned *mps;
+ CamelCipherContext *cipher = NULL;
mps = (CamelMultipartSigned *)camel_medium_get_content_object((CamelMedium *)part);
if (!CAMEL_IS_MULTIPART_SIGNED(mps)
@@ -1103,8 +1031,31 @@ efh_multipart_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *part, co
return;
}
- em_format_part(emf, stream, cpart);
- em_format_html_multipart_signed_sign(emf, stream, part);
+ /* FIXME: Should be done via a plugin interface */
+ /* FIXME: duplicated in em-format-html-display.c */
+ if (g_ascii_strcasecmp("application/x-pkcs7-signature", mps->protocol) == 0)
+ cipher = camel_smime_context_new(emf->session);
+ else if (g_ascii_strcasecmp("application/pgp-signature", mps->protocol) == 0)
+ cipher = camel_gpg_context_new(emf->session);
+
+ if (cipher == NULL) {
+ em_format_format_error(emf, stream, _("Unsupported signature format"));
+ em_format_part_as(emf, stream, part, NULL);
+ } else {
+ CamelException *ex = camel_exception_new();
+ CamelCipherValidity *valid;
+
+ valid = camel_cipher_verify(cipher, part, ex);
+ if (valid == NULL) {
+ em_format_format_error(emf, stream, ex->desc?ex->desc:_("Unknown error verifying signature"));
+ em_format_part_as(emf, stream, part, NULL);
+ } else {
+ efh_output_secure(emf, stream, cpart, valid);
+ }
+
+ camel_exception_free(ex);
+ camel_object_unref(cipher);
+ }
}
static void
@@ -1316,6 +1267,12 @@ efh_format_timeout(struct _format_msg *m)
efh_parent->format_clone((EMFormat *)efh, m->message, m->format_source);
em_format_html_clear_pobject(m->format);
+ if (efh->valid) {
+ camel_cipher_validity_free(efh->valid);
+ efh->valid = NULL;
+ efh->valid_parent = NULL;
+ }
+
if (m->message == NULL) {
hstream = gtk_html_begin(efh->html);
gtk_html_stream_close(hstream, GTK_HTML_STREAM_OK);
@@ -1591,9 +1548,10 @@ em_format_html_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMediu
static void efh_format_message(EMFormat *emf, CamelStream *stream, CamelMedium *part)
{
#define efh ((EMFormatHTML *)emf)
- CamelCipherValidity *save = efh->enveloped_validity;
+ CamelCipherValidity *save = efh->valid, *save_parent = efh->valid_parent;
- efh->enveloped_validity = NULL;
+ efh->valid = NULL;
+ efh->valid_parent = NULL;
if (emf->message != part)
camel_stream_printf(stream, "<blockquote>\n");
@@ -1607,7 +1565,10 @@ static void efh_format_message(EMFormat *emf, CamelStream *stream, CamelMedium *
if (emf->message != part)
camel_stream_printf(stream, "</blockquote>\n");
- efh->enveloped_validity = save;
+ camel_cipher_validity_free(efh->valid);
+
+ efh->valid = save;
+ efh->valid_parent = save_parent;
#undef efh
}
diff --git a/mail/em-format-html.h b/mail/em-format-html.h
index 5e48c8c671..4a981cd792 100644
--- a/mail/em-format-html.h
+++ b/mail/em-format-html.h
@@ -106,7 +106,8 @@ struct _EMFormatHTML {
EDList pending_object_list;
- struct _CamelCipherValidity *enveloped_validity;
+ struct _CamelCipherValidity *valid;
+ struct _CamelCipherValidity *valid_parent;
GSList *headers;
@@ -154,7 +155,4 @@ EMFormatHTMLJob *em_format_html_job_new(EMFormatHTML *emfh, void (*callback)(str
;
void em_format_html_job_queue(EMFormatHTML *emfh, struct _EMFormatHTMLJob *job);
-/* outputs a signature test */
-void em_format_html_multipart_signed_sign(EMFormat *emf, struct _CamelStream *stream, struct _CamelMimePart *part);
-
#endif /* ! EM_FORMAT_HTML_H */
diff --git a/mail/em-format.c b/mail/em-format.c
index 208b4b79b0..63c1b3936f 100644
--- a/mail/em-format.c
+++ b/mail/em-format.c
@@ -52,7 +52,7 @@
#include "em-format.h"
-#define d(x)
+#define d(x) x
static void emf_builtin_init(EMFormatClass *);
static const char *emf_snoop_part(CamelMimePart *part);
diff --git a/mail/em-message-browser.c b/mail/em-message-browser.c
index f7eb7ecd49..5621fe07bf 100644
--- a/mail/em-message-browser.c
+++ b/mail/em-message-browser.c
@@ -94,7 +94,7 @@ emmb_destroy(GtkObject *o)
EMMessageBrowser *emmb = (EMMessageBrowser *)o;
if (emmb->view.list) {
- gtk_widget_destroy(emmb->view.list);
+ gtk_widget_destroy((GtkWidget *)emmb->view.list);
emmb->view.list = NULL;
}