private static string ItemClassFromResponseType(string itemClassPrefix, ResponseType responseType)
        {
            bool   flag = ObjectClass.IsMeetingResponseSeries(itemClassPrefix);
            string result;

            switch (responseType)
            {
            case ResponseType.Tentative:
                result = (flag ? "IPM.MeetingMessageSeries.Resp.Tent" : "IPM.Schedule.Meeting.Resp.Tent");
                break;

            case ResponseType.Accept:
                result = (flag ? "IPM.MeetingMessageSeries.Resp.Pos" : "IPM.Schedule.Meeting.Resp.Pos");
                break;

            case ResponseType.Decline:
                result = (flag ? "IPM.MeetingMessageSeries.Resp.Neg" : "IPM.Schedule.Meeting.Resp.Neg");
                break;

            default:
                throw new ArgumentException(ServerStrings.ExUnknownResponseType, "responseType");
            }
            return(result);
        }
        internal static void ModifySubjectProperty(PropertyBag.BasicPropertyStore item, NativeStorePropertyDefinition property, string value)
        {
            string text  = item.GetValue(InternalSchema.SubjectPrefixInternal) as string;
            string text2 = item.GetValue(InternalSchema.NormalizedSubjectInternal) as string;
            string text3 = item.GetValue(InternalSchema.MapiSubject) as string;

            if (property == InternalSchema.NormalizedSubjectInternal)
            {
                text2 = value;
                if (text3 != null)
                {
                    string text4 = SubjectProperty.ExtractPrefixUsingNormalizedSubject(text3, text2);
                    if (text4 != null)
                    {
                        text = text4;
                    }
                }
                if (text == null)
                {
                    text = string.Empty;
                }
            }
            else if (property == InternalSchema.SubjectPrefixInternal)
            {
                text = value;
                if (text3 != null && text3.StartsWith(text, StringComparison.Ordinal))
                {
                    text2 = text3.Substring(text.Length);
                }
                if (text2 == null)
                {
                    text2 = string.Empty;
                }
            }
            else
            {
                if (property != InternalSchema.MapiSubject)
                {
                    throw new ArgumentException("Not a supported subject property", "property");
                }
                if (!string.IsNullOrEmpty(text) && value.StartsWith(text, StringComparison.Ordinal))
                {
                    text2 = value.Substring(text.Length);
                }
                else if (!string.IsNullOrEmpty(text2))
                {
                    string text5 = SubjectProperty.ExtractPrefixUsingNormalizedSubject(value, text2);
                    if (text5 != null)
                    {
                        text = text5;
                    }
                    else
                    {
                        SubjectProperty.ComputeSubjectPrefix(value, out text, out text2);
                    }
                }
                else
                {
                    SubjectProperty.ComputeSubjectPrefix(value, out text, out text2);
                }
            }
            text3 = text + text2;
            item.SetValueWithFixup(InternalSchema.SubjectPrefixInternal, text);
            item.SetValueWithFixup(InternalSchema.NormalizedSubjectInternal, text2);
            item.SetValueWithFixup(InternalSchema.MapiSubject, text3);
            string itemClass = item.GetValue(InternalSchema.ItemClass) as string;

            if (!ObjectClass.IsPost(itemClass))
            {
                item.SetValueWithFixup(InternalSchema.ConversationTopic, text2);
            }
        }
Exemple #3
0
 protected override StoreObjectType GetStoreObjectType(PropertyBag.BasicPropertyStore propertyBag)
 {
     return(ObjectClass.GetObjectType(propertyBag.GetValue(InternalSchema.ItemClass) as string));
 }
Exemple #4
0
        internal static Charset GetItemOutboundMimeCharset(Item item, OutboundConversionOptions options)
        {
            Charset charset   = ConvertUtils.GetItemOutboundMimeCharsetInternal(item, options);
            string  className = item.ClassName;

            if (options.DetectionOptions.PreferredCharset == null && charset.CodePage != 54936 && (ObjectClass.IsTaskRequest(className) || ObjectClass.IsMeetingMessage(className) || ObjectClass.IsCalendarItem(className)))
            {
                charset = Charset.GetCharset(65001);
            }
            return(charset);
        }
        private void ParseRecipientTable()
        {
            string valueOrDefault = base.CoreItem.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass);

            if (base.ConversionOptions.IsSenderTrusted || !base.MessageWriter.IsTopLevelWriter || ObjectClass.IsNonSendableWithRecipients(valueOrDefault) || ObjectClass.IsDsn(valueOrDefault))
            {
                TnefPropertyReader propertyReader = this.reader.PropertyReader;
                while (propertyReader.ReadNextRow())
                {
                    this.NewRecipient();
                    while (propertyReader.ReadNextProperty())
                    {
                        this.ParseTnefProperty(propertyReader, false);
                    }
                    this.EndRecipient();
                    this.isRecipientTablePromoted = true;
                }
            }
        }
        internal ReplyForwardCommon(Item originalItem, Item newItem, ReplyForwardConfiguration parameters, bool decodeSmime)
        {
            Util.ThrowOnNullArgument(parameters, "parameters");
            if (decodeSmime && ObjectClass.IsSmime(originalItem.ClassName))
            {
                if (parameters.ConversionOptionsForSmime == null || parameters.ConversionOptionsForSmime.IgnoreImceaDomain || parameters.ConversionOptionsForSmime.ImceaEncapsulationDomain == null)
                {
                    throw new InvalidOperationException("Cannot decode SMIME without valid ConversionOptionsForSmime");
                }
                this.originalItem = originalItem;
                MessageItem messageItem = originalItem as MessageItem;
                if (messageItem != null)
                {
                    Item item = messageItem.FetchSmimeContent(parameters.ConversionOptionsForSmime.ImceaEncapsulationDomain);
                    if (item != null)
                    {
                        this.originalItem = item;
                        this.originalItem[InternalSchema.NormalizedSubjectInternal] = messageItem.GetValueOrDefault <string>(InternalSchema.NormalizedSubjectInternal, string.Empty);
                        this.originalItem[InternalSchema.Sender] = messageItem.Sender;
                        this.originalItem[InternalSchema.From]   = messageItem.From;
                    }
                }
            }
            else
            {
                this.originalItem = originalItem;
            }
            this.newItem    = newItem;
            this.parameters = parameters;
            this.culture    = ReplyForwardUtils.CalculateReplyForwardCulture(parameters.Culture, newItem);
            if (this.culture == null)
            {
                throw new InvalidOperationException("Forward message culture is unknown");
            }
            this.FetchPropertiesFromOriginalItem();
            if (originalItem is MessageItem)
            {
                if (originalItem.MapiMessage != null)
                {
                    SetReadFlags readFlag = parameters.ShouldSuppressReadReceipt ? SetReadFlags.SuppressReceipt : SetReadFlags.None;
                    try
                    {
                        StoreSession session = originalItem.Session;
                        bool         flag    = false;
                        try
                        {
                            if (session != null)
                            {
                                session.BeginMapiCall();
                                session.BeginServerHealthCall();
                                flag = true;
                            }
                            if (StorageGlobals.MapiTestHookBeforeCall != null)
                            {
                                StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                            }
                            originalItem.MapiMessage.SetReadFlag(readFlag);
                        }
                        catch (MapiPermanentException ex)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex, session, this, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("ReplyForwardCommon::ctor.", new object[0]),
                                ex
                            });
                        }
                        catch (MapiRetryableException ex2)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("ReplyForwardCommon::ctor.", new object[0]),
                                ex2
                            });
                        }
                        finally
                        {
                            try
                            {
                                if (session != null)
                                {
                                    session.EndMapiCall();
                                    if (flag)
                                    {
                                        session.EndServerHealthCall();
                                    }
                                }
                            }
                            finally
                            {
                                if (StorageGlobals.MapiTestHookAfterCall != null)
                                {
                                    StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                                }
                            }
                        }
                    }
                    catch (StoragePermanentException)
                    {
                    }
                    catch (StorageTransientException)
                    {
                    }
                }
                (this.originalItem as MessageItem).IsRead = true;
            }
            else if (this.originalItem is CalendarItemOccurrence)
            {
                this.parentPropValues[ParentPropertyIndex.IsRecurring]               = true;
                this.parentPropValues[ParentPropertyIndex.AppointmentRecurring]      = false;
                this.parentPropValues[ParentPropertyIndex.RecurrenceType]            = 0;
                this.parentPropValues[ParentPropertyIndex.TimeZoneBlob]              = new PropertyError(InternalSchema.TimeZoneBlob, PropertyErrorCode.NotFound);
                this.parentPropValues[ParentPropertyIndex.AppointmentRecurrenceBlob] = new PropertyError(InternalSchema.AppointmentRecurrenceBlob, PropertyErrorCode.NotFound);
                this.parentPropValues[ParentPropertyIndex.IsException]               = true;
                if (string.IsNullOrEmpty(this.parentPropValues[ParentPropertyIndex.RecurrencePattern] as string))
                {
                    CalendarItemOccurrence calendarItemOccurrence = this.originalItem as CalendarItemOccurrence;
                    this.parentPropValues[ParentPropertyIndex.RecurrencePattern] = calendarItemOccurrence.OccurrencePropertyBag.MasterCalendarItem.GenerateWhen();
                }
            }
            string valueOrDefault = originalItem.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            this.originalItemSigned = (ObjectClass.IsOfClass(valueOrDefault, "IPM.Note.Secure.Sign") || ObjectClass.IsSmimeClearSigned(valueOrDefault));
            if (!this.originalItemSigned)
            {
                this.originalItemEncrypted = (ObjectClass.IsOfClass(valueOrDefault, "IPM.Note.Secure") || ObjectClass.IsSmime(valueOrDefault));
            }
            string valueOrDefault2 = originalItem.GetValueOrDefault <string>(InternalSchema.ContentClass, string.Empty);

            this.originalItemIrm = ObjectClass.IsRightsManagedContentClass(valueOrDefault2);
        }
        private static Notification CreateNotification(MapiNotification notification)
        {
            Notification result;

            if (notification.NotificationType == AdviseFlags.NewMail)
            {
                MapiNewMailNotification mapiNewMailNotification = notification as MapiNewMailNotification;
                result = new NewMailNotification(StoreObjectId.FromProviderSpecificId(mapiNewMailNotification.EntryId, ObjectClass.GetObjectType(mapiNewMailNotification.MessageClass)), StoreObjectId.FromProviderSpecificId(mapiNewMailNotification.ParentId, StoreObjectType.Folder), mapiNewMailNotification.MessageClass, (MessageFlags)mapiNewMailNotification.MessageFlags);
            }
            else if (notification.NotificationType == AdviseFlags.SearchComplete)
            {
                result = new ObjectNotification(null, null, null, null, (NotificationObjectType)0, null, NotificationType.SearchComplete);
            }
            else if (notification.NotificationType == AdviseFlags.ConnectionDropped)
            {
                MapiConnectionDroppedNotification mapiConnectionDroppedNotification = notification as MapiConnectionDroppedNotification;
                result = new ConnectionDroppedNotification(mapiConnectionDroppedNotification.ServerDN, mapiConnectionDroppedNotification.UserDN, mapiConnectionDroppedNotification.TickDeath);
            }
            else
            {
                MapiObjectNotification mapiObjectNotification = notification as MapiObjectNotification;
                if (mapiObjectNotification == null)
                {
                    throw new InvalidOperationException(ServerStrings.ExNotSupportedNotificationType((uint)notification.NotificationType));
                }
                AdviseFlags      notificationType = notification.NotificationType;
                NotificationType type;
                if (notificationType <= AdviseFlags.ObjectDeleted)
                {
                    if (notificationType == AdviseFlags.ObjectCreated)
                    {
                        type = NotificationType.Created;
                        goto IL_10A;
                    }
                    if (notificationType == AdviseFlags.ObjectDeleted)
                    {
                        type = NotificationType.Deleted;
                        goto IL_10A;
                    }
                }
                else
                {
                    if (notificationType == AdviseFlags.ObjectModified)
                    {
                        type = NotificationType.Modified;
                        goto IL_10A;
                    }
                    if (notificationType == AdviseFlags.ObjectMoved)
                    {
                        type = NotificationType.Moved;
                        goto IL_10A;
                    }
                    if (notificationType == AdviseFlags.ObjectCopied)
                    {
                        type = NotificationType.Copied;
                        goto IL_10A;
                    }
                }
                throw new InvalidOperationException(ServerStrings.ExNotSupportedNotificationType((uint)notification.NotificationType));
IL_10A:
                UnresolvedPropertyDefinition[] propertyDefinitions;
                if (mapiObjectNotification.Tags != null)
                {
                    propertyDefinitions = PropertyTagCache.UnresolvedPropertyDefinitionsFromPropTags(mapiObjectNotification.Tags);
                }
                else
                {
                    propertyDefinitions = Array <UnresolvedPropertyDefinition> .Empty;
                }
                result = new ObjectNotification((mapiObjectNotification.EntryId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.EntryId, StoreObjectType.Unknown), (mapiObjectNotification.ParentId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.ParentId, StoreObjectType.Folder), (mapiObjectNotification.OldId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.OldId, StoreObjectType.Unknown), (mapiObjectNotification.OldParentId == null) ? null : StoreObjectId.FromProviderSpecificId(mapiObjectNotification.OldParentId, StoreObjectType.Folder), (NotificationObjectType)mapiObjectNotification.ObjectType, propertyDefinitions, type);
            }
            return(result);
        }
