Esempio n. 1
0
 private void SetTaskFolderId(byte[] entryId)
 {
     if (IdConverter.IsFolderId(entryId))
     {
         this.taskFolderObjectId = StoreObjectId.FromProviderSpecificIdOrNull(entryId);
     }
 }
Esempio n. 2
0
        internal static TaskGroupEntryInfo GetTaskGroupEntryInfoFromRow(IStorePropertyBag row)
        {
            VersionedId versionedId = (VersionedId)row.TryGetProperty(ItemSchema.Id);

            byte[] valueOrDefault  = row.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.NodeEntryId, null);
            byte[] valueOrDefault2 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
            string valueOrDefault3 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty);

            byte[] valueOrDefault4 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null);
            row.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.StoreEntryId, null);
            ExDateTime valueOrDefault5 = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue);

            row.GetValueOrDefault <FolderTreeDataType>(FolderTreeDataSchema.Type, FolderTreeDataType.NormalFolder);
            FolderTreeDataFlags valueOrDefault6 = row.GetValueOrDefault <FolderTreeDataFlags>(FolderTreeDataSchema.FolderTreeDataFlags, FolderTreeDataFlags.None);
            Guid safeGuidFromByteArray          = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault2);

            if (safeGuidFromByteArray.Equals(Guid.Empty))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found TaskGroupEntry with invalid parent group class id. ArrayLength: {0}", (valueOrDefault2 == null) ? -1 : valueOrDefault2.Length);
                return(null);
            }
            if (IdConverter.IsFolderId(valueOrDefault))
            {
                StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault);
                if ((valueOrDefault6 & FolderTreeDataFlags.IsDefaultStore) == FolderTreeDataFlags.IsDefaultStore)
                {
                    return(new TaskGroupEntryInfo(valueOrDefault3, versionedId, storeObjectId, safeGuidFromByteArray, valueOrDefault4, valueOrDefault5));
                }
                ExTraceGlobals.StorageTracer.TraceDebug <StoreObjectType, string, VersionedId>(0L, "Found TaskGroupEntry of type {0} referencing a non-task folder. ObjectType: {0}. TaskFfolderName: {1}. Id: {2}.", storeObjectId.ObjectType, valueOrDefault3, versionedId);
            }
            return(null);
        }
Esempio n. 3
0
 public byte[] GetLongTermIdFromId(StoreObjectId folderOrMessageId)
 {
     if (IdConverter.IsFolderId(folderOrMessageId))
     {
         return(this.GetLongTermIdFromId(this.GetFidFromId(folderOrMessageId)));
     }
     if (IdConverter.IsMessageId(folderOrMessageId))
     {
         return(this.GetLongTermIdFromId(this.GetMidFromMessageId(folderOrMessageId)));
     }
     throw new ArgumentException("Not a valid folder or message ID", "folderOrMessageId");
 }
 public static CopyToFolderAction Create(StoreObjectId folderId, Rule rule)
 {
     ActionBase.CheckParams(new object[]
     {
         rule,
         folderId
     });
     if (!IdConverter.IsFolderId(folderId))
     {
         throw new ArgumentException("folderId");
     }
     return(new CopyToFolderAction(folderId, rule));
 }
Esempio n. 5
0
 internal override byte[] GetEntryId(DefaultFolderContext context)
 {
     byte[][] array = this.GetLocationPropertyBag(context).TryGetProperty(this.Property) as byte[][];
     if (array == null || array.Length <= this.index)
     {
         return(null);
     }
     byte[] array2 = array[this.index];
     if (!IdConverter.IsFolderId(array2))
     {
         return(null);
     }
     return(array2);
 }
Esempio n. 6
0
 public StoreObjectId GetSessionSpecificId(StoreObjectId storeObjectId)
 {
     if (this.session is PublicFolderSession)
     {
         if (IdConverter.IsMessageId(storeObjectId))
         {
             return(this.CreateMessageId(this.GetFidFromId(storeObjectId), this.GetMidFromMessageId(storeObjectId)));
         }
         if (IdConverter.IsFolderId(storeObjectId))
         {
             return(this.CreateFolderId(this.GetFidFromId(storeObjectId)));
         }
     }
     return(storeObjectId);
 }
 public static MoveToFolderAction Create(StoreObjectId folderId, Rule rule)
 {
     ActionBase.CheckParams(new object[]
     {
         rule,
         folderId
     });
     if (!IdConverter.IsFolderId(folderId))
     {
         rule.ThrowValidateException(delegate
         {
             throw new ArgumentNullException("folderId");
         }, "folderId");
     }
     return(new MoveToFolderAction(folderId, rule));
 }
