#include "idl_types.h"

cpp_quote("#include <gen_ndr/ndr_misc.h>")

import "exchange.idl";

[
	pointer_default(unique)
]
interface property
{
	typedef [v1_enum] enum {
		afNone			= 0x00000000,
		afByValue		= 0x00000001,
		afByReference		= 0x00000002,
		afByReferenceOnly	= 0x00000004,
		afEmbeddedMessage	= 0x00000005,
		afStorage		= 0x00000006
	} AttachmentMethod;

	typedef [v1_enum] enum {
		seOpenToDelete		= 0x00000001,
		seNoFrame		= 0x00000008,
		seCoerceToInbox		= 0x00000010,
		seOpenToCopy		= 0x00000020,
		seOpenToMove		= 0x00000040,
		seOpenForCtxMenu	= 0x00000100,
		seCannotUndoDelete	= 0x00000400,
		seCannotUndoCopy	= 0x00000800,
		seCannotUndoMove	= 0x00001000,
		seHasScript		= 0x00002000,
		seOpenToPermDelete	= 0x00004000
	} SideEffects;

	typedef [enum16bit] enum {
		RecurFrequency_Daily	= 0x200A,
		RecurFrequency_Weekly	= 0x200B,
		RecurFrequency_Monthly	= 0x200C,
		RecurFrequency_Yearly	= 0x200D
	} RecurFrequency;

	typedef [v1_enum] enum {
		rectypeNone	= 0x00000000,
		rectypeDaily	= 0x00000001,
		rectypeWeekly	= 0x00000002,
		rectypeMonthly	= 0x00000003,
		rectypeYearly	= 0x00000004
	} RecurrenceType;

	typedef [enum16bit] enum {
		PatternType_Day		= 0x0,
		PatternType_Week	= 0x1,
		PatternType_Month	= 0x2,
		PatternType_MonthNth	= 0x3,
		PatternType_MonthEnd	= 0x4,
		PatternType_HjMonth	= 0xA,
		PatternType_HjMonthNth	= 0xB,
		PatternType_HjMonthEnd	= 0xC
	} PatternType;

	typedef [enum16bit] enum {
		CAL_DEFAULT			= 0x0,
		CAL_GREGORIAN			= 0x1,
		CAL_GREGORIAN_US		= 0x2,
		CAL_JAPAN			= 0x3,
		CAL_TAIWAN			= 0x4,
		CAL_KOREA			= 0x5,
		CAL_HIJRI			= 0x6,
		CAL_THAI			= 0x7,
		CAL_HEBREW			= 0x8,
		CAL_GREGORIAN_ME_FRENCH		= 0x9,
		CAL_GREGORIAN_ARABIC		= 0xA,
		CAL_GREGORIAN_XLIT_ENGLISH	= 0xB,
		CAL_GREGORIAN_XLIT_FRENCH	= 0xC,
		CAL_LUNAR_JAPANESE		= 0xE,
		CAL_CHINESE_LUNAR		= 0xF,
		CAL_SAKA			= 0x10,
		CAL_LUNAR_KOREAN		= 0x14
	} CalendarType;

	typedef [bitmap32bit] bitmap {
		Su		= 0x00000001,
		M		= 0x00000002,
		Tu		= 0x00000004,
		W		= 0x00000008,
		Th		= 0x00000010,
		F		= 0x00000020,
		Sa		= 0x00000040
	} WeekRecurrencePattern;

	typedef [v1_enum] enum {
		olFree		= 0x00000000,
		olTentative	= 0x00000001,
		olBusy		= 0x00000002,
		olOutOfOffice	= 0x00000003
	} FreeBusyStatus; /* oxocal - 2.2.1.2 */

	typedef [v1_enum] enum {
		RecurrenceN_First	=	0x1,
		RecurrenceN_Second	=	0x2,
		RecurrenceN_Third	=	0x3,
		RecurrenceN_Fourth	=	0x4,
		RecurrenceN_Last	=	0x5
	} RecurrenceN;

