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



Author: msuman
Date: Tue Aug 19 08:45:06 2008
New Revision: 9394
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9394&view=rev

Log:
Support for accept/decline from mail folders, related changes.

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

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 Aug 19 08:45:06 2008
@@ -1294,6 +1294,7 @@
 			cbdata.is_modify = FALSE;
 			cbdata.msgflags = MSGFLAG_READ;
 			cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING;
+			cbdata.resp = (recipients != NULL) ? olResponseOrganized : olResponseNone;
 			cbdata.appt_id = exchange_mapi_cal_util_get_new_appt_id (priv->fid);
 			cbdata.appt_seq = 0;
 			e_cal_component_get_uid (comp, &compuid);
@@ -1359,6 +1360,41 @@
 	return (!g_ascii_strcasecmp(orgid, ownerid) ? TRUE : FALSE);
 }
 
+static OlResponseStatus 
+get_trackstatus_from_partstat (icalparameter_partstat partstat)
+{
+	switch (partstat) {
+		case ICAL_PARTSTAT_ACCEPTED 	: return olResponseAccepted;
+		case ICAL_PARTSTAT_TENTATIVE 	: return olResponseTentative;
+		case ICAL_PARTSTAT_DECLINED 	: return olResponseDeclined;
+		default 			: return olResponseTentative;
+	}
+}
+
+static OlResponseStatus
+find_my_response (ECalBackendMAPI *cbmapi, ECalComponent *comp)
+{
+	icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
+	icalproperty *attendee; 
+	gchar *att = NULL;
+	OlResponseStatus val = olResponseTentative; 
+
+	att = g_strdup_printf ("MAILTO:%s", e_cal_backend_mapi_get_owner_email (cbmapi));
+	attendee = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
+	while (attendee) {
+		const char *value = icalproperty_get_attendee (attendee);
+		if (!g_ascii_strcasecmp (value, att)) {
+			icalparameter *param = icalproperty_get_first_parameter (attendee, ICAL_PARTSTAT_PARAMETER);
+			val = get_trackstatus_from_partstat (icalparameter_get_partstat(param));
+			break;
+		}
+		attendee = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
+	}
+	g_free (att);
+
+	return val;
+}
+
 static ECalBackendSyncStatus 
 e_cal_backend_mapi_modify_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj, 
 				  CalObjModType mod, char **old_object, char **new_object)
