aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-composer-utils.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2006-02-22 16:56:47 +0800
committerTor Lillqvist <tml@src.gnome.org>2006-02-22 16:56:47 +0800
commit945b2343595dbd3d9fbd5dd9e145a9de03ba5068 (patch)
tree727b19abfe42ae6c8ed427c87872284175895421 /mail/em-composer-utils.c
parentdd19a253c8286bd5a24b5d335911f79ab7275d7c (diff)
downloadgsoc2013-evolution-945b2343595dbd3d9fbd5dd9e145a9de03ba5068.tar
gsoc2013-evolution-945b2343595dbd3d9fbd5dd9e145a9de03ba5068.tar.gz
gsoc2013-evolution-945b2343595dbd3d9fbd5dd9e145a9de03ba5068.tar.bz2
gsoc2013-evolution-945b2343595dbd3d9fbd5dd9e145a9de03ba5068.tar.lz
gsoc2013-evolution-945b2343595dbd3d9fbd5dd9e145a9de03ba5068.tar.xz
gsoc2013-evolution-945b2343595dbd3d9fbd5dd9e145a9de03ba5068.tar.zst
gsoc2013-evolution-945b2343595dbd3d9fbd5dd9e145a9de03ba5068.zip
Use the same Win32 macro for gmtime_r() that guards against gmtime()
2006-02-21 Tor Lillqvist <tml@novell.com> * em-composer-utils.c: Use the same Win32 macro for gmtime_r() that guards against gmtime() returning NULL as elsewhere. gmtime() is thread-safe on Win32. (attribution_format): Check if camel returns CAMEL_MESSAGE_DATE_CURRENT for Date:, try the date from Received: then. If that doesn't work either, use current date. svn path=/trunk/; revision=31560
Diffstat (limited to 'mail/em-composer-utils.c')
-rw-r--r--mail/em-composer-utils.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 583c0ba3a7..f9b1bf9f9c 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -56,6 +56,16 @@
#include <camel/camel-nntp-address.h>
#include <camel/camel-vee-folder.h>
+#ifdef G_OS_WIN32
+/* Undef the similar macro from pthread.h, it doesn't check if
+ * gmtime() returns NULL.
+ */
+#undef gmtime_r
+
+/* The gmtime() in Microsoft's C library is MT-safe */
+#define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
+#endif
+
static EAccount * guess_account (CamelMimeMessage *message, CamelFolder *folder);
struct emcs_t {
@@ -1716,15 +1726,22 @@ attribution_format (const char *format, CamelMimeMessage *message)
str = g_string_new ("");
date = camel_mime_message_get_date (message, &tzone);
+
+ if (date == CAMEL_MESSAGE_DATE_CURRENT) {
+ /* The message has no Date: header, look at Received: */
+ date = camel_mime_message_get_date_received (message, &tzone);
+ }
+ if (date == CAMEL_MESSAGE_DATE_CURRENT) {
+ /* That didn't work either, use current time */
+ time (&date);
+ tzone = 0;
+ }
+
/* Convert to UTC */
date += (tzone / 100) * 60 * 60;
date += (tzone % 100) * 60;
-#ifdef HAVE_GMTIME_R
gmtime_r (&date, &tm);
-#else
- memcpy (&tm, gmtime (&date), sizeof (struct tm));
-#endif
start = inptr = format;
while (*inptr != '\0') {