	typedef [flag(NDR_NOALIGN)] struct {
		WeekRecurrencePattern	WeekRecurrencePattern;
		RecurrenceN		N;
	} MonthRecurrencePattern;

	typedef [nodiscriminant,flag(NDR_NOALIGN)] union {
		[case(0x1)] WeekRecurrencePattern     		WeekRecurrencePattern;
		[case(0x2)] uint32				Day;
		[case(0x3)] MonthRecurrencePattern		MonthRecurrencePattern;
		[case(0x4)] uint32				Day;
		[case(0xA)] uint32				Day;
		[case(0xB)] MonthRecurrencePattern		MonthRecurrencePattern;
		[case(0xC)] uint32				Day;
		[case(0x0)];
		[default];
	} PatternTypeSpecific;

	typedef [v1_enum] enum {
		END_AFTER_DATE		= 0x00002021,
		END_AFTER_N_OCCURRENCES	= 0x00002022,
		END_NEVER_END		= 0x00002023,
		NEVER_END		= 0xFFFFFFFF
	} EndType;

	typedef [v1_enum] enum {
		FirstDOW_Sunday		= 0x0,
		FirstDOW_Monday		= 0x1,
		FirstDOW_Tuesday	= 0x2,
		FirstDOW_Wednesday	= 0x3,
		FirstDOW_Thursday	= 0x4,
		FirstDOW_Friday		= 0x5,
		FirstDOW_Saturday	= 0x6
	} FirstDOW;

	typedef [enum16bit] enum {
		ARO_SUBJECT		= 0x0001,
		ARO_MEETINGTYPE		= 0x0002,
		ARO_REMINDERDELTA	= 0x0004,
		ARO_REMINDER		= 0x0008,
		ARO_LOCATION		= 0x0010,
		ARO_BUSYSTATUS		= 0x0020,
		ARO_ATTACHMENT		= 0x0040,
		ARO_SUBTYPE		= 0x0080,
		ARO_APPTCOLOR		= 0x0100,
		ARO_EXCEPTIONAL_BODY	= 0x0200
	} OverrideFlags;

	typedef [public,flag(NDR_NOALIGN)] struct {
		uint16						ReaderVersion;
		uint16						WriterVersion;
		RecurFrequency					RecurFrequency;
		PatternType					PatternType;
		CalendarType					CalendarType;
		uint32						FirstDateTime;
		uint32						Period;
		uint32						SlidingFlag;
		[switch_is(PatternType)] PatternTypeSpecific   	PatternTypeSpecific;
		EndType						EndType;
		uint32						OccurrenceCount;
		FirstDOW       					FirstDOW;
		uint32						DeletedInstanceCount;
		uint32						DeletedInstanceDates[DeletedInstanceCount];
		uint32						ModifiedInstanceCount;
		uint32						ModifiedInstanceDates[ModifiedInstanceCount];
		uint32						StartDate;
		uint32						EndDate;
	} RecurrencePattern;

	typedef [public,flag(NDR_NOALIGN)] struct {	
		uint16				msgLength;
		uint16				msgLength2;
		uint8				msg[msgLength2];
	} Exception_Msg;

	typedef [nodiscriminant, flag(NDR_NOALIGN)] union {
		[case(0x0000)]			;
		[case(0x0001)] 	Exception_Msg	subjectMsg;
		[case(0x0002)]	uint32		mType;
		[case(0x0004)]	uint32		rDelta;
		[case(0x0008)]	uint32		rSet;
		[case(0x0010)]	Exception_Msg	locationMsg;
		[case(0x0020)]	uint32		bStatus;
		[case(0x0040)]	uint32		attachment;
		[case(0x0080)]	uint32		sType;
		[case(0x0100)]	uint32		aColor;
		[default];
	} Exception_Value;

