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



Author: msuman
Date: Sun Jul  6 10:04:47 2008
New Revision: 9096
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9096&view=rev

Log:
Set GlobalIDs on all appointments, changes to support meeting updates, typo fixes, added a utility function.

Modified:
   branches/EXCHANGE_MAPI_BRANCH/calendar/backends/mapi/ChangeLog
   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-cal-utils.c
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.h
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.c
   branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h

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	Sun Jul  6 10:04:47 2008
@@ -1176,6 +1176,65 @@
 	return id;
 }
 
+static gboolean 
+capture_req_props (struct mapi_SPropValue_array *properties, const mapi_id_t fid, const mapi_id_t mid, 
+		   GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
+{
+	struct cbdata *cbdata = (struct cbdata *) data;
+	const uint32_t *ui32;
+
+	ui32 = (const uint32_t *)find_mapi_SPropValue_data(properties, PR_OWNER_APPT_ID);
+	if (ui32)
+		cbdata->appt_id = *ui32;
+	ui32 = (const uint32_t *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_LONG, 0x8201));
+	if (ui32)
+		cbdata->appt_seq = *ui32;
+	cbdata->cleanglobalid = (const struct SBinary *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0023));
+	cbdata->globalid = (const struct SBinary *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0003));
+
+	return TRUE;
+}
+
+static void
+get_server_data (ECalBackendMAPI *cbmapi, icalcomponent *comp, struct cbdata *cbdata)
+{
+	ECalBackendMAPIPrivate *priv = cbmapi->priv;
+	const char *uid;
+	mapi_id_t mid;
+	struct mapi_SRestriction res;
+	struct SPropValue sprop;
+	struct SBinary sb;
+	uint32_t proptag = 0x00000000;
+	struct SPropTagArray *array;
+
+	uid = icalcomponent_get_uid (comp);
+	exchange_mapi_util_mapi_id_from_string (uid, &mid);
+	if (exchange_mapi_connection_fetch_item (priv->fid, mid, 
+					NULL, 0, 
+					NULL, NULL, 
+					capture_req_props, cbdata, 
+					MAPI_OPTIONS_FETCH_GENERIC_STREAMS))
+
+		return;
+
+	array = exchange_mapi_util_resolve_named_prop (priv->olFolder, priv->fid, 0x0023, PSETID_Meeting);
+	proptag = array->aulPropTag[0];
+
+	res.rt = RES_PROPERTY;
+	res.res.resProperty.relop = RELOP_EQ;
+	res.res.resProperty.ulPropTag = proptag;
+
+	exchange_mapi_cal_util_generate_globalobjectid (TRUE, uid, &sb);
+
+	set_SPropValue_proptag (&sprop, proptag, (const void *) &sb);
+	cast_mapi_SPropValue (&(res.res.resProperty.lpProp), &sprop);
+
+	exchange_mapi_connection_fetch_items (priv->fid, &res, 
+					NULL, 0, 
+					NULL, NULL, 
+					capture_req_props, cbdata, 
+					MAPI_OPTIONS_FETCH_GENERIC_STREAMS);
+}
 
 static ECalBackendSyncStatus 
 e_cal_backend_mapi_create_object (ECalBackendSync *backend, EDataCal *cal, char **calobj, char **uid)
@@ -1185,11 +1244,13 @@
 	icalcomponent_kind kind;
 	icalcomponent *icalcomp;
 	ECalComponent *comp;
+	const char *compuid;
 	mapi_id_t mid = 0;
 	gchar *tmp = NULL;
 	GSList *recipients = NULL;
 	GSList *attachments = NULL;
 	struct cbdata cbdata;
+	struct SBinary globalid;
 
 	cbmapi = E_CAL_BACKEND_MAPI (backend);
 	priv = cbmapi->priv;
@@ -1238,13 +1299,22 @@
 		case CAL_MODE_REMOTE:
 			/* Create an appointment */
 			cbdata.comp = comp;
-			cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING;
+			cbdata.is_modify = FALSE;
 			cbdata.msgflags = MSGFLAG_READ;
-			cbdata.new_appt_id = get_new_appt_id (cbmapi);
+			cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING;
+			cbdata.appt_id = get_new_appt_id (cbmapi);
+			cbdata.appt_seq = 0;
+			e_cal_component_get_uid (comp, &compuid);
+			exchange_mapi_cal_util_generate_globalobjectid (TRUE, compuid, &globalid);
+			cbdata.globalid = &globalid;
+			cbdata.cleanglobalid = &globalid;
+
 			mid = exchange_mapi_create_item (priv->olFolder, priv->fid, 
 							exchange_mapi_cal_util_build_name_id, GINT_TO_POINTER(kind), 
 							exchange_mapi_cal_util_build_props, &cbdata, 
 							recipients, attachments, NULL, MAPI_OPTIONS_DONT_SUBMIT);
