// Token: 0x06001809 RID: 6153 RVA: 0x0008D7B8 File Offset: 0x0008B9B8
        private void UpdateMapping(Dictionary <string, StoreObjectId> mapping)
        {
            FolderIdMapping folderIdMapping = (FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping];
            Dictionary <StoreObjectId, FolderStateEntry> data = ((GenericDictionaryData <StoreObjectIdData, StoreObjectId, FolderStateEntry>) this.syncState[SyncStateProp.ClientState]).Data;

            foreach (string text in mapping.Keys)
            {
                StoreObjectId storeObjectId = mapping[text];
                folderIdMapping.Add(MailboxSyncItemId.CreateForNewItem(storeObjectId), text);
                if (data.ContainsKey(storeObjectId))
                {
                    FolderStateEntry folderStateEntry = data[storeObjectId];
                    if (folderStateEntry.ChangeKey.Length == 1 && folderStateEntry.ChangeKey[0] == 1)
                    {
                        folderStateEntry.ChangeTrackingHash = "blah".GetHashCode();
                    }
                    else
                    {
                        folderStateEntry.ChangeTrackingHash = FolderCommand.ComputeChangeTrackingHash(this.mailboxSession, mapping[text], null);
                    }
                }
            }
            folderIdMapping.CommitChanges();
            StoreObjectId defaultFolderId = this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);

            mapping.Add("EmailSyncFile", defaultFolderId);
            defaultFolderId = this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Contacts);
            mapping.Add("ContactsSyncFile", defaultFolderId);
            defaultFolderId = this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar);
            mapping.Add("CalendarSyncFile", defaultFolderId);
            defaultFolderId = this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Tasks);
            mapping.Add("TasksSyncFile", defaultFolderId);
        }
        // Token: 0x06001805 RID: 6149 RVA: 0x0008D4A8 File Offset: 0x0008B6A8
        public void UpdateLastFolderId(int folderId)
        {
            FolderIdMappingSyncStateInfo syncStateInfo = new FolderIdMappingSyncStateInfo();

            this.folderIdMappingSyncState = this.syncStateStorage.GetCustomSyncState(syncStateInfo, new PropertyDefinition[0]);
            FolderIdMapping folderIdMapping = (FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping];

            folderIdMapping.IncreaseCounterTo((long)folderId);
            this.folderIdMappingSyncState.Commit();
        }
        // Token: 0x060009BF RID: 2495 RVA: 0x000395CC File Offset: 0x000377CC
        private static string GetOrAddSyncFolderId(SyncState folderIdMappingSyncState, StoreObjectId mailboxFolderId)
        {
            FolderIdMapping   folderIdMapping   = (FolderIdMapping)folderIdMappingSyncState[CustomStateDatumType.IdMapping];
            FolderTree        folderTree        = (FolderTree)folderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
            MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(mailboxFolderId);
            string            text = folderIdMapping[mailboxSyncItemId];

            if (text == null)
            {
                text = folderIdMapping.Add(mailboxSyncItemId);
                folderTree.AddFolder(mailboxSyncItemId);
            }
            return(text);
        }
        protected override void ProcessCommand(FolderCommand.FolderRequest folderRequest, XmlDocument doc)
        {
            string                    namespaceURI      = doc.DocumentElement.NamespaceURI;
            DefaultFolderType         defaultFolderType = base.MailboxSession.IsDefaultFolderType(folderRequest.ServerId);
            AirSyncPermanentException ex;

            if (defaultFolderType != DefaultFolderType.None)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "DeleteOfDefaultFolder");
                ex = new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, base.ConstructErrorXml(StatusCode.Sync_InvalidSyncKey), null, false);
                throw ex;
            }
            AggregateOperationResult aggregateOperationResult = base.MailboxSession.Delete(DeleteItemFlags.SoftDelete, new StoreObjectId[]
            {
                folderRequest.ServerId
            });

            if (aggregateOperationResult.OperationResult != OperationResult.Failed)
            {
                base.FolderHierarchySync.RecordClientOperation(folderRequest.ServerId, ChangeType.Delete, null);
                folderRequest.RecoverySyncKey = folderRequest.SyncKey;
                folderRequest.SyncKey         = base.GetNextNumber(folderRequest.SyncKey);
                base.SyncStateChanged         = true;
                base.FolderHierarchySyncState[CustomStateDatumType.SyncKey]         = new Int32Data(folderRequest.SyncKey);
                base.FolderHierarchySyncState[CustomStateDatumType.RecoverySyncKey] = new Int32Data(folderRequest.RecoverySyncKey);
                FolderIdMapping   folderIdMapping = (FolderIdMapping)base.FolderIdMappingSyncState[CustomStateDatumType.IdMapping];
                FolderTree        folderTree      = (FolderTree)base.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                MailboxSyncItemId folderId        = MailboxSyncItemId.CreateForNewItem(folderRequest.ServerId);
                folderTree.RemoveFolderAndChildren(folderId, folderIdMapping);
                folderIdMapping.CommitChanges();
                base.ProtocolLogger.IncrementValue("F", PerFolderProtocolLoggerData.ClientDeletes);
                XmlNode xmlNode = doc.CreateElement("Status", namespaceURI);
                xmlNode.InnerText = "1";
                XmlNode xmlNode2 = doc.CreateElement("SyncKey", namespaceURI);
                xmlNode2.InnerText = folderRequest.SyncKey.ToString(CultureInfo.InvariantCulture);
                doc.DocumentElement.AppendChild(xmlNode);
                doc.DocumentElement.AppendChild(xmlNode2);
                return;
            }
            if (aggregateOperationResult.GroupOperationResults != null && aggregateOperationResult.GroupOperationResults.Length > 0 && aggregateOperationResult.GroupOperationResults[0] != null && aggregateOperationResult.GroupOperationResults[0].Exception is ObjectNotFoundException)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "DeleteOfNonExistentFolder");
                ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolError, base.ConstructErrorXml(StatusCode.Sync_ProtocolError), null, false);
                throw ex;
            }
            base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "DeleteFailed");
            ex = new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, base.ConstructErrorXml(StatusCode.Sync_ClientServerConversion), null, false);
            throw ex;
        }
