From de5890b84b581099ab27937f9dd592f4658efdc0 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 17 Jul 2001 19:51:41 +0000 Subject: Cleaned up a bit. (handle_multipart_encrypted): Replace the encrypted part 2001-07-17 Jeffrey Stedfast * mail-format.c (mail_part_toggle_displayed): Cleaned up a bit. (handle_multipart_encrypted): Replace the encrypted part with the decrypted part. svn path=/trunk/; revision=11166 --- mail/mail-format.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'mail/mail-format.c') diff --git a/mail/mail-format.c b/mail/mail-format.c index cfe68fb559..b5d28eafca 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -561,23 +561,22 @@ void mail_part_toggle_displayed (CamelMimePart *part, MailDisplay *md) { GHashTable *asht = g_datalist_get_data (md->data, "attachment_states"); + gpointer ostate, opart; gint state; - state = GPOINTER_TO_INT (g_hash_table_lookup (asht, part)); - - if (state & I_DISPLAYED) { - /*printf ("** part %p, hiding\n", part);*/ - state &= ~I_DISPLAYED; + if (g_hash_table_lookup_extended (asht, part, &opart, &ostate)) { + g_hash_table_remove (asht, part); + + state = GPOINTER_TO_INT (ostate); + + if (state & I_DISPLAYED) + state &= ~I_DISPLAYED; + else + state |= I_DISPLAYED; } else { - if (state == 0) { - /*printf ("** part %p: uninitialized attachment state! Showing.", part);*/ - state |= I_VALID; - } - - printf ("** part %p, showing\n", part); - state |= I_DISPLAYED; + state = I_VALID | I_DISPLAYED; } - + g_hash_table_insert (asht, part, GINT_TO_POINTER (state)); } @@ -1658,12 +1657,14 @@ handle_multipart_encrypted (CamelMimePart *part, const char *mime_type, camel_exception_clear (&ex); return handle_multipart_mixed (part, mime_type, md); } else { - gboolean retcode; - - retcode = format_mime_part (mime_part, md); + /* replace the encrypted part with the decrypted part */ + /* FIXME: will this cause problems anywhere? -- seems to work okay so far */ + camel_medium_set_content_object (CAMEL_MEDIUM (part), + camel_medium_get_content_object (CAMEL_MEDIUM (mime_part))); camel_object_unref (CAMEL_OBJECT (mime_part)); - return retcode; + /* and continue on our merry way... */ + return format_mime_part (part, md); } } -- cgit