+			g_free (cbdata.props);
+//			g_free (globalid.lpb);
 			if (!mid) {
 				g_object_unref (comp);
 				exchange_mapi_util_free_recipient_list (&recipients);
@@ -1343,13 +1413,18 @@
 		exchange_mapi_util_mapi_id_from_string (uid, &mid);
 
 		cbdata.comp = comp;
-//		cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING;
+		cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING;
 		cbdata.msgflags = MSGFLAG_READ;
-		cbdata.new_appt_id = 0x0;
+		cbdata.is_modify = TRUE;
+
+		get_server_data (cbmapi, icalcomp, &cbdata);
+		cbdata.appt_seq += 1;
+
 		status = exchange_mapi_modify_item (priv->olFolder, priv->fid, mid, 
 						exchange_mapi_cal_util_build_name_id, GINT_TO_POINTER(kind), 
 						exchange_mapi_cal_util_build_props, &cbdata, 
 						NULL, NULL, MAPI_OPTIONS_DONT_SUBMIT);
+		g_free (cbdata.props);
 		if (!status) {
 			g_object_unref (comp);
 			g_object_unref (cache_comp);
@@ -1477,66 +1552,6 @@
 	return GNOME_Evolution_Calendar_Success;
 }
 
-static gboolean 
-capture_req_props (struct mapi_SPropValue_array *properties, const mapi_id_t fid, const mapi_id_t mid, 
-		   GSList *streams, GSList *recipients, GSList *attachments, gpointer data)
-{
-	struct cbdata *cbdata = (struct cbdata *) data;
-	const uint32_t *ui32;
-
-	ui32 = (const uint32_t *)find_mapi_SPropValue_data(properties, PR_OWNER_APPT_ID);
-	if (ui32)
-		cbdata->dup.owner_appt_id = *ui32;
-	ui32 = (const uint32_t *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_LONG, 0x8201));
-	if (ui32)
-		cbdata->dup.appt_seq = *ui32;
-	cbdata->dup.cleanglobalid = (const struct SBinary *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0023));
-	cbdata->dup.globalid = (const struct SBinary *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0003));
-
-	return TRUE;
-}
-
-static void
-get_server_data (ECalBackendMAPI *cbmapi, icalcomponent *comp, struct cbdata *cbdata)
-{
-	ECalBackendMAPIPrivate *priv = cbmapi->priv;
-	const char *uid;
-	mapi_id_t mid;
-	struct mapi_SRestriction res;
-	struct SPropValue sprop;
-	struct SBinary sb;
-	uint32_t proptag = 0x00000000;
-	struct SPropTagArray *array;
-
-	uid = icalcomponent_get_uid (comp);
-	exchange_mapi_util_mapi_id_from_string (uid, &mid);
-	if (exchange_mapi_connection_fetch_item (priv->fid, mid, 
-					NULL, 0, 
-					NULL, NULL, 
-					capture_req_props, cbdata, 
-					MAPI_OPTIONS_FETCH_GENERIC_STREAMS))
-
-		return;
-
-	array = exchange_mapi_util_resolve_named_prop (priv->olFolder, priv->fid, 0x0023, PSETID_Meeting);
-	proptag = array->aulPropTag[0];
-
-	res.rt = RES_PROPERTY;
-	res.res.resProperty.relop = RELOP_EQ;
-	res.res.resProperty.ulPropTag = proptag;
-
-	exchange_mapi_cal_util_generate_globalobjectid (TRUE, uid, &sb);
-
-	set_SPropValue_proptag (&sprop, proptag, (const void *) &sb);
-	cast_mapi_SPropValue (&(res.res.resProperty.lpProp), &sprop);
-
-	exchange_mapi_connection_fetch_items (priv->fid, &res, 
-					NULL, 0, 
-					NULL, NULL, 
-					capture_req_props, cbdata, 
-					MAPI_OPTIONS_FETCH_GENERIC_STREAMS);
-}
-
 static ECalBackendSyncStatus 
 e_cal_backend_mapi_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj, 
 				 GList **users, char **modified_calobj)
