\n");
else
camel_stream_printf (stream, "\n");
/* dump selected headers */
h = (EMFormatHeader *)emf->header_list.head;
if (emf->mode == EM_FORMAT_ALLHEADERS) {
header = ((CamelMimePart *)part)->headers;
while (header) {
efh_format_header(emf, stream, part, header, EM_FORMAT_HTML_HEADER_NOCOLUMNS, charset);
header = header->next;
}
} else {
int mailer_shown = FALSE;
while (h->next) {
int mailer, face;
header = ((CamelMimePart *)part)->headers;
mailer = !g_ascii_strcasecmp (h->name, "X-Evolution-Mailer");
face = !g_ascii_strcasecmp (h->name, "Face");
while (header) {
if (emf->show_photo && !photo_name && !g_ascii_strcasecmp (header->name, "From"))
photo_name = header->value;
if (!mailer_shown && mailer && (!g_ascii_strcasecmp (header->name, "X-Mailer") ||
!g_ascii_strcasecmp (header->name, "User-Agent") ||
!g_ascii_strcasecmp (header->name, "X-Newsreader") ||
!g_ascii_strcasecmp (header->name, "X-MimeOLE"))) {
struct _camel_header_raw xmailer, *use_header = NULL;
if (!g_ascii_strcasecmp (header->name, "X-MimeOLE")) {
for (use_header = header->next; use_header; use_header = use_header->next) {
if (!g_ascii_strcasecmp (use_header->name, "X-Mailer") ||
!g_ascii_strcasecmp (use_header->name, "User-Agent") ||
!g_ascii_strcasecmp (use_header->name, "X-Newsreader")) {
/* even we have X-MimeOLE, then use rather the standard one, when available */
break;
}
}
}
if (!use_header)
use_header = header;
xmailer.name = "X-Evolution-Mailer";
xmailer.value = use_header->value;
mailer_shown = TRUE;
efh_format_header (emf, stream, part, &xmailer, h->flags, charset);
if (strstr(use_header->value, "Evolution"))
have_icon = TRUE;
} else if (!face_decoded && face && !g_ascii_strcasecmp (header->name, "Face")) {
char *cp = header->value;
/* Skip over spaces */
while (*cp == ' ')
cp++;
face_header_value = g_base64_decode (cp, &face_header_len);
face_header_value = g_realloc (face_header_value, face_header_len + 1);
face_header_value[face_header_len] = 0;
face_decoded = TRUE;
/* Showing an encoded "Face" header makes little sense */
} else if (!g_ascii_strcasecmp (header->name, h->name) && !face) {
efh_format_header(emf, stream, part, header, h->flags, charset);
}
header = header->next;
}
h = h->next;
}
}
if (!efh->simple_headers) {
camel_stream_printf(stream, " | ");
if (photo_name) {
char *classid;
CamelMimePart *photopart;
cia = camel_internet_address_new();
camel_address_decode((CamelAddress *) cia, (const char *) photo_name);
photopart = em_utils_contact_photo (cia, emf->photo_local);
if (photopart) {
contact_has_photo = TRUE;
classid = g_strdup_printf("icon:///em-format-html/%s/photo/header",
emf->part_id->str);
camel_stream_printf(stream,
" | ",
classid);
em_format_add_puri(emf, sizeof(EMFormatPURI), classid,
photopart, efh_write_image);
camel_object_unref(photopart);
g_free(classid);
}
camel_object_unref(cia);
}
if (!contact_has_photo && face_decoded) {
char *classid;
CamelMimePart *part;
part = camel_mime_part_new ();
camel_mime_part_set_content ((CamelMimePart *) part, (const char *) face_header_value, face_header_len, "image/png");
classid = g_strdup_printf("icon:///em-format-html/face/photo/header");
camel_stream_printf(stream, " | ", classid);
em_format_add_puri(emf, sizeof(EMFormatPURI), classid, part, efh_write_image);
camel_object_unref(part);
}
if (have_icon && efh->show_icon) {
GtkIconInfo *icon_info;
char *classid;
CamelMimePart *iconpart = NULL;
classid = g_strdup_printf("icon:///em-format-html/%s/icon/header", emf->part_id->str);
camel_stream_printf(stream, " | ", classid);
icon_info = gtk_icon_theme_lookup_icon (
gtk_icon_theme_get_default (),
"evolution", 16, GTK_ICON_LOOKUP_NO_SVG);
if (icon_info != NULL) {
iconpart = em_format_html_file_part (
(EMFormatHTML *) emf, "image/png",
gtk_icon_info_get_filename (icon_info));
gtk_icon_info_free (icon_info);
}
if (iconpart) {
em_format_add_puri(emf, sizeof(EMFormatPURI), classid, iconpart, efh_write_image);
camel_object_unref(iconpart);
}
g_free(classid);
}
camel_stream_printf (stream, " \n\n");
}
}
static void efh_format_message(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
{
const EMFormatHandler *handle;
/* TODO: make this validity stuff a method */
EMFormatHTML *efh = (EMFormatHTML *) emf;
CamelCipherValidity *save = emf->valid, *save_parent = emf->valid_parent;
emf->valid = NULL;
emf->valid_parent = NULL;
if (emf->message != (CamelMimeMessage *)part)
camel_stream_printf(stream, "\n");
if (!efh->hide_headers)
efh_format_headers(efh, stream, (CamelMedium *)part);
handle = em_format_find_handler(emf, "x-evolution/message/post-header");
if (handle)
handle->handler(emf, stream, part, handle);
camel_stream_printf(stream, EM_FORMAT_HTML_VPAD);
em_format_part(emf, stream, part);
if (emf->message != (CamelMimeMessage *)part)
camel_stream_printf(stream, " \n");
camel_cipher_validity_free(emf->valid);
emf->valid = save;
emf->valid_parent = save_parent;
}
static void efh_format_source(EMFormat *emf, CamelStream *stream, CamelMimePart *part)
{
CamelStreamFilter *filtered_stream;
CamelMimeFilter *html_filter;
CamelDataWrapper *dw = (CamelDataWrapper *)part;
filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *) stream);
html_filter = camel_mime_filter_tohtml_new (CAMEL_MIME_FILTER_TOHTML_CONVERT_NL
| CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES
| CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT, 0);
camel_stream_filter_add(filtered_stream, html_filter);
camel_object_unref(html_filter);
camel_stream_write_string((CamelStream *)stream, "");
em_format_format_text(emf, (CamelStream *)filtered_stream, dw);
camel_object_unref(filtered_stream);
camel_stream_write_string(stream, " | ");
}
static void
efh_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const char *mime_type, const EMFormatHandler *handle)
{
char *text, *html;
/* we display all inlined attachments only */
/* this could probably be cleaned up ... */
camel_stream_write_string(stream,
""
" | "
" | \n");
/* output some info about it */
text = em_format_describe_part(part, mime_type);
html = camel_text_to_html(text, ((EMFormatHTML *)emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0);
camel_stream_write_string(stream, html);
g_free(html);
g_free(text);
camel_stream_write_string(stream, " | |
");
if (handle && em_format_is_inline(emf, emf->part_id->str, part, handle))
handle->handler(emf, stream, part, handle);
}
static gboolean
efh_busy(EMFormat *emf)
{
return (((EMFormatHTML *)emf)->priv->format_id != -1);
}
|