Esempio n. 1
0
        // Token: 0x06000C4A RID: 3146 RVA: 0x00040EDC File Offset: 0x0003F0DC
        private StoreObjectId GetStoreObjectId(string collectionId, string serverId)
        {
            StoreObjectId   result = null;
            FolderSyncState folderSyncState;

            if (this.syncStates.ContainsKey(collectionId))
            {
                folderSyncState = this.syncStates[collectionId];
            }
            else
            {
                folderSyncState = this.syncStateStorage.GetFolderSyncState(collectionId);
                if (folderSyncState != null)
                {
                    this.syncStates.Add(collectionId, folderSyncState);
                }
            }
            if (folderSyncState != null)
            {
                ItemIdMapping itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping];
                if (itemIdMapping != null)
                {
                    MailboxSyncItemId mailboxSyncItemId = itemIdMapping[serverId] as MailboxSyncItemId;
                    if (mailboxSyncItemId != null)
                    {
                        result = (StoreObjectId)mailboxSyncItemId.NativeId;
                    }
                }
            }
            return(result);
        }
        // Token: 0x06000D09 RID: 3337 RVA: 0x00047074 File Offset: 0x00045274
        private string GetDstSyncItemId(StoreObjectId dstFolderId, StoreObjectId mailboxItemId)
        {
            string    text = this.FolderIdMapping[MailboxSyncItemId.CreateForNewItem(dstFolderId)];
            SyncState syncState;

            if (this.loadedSyncStates.ContainsKey(text))
            {
                syncState = this.loadedSyncStates[text];
            }
            else
            {
                syncState = base.SyncStateStorage.GetFolderSyncState(text);
                if (syncState == null)
                {
                    MailboxSyncProviderFactory syncProviderFactory = new MailboxSyncProviderFactory(base.MailboxSession, dstFolderId);
                    syncState = base.SyncStateStorage.CreateFolderSyncState(syncProviderFactory, text);
                }
                if (syncState[CustomStateDatumType.IdMapping] == null)
                {
                    syncState[CustomStateDatumType.IdMapping] = new ItemIdMapping(text);
                }
                this.loadedSyncStates.Add(text, syncState);
            }
            ItemIdMapping     itemIdMapping     = (ItemIdMapping)syncState[CustomStateDatumType.IdMapping];
            MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(mailboxItemId);
            string            text2             = itemIdMapping[mailboxSyncItemId];

            if (text2 == null)
            {
                text2 = itemIdMapping.Add(mailboxSyncItemId);
            }
            return(text2);
        }
        // Token: 0x0600184F RID: 6223 RVA: 0x0008EB28 File Offset: 0x0008CD28
        private void LoadE12SyncState(StoreObjectId storeId, string shortParentId, int lastSeen)
        {
            this.syncState = this.syncStateStorage.CreateFolderSyncState(new MailboxSyncProviderFactory(this.mailboxSession, storeId, true), this.parentServerId);
            this.syncState.CustomVersion = new int?(2);
            ItemIdMapping itemIdMapping = new ItemIdMapping(shortParentId);

            itemIdMapping.IncreaseCounterTo((long)(lastSeen + 1));
            this.syncState[CustomStateDatumType.IdMapping] = itemIdMapping;
        }
        // Token: 0x06001850 RID: 6224 RVA: 0x0008EB8C File Offset: 0x0008CD8C
        private void UpdateMapping(Dictionary <StoreObjectId, string> mappingFromStorageIds, Dictionary <string, string> mappingToSP2Id)
        {
            ItemIdMapping itemIdMapping = (ItemIdMapping)this.syncState[CustomStateDatumType.IdMapping];

            foreach (StoreObjectId storeObjectId in mappingFromStorageIds.Keys)
            {
                string key    = mappingFromStorageIds[storeObjectId];
                string syncId = mappingToSP2Id[key];
                itemIdMapping.Add(MailboxSyncItemId.CreateForNewItem(storeObjectId), syncId);
            }
        }