	typedef [public,flag(NDR_NOALIGN)] struct {
		uint32								StartDateTime;
		uint32								EndDateTime;
		uint32								OriginalStartDate;
		OverrideFlags							OverrideFlags;
		[switch_is(OverrideFlags & 0x0001)]	Exception_Value		Subject;
		[switch_is(OverrideFlags & 0x0002)]	Exception_Value		MeetingType;
		[switch_is(OverrideFlags & 0x0004)]	Exception_Value		ReminderDelta;
		[switch_is(OverrideFlags & 0x0008)]	Exception_Value		ReminderSet;
		[switch_is(OverrideFlags & 0x0010)]	Exception_Value		Location;
		[switch_is(OverrideFlags & 0x0020)]	Exception_Value		BusyStatus;
		[switch_is(OverrideFlags & 0x0040)]	Exception_Value		Attachment;
		[switch_is(OverrideFlags & 0x0080)]	Exception_Value		SubType;
		[switch_is(OverrideFlags & 0x0100)]	Exception_Value		AppointmentColor;
		/* Those are fantom fields: even if they are mentionned in the documentation, they must not be read/written to. */
		// uint32								ReservedBlock1Size;
		// uint8								ReservedBlock1[ReservedBlock1Size];
	} ExceptionInfo;

	typedef [v1_enum] enum {
		BIT_CH_START	= 0x00000001,
		BIT_CH_END	= 0x00000002,
		BIT_CH_RECUR	= 0x00000004,
		BIT_CH_LOCATION = 0x00000008,
		BIT_CH_SUBJECT	= 0x00000010,
		BIT_CH_REQATT	= 0x00000020,
		BIT_CH_OPTATT	= 0x00000040,
		BIT_CH_BODY	= 0x00000080,
		BIT_CH_RESPONSE	= 0x00000200,
		BIT_CH_PROPOSE	= 0x00000400
	} ChangeHighlightFlags;

	typedef [public,flag(NDR_NOALIGN)] struct {
		uint32						Size;
		ChangeHighlightFlags				Value;
		uint8						Reserved[Size-4];
	} ChangeHighlight;

	typedef [nopull,nopush,noprint,flag(NDR_NOALIGN)] struct {
		ChangeHighlight					ChangeHighlight;
		uint32						ReservedBlockEE1Size;
		uint8						ReservedBlockEE1[ReservedBlockEE1Size];
		uint32						StartDateTime;			
		uint32						EndDateTime;
		uint32						OriginalStartDate;
		[flag(LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_CHARLEN)] string		Subject;
		[flag(LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_CHARLEN)] string		Location;
		uint32						ReservedBlockEE2Size;
		uint8						ReservedBlockEE2[ReservedBlockEE2Size];
	} ExtendedException;

	typedef [nopull,nopush,flag(NDR_NOALIGN)] struct {
		RecurrencePattern					RecurrencePattern;
		uint32							ReaderVersion2;
		uint32							WriterVersion2;
		uint32							StartTimeOffset;
		uint32							EndTimeOffset;
		uint16							ExceptionCount;
		ExceptionInfo						ExceptionInfo[ExceptionCount];
		uint32							ReservedBlock1Size;
		uint32							ReservedBlock1[ReservedBlock1Size];
		ExtendedException					ExtendedException[ExceptionCount];
		uint32							ReservedBlock2Size;
		uint32							ReservedBlock2[ReservedBlock2Size];
	} AppointmentRecurrencePattern;
	
	/* [MS-DIF].pdf Section 2.3.6 */
	typedef [public,flag(NDR_NOALIGN)] struct {
		uint16	wYear;
		uint16	wMonth;
		uint16	wDayOfWeek;
		uint16	wDay;
		uint16	wHour;
		uint16	wMinute;
		uint16	wSecond;
		uint16	wMilliseconds;
	} SYSTEMTIME;