Exemple #8
0
        internal static bool IsFolderTreeData(IStorePropertyBag row)
        {
            string valueOrDefault = row.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            return(ObjectClass.IsFolderTreeData(valueOrDefault));
        }
        public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
        {
            if (!COWContactLogging.COWContactLoggingConfiguration.Instance.IsLoggingEnabled())
            {
                return(true);
            }
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            if (item == null)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: Item is null");
                return(true);
            }
            if (!onBeforeNotification)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: Not onBeforeNotification");
                return(true);
            }
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            COWContactLogging.Tracer.TraceDebug <string>((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: ItemClass: {0}", valueOrDefault);
            if (ObjectClass.IsPlace(valueOrDefault))
            {
                return(true);
            }
            if (!ObjectClass.IsContact(valueOrDefault) && !ObjectClass.IsDistributionList(valueOrDefault) && !ObjectClass.IsContactsFolder(valueOrDefault))
            {
                return(true);
            }
            foreach (IContactChangeTracker contactChangeTracker in COWContactLogging.ChangeTrackers)
            {
                if (contactChangeTracker.ShouldLoadPropertiesForFurtherCheck(operation, valueOrDefault, itemId, item))
                {
                    COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: A tracker interested.");
                    return(false);
                }
            }
            return(true);
        }
Exemple #10
0
        public ICoreItem OpenAttachedItem(ICollection <PropertyDefinition> propertiesToLoad, AttachmentPropertyBag attachmentBag, bool isNew)
        {
            MapiMessage            mapiMessage            = null;
            PersistablePropertyBag persistablePropertyBag = null;
            CoreItem      coreItem      = null;
            bool          flag          = false;
            StoreObjectId storeObjectId = null;

            byte[]    array = null;
            ICoreItem result;

            try
            {
                StoreObjectPropertyBag storeObjectPropertyBag = (StoreObjectPropertyBag)attachmentBag.PersistablePropertyBag;
                MapiAttach             mapiAttach             = (MapiAttach)storeObjectPropertyBag.MapiProp;
                StoreSession           session           = this.AttachmentCollection.ContainerItem.Session;
                OpenPropertyFlags      openPropertyFlags = isNew ? OpenPropertyFlags.Create : (this.AttachmentCollection.IsReadOnly ? OpenPropertyFlags.BestAccess : OpenPropertyFlags.BestAccess);
                openPropertyFlags |= OpenPropertyFlags.DeferredErrors;
                string text   = storeObjectPropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;
                Schema schema = (text != null) ? ObjectClass.GetSchema(text) : MessageItemSchema.Instance;
                propertiesToLoad = InternalSchema.Combine <PropertyDefinition>(schema.AutoloadProperties, propertiesToLoad);
                StoreSession session2 = this.AttachmentCollection.ContainerItem.Session;
                bool         flag2    = false;
                try
                {
                    if (session2 != null)
                    {
                        session2.BeginMapiCall();
                        session2.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    mapiMessage = mapiAttach.OpenEmbeddedMessage(openPropertyFlags);
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex, session2, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiAttachmentProvider::OpenAttachedItem", new object[0]),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenEmbeddedMessage, ex2, session2, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiAttachmentProvider::OpenAttachedItem", new object[0]),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (session2 != null)
                        {
                            session2.EndMapiCall();
                            if (flag2)
                            {
                                session2.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
                persistablePropertyBag = new StoreObjectPropertyBag(session, mapiMessage, propertiesToLoad);
                if (!isNew)
                {
                    StoreObjectType storeObjectType = ItemBuilder.ReadStoreObjectTypeFromPropertyBag(persistablePropertyBag);
                    ItemCreateInfo  itemCreateInfo  = ItemCreateInfo.GetItemCreateInfo(storeObjectType);
                    propertiesToLoad = InternalSchema.Combine <PropertyDefinition>(itemCreateInfo.Schema.AutoloadProperties, propertiesToLoad);
                    if (this.AttachmentCollection.IsReadOnly)
                    {
                        StoreId.SplitStoreObjectIdAndChangeKey(StoreObjectId.DummyId, out storeObjectId, out array);
                    }
                    persistablePropertyBag = new AcrPropertyBag(persistablePropertyBag, itemCreateInfo.AcrProfile, storeObjectId, new RetryBagFactory(session), array);
                }
                coreItem = new CoreItem(session, persistablePropertyBag, storeObjectId, array, isNew ? Origin.New : Origin.Existing, ItemLevel.Attached, propertiesToLoad, ItemBindOption.None);
                if (text != null && isNew)
                {
                    coreItem.PropertyBag[InternalSchema.ItemClass] = text;
                }
                flag   = true;
                result = coreItem;
            }
            finally
            {
                if (!flag)
                {
                    if (coreItem != null)
                    {
                        coreItem.Dispose();
                        coreItem = null;
                    }
                    if (persistablePropertyBag != null)
                    {
                        persistablePropertyBag.Dispose();
                        persistablePropertyBag = null;
                    }
                    if (mapiMessage != null)
                    {
                        mapiMessage.Dispose();
                        mapiMessage = null;
                    }
                }
            }
            return(result);
        }
        public static Stream OpenRestrictedAttachment(StreamAttachment sourceAttachment, OrganizationId orgId, string userIdentity, SecurityIdentifier userSid, RecipientTypeDetails userType, out UseLicenseAndUsageRights validatedUseLicenseAndUsageRights, out bool acquiredNewLicense)
        {
            StreamAttachment.< > c__DisplayClass2 CS$ < > 8__locals1 = new StreamAttachment.< > c__DisplayClass2();
            CS$ < > 8__locals1.sourceAttachment = sourceAttachment;
            CS$ < > 8__locals1.orgId            = orgId;
            CS$ < > 8__locals1.userIdentity     = userIdentity;
            CS$ < > 8__locals1.userSid          = userSid;
            CS$ < > 8__locals1.userType         = userType;
            Util.ThrowOnNullArgument(CS$ < > 8__locals1.sourceAttachment, "sourceAttachment");
            Util.ThrowOnNullArgument(CS$ < > 8__locals1.orgId, "orgId");
            Util.ThrowOnNullArgument(CS$ < > 8__locals1.userIdentity, "userIdentity");
            Util.ThrowOnNullArgument(CS$ < > 8__locals1.userSid, "userSid");
            if (!Enum.IsDefined(typeof(RecipientTypeDetails), CS$ < > 8__locals1.userType))
            {
                throw new EnumArgumentException("userType");
            }
            CS$ < > 8__locals1.cachedServerUseLicense = null;
            if (!PropertyError.IsPropertyNotFound(CS$ < > 8__locals1.sourceAttachment.TryGetProperty(AttachmentSchema.DRMServerLicenseCompressed)))
            {
                using (Stream stream = CS$ < > 8__locals1.sourceAttachment.OpenPropertyStream(AttachmentSchema.DRMServerLicenseCompressed, PropertyOpenMode.ReadOnly))
                {
                    CS$ < > 8__locals1.cachedServerUseLicense = DrmEmailCompression.DecompressUseLicense(stream);
                }
            }
            StreamAttachment.< > c__DisplayClass2 CS$ < > 8__locals2 = CS$ < > 8__locals1;
            int?valueAsNullable = CS$ < > 8__locals1.sourceAttachment.PropertyBag.GetValueAsNullable <int>(AttachmentSchema.DRMRights);

            CS$ < > 8__locals2.cachedUsageRights       = ((valueAsNullable != null) ? new ContentRight?((ContentRight)valueAsNullable.GetValueOrDefault()) : null);
            CS$ < > 8__locals1.cachedExpiryTime        = CS$ < > 8__locals1.sourceAttachment.PropertyBag.GetValueAsNullable <ExDateTime>(AttachmentSchema.DRMExpiryTime);
            CS$ < > 8__locals1.cachedDrmPropsSignature = CS$ < > 8__locals1.sourceAttachment.PropertyBag.GetValueOrDefault <byte[]>(AttachmentSchema.DRMPropsSignature);
            CS$ < > 8__locals1.item = CS$ < > 8__locals1.sourceAttachment.CoreAttachment.ParentCollection.ContainerItem;
            if (string.IsNullOrEmpty(CS$ < > 8__locals1.cachedServerUseLicense) || CS$ < > 8__locals1.cachedUsageRights == null || CS$ < > 8__locals1.cachedExpiryTime == null || CS$ < > 8__locals1.cachedDrmPropsSignature == null)
            {
                string valueOrDefault = CS$ < > 8__locals1.item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);
                if (ObjectClass.IsMessage(valueOrDefault, false))
                {
                    CS$ < > 8__locals1.cachedServerUseLicense = CS$ < > 8__locals1.item.PropertyBag.GetValueOrDefault <string>(MessageItemSchema.DRMServerLicense, string.Empty);
                    StreamAttachment.< > c__DisplayClass2 CS$ < > 8__locals3 = CS$ < > 8__locals1;
                    int?valueAsNullable2 = CS$ < > 8__locals1.item.PropertyBag.GetValueAsNullable <int>(MessageItemSchema.DRMRights);
                    CS$ < > 8__locals3.cachedUsageRights       = ((valueAsNullable2 != null) ? new ContentRight?((ContentRight)valueAsNullable2.GetValueOrDefault()) : null);
                    CS$ < > 8__locals1.cachedExpiryTime        = CS$ < > 8__locals1.item.PropertyBag.GetValueAsNullable <ExDateTime>(MessageItemSchema.DRMExpiryTime);
                    CS$ < > 8__locals1.cachedDrmPropsSignature = CS$ < > 8__locals1.item.PropertyBag.GetValueOrDefault <byte[]>(MessageItemSchema.DRMPropsSignature);
                }
            }
            CS$ < > 8__locals1.unprotectionSuccess      = false;
            CS$ < > 8__locals1.useLicenseAndUsageRights = null;
            CS$ < > 8__locals1.validCachedLicense       = false;
            Stream unprotectedAttachment;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                StreamAttachment.< > c__DisplayClass4 CS$ < > 8__locals4 = new StreamAttachment.< > c__DisplayClass4();
                CS$ < > 8__locals4.unprotectedAttachment = disposeGuard.Add <Stream>(Streams.CreateTemporaryStorageStream());
                CS$ < > 8__locals4.decryptorHandle       = null;
                using (Stream inputStream = CS$ < > 8__locals1.sourceAttachment.GetContentStream(PropertyOpenMode.ReadOnly))
                {
                    try
                    {
                        MsgToRpMsgConverter.CallRM(delegate
                        {
                            CS$ < > 8__locals1.unprotectionSuccess = ProtectorsManager.Instance.Unprotect(delegate(string protectedDocumentIssuanceLicense)
                            {
                                string valueOrDefault2 = CS$ < > 8__locals1.item.PropertyBag.GetValueOrDefault <string>(ItemSchema.InternetMessageId, string.Empty);
                                bool flag = string.IsNullOrEmpty(valueOrDefault2);
                                RmsClientManagerContext context = new RmsClientManagerContext(CS$ < > 8__locals1.orgId, flag ? RmsClientManagerContext.ContextId.AttachmentFileName : RmsClientManagerContext.ContextId.MessageId, flag ? CS$ < > 8__locals1.sourceAttachment.FileName : valueOrDefault2, null);
                                if (!string.IsNullOrEmpty(CS$ < > 8__locals1.cachedServerUseLicense) && CS$ < > 8__locals1.cachedUsageRights != null && CS$ < > 8__locals1.cachedExpiryTime != null && CS$ < > 8__locals1.cachedDrmPropsSignature != null)
                                {
                                    try
                                    {
                                        CS$ < > 8__locals4.decryptorHandle    = RmsClientManager.VerifyDRMPropsSignatureAndGetDecryptor(context, CS$ < > 8__locals1.userSid, CS$ < > 8__locals1.userType, CS$ < > 8__locals1.userIdentity, CS$ < > 8__locals1.cachedUsageRights.Value, CS$ < > 8__locals1.cachedExpiryTime.Value, CS$ < > 8__locals1.cachedDrmPropsSignature, CS$ < > 8__locals1.cachedServerUseLicense, protectedDocumentIssuanceLicense, UsageRightsSignatureVerificationOptions.LookupSidHistory, StreamAttachment.EmptySidList);
                                        CS$ < > 8__locals1.validCachedLicense = true;
                                        Uri licensingUri = null;
                                        XmlNode[] array  = null;
                                        bool flag2;
                                        RmsClientManager.GetLicensingUri(CS$ < > 8__locals1.orgId, protectedDocumentIssuanceLicense, out licensingUri, out array, out flag2);
                                        CS$ < > 8__locals1.useLicenseAndUsageRights = new UseLicenseAndUsageRights(CS$ < > 8__locals1.cachedServerUseLicense, CS$ < > 8__locals1.cachedUsageRights.Value, CS$ < > 8__locals1.cachedExpiryTime.Value, CS$ < > 8__locals1.cachedDrmPropsSignature, CS$ < > 8__locals1.orgId, protectedDocumentIssuanceLicense, licensingUri);
                                    }
                                    catch (BadDRMPropsSignatureException)
                                    {
                                    }
                                }
                                if (CS$ < > 8__locals1.useLicenseAndUsageRights == null)
                                {
                                    CS$ < > 8__locals1.useLicenseAndUsageRights = RmsClientManager.AcquireUseLicenseAndUsageRights(context, protectedDocumentIssuanceLicense, CS$ < > 8__locals1.userIdentity, CS$ < > 8__locals1.userSid, CS$ < > 8__locals1.userType);
                                    if (CS$ < > 8__locals4.decryptorHandle != null)
                                    {
                                        CS$ < > 8__locals4.decryptorHandle.Close();
                                        CS$ < > 8__locals4.decryptorHandle = null;
                                    }
                                    RmsClientManager.BindUseLicenseForDecryption(context, CS$ < > 8__locals1.useLicenseAndUsageRights.LicensingUri, CS$ < > 8__locals1.useLicenseAndUsageRights.UseLicense, CS$ < > 8__locals1.useLicenseAndUsageRights.PublishingLicense, out CS$ < > 8__locals4.decryptorHandle);
                                }
                                return(CS$ < > 8__locals4.decryptorHandle);
                            }, CS$ < > 8__locals1.sourceAttachment.FileName, inputStream, CS$ < > 8__locals4.unprotectedAttachment);
                        }, ServerStrings.FailedToUnprotectAttachment(CS$ < > 8__locals1.sourceAttachment.FileName));
                    }
        private ContactLinkingProcessingState InspectNotification(COWTriggerAction operation, StoreSession session, CoreItem item, bool onBeforeNotification, bool onDumpster)
        {
            if (onDumpster)
            {
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (!onBeforeNotification)
            {
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (item == null)
            {
                return(ContactLinkingProcessingState.Unknown);
            }
            if (!(session is MailboxSession))
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not a mailbox session.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (operation != COWTriggerAction.Create && operation != COWTriggerAction.Update)
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not an Create or Update operation.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            PersistablePropertyBag persistablePropertyBag = CoreObject.GetPersistablePropertyBag(item);

            switch (persistablePropertyBag.Context.AutomaticContactLinkingAction)
            {
            case AutomaticContactLinkingAction.ClientBased:
                if (!this.IsClientAllowed(session.ClientInfoString))
                {
                    COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not allowed client session.");
                    return(ContactLinkingProcessingState.DoNotProcess);
                }
                break;

            case AutomaticContactLinkingAction.Ignore:
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: IgnoreAutomaticContactLinking=true.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (session.LogonType != LogonType.Owner && session.LogonType != LogonType.Delegated)
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: logon session is not user or delegated.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            if (string.IsNullOrEmpty(valueOrDefault))
            {
                return(ContactLinkingProcessingState.Unknown);
            }
            if (ObjectClass.IsPlace(valueOrDefault))
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: place item class are not processed.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (!ObjectClass.IsContact(valueOrDefault))
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: item class is not contact.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (operation == COWTriggerAction.Update && !Array.Exists <StorePropertyDefinition>(COWContactLinking.NotificationProperties, (StorePropertyDefinition property) => item.PropertyBag.IsPropertyDirty(property)))
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: no relevant properties changed");
                return(ContactLinkingProcessingState.Unknown);
            }
            if (ClientInfo.MOMT.IsMatch(session.ClientInfoString))
            {
                return(ContactLinkingProcessingState.ProcessAfterSave);
            }
            return(ContactLinkingProcessingState.ProcessBeforeSave);
        }
        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));
        }
 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);
 }
Exemple #15
0
 internal static bool CanConvertToMeetingMessage(Item item)
 {
     return(CalendarUtil.GetICalMethod(item) != CalendarMethod.None || ObjectClass.IsFailedInboundICal(item.ClassName));
 }
Exemple #16
0
        private void ReadFromMessageProperties(MessageItem messageItem)
        {
            SharingFlavor?valueAsNullable = messageItem.GetValueAsNullable <SharingFlavor>(InternalSchema.SharingFlavor);

            if (valueAsNullable == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingFlavor is missing", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingFlavor");
            }
            this.context.SharingFlavor = valueAsNullable.Value;
            SharingCapabilities?valueAsNullable2 = messageItem.GetValueAsNullable <SharingCapabilities>(InternalSchema.SharingCapabilities);

            if (valueAsNullable2 == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "{0}: SharingCapabilities is missing, use default value", messageItem.Session.UserLegacyDN);
                this.context.SetDefaultCapabilities();
            }
            else
            {
                this.context.SharingCapabilities = valueAsNullable2.Value;
            }
            string valueOrDefault = messageItem.GetValueOrDefault <string>(InternalSchema.SharingInitiatorName, null);

            if (valueOrDefault == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorName is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingInitiatorName");
            }
            this.context.InitiatorName = valueOrDefault;
            string valueOrDefault2 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingInitiatorSmtp, null);

            if (valueOrDefault2 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorSmtp is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingInitiatorSmtp");
            }
            if (!SmtpAddress.IsValidSmtpAddress(valueOrDefault2))
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingInitiatorSmtp is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault2);
                throw new InvalidSharingMessageException("SharingInitiatorSmtp");
            }
            this.context.InitiatorSmtpAddress = valueOrDefault2;
            byte[] valueOrDefault3 = messageItem.GetValueOrDefault <byte[]>(InternalSchema.SharingInitiatorEntryId, null);
            if (valueOrDefault3 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingInitiatorEntryId is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingInitiatorEntryId");
            }
            if (!AddressBookEntryId.IsAddressBookEntryId(valueOrDefault3))
            {
                ExTraceGlobals.SharingTracer.TraceError <string, byte[]>((long)this.GetHashCode(), "{0}: SharingInitiatorEntryId is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault3);
                throw new InvalidSharingMessageException("SharingInitiatorEntryId");
            }
            this.context.InitiatorEntryId = valueOrDefault3;
            string valueOrDefault4 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteType, null);

            if (valueOrDefault4 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteType is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingRemoteType");
            }
            if (SharingDataType.FromContainerClass(valueOrDefault4) == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingRemoteType is invalid: {1}.", messageItem.Session.UserLegacyDN, valueOrDefault4);
                throw new InvalidSharingMessageException("SharingRemoteType");
            }
            this.context.FolderClass = valueOrDefault4;
            string valueOrDefault5 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteName, null);

            if (valueOrDefault5 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteName is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingRemoteName");
            }
            this.context.FolderName = valueOrDefault5;
            string valueOrDefault6 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteUid, null);

            if (valueOrDefault6 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteUid is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingRemoteUid");
            }
            try
            {
                this.context.FolderId = StoreObjectId.FromHexEntryId(valueOrDefault6, ObjectClass.GetObjectType(valueOrDefault4));
            }
            catch (CorruptDataException)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingRemoteUid is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault6);
                throw new InvalidSharingMessageException("SharingRemoteUid");
            }
            string valueOrDefault7 = messageItem.GetValueOrDefault <string>(InternalSchema.SharingRemoteStoreUid, null);

            if (valueOrDefault7 == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: SharingRemoteStoreUid is missing.", messageItem.Session.UserLegacyDN);
                throw new InvalidSharingMessageException("SharingRemoteStoreUid");
            }
            byte[] array = null;
            try
            {
                array = HexConverter.HexStringToByteArray(valueOrDefault7);
            }
            catch (FormatException)
            {
            }
            if (array == null || StoreEntryId.TryParseStoreEntryIdMailboxDN(array) == null)
            {
                ExTraceGlobals.SharingTracer.TraceError <string, string>((long)this.GetHashCode(), "{0}: SharingRemoteStoreUid is invalid: {1}", messageItem.Session.UserLegacyDN, valueOrDefault7);
                throw new InvalidSharingMessageException("SharingRemoteStoreUid");
            }
            this.context.MailboxId = array;
            SharingContextPermissions?valueAsNullable3 = messageItem.GetValueAsNullable <SharingContextPermissions>(InternalSchema.SharingPermissions);

            if (valueAsNullable3 != null)
            {
                this.context.SharingPermissions = valueAsNullable3.Value;
            }
            SharingContextDetailLevel?valueAsNullable4 = messageItem.GetValueAsNullable <SharingContextDetailLevel>(InternalSchema.SharingDetail);

            if (valueAsNullable4 != null)
            {
                this.context.SharingDetail = valueAsNullable4.Value;
                return;
            }
            if (this.context.DataType == SharingDataType.Calendar)
            {
                this.context.SharingDetail = SharingContextDetailLevel.FullDetails;
            }
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsOfClass(valueOrDefault, "IPM.Appointment.Occurrence") || ObjectClass.IsOfClass(valueOrDefault, "IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}"))
            {
                bool valueOrDefault2 = propertyBag.GetValueOrDefault <bool>(InternalSchema.IsException);
                if (valueOrDefault2)
                {
                    return(CalendarItemType.Exception);
                }
                return(CalendarItemType.Occurrence);
            }
            else
            {
                bool valueOrDefault3 = propertyBag.GetValueOrDefault <bool>(InternalSchema.AppointmentRecurring);
                if (valueOrDefault3)
                {
                    return(CalendarItemType.RecurringMaster);
                }
                return(CalendarItemType.Single);
            }
        }
