aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog14
-rw-r--r--mail/em-folder-view.c2
-rw-r--r--mail/em-format-html-display.c70
-rw-r--r--mail/em-format-html.c6
-rw-r--r--mail/em-format.c8
-rw-r--r--mail/em-format.h5
6 files changed, 102 insertions, 3 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 090dfbffca..27f5d574a0 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,17 @@
+2004-01-15 Not Zed <NotZed@Ximian.com>
+
+ ** 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.
+
2004-01-14 Jeremy Katz <katzj@redhat.com>
* evolution-mail.schemas.in.in: Add a description for
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index cc41f8f501..ed4b444a8e 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -2047,7 +2047,7 @@ emfv_setting_notify(GConfClient *gconf, guint cnxn_id, GConfEntry *entry, EMFold
em_format_default_headers(emf);
/* force a redraw */
if (emf->message)
- em_format_format_clone(emf, emf->folder, emf->uid, emf->message, emf);
+ em_format_redraw(emf);
break; }
}
}
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 <camel/camel-mime-message.h>
#include <camel/camel-gpg-context.h>
+/* should this be in e-util rather than gal? */
+#include <gal/util/e-util.h>
+
#include <e-util/e-msgport.h>
#include <e-util/e-gui-utils.h>
#include <e-util/e-dialog-utils.h>
@@ -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, "<table border=1 width=\"100%%\" cellspacing=2 cellpadding=2><tr>");
+
+ 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, "<td align=\"left\"><img src=\"%s\"></td>", 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, "<td align=\"left\" width=\"100%%\">");
+
+ 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, "<b>%s</b>&nbsp;", _("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, "</td></tr></table>");
+}
+
/* TODO: if these aren't going to do anything should remove */
static void efhd_format_error(EMFormat *emf, CamelStream *stream, const char *txt)
{
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 96239fb925..44afe282d8 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -1194,10 +1194,12 @@ static void efh_format_do(struct _mail_msg *mm)
/* <insert top-header stuff here> */
- if (((EMFormat *)m->format)->mode == EM_FORMAT_SOURCE)
+ if (((EMFormat *)m->format)->mode == EM_FORMAT_SOURCE) {
em_format_format_source((EMFormat *)m->format, (CamelStream *)m->estream, (CamelMimePart *)m->message);
- else
+ } else {
+ em_format_format_prefix((EMFormat *)m->format, (CamelStream *)m->estream);
em_format_format_message((EMFormat *)m->format, (CamelStream *)m->estream, (CamelMedium *)m->message);
+ }
camel_stream_write_string((CamelStream *)m->estream, "</body>\n</html>\n");
camel_stream_close((CamelStream *)m->estream);
diff --git a/mail/em-format.c b/mail/em-format.c
index 4ced33aee2..b1f597af8e 100644
--- a/mail/em-format.c
+++ b/mail/em-format.c
@@ -59,6 +59,7 @@ static const char *emf_snoop_part(CamelMimePart *part);
static const EMFormatHandler *emf_find_handler(EMFormat *emf, const char *mime_type);
static void emf_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeMessage *msg, EMFormat *emfsource);
+static void emf_format_prefix(EMFormat *emf, CamelStream *stream);
static gboolean emf_busy(EMFormat *emf);
enum {
@@ -116,6 +117,7 @@ emf_class_init(GObjectClass *klass)
klass->finalize = emf_finalise;
((EMFormatClass *)klass)->find_handler = emf_find_handler;
((EMFormatClass *)klass)->format_clone = emf_format_clone;
+ ((EMFormatClass *)klass)->format_prefix = emf_format_prefix;
((EMFormatClass *)klass)->busy = emf_busy;
emf_signals[EMF_COMPLETE] =
@@ -565,6 +567,12 @@ emf_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeM
g_string_append_printf(emf->part_id, ".%s", uid);
}
+static void
+emf_format_prefix(EMFormat *emf, CamelStream *stream)
+{
+ /* NOOP */
+}
+
static gboolean
emf_busy(EMFormat *emf)
{
diff --git a/mail/em-format.h b/mail/em-format.h
index d01b50bc7e..5d41ae0020 100644
--- a/mail/em-format.h
+++ b/mail/em-format.h
@@ -138,6 +138,10 @@ struct _EMFormatClass {
/* start formatting a message */
void (*format_clone)(EMFormat *, struct _CamelFolder *, const char *uid, struct _CamelMimeMessage *, EMFormat *);
+
+ /* called to insert prefix material, after format_clone but before format_message */
+ void (*format_prefix)(EMFormat *, struct _CamelStream *);
+
/* some internel error/inconsistency */
void (*format_error)(EMFormat *, struct _CamelStream *, const char *msg);
@@ -196,6 +200,7 @@ void em_format_pull_level(EMFormat *emf);
#define em_format_format_clone(emf, folder, uid, msg, src) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_clone((emf), (folder), (uid), (msg), (src))
/* formats a new message */
#define em_format_format(emf, folder, uid, msg) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_clone((emf), (folder), (uid), (msg), NULL)
+#define em_format_format_prefix(emf, stream) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_prefix((emf), (stream))
#define em_format_redraw(emf) ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_clone((emf), \
((EMFormat *)(emf))->folder, \
((EMFormat *)(emf))->uid, \