\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 (em_format_html_get_show_sender_photo (efh) &&
!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 = (gchar *) "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;
gboolean only_local_photo;
cia = camel_internet_address_new();
camel_address_decode((CamelAddress *) cia, (const char *) photo_name);
only_local_photo = em_format_html_get_only_local_photos (efh);
photopart = em_utils_contact_photo (cia, only_local_photo);
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;
}
|