[balsa/gtk3] More crypto fixes
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] More crypto fixes
- Date: Tue, 20 Dec 2011 16:59:08 +0000 (UTC)
commit b0710b5f4ff1dba04ca18605fe7fcf173d656b04
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue Dec 20 11:54:30 2011 -0500
More crypto fixes
* libbalsa/rfc3156.c: suppress GLib warning when the message is
only encrypted; return 'no error' for encrypted-only RFC 2440
messages; re-wrap a few over-long lines
* src/balsa-message.c: properly pick up return values from
libbalsa
* src/balsa-mime-widget-crypto.[hc]: changes needed for drawing
encrypted-only frame
* src/balsa-mime-widget-multipart.c: use new crypto frame api
* src/balsa-mime-widget.c: draw frame around encrypted-only rfc
2440 part
* src/print-gtk.c: encrypted-only frame print implementation
ChangeLog | 14 ++++++++++++++
libbalsa/rfc3156.c | 37 ++++++++++++++++++++++---------------
src/balsa-message.c | 4 ++--
src/balsa-mime-widget-crypto.c | 24 +++++++++++++++---------
src/balsa-mime-widget-crypto.h | 3 ++-
src/balsa-mime-widget-multipart.c | 2 +-
src/balsa-mime-widget.c | 6 +++++-
src/print-gtk.c | 20 ++++++++++++++------
8 files changed, 75 insertions(+), 35 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index aed6e6a..be4407e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-12-20 Albrecht DreÃ
+
+ * libbalsa/rfc3156.c: suppress GLib warning when the message is
+ only encrypted; return 'no error' for encrypted-only RFC 2440
+ messages; re-wrap a few over-long lines
+ * src/balsa-message.c: properly pick up return values from
+ libbalsa
+ * src/balsa-mime-widget-crypto.[hc]: changes needed for drawing
+ encrypted-only frame
+ * src/balsa-mime-widget-multipart.c: use new crypto frame api
+ * src/balsa-mime-widget.c: draw frame around encrypted-only rfc
+ 2440 part
+ * src/print-gtk.c: encrypted-only frame print implementation
+
2011-12-18 Peter Bloomfield
* src/main.c (balsa_check_open_mailboxes),
diff --git a/libbalsa/rfc3156.c b/libbalsa/rfc3156.c
index c11f64e..4ad400d 100644
--- a/libbalsa/rfc3156.c
+++ b/libbalsa/rfc3156.c
@@ -453,10 +453,14 @@ libbalsa_body_decrypt(LibBalsaMessageBody *body, gpgme_protocol_t protocol, GtkW
libbalsa_mailbox_lock_store(body->message->mailbox);
if (protocol == GPGME_PROTOCOL_OpenPGP)
- mime_obj = g_mime_gpgme_mpe_decrypt(GMIME_MULTIPART_ENCRYPTED(body->mime_part), &sig_state, parent, &error);
+ mime_obj =
+ g_mime_gpgme_mpe_decrypt(GMIME_MULTIPART_ENCRYPTED(body->mime_part),
+ &sig_state, parent, &error);
#ifdef HAVE_SMIME
else
- mime_obj = g_mime_application_pkcs7_decrypt_verify(GMIME_PART(body->mime_part), &sig_state, parent, &error);
+ mime_obj =
+ g_mime_application_pkcs7_decrypt_verify(GMIME_PART(body->mime_part),
+ &sig_state, parent, &error);
#endif
libbalsa_mailbox_unlock_store(body->message->mailbox);
@@ -486,10 +490,12 @@ libbalsa_body_decrypt(LibBalsaMessageBody *body, gpgme_protocol_t protocol, GtkW
#endif
libbalsa_message_body_set_mime_body(body, mime_obj);
- if (sig_state && sig_state->status != GPG_ERR_NOT_SIGNED)
- body->sig_info = sig_state;
- else
- g_object_unref(G_OBJECT(sig_state));
+ if (sig_state) {
+ if (sig_state->status != GPG_ERR_NOT_SIGNED)
+ body->sig_info = sig_state;
+ else
+ g_object_unref(G_OBJECT(sig_state));
+ }
return body;
}
@@ -498,7 +504,8 @@ libbalsa_body_decrypt(LibBalsaMessageBody *body, gpgme_protocol_t protocol, GtkW
/* routines dealing with RFC2440 */
gboolean
-libbalsa_rfc2440_sign_encrypt(GMimePart *part, const gchar *sign_for, GList *encrypt_for, gboolean always_trust,
+libbalsa_rfc2440_sign_encrypt(GMimePart *part, const gchar *sign_for,
+ GList *encrypt_for, gboolean always_trust,
GtkWindow *parent, GError **error)
{
GPtrArray *recipients;
@@ -523,7 +530,8 @@ libbalsa_rfc2440_sign_encrypt(GMimePart *part, const gchar *sign_for, GList *enc
recipients = NULL;
/* sign and/or encrypt */
- result = g_mime_part_rfc2440_sign_encrypt(part, sign_for, recipients, always_trust, parent, error);
+ result = g_mime_part_rfc2440_sign_encrypt(part, sign_for, recipients,
+ always_trust, parent, error);
/* clean up */
if (recipients)
g_ptr_array_free(recipients, FALSE);
@@ -609,8 +617,6 @@ libbalsa_rfc2440_decrypt(GMimePart * part, GMimeGpgmeSigstat ** sig_info,
if (gpg_updates_trustdb())
return GPG_ERR_TRY_AGAIN;
- // g_object_set_data(G_OBJECT(ctx), "parent-window", parent); FIXME - pass downstream
-
/* decrypt */
result = g_mime_part_rfc2440_decrypt(part, parent, &error);
if (result == NULL) {
@@ -627,12 +633,13 @@ libbalsa_rfc2440_decrypt(GMimePart * part, GMimeGpgmeSigstat ** sig_info,
("decryption and signature verification failed"));
retval = GPG_ERR_GENERAL;
}
- return retval;
- } else
- retval = result->status;
+ } else {
+ if (result->status == GPG_ERR_NOT_SIGNED)
+ retval = GPG_ERR_NO_ERROR;
+ else
+ retval = result->status;
- /* return the signature info if requested */
- if (result) {
+ /* return the signature info if requested */
if (sig_info && result->status != GPG_ERR_NOT_SIGNED)
*sig_info = result;
else
diff --git a/src/balsa-message.c b/src/balsa-message.c
index f6b34f4..98fd207 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -3035,7 +3035,7 @@ libbalsa_msg_part_2440(LibBalsaMessage * message, LibBalsaMessageBody * body,
}
libbalsa_mailbox_unlock_store(body->message->mailbox);
- if (sig_res == GPG_ERR_NO_ERROR) {
+ if (body->sig_info && sig_res == GPG_ERR_NO_ERROR) {
if (body->sig_info->validity >= GPGME_VALIDITY_MARGINAL &&
body->sig_info->key->owner_trust >= GPGME_VALIDITY_MARGINAL)
libbalsa_information(LIBBALSA_INFORMATION_DEBUG,
@@ -3045,7 +3045,7 @@ libbalsa_msg_part_2440(LibBalsaMessage * message, LibBalsaMessageBody * body,
(LIBBALSA_INFORMATION_MESSAGE,
_("Detected a good signature with insufficient "
"validity/trust"));
- } else if (sig_res != GPG_ERR_NOT_SIGNED && sig_res != GPG_ERR_CANCELED)
+ } else if (sig_res != GPG_ERR_NO_ERROR && sig_res != GPG_ERR_CANCELED)
libbalsa_information
(chk_crypto->chk_mode == LB_MAILBOX_CHK_CRYPT_ALWAYS ?
LIBBALSA_INFORMATION_ERROR : LIBBALSA_INFORMATION_MESSAGE,
diff --git a/src/balsa-mime-widget-crypto.c b/src/balsa-mime-widget-crypto.c
index b63a4d5..c776865 100644
--- a/src/balsa-mime-widget-crypto.c
+++ b/src/balsa-mime-widget-crypto.c
@@ -61,6 +61,10 @@ balsa_mime_widget_signature_widget(LibBalsaMessageBody * mime_body,
{
gchar *infostr;
GtkWidget *vbox, *label;
+
+ if (!mime_body->sig_info ||
+ mime_body->sig_info->status == GPG_ERR_NOT_SIGNED)
+ return NULL;
infostr =
libbalsa_signature_info_to_gchar(mime_body->sig_info,
@@ -110,12 +114,12 @@ balsa_mime_widget_signature_widget(LibBalsaMessageBody * mime_body,
GtkWidget *
balsa_mime_widget_crypto_frame(LibBalsaMessageBody * mime_body, GtkWidget * child,
- gboolean was_encrypted, GtkWidget * signature)
+ gboolean was_encrypted, gboolean no_signature,
+ GtkWidget * signature)
{
GtkWidget * frame;
GtkWidget * vbox;
GtkWidget * icon_box;
- const gchar * icon_name;
frame = gtk_frame_new(NULL);
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
@@ -125,13 +129,15 @@ balsa_mime_widget_crypto_frame(LibBalsaMessageBody * mime_body, GtkWidget * chil
gtk_box_pack_start(GTK_BOX(icon_box),
gtk_image_new_from_stock(BALSA_PIXMAP_ENCR, GTK_ICON_SIZE_MENU),
FALSE, FALSE, 0);
- icon_name =
- balsa_mime_widget_signature_icon_name(libbalsa_message_body_protect_state(mime_body));
- if (!icon_name)
- icon_name = BALSA_PIXMAP_SIGN;
- gtk_box_pack_start(GTK_BOX(icon_box),
- gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_MENU),
- FALSE, FALSE, 0);
+ if (!no_signature) {
+ const gchar * icon_name =
+ balsa_mime_widget_signature_icon_name(libbalsa_message_body_protect_state(mime_body));
+ if (!icon_name)
+ icon_name = BALSA_PIXMAP_SIGN;
+ gtk_box_pack_start(GTK_BOX(icon_box),
+ gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_MENU),
+ FALSE, FALSE, 0);
+ }
gtk_frame_set_label_widget(GTK_FRAME(frame), icon_box);
gtk_container_set_border_width(GTK_CONTAINER(vbox), BMW_MESSAGE_PADDING);
diff --git a/src/balsa-mime-widget-crypto.h b/src/balsa-mime-widget-crypto.h
index 7fc1a51..e8c403e 100644
--- a/src/balsa-mime-widget-crypto.h
+++ b/src/balsa-mime-widget-crypto.h
@@ -43,7 +43,8 @@ BalsaMimeWidget *balsa_mime_widget_new_signature(BalsaMessage * bm,
GtkWidget * balsa_mime_widget_signature_widget(LibBalsaMessageBody * mime_body,
const gchar * content_type);
GtkWidget * balsa_mime_widget_crypto_frame(LibBalsaMessageBody * mime_body, GtkWidget * child,
- gboolean was_encrypted, GtkWidget * signature);
+ gboolean was_encrypted, gboolean no_signature,
+ GtkWidget * signature);
const gchar *balsa_mime_widget_signature_icon_name(LibBalsaMsgProtectState protect_state);
diff --git a/src/balsa-mime-widget-multipart.c b/src/balsa-mime-widget-multipart.c
index 3d65aa4..b0cf007 100644
--- a/src/balsa-mime-widget-multipart.c
+++ b/src/balsa-mime-widget-multipart.c
@@ -49,7 +49,7 @@ balsa_mime_widget_new_multipart(BalsaMessage * bm,
mime_body->parts->next->sig_info)
mw->widget =
balsa_mime_widget_crypto_frame(mime_body->parts->next, mw->widget,
- mime_body->was_encrypted, NULL);
+ mime_body->was_encrypted, FALSE, NULL);
#endif
return mw;
diff --git a/src/balsa-mime-widget.c b/src/balsa-mime-widget.c
index e29f352..647aafc 100644
--- a/src/balsa-mime-widget.c
+++ b/src/balsa-mime-widget.c
@@ -173,7 +173,11 @@ balsa_mime_widget_new(BalsaMessage * bm, LibBalsaMessageBody * mime_body, gpoint
balsa_mime_widget_signature_widget(mime_body, content_type);
mw->widget = balsa_mime_widget_crypto_frame(mime_body, mw->widget,
mime_body->was_encrypted,
- signature);
+ FALSE, signature);
+ } else if (mime_body->was_encrypted &&
+ g_ascii_strcasecmp("multipart/signed", content_type)) {
+ mw->widget = balsa_mime_widget_crypto_frame(mime_body, mw->widget,
+ TRUE, TRUE, NULL);
}
#endif
g_object_ref_sink(mw->widget);
diff --git a/src/print-gtk.c b/src/print-gtk.c
index 4945290..8d5d064 100644
--- a/src/print-gtk.c
+++ b/src/print-gtk.c
@@ -122,7 +122,7 @@ scan_body(GList *bpo_list, GtkPrintContext * context, BalsaPrintSetup * psetup,
{
#ifdef HAVE_GPGME
gboolean add_signature;
- gboolean is_multipart_signed;
+ gboolean have_crypto_frame;
#endif /* HAVE_GPGME */
while (body) {
@@ -137,7 +137,7 @@ scan_body(GList *bpo_list, GtkPrintContext * context, BalsaPrintSetup * psetup,
if (!g_ascii_strcasecmp("multipart/signed", conttype) &&
body->parts && body->parts->next
&& body->parts->next->sig_info) {
- is_multipart_signed = TRUE;
+ have_crypto_frame = TRUE;
bpo_list = balsa_print_object_separator(bpo_list, psetup);
no_first_sep = TRUE;
if (body->was_encrypted)
@@ -148,15 +148,22 @@ scan_body(GList *bpo_list, GtkPrintContext * context, BalsaPrintSetup * psetup,
bpo_list = balsa_print_object_frame_begin(bpo_list,
_("Signed matter"),
psetup);
+ } else if (!add_signature && body->was_encrypted) {
+ have_crypto_frame = TRUE;
+ bpo_list = balsa_print_object_separator(bpo_list, psetup);
+ no_first_sep = TRUE;
+ bpo_list = balsa_print_object_frame_begin(bpo_list,
+ _("Encrypted matter"),
+ psetup);
} else
- is_multipart_signed = FALSE;
+ have_crypto_frame = FALSE;
#endif /* HAVE_GPGME */
if (g_ascii_strncasecmp(conttype, "multipart/", 10)) {
if (no_first_sep)
no_first_sep = FALSE;
else
- bpo_list = balsa_print_object_separator(bpo_list, psetup);
+ bpo_list = balsa_print_object_separator(bpo_list, psetup);
#ifdef HAVE_GPGME
if (add_signature) {
if (body->was_encrypted)
@@ -178,10 +185,10 @@ scan_body(GList *bpo_list, GtkPrintContext * context, BalsaPrintSetup * psetup,
no_first_sep = FALSE;
}
- /* end the frame for an embedded message */
+ /* end the frame for an embedded message or encrypted stuff */
if (!g_ascii_strcasecmp(conttype, "message/rfc822")
#ifdef HAVE_GPGME
- || is_multipart_signed
+ || have_crypto_frame
#endif
)
bpo_list = balsa_print_object_frame_end(bpo_list, psetup);
@@ -192,6 +199,7 @@ scan_body(GList *bpo_list, GtkPrintContext * context, BalsaPrintSetup * psetup,
g_strdup_printf(_("This is an inline %s signed %s message part:"),
body->sig_info->protocol == GPGME_PROTOCOL_OpenPGP ?
_("OpenPGP") : _("S/MIME"), conttype);
+ bpo_list = balsa_print_object_separator(bpo_list, psetup);
bpo_list = balsa_print_object_header_crypto(bpo_list, context, body, header, psetup);
g_free(header);
bpo_list = balsa_print_object_frame_end(bpo_list, psetup);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]