Пример #1
0
        private static bool SearchForCalendarItem(MailboxSession session, StoreObjectId folderId, GlobalObjectId globalObjectId, out bool isOrganizer, out string subject, out string organizerEmailAddress)
        {
            StoreId arg = null;

            isOrganizer           = false;
            subject               = null;
            organizerEmailAddress = null;
            using (CalendarFolder calendarFolder = CalendarFolder.Bind(session, folderId, null))
            {
                PropertyBag calendarItemProperties = calendarFolder.GetCalendarItemProperties(globalObjectId.Bytes, MeetingOrganizerValidator.CalendarOrganizerProperties);
                if (calendarItemProperties == null)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Related Calendar Item not found in calendar folder : '{0}'", calendarFolder.DisplayName);
                    return(false);
                }
                arg = calendarItemProperties.GetValueOrDefault <VersionedId>(InternalSchema.ItemId);
                string valueOrDefault = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.ItemClass);
                AppointmentStateFlags valueOrDefault2 = calendarItemProperties.GetValueOrDefault <AppointmentStateFlags>(InternalSchema.AppointmentStateInternal);
                isOrganizer           = IsOrganizerProperty.GetForCalendarItem(valueOrDefault, valueOrDefault2);
                subject               = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.MapiSubject);
                organizerEmailAddress = calendarItemProperties.GetValueOrDefault <string>(InternalSchema.SentRepresentingEmailAddress);
            }
            ExTraceGlobals.SyncTracer.TraceDebug <StoreId, bool>(0L, "Related Calendar Item found. Id: {0}.  Is Organizer? {1}", arg, isOrganizer);
            return(true);
        }
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            string text = validatablePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;

            if (!string.IsNullOrEmpty(text) && (ObjectClass.IsCalendarItem(text) || ObjectClass.IsRecurrenceException(text) || ObjectClass.IsMeetingMessage(text)) && validatablePropertyBag.IsPropertyDirty(InternalSchema.AppointmentStateInternal))
            {
                object obj = validatablePropertyBag.TryGetProperty(InternalSchema.AppointmentStateInternal);
                if (obj is int)
                {
                    AppointmentStateFlags appointmentStateFlags = (AppointmentStateFlags)obj;
                    if (EnumValidator <AppointmentStateFlags> .IsValidValue(appointmentStateFlags))
                    {
                        PropertyValueTrackingData originalPropertyInformation = validatablePropertyBag.GetOriginalPropertyInformation(InternalSchema.AppointmentStateInternal);
                        if (originalPropertyInformation.PropertyValueState == PropertyTrackingInformation.Modified && originalPropertyInformation.OriginalPropertyValue != null && !PropertyError.IsPropertyNotFound(originalPropertyInformation.OriginalPropertyValue))
                        {
                            AppointmentStateFlags appointmentStateFlags2 = (AppointmentStateFlags)originalPropertyInformation.OriginalPropertyValue;
                            bool flag  = (appointmentStateFlags2 & AppointmentStateFlags.Received) == AppointmentStateFlags.None;
                            bool flag2 = (appointmentStateFlags & AppointmentStateFlags.Received) == AppointmentStateFlags.None;
                            if (flag != flag2)
                            {
                                return(new StoreObjectValidationError(context, InternalSchema.AppointmentStateInternal, obj, this));
                            }
                        }
                    }
                }
            }
            return(null);
        }
        private bool IsOrganizerValid(MailboxSession organizerSession, CalendarInstanceContext instanceContext)
        {
            bool isOrganizer = false;
            CalendarVersionStoreGateway cvsGateway = instanceContext.ValidationContext.CvsGateway;

            cvsGateway.QueryByGlobalObjectId(organizerSession, instanceContext.ValidationContext.BaseItem.GlobalObjectId, string.Empty, new StorePropertyDefinition[]
            {
                StoreObjectSchema.ItemClass,
                CalendarItemBaseSchema.AppointmentState
            }, delegate(PropertyBag propertyBag)
            {
                string valueOrDefault = propertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass);
                if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault))
                {
                    AppointmentStateFlags valueOrDefault2 = propertyBag.GetValueOrDefault <AppointmentStateFlags>(CalendarItemBaseSchema.AppointmentState);
                    isOrganizer = ((valueOrDefault2 & AppointmentStateFlags.Received) == AppointmentStateFlags.None);
                    if (!isOrganizer)
                    {
                        return(false);
                    }
                }
                return(true);
            }, false, null, null, null);
            return(isOrganizer);
        }
