evolution-data-server r8817 - in branches/EXCHANGE_MAPI_BRANCH: calendar/backends/mapi servers/mapi



Author: msuman
Date: Tue May 20 11:36:08 2008
New Revision: 8817
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8817&view=rev

Log:
Use restrictions while getting changes from the server (in calendars/tasks/memos), print a readable time-string for PT_SYSTIME while dumping properties array.

Modified:
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.c
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.h
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c

Modified: branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.c	Tue May 20 11:36:08 2008
@@ -1091,58 +1091,3 @@
 	return i;
 }
 
-void
-e_cal_backend_mapi_util_dump_properties (struct mapi_SPropValue_array *properties)
-{
-	int i;
-
-	for (i = 0; i < properties->cValues; i++) { 
-		struct mapi_SPropValue *lpProp = &properties->lpProps[i];
-		const char *tmp =  get_proptag_name (lpProp->ulPropTag);
-		struct timeval t;
-		if (tmp && *tmp)
-			printf("\n%s \t",tmp);
-		else
-			printf("\n%x \t", lpProp->ulPropTag);
-		switch(lpProp->ulPropTag & 0xFFFF) {
-			case PT_BOOLEAN:
-				printf(" (bool) - %d", lpProp->value.b);
-				break;
-			case PT_I2:
-				printf(" (uint16_t) - %d", lpProp->value.i);
-				break;
-			case PT_LONG:
-				printf(" (long) - %d", lpProp->value.l);
-				break;
-			case PT_DOUBLE:
-				printf (" (double) - %lld", lpProp->value.dbl);
-				break;
-			case PT_I8:
-				printf (" (int) - %lld", lpProp->value.d);
-				break;
-			case PT_SYSTIME:
-				get_mapi_SPropValue_array_date_timeval (&t, properties, lpProp->ulPropTag);
-				printf (" (struct FILETIME *) - %p\t[%s]\t", &lpProp->value.ft, icaltime_as_ical_string (icaltime_from_timet_with_zone (t.tv_sec, 0, 0)));
-				break;
-			case PT_ERROR:
-//				printf (" (error) - %p", lpProp->value.err);
-				break;
-			case PT_STRING8:
-				printf(" (string) - %s", lpProp->value.lpszA ? lpProp->value.lpszA : "null" );
-				break;
-			case PT_UNICODE:
-				printf(" (unicodestring) - %s", lpProp->value.lpszW ? lpProp->value.lpszW : "null");
-				break;
-			case PT_BINARY:
-				printf(" (struct SBinary_short *) - %p\t[%s]\t", &lpProp->value.bin, (const char *) (lpProp->value.bin.lpb));
-				break;
-			case PT_MV_STRING8:
-// 				printf(" (struct mapi_SLPSTRArray *) - %p", &lpProp->value.MVszA);
-				break;
-			default:
-				printf(" - NONE NULL");
-				break;
-		}
-	}
-}
-

Modified: branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.h	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi-utils.h	Tue May 20 11:36:08 2008
@@ -42,9 +42,6 @@
 int
 mapi_cal_build_props (struct SPropValue **value, struct SPropTagArray *proptag_array, gpointer data);
 
-void
-e_cal_backend_mapi_util_dump_properties (struct mapi_SPropValue_array *properties);
-
 G_END_DECLS
 
 #endif

Modified: branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c	Tue May 20 11:36:08 2008
@@ -392,8 +392,8 @@
 static const uint16_t n_IDList = G_N_ELEMENTS (IDList);
 
 static gboolean
