evolution-data-server r10137 - in trunk: camel/providers/groupwise servers/groupwise



Author: pchen
Date: Thu Mar  5 09:41:24 2009
New Revision: 10137
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=10137&view=rev

Log:
Fixes #465364 (bnc)

Modified:
   trunk/camel/providers/groupwise/ChangeLog
   trunk/camel/providers/groupwise/camel-groupwise-folder.c
   trunk/servers/groupwise/ChangeLog
   trunk/servers/groupwise/e-gw-connection.c

Modified: trunk/camel/providers/groupwise/camel-groupwise-folder.c
==============================================================================
--- trunk/camel/providers/groupwise/camel-groupwise-folder.c	(original)
+++ trunk/camel/providers/groupwise/camel-groupwise-folder.c	Thu Mar  5 09:41:24 2009
@@ -230,17 +230,27 @@
 static void
 groupwise_populate_details_from_item (CamelMimeMessage *msg, EGwItem *item)
 {
+	EGwItemType type;
 	char *dtstring = NULL;
 	char *temp_str = NULL;
 
 	temp_str = (char *)e_gw_item_get_subject(item);
 	if(temp_str)
 		camel_mime_message_set_subject (msg, temp_str);
+	type = e_gw_item_get_item_type (item);
+
+	if (type == E_GW_ITEM_TYPE_APPOINTMENT  || type == E_GW_ITEM_TYPE_NOTE || type == E_GW_ITEM_TYPE_TASK) {
+		int offset = 0;
+		dtstring = e_gw_item_get_start_date (item);
+		time_t actual_time = e_gw_connection_get_date_from_string (dtstring);
+		camel_mime_message_set_date (msg, actual_time, offset);
+		return;
+	}
+
 	dtstring = e_gw_item_get_delivered_date (item);
 	if(dtstring) {
 		int offset = 0;
-		time_t time = e_gw_connection_get_date_from_string (dtstring);
-		time_t actual_time = camel_header_decode_date (ctime(&time), &offset);
+		time_t actual_time = e_gw_connection_get_date_from_string (dtstring);
 		camel_mime_message_set_date (msg, actual_time, offset);
 	} else {
 		time_t time;
@@ -248,8 +258,7 @@
 		int offset = 0;
 		dtstring = e_gw_item_get_creation_date (item);
 		if (dtstring) {
-				time = e_gw_connection_get_date_from_string (dtstring);
-				actual_time = camel_header_decode_date (ctime(&time), NULL);
+				actual_time = e_gw_connection_get_date_from_string (dtstring);
 		} else
 				actual_time = (time_t) 0;
 		camel_mime_message_set_date (msg, actual_time, offset);
@@ -1498,24 +1507,20 @@
 				|| type ==  E_GW_ITEM_TYPE_TASK ) {
 			temp_date = e_gw_item_get_start_date (item);
 			if (temp_date) {
-				time_t time = e_gw_connection_get_date_from_string (temp_date);
-				time_t actual_time = camel_header_decode_date (ctime(&time), NULL);
+				time_t actual_time = e_gw_connection_get_date_from_string (temp_date);
 				mi->info.date_sent = mi->info.date_received = actual_time;
 			}
 		} else {
 			temp_date = e_gw_item_get_delivered_date(item);
 			if (temp_date) {
-				time_t time = e_gw_connection_get_date_from_string (temp_date);
-				time_t actual_time = camel_header_decode_date (ctime(&time), NULL);
+				time_t actual_time = e_gw_connection_get_date_from_string (temp_date);
 				mi->info.date_sent = mi->info.date_received = actual_time;
 			} else {
-				time_t time;
 				time_t actual_time;
 				temp_date = e_gw_item_get_creation_date (item);
 				if (temp_date) {
 						/* Creation date can be returned as null for auto-generated meetings */
-						time = e_gw_connection_get_date_from_string (temp_date);
-						actual_time = camel_header_decode_date (ctime(&time), NULL);
+						actual_time = e_gw_connection_get_date_from_string (temp_date);
 				} else
 					actual_time = (time_t) 0;
 				mi->info.date_sent = mi->info.date_received = actual_time;
@@ -1720,23 +1725,19 @@
 		    type ==  E_GW_ITEM_TYPE_TASK ) {
 			temp_date = e_gw_item_get_start_date (item);
 			if (temp_date) {
-				time_t time = e_gw_connection_get_date_from_string (temp_date);
-				time_t actual_time = camel_header_decode_date (ctime(&time), NULL);
+				time_t actual_time = e_gw_connection_get_date_from_string (temp_date);
 				mi->info.date_sent = mi->info.date_received = actual_time;
 			} 
 		} else {
 			temp_date = e_gw_item_get_delivered_date(item);
 			if (temp_date) {
-				time_t time = e_gw_connection_get_date_from_string (temp_date);
-				time_t actual_time = camel_header_decode_date (ctime(&time), NULL);
+				time_t actual_time = e_gw_connection_get_date_from_string (temp_date);
 				mi->info.date_sent = mi->info.date_received = actual_time;
 			} else {
-				time_t time;
 				time_t actual_time;
 				temp_date = e_gw_item_get_creation_date (item);
 				if (temp_date) {
-						time = e_gw_connection_get_date_from_string (temp_date);
-						actual_time = camel_header_decode_date (ctime(&time), NULL);
+						actual_time = e_gw_connection_get_date_from_string (temp_date);
 				} else
 						actual_time = (time_t) 0;
 				mi->info.date_sent = mi->info.date_received = actual_time;

Modified: trunk/servers/groupwise/e-gw-connection.c
==============================================================================
--- trunk/servers/groupwise/e-gw-connection.c	(original)
+++ trunk/servers/groupwise/e-gw-connection.c	Thu Mar  5 09:41:24 2009
@@ -1811,46 +1811,6 @@
 	return (const char *) cnc->priv->server_time ;
 }
 
-static time_t
-timet_from_string (const char *str)
-{
-		struct tm date;
-		int len, i;
-
-		g_return_val_if_fail (str != NULL, -1);
-
-		/* yyyymmdd[Thhmmss[Z]] */
-		len = strlen (str);
-
-		if (!(len == 8 || len == 15 || len == 16))
-				return -1;
-
-		for (i = 0; i < len; i++)
-				if (!((i != 8 && i != 15 && isdigit (str[i]))
-										|| (i == 8 && str[i] == 'T')
-										|| (i == 15 && str[i] == 'Z')))
-						return -1;
-
-#define digit_at(x,y) (x[y] - '0')
-
-		date.tm_year = digit_at (str, 0) * 1000
-				+ digit_at (str, 1) * 100
-				+ digit_at (str, 2) * 10
-				+ digit_at (str, 3) -1900;
-		date.tm_mon = digit_at (str, 4) * 10 + digit_at (str, 5) -1;
-		date.tm_mday = digit_at (str, 6) * 10 + digit_at (str, 7);
-		if (len > 8) {
-				date.tm_hour = digit_at (str, 9) * 10 + digit_at (str, 10);
-				date.tm_min  = digit_at (str, 11) * 10 + digit_at (str, 12);
-				date.tm_sec  = digit_at (str, 13) * 10 + digit_at (str, 14);
-		} else
-				date.tm_hour = date.tm_min = date.tm_sec = 0;
-
-		date.tm_wday = date.tm_yday = date.tm_isdst = 0;
-
-		return mktime (&date);
-}
-
 char *
 e_gw_connection_format_date_string (const char *dtstring)
 {
@@ -1875,24 +1835,35 @@
 time_t
 e_gw_connection_get_date_from_string (const char *dtstring)
 {
-        char *str2;
-	int i, j, len;
-	time_t t;
+	time_t t = 0;
+	GTimeVal t_val;
 
 	g_return_val_if_fail (dtstring != NULL, 0);
 
-	len = strlen (dtstring);
-        str2 = g_malloc0 (len+1);
-        for (i = 0,j = 0; i < len; i++) {
-                if ((dtstring[i] != '-') && (dtstring[i] != ':')) {
-			str2[j] = dtstring[i];
-			j++;
-                }
-        }
+	if (g_time_val_from_iso8601 (dtstring, &t_val)) {
+		t = (time_t) t_val.tv_sec;
+	} else if (strlen (dtstring) == 8) {
+		/* It might be a date value */
+		GDate date;
+		struct tm tt;
 
-	str2[j] = '\0';
-	t = timet_from_string (str2);
-	g_free (str2);
+		g_date_clear (&date, 1);
+#define digit_at(x,y) (x[y] - '0')
+		guint16 year = digit_at (dtstring, 0) * 1000
+				+ digit_at (dtstring, 1) * 100
+				+ digit_at (dtstring, 2) * 10
+				+ digit_at (dtstring, 3);
+		guint month = digit_at (dtstring, 4) * 10 + digit_at (dtstring, 5);
+		guint8 day = digit_at (dtstring, 6) * 10 + digit_at (dtstring, 7);
+		g_date_set_year (&date, year);
+		g_date_set_month (&date, month);
+		g_date_set_day (&date, day);
+
+		g_date_to_struct_tm (&date, &tt);
+		t = mktime (&tt);
+
+	} else 
+		g_warning ("Could not parse the string \n");
 
         return t;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]