@@ -1598,7 +1613,7 @@
 			cbdata.ownerid = e_cal_backend_mapi_get_owner_email (cbmapi);
 
 			cbdata.comp = comp;
-			cbdata.new_appt_id = 0x0;
+			cbdata.is_modify = TRUE;
 			switch (method) {
 			case ICAL_METHOD_REQUEST : 
 				cbdata.meeting_type = MEETING_REQUEST;
@@ -1620,6 +1635,7 @@
 							exchange_mapi_cal_util_build_name_id, GINT_TO_POINTER(kind), 
 							exchange_mapi_cal_util_build_props, &cbdata, 
 							recipients, attachments, NULL, 0);
+			g_free (cbdata.props);
 			if (!mid) {
 				g_object_unref (comp);
 				exchange_mapi_util_free_recipient_list (&recipients);

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.c	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.c	Sun Jul  6 10:04:47 2008
@@ -374,7 +374,7 @@
 			prop = icalproperty_new_organizer (val);
 
 			/* CN */
-			str = (const char *) get_SPropValue(recip->out.all_lpProps, PR_RECIPIENT_DISPLAY_NAME);
+			str = (const char *) exchange_mapi_util_find_SPropVal_array_propval(recip->out.all_lpProps, PR_RECIPIENT_DISPLAY_NAME);
 			if (str) {
 				param = icalparameter_new_cn (str);
 				icalproperty_add_parameter (prop, param);
@@ -383,7 +383,7 @@
 			prop = icalproperty_new_attendee (val);
 
 			/* CN */
-			str = (const char *) get_SPropValue(recip->out.all_lpProps, PR_RECIPIENT_DISPLAY_NAME);
+			str = (const char *) exchange_mapi_util_find_SPropVal_array_propval(recip->out.all_lpProps, PR_RECIPIENT_DISPLAY_NAME);
 			if (str) {
 				param = icalparameter_new_cn (str);
 				icalproperty_add_parameter (prop, param);
@@ -1130,12 +1130,12 @@
 	set_SPropValue_proptag(&props[i++], PR_PRIORITY, (const void *) &flag32); 		/* prop count: 7 */
 
 	set_SPropValue_proptag(&props[i++], PR_SENT_REPRESENTING_NAME, 
-		(const void *) cbdata->ownerid);
+		(const void *) cbdata->ownername);
 	text = "SMTP";
 	set_SPropValue_proptag(&props[i++], PR_SENT_REPRESENTING_ADDRTYPE, 
 		(const void *) text);
 	set_SPropValue_proptag(&props[i++], PR_SENT_REPRESENTING_EMAIL_ADDRESS, 
-		(const void *) cbdata->ownername);
+		(const void *) cbdata->ownerid);
 	set_SPropValue_proptag(&props[i++], PR_SENDER_NAME, 
 		(const void *) cbdata->username);
 	text = "SMTP";
@@ -1224,7 +1224,7 @@
 
 	if (kind == ICAL_VEVENT_COMPONENT) {
 		const char *mapi_tzid;
-		struct SBinary start_tz, end_tz, globalid; 
+		struct SBinary start_tz, end_tz; 
 
 		/* Busy Status */
 		flag32 = olBusy; 	/* default */
@@ -1290,6 +1290,15 @@
 		flag32 = rectypeNone ;
 		set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RECURTYPE], (const void *) &flag32);
 
+		flag32 = cbdata->appt_id;
+		set_SPropValue_proptag(&props[i++], PR_OWNER_APPT_ID, (const void *) &flag32);
+
+		flag32 = cbdata->appt_seq;
+		set_SPropValue_proptag(&props[i++],  proptag_array->aulPropTag[I_APPT_SEQ], (const void *) &flag32);
+
+		set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_CLEANGUID], (const void *) cbdata->cleanglobalid);
+		set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_GUID], (const void *) cbdata->globalid);
+
 		switch (cbdata->meeting_type) {
 		case MEETING_OBJECT :
 			flag32 = e_cal_component_has_recurrences (comp) ? RecurMeet : SingleMeet; 
@@ -1310,14 +1319,6 @@
 			b = 0;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
 
-			flag32 = cbdata->new_appt_id;
-			set_SPropValue_proptag(&props[i++], PR_OWNER_APPT_ID, (const void *) &flag32);
-
-			e_cal_component_get_uid (comp, &uid);
-			exchange_mapi_cal_util_generate_globalobjectid (TRUE, uid, &globalid);
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_CLEANGUID], (const void *) &globalid);
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_GUID], (const void *) &globalid);
-
 			break;
 		case MEETING_REQUEST :
 			flag32 = 0xFFFFFFFF;  /* no idea why this has to be -1, but that's what the docs say */