-get_changes_cb (struct mapi_SPropValue_array *array, const mapi_id_t fid, const mapi_id_t mid, 
-		GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
+mapi_cal_get_changes_cb (struct mapi_SPropValue_array *array, const mapi_id_t fid, const mapi_id_t mid, 
+			 GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
 {
 	ECalBackendMAPI *cbmapi	= data;
 	ECalBackendMAPIPrivate *priv = cbmapi->priv;
@@ -401,6 +401,8 @@
 	ECalComponent *cache_comp = NULL;
 	const bool *recurring;
 
+//	exchange_mapi_debug_property_dump (array);
+
 	/* FIXME: Provide support for meetings/assigned tasks */
 	if (recipients != NULL) {
 		g_warning ("Calendar backend failed to parse a meeting");
@@ -549,8 +551,20 @@
 	serv_time = e_cal_backend_cache_get_server_utc_time (priv->cache);
 	itt_cache = icaltime_from_string (serv_time); 
 	if (!icaltime_is_null_time (itt_cache)) {
-		/* FIXME: prepare the restriction here */
-	} 
+		struct SPropValue sprop;
+		struct timeval t;
+
+		use_restriction = TRUE;
+		res.rt = RES_PROPERTY;
+		res.res.resProperty.relop = RELOP_GE;
+		res.res.resProperty.ulPropTag = PR_LAST_MODIFICATION_TIME;
+
+		t.tv_sec = icaltime_as_timet_with_zone (itt_cache, icaltimezone_get_utc_timezone ());
+		t.tv_usec = 0;
+		set_SPropValue_proptag_date_timeval (&sprop, PR_LAST_MODIFICATION_TIME, &t);
+		cast_mapi_SPropValue (&(res.res.resProperty.lpProp), &sprop);
+	} else
+		g_warning ("Cache time-stamp not found."); 
 
 	itt_current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
 	current_time = icaltime_as_timet_with_zone (itt_current, icaltimezone_get_utc_timezone ());
@@ -558,7 +572,7 @@
 	strftime (t_str, 26, "%Y-%m-%dT%H:%M:%SZ", &tm);
 
 //	e_file_cache_freeze_changes (E_FILE_CACHE (priv->cache));
-	if (!exchange_mapi_connection_fetch_items (priv->fid, GetPropsList, n_GetPropsList, mapi_cal_build_name_id, use_restriction ? &res : NULL, get_changes_cb, cbmapi, MAPI_OPTIONS_FETCH_ALL)) {
+	if (!exchange_mapi_connection_fetch_items (priv->fid, GetPropsList, n_GetPropsList, mapi_cal_build_name_id, use_restriction ? &res : NULL, mapi_cal_get_changes_cb, cbmapi, MAPI_OPTIONS_FETCH_ALL)) {
 		/* FIXME: better string please... */
 		e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Error fetching changes from the server. Removing the cache might help."));
 //		e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
@@ -843,8 +857,8 @@
 }
 
 static gboolean
-cache_create_cb (struct mapi_SPropValue_array *properties, const mapi_id_t fid, const mapi_id_t mid, 
-		 GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
+mapi_cal_cache_create_cb (struct mapi_SPropValue_array *properties, const mapi_id_t fid, const mapi_id_t mid, 
+			  GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
 {
 	ECalBackendMAPI *cbmapi	= E_CAL_BACKEND_MAPI (data);
 	ECalBackendMAPIPrivate *priv = cbmapi->priv;
@@ -852,7 +866,7 @@
 	gchar *tmp = NULL;
 	const bool *recurring = NULL;
 
-//	e_cal_backend_mapi_util_dump_properties (properties);
+//	exchange_mapi_debug_property_dump (properties);
 
 	/* FIXME: Provide support for meetings/assigned tasks */
 	if (recipients != NULL) {
@@ -941,7 +955,7 @@
 	strftime (t_str, 26, "%Y-%m-%dT%H:%M:%SZ", &tm);
 
 //	e_file_cache_freeze_changes (E_FILE_CACHE (priv->cache));
-	if (!exchange_mapi_connection_fetch_items (priv->fid, GetPropsList, n_GetPropsList, mapi_cal_build_name_id, NULL, cache_create_cb, cbmapi, MAPI_OPTIONS_FETCH_ALL)) {
+	if (!exchange_mapi_connection_fetch_items (priv->fid, GetPropsList, n_GetPropsList, mapi_cal_build_name_id, NULL, mapi_cal_cache_create_cb, cbmapi, MAPI_OPTIONS_FETCH_ALL)) {
 		e_cal_backend_notify_error (E_CAL_BACKEND (cbmapi), _("Could not create cache file"));
 		e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
 		g_free (progress_string);

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.c	Tue May 20 11:36:08 2008
@@ -935,7 +935,6 @@
 				if ((properties_array.lpProps[z].ulPropTag & 0xFFFF) == PT_BINARY && (options & MAPI_OPTIONS_FETCH_GENERIC_STREAMS)) 
 					exchange_mapi_util_read_generic_stream (&obj_message, properties_array.lpProps[z].ulPropTag, &stream_list);
 			}
-			
 
 			mapi_SPropValue_array_named(&obj_message, &properties_array);
 

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c	Tue May 20 11:36:08 2008
@@ -24,6 +24,16 @@
 #include <config.h>
 #endif
 
+#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
+
 #include "exchange-mapi-utils.h"
 
 
@@ -277,7 +287,7 @@
 		for (i = 0; i < properties->cValues; i++) {
 			struct mapi_SPropValue *lpProp = &properties->lpProps[i];
 			const char *tmp =  get_proptag_name (lpProp->ulPropTag);
-			struct timeval t;
+			char t_str[26];
 			if (tmp && *tmp)
 				printf("\n%s \t",tmp);
 			else
@@ -290,17 +300,22 @@
 				printf(" (uint16_t) - %d", lpProp->value.i);
 				break;
 			case PT_LONG:
-				printf(" (long) - %ld", lpProp->value.l);
+				printf(" (long) - %u", lpProp->value.l);
 				break;
 			case PT_DOUBLE:
 				printf (" (double) -  %lf", lpProp->value.dbl);
 				break;
 			case PT_I8:
-				printf (" (int) - %d", lpProp->value.d);
+				printf (" (int) - %lld", lpProp->value.d);
 				break;
-			case PT_SYSTIME:
-/* 				get_mapi_SPropValue_array_date_timeval (&t, properties, lpProp->ulPropTag); */
-/* 				printf (" (struct FILETIME *) - %p\t[%s]\t", &lpProp->value.ft, icaltime_as_ical_string (icaltime_from_timet_with_zone (t.tv_sec, 0, utc_zone))); */
+			case PT_SYSTIME: {
+					struct timeval t;
+					struct tm tm;
+					get_mapi_SPropValue_array_date_timeval (&t, properties, lpProp->ulPropTag);
+					gmtime_r (&(t.tv_sec), &tm);
+					strftime (t_str, 26, "%Y-%m-%dT%H:%M:%SZ", &tm);
+				}
+				printf (" (struct FILETIME *) - %p\t (struct timeval) %s\t", &lpProp->value.ft, t_str);
 				break;
 			case PT_ERROR:
 				printf (" (error) - %p", lpProp->value.err);



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