// // Appointment.cs // // Author: Kees van Spelde // // Copyright (c) 2013-2018 Magic-Sessions. (www.magic-sessions.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // using System; using System.Collections.Generic; using System.Collections.ObjectModel; using MsgReader.Localization; namespace MsgReader.Outlook { #region Enum AppointmentRecurrenceType /// /// The recurrence type of an appointment /// public enum AppointmentRecurrenceType { /// /// There is no reccurence /// None = -1, /// /// The appointment is daily /// Daily = 0, /// /// The appointment is weekly /// Weekly = 1, /// /// The appointment is monthly /// Montly = 2, /// /// The appointment is yearly /// Yearly = 3 } #endregion #region Enum AppointmentClientIntent /// /// The intent of an appointment /// public enum AppointmentClientIntent { /// /// The user is the owner of the Meeting object's /// Manager = 1, /// /// The user is a delegate acting on a Meeting object in a delegator's Calendar folder. If this bit is set, the /// ciManager bit SHOULD NOT be set /// Delegate = 2, /// /// The user deleted the Meeting object with no response sent to the organizer /// DeletedWithNoResponse = 4, /// /// The user deleted an exception to a recurring series with no response sent to the organizer /// DeletedExceptionWithNoResponse = 8, /// /// Appointment accepted as tentative /// RespondedTentative = 16, /// /// Appointment accepted /// RespondedAccept = 32, /// /// Appointment declined /// RespondedDecline = 64, /// /// The user modified the start time /// ModifiedStartTime = 128, /// /// The user modified the end time /// ModifiedEndTime = 256, /// /// The user changed the location of the meeting /// ModifiedLocation = 512, /// /// The user declined an exception to a recurring series /// RespondedExceptionDecline = 1024, /// /// The user declined an exception to a recurring series /// Canceled = 2048, /// /// The user canceled an exception to a recurring serie /// ExceptionCanceled = 4096 } #endregion public partial class Storage { /// /// Class used to contain all the appointment information of a . /// public sealed class Appointment : Storage { #region Properties /// /// Returns the location for the appointment, null when not available /// public string Location { get; } /// /// Returns the start time for the appointment, null when not available /// public DateTime? Start { get; } /// /// Returns the end time for the appointment, null when not available /// public DateTime? End { get; } /// /// Returns a string with all the attendees (To and CC), if you also want their E-mail addresses then /// get the from the message, null when not available /// public string AllAttendees { get; } /// /// Returns a string with all the TO (mandatory) attendees. If you also want their E-mail addresses then /// get the from the and filter this /// one on . Null when not available /// public string ToAttendees { get; } /// /// Returns a string with all the CC (optional) attendees. If you also want their E-mail addresses then /// get the from the and filter this /// one on . Null when not available /// public string CcAttendees { get; } /// /// Returns A value of true for the PidLidAppointmentNotAllowPropose property ([MS-OXPROPS] section 2.17) /// indicates that attendees are not allowed to propose a new date and/or time for the meeting. A value of /// false or the absence of this property indicates that the attendees are allowed to propose a new date /// and/or time. This property is meaningful only on Meeting objects, Meeting Request objects, and Meeting /// Update objects. Null when not available /// public bool? NotAllowPropose { get; } /// /// Returns a object with all the unsendable attendees. Null when not available /// public UnsendableRecipients UnsendableRecipients { get; } /// /// Returns the reccurence type (daily, weekly, monthly or yearly) for the /// public AppointmentRecurrenceType ReccurrenceType { get; } /// /// Returns the reccurence type (daily, weekly, monthly or yearly) for the as a /// string, /// null when not available /// public string RecurrenceTypeText { get; } /// /// Returns the reccurence patern for the , null when not available /// public string RecurrencePatern { get; } /// /// The clients intention for the the as a list, /// null when not available /// of /// public ReadOnlyCollection ClientIntent { get; } /// /// The for the the as text /// public string ClientIntentText { get; } #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The message. internal Appointment(Storage message) : base(message._rootStorage) { //GC.SuppressFinalize(message); _namedProperties = message._namedProperties; _propHeaderSize = MapiTags.PropertiesStreamHeaderTop; Location = GetMapiPropertyString(MapiTags.Location); Start = GetMapiPropertyDateTime(MapiTags.AppointmentStartWhole); End = GetMapiPropertyDateTime(MapiTags.AppointmentEndWhole); AllAttendees = GetMapiPropertyString(MapiTags.AppointmentAllAttendees); ToAttendees = GetMapiPropertyString(MapiTags.AppointmentToAttendees); CcAttendees = GetMapiPropertyString(MapiTags.AppointmentCCAttendees); NotAllowPropose = GetMapiPropertyBool(MapiTags.AppointmentNotAllowPropose); UnsendableRecipients = GetUnsendableRecipients(MapiTags.AppointmentUnsendableRecipients); #region Recurrence var recurrenceType = GetMapiPropertyInt32(MapiTags.ReccurrenceType); if (recurrenceType == null) { ReccurrenceType = AppointmentRecurrenceType.None; RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeNoneText; } else { switch (recurrenceType) { case 1: ReccurrenceType = AppointmentRecurrenceType.Daily; break; case 2: ReccurrenceType = AppointmentRecurrenceType.Weekly; break; case 3: case 4: ReccurrenceType = AppointmentRecurrenceType.Montly; break; case 5: case 6: ReccurrenceType = AppointmentRecurrenceType.Yearly; break; default: ReccurrenceType = AppointmentRecurrenceType.None; break; } switch (ReccurrenceType) { case AppointmentRecurrenceType.Daily: RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeDailyText; break; case AppointmentRecurrenceType.Weekly: RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeWeeklyText; break; case AppointmentRecurrenceType.Montly: RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeMonthlyText; break; case AppointmentRecurrenceType.Yearly: RecurrenceTypeText = LanguageConsts.AppointmentReccurenceTypeYearlyText; break; } } RecurrencePatern = GetMapiPropertyString(MapiTags.ReccurrencePattern); #endregion #region ClientIntent var clientIntentList = new List(); var clientIntent = GetMapiPropertyInt32(MapiTags.PidLidClientIntent); if (clientIntent == null) { ClientIntent = null; } else { var bitwiseValue = (int) clientIntent; if ((bitwiseValue & 1) == 1) { clientIntentList.Add(AppointmentClientIntent.Manager); ClientIntentText = LanguageConsts.AppointmentClientIntentManagerText; } if ((bitwiseValue & 2) == 2) { clientIntentList.Add(AppointmentClientIntent.Delegate); ClientIntentText = LanguageConsts.AppointmentClientIntentDelegateText; } if ((bitwiseValue & 4) == 4) { clientIntentList.Add(AppointmentClientIntent.DeletedWithNoResponse); ClientIntentText = LanguageConsts.AppointmentClientIntentDeletedWithNoResponseText; } if ((bitwiseValue & 8) == 8) { clientIntentList.Add(AppointmentClientIntent.DeletedExceptionWithNoResponse); ClientIntentText = LanguageConsts.AppointmentClientIntentDeletedExceptionWithNoResponseText; } if ((bitwiseValue & 16) == 16) { clientIntentList.Add(AppointmentClientIntent.RespondedTentative); ClientIntentText = LanguageConsts.AppointmentClientIntentRespondedTentativeText; } if ((bitwiseValue & 32) == 32) { clientIntentList.Add(AppointmentClientIntent.RespondedAccept); ClientIntentText = LanguageConsts.AppointmentClientIntentRespondedAcceptText; } if ((bitwiseValue & 64) == 64) { clientIntentList.Add(AppointmentClientIntent.RespondedDecline); ClientIntentText = LanguageConsts.AppointmentClientIntentRespondedDeclineText; } if ((bitwiseValue & 128) == 128) { clientIntentList.Add(AppointmentClientIntent.ModifiedStartTime); ClientIntentText = LanguageConsts.AppointmentClientIntentModifiedStartTimeText; } if ((bitwiseValue & 256) == 256) { clientIntentList.Add(AppointmentClientIntent.ModifiedEndTime); ClientIntentText = LanguageConsts.AppointmentClientIntentModifiedEndTimeText; } if ((bitwiseValue & 512) == 512) { clientIntentList.Add(AppointmentClientIntent.ModifiedLocation); ClientIntentText = LanguageConsts.AppointmentClientIntentModifiedLocationText; } if ((bitwiseValue & 1024) == 1024) { clientIntentList.Add(AppointmentClientIntent.RespondedExceptionDecline); ClientIntentText = LanguageConsts.AppointmentClientIntentRespondedExceptionDeclineText; } if ((bitwiseValue & 2048) == 2048) { clientIntentList.Add(AppointmentClientIntent.Canceled); ClientIntentText = LanguageConsts.AppointmentClientIntentCanceledText; } if ((bitwiseValue & 4096) == 4096) { clientIntentList.Add(AppointmentClientIntent.ExceptionCanceled); ClientIntentText = LanguageConsts.AppointmentClientIntentExceptionCanceledText; } ClientIntent = clientIntentList.AsReadOnly(); } #endregion } #endregion } } }