@@ -1427,6 +1463,11 @@
 		/* check if the object exists */
 		cache_comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
 		if (!cache_comp) {
+			get_deltas (cbmapi);
+			cache_comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+		}
+
+		if (!cache_comp) {
 			g_message ("CRITICAL : Could not find the object in cache");
 			g_object_unref (comp);
 			exchange_mapi_util_free_recipient_list (&recipients);
@@ -1436,12 +1477,13 @@
 		exchange_mapi_util_mapi_id_from_string (uid, &mid);
 
 		cbdata.comp = comp;
-		cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING;
 		cbdata.msgflags = MSGFLAG_READ;
 		cbdata.is_modify = TRUE;
 
 		get_server_data (cbmapi, icalcomp, &cbdata);
 		if (modifier_is_organizer(cbmapi, comp)) {
+			cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING; 
+			cbdata.resp = (recipients != NULL) ? olResponseOrganized : olResponseNone;
 			if (!no_increment)
 				cbdata.appt_seq += 1;
 			cbdata.username = e_cal_backend_mapi_get_user_name (cbmapi);
@@ -1449,7 +1491,10 @@
 			cbdata.userid = e_cal_backend_mapi_get_user_email (cbmapi);
 			cbdata.ownername = e_cal_backend_mapi_get_owner_name (cbmapi);
 			cbdata.owneridtype = "SMTP";
-			cbdata.ownerid = e_cal_backend_mapi_get_owner_email (cbmapi);			
+			cbdata.ownerid = e_cal_backend_mapi_get_owner_email (cbmapi);
+		} else {
+			cbdata.resp = (recipients != NULL) ? find_my_response(cbmapi, comp) : olResponseNone;
+			cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT_RCVD : NOT_A_MEETING; 
 		}
 
 		status = exchange_mapi_modify_item (priv->olFolder, priv->fid, mid, 
@@ -1583,7 +1628,8 @@
 }
 
 static ECalBackendSyncStatus 
-e_cal_backend_mapi_receive_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj)
+e_cal_backend_mapi_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj, 
+				 GList **users, char **modified_calobj)
 {
 	ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
 	ECalBackendMAPI *cbmapi;
@@ -1606,15 +1652,18 @@
 	if (!icalcomp)
 		return GNOME_Evolution_Calendar_InvalidObject;
 
+	*modified_calobj = NULL;
+	*users = NULL;
+
 	if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
-		gboolean stop = FALSE;
 		icalproperty_method method = icalcomponent_get_method (icalcomp);
 		icalcomponent *subcomp = icalcomponent_get_first_component (icalcomp, kind);
-		while (subcomp && !stop) {
+		while (subcomp) {
 			ECalComponent *comp = e_cal_component_new ();
-			gchar *rid = NULL; 
-			const char *uid;
-			gchar *old_object = NULL, *new_object = NULL; 
+			struct cbdata cbdata;
+			mapi_id_t mid = 0;
+			GSList *recipients = NULL;
+			GSList *attachments = NULL;
 
 			e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (subcomp));
 
@@ -1624,41 +1673,80 @@
 				return GNOME_Evolution_Calendar_OtherError;
 			}
 
-			e_cal_component_get_uid (comp, &uid);
-			rid = e_cal_component_get_recurid_as_string (comp);
+			if (e_cal_component_has_attachments (comp))
+				exchange_mapi_cal_util_fetch_attachments (comp, &attachments, priv->local_attachments_store);
+
+			cbdata.comp = comp;
+			cbdata.is_modify = TRUE;
+			cbdata.msgflags = MSGFLAG_READ | MSGFLAG_SUBMIT | MSGFLAG_UNSENT;
 
 			switch (method) {
-			case ICAL_METHOD_CANCEL :
-				status = e_cal_backend_mapi_remove_object (backend, cal, uid, rid, CALOBJ_MOD_THIS, &old_object, &new_object);
-				if (status != GNOME_Evolution_Calendar_Success)
-					stop = TRUE;
-				g_free (old_object);
-				g_free (new_object);
+			case ICAL_METHOD_REQUEST : 
+				cbdata.meeting_type = MEETING_REQUEST;
+				cbdata.resp = olResponseNotResponded;
+				if (e_cal_component_has_attendees (comp))
+					exchange_mapi_cal_util_fetch_recipients (comp, &recipients);
+				break;
+			case ICAL_METHOD_CANCEL : 
+				cbdata.meeting_type = MEETING_CANCEL;
+				cbdata.resp = olResponseNotResponded;
+				if (e_cal_component_has_attendees (comp))
+					exchange_mapi_cal_util_fetch_recipients (comp, &recipients);
+				break;
+			case ICAL_METHOD_RESPONSE : 
+				cbdata.meeting_type = MEETING_RESPONSE;
+				cbdata.resp = find_my_response (cbmapi, comp);
+				if (e_cal_component_has_organizer (comp))
+					exchange_mapi_cal_util_fetch_organizer (comp, &recipients);
 				break;
-			case ICAL_METHOD_REPLY :
-				/* responses are automatically updated even as they are rendered (just like in Outlook) */
-				status = GNOME_Evolution_Calendar_Success;
-				break; 
 			default :
+				cbdata.meeting_type = NOT_A_MEETING;
+				cbdata.resp = olResponseNone;
+				if (e_cal_component_has_attendees (comp))
+					exchange_mapi_cal_util_fetch_recipients (comp, &recipients);
 				break;
 			}
 
-			g_free (rid);
+			get_server_data (cbmapi, subcomp, &cbdata);
+			cbdata.username = e_cal_backend_mapi_get_user_name (cbmapi);
+			cbdata.useridtype = "SMTP";
+			cbdata.userid = e_cal_backend_mapi_get_user_email (cbmapi);
+			cbdata.ownername = e_cal_backend_mapi_get_owner_name (cbmapi);
+			cbdata.owneridtype = "SMTP";
+			cbdata.ownerid = e_cal_backend_mapi_get_owner_email (cbmapi);
+
+			mid = exchange_mapi_create_item (olFolderOutbox, 0, 
+							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);
+				exchange_mapi_util_free_attachment_list (&attachments);
+				return GNOME_Evolution_Calendar_OtherError;
+			} else 
+				status = GNOME_Evolution_Calendar_Success;
+
 			g_object_unref (comp);
