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



Author: msuman
Date: Wed Jul 30 07:59:17 2008
New Revision: 9225
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9225&view=rev

Log:
Some fixes for external recipients, use AppointmentStateFlags instead of OlMeetingStatus (fixes a few bugs) and some code cleanup.

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

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	Wed Jul 30 07:59:17 2008
@@ -1673,22 +1673,20 @@
 
 			cbdata.comp = comp;
 			cbdata.is_modify = TRUE;
+			cbdata.msgflags = MSGFLAG_UNSENT;
+
 			switch (method) {
 			case ICAL_METHOD_REQUEST : 
 				cbdata.meeting_type = MEETING_REQUEST;
-				cbdata.msgflags = MSGFLAG_UNSENT ;
 				break;
 			case ICAL_METHOD_CANCEL : 
 				cbdata.meeting_type = MEETING_CANCEL;
-				cbdata.msgflags = MSGFLAG_UNSENT ;
 				break;
 			case ICAL_METHOD_RESPONSE : 
 				cbdata.meeting_type = MEETING_RESPONSE_ACCEPT;
-				cbdata.msgflags = MSGFLAG_UNSENT;
 				break;
 			default :
 				cbdata.meeting_type = NOT_A_MEETING;
-				cbdata.msgflags = MSGFLAG_READ;
 				break;
 			}
 

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	Wed Jul 30 07:59:17 2008
@@ -247,29 +247,55 @@
 
 	for (l = al; l != NULL; l = l->next) {
 		ECalComponentAttendee *attendee = (ECalComponentAttendee *)(l->data);
-		ExchangeMAPIRecipient *recipient = g_new0 (ExchangeMAPIRecipient, 1);
+		ExchangeMAPIRecipient *recipient;
 		uint32_t val = 0;
-//		const char *str = NULL;
-		if (attendee->value && !g_ascii_strncasecmp (attendee->value, "mailto:";, 7)) 
+		const char *str = NULL;
+
+		if (!attendee->value)
+			continue;
+
+		recipient = g_new0 (ExchangeMAPIRecipient, 1);
+
+		if (!g_ascii_strncasecmp (attendee->value, "mailto:";, 7)) 
 			recipient->email_id = (attendee->value) + 7;
 		else 
 			recipient->email_id = (attendee->value);
+
+		/* 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 | (!g_ascii_strcasecmp(recipient->email_id, organizer.value) ? RECIP_ORGANIZER : 0);
+		val = RECIP_SENDABLE | (!g_ascii_strcasecmp(attendee->value, organizer.value) ? RECIP_ORGANIZER : 0);
 		set_SPropValue_proptag (&(recipient->in.req_lpProps[1]), PR_RECIPIENTS_FLAGS, (const void *)&val);
 		val = get_trackstatus_from_partstat (attendee->status);
 		set_SPropValue_proptag (&(recipient->in.req_lpProps[2]), PR_RECIPIENT_TRACKSTATUS, (const void *)&val);
 		val = get_type_from_role (attendee->role);
 		set_SPropValue_proptag (&(recipient->in.req_lpProps[3]), PR_RECIPIENT_TYPE, (const void *) &val);
-/*		if (attendee->cn && *(attendee->cn))
+		if (attendee->cn && *(attendee->cn))
 			str = attendee->cn;
 		else 
 			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));
+		if (attendee->cn && *(attendee->cn))
+			str = attendee->cn;
+		else 
+			str = "";
+		set_SPropValue_proptag (&(recipient->in.ext_lpProps[4]), PR_DISPLAY_NAME, (const void *)(str));
+
 		*recip_list = g_slist_append (*recip_list, recipient);
 	}
 
@@ -1049,7 +1075,7 @@
 	I_APPT_DURATION , 
 	I_APPT_ALLDAY , 
 /**/	I_APPT_RECURBLOB , 
-	I_APPT_MEETINGSTATUS , 
+	I_APPT_STATEFLAGS , 
 	I_APPT_RESPONSESTATUS , 
 	I_APPT_RECURRING , 
 	I_APPT_INTENDEDBUSY , 
@@ -1092,7 +1118,7 @@
 	mapi_nameid_lid_add(nameid, 0x8213, PSETID_Appointment); 	// PT_LONG - Duration/ApptDuration
 	mapi_nameid_lid_add(nameid, 0x8215, PSETID_Appointment); 	// PT_BOOLEAN - AllDayEvent (also called ApptSubType)
 	mapi_nameid_lid_add(nameid, 0x8216, PSETID_Appointment); 	// PT_BINARY - (recurrence blob)
-	mapi_nameid_lid_add(nameid, 0x8217, PSETID_Appointment); 	// PT_LONG - MeetingStatus
+	mapi_nameid_lid_add(nameid, 0x8217, PSETID_Appointment); 	// PT_LONG - ApptStateFlags
 	mapi_nameid_lid_add(nameid, 0x8218, PSETID_Appointment); 	// PT_LONG - ResponseStatus
 	mapi_nameid_lid_add(nameid, 0x8223, PSETID_Appointment); 	// PT_BOOLEAN - Recurring
 	mapi_nameid_lid_add(nameid, 0x8224, PSETID_Appointment); 	// PT_LONG - IntendedBusyStatus
@@ -1212,26 +1238,26 @@
 	struct icaltimetype dtstart, dtend, utc_dtstart, utc_dtend;
 	const icaltimezone *utc_zone;
 	const char *dtstart_tzid, *dtend_tzid, *text = NULL;
-	const char *uid = NULL;
 	struct timeval t;
 
+	flag32 = REGULAR_PROPS_N + COMMON_NAMED_PROPS_N;
 	switch (kind) {
 		case ICAL_VEVENT_COMPONENT:
-			props = g_new0 (struct SPropValue, REGULAR_PROPS_N + COMMON_NAMED_PROPS_N + APPT_NAMED_PROPS_N);
-			g_debug ("\nAllocating space for %d props\n", REGULAR_PROPS_N + COMMON_NAMED_PROPS_N + APPT_NAMED_PROPS_N);
+			flag32 += APPT_NAMED_PROPS_N;
 			break;
 		case ICAL_VTODO_COMPONENT:
-			props = g_new0 (struct SPropValue, REGULAR_PROPS_N + COMMON_NAMED_PROPS_N + TASK_NAMED_PROPS_N);
-			g_debug ("\nAllocating space for %d props\n", REGULAR_PROPS_N + COMMON_NAMED_PROPS_N + TASK_NAMED_PROPS_N);
+			flag32 += TASK_NAMED_PROPS_N;
 			break;
 		case ICAL_VJOURNAL_COMPONENT:
-			props = g_new0 (struct SPropValue, REGULAR_PROPS_N + COMMON_NAMED_PROPS_N + NOTE_NAMED_PROPS_N);
-			g_debug ("\nAllocating space for %d props\n", REGULAR_PROPS_N + COMMON_NAMED_PROPS_N + NOTE_NAMED_PROPS_N);
+			flag32 += NOTE_NAMED_PROPS_N;
 			break;
 		default:
 			return 0;
 	} 
 
+	g_debug ("Allocating space for %d props\n", flag32);
+	props = g_new0 (struct SPropValue, flag32);
+
 	/* PR_MESSAGE_CLASS needs to be set appropriately */					/* prop count: 1 */
 
 	utc_zone = icaltimezone_get_utc_timezone ();
@@ -1469,8 +1495,8 @@
 			flag32 = 0x0171;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_COMMON_SIDEEFFECTS], (const void *) &flag32);
 