Пример #4
0
 private static bool TryFindTimezoneRow(object[] row, out byte[] blob)
 {
     blob = null;
     if (!(row[0] is bool) || !(bool)row[0])
     {
         return(false);
     }
     if (!(row[3] is byte[]))
     {
         return(false);
     }
     if (row[2] is int)
     {
         if ((int)row[2] == 1)
         {
             blob = (byte[])row[3];
             return(true);
         }
     }
     else if (row[1] is int)
     {
         AppointmentStateFlags appointmentStateFlags = (AppointmentStateFlags)((int)row[1]);
         if (((appointmentStateFlags & AppointmentStateFlags.Meeting) == AppointmentStateFlags.Meeting && (appointmentStateFlags & AppointmentStateFlags.Received) == AppointmentStateFlags.None && (appointmentStateFlags & AppointmentStateFlags.Forward) == AppointmentStateFlags.None) || appointmentStateFlags == AppointmentStateFlags.None)
         {
             blob = (byte[])row[3];
             return(true);
         }
     }
     return(false);
 }
Пример #5
0
        protected virtual AppointmentStateFlags CalculatedAppointmentState()
        {
            this.CheckDisposed("CalculatedAppointmentState");
            AppointmentStateFlags appointmentStateFlags = this.AppointmentState;

            appointmentStateFlags |= AppointmentStateFlags.Meeting;
            return(appointmentStateFlags | AppointmentStateFlags.Received);
        }
Пример #6
0
 internal static bool GetForCalendarItem(string messageClass, AppointmentStateFlags flags)
 {
     if (!ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(messageClass) && !ObjectClass.IsCalendarItemSeries(messageClass))
     {
         throw new ArgumentException(string.Format("[IsOrganizerProperty.GetForCalendarItem] Message class MUST be a calendar item occurrence or recurrence exception in order to call this method.  ItemClass: {0}", messageClass));
     }
     return((flags & AppointmentStateFlags.Received) == AppointmentStateFlags.None);
 }