Exemple #18
0
        public static bool IsItemLegallyDirty(StoreSession session, CoreItem item, bool verifyLegallyDirty, out List <string> dirtyProperties)
        {
            dirtyProperties = null;
            if (COWSettings.IsCalendarRepairAssistantAction(session))
            {
                ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} skipped because the action was generated by Calendar Repair Assistant.", item);
                return(false);
            }
            if (item.PropertyBag.GetValueOrDefault <bool>(InternalSchema.IsDraft))
            {
                ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} skipped because it is a draft.", item);
                return(false);
            }
            if (item.Id == null)
            {
                ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} skipped because it does not have an id.", item);
                return(false);
            }
            if (item.PropertyBag.GetValueOrDefault <bool>(InternalSchema.IsAssociated))
            {
                ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} skipped because it is an associated item.", item);
                return(false);
            }
            if (item.Id == null)
            {
                ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} skipped because the id was null.", item);
                return(false);
            }
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsOfClass(valueOrDefault, "IPM.Post.RSS"))
            {
                ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} skipped because it is a RSS item.", item);
                return(false);
            }
            Schema schema = ObjectClass.GetSchema(valueOrDefault);

            if (!(schema is ItemSchema))
            {
                schema = ItemSchema.Instance;
            }
            bool isLegallyDirty = item.IsLegallyDirty;
            CoreRecipientCollection  recipients           = ((ICoreItem)item).Recipients;
            CoreAttachmentCollection attachmentCollection = ((ICoreItem)item).AttachmentCollection;
            bool flag  = (recipients != null && recipients.IsDirty) || item.IsLegallyDirtyProperty("RecipientCollection");
            bool flag2 = (attachmentCollection != null && attachmentCollection.IsDirty) || item.IsLegallyDirtyProperty("AttachmentCollection");

            if (!isLegallyDirty && !item.PropertyBag.IsDirty && !flag && !flag2)
            {
                ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} skipped because the property bag is not dirty.", item);
                return(false);
            }
            StorePropertyDefinition[] array = (from x in schema.LegalTrackingProperties
                                               where item.PropertyBag.IsPropertyDirty(x) || item.IsLegallyDirtyProperty(x.Name)
                                               select x).ToArray <StorePropertyDefinition>();
            if (array.Length == 0 && !flag && !flag2)
            {
                ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} skipped because the property bag is not legally dirty.", item);
                return(false);
            }
            dirtyProperties = new List <string>();
            if (!verifyLegallyDirty)
            {
                dirtyProperties = (from x in array
                                   select x.Name).ToList <string>();
                if (flag)
                {
                    dirtyProperties.Add("RecipientCollection");
                }
                if (flag2)
                {
                    dirtyProperties.Add("AttachmentCollection");
                }
            }
            else
            {
                using (CoreItem coreItem = CoreItem.Bind(session, item.Id, array))
                {
                    CoreRecipientCollection recipients2 = coreItem.Recipients;
                    if (flag)
                    {
                        flag = false;
                        int num  = (recipients == null) ? 0 : recipients.Count;
                        int num2 = (recipients2 == null) ? 0 : recipients2.Count;
                        if (num == num2)
                        {
                            if (recipients == null || recipients2 == null)
                            {
                                goto IL_36E;
                            }
                            using (IEnumerator <CoreRecipient> enumerator = recipients.GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    CoreRecipient value = enumerator.Current;
                                    if (!recipients2.Contains(value, COWDumpster.CoreRecipientParticipantEqualityComparer.Default))
                                    {
                                        flag = true;
                                        break;
                                    }
                                }
                                goto IL_36E;
                            }
                        }
                        flag = true;
                    }
                    else
                    {
                        int num3 = (recipients == null) ? 0 : recipients.Count;
                        int num4 = (recipients2 == null) ? 0 : recipients2.Count;
                        flag = (num3 != num4);
                    }
IL_36E:
                    if (flag)
                    {
                        ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} is dirty because the recipient collection is dirty.", item);
                        dirtyProperties.Add("RecipientCollection");
                    }
                    if (!flag2)
                    {
                        CoreAttachmentCollection attachmentCollection2 = coreItem.AttachmentCollection;
                        int num5 = (attachmentCollection == null) ? 0 : attachmentCollection.Count;
                        int num6 = (attachmentCollection2 == null) ? 0 : attachmentCollection2.Count;
                        flag2 = (num5 != num6);
                    }
                    if (flag2)
                    {
                        ExTraceGlobals.SessionTracer.TraceWarning <CoreItem>((long)session.GetHashCode(), "Update Item {0} is dirty because the attachment collection is dirty.", item);
                        dirtyProperties.Add("AttachmentCollection");
                    }
                    foreach (StorePropertyDefinition propertyDefinition in array)
                    {
                        object x2 = item.PropertyBag.TryGetProperty(propertyDefinition);
                        object y  = coreItem.PropertyBag.TryGetProperty(propertyDefinition);
                        if (!COWDumpster.PropertyValuesAreEqual(propertyDefinition, x2, y))
                        {
                            ExTraceGlobals.SessionTracer.TraceWarning <CoreItem, string, PropertyDefinition>((long)session.GetHashCode(), "Update Item {0}, class {1} is dirty because the {2} property is dirty.", item, valueOrDefault, propertyDefinition);
                            dirtyProperties.Add(propertyDefinition.Name);
                        }
                    }
                }
            }
            if (dirtyProperties.Count > 0)
            {
                ExTraceGlobals.SessionTracer.TraceWarning((long)session.GetHashCode(), "Update Item {0}, class {1} is {2} dirty with {3} properties changed", new object[]
                {
                    item,
                    valueOrDefault,
                    verifyLegallyDirty ? "verified" : "not verified",
                    dirtyProperties.Count
                });
                return(true);
            }
            ExTraceGlobals.SessionTracer.TraceWarning <CoreItem, string, int>((long)session.GetHashCode(), "Update Item {0}, class {1} skipped because no legal tracking property was found dirty out of {2} modified legal tracking properties.", item, valueOrDefault, array.Length);
            dirtyProperties = null;
            return(false);
        }
        public IEnumerator <IStorePropertyBag> GetEnumerator()
        {
            ContactFoldersEnumeratorOptions foldersEnumeratorOptions = ContactFoldersEnumeratorOptions.SkipHiddenFolders | ContactFoldersEnumeratorOptions.SkipDeletedFolders | ContactFoldersEnumeratorOptions.IncludeParentFolder;
            ContactFoldersEnumerator        foldersEnumerator        = new ContactFoldersEnumerator(this.session, new XSOFactory(), this.folderType, foldersEnumeratorOptions, new PropertyDefinition[0]);

            foreach (IStorePropertyBag folderPropertyBag in foldersEnumerator)
            {
                VersionedId folderId = folderPropertyBag.GetValueOrDefault <VersionedId>(FolderSchema.Id, null);
                IFolder     folder;
                try
                {
                    folder = this.xsoFactory.BindToFolder(this.session, folderId.ObjectId);
                }
                catch (ObjectNotFoundException)
                {
                    RecursiveContactsEnumerator.Tracer.TraceError <VersionedId, Guid>((long)this.GetHashCode(), "Failed to bind to folder. FolderId: {0}. Mailbox: {1}.", folderId, this.session.MailboxOwner.MailboxInfo.MailboxGuid);
                    continue;
                }
                try
                {
                    using (IQueryResult contactsQuery = folder.IItemQuery(ItemQueryType.None, null, null, this.properties))
                    {
                        IStorePropertyBag[] contacts = contactsQuery.GetPropertyBags(100);
                        while (contacts.Length > 0)
                        {
                            foreach (IStorePropertyBag contactPropertyBag in contacts)
                            {
                                if (contactPropertyBag != null && !(contactPropertyBag.TryGetProperty(ItemSchema.Id) is PropertyError) && ObjectClass.IsContact(contactPropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, null)))
                                {
                                    yield return(contactPropertyBag);
                                }
                            }
                            contacts = contactsQuery.GetPropertyBags(100);
                        }
                    }
                }
                finally
                {
                    folder.Dispose();
                }
            }
            yield break;
        }