+			exchange_mapi_util_free_recipient_list (&recipients);
+			exchange_mapi_util_free_attachment_list (&attachments);
 
 			subcomp = icalcomponent_get_next_component (icalcomp,
 								    e_cal_backend_get_kind (E_CAL_BACKEND (backend)));
 		}
 	}
 
-	return status;
-}
+	if (status == GNOME_Evolution_Calendar_Success)
+		*modified_calobj = g_strdup (calobj);
 
+	icalcomponent_free (icalcomp);
 
+	return GNOME_Evolution_Calendar_Success;
+}
 
 static ECalBackendSyncStatus 
-e_cal_backend_mapi_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj, 
-				 GList **users, char **modified_calobj)
+e_cal_backend_mapi_receive_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj)
 {
 	ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
 	ECalBackendMAPI *cbmapi;
@@ -1681,18 +1769,15 @@
 	if (!icalcomp)
 		return GNOME_Evolution_Calendar_InvalidObject;
 
-	*modified_calobj = NULL;
-	*users = NULL;
-
 	if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
+		gboolean stop = FALSE;
 		icalproperty_method method = icalcomponent_get_method (icalcomp);
 		icalcomponent *subcomp = icalcomponent_get_first_component (icalcomp, kind);
-		while (subcomp) {
+		while (subcomp && !stop) {
 			ECalComponent *comp = e_cal_component_new ();
-			struct cbdata cbdata;
-			mapi_id_t mid = 0;
-			GSList *recipients = NULL;
-			GSList *attachments = NULL;
+			gchar *rid = NULL; 
+			const char *uid;
+			gchar *old_object = NULL, *new_object = NULL, *comp_str; 
 
 			e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (subcomp));
 
@@ -1702,71 +1787,62 @@
 				return GNOME_Evolution_Calendar_OtherError;
 			}
 
-			if (e_cal_component_has_attendees (comp)) {
-				exchange_mapi_cal_util_fetch_recipients (comp, &recipients);
-				method = icalcomponent_get_method (icalcomp);
-			}
-
-			if (e_cal_component_has_attachments (comp))
-				exchange_mapi_cal_util_fetch_attachments (comp, &attachments, priv->local_attachments_store);
-
-			cbdata.comp = comp;
-			cbdata.is_modify = TRUE;
-			cbdata.msgflags = MSGFLAG_UNSENT;
+			e_cal_component_get_uid (comp, &uid);
+			rid = e_cal_component_get_recurid_as_string (comp);
 
 			switch (method) {
-			case ICAL_METHOD_REQUEST : 
-				cbdata.meeting_type = MEETING_REQUEST;
-				break;
-			case ICAL_METHOD_CANCEL : 
-				cbdata.meeting_type = MEETING_CANCEL;
+			case ICAL_METHOD_REQUEST :
+				comp_str = e_cal_component_get_as_string (comp);
+				status = e_cal_backend_mapi_modify_object (backend, cal, comp_str, CALOBJ_MOD_THIS, &old_object, &new_object);
+				g_free (comp_str);
+				g_free (old_object);
+				g_free (new_object);
+				if (status == GNOME_Evolution_Calendar_Success) {
+					GList *users = NULL, *l;
+					icalcomponent *resp_comp = e_cal_util_new_top_level ();
+					icalcomponent_set_method (resp_comp, ICAL_METHOD_RESPONSE);
+					icalcomponent_add_component (resp_comp, 
+						icalcomponent_new_clone(e_cal_component_get_icalcomponent(comp)));
+					comp_str = icalcomponent_as_ical_string (resp_comp);
+					status = e_cal_backend_mapi_send_objects (backend, cal, comp_str, &users, &new_object);
+					g_free (comp_str);
+					g_free (new_object);
+					for (l = users; l; l = l->next)
+						g_free (l->data);
+					g_list_free (users);
+					icalcomponent_free (resp_comp);
+				}
+
+				if (status != GNOME_Evolution_Calendar_Success)
+					stop = TRUE;
 				break;
-			case ICAL_METHOD_RESPONSE : 
-				cbdata.meeting_type = MEETING_RESPONSE_ACCEPT;
+			case ICAL_METHOD_CANCEL :
+				status = e_cal_backend_mapi_remove_object (backend, cal, uid, rid, CALOBJ_MOD_THIS, &old_object, &new_object);
+				if (status != GNOME_Evolution_Calendar_Success)
+					stop = TRUE;
+				g_free (old_object);
+				g_free (new_object);
 				break;
+			case ICAL_METHOD_REPLY :
+				/* responses are automatically updated even as they are rendered (just like in Outlook) */
+				status = GNOME_Evolution_Calendar_Success;
+				break; 
 			default :
-				cbdata.meeting_type = NOT_A_MEETING;
 				break;
 			}
 
-			get_server_data (cbmapi, subcomp, &cbdata);
-			cbdata.username = e_cal_backend_mapi_get_user_name (cbmapi);
-			cbdata.useridtype = "SMTP";
-			cbdata.userid = e_cal_backend_mapi_get_user_email (cbmapi);
-			cbdata.ownername = e_cal_backend_mapi_get_owner_name (cbmapi);
-			cbdata.owneridtype = "SMTP";
-			cbdata.ownerid = e_cal_backend_mapi_get_owner_email (cbmapi);
-
-			mid = exchange_mapi_create_item (olFolderOutbox, 0, 
-							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);
-				exchange_mapi_util_free_attachment_list (&attachments);
-				return GNOME_Evolution_Calendar_OtherError;
-			} else 
-				status = GNOME_Evolution_Calendar_Success;
-
+			g_free (rid);
 			g_object_unref (comp);