Пример #7
0
        protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            AppointmentStateFlags?valueAsNullable       = propertyBag.GetValueAsNullable <AppointmentStateFlags>(InternalSchema.AppointmentStateInternal);
            AppointmentStateFlags appointmentStateFlags = (AppointmentStateFlags)value;

            if (valueAsNullable != null && (valueAsNullable.Value & AppointmentStateFlags.Received) == AppointmentStateFlags.Received && (appointmentStateFlags & AppointmentStateFlags.Received) != AppointmentStateFlags.Received)
            {
                propertyBag.SetLocationIdentifier(63651U, LastChangeAction.SmartPropertyFixup);
                ExTraceGlobals.StorageTracer.TraceInformation(63651, (long)propertyBag.GetHashCode(), "Prevent from removing Received flag on AppointmentState");
                appointmentStateFlags |= AppointmentStateFlags.Received;
            }
            propertyBag.SetValueWithFixup(InternalSchema.AppointmentStateInternal, appointmentStateFlags);
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            bool valueOrDefault = propertyBag.GetValueOrDefault <bool>(InternalSchema.AppointmentRecurring);

            if (valueOrDefault)
            {
                AppointmentStateFlags valueOrDefault2 = propertyBag.GetValueOrDefault <AppointmentStateFlags>(InternalSchema.AppointmentStateInternal);
                return(CalendarItemBase.IsAppointmentStateCancelled(valueOrDefault2));
            }
            CalendarItemOccurrence calendarItemOccurrence = propertyBag.Context.StoreObject as CalendarItemOccurrence;

            if (calendarItemOccurrence != null)
            {
                AppointmentStateFlags valueOrDefault3 = calendarItemOccurrence.OccurrencePropertyBag.MasterCalendarItem.GetValueOrDefault <AppointmentStateFlags>(CalendarItemBaseSchema.AppointmentState);
                return(CalendarItemBase.IsAppointmentStateCancelled(valueOrDefault3));
            }
            return(new PropertyError(this, PropertyErrorCode.NotFound));
        }
        // Token: 0x0600091E RID: 2334 RVA: 0x0003D7E8 File Offset: 0x0003B9E8
        private static CalendarNotificationType AnalyzeEvent(MailboxData mailboxData, MapiEvent mapiEvent, StoreObject item)
        {
            StoreObjectId defaultCalendarFolderId = mailboxData.DefaultCalendarFolderId;

            if (item == null)
            {
                return(CalendarNotificationType.DeletedUpdate);
            }
            AppointmentStateFlags     valueOrDefault            = item.GetValueOrDefault <AppointmentStateFlags>(CalendarItemBaseSchema.AppointmentState);
            ChangeHighlightProperties changeHighlightProperties = item.GetValueOrDefault <ChangeHighlightProperties>(CalendarItemBaseSchema.ChangeHighlight);
            CalendarItemType          valueOrDefault2           = item.GetValueOrDefault <CalendarItemType>(CalendarItemBaseSchema.CalendarItemType, CalendarItemType.Single);
            ResponseType valueOrDefault3 = item.GetValueOrDefault <ResponseType>(CalendarItemBaseSchema.ResponseType, ResponseType.None);

            if (changeHighlightProperties == ChangeHighlightProperties.None && valueOrDefault2 != CalendarItemType.Single)
            {
                changeHighlightProperties = (ChangeHighlightProperties)(-1);
            }
            return(CalendarChangeProcessor.AnalyzeEvent(mapiEvent, defaultCalendarFolderId, valueOrDefault, changeHighlightProperties, valueOrDefault3));
        }
Пример #10
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            bool?  flag           = null;
            string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault) || ObjectClass.IsCalendarItemSeries(valueOrDefault))
            {
                AppointmentStateFlags valueOrDefault2 = propertyBag.GetValueOrDefault <AppointmentStateFlags>(InternalSchema.AppointmentStateInternal);
                flag = new bool?(IsOrganizerProperty.GetForCalendarItem(valueOrDefault, valueOrDefault2));
            }
            else if (ObjectClass.IsMeetingMessage(valueOrDefault))
            {
                MeetingMessage meetingMessage = propertyBag.Context.StoreObject as MeetingMessage;
                if (meetingMessage != null)
                {
                    CalendarItemBase calendarItemBase = null;
                    try
                    {
                        calendarItemBase = meetingMessage.GetCorrelatedItemInternal(true);
                    }
                    catch (CorruptDataException)
                    {
                    }
                    catch (CorrelationFailedException)
                    {
                    }
                    if (calendarItemBase != null)
                    {
                        flag = new bool?(calendarItemBase.IsOrganizer());
                    }
                    else if (!(meetingMessage is MeetingResponse))
                    {
                        flag = new bool?(meetingMessage.IsMailboxOwnerTheSender());
                    }
                }
            }
            if (flag != null)
            {
                return(flag);
            }
            return(new PropertyError(this, PropertyErrorCode.NotFound));
        }