Esempio n. 8
0
        internal static DeferredAction Create(MailboxSession session, StoreObjectId ruleFolderId, string providerName)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(ruleFolderId, "ruleFolderId");
            Util.ThrowOnNullArgument(providerName, "providerName");
            if (!IdConverter.IsFolderId(ruleFolderId))
            {
                throw new ArgumentException(ServerStrings.InvalidFolderId(ruleFolderId.ToBase64String()));
            }
            DeferredAction deferredAction = new DeferredAction();

            deferredAction.actions = new List <RuleAction>();
            deferredAction.ruleIds = new List <long>();
            deferredAction.message = MessageItem.Create(session, session.GetDefaultFolderId(DefaultFolderType.DeferredActionFolder));
            deferredAction.message[InternalSchema.ItemClass]         = "IPC.Microsoft Exchange 4.0.Deferred Action";
            deferredAction.message[InternalSchema.RuleFolderEntryId] = ruleFolderId.ProviderLevelItemId;
            deferredAction.message[InternalSchema.RuleProvider]      = providerName;
            return(deferredAction);
        }
Esempio n. 9
0
        private DefaultFolderData InitializeFolderIdPrivate()
        {
            ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::InitializeFolderId. The default folder ID is about to be initialized. defaultFolder = {0}.", this);
            byte[] array = this.defaultFolderInfo.EntryIdStrategy.GetEntryId(this.context);
            if (!IdConverter.IsFolderId(array))
            {
                array = null;
                ExTraceGlobals.DefaultFoldersTracer.TraceError <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::InitializeFolderId. Invalid entry id found. defaultFolder = {0}.", this);
            }
            DefaultFolderData result;

            if (array != null)
            {
                result = new DefaultFolderData(StoreObjectId.FromProviderSpecificId(array, this.StoreObjectType), true, false);
            }
            else
            {
                result = new DefaultFolderData(null, true, false);
            }
            return(result);
        }
Esempio n. 10
0
        public static DeferredError Create(MailboxSession session, StoreObjectId folderId, string providerName, long ruleId, RuleAction.Type actionType, int actionNumber, DeferredError.RuleError ruleError)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(folderId, "folderId");
            Util.ThrowOnNullArgument(providerName, "providerName");
            EnumValidator.ThrowIfInvalid <RuleAction.Type>(actionType, "actionType");
            EnumValidator.ThrowIfInvalid <DeferredError.RuleError>(ruleError, "ruleError");
            if (!IdConverter.IsFolderId(folderId))
            {
                throw new ArgumentException(ServerStrings.InvalidFolderId(folderId.ToBase64String()));
            }
            DeferredError deferredError = new DeferredError();

            deferredError.message = MessageItem.Create(session, session.GetDefaultFolderId(DefaultFolderType.DeferredActionFolder));
            deferredError.message[InternalSchema.ItemClass]         = "IPC.Microsoft Exchange 4.0.Deferred Error";
            deferredError.message[InternalSchema.RuleFolderEntryId] = folderId.ProviderLevelItemId;
            deferredError.message[InternalSchema.RuleId]            = ruleId;
            deferredError.message[InternalSchema.RuleActionType]    = (int)actionType;
            deferredError.message[InternalSchema.RuleActionNumber]  = actionNumber;
            deferredError.message[InternalSchema.RuleError]         = ruleError;
            deferredError.message[InternalSchema.RuleProvider]      = providerName;
            return(deferredError);
        }
Esempio n. 11
0
 protected override bool IsCompatibleId(StoreId id, ICoreObject coreObject)
 {
     return((coreObject == null || coreObject is CoreFolder) && IdConverter.IsFolderId(StoreId.GetStoreObjectId(id)));
 }