Exemple #20
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);
        }
Exemple #21
0
 private void WriteRecipientTable()
 {
     if (this.tnefType != TnefType.LegacyTnef || this.isEmbeddedItem)
     {
         this.tnefWriter.StartAttribute(TnefAttributeTag.RecipientTable, TnefAttributeLevel.Message);
         List <ConversionRecipientEntry> recipients = this.addressCache.Recipients;
         if (recipients != null)
         {
             this.conversionResult.RecipientCount = recipients.Count;
             foreach (ConversionRecipientEntry conversionRecipientEntry in recipients)
             {
                 if (!(this.item is MessageItem) || this.options.DemoteBcc || conversionRecipientEntry.RecipientItemType != RecipientItemType.Bcc || ((conversionRecipientEntry.Participant.GetValueOrDefault <bool>(ParticipantSchema.IsRoom, false) || conversionRecipientEntry.Participant.GetValueOrDefault <bool>(ParticipantSchema.IsResource, false)) && ObjectClass.IsMeetingMessage(this.item.ClassName)))
                 {
                     this.WriteRecipient(conversionRecipientEntry);
                 }
             }
         }
     }
 }
Exemple #22
0
        private ConflictResolutionResult ApplyAcr(PropertyBag acrPropBag, SaveMode saveMode)
        {
            Dictionary <PropertyDefinition, AcrPropertyProfile.ValuesToResolve> valuesToResolve = this.GetValuesToResolve(acrPropBag);
            string valueOrDefault = this.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault) || ObjectClass.IsMeetingMessage(valueOrDefault))
            {
                LocationIdentifierHelper           locationIdentifierHelper = new LocationIdentifierHelper();
                AcrPropertyProfile.ValuesToResolve valuesToResolve2;
                object serverValue;
                if (valuesToResolve.TryGetValue(InternalSchema.ChangeList, out valuesToResolve2))
                {
                    locationIdentifierHelper.ChangeBuffer = (byte[])valuesToResolve2.ClientValue;
                    serverValue = valuesToResolve2.ServerValue;
                }
                else
                {
                    serverValue = new PropertyError(InternalSchema.ChangeList, PropertyErrorCode.NotFound);
                }
                locationIdentifierHelper.SetLocationIdentifier(53909U, LastChangeAction.AcrPerformed);
                valuesToResolve2 = new AcrPropertyProfile.ValuesToResolve(locationIdentifierHelper.ChangeBuffer, serverValue, null);
                valuesToResolve[InternalSchema.ChangeList] = valuesToResolve2;
            }
            ConflictResolutionResult conflictResolutionResult = this.profile.ResolveConflicts(valuesToResolve);

            if (this.propertiesWrittenAsStream.Count > 0)
            {
                List <PropertyConflict> list = new List <PropertyConflict>(conflictResolutionResult.PropertyConflicts);
                foreach (PropertyDefinition propertyDefinition in this.propertiesWrittenAsStream.Keys)
                {
                    PropertyConflict item = new PropertyConflict(propertyDefinition, null, null, null, null, false);
                    list.Add(item);
                }
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, list.ToArray());
            }
            if (this.irresolvableChanges || saveMode == SaveMode.FailOnAnyConflict)
            {
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, conflictResolutionResult.PropertyConflicts);
            }
            if (conflictResolutionResult.SaveStatus != SaveResult.IrresolvableConflict)
            {
                List <PropertyDefinition> list2 = new List <PropertyDefinition>();
                List <PropertyDefinition> list3 = new List <PropertyDefinition>();
                List <object>             list4 = new List <object>();
                if (this.propertyBag == acrPropBag)
                {
                    foreach (PropertyConflict propertyConflict in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict.ResolvedValue) && (!PropertyError.IsPropertyError(propertyConflict.ClientValue) || !PropertyError.IsPropertyNotFound(propertyConflict.ClientValue)))
                            {
                                list2.Add(propertyConflict.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict.ResolvedValue != propertyConflict.ClientValue)
                        {
                            list3.Add(propertyConflict.PropertyDefinition);
                            list4.Add(propertyConflict.ResolvedValue);
                        }
                    }
                }
                else
                {
                    foreach (PropertyConflict propertyConflict2 in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict2.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict2.ResolvedValue))
                            {
                                list2.Add(propertyConflict2.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict2.ServerValue != propertyConflict2.ResolvedValue)
                        {
                            list3.Add(propertyConflict2.PropertyDefinition);
                            list4.Add(propertyConflict2.ResolvedValue);
                        }
                    }
                }
                for (int k = 0; k < list2.Count; k++)
                {
                    acrPropBag.Delete(list2[k]);
                }
                for (int l = 0; l < list3.Count; l++)
                {
                    acrPropBag[list3[l]] = list4[l];
                }
            }
            return(conflictResolutionResult);
        }