-			flag32 = olMeeting;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_MEETINGSTATUS], (const void *) &flag32);
+			flag32 = asfMeeting;
+			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);
@@ -1491,8 +1517,8 @@
 			flag32 = 0x1C61;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_COMMON_SIDEEFFECTS], (const void *) &flag32);
 
-			flag32 = olMeetingReceived;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_MEETINGSTATUS], (const void *) &flag32);
+			flag32 = asfMeeting | asfReceived;
+			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_STATEFLAGS], (const void *) &flag32);
 
 			flag32 = (cbdata->appt_seq == 0) ? mtgRequest : mtgFull; 
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
@@ -1513,8 +1539,8 @@
 			flag32 = 0x0171;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_COMMON_SIDEEFFECTS], (const void *) &flag32);
 
-			flag32 = olMeetingReceived;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_MEETINGSTATUS], (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);
@@ -1529,16 +1555,16 @@
 		case MEETING_CANCEL :
 			set_SPropValue_proptag(&props[i++], PR_MESSAGE_CLASS, (const void *) "IPM.Schedule.Meeting.Canceled");
 
-			flag32 = e_cal_component_has_recurrences (comp) ? RecurMeet : SingleMeet; 
+			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);
 
-			flag32 = 0x0171;
+			flag32 = 0x1C61;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_COMMON_SIDEEFFECTS], (const void *) &flag32);
 