-			exchange_mapi_util_free_recipient_list (&recipients);
-			exchange_mapi_util_free_attachment_list (&attachments);
 
 			subcomp = icalcomponent_get_next_component (icalcomp,
 								    e_cal_backend_get_kind (E_CAL_BACKEND (backend)));
 		}
 	}
 
-	if (status == GNOME_Evolution_Calendar_Success)
-		*modified_calobj = g_strdup (calobj);
-
-	icalcomponent_free (icalcomp);
-
-	return GNOME_Evolution_Calendar_Success;
+	return status;
 }
 
+
 static ECalBackendSyncStatus 
 e_cal_backend_mapi_get_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid, char **object)
 {

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	Tue Aug 19 08:45:06 2008
@@ -66,6 +66,7 @@
 get_partstat_from_trackstatus (uint32_t trackstatus)
 {
 	switch (trackstatus) {
+		case olResponseOrganized : 
 		case olResponseAccepted  : return ICAL_PARTSTAT_ACCEPTED;
 		case olResponseTentative : return ICAL_PARTSTAT_TENTATIVE;
 		case olResponseDeclined  : return ICAL_PARTSTAT_DECLINED;
@@ -236,6 +237,73 @@
 #define RECIP_ORGANIZER 0x2
 
 void
+exchange_mapi_cal_util_fetch_organizer (ECalComponent *comp, GSList **recip_list)
+{
+	icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
+	icalproperty *org_prop = NULL; 
+	const gchar *org = NULL;
+
+	org_prop = icalcomponent_get_first_property (icalcomp, ICAL_ORGANIZER_PROPERTY);
+	org = icalproperty_get_organizer (org_prop);
+	if (org && *org) {
+		ExchangeMAPIRecipient *recipient;
+		uint32_t val = 0;
+		const char *str = NULL;
+		icalparameter *param;
+
+		recipient = g_new0 (ExchangeMAPIRecipient, 1);
+
+		if (!g_ascii_strncasecmp (org, "mailto:";, 7)) 
+			recipient->email_id = (org) + 7;
+		else 
+			recipient->email_id = (org);
+
+		/* Required properties - set them always */
+		recipient->in.req_lpProps = g_new0 (struct SPropValue, 5);
+		recipient->in.req_cValues = 5;
+
+		val = 0;
+		set_SPropValue_proptag (&(recipient->in.req_lpProps[0]), PR_SEND_INTERNET_ENCODING, (const void *)&val);
+
+		val = RECIP_SENDABLE | RECIP_ORGANIZER;
+		set_SPropValue_proptag (&(recipient->in.req_lpProps[1]), PR_RECIPIENTS_FLAGS, (const void *)&val);
+
+		val = olResponseNone;
+		set_SPropValue_proptag (&(recipient->in.req_lpProps[2]), PR_RECIPIENT_TRACKSTATUS, (const void *)&val);
+
+		val = olTo;
+		set_SPropValue_proptag (&(recipient->in.req_lpProps[3]), PR_RECIPIENT_TYPE, (const void *) &val);
+
+		param = icalproperty_get_first_parameter (org_prop, ICAL_CN_PARAMETER);
+		str = icalparameter_get_cn (param);
+		if (!(str && *str)) 
+			str = "";
+		set_SPropValue_proptag (&(recipient->in.req_lpProps[4]), PR_RECIPIENT_DISPLAY_NAME, (const void *)(str));
+
+		/* External recipient properties - set them only when the recipient is unresolved */
+		recipient->in.ext_lpProps = g_new0 (struct SPropValue, 5);
+		recipient->in.ext_cValues = 5;
+
+		val = DT_MAILUSER;
+		set_SPropValue_proptag (&(recipient->in.ext_lpProps[0]), PR_DISPLAY_TYPE, (const void *)&val);
+		val = MAPI_MAILUSER;
+		set_SPropValue_proptag (&(recipient->in.ext_lpProps[1]), PR_OBJECT_TYPE, (const void *)&val);
+		str = "SMTP";
+		set_SPropValue_proptag (&(recipient->in.ext_lpProps[2]), PR_ADDRTYPE, (const void *)(str));
+		str = recipient->email_id;
+		set_SPropValue_proptag (&(recipient->in.ext_lpProps[3]), PR_SMTP_ADDRESS, (const void *)(str));
+
+		param = icalproperty_get_first_parameter (org_prop, ICAL_CN_PARAMETER);
+		str = icalparameter_get_cn (param);
+		if (!(str && *str)) 
+			str = "";
+		set_SPropValue_proptag (&(recipient->in.ext_lpProps[4]), PR_DISPLAY_NAME, (const void *)(str));
+
+		*recip_list = g_slist_append (*recip_list, recipient);
+	}
+}
+
+void
 exchange_mapi_cal_util_fetch_recipients (ECalComponent *comp, GSList **recip_list)
 {
 	icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
@@ -993,6 +1061,7 @@
 			exchange_mapi_cal_util_fetch_recipients (cbdata.comp, &recipients);
 
 		cbdata.meeting_type = (recipients != NULL) ? MEETING_OBJECT : NOT_A_MEETING;
+		cbdata.resp = (recipients != NULL) ? olResponseOrganized : olResponseNone;
 		cbdata.msgflags = MSGFLAG_READ;
 		cbdata.is_modify = TRUE;
 		cbdata.cleanglobalid = (const struct SBinary *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0023));
@@ -1069,6 +1138,7 @@
 		cbdata.is_modify = FALSE;
 		cbdata.msgflags = MSGFLAG_READ;
 		cbdata.meeting_type = MEETING_REQUEST_RCVD;
+		cbdata.resp = olResponseNone;
 		cbdata.appt_seq = (*(const uint32_t *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_LONG, 0x8201)));
 		cbdata.appt_id = (*(const uint32_t *)find_mapi_SPropValue_data(properties, PR_OWNER_APPT_ID));
 		cbdata.globalid = (const struct SBinary *)find_mapi_SPropValue_data(properties, PROP_TAG(PT_BINARY, 0x0003));
@@ -1135,7 +1205,6 @@
 	icalproperty_method method = ICAL_METHOD_NONE;
 	const char *msg_class = NULL;
 	mapi_id_t mid = 0;
-	const bool *b = NULL;
 	icalcomponent *icalcomp = NULL;
 	gchar *str = NULL, *smid = NULL, *tmp, *filename, *fileuri;
 
@@ -1181,9 +1250,7 @@
 							NULL, NULL, NULL);
 		set_attachments_to_cal_component (comp, attachments, fileuri);
 
-		b = (const bool *) find_mapi_SPropValue_data(properties, PR_PROCESSED);
-		if (!(b && *b))
-			update_server_object (properties, attachments, comp, &mid);
+		update_server_object (properties, attachments, comp, &mid);
 
 		tmp = exchange_mapi_util_mapi_id_to_string (mid);
 		e_cal_component_set_uid (comp, tmp);
@@ -1281,37 +1348,38 @@
 	I_APPT_BUSYSTATUS , 
 	I_APPT_LOCATION , 
 	I_APPT_START , 
-	I_APPT_END , 
+/*5*/	I_APPT_END , 
 	I_APPT_DURATION , 
 	I_APPT_ALLDAY , 
 /**/	I_APPT_RECURBLOB , 
 	I_APPT_STATEFLAGS , 
-	I_APPT_RESPONSESTATUS , 
+/*10*/	I_APPT_RESPONSESTATUS , 
 	I_APPT_RECURRING , 
 	I_APPT_INTENDEDBUSY , 
 /**/	I_APPT_RECURBASE , 
 	I_APPT_INVITED , 
-/**/	I_APPT_RECURTYPE , 
+/*15*/	I_APPT_RECURTYPE , 
 /**/	I_APPT_RECURPATTERN , 
 	I_APPT_CLIPSTART , 
 	I_APPT_CLIPEND , 
 	I_APPT_AUTOLOCATION , 
+/*20*/	I_APPT_ISCOUNTERPROPOSAL , 
 	I_APPT_NOTALLOWPROPOSE , 
 	I_APPT_STARTTZBLOB , 
-	I_APPT_ENDTZBLOB ,
+	I_APPT_ENDTZBLOB , 
 
 	I_MEET_WHERE , 
-	I_MEET_GUID , 
+/*25*/	I_MEET_GUID , 
 	I_MEET_ISRECURRING , 
 	I_MEET_ISEXCEPTION , 
 	I_MEET_CLEANGUID , 
 	I_MEET_APPTMSGCLASS , 
-	I_MEET_TYPE
+/*30*/	I_MEET_TYPE
 
-//	I_SENDASICAL , 
+//	I_APPT_SENDASICAL , 
 //	I_APPT_SEQTIME , 
 //	I_APPT_LABEL , 
-//	I_APPT_DISPTZ 
+//	I_APPT_DISPTZ , 
 //	I_APPT_ALLATTENDEES , 
 //	I_APPT_TOATTENDEES , 
 //	I_APPT_CCATTENDEES , 
@@ -1339,6 +1407,7 @@
 	mapi_nameid_lid_add(nameid, 0x8235, PSETID_Appointment); 	// PT_SYSTIME - (dtstart)(for recurring events UTC 12 AM of day of start)
 	mapi_nameid_lid_add(nameid, 0x8236, PSETID_Appointment); 	// PT_SYSTIME - (dtend)(for recurring events UTC 12 AM of day of end)
 	mapi_nameid_lid_add(nameid, 0x823A, PSETID_Appointment); 	// PT_BOOLEAN - AutoFillLocation
+	mapi_nameid_lid_add(nameid, 0x8257, PSETID_Appointment); 	// PT_BOOLEAN - ApptCounterProposal
 	mapi_nameid_lid_add(nameid, 0x825A, PSETID_Appointment); 	// PT_BOOLEAN - ApptNotAllowPropose
 	mapi_nameid_lid_add(nameid, 0x825E, PSETID_Appointment); 	// PT_BINARY - (timezone for dtstart)
 	mapi_nameid_lid_add(nameid, 0x825F, PSETID_Appointment); 	// PT_BINARY - (timezone for dtend)
@@ -1408,20 +1477,18 @@
 }
 
 