Beispiel #5
0
        private bool RemoveFolderAndChildren(ISyncItemId folderId, FolderIdMapping folderIdMapping, int foldersSeen, int numberOfFoldersInTree)
        {
            FolderTree.FolderInfo folderInfo = this.GetFolderInfo(folderId);
            foldersSeen++;
            if (foldersSeen > numberOfFoldersInTree)
            {
                AirSyncDiagnostics.TraceError <int>(ExTraceGlobals.AlgorithmTracer, this, "Error: Loop detected in folder tree.  NumberOfFoldersInTree: {0}", numberOfFoldersInTree);
                this.TraceTree();
                return(false);
            }
            int num = 0;

            while (folderInfo.Children.Count > num)
            {
                ISyncItemId syncItemId = folderInfo.Children[num];
                if (this.folderTree.ContainsKey(syncItemId))
                {
                    if (!this.RemoveFolderAndChildren(syncItemId, folderIdMapping, foldersSeen, numberOfFoldersInTree))
                    {
                        return(false);
                    }
                }
                else
                {
                    num++;
                    MailboxSyncItemId mailboxSyncItemId = syncItemId as MailboxSyncItemId;
                    AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.AlgorithmTracer, this, "FolderTree.RemoveFolderAndChildren could not find child folder: {0} to remove.", (mailboxSyncItemId == null) ? "<folder is not a MailboxSyncItemId>" : mailboxSyncItemId.ToString());
                }
            }
            if (folderIdMapping.Contains(folderId))
            {
                folderIdMapping.Delete(new ISyncItemId[]
                {
                    folderId
                });
            }
            this.RemoveFolder(folderId);
            return(true);
        }