Пример #11
0
        internal static CalendarEvent CreateFromQueryData(EmailAddress mailbox, object[] properties, FreeBusyViewType allowedView, bool isCallerMailboxOwner, ExchangeVersionType exchangeVersion)
        {
            CalendarEvent calendarEvent = new CalendarEvent();

            calendarEvent.viewType       = allowedView;
            calendarEvent.globalObjectId = CalendarEvent.GetPropertyValue <byte[]>(properties, QueryPropertyIndexes.GlobalObjectId);
            calendarEvent.StartTime      = DateTime.SpecifyKind((DateTime)CalendarEvent.GetPropertyValue <ExDateTime>(properties, QueryPropertyIndexes.StartTime, ExDateTime.MinValue), DateTimeKind.Unspecified);
            calendarEvent.EndTime        = DateTime.SpecifyKind((DateTime)CalendarEvent.GetPropertyValue <ExDateTime>(properties, QueryPropertyIndexes.EndTime, ExDateTime.MinValue), DateTimeKind.Unspecified);
            BusyType busyType = CalendarEvent.GetPropertyValue <BusyType>(properties, QueryPropertyIndexes.BusyStatus, BusyType.Busy);

            if (busyType < BusyType.Free || busyType > BusyType.NoData)
            {
                CalendarEvent.CalendarViewTracer.TraceError((long)calendarEvent.GetHashCode(), "{0}: Calendar event with start time {1} and end time {2} in mailbox {3} has invalid busy type: {4}. This is being returned as BusyType.Tentative", new object[]
                {
                    TraceContext.Get(),
                    calendarEvent.StartTime,
                    calendarEvent.EndTime,
                    mailbox,
                    busyType
                });
                calendarEvent.BusyType = BusyType.Tentative;
            }
            else
            {
                if (exchangeVersion < ExchangeVersionType.Exchange2012 && busyType == BusyType.WorkingElsewhere)
                {
                    busyType = BusyType.Free;
                }
                calendarEvent.BusyType = busyType;
            }
            Sensitivity propertyValue = CalendarEvent.GetPropertyValue <Sensitivity>(properties, QueryPropertyIndexes.Sensitivity, Sensitivity.Normal);

            if (propertyValue < Sensitivity.Normal || propertyValue > Sensitivity.CompanyConfidential)
            {
                CalendarEvent.CalendarViewTracer.TraceError((long)calendarEvent.GetHashCode(), "{0}: Calendar event with start time {1} and end time {2} in mailbox {3} has invalid sensitivity value: {4}.", new object[]
                {
                    TraceContext.Get(),
                    calendarEvent.StartTime,
                    calendarEvent.EndTime,
                    mailbox,
                    propertyValue
                });
            }
            VersionedId propertyValue2 = CalendarEvent.GetPropertyValue <VersionedId>(properties, QueryPropertyIndexes.EntryId);
            ByteArray   byteArray      = new ByteArray(propertyValue2.ObjectId.ProviderLevelItemId);

            if (allowedView != FreeBusyViewType.Detailed && allowedView != FreeBusyViewType.DetailedMerged)
            {
                return(calendarEvent);
            }
            calendarEvent.CalendarEventDetails = new CalendarEventDetails();
            CalendarEventDetails calendarEventDetails = calendarEvent.CalendarEventDetails;

            calendarEventDetails.IsPrivate = (propertyValue != Sensitivity.Normal);
            if (calendarEventDetails.IsPrivate && !isCallerMailboxOwner)
            {
                CalendarEvent.CalendarViewTracer.TraceError((long)calendarEvent.GetHashCode(), "{0}: Calendar event with start time {1} and end time {2} in mailbox {3} is a private item. Detail data will not be included.", new object[]
                {
                    TraceContext.Get(),
                    calendarEvent.StartTime,
                    calendarEvent.EndTime,
                    mailbox
                });
                return(calendarEvent);
            }
            calendarEventDetails.ID            = byteArray.ToString();
            calendarEventDetails.Subject       = CalendarEvent.GetPropertyValue <string>(properties, QueryPropertyIndexes.Subject);
            calendarEventDetails.Location      = CalendarEvent.GetPropertyValue <string>(properties, QueryPropertyIndexes.Location);
            calendarEventDetails.IsReminderSet = CalendarEvent.GetPropertyValue <bool>(properties, QueryPropertyIndexes.IsReminderSet, false);
            AppointmentStateFlags propertyValue3 = CalendarEvent.GetPropertyValue <AppointmentStateFlags>(properties, QueryPropertyIndexes.AppointmentState, AppointmentStateFlags.None);

            calendarEventDetails.IsMeeting = ((propertyValue3 & AppointmentStateFlags.Meeting) > AppointmentStateFlags.None);
            CalendarItemType propertyValue4 = CalendarEvent.GetPropertyValue <CalendarItemType>(properties, QueryPropertyIndexes.CalendarItemType, CalendarItemType.Single);

            if (propertyValue4 == CalendarItemType.Occurrence)
            {
                calendarEventDetails.IsRecurring = true;
            }
            if (propertyValue4 == CalendarItemType.Exception)
            {
                calendarEventDetails.IsException = true;
                calendarEventDetails.IsRecurring = true;
            }
            return(calendarEvent);
        }
        // Token: 0x0600091D RID: 2333 RVA: 0x0003D75C File Offset: 0x0003B95C
        private static CalendarNotificationType AnalyzeEvent(MapiEvent mapiEvent, StoreObjectId defaultCalFldrId, AppointmentStateFlags flags, ChangeHighlightProperties changeHilite, ResponseType responseType)
        {
            CalendarNotificationType result = CalendarNotificationType.Uninteresting;

            if ((AppointmentStateFlags.Cancelled & flags) != AppointmentStateFlags.None || (MapiEventTypeFlags.ObjectDeleted & mapiEvent.EventMask) != (MapiEventTypeFlags)0)
            {
                result = CalendarNotificationType.DeletedUpdate;
            }
            else if (((MapiEventTypeFlags.ObjectCreated | MapiEventTypeFlags.ObjectCopied) & mapiEvent.EventMask) != (MapiEventTypeFlags)0)
            {
                result = CalendarNotificationType.NewUpdate;
            }
            else if ((MapiEventTypeFlags.ObjectModified & mapiEvent.EventMask) != (MapiEventTypeFlags)0 && (CalendarChangeProcessor.InterestingFlagsExists(changeHilite, mapiEvent.ExtendedEventFlags) || ResponseType.Organizer == responseType))
            {
                result = CalendarNotificationType.ChangedUpdate;
            }
            else if ((MapiEventTypeFlags.ObjectMoved & mapiEvent.EventMask) != (MapiEventTypeFlags)0)
            {
                if (object.Equals(defaultCalFldrId, StoreObjectId.FromProviderSpecificId(mapiEvent.ParentEntryId)))
                {
                    result = CalendarNotificationType.NewUpdate;
                }
                else if (object.Equals(defaultCalFldrId, StoreObjectId.FromProviderSpecificId(mapiEvent.OldParentEntryId)))
                {
                    result = CalendarNotificationType.DeletedUpdate;
                }
            }
            return(result);
        }