Exemple #23
0
        public static void CreateForwardReplyHeader(ReplyForwardConfiguration configuration, Item item, ForwardReplyHeaderOptions headerOptions = null)
        {
            if (!(item is MessageItem) && !(item is CalendarItemBase) && !(item is PostItem))
            {
                throw new ArgumentException("HTML reply forward headers can only be created for MessageItem, CalendarItemBase and PostItem");
            }
            if (headerOptions == null)
            {
                headerOptions = new ForwardReplyHeaderOptions();
            }
            CultureInfo cultureInfo = configuration.Culture ?? item.Session.InternalCulture;

            if (item is PostItem)
            {
                ReplyForwardHeader.CreatePostReplyForwardHeader(configuration, item, headerOptions, cultureInfo);
            }
            IList <IRecipientBase> toRecipients = null;
            IList <IRecipientBase> ccRecipients = null;
            string from          = string.Empty;
            string sender        = null;
            string fromLabel     = ClientStrings.FromColon.ToString(cultureInfo);
            string toLabel       = ClientStrings.ToColon.ToString(cultureInfo);
            string ccLabel       = ClientStrings.CcColon.ToString(cultureInfo);
            bool   isMeetingItem = ObjectClass.IsMeetingMessage(item.ClassName);

            if (item is MessageItem)
            {
                MessageItem messageItem = (MessageItem)item;
                if (messageItem.From != null)
                {
                    from = messageItem.From.DisplayName;
                }
                if (messageItem.Sender != null)
                {
                    sender = messageItem.Sender.DisplayName;
                }
                toRecipients = ReplyForwardHeader.GetMessageRecipientCollection(RecipientItemType.To, messageItem);
                ccRecipients = ReplyForwardHeader.GetMessageRecipientCollection(RecipientItemType.Cc, messageItem);
            }
            else if (item is CalendarItemBase)
            {
                CalendarItemBase calendarItemBase = (CalendarItemBase)item;
                if (calendarItemBase.Organizer != null)
                {
                    from = calendarItemBase.Organizer.DisplayName;
                }
                toRecipients = ReplyForwardHeader.GetCalendarItemRecipientCollection(AttendeeType.Required, calendarItemBase);
                ccRecipients = ReplyForwardHeader.GetCalendarItemRecipientCollection(AttendeeType.Optional, calendarItemBase);
            }
            BodyInjectionFormat bodyPrefixFormat;
            string bodyPrefix;

            switch (configuration.TargetFormat)
            {
            case BodyFormat.TextPlain:
                bodyPrefixFormat = BodyInjectionFormat.Text;
                bodyPrefix       = ReplyForwardHeader.CreateTextReplyForwardHeader(item, headerOptions, fromLabel, from, sender, toLabel, ccLabel, toRecipients, ccRecipients, isMeetingItem, cultureInfo, configuration.TimeZone);
                break;

            case BodyFormat.TextHtml:
            case BodyFormat.ApplicationRtf:
                bodyPrefixFormat = BodyInjectionFormat.Html;
                bodyPrefix       = ReplyForwardHeader.CreateHtmlReplyForwardHeader(item, headerOptions, fromLabel, from, sender, toLabel, ccLabel, toRecipients, ccRecipients, isMeetingItem, cultureInfo, configuration.TimeZone);
                break;

            default:
                throw new ArgumentException("Unsupported body format");
            }
            configuration.AddBodyPrefix(bodyPrefix, bodyPrefixFormat);
        }