Esempio n. 5
0
        private static StoreObjectId GetItemId(ItemIdMapping idmapping, string folder, string item)
        {
            string            syncId            = folder + ":" + item;
            MailboxSyncItemId mailboxSyncItemId = idmapping[syncId] as MailboxSyncItemId;

            if (mailboxSyncItemId != null)
            {
                return((StoreObjectId)mailboxSyncItemId.NativeId);
            }
            return(null);
        }
        // Token: 0x06000C3C RID: 3132 RVA: 0x00040194 File Offset: 0x0003E394
        protected override int InternalExecute(int count)
        {
            FolderSyncState folderSyncState = null;
            int             result;

            try
            {
                string        text          = HttpUtility.UrlDecode(base.FileReference);
                int           num           = text.IndexOf(':');
                ItemIdMapping itemIdMapping = null;
                if (num != -1 && num != text.LastIndexOf(':'))
                {
                    string text2 = text.Substring(0, num);
                    SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(text2);
                    if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoAttachmentsOnVItem");
                        AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidCombinationOfIDs, null, false);
                        throw ex;
                    }
                    folderSyncState = base.SyncStateStorage.GetFolderSyncState(new MailboxSyncProviderFactory(base.Session), text2);
                    if (folderSyncState == null)
                    {
                        throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(text));
                    }
                    itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping];
                    if (itemIdMapping == null)
                    {
                        throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(text));
                    }
                }
                int num2;
                base.ContentType = AttachmentHelper.GetAttachment(base.Session, text, base.OutStream, base.MinRange, count, base.MaxAttachmentSize, itemIdMapping, base.RightsManagementSupport, out num2);
                result           = num2;
            }
            finally
            {
                if (folderSyncState != null)
                {
                    folderSyncState.Dispose();
                    folderSyncState = null;
                }
            }
            return(result);
        }
 // Token: 0x0600184B RID: 6219 RVA: 0x0008E5E4 File Offset: 0x0008C7E4
 public void UpdateMappingWithParent(string shortParentId)
 {
     try
     {
         this.syncState = this.syncStateStorage.GetFolderSyncState(new MailboxSyncProviderFactory(this.mailboxSession, this.storeId, true), this.parentServerId);
         ItemIdMapping itemIdMapping = (ItemIdMapping)this.syncState[CustomStateDatumType.IdMapping];
         itemIdMapping.UpdateParent(shortParentId);
         itemIdMapping.CommitChanges();
         this.syncState.Commit();
     }
     finally
     {
         if (this.syncState != null)
         {
             this.syncState.Dispose();
         }
     }
 }