Пример #13
0
        public static MessageItem CreateForward(MessageItem originalItem, bool asAttachment, CultureInfo culture, string imceaDomain, string xLoop, ExTimeZone timeZone, IRuleEvaluationContext context)
        {
            Util.ThrowOnNullArgument(originalItem, "originalItem");
            Util.ThrowOnNullArgument(culture, "culture");
            Util.ThrowOnNullOrEmptyArgument(imceaDomain, "imceaDomain");
            ExTraceGlobals.StorageTracer.Information(0L, "RuleMessageUtils::CreateForward.");
            MessageItem messageItem = null;
            bool        flag        = false;
            MessageItem result;

            try
            {
                ForwardCreationFlags forwardCreationFlags = ForwardCreationFlags.None;
                string className = originalItem.ClassName;
                if (ObjectClass.IsMeetingMessage(className))
                {
                    forwardCreationFlags |= ForwardCreationFlags.TreatAsMeetingMessage;
                }
                messageItem = context.CreateMessageItem(InternalSchema.ContentConversionProperties);
                messageItem[InternalSchema.ItemClass] = "IPM.Note";
                StoreSession storeSession = context.StoreSession ?? originalItem.Session;
                if (asAttachment)
                {
                    ForwardAsAttachmentCreation forwardAsAttachmentCreation = new ForwardAsAttachmentCreation(originalItem, messageItem, new ReplyForwardConfiguration(forwardCreationFlags, culture)
                    {
                        XLoop    = xLoop,
                        TimeZone = timeZone,
                        ConversionOptionsForSmime = new InboundConversionOptions(storeSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), imceaDomain)
                    });
                    forwardAsAttachmentCreation.PopulateProperties();
                }
                else
                {
                    bool flag2        = ObjectClass.IsMeetingCancellation(className);
                    bool flag3        = ObjectClass.IsMeetingRequest(className);
                    bool isRestricted = originalItem.IsRestricted;
                    if (flag2)
                    {
                        messageItem[InternalSchema.ItemClass] = "IPM.Schedule.Meeting.Canceled";
                        messageItem[InternalSchema.IconIndex] = IconIndex.AppointmentMeetCancel;
                    }
                    else if (flag3)
                    {
                        messageItem[InternalSchema.ItemClass]           = "IPM.Schedule.Meeting.Request";
                        messageItem[InternalSchema.IsResponseRequested] = true;
                        messageItem[InternalSchema.IsReplyRequested]    = true;
                    }
                    else if (isRestricted)
                    {
                        messageItem[StoreObjectSchema.ContentClass] = "rpmsg.message";
                        messageItem.IconIndex = IconIndex.MailIrm;
                    }
                    BodyFormat format = originalItem.Body.Format;
                    ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(format, forwardCreationFlags, culture);
                    replyForwardConfiguration.XLoop    = xLoop;
                    replyForwardConfiguration.TimeZone = timeZone;
                    replyForwardConfiguration.ConversionOptionsForSmime = new InboundConversionOptions(storeSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), imceaDomain);
                    RuleMessageUtils.GenerateHeader(replyForwardConfiguration, originalItem);
                    ForwardCreation forwardCreation = new ForwardCreation(originalItem, messageItem, replyForwardConfiguration);
                    forwardCreation.PopulateProperties();
                    if (flag2 || flag3)
                    {
                        AppointmentStateFlags appointmentStateFlags = messageItem.GetValueOrDefault <AppointmentStateFlags>(InternalSchema.AppointmentState);
                        appointmentStateFlags |= (AppointmentStateFlags.Meeting | AppointmentStateFlags.Received);
                        messageItem[InternalSchema.AppointmentState] = appointmentStateFlags;
                        int num = messageItem.GetValueOrDefault <int>(InternalSchema.AppointmentAuxiliaryFlags, 0);
                        num |= 4;
                        messageItem[InternalSchema.AppointmentAuxiliaryFlags] = num;
                        if (flag3)
                        {
                            List <BlobRecipient> list = BlobRecipientParser.ReadRecipients(originalItem, InternalSchema.UnsendableRecipients);
                            list = MeetingRequest.FilterBlobRecipientList(list);
                            list = MeetingRequest.MergeRecipientLists(originalItem.Recipients, list);
                            list = MeetingRequest.FilterBlobRecipientList(list);
                            BlobRecipientParser.WriteRecipients(messageItem, InternalSchema.UnsendableRecipients, list);
                        }
                    }
                }
                flag   = true;
                result = messageItem;
            }
            finally
            {
                if (!flag && messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
            return(result);
        }