recipients_string);
g_free (recipients_string);
g_mime_stream_printf (stream, "> Subject: %s\n", g_mime_message_get_subject (message));
- g_mime_stream_printf (stream, "> Date: %s\n", g_mime_message_get_date_as_string (message));
+ g_mime_stream_printf (stream, "> Date: %s\n", g_mime_message_get_date_string (node, message));
g_mime_stream_printf (stream, ">\n");
} else if (GMIME_IS_PART (node->part)) {
GMimeContentType *content_type = g_mime_object_get_content_type (node->part);
InternetAddressList *recipients;
char *recipients_string;
const char *reply_to_string;
- char *date_string;
sp->begin_map (sp);
sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "References"));
} else {
sp->map_key (sp, "Date");
- date_string = g_mime_message_get_date_as_string (message);
- sp->string (sp, date_string);
- g_free (date_string);
+ sp->string (sp, g_mime_message_get_date_string (sp, message));
}
sp->end (sp);
if (recipients_string)
g_mime_stream_printf (stream, "Cc: %s\n", recipients_string);
g_free (recipients_string);
- date_string = g_mime_message_get_date_as_string (message);
+ date_string = g_mime_message_get_date_string (node, message);
g_mime_stream_printf (stream, "Date: %s\n", date_string);
- g_free (date_string);
g_mime_stream_printf (stream, "\fheader}\n");
g_mime_stream_printf (stream, "\fbody{\n");
return stream_buffered;
}
+
+/**
+ * copy a glib string into a talloc context, and free it.
+ */
+static char*
+g_string_talloc_strdup (void *ctx, char *g_string)
+{
+ char *new_str = talloc_strdup (ctx, g_string);
+ g_free (g_string);
+ return new_str;
+}
+
+#if (GMIME_MAJOR_VERSION < 3)
+
+char *
+g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
+{
+ char *date = g_mime_message_get_date_as_string (message);
+ return g_string_talloc_strdup (ctx, date);
+}
+
+#else /* GMime >= 3.0 */
+
+char *
+g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
+{
+ GDateTime* parsed_date = g_mime_message_get_date (message);
+ if (parsed_date) {
+ char *date = g_mime_utils_header_format_date (parsed_date);
+ return g_string_talloc_strdup (ctx, date);
+ } else {
+ return talloc_strdup(ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
+ }
+}
+#endif
#include <gmime/gmime.h>
GMimeStream *g_mime_stream_stdout_new(void);
+
+#include <talloc.h>
+
+/**
+ * return talloc allocated date string
+ */
+char *g_mime_message_get_date_string (void *ctx, GMimeMessage *message);
+
#endif