-#define NOTE_NAMED_PROPS_N 0
+#define NOTE_NAMED_PROPS_N 1
 
-/*
 typedef enum 
 {
-//	I_NOTE_COLOR 
+	I_NOTE_COLOR = COMMON_NAMED_PROPS_N 
 } NoteNamedPropsIndex;
-*/
 
 static void 
 note_build_name_id (struct mapi_nameid *nameid)
 {
 	/* These probably would never be used from Evolution */
-//	mapi_nameid_lid_add(nameid, 0x8B00, PSETID_Note); 	// PT_LONG - Color
+	mapi_nameid_lid_add(nameid, 0x8B00, PSETID_Note); 	// PT_LONG - Color
 }
 
 #define MINUTES_IN_HOUR 60
@@ -1465,7 +1532,7 @@
 			return 0;
 	} 
 
-	g_debug ("Allocating space for %d props\n", flag32);
+	g_debug ("Allocating space for %d props ", flag32);
 	props = g_new0 (struct SPropValue, flag32);
 
 	/* PR_MESSAGE_CLASS needs to be set appropriately */					/* prop count: 1 */
@@ -1507,7 +1574,7 @@
 
 	/* it'd be better to convert, then set it in unicode */
 	text = icalcomponent_get_description (ical_comp);
-	if (!(text && *text)) 
+	if (!(text && *text) || !g_utf8_validate (text, -1, NULL)) 
 		text = "";
 	set_SPropValue_proptag(&props[i++], PR_BODY, 						/* prop count: 6 */
 					(const void *) text);
