evolution-data-server r8487 - in branches/EXCHANGE_MAPI_BRANCH: addressbook/backends/mapi calendar/backends/mapi camel/providers/mapi servers/mapi



Author: jjohnny
Date: Fri Feb 15 08:00:48 2008
New Revision: 8487
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8487&view=rev

Log:
Options to selectively fetch different streams.


Modified:
   branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/e-book-backend-mapi.c
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/e-cal-backend-mapi.c
   branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/ChangeLog
   branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.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-connection.h

Modified: branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/e-book-backend-mapi.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/e-book-backend-mapi.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/addressbook/backends/mapi/e-book-backend-mapi.c	Fri Feb 15 08:00:48 2008
@@ -748,7 +748,7 @@
 			mapi_id_t fid, mid;
 			
 			exchange_mapi_util_mapi_ids_from_uid (id, &fid, &mid);
-			contact = exchange_mapi_connection_fetch_item (priv->fid, mid, NULL, 0, NULL, create_contact_item, NULL);
+			contact = exchange_mapi_connection_fetch_item (priv->fid, mid, NULL, 0, NULL, create_contact_item, NULL, MAPI_OPTIONS_FETCH_ALL);
 
 			if (contact) {
 				e_contact_set (contact, E_CONTACT_BOOK_URI, priv->uri);
@@ -898,7 +898,7 @@
 
 			if (!exchange_mapi_connection_fetch_items (priv->fid, 
 								GetPropsList, n_GetPropsList, build_name_id_for_getprops, 
-								&res, create_contact_list_cb, &vcard_str)) {
+								   &res, create_contact_list_cb, &vcard_str, MAPI_OPTIONS_FETCH_ALL)) {
 				e_data_book_respond_get_contact_list (book, opid, GNOME_Evolution_Addressbook_OtherError, NULL);
 				return ;
 			}
@@ -1285,7 +1285,7 @@
 
 		//FIXME: We need to fetch only the query from the server live and not everything.
 		/* execute the query */