Esempio n. 8
0
        public override ISyncItemId ConvertClientToServerObjectAndSave(SyncCommandItem syncCommandItem, ref uint maxWindowSize, ref bool mergeToClient)
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.ConvertClientToServerObjectAndSave");
            base.CheckFullAccess();
            ItemIdMapping itemIdMapping = base.ItemIdMapping;
            IItem         item          = ((EntitySyncItem)syncCommandItem.Item).Item;

            try
            {
                this.EntityDataObject.Bind(item);
                base.AirSyncDataObject.Bind(syncCommandItem.XmlNode);
                this.EntityDataObject.CopyFrom(base.AirSyncDataObject);
            }
            finally
            {
                base.AirSyncDataObject.Unbind();
                this.EntityDataObject.Unbind();
            }
            ISyncItemId syncItemId = this.ApplyChanges(syncCommandItem);

            syncCommandItem.ChangeTrackingInformation = base.ChangeTrackFilter.UpdateChangeTrackingInformation(syncCommandItem.XmlNode, syncCommandItem.ChangeTrackingInformation);
            syncCommandItem.SyncId = base.ItemIdMapping[syncItemId];
            return(syncItemId);
        }
        // Token: 0x06000D0A RID: 3338 RVA: 0x0004713C File Offset: 0x0004533C
        private StoreObjectId GetXsoItemId(string syncFolderId, string syncItemId)
        {
            FolderSyncState folderSyncState;

            if (this.loadedSyncStates.ContainsKey(syncFolderId))
            {
                folderSyncState = (FolderSyncState)this.loadedSyncStates[syncFolderId];
            }
            else
            {
                folderSyncState = base.SyncStateStorage.GetFolderSyncState(syncFolderId);
                if (folderSyncState == null)
                {
                    return(null);
                }
                if (folderSyncState.CustomVersion != null && folderSyncState.CustomVersion.Value > 9)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SyncStateVersionMismatch");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateVersionInvalid, EASServerStrings.MismatchSyncStateError, true);
                }
                this.loadedSyncStates.Add(syncFolderId, folderSyncState);
            }
            ItemIdMapping itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping];

            if (itemIdMapping == null)
            {
                return(null);
            }
            MailboxSyncItemId mailboxSyncItemId = itemIdMapping[syncItemId] as MailboxSyncItemId;

            if (mailboxSyncItemId != null)
            {
                return((StoreObjectId)mailboxSyncItemId.NativeId);
            }
            return(null);
        }
        // Token: 0x06001561 RID: 5473 RVA: 0x0007D91C File Offset: 0x0007BB1C
        protected StoreObjectId GetSmartItemId()
        {
            this.ParseXmlRequest();
            string          collectionId    = this.CollectionId;
            string          itemId          = this.ItemId;
            string          longId          = this.LongId;
            StoreObjectId   storeObjectId   = null;
            FolderSyncState folderSyncState = null;
            StoreObjectId   result;

            try
            {
                if (longId != null)
                {
                    if (base.Version < 120)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "LongIdSupportedinV12Only");
                        throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
                    }
                    try
                    {
                        storeObjectId = StoreObjectId.Deserialize(longId);
                        goto IL_1F1;
                    }
                    catch (ArgumentException innerException)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId");
                        throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidIDs, innerException, false);
                    }
                    catch (FormatException innerException2)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId2");
                        throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidIDs, innerException2, false);
                    }
                    catch (CorruptDataException innerException3)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId3");
                        throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidIDs, innerException3, false);
                    }
                }
                if (collectionId == null)
                {
                    StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);
                    MailboxSyncProviderFactory syncProviderFactory = new MailboxSyncProviderFactory(base.MailboxSession, defaultFolderId);
                    folderSyncState = base.SyncStateStorage.GetFolderSyncState(syncProviderFactory);
                }
                else
                {
                    SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(collectionId);
                    if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SendFromVirtualFolder");
                        throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
                    }
                    folderSyncState = base.SyncStateStorage.GetFolderSyncState(collectionId);
                }
                if (folderSyncState == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SyncStateNotFound");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateNotFound, null, false);
                }
                ItemIdMapping itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping];
                if (itemIdMapping == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemIdMappingNotFound");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ItemNotFound, null, false);
                }
                MailboxSyncItemId mailboxSyncItemId = itemIdMapping[itemId] as MailboxSyncItemId;
                storeObjectId = ((mailboxSyncItemId == null) ? null : ((StoreObjectId)mailboxSyncItemId.NativeId));
                if (storeObjectId == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemIdMappingNotFound");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ItemNotFound, null, false);
                }
                folderSyncState.Dispose();
                folderSyncState = null;