@@ -1696,6 +1763,9 @@
 		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);
 
+		flag32 = cbdata->resp;
+		set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RESPONSESTATUS], (const void *) &flag32);
+
 		switch (cbdata->meeting_type) {
 		case MEETING_OBJECT :
 			set_SPropValue_proptag(&props[i++], PR_MESSAGE_CLASS, (const void *) IPM_APPOINTMENT);
@@ -1712,8 +1782,24 @@
 			flag32 = mtgRequest; 
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
 
-			flag32 = olResponseOrganized;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RESPONSESTATUS], (const void *) &flag32);
+			b = 1;
+			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
+
+			break;
+		case MEETING_OBJECT_RCVD :
+			set_SPropValue_proptag(&props[i++], PR_MESSAGE_CLASS, (const void *) IPM_APPOINTMENT);
+
+			flag32 = e_cal_component_has_recurrences (comp) ? RecurMeet : SingleMeet; 
+			set_SPropValue_proptag(&props[i++], PR_ICON_INDEX, (const void *) &flag32);
+
+			flag32 = 0x0171;
+			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_COMMON_SIDEEFFECTS], (const void *) &flag32);
+
+			flag32 = asfMeeting | asfReceived;
+			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_STATEFLAGS], (const void *) &flag32);
+
+			flag32 = mtgRequest; 
+			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
 
 			b = 1;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