	/* pidLidTimeZoneStruct */
	typedef [public,flag(NDR_NOALIGN)] struct {
		uint32			lBias;
		uint32			lStandardBias;
		uint32			lDaylightBias;
		uint16			wStandardYear;
		SYSTEMTIME     		stStandardDate;
		uint16			wDaylightYear;
		SYSTEMTIME		stDaylightDate;
	} TimeZoneStruct;

	typedef [enum16bit] enum {
		TZRULE_FLAG_RECUR_CURRENT_TZREG	= 0x8000,
		TZRULE_FLAG_EFFECTIVE_TZREG	= 0x4000
	} TZRuleFlag;

	/* pidLidAppointmentTimeZoneDefinitionRecur,
	 * PidLidAppointmentTimeZoneDefinitionStartDisplay,
	 * PidLidAppointmentTimeZoneDefinitionEndDisplay */
	typedef [public,flag(NDR_NOALIGN)] struct {
		uint8		major; /* 0x02 */
		uint8		minor; /* 0x01 */
		uint16		reserved; /* must be 0x003E */
		TZRuleFlag	flags;
		uint16		wYear;
		uint8		X[14]; /* all zeroes */
		uint32		lBias;
		uint32		lStandardBias;
		uint32		lDaylightBias;
		SYSTEMTIME	stStandardDate;
		SYSTEMTIME	stDaylightDate;
	} TZRule;

	typedef [public,flag(NDR_NOALIGN)] struct {
		uint8								major; /* 0x02 */
		uint8								minor; /* 0x01 */
		uint16								cbHeader;
		uint16								reserved; /* 0x0002 */
		[flag(LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM)] string	keyName;
		uint16								cRules;
		TZRule								TZRules[cRules];
	} TimeZoneDefinition;

	/* pidLidGlobalObjectId */
	typedef [public,flag(NDR_NOALIGN)] struct {
		uint8			ByteArrayID[16];
		uint8			YH;
		uint8			YL;
 		uint8			Month;
 		uint8			D;
		FILETIME		CreationTime;
		uint8			X[8];
		uint32			Size;
		uint8			Data[Size];
	} GlobalObjectId;

	typedef [enum16bit] enum {
		eitLTPrivateFolder		= 0x01,
		eitLTPPublicFolder		= 0x03,
		eitLTPMappedPublicFolder	= 0x05,
		eitLTPPrivateMessage		= 0x07,
		eitLTPPublicMessage		= 0x09,
		eitLTPMappedPublicMessage	= 0x0b,
		eitLTPPublicNewsgroupFolder	= 0x0c
	} EntryIdFolderType;

	/* PtypServerId */
	typedef [public,flag(NDR_NOALIGN)] struct {
		uint8			ours;
		dlong			FolderId;
		dlong			MessageId;
		int32			Instance;
	} PtypServerId;

	/* FolderEntryId */
	typedef [public,flag(NDR_NOALIGN)] struct {
		uint32			Flags;
		GUID			ProviderUID;
		EntryIdFolderType	FolderType;
		GUID			FolderDatabaseGuid;
		[switch_is(1)] GLOBCNT	FolderGlobalCounter;
		uint16			Pad;
	} FolderEntryId;

	/* PR_ENTRYID/PR_TARGET_ENTRYID (messages) */
	typedef [public,flag(NDR_NOALIGN)] struct {
		uint32			Flags;
		GUID			ProviderUID;
		EntryIdFolderType	MessageType;
		GUID			FolderDatabaseGuid;
		[switch_is(1)] GLOBCNT	FolderGlobalCounter;
		uint16			Pad1;
		GUID			MessageDatabaseGuid;
		[switch_is(1)] GLOBCNT	MessageGlobalCounter;
		uint16			Pad2;
	} MessageEntryId;

	/* AddressBookEntryId */
	typedef [public,flag(NDR_NOALIGN)] struct {
		uint32			Flags;
		GUID			ProviderUID;
		uint32			Version;
		uint32			Type;
		astring			X500DN;
	} AddressBookEntryId;
}
