[balsa] Handle text/rfc822-headers parts (Albrecht Dre ß)
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Handle text/rfc822-headers parts (Albrecht Dre ß)
- Date: Sun, 1 Mar 2015 20:55:12 +0000 (UTC)
commit f284745537176d58bbf6a368980d468d619caf0a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Mar 1 15:53:59 2015 -0500
Handle text/rfc822-headers parts (Albrecht Dreß)
* libbalsa/body.[hc]: parse text/rfc822-headers parts,
and store them in the body structure
* src/balsa-mime-widget.c, src/balsa-mime-widget-message.c:
display a text/rfc822-headers part
* src/balsa-print-object.c: print a text/rfc822-headers part
ChangeLog | 10 ++++++++++
libbalsa/body.c | 38 ++++++++++++++++++++++++++++++++++++++
libbalsa/body.h | 2 +-
src/balsa-mime-widget-message.c | 11 +++++++++++
src/balsa-mime-widget.c | 3 ++-
src/balsa-print-object.c | 13 ++++++++++++-
6 files changed, 74 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 289469a..27ca1bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2015-03-01 Albrecht Dreß
+ Display and print text/rfc822-headers parts
+
+ * libbalsa/body.[hc]: parse text/rfc822-headers parts,
+ and store them in the body structure
+ * src/balsa-mime-widget.c, src/balsa-mime-widget-message.c:
+ display a text/rfc822-headers part
+ * src/balsa-print-object.c: print a text/rfc822-headers part
+
+2015-03-01 Albrecht Dreß
+
* libbalsa/send.c (libbalsa_set_message_id): obfuscate the
message-id header.
diff --git a/libbalsa/body.c b/libbalsa/body.c
index 06164bc..af4e2fe 100644
--- a/libbalsa/body.c
+++ b/libbalsa/body.c
@@ -214,6 +214,35 @@ libbalsa_message_body_set_multipart(LibBalsaMessageBody * body,
}
static void
+libbalsa_message_body_set_text_rfc822headers(LibBalsaMessageBody *body)
+{
+ GMimeStream *headers;
+ GError *err = NULL;
+
+ libbalsa_mailbox_lock_store(body->message->mailbox);
+ headers = libbalsa_message_body_get_stream(body, &err);
+ if (err != NULL) {
+ g_error_free(err);
+ }
+
+ if (headers != NULL) {
+ GMimeMessage *dummy_msg;
+ GMimeParser *parser;
+
+ g_mime_stream_reset(headers);
+ parser = g_mime_parser_new_with_stream(headers);
+ g_object_unref(headers);
+ dummy_msg = g_mime_parser_construct_message(parser);
+ g_object_unref(parser);
+
+ body->embhdrs = libbalsa_message_body_extract_embedded_headers(dummy_msg);
+ g_object_unref(dummy_msg);
+ }
+
+ libbalsa_mailbox_unlock_store(body->message->mailbox);
+}
+
+static void
libbalsa_message_body_set_parts(LibBalsaMessageBody * body)
{
LibBalsaMessageBody **next_part = &body->parts;
@@ -222,6 +251,15 @@ libbalsa_message_body_set_parts(LibBalsaMessageBody * body)
next_part = libbalsa_message_body_set_message_part(body, next_part);
else if (GMIME_IS_MULTIPART(body->mime_part))
next_part = libbalsa_message_body_set_multipart(body, next_part);
+ else {
+ gchar *mime_type;
+
+ mime_type = libbalsa_message_body_get_mime_type(body);
+ if (strcmp(mime_type, "text/rfc822-headers") == 0) {
+ libbalsa_message_body_set_text_rfc822headers(body);
+ }
+ g_free(mime_type);
+ }
/* Free any parts that weren't used; the test isn't strictly
* necessary, but it should fail unless something really strange has
diff --git a/libbalsa/body.h b/libbalsa/body.h
index d04e745..7821dff 100644
--- a/libbalsa/body.h
+++ b/libbalsa/body.h
@@ -69,7 +69,7 @@ struct _LibBalsaMessageBody {
gchar *buffer; /* holds raw data of the MIME part, or NULL */
gchar *html_buffer; /* holds the html representation of the part or NULL */
ssize_t buflen; /* size of the block */
- LibBalsaMessageHeaders *embhdrs; /* headers of a message/rfc822 part */
+ LibBalsaMessageHeaders *embhdrs; /* headers of a message/rfc822 or text/rfc822-headers part */
LibBalsaMessageBodyType body_type;
gchar *content_type; /* value of the Content-Type header of
* the body including mime type with
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index cb68d43..af4a9ae 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -133,6 +133,17 @@ balsa_mime_widget_new_message(BalsaMessage * bm,
gtk_box_pack_start(GTK_BOX(mw->container), emb_hdrs, FALSE, FALSE, 0);
balsa_mime_widget_message_set_headers(bm, mw, mime_body);
+ } else if (!g_ascii_strcasecmp("text/rfc822-headers", content_type)) {
+ GtkWidget *alignment;
+
+ mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
+ mw->widget = gtk_frame_new(_("message headers"));
+ alignment = gtk_alignment_new(1.0, 0.0, 1.0, 0.0);
+ gtk_container_add(GTK_CONTAINER(mw->widget), alignment);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 5, 5, 5, 5);
+ mw->header_widget = bm_header_widget_new(bm, NULL);
+ gtk_container_add(GTK_CONTAINER(alignment), mw->header_widget);
+ balsa_mime_widget_message_set_headers(bm, mw, mime_body);
}
/* return the created widget (may be NULL) */
diff --git a/src/balsa-mime-widget.c b/src/balsa-mime-widget.c
index 38ded89..f7f6ecd 100644
--- a/src/balsa-mime-widget.c
+++ b/src/balsa-mime-widget.c
@@ -115,6 +115,7 @@ static mime_delegate_t mime_delegate[] =
{ {FALSE, "message/delivery-status", balsa_mime_widget_new_text},
{TRUE, "message/", balsa_mime_widget_new_message},
{FALSE, "text/calendar", balsa_mime_widget_new_vcalendar},
+ {FALSE, "text/rfc822-headers", balsa_mime_widget_new_message},
{TRUE, "text/", balsa_mime_widget_new_text},
{TRUE, "multipart/", balsa_mime_widget_new_multipart},
{TRUE, "image/", balsa_mime_widget_new_image},
@@ -263,7 +264,7 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
g_object_unref(stream);
use_content_type = libbalsa_vfs_content_type_of_buffer(buffer, size);
if (g_ascii_strncasecmp(use_content_type, "text", 4) == 0
- && libbalsa_text_attr_string(buffer) & LIBBALSA_TEXT_HI_BIT) {
+ && (libbalsa_text_attr_string(buffer) & LIBBALSA_TEXT_HI_BIT)) {
/* Hmmm...better stick with application/octet-stream. */
g_free(use_content_type);
use_content_type = g_strdup("application/octet-stream");
diff --git a/src/balsa-print-object.c b/src/balsa-print-object.c
index 9f6d68e..c42ca42 100644
--- a/src/balsa-print-object.c
+++ b/src/balsa-print-object.c
@@ -1,7 +1,7 @@
/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
/* Balsa E-Mail Client
* Copyright (C) 1997-2001 Stuart Parmenter and others
- * Written by (C) Albrecht Dre� <albrecht dress arcor de> 2007
+ * Written by (C) Albrecht Dreß <albrecht dress arcor de> 2007
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
#endif /* HAVE_CONFIG_H */
#include "balsa-print-object.h"
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libbalsa.h>
#include "balsa-app.h"
@@ -104,6 +105,15 @@ balsa_print_object_emb_message(GList * list, GtkPrintContext * context,
return balsa_print_object_header_from_body(list, context, mime_body, psetup);
}
+static GList *
+balsa_print_object_emb_headers(GList * list, GtkPrintContext * context,
+ LibBalsaMessageBody * mime_body,
+ BalsaPrintSetup * psetup)
+{
+ list = balsa_print_object_frame_begin(list, _("message headers"), psetup);
+ list = balsa_print_object_header_from_body(list, context, mime_body, psetup);
+ return balsa_print_object_frame_end(list, psetup);
+}
#ifdef HAVE_GPGME
static GList *
@@ -135,6 +145,7 @@ balsa_print_objects_append_from_body(GList * list,
{ "text/directory", -1, balsa_print_object_text_vcard },
{ "text/calendar", -1, balsa_print_object_text_calendar },
{ "text/plain", -1, balsa_print_object_text_plain },
+ { "text/rfc822-headers", -1, balsa_print_object_emb_headers },
{ "text/", 5, balsa_print_object_text },
{ "image/", 6, balsa_print_object_image },
{ "message/rfc822", -1, balsa_print_object_emb_message },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]