/*
* e-mail-formatter-print-headers.c
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see .
*
*/
#ifdef HAVE_CONFIG_H
#include
#endif
#include
#include
#include
#include
#include
#include "e-mail-formatter-print.h"
#include "e-mail-formatter-utils.h"
#include "e-mail-inline-filter.h"
#include "e-mail-part-headers.h"
typedef EMailFormatterExtension EMailFormatterPrintHeaders;
typedef EMailFormatterExtensionClass EMailFormatterPrintHeadersClass;
GType e_mail_formatter_print_headers_get_type (void);
G_DEFINE_TYPE (
EMailFormatterPrintHeaders,
e_mail_formatter_print_headers,
E_TYPE_MAIL_FORMATTER_PRINT_EXTENSION)
static const gchar *formatter_mime_types[] = {
"application/vnd.evolution.headers",
NULL
};
static gboolean
emfpe_headers_format (EMailFormatterExtension *extension,
EMailFormatter *formatter,
EMailFormatterContext *context,
EMailPart *part,
GOutputStream *stream,
GCancellable *cancellable)
{
EMailPartHeaders *headers_part;
GtkTreeModel *tree_model;
GtkTreeIter iter;
gboolean iter_valid;
GString *str, *tmp;
gchar *subject;
const gchar *buf;
gint attachments_count;
gchar *part_id_prefix;
CamelMimePart *mime_part;
GQueue queue = G_QUEUE_INIT;
GList *head, *link;
const gchar *part_id;
g_return_val_if_fail (E_IS_MAIL_PART_HEADERS (part), FALSE);
mime_part = e_mail_part_ref_mime_part (part);
buf = camel_medium_get_header (CAMEL_MEDIUM (mime_part), "subject");
subject = camel_header_decode_string (buf, "UTF-8");
str = g_string_new ("");
g_string_append_printf (str, "%s
\n", subject);
g_free (subject);
g_string_append (
str,
"");
g_output_stream_write_all (
stream, str->str, str->len, NULL, cancellable, NULL);
g_string_free (str, TRUE);
g_free (part_id_prefix);
g_object_unref (mime_part);
return TRUE;
}
static void
e_mail_formatter_print_headers_class_init (EMailFormatterExtensionClass *class)
{
class->mime_types = formatter_mime_types;
class->priority = G_PRIORITY_LOW;
class->format = emfpe_headers_format;
}
static void
e_mail_formatter_print_headers_init (EMailFormatterExtension *extension)
{
}