Exemple #24
0
        private void CopyMeetingRequestProperties(CalendarItemBase calendarItem, bool preserveLocalExceptions)
        {
            long size = calendarItem.Body.Size;

            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(42101U);
            if (!base.IsRepairUpdateMessage || (this.ChangeHighlight & ChangeHighlightProperties.BodyProps) == ChangeHighlightProperties.BodyProps)
            {
                Body.CopyBody(this, calendarItem, false);
                this.CopyNlgPropertiesTo(calendarItem);
            }
            ChangeHighlightProperties changeHighlight = this.ChangeHighlight;

            this.ProcessChangeHighlights(calendarItem, calendarItem.Body.Size, size);
            MeetingMessageType meetingMessageType = base.GetValueOrDefault <MeetingMessageType>(InternalSchema.MeetingRequestType, MeetingMessageType.NewMeetingRequest);

            if (meetingMessageType == MeetingMessageType.PrincipalWantsCopy)
            {
                if (calendarItem.IsNew)
                {
                    meetingMessageType = MeetingMessageType.NewMeetingRequest;
                    ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; Meeting type is PrincipalWantsCopy and calendar item just created.", this.GlobalObjectId);
                }
                else
                {
                    meetingMessageType = base.GetValueOrDefault <MeetingMessageType>(InternalSchema.OriginalMeetingType, MeetingMessageType.NewMeetingRequest);
                    ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, MeetingMessageType>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; Meeting type is PrincipalWantsCopy. Will use OriginalMeetingType {1}", this.GlobalObjectId, meetingMessageType);
                }
            }
            base.LocationIdentifierHelperInstance.SetLocationIdentifier(60533U, LastChangeAction.CopyMeetingRequestProperties);
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(35957U, LastChangeAction.CopyMeetingRequestProperties);
            if (MeetingMessageType.NewMeetingRequest == meetingMessageType || calendarItem.IsNew)
            {
                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Copying WriteOnCreate properties onto calendar item.");
                calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(52341U);
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.WriteOnCreateProperties);
                if (base.IsSeriesMessage)
                {
                    CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.WriteOnCreateSeriesProperties);
                }
                Reminder.EnsureMinutesBeforeStartIsInRange(calendarItem, this.consumerDefaultMinutesBeforeStart);
                if (base.IsRepairUpdateMessage)
                {
                    int?valueAsNullable = base.GetValueAsNullable <int>(CalendarItemBaseSchema.ItemVersion);
                    if (valueAsNullable != null)
                    {
                        calendarItem[CalendarItemBaseSchema.ItemVersion] = valueAsNullable;
                    }
                }
            }
            if (meetingMessageType == MeetingMessageType.NewMeetingRequest || (!base.IsRepairUpdateMessage && meetingMessageType == MeetingMessageType.FullUpdate))
            {
                calendarItem.ResponseType = ResponseType.NotResponded;
                BusyType valueOrDefault  = base.GetValueOrDefault <BusyType>(InternalSchema.IntendedFreeBusyStatus, BusyType.Busy);
                BusyType valueOrDefault2 = base.GetValueOrDefault <BusyType>(InternalSchema.FreeBusyStatus, BusyType.Tentative);
                calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(58485U);
                calendarItem[InternalSchema.IntendedFreeBusyStatus] = valueOrDefault;
                calendarItem[InternalSchema.FreeBusyStatus]         = ((valueOrDefault != BusyType.Free) ? valueOrDefault2 : BusyType.Free);
            }
            ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Copying properties onto calendar item.");
            byte[]       largeBinaryProperty = base.PropertyBag.GetLargeBinaryProperty(InternalSchema.AppointmentRecurrenceBlob);
            CalendarItem calendarItem2       = calendarItem as CalendarItem;
            bool         flag = false;

            if (largeBinaryProperty != null && calendarItem2 != null)
            {
                calendarItem2.SuppressUpdateRecurrenceTimeOffset = true;
                this.CopyRecurrenceBlob(calendarItem2, largeBinaryProperty, preserveLocalExceptions);
                flag = true;
            }
            else if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster)
            {
                CalendarItem calendarItem3 = calendarItem as CalendarItem;
                if (calendarItem3 != null)
                {
                    calendarItem3.Recurrence = null;
                }
            }
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(62581U);
            if (calendarItem is CalendarItem)
            {
                PropertyChangeMetadataProcessingFlags propertyChangeMetadataProcessingFlags = calendarItem.GetValueOrDefault <PropertyChangeMetadataProcessingFlags>(CalendarItemSchema.PropertyChangeMetadataProcessingFlags, PropertyChangeMetadataProcessingFlags.None);
                propertyChangeMetadataProcessingFlags |= PropertyChangeMetadataProcessingFlags.OverrideMetadata;
                calendarItem[CalendarItemSchema.PropertyChangeMetadataProcessingFlags] = propertyChangeMetadataProcessingFlags;
            }
            if (this.ShouldPreserveAttendeesChanges(calendarItem))
            {
                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Will copy properties trying to preserve attendee's changes.");
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, CalendarItemProperties.NonPreservableMeetingMessageProperties);
                PreservableMeetingMessageProperty.CopyPreserving(new PreservablePropertyContext(this, calendarItem, changeHighlight));
                if (calendarItem is CalendarItem)
                {
                    PropertyChangeMetadata valueOrDefault3        = calendarItem.GetValueOrDefault <PropertyChangeMetadata>(InternalSchema.PropertyChangeMetadata);
                    PropertyChangeMetadata valueOrDefault4        = base.GetValueOrDefault <PropertyChangeMetadata>(InternalSchema.PropertyChangeMetadata);
                    PropertyChangeMetadata propertyChangeMetadata = PropertyChangeMetadata.Merge(valueOrDefault3, valueOrDefault4);
                    if (propertyChangeMetadata != null)
                    {
                        calendarItem[InternalSchema.PropertyChangeMetadata] = propertyChangeMetadata;
                    }
                }
            }
            else
            {
                if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster || calendarItem.CalendarItemType == CalendarItemType.Single)
                {
                    calendarItem.DeleteProperties(MeetingMessage.DisplayTimeZoneProperties);
                }
                if (calendarItem is CalendarItem)
                {
                    CalendarItemBase.CopyPropertiesTo(this, calendarItem, new PropertyDefinition[]
                    {
                        InternalSchema.PropertyChangeMetadataRaw
                    });
                }
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.MeetingMessageProperties);
            }
            string valueOrDefault5 = base.GetValueOrDefault <string>(InternalSchema.AppointmentClass);

            if (valueOrDefault5 != null && ObjectClass.IsDerivedClass(valueOrDefault5, "IPM.Appointment"))
            {
                calendarItem.ClassName = valueOrDefault5;
            }
            Microsoft.Exchange.Data.Storage.Item.CopyCustomPublicStrings(this, calendarItem);
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(54389U);
            CalendarItemBase.CopyPropertiesTo(this, calendarItem, new PropertyDefinition[]
            {
                InternalSchema.TimeZoneDefinitionRecurring
            });
            if (meetingMessageType == MeetingMessageType.InformationalUpdate && !calendarItem.IsCalendarItemTypeOccurrenceOrException)
            {
                Sensitivity?valueAsNullable2 = base.GetValueAsNullable <Sensitivity>(InternalSchema.Sensitivity);
                if (valueAsNullable2 != null && calendarItem.Sensitivity != Sensitivity.Private && Enum.IsDefined(typeof(Sensitivity), valueAsNullable2.Value))
                {
                    calendarItem.Sensitivity = valueAsNullable2.Value;
                }
            }
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(50293U);
            calendarItem.Reminder.Adjust();
            if (flag && calendarItem2 != null)
            {
                calendarItem2.ReloadRecurrence();
            }
        }