-			flag32 = olMeetingCanceled;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_MEETINGSTATUS], (const void *) &flag32);
+			flag32 = asfMeeting | asfReceived | asfCanceled;
+			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_STATEFLAGS], (const void *) &flag32);
 
-			flag32 = mtgFull; 
+			flag32 = mtgEmpty; 
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_MEET_TYPE], (const void *) &flag32);
 
 			flag32 = olResponseNotResponded;
@@ -1557,8 +1583,8 @@
 			flag32 = 0x0171;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_COMMON_SIDEEFFECTS], (const void *) &flag32);
 /*
-			flag32 = olMeeting;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_MEETINGSTATUS], (const void *) &flag32);
+			flag32 = ???;
+			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);
@@ -1577,8 +1603,8 @@
 			flag32 = 0x0171;
 			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_COMMON_SIDEEFFECTS], (const void *) &flag32);
 
-			flag32 = olNonMeeting;
-			set_SPropValue_proptag(&props[i++], proptag_array->aulPropTag[I_APPT_MEETINGSTATUS], (const void *) &flag32);
+			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);
@@ -1667,7 +1693,7 @@
 	/* Free this memory at the backends. */
 	cbdata->props = props;
 
-	g_debug ("\nEnded up setting %d props\n", i);
+	g_debug ("Ended up setting %d props\n", i);
 
 	return i;
 }

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	Wed Jul 30 07:59:17 2008
@@ -813,8 +813,17 @@
 			ExchangeMAPIRecipient 	*recipient = g_new0 (ExchangeMAPIRecipient, 1);
 
 			recipient->email_id = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_SMTP_ADDRESS);
-			if (!recipient->email_id)
+			/* fallback */
+			if (!recipient->email_id) {
+				const char *addrtype = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_ADDRTYPE);
+				if (addrtype && !g_ascii_strcasecmp(addrtype, "SMTP"))
+					recipient->email_id = (const char *) exchange_mapi_util_find_row_propval (&(rows_recip.aRow[i_row_recip]), PR_EMAIL_ADDRESS);
+			}
+			/* fail */
+			if (!recipient->email_id) {
 				g_warning ("\n%s:%d %s() - object has a recipient without a PR_SMTP_ADDRESS ", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+				mapidump_SRow (&(rows_recip.aRow[i_row_recip]), " ");
+			}
 
 			recipient->out.all_lpProps = rows_recip.aRow[i_row_recip].lpProps;
 			recipient->out.all_cValues = rows_recip.aRow[i_row_recip].cValues;
@@ -834,19 +843,30 @@
 }
 
 static void 
-set_recipient_properties (struct SRow *aRow, ExchangeMAPIRecipient *recipient, gboolean is_external)
+set_recipient_properties (TALLOC_CTX *mem_ctx, struct SRow *aRow, ExchangeMAPIRecipient *recipient, gboolean is_external)
 {
 	uint32_t i;
 
-	if (is_external)
+	if (is_external) {
+		struct SBinary *oneoff_eid;
+		struct SPropValue sprop; 
+		const gchar *dn = NULL, *email = NULL; 
+
 		for (i = 0; i < recipient->in.ext_cValues; ++i)
 			SRow_addprop (aRow, recipient->in.ext_lpProps[i]);
 
+		dn = (const gchar *) get_SPropValue (recipient->in.ext_lpProps, PR_DISPLAY_NAME);
+		email = (const gchar *) get_SPropValue (recipient->in.ext_lpProps, PR_SMTP_ADDRESS);
+		oneoff_eid = exchange_mapi_util_entryid_generate_oneoff (mem_ctx, dn, email, FALSE);
+		set_SPropValue_proptag (&sprop,  PR_ENTRYID, (const void *)(oneoff_eid));
+		SRow_addprop (aRow, sprop);
+	}
+
 	for (i = 0; i < recipient->in.req_cValues; ++i)
 		SRow_addprop (aRow, recipient->in.req_lpProps[i]);
 }
 
