"
""
""
""
" | "
"\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;
}
void
em_format_html_format_cert_infos (GQueue *cert_infos,
GString *output_buffer)
{
GQueue valid = G_QUEUE_INIT;
GList *head, *link;
g_return_if_fail (cert_infos != NULL);
g_return_if_fail (output_buffer != NULL);
head = g_queue_peek_head_link (cert_infos);
/* Make sure we have a valid CamelCipherCertInfo before
* appending anything to the output buffer, so we don't
* end up with "()". */
for (link = head; link != NULL; link = g_list_next (link)) {
CamelCipherCertInfo *cinfo = link->data;
if ((cinfo->name != NULL && *cinfo->name != '\0') ||
(cinfo->email != NULL && *cinfo->email != '\0'))
g_queue_push_tail (&valid, cinfo);
}
if (g_queue_is_empty (&valid))
return;
g_string_append (output_buffer, " (");
while (!g_queue_is_empty (&valid)) {
CamelCipherCertInfo *cinfo;
cinfo = g_queue_pop_head (&valid);
if (cinfo->name != NULL && *cinfo->name != '\0') {
g_string_append (output_buffer, cinfo->name);
if (cinfo->email != NULL && *cinfo->email != '\0') {
g_string_append (output_buffer, " <");
g_string_append (output_buffer, cinfo->email);
g_string_append (output_buffer, ">");
}
} else if (cinfo->email != NULL && *cinfo->email != '\0') {
g_string_append (output_buffer, cinfo->email);
}
if (!g_queue_is_empty (&valid))
g_string_append (output_buffer, ", ");
}
g_string_append_c (output_buffer, ')');
}
/* unref returned pointer with g_object_unref(), if not NULL */
CamelStream *
em_format_html_get_cached_image (EMFormatHTML *efh,
const gchar *image_uri)
{
g_return_val_if_fail (efh != NULL, NULL);
g_return_val_if_fail (image_uri != NULL, NULL);
if (!emfh_http_cache)
return NULL;
return camel_data_cache_get (
emfh_http_cache, EMFH_HTTP_CACHE_PATH, image_uri, NULL);
}
| | |