Exemple #25
0
        private COWProcessorState InspectNotification(COWTriggerAction operation, StoreSession session, CoreItem item, bool onBeforeNotification, bool onDumpster)
        {
            if (onDumpster)
            {
                return(COWProcessorState.DoNotProcess);
            }
            if (operation != COWTriggerAction.Create)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: not an Create operation.");
                return(COWProcessorState.DoNotProcess);
            }
            if (!onBeforeNotification)
            {
                return(COWProcessorState.DoNotProcess);
            }
            if (item == null)
            {
                return(COWProcessorState.Unknown);
            }
            if (item.Id != null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: ItemId is non-null, so this is not a new item. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            MailboxSession mailboxSession = session as MailboxSession;

            if (mailboxSession == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: not a mailbox session. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            int?num = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.MailboxTypeDetail) as int?;

            if (num == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: mailbox type not found. Try to inspect later.");
                return(COWProcessorState.Unknown);
            }
            if (!StoreSession.IsGroupMailbox(num.Value))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: Mailbox isn't a GroupMailbox. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            if (string.IsNullOrEmpty(valueOrDefault))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class not found. Try to inspect later.");
                return(COWProcessorState.Unknown);
            }
            if (!ObjectClass.IsMessage(valueOrDefault, false))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is not a message. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            if (ObjectClass.IsMeetingForwardNotification(valueOrDefault))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is meeting forward notification. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            if (ObjectClass.IsMeetingResponse(valueOrDefault))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is meeting response. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            bool flag  = ClientInfo.OWA.IsMatch(mailboxSession.ClientInfoString);
            bool flag2 = ClientInfo.HubTransport.IsMatch(mailboxSession.ClientInfoString);

            if (!flag && !flag2)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: This isn't either a post or a delivery. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            StoreObjectId storeObjectId = item.PropertyBag.TryGetProperty(StoreObjectSchema.ParentItemId) as StoreObjectId;

            if (storeObjectId == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: parent folder id not found. Try to inspect later.");
                return(COWProcessorState.Unknown);
            }
            StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);

            if (defaultFolderId == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: inbox folder id not found. Try to inspect later.");
                return(COWProcessorState.Unknown);
            }
            if (!storeObjectId.Equals(defaultFolderId))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: This message isn't located on the inbox folder. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            return(COWProcessorState.ProcessAfterSave);
        }
        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);
        }
Exemple #27
0
        private static Charset GetItemOutboundMimeCharsetInternal(Item item, OutboundConversionOptions options)
        {
            object  obj            = item.TryGetProperty(InternalSchema.InternetCpid);
            bool    valueOrDefault = item.GetValueOrDefault <bool>(InternalSchema.IsAutoForwarded, false);
            string  className      = item.ClassName;
            Charset charset        = null;

            if (valueOrDefault || (obj is PropertyError && !item.Body.IsBodyDefined) || (options != null && options.DetectionOptions.PreferredCharset != null && (options.DetectionOptions.RequiredCoverage < 100 || ObjectClass.IsTaskRequest(className) || ObjectClass.IsMeetingMessage(className))))
            {
                charset = ConvertUtils.DetectOutboundCharset(item, options, obj, !valueOrDefault);
                if (charset != null)
                {
                    if (!item.CharsetDetector.IsItemCharsetKnownWithoutDetection(BodyCharsetFlags.DisableCharsetDetection, charset, out charset))
                    {
                        throw new InvalidOperationException();
                    }
                    return(charset);
                }
            }
            if (!(obj is PropertyError) && Charset.TryGetCharset((int)obj, out charset) && ConvertUtils.TryTransformCharset(ref charset))
            {
                return(charset);
            }
            object obj2 = item.TryGetProperty(InternalSchema.Codepage);

            if (!(obj2 is PropertyError) && Charset.TryGetCharset((int)obj2, out charset))
            {
                charset = charset.Culture.MimeCharset;
                if (ConvertUtils.TryTransformCharset(ref charset))
                {
                    return(charset);
                }
            }
            return(Charset.GetCharset(65001));
        }