Beispiel #6
0
        // Token: 0x0600052E RID: 1326 RVA: 0x0001E8B4 File Offset: 0x0001CAB4
        protected override void ProcessCommand(MailboxSession mailboxSession, XmlDocument doc)
        {
            if (base.CollectionRequest.CollectionId == null)
            {
                base.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidURLParameters");
                throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
            }
            mailboxSession.Delete(DeleteItemFlags.SoftDelete, new StoreObjectId[]
            {
                base.CollectionRequest.CollectionId
            });
            FolderIdMapping folderIdMapping = (FolderIdMapping)base.SyncState[CustomStateDatumType.IdMapping];

            folderIdMapping.Delete(new ISyncItemId[]
            {
                MailboxSyncItemId.CreateForNewItem(base.CollectionRequest.CollectionId)
            });
            XmlNode xmlNode  = doc.CreateElement("Response", "FolderHierarchy:");
            XmlNode xmlNode2 = doc.CreateElement("Status", "FolderHierarchy:");

            xmlNode2.InnerText = "1";
            doc.AppendChild(xmlNode);
            xmlNode.AppendChild(xmlNode2);
        }
 // Token: 0x060008C8 RID: 2248 RVA: 0x00034B7C File Offset: 0x00032D7C
 protected override void ProcessCommand(FolderCommand.FolderRequest folderRequest, XmlDocument doc)
 {
     if (FolderCommand.IsEmptyOrWhiteSpacesOnly(folderRequest.DisplayName))
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EmptyDisplayName");
         AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), null, false);
         throw ex;
     }
     using (Folder folder = Folder.Create(base.MailboxSession, folderRequest.ParentId, StoreObjectType.Folder))
     {
         string namespaceURI = doc.DocumentElement.NamespaceURI;
         folder.DisplayName = folderRequest.DisplayName;
         string classNameFromType = AirSyncUtility.GetClassNameFromType(folderRequest.Type);
         if (classNameFromType == null)
         {
             AirSyncPermanentException ex;
             if (!this.IsValidSpecialFolderType(base.Version, folderRequest.Type))
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidFolderType");
                 ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), null, false);
                 throw ex;
             }
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CreateOfSpecialFolder");
             ex = new AirSyncPermanentException(StatusCode.Sync_InvalidSyncKey, base.ConstructErrorXml(StatusCode.Sync_InvalidSyncKey), null, false);
             throw ex;
         }
         else
         {
             folder.ClassName = classNameFromType;
             try
             {
                 folder.Save();
                 folder.Load();
             }
             catch (ObjectExistedException innerException)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FolderExistsOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), innerException, false);
                 throw ex;
             }
             catch (InvalidOperationException innerException2)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidOperationOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException2, false);
                 throw ex;
             }
             catch (ObjectValidationException innerException3)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ObjectValidationOnCreate");
                 AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), innerException3, false);
                 throw ex;
             }
             base.FolderHierarchySync.RecordClientOperation(folder.Id.ObjectId, ChangeType.Add, folder);
             folderRequest.RecoverySyncKey = folderRequest.SyncKey;
             folderRequest.SyncKey         = base.GetNextNumber(folderRequest.SyncKey);
             base.SyncStateChanged         = true;
             base.FolderHierarchySyncState[CustomStateDatumType.SyncKey]         = new Int32Data(folderRequest.SyncKey);
             base.FolderHierarchySyncState[CustomStateDatumType.RecoverySyncKey] = new Int32Data(folderRequest.RecoverySyncKey);
             XmlNode xmlNode = doc.CreateElement("Status", namespaceURI);
             xmlNode.InnerText = "1";
             XmlNode xmlNode2 = doc.CreateElement("SyncKey", namespaceURI);
             xmlNode2.InnerText = folderRequest.SyncKey.ToString(CultureInfo.InvariantCulture);
             XmlNode         xmlNode3        = doc.CreateElement("ServerId", namespaceURI);
             FolderIdMapping folderIdMapping = (FolderIdMapping)base.FolderIdMappingSyncState[CustomStateDatumType.IdMapping];
             ISyncItemId     syncItemId      = MailboxSyncItemId.CreateForNewItem(folder.Id.ObjectId);
             xmlNode3.InnerText = folderIdMapping.Add(syncItemId);
             folderIdMapping.CommitChanges();
             doc.DocumentElement.AppendChild(xmlNode);
             doc.DocumentElement.AppendChild(xmlNode2);
             doc.DocumentElement.AppendChild(xmlNode3);
             FolderTree folderTree = (FolderTree)base.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
             folderTree.AddFolder(syncItemId);
             if (!base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root).Equals(folderRequest.ParentId))
             {
                 ISyncItemId parentId = MailboxSyncItemId.CreateForNewItem(folderRequest.ParentId);
                 folderTree.LinkChildToParent(parentId, syncItemId);
             }
             base.ProtocolLogger.IncrementValue("F", PerFolderProtocolLoggerData.ClientAdds);
         }
     }
 }
        // Token: 0x0600088E RID: 2190 RVA: 0x00032DC8 File Offset: 0x00030FC8
        private void LoadSyncState(int syncKey)
        {
            FolderIdMappingSyncStateInfo syncStateInfo = new FolderIdMappingSyncStateInfo();

            if (syncKey == 0)
            {
                base.SendServerUpgradeHeader  = true;
                this.folderIdMappingSyncState = base.SyncStateStorage.GetCustomSyncState(syncStateInfo, new PropertyDefinition[0]);
                if (this.folderIdMappingSyncState == null || this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] == null)
                {
                    CustomSyncState customSyncState = base.SyncStateStorage.GetCustomSyncState(new GlobalSyncStateInfo(), new PropertyDefinition[0]);
                    if (customSyncState == null)
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Could not find policy sync state.  Deleting all sync states.");
                        base.SyncStateStorage.DeleteAllSyncStates();
                    }
                    else
                    {
                        customSyncState.Dispose();
                        using (FolderHierarchySyncState folderHierarchySyncState = base.SyncStateStorage.GetFolderHierarchySyncState())
                        {
                            if (folderHierarchySyncState != null)
                            {
                                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Deleting all sync states.");
                                base.SyncStateStorage.DeleteAllSyncStates();
                            }
                        }
                    }
                    this.folderIdMappingSyncState = base.SyncStateStorage.CreateCustomSyncState(syncStateInfo);
                    this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] = new FolderIdMapping();
                    this.folderHierarchySyncState = base.SyncStateStorage.CreateFolderHierarchySyncState();
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Deleting folder hierarchy sync state.");
                    base.SyncStateStorage.DeleteFolderHierarchySyncState();
                    this.folderHierarchySyncState = base.SyncStateStorage.CreateFolderHierarchySyncState();
                    ((FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping]).CommitChanges();
                }
                this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree]         = new FolderTree();
                this.folderIdMappingSyncState[CustomStateDatumType.RecoveryFullFolderTree] = this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                base.InitializeSyncStatusSyncState();
                base.SyncStatusSyncData.ClearClientCategoryHash();
                this.shouldSaveSyncStatus = true;
                Interlocked.Exchange(ref this.validToCommitSyncStatusSyncState, 1);
            }
            else
            {
                this.folderIdMappingSyncState = base.SyncStateStorage.GetCustomSyncState(syncStateInfo, new PropertyDefinition[0]);
                this.folderHierarchySyncState = base.SyncStateStorage.GetFolderHierarchySyncState();
                if (this.folderHierarchySyncState == null || this.folderIdMappingSyncState == null || this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoHierarchyState");
                    throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                }
                FolderIdMapping   folderIdMapping = (FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping];
                StoreObjectId     defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);
                MailboxSyncItemId mailboxId       = MailboxSyncItemId.CreateForNewItem(defaultFolderId);
                if (!folderIdMapping.Contains(mailboxId))
                {
                    base.SyncStateStorage.DeleteAllSyncStates();
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InboxStoreObjectIdChanged");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateCorrupt, new LocalizedString("The sync state is corrupt.  It is most likely due to a recent mailbox migration."), false);
                }
            }
            if (this.folderHierarchySyncState.CustomVersion != null && this.folderHierarchySyncState.CustomVersion.Value > 5)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SyncStateVersionMismatch");
                throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.SyncStateVersionInvalid, EASServerStrings.MismatchSyncStateError, true);
            }
        }
 // Token: 0x06000886 RID: 2182 RVA: 0x00032504 File Offset: 0x00030704
 internal override Command.ExecutionState ExecuteCommand()
 {
     try
     {
         FolderCommand.FolderRequest folderRequest = this.ParseRequest();
         XmlDocument xmlDocument = new SafeXmlDocument();
         XmlNode     newChild    = xmlDocument.CreateElement(base.XmlRequest.LocalName, base.XmlRequest.NamespaceURI);
         xmlDocument.AppendChild(newChild);
         try
         {
             base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.ClientSyncKey, folderRequest.SyncKey);
             this.LoadSyncState(folderRequest.SyncKey);
             this.ConvertSyncIdsToXsoIds(folderRequest);
             this.folderHierarchySync = this.folderHierarchySyncState.GetFolderHierarchySync(new ChangeTrackingDelegate(FolderCommand.ComputeChangeTrackingHash));
             if (folderRequest.SyncKey != 0)
             {
                 if (!this.folderHierarchySyncState.Contains(CustomStateDatumType.SyncKey))
                 {
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "I");
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "RecoveryNotAllowed");
                     throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                 }
                 int data  = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.SyncKey, -1);
                 int data2 = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.RecoverySyncKey, -1);
                 if (folderRequest.SyncKey != data && (!this.allowRecovery || folderRequest.SyncKey != data2))
                 {
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "I");
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidSyncKey");
                     throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), null, false);
                 }
                 FolderIdMapping folderIdMapping = (FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping];
                 if (folderRequest.SyncKey == data)
                 {
                     AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Committing folderIdMapping.");
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "S");
                     folderIdMapping.CommitChanges();
                     this.folderHierarchySync.AcknowledgeServerOperations();
                 }
                 else
                 {
                     AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Clearing changes on folderIdMapping.");
                     base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "R");
                     folderIdMapping.ClearChanges();
                     this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree] = this.folderIdMappingSyncState[CustomStateDatumType.RecoveryFullFolderTree];
                 }
             }
             else
             {
                 base.ProtocolLogger.SetValue("F", PerFolderProtocolLoggerData.SyncType, "F");
                 base.SendServerUpgradeHeader = true;
             }
             this.ProcessCommand(folderRequest, xmlDocument);
             if (this.folderHierarchySyncState != null)
             {
                 int data3 = this.folderHierarchySyncState.GetData <Int32Data, int>(CustomStateDatumType.AirSyncProtocolVersion, -1);
                 if (base.Version > data3)
                 {
                     AirSyncDiagnostics.TraceDebug <int, int>(ExTraceGlobals.RequestsTracer, this, "Changing sync state protocol version from {0} to {1}.", data3, base.Version);
                     this.folderHierarchySyncState[CustomStateDatumType.AirSyncProtocolVersion] = new Int32Data(base.Version);
                     this.syncStateChanged = true;
                 }
             }
             if (this.syncStateChanged)
             {
                 if (this.folderHierarchySyncState != null)
                 {
                     this.folderHierarchySyncState.CustomVersion = new int?(5);
                     this.folderHierarchySyncState.Commit();
                 }
                 if (this.folderIdMappingSyncState != null)
                 {
                     FolderIdMapping folderIdMapping2 = this.folderIdMappingSyncState[CustomStateDatumType.IdMapping] as FolderIdMapping;
                     FolderTree      folderTree       = this.folderIdMappingSyncState[CustomStateDatumType.FullFolderTree] as FolderTree;
                     if (folderIdMapping2.IsDirty || folderTree.IsDirty)
                     {
                         this.folderIdMappingSyncState.Commit();
                     }
                 }
             }
         }
         finally
         {
             if (this.folderIdMappingSyncState != null)
             {
                 this.folderIdMappingSyncState.Dispose();
             }
             if (this.folderHierarchySyncState != null)
             {
                 this.folderHierarchySyncState.Dispose();
             }
         }
         base.XmlResponse = xmlDocument;
     }
     catch (ObjectNotFoundException innerException)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FolderNotFound");
         throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, this.ConstructErrorXml(StatusCode.Sync_ProtocolError), innerException, false);
     }
     catch (CorruptDataException ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CorruptData");
         AirSyncDiagnostics.TraceDebug <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "Corrupted data found, replacing error with wrongsynckey error to force client to refresh.\r\n{0}", arg);
         throw new AirSyncPermanentException(StatusCode.Sync_OutOfDisk, this.ConstructErrorXml(StatusCode.Sync_OutOfDisk), ex, false);
     }
     catch (QuotaExceededException)
     {
         throw;
     }
     catch (StoragePermanentException ex2)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, ex2.GetType().ToString());
         throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, this.ConstructErrorXml(StatusCode.Sync_ClientServerConversion), ex2, false);
     }
     catch (ArgumentException innerException2)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ArgumentException");
         throw new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, this.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException2, false);
     }
     catch (FormatException innerException3)
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FormatException");
         throw new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, this.ConstructErrorXml(StatusCode.Sync_NotificationGUID), innerException3, false);
     }
     return(Command.ExecutionState.Complete);
 }
        // Token: 0x060008A6 RID: 2214 RVA: 0x00033214 File Offset: 0x00031414
        protected override void ProcessCommand(FolderCommand.FolderRequest folderRequest, XmlDocument doc)
        {
            bool    flag         = folderRequest.SyncKey == 0;
            string  namespaceURI = doc.DocumentElement.NamespaceURI;
            XmlNode xmlNode      = doc.CreateElement("Status", namespaceURI);

            doc.DocumentElement.AppendChild(xmlNode);
            xmlNode.InnerText = "1";
            base.DeviceSyncStateMetadata.RecordLatestFolderHierarchySnapshot(base.MailboxSession, base.Context);
            HierarchySyncOperations hierarchySyncOperations = base.FolderHierarchySync.EnumerateServerOperations(base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root), false);

            if (hierarchySyncOperations.Count > 0)
            {
                folderRequest.RecoverySyncKey = folderRequest.SyncKey;
                folderRequest.SyncKey         = base.GetNextNumber(folderRequest.SyncKey);
                base.FolderHierarchySyncState[CustomStateDatumType.SyncKey] = new Int32Data(folderRequest.SyncKey);
                if (folderRequest.RecoverySyncKey > 0)
                {
                    base.FolderHierarchySyncState[CustomStateDatumType.RecoverySyncKey]        = new Int32Data(folderRequest.RecoverySyncKey);
                    base.FolderIdMappingSyncState[CustomStateDatumType.RecoveryFullFolderTree] = base.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                }
                base.SyncStateChanged = true;
            }
            XmlNode xmlNode2 = doc.CreateElement("SyncKey", namespaceURI);

            doc.DocumentElement.AppendChild(xmlNode2);
            xmlNode2.InnerText = folderRequest.SyncKey.ToString(CultureInfo.InvariantCulture);
            Dictionary <ISyncItemId, XmlNode> dictionary = new Dictionary <ISyncItemId, XmlNode>(flag ? (hierarchySyncOperations.Count + FolderSyncCommand.virtualFolders.Length) : hierarchySyncOperations.Count);
            XmlNode xmlNode3 = doc.CreateElement("Changes", namespaceURI);

            doc.DocumentElement.AppendChild(xmlNode3);
            StoreObjectId         defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root);
            FolderIdMapping       folderIdMapping = (FolderIdMapping)base.FolderIdMappingSyncState[CustomStateDatumType.IdMapping];
            FolderTree            folderTree      = (FolderTree)base.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
            HashSet <ISyncItemId> hashSet         = new HashSet <ISyncItemId>();
            HashSet <ISyncItemId> hashSet2        = new HashSet <ISyncItemId>();
            bool flag2 = false;

            AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). changes.Count={0}", hierarchySyncOperations.Count);
            for (int i = 0; i < hierarchySyncOperations.Count; i++)
            {
                HierarchySyncOperation hierarchySyncOperation = hierarchySyncOperations[i];
                MailboxSyncItemId      mailboxSyncItemId      = MailboxSyncItemId.CreateForNewItem(hierarchySyncOperation.ItemId);
                MailboxSyncItemId      mailboxSyncItemId2     = MailboxSyncItemId.CreateForNewItem(hierarchySyncOperation.ParentId);
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). change# {0}. changeType{1}. Processing folder: {2} with parent {3}", new object[]
                {
                    i,
                    Enum.GetName(typeof(ChangeType), hierarchySyncOperation.ChangeType),
                    mailboxSyncItemId,
                    mailboxSyncItemId2
                });
                string parentShortId = null;
                bool   flag3         = false;
                switch (hierarchySyncOperation.ChangeType)
                {
                case ChangeType.Add:
                {
                    if (folderTree.AddFolder(mailboxSyncItemId))
                    {
                        AirSyncDiagnostics.TraceDebug <MailboxSyncItemId, MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Adding folder {0} with Parent {1} to Full Folder Tree.", mailboxSyncItemId, mailboxSyncItemId2);
                    }
                    folderTree.SetOwner(mailboxSyncItemId, hierarchySyncOperation.Owner);
                    folderTree.SetPermissions(mailboxSyncItemId, hierarchySyncOperation.Permissions);
                    if (!defaultFolderId.Equals(mailboxSyncItemId2.NativeId))
                    {
                        if (folderTree.AddFolder(mailboxSyncItemId2))
                        {
                            AirSyncDiagnostics.TraceDebug <MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Adding parent folder {0} to Full Folder Tree.", mailboxSyncItemId2);
                            hashSet2.Add(mailboxSyncItemId2);
                        }
                        folderTree.LinkChildToParent(mailboxSyncItemId2, mailboxSyncItemId, hashSet);
                        parentShortId = (folderIdMapping.Contains(mailboxSyncItemId2) ? folderIdMapping[mailboxSyncItemId2] : folderIdMapping.Add(mailboxSyncItemId2));
                        flag3         = folderTree.IsHidden(mailboxSyncItemId2);
                    }
                    bool sharedFolder = folderTree.IsSharedFolder(mailboxSyncItemId);
                    AirSyncUtility.GetAirSyncFolderType(base.MailboxSession, sharedFolder, hierarchySyncOperation.ItemId, hierarchySyncOperation.ClassName);
                    if (!this.IsFolderVisible(hierarchySyncOperation, flag3))
                    {
                        folderTree.SetHidden(mailboxSyncItemId, true, hashSet);
                        AirSyncDiagnostics.TraceDebug <MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Added folder {0} is set to hidden and will not be sent to client.", mailboxSyncItemId);
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug <MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Added folder {0} will be sent to client. Details next...", mailboxSyncItemId);
                        string text = folderIdMapping.Contains(mailboxSyncItemId) ? folderIdMapping[mailboxSyncItemId] : folderIdMapping.Add(mailboxSyncItemId);
                        dictionary[mailboxSyncItemId] = this.CreateChangeNode(doc, namespaceURI, hierarchySyncOperation.ChangeType, folderTree, mailboxSyncItemId, hierarchySyncOperation, text, parentShortId, ref flag2);
                        hashSet2.Add(mailboxSyncItemId);
                    }
                    break;
                }

                case ChangeType.Change:
                    if (!folderTree.Contains(mailboxSyncItemId))
                    {
                        AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "Could not find folder {0} with item ID {1} in the full folder tree, skipping...  FolderIdMappingSyncState backend version is {2} and current version is {3}.", new object[]
                        {
                            hierarchySyncOperation.DisplayName,
                            mailboxSyncItemId,
                            base.FolderIdMappingSyncState.BackendVersion,
                            base.FolderIdMappingSyncState.Version
                        });
                    }
                    else
                    {
                        if (!defaultFolderId.Equals(mailboxSyncItemId2.NativeId))
                        {
                            if (folderTree.AddFolder(mailboxSyncItemId2))
                            {
                                AirSyncDiagnostics.TraceDebug <MailboxSyncItemId, MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Changed folder {0} has new parent {1} to be sent to client.", mailboxSyncItemId, mailboxSyncItemId2);
                                hashSet2.Add(mailboxSyncItemId2);
                            }
                            flag3 = folderTree.IsHidden(mailboxSyncItemId2);
                            if (!flag3)
                            {
                                parentShortId = (folderIdMapping.Contains(mailboxSyncItemId2) ? folderIdMapping[mailboxSyncItemId2] : folderIdMapping.Add(mailboxSyncItemId2));
                            }
                        }
                        ISyncItemId parentId = folderTree.GetParentId(mailboxSyncItemId);
                        if (!mailboxSyncItemId2.Equals(parentId))
                        {
                            if (parentId != null)
                            {
                                folderTree.UnlinkChild(parentId, mailboxSyncItemId);
                                AirSyncDiagnostics.TraceDebug <MailboxSyncItemId, ISyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Removing changed folder {0} as child from old parent {1} in Full Folder Tree.", mailboxSyncItemId, parentId);
                            }
                            if (!defaultFolderId.Equals(mailboxSyncItemId2.NativeId))
                            {
                                folderTree.LinkChildToParent(mailboxSyncItemId2, mailboxSyncItemId, hashSet);
                                AirSyncDiagnostics.TraceDebug <MailboxSyncItemId, MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Adding changed folder {0} as child to new parent {1} in Full Folder Tree.", mailboxSyncItemId, mailboxSyncItemId2);
                            }
                            else
                            {
                                AirSyncDiagnostics.TraceDebug <MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Changed folder {0} now has no parent in Full Folder Tree.", mailboxSyncItemId);
                            }
                        }
                        folderTree.SetOwner(mailboxSyncItemId, hierarchySyncOperation.Owner);
                        folderTree.SetPermissions(mailboxSyncItemId, hierarchySyncOperation.Permissions);
                        bool sharedFolder = folderTree.IsSharedFolder(mailboxSyncItemId);
                        AirSyncUtility.GetAirSyncFolderType(base.MailboxSession, sharedFolder, hierarchySyncOperation.ItemId, hierarchySyncOperation.ClassName);
                        if (!this.IsFolderVisible(hierarchySyncOperation, flag3))
                        {
                            folderTree.SetHidden(mailboxSyncItemId, true, hashSet);
                            if (folderIdMapping.Contains(mailboxSyncItemId))
                            {
                                string text = folderIdMapping[mailboxSyncItemId];
                                folderIdMapping.Delete(new ISyncItemId[]
                                {
                                    mailboxSyncItemId
                                });
                                dictionary[mailboxSyncItemId] = this.CreateDeleteNode(doc, namespaceURI, text);
                                AirSyncDiagnostics.TraceDebug <MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Changed folder {0} is now hidden; deleting from client.", mailboxSyncItemId);
                            }
                        }
                        else
                        {
                            folderTree.SetHidden(mailboxSyncItemId, false, hashSet);
                            string text;
                            if (!folderIdMapping.Contains(mailboxSyncItemId))
                            {
                                text = folderIdMapping.Add(mailboxSyncItemId);
                                hierarchySyncOperation.ChangeType = ChangeType.Add;
                                AirSyncDiagnostics.TraceDebug <MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Changed folder {0} is now visible; adding to client.", mailboxSyncItemId);
                            }
                            else
                            {
                                text = folderIdMapping[mailboxSyncItemId];
                                AirSyncDiagnostics.TraceDebug <MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Changed folder {0} is being sent to client.", mailboxSyncItemId);
                            }
                            dictionary[mailboxSyncItemId] = this.CreateChangeNode(doc, namespaceURI, hierarchySyncOperation.ChangeType, folderTree, mailboxSyncItemId, hierarchySyncOperation, text, parentShortId, ref flag2);
                        }
                    }
                    break;

                case ChangeType.Delete:
                    if (folderTree.Contains(mailboxSyncItemId))
                    {
                        if (folderIdMapping.Contains(mailboxSyncItemId))
                        {
                            string text = folderIdMapping[mailboxSyncItemId];
                            dictionary[mailboxSyncItemId] = this.CreateDeleteNode(doc, namespaceURI, text);
                            AirSyncDiagnostics.TraceDebug <MailboxSyncItemId, string>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Deleted folder {0} with Short Id {1} is being sent to client.", mailboxSyncItemId, text);
                        }
                        folderTree.RemoveFolderAndChildren(mailboxSyncItemId, folderIdMapping);
                        AirSyncDiagnostics.TraceDebug <MailboxSyncItemId>(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Deleted folder {0} and children are being removed from Full Folder Tree.", mailboxSyncItemId);
                    }
                    break;
                }
            }
            if (flag)
            {
                this.AddVirtualFolders(doc, namespaceURI, dictionary);
            }
            using (HashSet <ISyncItemId> .Enumerator enumerator = hashSet.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ISyncItemId itemId = enumerator.Current;
                    if (folderTree.IsHidden(itemId))
                    {
                        dictionary.Remove(itemId);
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncCommand.ProcessCommand(). Removing hidden folder {0} from list of changes being sent to client.", new object[]
                        {
                            itemId.NativeId
                        });
                        if (folderIdMapping.Contains(itemId))
                        {
                            if (!hashSet2.Contains(itemId))
                            {
                                dictionary[itemId] = this.CreateDeleteNode(doc, namespaceURI, folderIdMapping[itemId]);
                            }
                            folderIdMapping.Delete(new ISyncItemId[]
                            {
                                itemId
                            });
                        }
                    }
                    else if (!dictionary.ContainsKey(itemId))
                    {
                        HierarchySyncOperation hierarchySyncOperation2 = (from change in hierarchySyncOperations
                                                                          where change.ItemId == (StoreObjectId)itemId.NativeId
                                                                          select change).First <HierarchySyncOperation>();
                        string parentShortId2 = folderIdMapping[folderTree.GetParentId(itemId)];
                        if (folderIdMapping.Contains(itemId))
                        {
                            flag2 = true;
                            AirSyncDiagnostics.TraceError <string, object>(ExTraceGlobals.RequestsTracer, this, "Hidden folder {0} with item ID {1} is in folderIdMapping table.", hierarchySyncOperation2.DisplayName, itemId.NativeId);
                        }
                        else
                        {
                            string shortId = folderIdMapping.Add(itemId);
                            dictionary[itemId] = this.CreateChangeNode(doc, namespaceURI, ChangeType.Add, folderTree, itemId, hierarchySyncOperation2, shortId, parentShortId2, ref flag2);
                        }
                    }
                }
            }
            XmlNode xmlNode4 = doc.CreateElement("Count", namespaceURI);

            xmlNode4.InnerText = dictionary.Count.ToString(CultureInfo.InvariantCulture);
            xmlNode3.AppendChild(xmlNode4);
            foreach (XmlNode newChild in dictionary.Values)
            {
                xmlNode3.AppendChild(newChild);
            }
            if (flag2)
            {
                Exception exception = new InvalidOperationException("FolderSyncCommand.ProcessCommand found errors.  See traces above.");
                if (GlobalSettings.SendWatsonReport)
                {
                    AirSyncDiagnostics.SendWatson(exception, false);
                }
            }
        }
 // Token: 0x060006CE RID: 1742 RVA: 0x00025F84 File Offset: 0x00024184
 private void FillFidMapping(GetSyncStateResult results, MailboxSession session)
 {
     foreach (DeviceData deviceData in results.Devices)
     {
         foreach (SyncStateFolderData syncStateFolderData in deviceData.SyncFolders)
         {
             if (syncStateFolderData != null && !string.IsNullOrEmpty(syncStateFolderData.SyncStateBlob))
             {
                 syncStateFolderData.FolderMapping = new List <FolderMappingData>();
                 using (PooledMemoryStream pooledMemoryStream = new PooledMemoryStream(102400))
                 {
                     byte[] array = Convert.FromBase64String(syncStateFolderData.SyncStateBlob);
                     pooledMemoryStream.Write(array, 0, array.Length);
                     pooledMemoryStream.Flush();
                     pooledMemoryStream.Position = 0L;
                     int  num;
                     int  num2;
                     long num3;
                     long num4;
                     Dictionary <string, bool> dictionary;
                     GenericDictionaryData <ConstStringData, string, DerivedData <ICustomSerializableBuilder> > genericDictionaryData = SyncState.InternalDeserializeData(pooledMemoryStream, out num, out num2, out num3, out num4, out dictionary);
                     FolderIdMapping       folderIdMapping    = genericDictionaryData.Data["IdMapping"].Data as FolderIdMapping;
                     IDictionaryEnumerator syncIdIdEnumerator = folderIdMapping.SyncIdIdEnumerator;
                     while (syncIdIdEnumerator.MoveNext())
                     {
                         string        shortId       = syncIdIdEnumerator.Key as string;
                         ISyncItemId   syncItemId    = syncIdIdEnumerator.Value as ISyncItemId;
                         StoreObjectId storeObjectId = syncItemId.NativeId as StoreObjectId;
                         try
                         {
                             using (Folder folder = Folder.Bind(session, storeObjectId, new PropertyDefinition[]
                             {
                                 FolderSchema.DisplayName
                             }))
                             {
                                 DefaultFolderType defaultFolderType = session.IsDefaultFolderType(folder.Id);
                                 syncStateFolderData.FolderMapping.Add(new FolderMappingData
                                 {
                                     ShortId           = shortId,
                                     LongId            = storeObjectId.ToString(),
                                     Name              = folder.DisplayName,
                                     DefaultFolderType = defaultFolderType.ToString(),
                                     Exception         = null
                                 });
                             }
                         }
                         catch (Exception ex)
                         {
                             syncStateFolderData.FolderMapping.Add(new FolderMappingData
                             {
                                 ShortId           = shortId,
                                 LongId            = "[Error]",
                                 Name              = "[Error]",
                                 DefaultFolderType = "[Error]",
                                 Exception         = ex.ToString()
                             });
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #12
0
        public void ParseQueryNode(XmlElement queryNode)
        {
            this.searchCriteriaBuilder = new MailboxSearchCriteriaBuilder(this.context.Request.Culture);
            if (!this.mailboxSession.Mailbox.IsContentIndexingEnabled)
            {
                AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_ContentIndexingNotEnabled, "ContentIndexingNotEnabled", new string[]
                {
                    this.mailboxSession.MailboxOwner.MailboxInfo.Location.ServerFqdn
                });
            }
            this.queryFilter = this.searchCriteriaBuilder.ParseTopLevelClassAndFolders(queryNode, this.mailboxSession.Mailbox.IsContentIndexingEnabled, this.versionFactory, this.context);
            this.schemaCache = this.searchCriteriaBuilder.SchemaCache;
            if (this.FolderIdMappingSyncState == null || !this.FolderIdMappingSyncState.Contains(CustomStateDatumType.FullFolderTree))
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.AlgorithmTracer, this, "FolderIdMappingSyncState error: {0}", (this.FolderIdMappingSyncState != null) ? "no FullFolderTree" : "FolderIdMappingSyncState is null");
                throw new SearchNeedToFolderSyncException();
            }
            List <string>   list            = this.searchCriteriaBuilder.FolderScope;
            FolderIdMapping folderIdMapping = (FolderIdMapping)this.FolderIdMappingSyncState[CustomStateDatumType.IdMapping];
            FolderTree      folderTree      = (FolderTree)this.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];

            if (list.Count == 0)
            {
                this.folderScope = new StoreId[]
                {
                    this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Root)
                };
            }
            else
            {
                int num = 0;
                this.folderScope = new StoreId[list.Count];
                foreach (string text in list)
                {
                    StoreObjectId storeObjectId = null;
                    if (text == "0")
                    {
                        storeObjectId = this.mailboxSession.GetDefaultFolderId(DefaultFolderType.Root);
                    }
                    else
                    {
                        SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(text);
                        if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
                        {
                            throw new AirSyncPermanentException(StatusCode.InvalidCombinationOfIDs, false)
                                  {
                                      ErrorStringForProtocolLogger = "BadIdComboInMbxSearch"
                                  };
                        }
                        MailboxSyncItemId mailboxSyncItemId = folderIdMapping[text] as MailboxSyncItemId;
                        if (mailboxSyncItemId != null)
                        {
                            if (folderTree.IsSharedFolder(mailboxSyncItemId))
                            {
                                throw new AirSyncPermanentException(StatusCode.Sync_InvalidParameters, false)
                                      {
                                          ErrorStringForProtocolLogger = "AccessDeniedInMbxSearch"
                                      };
                            }
                            storeObjectId = (StoreObjectId)mailboxSyncItemId.NativeId;
                        }
                    }
                    if (storeObjectId == null)
                    {
                        throw new SearchNeedToFolderSyncException();
                    }
                    try
                    {
                        using (Folder.Bind(this.mailboxSession, storeObjectId))
                        {
                        }
                    }
                    catch (ObjectNotFoundException)
                    {
                        throw new SearchNeedToFolderSyncException();
                    }
                    this.folderScope[num++] = storeObjectId;
                }
            }
            foreach (object obj in folderTree)
            {
                ISyncItemId       syncItemId         = (ISyncItemId)obj;
                MailboxSyncItemId mailboxSyncItemId2 = syncItemId as MailboxSyncItemId;
                if (mailboxSyncItemId2 != null && (folderTree.IsHidden(syncItemId) || folderTree.IsSharedFolder(syncItemId)))
                {
                    this.searchCriteriaBuilder.ExcludedFolders.Add((StoreObjectId)mailboxSyncItemId2.NativeId);
                }
            }
            if (this.mailboxSchemaOptions.HasBodyPartPreferences)
            {
                if (this.searchCriteriaBuilder.Conversation == null)
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.AlgorithmTracer, this, "<BodyPartPreference> is only supported when search for ConversationId");
                    throw new AirSyncPermanentException(StatusCode.Sync_ObjectNotFound, false)
                          {
                              ErrorStringForProtocolLogger = "BodyPartNotSupported"
                          };
                }
                this.searchCriteriaBuilder.Conversation.LoadBodySummaries();
            }
        }
Beispiel #13
0
 public void RemoveFolderAndChildren(ISyncItemId folderId, FolderIdMapping folderIdMapping)
 {
     this.RemoveFolderAndChildren(folderId, folderIdMapping, 0, this.folderTree.Keys.Count);
 }