IL_1F1:
                result = storeObjectId;
            }
            finally
            {
                if (folderSyncState != null)
                {
                    folderSyncState.Dispose();
                }
            }
            return(result);
        }
        internal override Command.ExecutionState ExecuteCommand()
        {
            string          attachmentName  = this.AttachmentName;
            string          value           = string.Empty;
            FolderSyncState folderSyncState = null;

            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "GetAttachmentCommand.Execute(). AttachmentName: '{0}'", attachmentName);
            try
            {
                int incBy = 0;
                if (base.Request.ContentType != null && !string.Equals(base.Request.ContentType, "message/rfc822", StringComparison.OrdinalIgnoreCase))
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidContentType");
                    throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.First140Error, null, false);
                }
                int           num           = attachmentName.IndexOf(':');
                ItemIdMapping itemIdMapping = null;
                if (num != -1 && num != attachmentName.LastIndexOf(':'))
                {
                    folderSyncState = base.SyncStateStorage.GetFolderSyncState(new MailboxSyncProviderFactory(base.MailboxSession), attachmentName.Substring(0, num));
                    if (folderSyncState == null)
                    {
                        throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentName));
                    }
                    itemIdMapping = (ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping];
                    if (itemIdMapping == null)
                    {
                        throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentName));
                    }
                }
                PolicyData policyData = ADNotificationManager.GetPolicyData(base.User);
                if (policyData != null && !policyData.AttachmentsEnabled)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AttachmentsNotEnabledGetAttCmd");
                    throw new AirSyncPermanentException(HttpStatusCode.Forbidden, StatusCode.AccessDenied, null, false);
                }
                Unlimited <ByteQuantifiedSize> maxAttachmentSize = (policyData != null) ? policyData.MaxAttachmentSize : Unlimited <ByteQuantifiedSize> .UnlimitedValue;
                value = AttachmentHelper.GetAttachment(base.MailboxSession, attachmentName, base.OutputStream, maxAttachmentSize, itemIdMapping, out incBy);
                base.ProtocolLogger.IncrementValue(ProtocolLoggerData.Attachments);
                base.ProtocolLogger.IncrementValueBy(ProtocolLoggerData.AttachmentBytes, incBy);
            }
            catch (FormatException innerException)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidAttachmentName");
                AirSyncPermanentException ex = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidIDs, innerException, false);
                throw ex;
            }
            catch (ObjectNotFoundException innerException2)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AttachmentNotFound");
                AirSyncPermanentException ex2 = new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.None, innerException2, false);
                throw ex2;
            }
            catch (IOException innerException3)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "IOException");
                throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.None, innerException3, false);
            }
            catch (DataTooLargeException innerException4)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "AttachmentIsTooLarge");
                PolicyData policyData2 = ADNotificationManager.GetPolicyData(base.User);
                if (policyData2 != null)
                {
                    policyData2.MaxAttachmentSize.ToString();
                }
                else
                {
                    GlobalSettings.MaxDocumentDataSize.ToString(CultureInfo.InvariantCulture);
                }
                throw new AirSyncPermanentException(HttpStatusCode.RequestEntityTooLarge, StatusCode.AttachmentIsTooLarge, innerException4, false);
            }
            finally
            {
                if (folderSyncState != null)
                {
                    folderSyncState.Dispose();
                    folderSyncState = null;
                }
            }
            base.Context.Response.AppendHeader("Content-Type", value);
            return(Command.ExecutionState.Complete);
        }
Esempio n. 12
0
        internal static string GetAttachment(MailboxSession mailboxSession, string attachmentId, Stream outStream, int offset, int count, Unlimited <ByteQuantifiedSize> maxAttachmentSize, ItemIdMapping idmapping, bool rightsManagementSupport, out int total)
        {
            string[] array = attachmentId.Split(new char[]
            {
                ':'
            });
            if (array.Length != 2 && array.Length != 3)
            {
                return(AttachmentHelper.GetAttachmentByUrlCompName(mailboxSession, attachmentId, outStream, offset, count, maxAttachmentSize, out total));
            }
            StoreObjectId itemId;
            string        text;

            if (array.Length == 2)
            {
                itemId = AttachmentHelper.GetItemId(array[0]);
                text   = array[1];
            }
            else
            {
                itemId = AttachmentHelper.GetItemId(idmapping, array[0], array[1]);
                text   = array[2];
            }
            if (itemId == null)
            {
                throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentId));
            }
            AirSyncDiagnostics.TraceDebug <StoreObjectId, string>(ExTraceGlobals.RequestsTracer, null, "Getting attachment with itemId {0} and attachmentIndex {1}.", itemId, text);
            return(AttachmentHelper.GetAttachment(mailboxSession, itemId, text, outStream, offset, count, maxAttachmentSize, rightsManagementSupport, out total));
        }
Esempio n. 13
0
 internal static string GetAttachment(MailboxSession mailboxSession, string attachmentId, Stream outStream, Unlimited <ByteQuantifiedSize> maxAttachmentSize, ItemIdMapping idmapping, out int total)
 {
     return(AttachmentHelper.GetAttachment(mailboxSession, attachmentId, outStream, 0, -1, maxAttachmentSize, idmapping, false, out total));
 }