-		if (!exchange_mapi_connection_fetch_items (priv->fid, NULL, 0, NULL, NULL, create_contact_cb, book_view)) {
+		if (!exchange_mapi_connection_fetch_items (priv->fid, NULL, 0, NULL, NULL, create_contact_cb, book_view, MAPI_OPTIONS_FETCH_ALL)) {
 			if (e_flag_is_set (closure->running))
 				e_data_book_view_notify_complete (book_view, 
 								  GNOME_Evolution_Addressbook_OtherError);	
@@ -1388,7 +1388,7 @@
 	
 	e_file_cache_freeze_changes (E_FILE_CACHE (priv->cache));
 	
-	if (!exchange_mapi_connection_fetch_items (priv->fid, NULL, 0, NULL, NULL, cache_contact_cb, ebmapi)) {
+	if (!exchange_mapi_connection_fetch_items (priv->fid, NULL, 0, NULL, NULL, cache_contact_cb, ebmapi, MAPI_OPTIONS_FETCH_ALL)) {
 		printf("Error during caching addressbook\n");
 		e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
 		return NULL;
@@ -1430,7 +1430,7 @@
 	
 	e_file_cache_freeze_changes (E_FILE_CACHE (priv->cache));
 	
-	if (!exchange_mapi_connection_fetch_items ( priv->fid, NULL, 0, NULL, &res, cache_contact_cb,ebmapi)) {
+	if (!exchange_mapi_connection_fetch_items ( priv->fid, NULL, 0, NULL, &res, cache_contact_cb,ebmapi, MAPI_OPTIONS_FETCH_ALL)) {
 		printf("Error during caching addressbook\n");
 		e_file_cache_thaw_changes (E_FILE_CACHE (priv->cache));
 		return NULL;

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	Fri Feb 15 08:00:48 2008
@@ -491,7 +491,7 @@
 	priv->cache_keys = e_cal_backend_cache_get_keys (cache);
 
 //	e_file_cache_freeze_changes (E_FILE_CACHE (cache));
-	if (!exchange_mapi_connection_fetch_items (priv->fid, GetPropsList, n_GetPropsList, build_name_id, NULL, get_changes_cb, cbmapi)) {
+	if (!exchange_mapi_connection_fetch_items (priv->fid, GetPropsList, n_GetPropsList, build_name_id, NULL, get_changes_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 (cache));
 		priv->cache_keys = NULL;
@@ -924,7 +924,7 @@
 	e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbmapi), progress_string, 99);
 
 //	e_file_cache_freeze_changes (E_FILE_CACHE (priv->cache));
-	if (!exchange_mapi_connection_fetch_items (priv->fid, GetPropsList, n_GetPropsList, build_name_id, NULL, cache_create_cb, cbmapi)) {
+	if (!exchange_mapi_connection_fetch_items (priv->fid, GetPropsList, n_GetPropsList, build_name_id, NULL, 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/camel/providers/mapi/camel-mapi-folder.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/camel/providers/mapi/camel-mapi-folder.c	Fri Feb 15 08:00:48 2008
@@ -274,10 +274,6 @@
 		item->header.flags |= CAMEL_MESSAGE_SEEN;
 	if ((*flags & MSGFLAG_HASATTACH) != 0)
 		item->header.flags |= CAMEL_MESSAGE_ATTACHMENTS;
-/* 	printf("%s(%d):%s:subject : %s \n from : %s\nto : %s\n cc : %s\n", __FILE__, */
-/* 	       __LINE__, __PRETTY_FUNCTION__, item->header.subject, */
-/* 	       item->header.from, item->header.to, item->header.cc); */
-/* 	debug_mapi_property_dump (array); */
 
 	slist = g_slist_append (slist, item);
 	mapi_folder->priv->item_list = slist;
@@ -649,7 +645,7 @@
 
 		status = exchange_mapi_connection_fetch_items (temp_folder_id, summary_prop_list, 
 							       G_N_ELEMENTS (summary_prop_list), NULL, NULL, 
-							       fetch_items_cb, folder);
+							       fetch_items_cb, folder, 0);
 
 		if (!status) {
 			camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Fetch items failed"));
@@ -973,7 +969,9 @@
 	exchange_mapi_util_mapi_ids_from_uid (uid, &id_folder, &id_message);
 
 	folder_id =  g_strdup (camel_mapi_store_folder_id_lookup (mapi_store, folder->full_name)) ;
-	item = exchange_mapi_connection_fetch_item (id_folder, id_message, NULL, 0, NULL, fetch_item_cb, NULL);
+	item = exchange_mapi_connection_fetch_item (id_folder, id_message, NULL, 0, 
+						    NULL, fetch_item_cb, NULL, 
+						    MAPI_OPTIONS_FETCH_ATTACHMENTS | MAPI_OPTIONS_FETCH_BODY_STREAM | MAPI_OPTIONS_FETCH_BODY_STREAM);
 
 	if (item == NULL) {
 		camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Could not get message"));

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	Fri Feb 15 08:00:48 2008
@@ -747,7 +747,7 @@
 					BuildNameID build_name_id, 
 					struct mapi_SRestriction *res,
 					FetchItemsCallback cb, 
-					gpointer data)
+					gpointer data, guint32 options)
 {
 	enum MAPISTATUS retval;
 	TALLOC_CTX *mem_ctx;
@@ -791,6 +791,8 @@
 	GetPropsTagArray = talloc_zero(mem_ctx, struct SPropTagArray);
 	GetPropsTagArray->cValues = 0;
 
+	// FIXME : Why are we fetching all these props ?
+
 	SPropTagArray = set_SPropTagArray(mem_ctx, 0xA,
 					  PR_FID,
 					  PR_MID,
@@ -893,15 +895,17 @@
 			goto loop_cleanup;
 		}
 
-		if (has_attach && *has_attach) {
+		if (has_attach && *has_attach && (MAPI_OPTIONS_FETCH_ATTACHMENTS & options)) {
 			g_print ("%s(%d): %s: Fetching Attachments \n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
 			exchange_mapi_util_get_attachments (&obj_message, &attach_list);
 		}
 
-		exchange_mapi_util_get_recipients (&obj_message, &recip_list);
+		if ( options & MAPI_OPTIONS_FETCH_RECIPIENTS) 
+			exchange_mapi_util_get_recipients (&obj_message, &recip_list);
 
 		/* get the main body stream no matter what */
-		exchange_mapi_util_read_body_stream (&obj_message, &stream_list);
+		if (options & MAPI_OPTIONS_FETCH_BODY_STREAM)
+			exchange_mapi_util_read_body_stream (&obj_message, &stream_list);
 
 		if (GetPropsTagArray->cValues) {
 			struct SPropValue *lpProps;
@@ -924,9 +928,11 @@
 			uint32_t z;
 
 			/* just to get all the other streams */
-			for (z=0; z < properties_array.cValues; z++)
-				if ((properties_array.lpProps[z].ulPropTag & 0xFFFF) == PT_BINARY) 
+			for (z=0; z < properties_array.cValues; z++) {
+				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);
 
@@ -969,9 +975,8 @@
 gpointer
 exchange_mapi_connection_fetch_item (mapi_id_t fid, mapi_id_t mid, 
 				     const uint32_t *GetPropsList, const uint16_t cn_props, 
-				     BuildNameID build_name_id, 
-				     FetchItemCallback cb, 
-				     gpointer data)
+				     BuildNameID build_name_id, FetchItemCallback cb, 
+				     gpointer data, guint32 options)
 {
 	enum MAPISTATUS retval;
 	TALLOC_CTX *mem_ctx;
@@ -1055,13 +1060,16 @@
 	}
 
 	/* Fetch attachments */
-	exchange_mapi_util_get_attachments (&obj_message, &attach_list);
+	if (options & MAPI_OPTIONS_FETCH_ATTACHMENTS) 
+		exchange_mapi_util_get_attachments (&obj_message, &attach_list);
 
 	/* Fetch recipients */
-	exchange_mapi_util_get_recipients (&obj_message, &recip_list);
+	if (options & MAPI_OPTIONS_FETCH_RECIPIENTS) 
+		exchange_mapi_util_get_recipients (&obj_message, &recip_list);
 
 	/* get the main body stream no matter what */
-	exchange_mapi_util_read_body_stream (&obj_message, &stream_list);
+	if (options & MAPI_OPTIONS_FETCH_BODY_STREAM)
+		exchange_mapi_util_read_body_stream (&obj_message, &stream_list);
 
 	if (GetPropsTagArray->cValues) {
 		struct SPropValue *lpProps;
@@ -1085,7 +1093,7 @@
 
 		/* just to get all the other streams */
 		for (z=0; z < properties_array.cValues; z++)
-			if ((properties_array.lpProps[z].ulPropTag & 0xFFFF) == PT_BINARY)
+			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-connection.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-connection.h	Fri Feb 15 08:00:48 2008
@@ -32,6 +32,18 @@
 	RECIPIENT_BCC  = 0x3
 } ExchangeMAPIRecipientType;
 
+typedef enum _ExchangeMapiOptions {
+	MAPI_OPTIONS_FETCH_ATTACHMENTS = 1<<0,
+	MAPI_OPTIONS_FETCH_RECIPIENTS = 1<<1,
+	MAPI_OPTIONS_FETCH_BODY_STREAM = 1<<2,
+	MAPI_OPTIONS_FETCH_GENERIC_STREAMS = 1<<3
+} ExchangeMapiOptions;
+
+#define MAPI_OPTIONS_FETCH_ALL MAPI_OPTIONS_FETCH_ATTACHMENTS | \
+	                       MAPI_OPTIONS_FETCH_RECIPIENTS | \
+	                       MAPI_OPTIONS_FETCH_BODY_STREAM | \
+	                       MAPI_OPTIONS_FETCH_GENERIC_STREAMS
+
 /* FIXME: need to accomodate rendering position */
 typedef struct {
 	GByteArray *value;
@@ -81,14 +93,13 @@
 gpointer
 exchange_mapi_connection_fetch_item (mapi_id_t fid, mapi_id_t mid, 
 				     const uint32_t *GetPropsList, const uint16_t cn_props, 
-				     BuildNameID build_name_id, 
-				     FetchItemCallback cb, 
-				     gpointer data);
+				     BuildNameID build_name_id, FetchItemCallback cb, 
+				     gpointer data, guint32 options);
 gboolean
 exchange_mapi_connection_fetch_items (mapi_id_t fid, 
 				      const uint32_t *GetPropsList, const uint16_t cn_props, BuildNameID build_name_id,  
 				      struct mapi_SRestriction *res, 
-				      FetchItemsCallback cb, gpointer data);
+				      FetchItemsCallback cb, gpointer data, guint32 options);
 
 mapi_id_t 
 exchange_mapi_create_folder (uint32_t olFolder, mapi_id_t pfid, const char *name);



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