-/* DON'T fucking touch this function. */
+/* DON'T f***ing touch this function. */
 static void
 exchange_mapi_util_modify_recipients (TALLOC_CTX *mem_ctx, mapi_object_t *obj_message , GSList *recipients)
 {
@@ -910,11 +930,11 @@
 			last = SRowSet->cRows;
 			SRowSet->aRow[last].cValues = 0;
 			SRowSet->aRow[last].lpProps = talloc_zero(mem_ctx, struct SPropValue);
-			set_recipient_properties (&SRowSet->aRow[last], recipient, TRUE);
+			set_recipient_properties (mem_ctx, &SRowSet->aRow[last], recipient, TRUE);
 			SRowSet->cRows += 1;
 			break;
 		case MAPI_RESOLVED:
-			set_recipient_properties (&SRowSet->aRow[j], recipient, FALSE);
+			set_recipient_properties (mem_ctx, &SRowSet->aRow[j], recipient, FALSE);
 			j += 1;
 			break;
 		}
@@ -1503,7 +1523,6 @@
 {
 	enum MAPISTATUS retval;
 	mapi_object_t obj_store;
-	mapi_object_t obj_top;
 	mapi_object_t obj_folder;
 	ExchangeMAPIFolder *folder;
 	gboolean result = FALSE;
@@ -2582,7 +2601,7 @@
 		ExchangeMAPIFolder *folder = NULL;
 		gchar *newname = NULL;
 
-		const uint64_t *fid = (const uint64_t *)find_SPropValue_data(&rowset.aRow[i], PR_FID);
+		const mapi_id_t *fid = (const mapi_id_t *)find_SPropValue_data(&rowset.aRow[i], PR_FID);
 		const char *class = (const char *)find_SPropValue_data(&rowset.aRow[i], PR_CONTAINER_CLASS);
 		const char *name = (const char *)find_SPropValue_data(&rowset.aRow[i], PR_DISPLAY_NAME);
 		const uint32_t *unread = (const uint32_t *)find_SPropValue_data(&rowset.aRow[i], PR_CONTENT_UNREAD);

Modified: branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h	(original)
+++ branches/EXCHANGE_MAPI_BRANCH/servers/mapi/exchange-mapi-defs.h	Wed Jul 30 07:59:17 2008
@@ -159,6 +159,12 @@
 } OlMeetingStatus;
 
 typedef enum {
+    asfMeeting = 1,
+    asfReceived = 2,
+    asfCanceled = 4
+} AppointmentStateFlags;
+
+typedef enum {
     olNetMeeting = 0,
     olNetShow = 1,
     olChat = 2

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	Wed Jul 30 07:59:17 2008
@@ -343,10 +343,10 @@
 				g_print(" (long) - %u", lpProp->value.l);
 				break;
 			case PT_DOUBLE:
-				g_print (" (double) -  %lf", lpProp->value.dbl);
+				g_print (" (double) -  %lf", (double)lpProp->value.dbl);
 				break;
 			case PT_I8:
-				g_print (" (int) - %lld", lpProp->value.d);
+				g_print (" (int) - %ld", lpProp->value.d);
 				break;
 			case PT_SYSTIME: {
 					struct timeval t;
@@ -358,7 +358,7 @@
 				g_print (" (struct FILETIME *) - %p\t (struct timeval) %s\t", &lpProp->value.ft, t_str);
 				break;
 			case PT_ERROR:
-				g_print (" (error) - %p", lpProp->value.err);
+				g_print (" (error) - %d", lpProp->value.err);
 				break;
 			case PT_STRING8:
 				g_print(" (string) - %s", lpProp->value.lpszA ? lpProp->value.lpszA : "null" );



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