From e70e3982edf25a75bd93bdaf9205cca1167a3d4c Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 15 Jan 2004 01:22:55 +0000 Subject: ** See bugs #51609 and #43515. 2004-01-15 Not Zed ** See bugs #51609 and #43515. * em-format-html-display.c (efhd_format_prefix): output flag for followup details above the message. (efhd_write_image): added to output icon data. * em-format-html.c (efh_format_do): call format_prefix before outputting the message in normal display mode. * em-format.c (emf_format_prefix): method called to format data before the first message output. Default impl == noop. svn path=/trunk/; revision=24230 --- mail/em-format-html-display.c | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 60c096ac65..10f5d89d33 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -69,6 +69,9 @@ #include #include +/* should this be in e-util rather than gal? */ +#include + #include #include #include @@ -127,6 +130,7 @@ static void efhd_iframe_created(GtkHTML *html, GtkHTML *iframe, EMFormatHTMLDisp static const EMFormatHandler *efhd_find_handler(EMFormat *emf, const char *mime_type); static void efhd_format_clone(EMFormat *, CamelFolder *folder, const char *, CamelMimeMessage *msg, EMFormat *); +static void efhd_format_prefix(EMFormat *emf, CamelStream *stream); static void efhd_format_error(EMFormat *emf, CamelStream *stream, const char *txt); static void efhd_format_message(EMFormat *, CamelStream *, CamelMedium *); static void efhd_format_source(EMFormat *, CamelStream *, CamelMimePart *); @@ -264,6 +268,7 @@ efhd_class_init(GObjectClass *klass) { ((EMFormatClass *)klass)->find_handler = efhd_find_handler; ((EMFormatClass *)klass)->format_clone = efhd_format_clone; + ((EMFormatClass *)klass)->format_prefix = efhd_format_prefix; ((EMFormatClass *)klass)->format_error = efhd_format_error; ((EMFormatClass *)klass)->format_message = efhd_format_message; ((EMFormatClass *)klass)->format_source = efhd_format_source; @@ -1011,6 +1016,71 @@ static void efhd_format_clone(EMFormat *emf, CamelFolder *folder, const char *ui ((EMFormatClass *)efhd_parent)->format_clone(emf, folder, uid, msg, src); } +static void +efhd_write_image(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) +{ + CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)puri->part); + + /* TODO: identical to efh_write_image */ + d(printf("writing image '%s'\n", puri->uri?puri->uri:puri->cid)); + camel_data_wrapper_decode_to_stream(dw, stream); + camel_stream_close(stream); +} + +static void efhd_format_prefix(EMFormat *emf, CamelStream *stream) +{ + const char *flag, *comp, *due; + CamelMimePart *iconpart; + time_t date; + char due_date[128]; + struct tm due_tm; + + if (emf->folder == NULL || emf->uid == NULL + || (flag = camel_folder_get_message_user_tag(emf->folder, emf->uid, "follow-up")) == NULL + || flag[0] == 0) + return; + + /* header displayed for message-flags in mail display */ + camel_stream_printf(stream, ""); + + comp = camel_folder_get_message_user_tag(emf->folder, emf->uid, "completed-on"); + iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png", EVOLUTION_ICONSDIR, + comp&&comp[0]?"flag-for-followup-done-16.png":"flag-for-followup-16.png"); + if (iconpart) { + char *classid; + + classid = g_strdup_printf("icon:///em-format-html-display/%s/%s", emf->part_id->str, comp&&comp[0]?"comp":"uncomp"); + camel_stream_printf(stream, "", classid); + (void)em_format_add_puri(emf, sizeof(EMFormatPURI), classid, iconpart, efhd_write_image); + g_free(classid); + camel_object_unref(iconpart); + } + + camel_stream_printf(stream, "
"); + + if (comp && comp[0]) { + date = camel_header_decode_date(comp, NULL); + localtime_r(&date, &due_tm); + e_utf8_strftime_fix_am_pm(due_date, sizeof (due_date), _("Completed on %B %d, %Y, %l:%M %p"), &due_tm); + camel_stream_printf(stream, "%s, %s", flag, due_date); + } else if ((due = camel_folder_get_message_user_tag(emf->folder, emf->uid, "due-by")) != NULL && due[0]) { + time_t now; + + date = camel_header_decode_date(due, NULL); + now = time(NULL); + if (now > date) + camel_stream_printf(stream, "%s ", _("Overdue:")); + + localtime_r(&date, &due_tm); + e_utf8_strftime_fix_am_pm(due_date, sizeof (due_date), _("by %B %d, %Y, %l:%M %p"), &due_tm); + camel_stream_printf(stream, "%s %s", flag, due_date); + } else { + camel_stream_printf(stream, "%s", flag); + } + + camel_stream_printf(stream, "
"); +} + /* TODO: if these aren't going to do anything should remove */ static void efhd_format_error(EMFormat *emf, CamelStream *stream, const char *txt) { -- cgit v1.2.3