"
""
""
""
" | "
"\n",
evolution_imagesdir);
else
g_string_append (
buffer,
""
"\n");
} else {
if (efh->priv->headers_collapsable)
g_string_append_printf (
buffer,
""
""
""
""
" | "
"\n",
evolution_imagesdir);
else
g_string_append (
buffer,
""
"\n");
}
g_free (evolution_imagesdir);
/* dump selected headers */
if (emf->mode == EM_FORMAT_MODE_ALLHEADERS) {
header = ((CamelMimePart *) part)->headers;
while (header) {
efh_format_header (
emf, buffer, part, header,
EM_FORMAT_HTML_HEADER_NOCOLUMNS, charset);
header = header->next;
}
} else {
GList *link;
gint mailer_shown = FALSE;
link = g_queue_peek_head_link (&emf->header_list);
while (link != NULL) {
EMFormatHeader *h = link->data;
gint 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, buffer, 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")) {
gchar *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, buffer, part,
header, h->flags, charset);
}
header = header->next;
}
link = g_list_next (link);
}
}
if (!efh->simple_headers) {
g_string_append (buffer, " | ");
if (photo_name) {
gchar *classid;
CamelMimePart *photopart;
gboolean only_local_photo;
cia = camel_internet_address_new ();
camel_address_decode ((CamelAddress *) cia, (const gchar *) 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);
g_string_append_printf (
buffer,
""
" | ",
classid);
em_format_add_puri (emf, sizeof (EMFormatPURI), classid,
photopart, efh_write_image);
g_object_unref (photopart);
g_free (classid);
}
g_object_unref (cia);
}
if (!contact_has_photo && face_decoded) {
gchar *classid;
CamelMimePart *part;
part = camel_mime_part_new ();
camel_mime_part_set_content (
(CamelMimePart *) part,
(const gchar *) face_header_value,
face_header_len, "image/png");
classid = g_strdup_printf (
"icon:///em-format-html/face/photo/header");
g_string_append_printf (
buffer,
""
" | ",
classid);
em_format_add_puri (
emf, sizeof (EMFormatPURI),
classid, part, efh_write_image);
g_object_unref (part);
}
if (have_icon && efh->show_icon) {
GtkIconInfo *icon_info;
gchar *classid;
CamelMimePart *iconpart = NULL;
classid = g_strdup_printf (
"icon:///em-format-html/%s/icon/header",
emf->part_id->str);
g_string_append_printf (
buffer,
""
" | ",
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),
cancellable);
gtk_icon_info_free (icon_info);
}
if (iconpart) {
em_format_add_puri (
emf, sizeof (EMFormatPURI),
classid, iconpart, efh_write_image);
g_object_unref (iconpart);
}
g_free (classid);
}
g_string_append (buffer, " \n\n");
}
}
static void
efh_format_message (EMFormat *emf,
CamelStream *stream,
CamelMimePart *part,
const EMFormatHandler *info,
GCancellable *cancellable,
gboolean is_fallback)
{
const EMFormatHandler *handle;
GString *buffer;
/* 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;
buffer = g_string_sized_new (1024);
if (emf->message != (CamelMimeMessage *) part)
g_string_append (buffer, "\n");
if (!efh->hide_headers)
efh_format_headers (
efh, buffer, CAMEL_MEDIUM (part), cancellable);
camel_stream_write (
stream, buffer->str, buffer->len, cancellable, NULL);
g_string_free (buffer, TRUE);
handle = em_format_find_handler(emf, "x-evolution/message/post-header");
if (handle)
handle->handler (
emf, stream, part, handle, cancellable, FALSE);
camel_stream_write_string (
stream, EM_FORMAT_HTML_VPAD, cancellable, NULL);
em_format_part (emf, stream, part, cancellable);
if (emf->message != (CamelMimeMessage *) part)
camel_stream_write_string (
stream, " \n", cancellable, NULL);
camel_cipher_validity_free (emf->valid);
emf->valid = save;
emf->valid_parent = save_parent;
}
gchar *
em_format_html_format_cert_infos (CamelCipherCertInfo *first_cinfo)
{
GString *res = NULL;
CamelCipherCertInfo *cinfo;
if (!first_cinfo)
return NULL;
#define append(x) G_STMT_START { \
if (!res) { \
res = g_string_new (x); \
} else { \
g_string_append (res, x); \
} \
} G_STMT_END
for (cinfo = first_cinfo; cinfo && cinfo->next; cinfo = cinfo->next) {
if (!cinfo->name && !cinfo->email)
continue;
if (res)
append (", ");
if (cinfo->name && *cinfo->name) {
append (cinfo->name);
if (cinfo->email && *cinfo->email) {
append (" <");
append (cinfo->email);
append (">");
}
} else if (cinfo->email && *cinfo->email) {
append (cinfo->email);
}
}
#undef append
if (!res)
return NULL;
return g_string_free (res, FALSE);
}
| | |