Exemple #28
0
        public ManifestCallbackStatus Change(byte[] entryId, byte[] sourceKey, byte[] changeKey, byte[] changeList, DateTime lastModifiedTime, ManifestChangeType changeType, bool associated, PropValue[] properties)
        {
            EnumValidator.ThrowIfInvalid <ManifestChangeType>(changeType, "changeType");
            if (ExTraceGlobals.SyncTracer.IsTraceEnabled(TraceType.InfoTrace))
            {
                this.TraceChangeChangeCallbackProps(entryId, sourceKey, changeKey, changeList, lastModifiedTime, changeType, associated, properties);
            }
            int?           num                        = null;
            string         text                       = null;
            bool           read                       = false;
            ConversationId conversationId             = null;
            bool           firstMessageInConversation = false;
            ExDateTime?    filterDate                 = null;

            foreach (PropValue propValue in properties)
            {
                if (!propValue.IsError())
                {
                    PropTag propTag = propValue.PropTag;
                    if (propTag <= PropTag.MessageDeliveryTime)
                    {
                        if (propTag != PropTag.MessageClass)
                        {
                            ConversationIndex index;
                            if (propTag != PropTag.ConversationIndex)
                            {
                                if (propTag == PropTag.MessageDeliveryTime)
                                {
                                    if (propValue.PropType == PropType.SysTime)
                                    {
                                        filterDate = new ExDateTime?((ExDateTime)propValue.GetDateTime());
                                    }
                                }
                            }
                            else if (propValue.PropType == PropType.Binary && ConversationIndex.TryCreate(propValue.GetBytes(), out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
                            {
                                firstMessageInConversation = true;
                            }
                        }
                        else if (propValue.PropType == PropType.String)
                        {
                            text = propValue.GetString();
                        }
                    }
                    else if (propTag != PropTag.MessageFlags)
                    {
                        if (propTag != PropTag.InternetArticleNumber)
                        {
                            if (propTag == PropTag.ConversationId)
                            {
                                if (propValue.PropType == PropType.Binary)
                                {
                                    conversationId = ConversationId.Create(propValue.GetBytes());
                                }
                            }
                        }
                        else
                        {
                            if (propValue.PropType != PropType.Int)
                            {
                                return(ManifestCallbackStatus.Continue);
                            }
                            num = new int?(propValue.GetInt());
                        }
                    }
                    else if (propValue.PropType == PropType.Int)
                    {
                        MessageFlags @int = (MessageFlags)propValue.GetInt();
                        read = ((@int & MessageFlags.IsRead) == MessageFlags.IsRead);
                    }
                }
            }
            if (changeType == ManifestChangeType.Add || changeType == ManifestChangeType.Change)
            {
                if (num == null)
                {
                    return(ManifestCallbackStatus.Continue);
                }
                StoreObjectId        id = StoreObjectId.FromProviderSpecificId(entryId, (text == null) ? StoreObjectType.Unknown : ObjectClass.GetObjectType(text));
                MailboxSyncItemId    mailboxSyncItemId    = MailboxSyncItemId.CreateForNewItem(id);
                MailboxSyncWatermark mailboxSyncWatermark = MailboxSyncWatermark.CreateForSingleItem();
                mailboxSyncWatermark.UpdateWithChangeNumber(num.Value, read);
                ServerManifestEntry serverManifestEntry = this.mailboxSyncProvider.CreateItemChangeManifestEntry(mailboxSyncItemId, mailboxSyncWatermark);
                serverManifestEntry.IsNew                      = (changeType == ManifestChangeType.Add);
                serverManifestEntry.MessageClass               = text;
                serverManifestEntry.ConversationId             = conversationId;
                serverManifestEntry.FirstMessageInConversation = firstMessageInConversation;
                serverManifestEntry.FilterDate                 = filterDate;
                mailboxSyncItemId.ChangeKey                    = changeKey;
                this.lastServerManifestEntry                   = serverManifestEntry;
            }
            else
            {
                StoreObjectId     id2 = StoreObjectId.FromProviderSpecificId(entryId, StoreObjectType.Unknown);
                MailboxSyncItemId mailboxSyncItemId2 = MailboxSyncItemId.CreateForExistingItem(this.mailboxSyncProvider.FolderSync, id2);
                if (mailboxSyncItemId2 == null)
                {
                    return(ManifestCallbackStatus.Continue);
                }
                this.lastServerManifestEntry = MailboxSyncProvider.CreateItemDeleteManifestEntry(mailboxSyncItemId2);
                this.lastServerManifestEntry.ConversationId = conversationId;
            }
            return(this.CheckYieldOrStop());
        }
Exemple #29
0
        protected override void OnBeforeSave()
        {
            if (this.decodedItem == null && !base.AttachmentCollection.IsDirty && base.IsRestricted && (base.Recipients.IsDirty || base.IsPropertyDirty(ItemSchema.Sender)))
            {
                this.EnsureIsDecoded();
            }
            if (this.decodedItem != null)
            {
                string contentClass = base.TryGetProperty(InternalSchema.ContentClass) as string;
                if (this.rmsTemplate == null)
                {
                    this.UnprotectAllAttachments();
                    RightsManagedMessageItem.CopyProtectableData(this.decodedItem, this);
                    if (ObjectClass.IsRightsManagedContentClass(contentClass))
                    {
                        base.Delete(StoreObjectSchema.ContentClass);
                    }
                }
                else
                {
                    this.charsetDetectionStringForProtectedData = new StringBuilder((int)Math.Min(this.ProtectedBody.Size, 2147483647L));
                    this.GetCharsetDetectionStringFromProtectedData(this.charsetDetectionStringForProtectedData);
                    if (!ObjectClass.IsRightsManagedContentClass(contentClass))
                    {
                        this[StoreObjectSchema.ContentClass] = "rpmsg.message";
                    }
                    if (this.isSending)
                    {
                        byte[][] valueOrDefault = base.GetValueOrDefault <byte[][]>(InternalSchema.DRMLicense);
                        if (valueOrDefault != null && valueOrDefault.Length == RightsManagedMessageItem.EmptyDrmLicense.Length && valueOrDefault[0].Length == RightsManagedMessageItem.EmptyDrmLicense[0].Length)
                        {
                            base.DeleteProperties(new PropertyDefinition[]
                            {
                                InternalSchema.DRMLicense
                            });
                        }
                    }
                    else if (base.IsDraft && base.GetValueOrDefault <byte[][]>(InternalSchema.DRMLicense) == null)
                    {
                        this[InternalSchema.DRMLicense] = RightsManagedMessageItem.EmptyDrmLicense;
                    }
                    base.AttachmentCollection.RemoveAll();
                    using (StreamAttachment streamAttachment = base.AttachmentCollection.Create(AttachmentType.Stream) as StreamAttachment)
                    {
                        streamAttachment.FileName    = "message.rpmsg";
                        streamAttachment.ContentType = "application/x-microsoft-rpmsg-message";
                        using (Stream stream = new PooledMemoryStream(131072))
                        {
                            if (this.serverUseLicense == null || ((this.UsageRights & ContentRight.Owner) == ContentRight.Owner && this.rmsTemplate.RequiresRepublishingWhenRecipientsChange && this.CanRepublish && (base.Recipients.IsDirty || (base.IsPropertyDirty(ItemSchema.Sender) && this.conversationOwner == null))))
                            {
                                if (this.ConversationOwner == null)
                                {
                                    throw new InvalidOperationException("Conversation owner must be set before protecting the message.");
                                }
                                this.UnprotectAllAttachments();
                                using (MsgToRpMsgConverter msgToRpMsgConverter = new MsgToRpMsgConverter(this, this.ConversationOwner, this.orgId, this.rmsTemplate, this.options))
                                {
                                    msgToRpMsgConverter.Convert(this.decodedItem, stream);
                                    using (Stream stream2 = base.OpenPropertyStream(MessageItemSchema.DRMServerLicenseCompressed, PropertyOpenMode.Create))
                                    {
                                        DrmEmailCompression.CompressUseLicense(msgToRpMsgConverter.ServerUseLicense, stream2);
                                    }
                                    if (this.InternalSession != null && this.InternalSession.MailboxOwner.Sid != null)
                                    {
                                        ExDateTime useLicenseExpiryTime = RmsClientManagerUtils.GetUseLicenseExpiryTime(msgToRpMsgConverter.ServerUseLicense, this.UsageRights);
                                        this[MessageItemSchema.DRMRights]     = (int)this.UsageRights;
                                        this[MessageItemSchema.DRMExpiryTime] = useLicenseExpiryTime;
                                        using (RightsSignatureBuilder rightsSignatureBuilder = new RightsSignatureBuilder(msgToRpMsgConverter.ServerUseLicense, msgToRpMsgConverter.PublishLicense, RmsClientManager.EnvironmentHandle, msgToRpMsgConverter.LicensePair))
                                        {
                                            this[MessageItemSchema.DRMPropsSignature] = rightsSignatureBuilder.Sign(this.UsageRights, useLicenseExpiryTime, this.InternalSession.MailboxOwner.Sid);
                                        }
                                    }
                                    goto IL_362;
                                }
                            }
                            using (MsgToRpMsgConverter msgToRpMsgConverter2 = new MsgToRpMsgConverter(this, this.orgId, this.publishLicense, this.serverUseLicense, this.options))
                            {
                                msgToRpMsgConverter2.Convert(this.decodedItem, stream);
                            }
IL_362:
                            using (Stream contentStream = streamAttachment.GetContentStream(PropertyOpenMode.Create))
                            {
                                stream.Seek(0L, SeekOrigin.Begin);
                                Util.StreamHandler.CopyStreamData(stream, contentStream);
                            }
                        }
                        bool flag = false;
                        foreach (AttachmentHandle handle in this.decodedItem.AttachmentCollection)
                        {
                            if (!CoreAttachmentCollection.IsInlineAttachment(handle))
                            {
                                flag = true;
                                break;
                            }
                        }
                        this[InternalSchema.AllAttachmentsHidden] = !flag;
                        streamAttachment.Save();
                    }
                }
                this.decodedItem.Dispose();
                this.decodedItem       = null;
                this.effectiveRights   = ContentRight.Owner;
                this.publishLicense    = null;
                this.restrictionInfo   = null;
                this.rmsTemplate       = null;
                this.serverUseLicense  = null;
                this.conversationOwner = null;
            }
            base.OnBeforeSave();
        }
Exemple #30
0
 public void MoveNext()
 {
     this.CheckDisposed("MoveNext");
     for (;;)
     {
         this.currentRow++;
         if (this.rows == null || this.currentRow >= this.rows.Length)
         {
             this.currentRow = 0;
             this.rows       = this.query.GetPropertyBags(this.chunkSize);
             if (this.rows.Length == 0)
             {
                 break;
             }
             this.chunkSize = Math.Min(this.chunkSize * 2, 1000);
         }
         IStorePropertyBag storePropertyBag = this.Current;
         object            obj = storePropertyBag.TryGetProperty(StoreObjectSchema.ItemClass);
         if (storePropertyBag != null && !(storePropertyBag.TryGetProperty(ItemSchema.Id) is PropertyError) && !(obj is PropertyError) && (ObjectClass.IsContact((string)obj) || ObjectClass.IsDistributionList((string)obj)))
         {
             return;
         }
         AllContactsCursor.Tracer.TraceDebug(0L, "AllContactsCursor.MoveNext: Skipping bogus contact");
     }
     this.rows = null;
 }