evolution-data-server r9711 - in branches/EXCHANGE_MAPI_BRANCH: camel/providers/mapi servers/mapi



Author: jjohnny
Date: Fri Oct 31 03:34:16 2008
New Revision: 9711
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9711&view=rev

Log:
Servers/mapi :  FetchCallback signature. Wrapped params in a struct.

Modified:
   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/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 Oct 31 03:34:16 2008
@@ -176,8 +176,7 @@
 	exchange_mapi_util_free_stream_list (&item->generic_streams);
 }
 static gboolean
-fetch_items_cb (struct mapi_SPropValue_array *array, const mapi_id_t fid, const mapi_id_t mid, 
-		GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
+fetch_items_cb (FetchItemsCallbackData *item_data, gpointer data)
 {
 	fetch_items_data *fi_data = (fetch_items_data *)data;
 	
@@ -192,21 +191,21 @@
 	MapiItem *item = g_new0(MapiItem , 1);
 
 	if (camel_debug_start("mapi:folder")) {
-		exchange_mapi_debug_property_dump (array);
+		exchange_mapi_debug_property_dump (item_data->properties);
 		camel_debug_end();
 	}
 
-	item->fid = fid;
-	item->mid = mid;
+	item->fid = item_data->fid;
+	item->mid = item_data->mid;
 
-	item->header.subject = g_strdup (find_mapi_SPropValue_data (array, PR_NORMALIZED_SUBJECT));
-	item->header.to = g_strdup (find_mapi_SPropValue_data (array, PR_DISPLAY_TO));
-	item->header.cc = g_strdup (find_mapi_SPropValue_data (array, PR_DISPLAY_CC));
-	item->header.bcc = g_strdup (find_mapi_SPropValue_data (array, PR_DISPLAY_BCC));
-	item->header.from = g_strdup (find_mapi_SPropValue_data (array, PR_SENT_REPRESENTING_NAME));
-	item->header.size = *(glong *)(find_mapi_SPropValue_data (array, PR_MESSAGE_SIZE));
+	item->header.subject = g_strdup (find_mapi_SPropValue_data (item_data->properties, PR_NORMALIZED_SUBJECT));
+	item->header.to = g_strdup (find_mapi_SPropValue_data (item_data->properties, PR_DISPLAY_TO));
+	item->header.cc = g_strdup (find_mapi_SPropValue_data (item_data->properties, PR_DISPLAY_CC));
+	item->header.bcc = g_strdup (find_mapi_SPropValue_data (item_data->properties, PR_DISPLAY_BCC));
+	item->header.from = g_strdup (find_mapi_SPropValue_data (item_data->properties, PR_SENT_REPRESENTING_NAME));
+	item->header.size = *(glong *)(find_mapi_SPropValue_data (item_data->properties, PR_MESSAGE_SIZE));
 
-	delivery_date = (struct FILETIME *)find_mapi_SPropValue_data(array, PR_MESSAGE_DELIVERY_TIME);
+	delivery_date = (struct FILETIME *)find_mapi_SPropValue_data(item_data->properties, PR_MESSAGE_DELIVERY_TIME);
 	if (delivery_date) {
 		ntdate = delivery_date->dwHighDateTime;
 		ntdate = ntdate << 32;
@@ -214,7 +213,7 @@
 		item->header.recieved_time = nt_time_to_unix(ntdate);
 	}
 
-	delivery_date = (struct FILETIME *)find_mapi_SPropValue_data(array, PR_LAST_MODIFICATION_TIME);
+	delivery_date = (struct FILETIME *)find_mapi_SPropValue_data(item_data->properties, PR_LAST_MODIFICATION_TIME);
 	if (delivery_date) {
 		ntdate = delivery_date->dwHighDateTime;
 		ntdate = ntdate << 32;
@@ -226,7 +225,7 @@
 	if (timeval_compare (item_modification_time, fi_data->last_modification_time) == 1) 
 			fi_data->last_modification_time = item_modification_time;
 
-	flags = (long *)find_mapi_SPropValue_data (array, PR_MESSAGE_FLAGS);
+	flags = (long *)find_mapi_SPropValue_data (item_data->properties, PR_MESSAGE_FLAGS);
 	if ((*flags & MSGFLAG_READ) != 0)
 		item->header.flags |= CAMEL_MESSAGE_SEEN;
 	if ((*flags & MSGFLAG_HASATTACH) != 0)
@@ -769,8 +768,7 @@
 }
 
 static gboolean
-fetch_item_cb 	(struct mapi_SPropValue_array *array, mapi_id_t fid, mapi_id_t mid, 
-		GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
+fetch_item_cb (FetchItemsCallbackData *item_data, gpointer data)
 {
 	long *flags;
 	struct FILETIME *delivery_date;
@@ -783,23 +781,25 @@
 	MapiItem **i = (MapiItem **)data;
 
 	if (camel_debug_start("mapi:folder")) {
-		exchange_mapi_debug_property_dump (array);
+		exchange_mapi_debug_property_dump (item_data->properties);
 		camel_debug_end();
 	}
 
-	item->fid = fid;
-	item->mid = mid;
+	item->fid = item_data->fid;
+	item->mid = item_data->mid;
 
-	item->header.subject = g_strdup (exchange_mapi_util_find_array_propval (array, PR_NORMALIZED_SUBJECT));
-	item->header.to = g_strdup (exchange_mapi_util_find_array_propval (array, PR_DISPLAY_TO));
-	item->header.cc = g_strdup (exchange_mapi_util_find_array_propval (array, PR_DISPLAY_CC));
-	item->header.bcc = g_strdup (exchange_mapi_util_find_array_propval (array, PR_DISPLAY_BCC));
-	item->header.from = g_strdup (exchange_mapi_util_find_array_propval (array, PR_SENT_REPRESENTING_NAME));
-	item->header.size = *(glong *)(find_mapi_SPropValue_data (array, PR_MESSAGE_SIZE));
+	item->header.subject = g_strdup (exchange_mapi_util_find_array_propval (item_data->properties, PR_NORMALIZED_SUBJECT));
+	item->header.to = g_strdup (exchange_mapi_util_find_array_propval (item_data->properties, PR_DISPLAY_TO));
+	item->header.cc = g_strdup (exchange_mapi_util_find_array_propval (item_data->properties, PR_DISPLAY_CC));
+	item->header.bcc = g_strdup (exchange_mapi_util_find_array_propval (item_data->properties, PR_DISPLAY_BCC));
+	item->header.from = g_strdup (exchange_mapi_util_find_array_propval (item_data->properties, PR_SENT_REPRESENTING_NAME));
+	item->header.size = *(glong *)(find_mapi_SPropValue_data (item_data->properties, PR_MESSAGE_SIZE));
 
-	msg_class = (const char *) exchange_mapi_util_find_array_propval (array, PR_MESSAGE_CLASS);
+	msg_class = (const char *) exchange_mapi_util_find_array_propval (item_data->properties, PR_MESSAGE_CLASS);
 	if (g_str_has_prefix (msg_class, IPM_SCHEDULE_MEETING_PREFIX)) {
-		gchar *appointment_body_str = (gchar *) exchange_mapi_cal_util_camel_helper (array, streams, recipients, attachments);
+		gchar *appointment_body_str = (gchar *) exchange_mapi_cal_util_camel_helper (item_data->properties, 
+											     item_data->streams, 
+											     item_data->recipients, item_data->attachments);
 
 		body = g_new0(ExchangeMAPIStream, 1);
 		body->proptag = PR_BODY;
@@ -810,16 +810,16 @@
 
 		item->is_cal = TRUE;
 	} else { 
-		if (!((body = exchange_mapi_util_find_stream (streams, PR_HTML)) || 
-		      (body = exchange_mapi_util_find_stream (streams, PR_BODY))))
-			body = exchange_mapi_util_find_stream (streams, PR_BODY_UNICODE);
+		if (!((body = exchange_mapi_util_find_stream (item_data->streams, PR_HTML)) || 
+		      (body = exchange_mapi_util_find_stream (item_data->streams, PR_BODY))))
+			body = exchange_mapi_util_find_stream (item_data->streams, PR_BODY_UNICODE);
 
 		item->msg.body_parts = g_slist_append (item->msg.body_parts, body);
 
 		item->is_cal = FALSE;
 	}
 
-	delivery_date = (struct FILETIME *)find_mapi_SPropValue_data(array, PR_MESSAGE_DELIVERY_TIME);
+	delivery_date = (struct FILETIME *)find_mapi_SPropValue_data(item_data->properties, PR_MESSAGE_DELIVERY_TIME);
 	if (delivery_date) {
 		ntdate = delivery_date->dwHighDateTime;
 		ntdate = ntdate << 32;
@@ -827,13 +827,13 @@
 		item->header.recieved_time = nt_time_to_unix(ntdate);
 	}
 
-	flags = (long *)find_mapi_SPropValue_data (array, PR_MESSAGE_FLAGS);
+	flags = (long *)find_mapi_SPropValue_data (item_data->properties, PR_MESSAGE_FLAGS);
 	if ((*flags & MSGFLAG_READ) != 0)
 		item->header.flags |= CAMEL_MESSAGE_SEEN;
 	if ((*flags & MSGFLAG_HASATTACH) != 0)
 		item->header.flags |= CAMEL_MESSAGE_ATTACHMENTS;
 
-	item->attachments = attachments;
+	item->attachments = item_data->attachments;
 
 	*i = item;
 

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 Oct 31 03:34:16 2008
@@ -1177,9 +1177,21 @@
 			mapi_SPropValue_array_named(&obj_message, &properties_array);
 
 			/* NOTE: stream_list, recipient_list and attach_list should be freed by the callback */
-			if (!cb (&properties_array, *pfid, *pmid, stream_list, recip_list, attach_list, data)) {
+			FetchItemsCallbackData *item_data = g_new0 (FetchItemsCallbackData, 1);
+			item_data->fid = *pfid;
+			item_data->mid = *pmid;
+			item_data->properties = &properties_array;
+			item_data->streams = stream_list;
+			item_data->recipients = recip_list;
+			item_data->attachments = attach_list;
+			item_data->total = SRowSet.cRows;
+			item_data->index = i;
+
+			if (!cb (item_data, data)) {
 				g_warning ("\n%s(%d): %s: Callback failed for message-id %016llX ", __FILE__, __LINE__, __PRETTY_FUNCTION__, *pmid);
 			}
+
+			g_free (item_data);
 		}
 
 		if (GetPropsTagArray->cValues) 
@@ -1333,8 +1345,18 @@
 
 		mapi_SPropValue_array_named(&obj_message, &properties_array);
 
+		FetchItemsCallbackData *item_data = g_new0 (FetchItemsCallbackData, 1);
+		item_data->fid = &fid;
+		item_data->mid = &mid;
+		item_data->properties = &properties_array;
+		item_data->streams = stream_list;
+		item_data->recipients = recip_list;
+		item_data->attachments = attach_list;
+
 		/* NOTE: stream_list, recipient_list and attach_list should be freed by the callback */
-		cb (&properties_array, fid, mid, stream_list, recip_list, attach_list, data);
+		cb (item_data, data);
+
+		g_free (item_data);
 	}
 
 //	if (GetPropsTagArray->cValues) 

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 Oct 31 03:34:16 2008
@@ -88,12 +88,22 @@
 	GSList *objects; 
 } ExchangeMAPIAttachment;
 
+typedef struct {
+	struct mapi_SPropValue_array *properties;
+	mapi_id_t fid;
+	mapi_id_t mid;
+	GSList *attachments;
+	GSList *recipients;
+	GSList *streams;
+	guint total; /*Total number of results*/
+	guint index; /*Index of this Item*/
+} FetchItemsCallbackData;
+
 struct id_list {
 	mapi_id_t id;
 };
 
-typedef gboolean (*FetchCallback) 	(struct mapi_SPropValue_array *, const mapi_id_t fid, const mapi_id_t mid, 
-					GSList *streams, GSList *recipients, GSList *attachments, gpointer data);
+typedef gboolean (*FetchCallback) 	(FetchItemsCallbackData *item_data, gpointer data);
 typedef gboolean (*BuildNameID) 	(struct mapi_nameid *nameid, gpointer data);
 typedef int 	 (*BuildProps) 		(struct SPropValue **, struct SPropTagArray *, gpointer data);
 



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