@@ -1734,9 +1820,6 @@
 			flag32 = (cbdata->appt_seq == 0) ? mtgRequest : mtgFull; 
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
 
-			flag32 = olResponseNotResponded;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RESPONSESTATUS], (const void *) &flag32);
-
 			b = 1;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
 
@@ -1756,9 +1839,6 @@
 			flag32 = mtgRequest; 
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
 
-			flag32 = olResponseNone;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RESPONSESTATUS], (const void *) &flag32);
-
 			b = 1;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
 
@@ -1778,17 +1858,22 @@
 			flag32 = mtgEmpty; 
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
 
-			flag32 = olResponseNotResponded;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RESPONSESTATUS], (const void *) &flag32);
-
 			b = 1;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
 
 			break;
-		case MEETING_RESPONSE_ACCEPT : 
-		case MEETING_RESPONSE_DECLINE : 
-		case MEETING_RESPONSE_TENTATIVE : 
-			set_SPropValue_proptag(&props[i++], PR_MESSAGE_CLASS, (const void *) IPM_SCHEDULE_MEETING_RESP_POS);
+		case MEETING_RESPONSE : 
+			if (cbdata->resp == olResponseAccepted) {
+				text = IPM_SCHEDULE_MEETING_RESP_POS; 
+			} else if (cbdata->resp == olResponseTentative) {
+				text = IPM_SCHEDULE_MEETING_RESP_TENT; 
+			} else if (cbdata->resp == olResponseDeclined) {
+				text = IPM_SCHEDULE_MEETING_RESP_NEG; 
+			} else {
+				text = ""; 
+			}
+			set_SPropValue_proptag(&props[i++], PR_MESSAGE_CLASS, (const void *) text);
+			text = NULL;
 
 			flag32 = 0xFFFFFFFF;  /* no idea why this has to be -1, but that's what the docs say */ 
 			set_SPropValue_proptag(&props[i++], PR_ICON_INDEX, (const void *) &flag32);