@@ -1329,7 +1330,7 @@
 			flag32 = olMeetingReceived;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_MEETINGSTATUS], (const void *) &flag32);
 
-			flag32 = mtgRequest; 
+			flag32 = (cbdata->appt_seq == 0) ? mtgRequest : mtgFull; 
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
 
 			flag32 = olResponseNotResponded;
@@ -1338,12 +1339,6 @@
 			b = 1;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
 
-			flag32 = cbdata->dup.owner_appt_id;
-			set_SPropValue_proptag(&props[i++], PR_OWNER_APPT_ID, (const void *) &flag32);
-
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_CLEANGUID], (const void *) cbdata->dup.cleanglobalid);
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_GUID], (const void *) cbdata->dup.globalid);
-
 			break;
 		case MEETING_RESPONSE : 
 			flag32 = RespAccept; 
@@ -1457,6 +1452,8 @@
 	}
 
 	*value = props;
+	/* Free this memory at the backends. */
+	cbdata->props = props;
 
 	g_print ("\nEnded up setting %d props\n", i);
 

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.h	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-cal-utils.h	Sun Jul  6 10:04:47 2008
@@ -42,19 +42,20 @@
 	MEETING_RESPONSE = (1 << 3)
 } MAPIMeetingOptions;
 
-struct dup_data {
-	struct SBinary *globalid;
-	struct SBinary *cleanglobalid;
-	uint32_t owner_appt_id;
-	uint32_t appt_seq;
-};
-
 struct cbdata { 
 	ECalComponent *comp;
-	MAPIMeetingOptions meeting_type;
+	struct SPropValue *props;
+	gboolean is_modify;
+
 	uint32_t msgflags;
-	uint32_t new_appt_id;
-	struct dup_data dup;
+
+	/* These are appt specific data */ 
+	MAPIMeetingOptions meeting_type;
+	uint32_t appt_id;
+	uint32_t appt_seq;
+	struct SBinary *globalid;
+	struct SBinary *cleanglobalid;
+
 	const char *username;
 	const char *userid;
 	const char *ownername;

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	Sun Jul  6 10:04:47 2008
@@ -103,6 +103,43 @@
 }
 
 /*
+ * Retrieve the property value for a given SPropValue and property tag.  
+ *
+ * If the property type is a string: fetch PT_STRING8 then PT_UNICODE
+ * in case the desired property is not available in first choice.
+ *
+ * Fetch property normally for any others properties
+ */
+/* NOTE: For now, since this function has special significance only for
+ * 'string' type properties, callers should (preferably) use it for fetching 
+ * such properties alone. If callers are sure that proptag would, for instance, 
+ * return an 'int' or a 'systime', they should prefer find_SPropValue_data.
+ */
+void *
+exchange_mapi_util_find_SPropVal_array_propval (struct SPropValue *values, uint32_t proptag)
+{
+	if (((proptag & 0xFFFF) == PT_STRING8) ||
+	    ((proptag & 0xFFFF) == PT_UNICODE)) {
+		const char 	*str;
+
+		proptag = (proptag & 0xFFFF0000) | PT_STRING8;
+		str = (const char *)get_SPropValue(values, proptag);
+		if (str) 
+			return (void *)str;
+
+		proptag = (proptag & 0xFFFF0000) | PT_UNICODE;
+		str = (const char *)get_SPropValue(values, proptag);
+		return (void *)str;
+	} 
+
+	/* NOTE: Similar generalizations (if any) for other property types 
+	 * can be made here. 
+	 */
+
+	return (void *)get_SPropValue(values, proptag);
+}
+
+/*
  * Retrieve the property value for a given SRow and property tag.  
  *
  * If the property type is a string: fetch PT_STRING8 then PT_UNICODE

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-utils.h	Sun Jul  6 10:04:47 2008
@@ -44,6 +44,8 @@
 exchange_mapi_util_mapi_ids_from_uid (const char *str, mapi_id_t *fid, mapi_id_t *mid);
 
 void *
+exchange_mapi_util_find_SPropVal_array_propval (struct SPropValue *values, uint32_t proptag);
+void *
 exchange_mapi_util_find_row_propval (struct SRow *aRow, uint32_t proptag);
 void *
 exchange_mapi_util_find_array_propval (struct mapi_SPropValue_array *properties, uint32_t proptag);



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