Esempio n. 12
0
        internal static CalendarGroupEntryInfo GetCalendarGroupEntryInfoFromRow(IStorePropertyBag row)
        {
            VersionedId versionedId = (VersionedId)row.TryGetProperty(ItemSchema.Id);

            byte[] valueOrDefault  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.NodeEntryId, null);
            byte[] valueOrDefault2 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
            string valueOrDefault3 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty);
            LegacyCalendarColor valueOrDefault4 = row.GetValueOrDefault <LegacyCalendarColor>(CalendarGroupEntrySchema.CalendarColor, LegacyCalendarColor.Auto);

            byte[]              valueOrDefault5  = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null);
            byte[]              valueOrDefault6  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.SharerAddressBookEntryId, null);
            byte[]              valueOrDefault7  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.StoreEntryId, null);
            ExDateTime          valueOrDefault8  = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue);
            FolderTreeDataType  valueOrDefault9  = row.GetValueOrDefault <FolderTreeDataType>(FolderTreeDataSchema.Type, FolderTreeDataType.NormalFolder);
            FolderTreeDataFlags valueOrDefault10 = row.GetValueOrDefault <FolderTreeDataFlags>(FolderTreeDataSchema.FolderTreeDataFlags, FolderTreeDataFlags.None);
            Guid safeGuidFromByteArray           = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault2);

            if (safeGuidFromByteArray.Equals(Guid.Empty))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found CalendarGroupEntry with invalid parent group class id. ArrayLength: {0}", (valueOrDefault2 == null) ? -1 : valueOrDefault2.Length);
                return(null);
            }
            if (valueOrDefault9 != FolderTreeDataType.SharedFolder)
            {
                if (IdConverter.IsFolderId(valueOrDefault))
                {
                    StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault);
                    if ((valueOrDefault10 & FolderTreeDataFlags.IsDefaultStore) == FolderTreeDataFlags.IsDefaultStore)
                    {
                        return(new LocalCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId, valueOrDefault5, safeGuidFromByteArray, (valueOrDefault10 & FolderTreeDataFlags.ICalFolder) == FolderTreeDataFlags.ICalFolder || (valueOrDefault10 & FolderTreeDataFlags.SharedIn) == FolderTreeDataFlags.SharedIn, valueOrDefault8));
                    }
                    if ((valueOrDefault10 & FolderTreeDataFlags.PublicFolder) == FolderTreeDataFlags.PublicFolder)
                    {
                        string calendarOwner = Microsoft.Exchange.Data.Storage.StoreEntryId.TryParseStoreEntryIdMailboxDN(valueOrDefault7);
                        storeObjectId = StoreObjectId.FromLegacyFavoritePublicFolderId(storeObjectId);
                        return(new LinkedCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId, calendarOwner, safeGuidFromByteArray, valueOrDefault5, false, true, valueOrDefault8));
                    }
                    ExTraceGlobals.StorageTracer.TraceDebug <StoreObjectType, string, VersionedId>(0L, "Found CalendarGroupEntry of type {0} referencing a non-calendar folder. ObjectType: {0}. CalendarName: {1}. Id: {2}.", storeObjectId.ObjectType, valueOrDefault3, versionedId);
                }
                return(null);
            }
            bool   flag = true;
            Eidt   eidt;
            string text;

            if (!AddressBookEntryId.IsAddressBookEntryId(valueOrDefault6, out eidt, out text))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "AddressBookEntryId is missing, not primary calendar {0}", valueOrDefault3);
                if (valueOrDefault7 == null)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "StoreEntryId is missing for calendar: {0} - invalid entry, skipping.", valueOrDefault3);
                    return(null);
                }
                text = Microsoft.Exchange.Data.Storage.StoreEntryId.TryParseStoreEntryIdMailboxDN(valueOrDefault7);
                flag = false;
            }
            if (text == null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Unable to determine owner of shared calendar: {0}. Skipping.", valueOrDefault3);
                return(null);
            }
            StoreObjectId storeObjectId2 = IdConverter.IsFolderId(valueOrDefault) ? StoreObjectId.FromProviderSpecificId(valueOrDefault) : null;

            if (!flag && storeObjectId2 == null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Secondary shared calendar without a folder id encountered {0}. Skipping.", valueOrDefault3);
                return(null);
            }
            return(new LinkedCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId2, text, safeGuidFromByteArray, valueOrDefault5, flag, false, valueOrDefault8));
        }
        internal static DefaultFolderManager Create(MailboxSession session, OpenMailboxSessionFlags openFlags, IList <DefaultFolderType> foldersToInit)
        {
            DefaultFolderManager defaultFolderManager = new DefaultFolderManager(session);
            DefaultFolderContext defaultFolderContext = new DefaultFolderContext(session, defaultFolderManager.defaultFolders);

            defaultFolderManager.context = defaultFolderContext;
            if ((openFlags & OpenMailboxSessionFlags.DeferDefaultFolderIdInitialization) == OpenMailboxSessionFlags.DeferDefaultFolderIdInitialization)
            {
                defaultFolderContext.DeferFolderIdInit = true;
            }
            if ((openFlags & OpenMailboxSessionFlags.IgnoreForcedFolderInit) == OpenMailboxSessionFlags.IgnoreForcedFolderInit)
            {
                defaultFolderContext.IgnoreForcedFolderInit = true;
            }
            if (defaultFolderContext.Session.SharedDataManager.DefaultFoldersInitialized)
            {
                defaultFolderManager.CacheDefaultFoldersFromSharedDataManager(defaultFolderContext);
                defaultFolderContext.DoneDefaultFolderInitialization();
                return(defaultFolderManager);
            }
            try
            {
                if ((openFlags & OpenMailboxSessionFlags.SuppressFolderIdPrefetch) == OpenMailboxSessionFlags.None)
                {
                    defaultFolderContext.FolderDataDictionary = defaultFolderManager.ReadFolderData();
                }
                else if (session.Capabilities.CanCreateDefaultFolders)
                {
                    string      inboxDisplayName = null;
                    CultureInfo stampedCulture   = session.Capabilities.CanHaveCulture ? session.PreferedCulture : CultureInfo.InvariantCulture;
                    if (session.LogonType != LogonType.Delegated)
                    {
                        object thisObject = null;
                        bool   flag       = false;
                        byte[] inboxFolderEntryId;
                        try
                        {
                            if (session != null)
                            {
                                session.BeginMapiCall();
                                session.BeginServerHealthCall();
                                flag = true;
                            }
                            if (StorageGlobals.MapiTestHookBeforeCall != null)
                            {
                                StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                            }
                            inboxFolderEntryId = session.Mailbox.MapiStore.GetInboxFolderEntryId();
                        }
                        catch (MapiPermanentException ex)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("DefaultFolderManager::GetInboxId. Hit exception when adding ``free'' default folders.", new object[0]),
                                ex
                            });
                        }
                        catch (MapiRetryableException ex2)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("DefaultFolderManager::GetInboxId. Hit exception when adding ``free'' default folders.", new object[0]),
                                ex2
                            });
                        }
                        finally
                        {
                            try
                            {
                                if (session != null)
                                {
                                    session.EndMapiCall();
                                    if (flag)
                                    {
                                        session.EndServerHealthCall();
                                    }
                                }
                            }
                            finally
                            {
                                if (StorageGlobals.MapiTestHookAfterCall != null)
                                {
                                    StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                                }
                            }
                        }
                        if (IdConverter.IsFolderId(inboxFolderEntryId))
                        {
                            StoreObjectId inboxId = StoreObjectId.FromProviderSpecificId(inboxFolderEntryId);
                            DefaultFolderManager.TryGetDefaultFolderCulture(session, inboxId, out stampedCulture, out inboxDisplayName);
                        }
                    }
                    defaultFolderContext.Session.SharedDataManager.DefaultFoldersCulture = defaultFolderManager.GetBestCulture(stampedCulture, inboxDisplayName, session);
                }
                else
                {
                    defaultFolderContext.Session.SharedDataManager.DefaultFoldersCulture = CultureInfo.InvariantCulture;
                }
                defaultFolderManager.CacheDefaultFolders(defaultFolderContext, foldersToInit);
                defaultFolderManager.ValidateDefaultFolderSet(defaultFolderContext);
            }
            finally
            {
                defaultFolderContext.DoneDefaultFolderInitialization();
            }
            return(defaultFolderManager);
        }