@@ -1802,9 +1887,6 @@
 			flag32 = mtgEmpty; 
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
 
-			flag32 = olResponseAccepted;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RESPONSESTATUS], (const void *) &flag32);
-
 			break;
 		case NOT_A_MEETING :
 		default :
@@ -1819,9 +1901,6 @@
 			flag32 = 0;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_STATEFLAGS], (const void *) &flag32);
 
-			flag32 = olResponseNone;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_RESPONSESTATUS], (const void *) &flag32);
-
 			b = 0;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_INVITED], (const void *) &b);
 
@@ -1838,6 +1917,8 @@
 		/* Counter Proposal for appointments : not supported */
 		b = 1;
 		set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_NOTALLOWPROPOSE], (const void *) &b);
+		b = 0;
+		set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_ISCOUNTERPROPOSAL], (const void *) &b);
 
 	} else if (kind == ICAL_VTODO_COMPONENT) {
 		double d;
@@ -1906,7 +1987,7 @@
 	/* Free this memory at the backends. */
 	cbdata->props = props;
 
-	g_debug ("Ended up setting %d props\n", i);
+	g_debug ("Ended up setting %d props ", i);
 
 	return 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	Tue Aug 19 08:45:06 2008
@@ -37,17 +37,16 @@
 G_BEGIN_DECLS
 
 typedef enum {
-	NOT_A_MEETING = 0, 
-	MEETING_OBJECT 		= (1 << 0),
-	MEETING_OBJECT_SENT 	= (1 << 1),
-	MEETING_REQUEST 	= (1 << 2), 
-	MEETING_REQUEST_RCVD 	= (1 << 3), 
-	MEETING_RESPONSE_ACCEPT = (1 << 4), 
-	MEETING_RESPONSE_DECLINE = (1 << 5), 
-	MEETING_RESPONSE_TENTATIVE = (1 << 6), 
+	NOT_A_MEETING 		= (1 << 0), 
+	MEETING_OBJECT 		= (1 << 1), 
+	MEETING_OBJECT_SENT 	= (1 << 2), 
+	MEETING_OBJECT_RCVD 	= (1 << 3), 
+	MEETING_REQUEST 	= (1 << 4), 
+	MEETING_REQUEST_RCVD 	= (1 << 5), 
+	MEETING_RESPONSE 	= (1 << 6), 
 	MEETING_RESPONSE_RCVD 	= (1 << 7), 
 	MEETING_CANCEL 		= (1 << 8), 
-	MEETING_CANCEL_RCVD 	= (1 << 9)
+	MEETING_CANCEL_RCVD 	= (1 << 9) 
 } MAPIMeetingOptions;
 
 struct cbdata { 
@@ -55,8 +54,6 @@
 	struct SPropValue *props;
 	gboolean is_modify;
 
-	uint32_t msgflags;
-
 	/* These are appt specific data */ 
 	MAPIMeetingOptions meeting_type;
 	uint32_t appt_id;
@@ -64,6 +61,8 @@
 	struct SBinary *globalid;
 	struct SBinary *cleanglobalid;
 
+	uint32_t msgflags;
+	OlResponseStatus resp; 
 	const char *username;
 	const char *useridtype;
 	const char *userid;
@@ -73,6 +72,8 @@
 };
 
 void
+exchange_mapi_cal_util_fetch_organizer (ECalComponent *comp, GSList **recip_list);
+void
 exchange_mapi_cal_util_fetch_recipients (ECalComponent *comp, GSList **recip_list);
 void
 exchange_mapi_cal_util_fetch_attachments (ECalComponent *comp, GSList **attach_list, const char *local_store_uri);



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