Ejemplo 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: 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: 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);
        }
Ejemplo n.º 4
0
        private StoreObjectId GetStoreObjectId(string folderId)
        {
            SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(folderId);
            if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
            {
                throw new AirSyncPermanentException(StatusCode.InvalidCombinationOfIDs, false)
                      {
                          ErrorStringForProtocolLogger = "BadIdComboInConversationMove"
                      };
            }
            if (this.folderIdMapping == null)
            {
                using (CustomSyncState customSyncState = this.syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]))
                {
                    if (customSyncState == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoSyncStateInConversationMove"
                              };
                    }
                    if (customSyncState[CustomStateDatumType.IdMapping] == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoIdMappingInConversationMove"
                              };
                    }
                    this.folderIdMapping = (FolderIdMapping)customSyncState[CustomStateDatumType.IdMapping];
                    this.fullFolderTree  = (FolderTree)customSyncState[CustomStateDatumType.FullFolderTree];
                }
            }
            ISyncItemId syncItemId = this.folderIdMapping[folderId];

            if (syncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "NoFldrIdInMappingInConversationMove"
                      };
            }
            MailboxSyncItemId mailboxSyncItemId = syncItemId as MailboxSyncItemId;

            if (mailboxSyncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.InvalidIDs, false)
                      {
                          ErrorStringForProtocolLogger = "BadIdInConversationMove"
                      };
            }
            if (this.fullFolderTree.IsSharedFolder(mailboxSyncItemId) || this.fullFolderTree.GetPermissions(mailboxSyncItemId) != SyncPermissions.FullAccess)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_Retry, false)
                      {
                          ErrorStringForProtocolLogger = "DeniedInConversationMove"
                      };
            }
            return((StoreObjectId)mailboxSyncItemId.NativeId);
        }
 // Token: 0x06000D02 RID: 3330 RVA: 0x0004676C File Offset: 0x0004496C
 private void ParseXmlRequest()
 {
     if (base.XmlRequest.Name != "MoveItems")
     {
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidParentTag");
         throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidXML, null, false);
     }
     using (XmlNodeList elementsByTagName = base.XmlRequest.GetElementsByTagName("Move", "Move:"))
     {
         if (elementsByTagName.Count < 1 || elementsByTagName.Count >= GlobalSettings.MaxNoOfItemsMove)
         {
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, (elementsByTagName.Count < 1) ? "NoMoveTags" : "MITooManyOperations");
             throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidXML, null, false);
         }
         foreach (object obj in elementsByTagName)
         {
             XmlNode xmlNode = (XmlNode)obj;
             string  text    = null;
             string  text2   = null;
             string  text3   = null;
             try
             {
                 text  = xmlNode["SrcMsgId", "Move:"].InnerText;
                 text2 = xmlNode["SrcFldId", "Move:"].InnerText;
                 text3 = xmlNode["DstFldId", "Move:"].InnerText;
             }
             catch (NullReferenceException innerException)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MessageOrFolderIdNotSpecified");
                 throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.InvalidXML, innerException, false);
             }
             if ((AirSyncUtility.GetCollectionType(text2) != SyncCollection.CollectionTypes.Mailbox && AirSyncUtility.GetCollectionType(text2) != SyncCollection.CollectionTypes.Unknown) || (AirSyncUtility.GetCollectionType(text3) != SyncCollection.CollectionTypes.Mailbox && AirSyncUtility.GetCollectionType(text3) != SyncCollection.CollectionTypes.Unknown))
             {
                 this.AppendItemXmlNode(text, 105.ToString(CultureInfo.InvariantCulture), text3);
             }
             else
             {
                 StoreObjectId     xsoItemId          = this.GetXsoItemId(text2, text);
                 MailboxSyncItemId mailboxSyncItemId  = this.FolderIdMapping[text2] as MailboxSyncItemId;
                 MailboxSyncItemId mailboxSyncItemId2 = this.FolderIdMapping[text3] as MailboxSyncItemId;
                 StoreObjectId     srcFldId           = (mailboxSyncItemId == null) ? null : ((StoreObjectId)mailboxSyncItemId.NativeId);
                 StoreObjectId     dstFldId           = (mailboxSyncItemId2 == null) ? null : ((StoreObjectId)mailboxSyncItemId2.NativeId);
                 if (mailboxSyncItemId != null && (!this.FullFolderTree.Contains(mailboxSyncItemId) || this.FullFolderTree.GetPermissions(mailboxSyncItemId) != SyncPermissions.FullAccess || this.FullFolderTree.IsSharedFolder(mailboxSyncItemId)))
                 {
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MoveFromNonFullAccessFolder");
                     throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.Success, null, false);
                 }
                 if (mailboxSyncItemId2 != null && (!this.FullFolderTree.Contains(mailboxSyncItemId2) || this.FullFolderTree.GetPermissions(mailboxSyncItemId2) != SyncPermissions.FullAccess || this.FullFolderTree.IsSharedFolder(mailboxSyncItemId2)))
                 {
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MoveToNonFullAccessFolder");
                     throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.Sync_ProtocolVersionMismatch, null, false);
                 }
                 this.ValidateItem(text, xsoItemId, srcFldId, dstFldId);
             }
         }
     }
 }
Ejemplo n.º 6
0
 public override ISyncItemId CreateISyncItemIdForNewItem(StoreObjectId itemId)
 {
     base.CheckDisposed("CreateISyncItemIdForNewItem");
     if (itemId == null)
     {
         throw new ArgumentNullException("itemId");
     }
     return(MailboxSyncItemId.CreateForNewItem(itemId));
 }
Ejemplo n.º 7
0
        public static void BuildFolderTree(MailboxSession mailboxSession, SyncState syncState)
        {
            StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Root);

            SharingSubscriptionData[] array = null;
            using (SharingSubscriptionManager sharingSubscriptionManager = new SharingSubscriptionManager(mailboxSession))
            {
                array = sharingSubscriptionManager.GetAll();
            }
            using (Folder folder = Folder.Bind(mailboxSession, defaultFolderId))
            {
                FolderTree folderTree;
                using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, FolderTree.fetchProperties))
                {
                    folderTree = new FolderTree();
                    object[][] rows;
                    do
                    {
                        rows = queryResult.GetRows(10000);
                        for (int i = 0; i < rows.Length; i++)
                        {
                            MailboxSyncItemId mailboxSyncItemId  = MailboxSyncItemId.CreateForNewItem(((VersionedId)rows[i][0]).ObjectId);
                            MailboxSyncItemId mailboxSyncItemId2 = MailboxSyncItemId.CreateForNewItem((StoreObjectId)rows[i][1]);
                            folderTree.AddFolder(mailboxSyncItemId);
                            object obj = rows[i][3];
                            int    num = (obj is PropertyError) ? 0 : ((int)obj);
                            if ((num & 1073741824) != 0)
                            {
                                for (int j = 0; j < array.Length; j++)
                                {
                                    if (array[j].LocalFolderId.Equals(mailboxSyncItemId.NativeId))
                                    {
                                        folderTree.SetPermissions(mailboxSyncItemId, SyncPermissions.Readonly);
                                        folderTree.SetOwner(mailboxSyncItemId, array[j].SharerIdentity);
                                        break;
                                    }
                                }
                            }
                            if (!defaultFolderId.Equals(mailboxSyncItemId2.NativeId))
                            {
                                folderTree.AddFolder(mailboxSyncItemId2);
                                folderTree.LinkChildToParent(mailboxSyncItemId2, mailboxSyncItemId);
                            }
                            if ((bool)rows[i][2])
                            {
                                folderTree.SetHidden(mailboxSyncItemId, true);
                            }
                        }
                    }while (rows.Length != 0);
                }
                syncState[CustomStateDatumType.FullFolderTree]         = folderTree;
                syncState[CustomStateDatumType.RecoveryFullFolderTree] = syncState[CustomStateDatumType.FullFolderTree];
            }
        }
Ejemplo n.º 8
0
        // 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);
            }
        }
Ejemplo n.º 9
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: 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);
        }
Ejemplo n.º 11
0
        // Token: 0x06000884 RID: 2180 RVA: 0x000323A8 File Offset: 0x000305A8
        public static bool FolderSyncRequired(SyncStateStorage syncStateStorage, HierarchySyncOperations folderHierarchyChanges, SyncState folderIdMappingSyncState = null)
        {
            bool flag = folderIdMappingSyncState == null;

            try
            {
                if (folderIdMappingSyncState == null)
                {
                    folderIdMappingSyncState = syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]);
                    if (folderIdMappingSyncState == null)
                    {
                        return(true);
                    }
                }
                FolderTree folderTree = (FolderTree)folderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                if (folderTree == null)
                {
                    return(true);
                }
                for (int i = 0; i < folderHierarchyChanges.Count; i++)
                {
                    HierarchySyncOperation hierarchySyncOperation = folderHierarchyChanges[i];
                    MailboxSyncItemId      folderId  = MailboxSyncItemId.CreateForNewItem(hierarchySyncOperation.ItemId);
                    MailboxSyncItemId      folderId2 = MailboxSyncItemId.CreateForNewItem(hierarchySyncOperation.ParentId);
                    if (!folderTree.Contains(folderId2))
                    {
                        return(true);
                    }
                    if (!folderTree.Contains(folderId))
                    {
                        if (!folderTree.IsHidden(folderId2))
                        {
                            return(true);
                        }
                    }
                    else if (!folderTree.IsHidden(folderId) || (folderTree.IsHiddenDueToParent(folderId) && !folderTree.IsHidden(folderId2)))
                    {
                        return(true);
                    }
                }
            }
            finally
            {
                if (flag && folderIdMappingSyncState != null)
                {
                    folderIdMappingSyncState.Dispose();
                }
            }
            return(false);
        }
Ejemplo n.º 12
0
        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;
        }
        // Token: 0x06000763 RID: 1891 RVA: 0x000291AC File Offset: 0x000273AC
        private StoreObjectId GetStoreObjectId(string folderId)
        {
            if (this.folderIdMapping == null)
            {
                using (CustomSyncState customSyncState = this.syncStateStorage.GetCustomSyncState(new FolderIdMappingSyncStateInfo(), new PropertyDefinition[0]))
                {
                    if (customSyncState == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoSyncStateInEmptyFolder"
                              };
                    }
                    if (customSyncState[CustomStateDatumType.IdMapping] == null)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                              {
                                  ErrorStringForProtocolLogger = "NoIdMappingInEmptyFolder"
                              };
                    }
                    this.folderIdMapping = (FolderIdMapping)customSyncState[CustomStateDatumType.IdMapping];
                }
            }
            SyncCollection.CollectionTypes collectionType = AirSyncUtility.GetCollectionType(folderId);
            if (collectionType != SyncCollection.CollectionTypes.Mailbox && collectionType != SyncCollection.CollectionTypes.Unknown)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_Retry, false)
                      {
                          ErrorStringForProtocolLogger = "SpecialFolderInEmptyFolder"
                      };
            }
            MailboxSyncItemId mailboxSyncItemId = this.folderIdMapping[folderId] as MailboxSyncItemId;

            if (mailboxSyncItemId == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "NoIdMappingInEmptyFolder2"
                      };
            }
            return((StoreObjectId)mailboxSyncItemId.NativeId);
        }
Ejemplo n.º 14
0
        // Token: 0x0600088B RID: 2187 RVA: 0x00032D38 File Offset: 0x00030F38
        protected StoreObjectId GetXsoFolderId(string syncFolderId, out SyncPermissions permissions)
        {
            StoreObjectId result = null;

            permissions = SyncPermissions.FullAccess;
            if (syncFolderId == "0")
            {
                result = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root);
            }
            else
            {
                MailboxSyncItemId mailboxSyncItemId = ((FolderIdMapping)this.folderIdMappingSyncState[CustomStateDatumType.IdMapping])[syncFolderId] as MailboxSyncItemId;
                if (mailboxSyncItemId != null)
                {
                    FolderTree folderTree = (FolderTree)this.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                    result      = (StoreObjectId)mailboxSyncItemId.NativeId;
                    permissions = folderTree.GetPermissions(mailboxSyncItemId);
                }
            }
            return(result);
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        // Token: 0x06000498 RID: 1176 RVA: 0x0001C590 File Offset: 0x0001A790
        private void ParseRequest(MailboxSession mailboxSession)
        {
            this.collectionRequest = default(CollectionCommand.CollectionRequestStruct);
            string collectionId = this.CollectionId;

            if (collectionId != null)
            {
                MailboxSyncItemId mailboxSyncItemId = ((FolderIdMapping)this.syncState[CustomStateDatumType.IdMapping])[collectionId] as MailboxSyncItemId;
                if (mailboxSyncItemId == null)
                {
                    throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, CollectionCommand.ConstructErrorXml(StatusCode.Sync_ProtocolError), null, false)
                          {
                              ErrorStringForProtocolLogger = "FolderNotFound2"
                          };
                }
                this.collectionRequest.CollectionId = (StoreObjectId)mailboxSyncItemId.NativeId;
                AirSyncDiagnostics.TraceDebug <string, StoreObjectId>(ExTraceGlobals.RequestsTracer, this, "Received request with syncCollectionId {0}, which maps to collection Id {1}.", collectionId, this.collectionRequest.CollectionId);
            }
            string parentId = this.ParentId;

            if (parentId == "0")
            {
                this.collectionRequest.ParentId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Root);
            }
            else if (parentId != null)
            {
                MailboxSyncItemId mailboxSyncItemId2 = ((FolderIdMapping)this.syncState[CustomStateDatumType.IdMapping])[parentId] as MailboxSyncItemId;
                if (mailboxSyncItemId2 == null)
                {
                    throw new AirSyncPermanentException(StatusCode.Sync_ServerError, CollectionCommand.ConstructErrorXml(StatusCode.Sync_ServerError), null, false)
                          {
                              ErrorStringForProtocolLogger = "NoIdMappingForParentId"
                          };
                }
                this.collectionRequest.ParentId = (StoreObjectId)mailboxSyncItemId2.NativeId;
                AirSyncDiagnostics.TraceDebug <string, StoreObjectId>(ExTraceGlobals.RequestsTracer, this, "Received request with syncParentId {0}, which maps to parent Id {1}.", parentId, this.collectionRequest.ParentId);
            }
            this.collectionRequest.CollectionName = this.CollectionName;
        }
Ejemplo n.º 17
0
 // Token: 0x0600184E RID: 6222 RVA: 0x0008E9FC File Offset: 0x0008CBFC
 private void UpdateFilter(Dictionary <StoreObjectId, string> mapping, DateTimeCustomSyncFilter dateTimeFilter, Dictionary <string, CommonNode> items)
 {
     foreach (StoreObjectId storeObjectId in mapping.Keys)
     {
         string      key        = mapping[storeObjectId];
         CommonNode  commonNode = items[key];
         ISyncItemId syncItemId = MailboxSyncItemId.CreateForNewItem(storeObjectId);
         if (commonNode.IsCalendar)
         {
             dateTimeFilter.UpdateFilterStateWithAddOrChange(syncItemId, true, true, commonNode.EndTime);
         }
         ChangeTrackingNode[] array;
         if (commonNode.IsEmail)
         {
             array = new ChangeTrackingNode[]
             {
                 ChangeTrackingNode.AllOtherNodes,
                 new ChangeTrackingNode("Email", "Read")
             };
         }
         else
         {
             array = new ChangeTrackingNode[]
             {
                 ChangeTrackingNode.AllNodes
             };
         }
         GenericDictionaryData <DerivedData <ISyncItemId>, ISyncItemId, FolderSync.ClientStateInformation> genericDictionaryData = (GenericDictionaryData <DerivedData <ISyncItemId>, ISyncItemId, FolderSync.ClientStateInformation>) this.syncState[SyncStateProp.ClientState];
         if (!genericDictionaryData.Data.ContainsKey(syncItemId))
         {
             genericDictionaryData.Data[syncItemId] = new FolderSync.ClientStateInformation();
         }
         FolderSync.ClientStateInformation clientStateInformation = genericDictionaryData.Data[syncItemId];
         clientStateInformation.ChangeTrackingInformation = new int?[array.Length];
         clientStateInformation.ClientHasItem             = true;
     }
 }
        // 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);
        }
Ejemplo n.º 19
0
        // Token: 0x060008E7 RID: 2279 RVA: 0x00035378 File Offset: 0x00033578
        public virtual void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool)
        {
            if (componentDataPool.ExternalVersion < 1)
            {
                GenericDictionaryData <StringData, string, StoreObjectIdData, StoreObjectId> genericDictionaryData = new GenericDictionaryData <StringData, string, StoreObjectIdData, StoreObjectId>();
                genericDictionaryData.DeserializeData(reader, componentDataPool);
                Dictionary <string, StoreObjectId> data = genericDictionaryData.Data;
                this.syncIdToMailboxIdTable = new Dictionary <string, ISyncItemId>(data.Count);
                using (Dictionary <string, StoreObjectId> .Enumerator enumerator = data.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        KeyValuePair <string, StoreObjectId> keyValuePair = enumerator.Current;
                        this.syncIdToMailboxIdTable[keyValuePair.Key] = MailboxSyncItemId.CreateForNewItem(keyValuePair.Value);
                    }
                    goto IL_92;
                }
            }
            GenericDictionaryData <StringData, string, DerivedData <ISyncItemId>, ISyncItemId> genericDictionaryData2 = new GenericDictionaryData <StringData, string, DerivedData <ISyncItemId>, ISyncItemId>();

            genericDictionaryData2.DeserializeData(reader, componentDataPool);
            this.syncIdToMailboxIdTable = genericDictionaryData2.Data;
IL_92:
            this.mailboxIdToSyncIdTable = new Dictionary <ISyncItemId, string>(this.syncIdToMailboxIdTable.Count);
            foreach (KeyValuePair <string, ISyncItemId> keyValuePair2 in this.syncIdToMailboxIdTable)
            {
                this.mailboxIdToSyncIdTable.Add(keyValuePair2.Value, keyValuePair2.Key);
            }
            GenericListData <StringData, string> genericListData = new GenericListData <StringData, string>();

            genericListData.DeserializeData(reader, componentDataPool);
            this.deletedItems = genericListData.Data;
            genericListData.DeserializeData(reader, componentDataPool);
            this.addedItems    = genericListData.Data;
            this.uniqueCounter = reader.ReadInt64();
        }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
 // Token: 0x060004C8 RID: 1224 RVA: 0x0001D6DC File Offset: 0x0001B8DC
 protected override void ProcessCommand(MailboxSession mailboxSession, XmlDocument doc)
 {
     if (base.CollectionRequest.CollectionName == null || base.CollectionRequest.ParentId == null)
     {
         base.Context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidURLParameters");
         throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
     }
     AirSyncDiagnostics.TraceDebug <string, StoreObjectId>(ExTraceGlobals.RequestsTracer, this, "Creating collection with name {0} and parent Id {1}.", base.CollectionRequest.CollectionName, base.CollectionRequest.ParentId);
     using (Folder folder = Folder.Create(mailboxSession, base.CollectionRequest.ParentId, StoreObjectType.Folder))
     {
         folder.DisplayName = base.CollectionRequest.CollectionName;
         folder.ClassName   = "IPF.Note";
         folder.Save();
         XmlNode xmlNode  = doc.CreateElement("Response", "FolderHierarchy:");
         XmlNode xmlNode2 = doc.CreateElement("Status", "FolderHierarchy:");
         XmlNode xmlNode3 = doc.CreateElement("Folder", "FolderHierarchy:");
         XmlNode xmlNode4 = doc.CreateElement("ServerId", "FolderHierarchy:");
         xmlNode2.InnerText = "1";
         folder.Load();
         xmlNode4.InnerText = ((FolderIdMapping)base.SyncState[CustomStateDatumType.IdMapping]).Add(MailboxSyncItemId.CreateForNewItem(folder.Id.ObjectId));
         doc.AppendChild(xmlNode);
         xmlNode.AppendChild(xmlNode2);
         xmlNode.AppendChild(xmlNode3);
         xmlNode3.AppendChild(xmlNode4);
     }
 }
 // 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);
         }
     }
 }
Ejemplo n.º 23
0
        // Token: 0x06000CEA RID: 3306 RVA: 0x00045C70 File Offset: 0x00043E70
        private bool LegacyRespond(StoreObjectId itemId, string requestId, string userResponse, bool usingLongId)
        {
            MeetingRequest   meetingRequest   = null;
            CalendarItemBase calendarItemBase = null;
            StoreObjectId    storeObjectId    = null;
            StoreObjectId    storeObjectId2   = null;
            Item             item             = null;

            try
            {
                base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRItems);
                try
                {
                    item = Item.Bind(base.MailboxSession, itemId, null);
                }
                catch (ObjectNotFoundException)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, userResponse, "Cannot find the meeting-request as specified in the reqest.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemNotFound");
                    return(false);
                }
                meetingRequest = (item as MeetingRequest);
                if (base.Version >= 141 && meetingRequest == null)
                {
                    calendarItemBase = (item as CalendarItemBase);
                    if (calendarItemBase != null)
                    {
                        calendarItemBase.OpenAsReadWrite();
                    }
                }
                if (meetingRequest == null && calendarItemBase == null)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, userResponse, "The item is not meeting-request or calendar item.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemNotValid");
                    return(false);
                }
                item = null;
                if (meetingRequest != null)
                {
                    if (meetingRequest.IsOrganizer())
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "The organizer of this meeting request is the mailbox owner. Checking meetingRequest.", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MRIsOrganizer");
                        return(false);
                    }
                    if (meetingRequest.IsDelegated())
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "Cannot respond to a delegated meeting request.  Use Outlook", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MRIsDelegated");
                        return(false);
                    }
                    if (meetingRequest.IsOutOfDate())
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "Cannot respond to a OutOfDated meeting request.", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MRIsOutOfDate");
                        return(false);
                    }
                    meetingRequest.OpenAsReadWrite();
                    storeObjectId    = meetingRequest.Id.ObjectId;
                    calendarItemBase = meetingRequest.UpdateCalendarItem(false);
                }
                if (calendarItemBase == null)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NullCalItemInMRCmd");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.ServerError, null, false);
                }
                if (calendarItemBase.IsOrganizer())
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "The organizer of this meeting request is the mailbox owner. Checking calendarItem.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CalIsOrganizer");
                    return(false);
                }
                if (calendarItemBase.IsCancelled)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "Cannot respond to a canceled meeting.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CalIsCancelled");
                    return(false);
                }
                if (userResponse != null)
                {
                    ResponseType responseType;
                    if (!(userResponse == "1"))
                    {
                        if (!(userResponse == "2"))
                        {
                            if (!(userResponse == "3"))
                            {
                                goto IL_22F;
                            }
                            responseType = ResponseType.Decline;
                        }
                        else
                        {
                            responseType = ResponseType.Tentative;
                        }
                    }
                    else
                    {
                        responseType = ResponseType.Accept;
                    }
                    try
                    {
                        using (calendarItemBase.RespondToMeetingRequest(responseType))
                        {
                        }
                    }
                    catch (SaveConflictException ex)
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, userResponse, "A conflict calendar item has been detected: " + ex.Message, usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "SavedWithConflicts");
                        return(false);
                    }
                    calendarItemBase.Load();
                    if (meetingRequest != null)
                    {
                        meetingRequest.Save(SaveMode.ResolveConflicts);
                    }
                    if (responseType != ResponseType.Decline)
                    {
                        if (calendarItemBase is CalendarItemOccurrence)
                        {
                            storeObjectId2 = ((CalendarItemOccurrence)calendarItemBase).MasterId.ObjectId;
                        }
                        else
                        {
                            storeObjectId2 = calendarItemBase.Id.ObjectId;
                        }
                    }
                    else
                    {
                        base.MailboxSession.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                        {
                            calendarItemBase.Id
                        });
                    }
                    calendarItemBase.Dispose();
                    calendarItemBase = null;
                    if (storeObjectId != null)
                    {
                        base.MailboxSession.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                        {
                            storeObjectId
                        });
                    }
                    goto IL_339;
                }
IL_22F:
                throw new ArgumentException(string.Format("Unexpected userResponse value \"{0}\"", userResponse));
            }
            finally
            {
                if (calendarItemBase != null)
                {
                    calendarItemBase.Dispose();
                }
                if (meetingRequest != null)
                {
                    meetingRequest.Dispose();
                }
                if (item != null)
                {
                    item.Dispose();
                }
            }
IL_339:
            string calendarId = null;

            if (storeObjectId2 != null)
            {
                MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(storeObjectId2);
                if (this.CalendarItemIdMapping.Contains(mailboxSyncItemId))
                {
                    calendarId = this.CalendarItemIdMapping[mailboxSyncItemId];
                }
                else
                {
                    calendarId = this.CalendarItemIdMapping.Add(mailboxSyncItemId);
                    this.calendarSyncStateChangedFlag = true;
                }
            }
            this.AppendXmlNode(requestId, StatusCode.Success, calendarId, userResponse, usingLongId);
            return(true);
        }
Ejemplo n.º 24
0
        // Token: 0x06000CE9 RID: 3305 RVA: 0x000459B0 File Offset: 0x00043BB0
        private bool Respond(StoreObjectId itemId, string requestId, MeetingResponseCommand.RequestNodeData response, bool usingLongId)
        {
            if (base.Version <= 141)
            {
                return(this.LegacyRespond(itemId, requestId, response.UserResponse, usingLongId));
            }
            if (response.RespondToEventParameters == null)
            {
                throw new InvalidOperationException("Response.RespondToEventParameters must not be null at this point.");
            }
            StoreObjectId storeObjectId = null;
            string        calendarId    = null;

            if (this.CalendaringContainer == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Set default CalendaringContainer");
                this.CalendaringContainer = new CalendaringContainer(base.MailboxSession, null);
            }
            if (this.MailboxGuid == Guid.Empty)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Set default MailboxGuid");
                this.MailboxGuid = base.MailboxSession.MailboxGuid;
            }
            string  key = EntitySyncItem.GetKey(this.MailboxGuid, itemId);
            IEvents events;

            if (itemId.ObjectType == StoreObjectType.CalendarItem || itemId.ObjectType == StoreObjectType.CalendarItemOccurrence || itemId.ObjectType == StoreObjectType.CalendarItemSeries)
            {
                storeObjectId = itemId;
                events        = EntitySyncItem.GetEvents(this.CalendaringContainer, base.MailboxSession, itemId);
            }
            else
            {
                if (itemId.ObjectType != StoreObjectType.MeetingRequest)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "The item is not meeting-request or calendar item.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UnsupportedObjectType" + itemId.ObjectType);
                    return(false);
                }
                using (MeetingMessage meetingMessage = MeetingMessage.Bind(base.MailboxSession, itemId))
                {
                    if (meetingMessage == null)
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "Cannot find the meeting-request as specified in the reqest.", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemNotFound");
                        return(false);
                    }
                    using (CalendarItemBase correlatedItem = meetingMessage.GetCorrelatedItem())
                    {
                        if (meetingMessage == null)
                        {
                            this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "Cannot find the correlated meeitng item.", usingLongId);
                            base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NullCalItemInMRCmd");
                            return(false);
                        }
                        storeObjectId = correlatedItem.Id.ObjectId;
                    }
                }
                response.RespondToEventParameters.MeetingRequestIdToBeDeleted = key;
                key    = EntitySyncItem.GetKey(this.MailboxGuid, storeObjectId);
                events = this.CalendaringContainer.Calendars.Default.Events;
            }
            try
            {
                events.Respond(key, response.RespondToEventParameters, null);
            }
            catch (LocalizedException ex)
            {
                this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, response.UserResponse, ex.Message, usingLongId);
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EntityRespondError");
                return(false);
            }
            if (storeObjectId != null)
            {
                MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(storeObjectId);
                if (this.CalendarItemIdMapping.Contains(mailboxSyncItemId))
                {
                    calendarId = this.CalendarItemIdMapping[mailboxSyncItemId];
                }
                else
                {
                    calendarId = this.CalendarItemIdMapping.Add(mailboxSyncItemId);
                    this.calendarSyncStateChangedFlag = true;
                }
            }
            this.AppendXmlNode(requestId, StatusCode.Success, calendarId, response.UserResponse, usingLongId);
            return(true);
        }
Ejemplo n.º 25
0
 // Token: 0x06000CE3 RID: 3299 RVA: 0x00044E4C File Offset: 0x0004304C
 internal void ProcessCommand()
 {
     foreach (MeetingResponseCommand.RequestNodeData requestNodeData in this.longIdRequests)
     {
         StoreObjectId storeObjectId = null;
         try
         {
             storeObjectId = StoreObjectId.Deserialize(HttpUtility.UrlDecode(requestNodeData.RequestId));
             if (requestNodeData.InstanceId != ExDateTime.MinValue)
             {
                 storeObjectId = this.GetOccurenceId(storeObjectId, requestNodeData.InstanceId);
             }
         }
         catch (ArgumentException)
         {
             base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRErrors);
             this.AppendNonSuccessXmlNode(requestNodeData.RequestId, StatusCode.Sync_ProtocolVersionMismatch, requestNodeData.UserResponse, string.Format(CultureInfo.InvariantCulture, "The LongId '{0}' in the reqest is invalid!", new object[]
             {
                 requestNodeData.RequestId
             }), true);
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId");
             base.PartialFailure = true;
             continue;
         }
         catch (CorruptDataException)
         {
             base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRErrors);
             this.AppendNonSuccessXmlNode(requestNodeData.RequestId, StatusCode.Sync_ProtocolVersionMismatch, requestNodeData.UserResponse, string.Format(CultureInfo.InvariantCulture, "The LongId '{0}' in the reqest is invalid!", new object[]
             {
                 requestNodeData.RequestId
             }), true);
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId2");
             base.PartialFailure = true;
             continue;
         }
         catch (FormatException)
         {
             base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRErrors);
             this.AppendNonSuccessXmlNode(requestNodeData.RequestId, StatusCode.Sync_ProtocolVersionMismatch, requestNodeData.UserResponse, string.Format(CultureInfo.InvariantCulture, "The LongId '{0}' in the reqest is invalid!", new object[]
             {
                 requestNodeData.RequestId
             }), true);
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidLongId3");
             base.PartialFailure = true;
             continue;
         }
         catch (AirSyncPermanentException ex)
         {
             base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRErrors);
             AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.RequestsTracer, this, "Exception caught while processing LongId {0}\r\n{1}", requestNodeData.RequestId, ex.ToString());
             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, (!string.IsNullOrEmpty(ex.ErrorStringForProtocolLogger)) ? ex.ErrorStringForProtocolLogger : "InvalidLongId4");
             this.AppendNonSuccessXmlNode(requestNodeData.RequestId, ex.AirSyncStatusCode, requestNodeData.UserResponse, ex.ErrorStringForProtocolLogger, true);
             base.PartialFailure = true;
             continue;
         }
         try
         {
             if (!this.Respond(storeObjectId, requestNodeData.RequestId, requestNodeData, true))
             {
                 base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRErrors);
             }
         }
         catch (AirSyncPermanentException)
         {
             base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRErrors);
             base.PartialFailure = true;
             throw;
         }
     }
     foreach (string text in this.shortIdRequests.Keys)
     {
         IList <MeetingResponseCommand.RequestNodeData> list = this.shortIdRequests[text];
         using (FolderSyncState folderSyncState = base.SyncStateStorage.GetFolderSyncState(text))
         {
             for (int i = 0; i < list.Count; i++)
             {
                 try
                 {
                     string requestId = list[i].RequestId;
                     if (folderSyncState == null || folderSyncState[CustomStateDatumType.IdMapping] == null)
                     {
                         this.AppendNonSuccessXmlNode(list[i].RequestId, StatusCode.Sync_ProtocolVersionMismatch, list[i].UserResponse, string.Format(CultureInfo.InvariantCulture, "The CollectionId '{0}' in the reqest has not been synced yet.", new object[]
                         {
                             text
                         }), false);
                         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "CollectionNotSynced");
                     }
                     else
                     {
                         StoreObjectId     storeObjectId2    = null;
                         MailboxSyncItemId mailboxSyncItemId = ((ItemIdMapping)folderSyncState[CustomStateDatumType.IdMapping])[requestId] as MailboxSyncItemId;
                         if (mailboxSyncItemId != null)
                         {
                             if (list[i].InstanceId == ExDateTime.MinValue)
                             {
                                 storeObjectId2 = (StoreObjectId)mailboxSyncItemId.NativeId;
                             }
                             else
                             {
                                 storeObjectId2 = this.GetOccurenceId((StoreObjectId)mailboxSyncItemId.NativeId, list[i].InstanceId);
                             }
                         }
                         if (storeObjectId2 == null)
                         {
                             this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, list[i].UserResponse, string.Format(CultureInfo.InvariantCulture, "Cannot look up the meeting-request '{0}' from ItemIdMapping.", new object[]
                             {
                                 requestId
                             }), false);
                             base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "InvalidRequestId");
                         }
                         else if (!this.Respond(storeObjectId2, requestId, list[i], false))
                         {
                             base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRErrors);
                         }
                     }
                 }
                 catch (AirSyncPermanentException ex2)
                 {
                     base.ProtocolLogger.IncrementValue(ProtocolLoggerData.MRErrors);
                     AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.RequestsTracer, this, "Exception caught while processing meeting-request {0}\r\n{1}", list[i].RequestId, ex2.ToString());
                     base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, (!string.IsNullOrEmpty(ex2.ErrorStringForProtocolLogger)) ? ex2.ErrorStringForProtocolLogger : "InvalidLongId4");
                     this.AppendNonSuccessXmlNode(list[i].RequestId, ex2.AirSyncStatusCode, list[i].UserResponse, ex2.ErrorStringForProtocolLogger, false);
                     base.PartialFailure = true;
                 }
             }
         }
     }
 }
Ejemplo n.º 26
0
        protected override void ProcessCommand(FolderCommand.FolderRequest folderRequest, XmlDocument doc)
        {
            DefaultFolderType defaultFolderType = base.MailboxSession.IsDefaultFolderType(folderRequest.ServerId);

            if (defaultFolderType != DefaultFolderType.None)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateOfDefaultFolder");
                AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), null, false);
                throw ex;
            }
            if (FolderCommand.IsEmptyOrWhiteSpacesOnly(folderRequest.DisplayName))
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateOfEmptyDisplayName");
                AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_NotificationGUID, base.ConstructErrorXml(StatusCode.Sync_NotificationGUID), null, false);
                throw ex;
            }
            string namespaceURI = doc.DocumentElement.NamespaceURI;

            using (Folder folder = Folder.Bind(base.MailboxSession, folderRequest.ServerId, null))
            {
                try
                {
                    this.ProcessFolderNameChange(folderRequest, folder);
                    if (folderRequest.ParentId.Equals(folderRequest.ServerId))
                    {
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateUnderSelf");
                        AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), null, false);
                        throw ex;
                    }
                    if (!folderRequest.ParentId.Equals(folder.ParentId))
                    {
                        using (Folder.Bind(base.MailboxSession, folderRequest.ParentId, null))
                        {
                        }
                        AggregateOperationResult aggregateOperationResult = base.MailboxSession.Move(folderRequest.ParentId, new StoreObjectId[]
                        {
                            folderRequest.ServerId
                        });
                        if (aggregateOperationResult.OperationResult == OperationResult.Failed)
                        {
                            AirSyncPermanentException ex;
                            if (aggregateOperationResult.GroupOperationResults != null && aggregateOperationResult.GroupOperationResults[0] != null && aggregateOperationResult.GroupOperationResults[0].Exception is ObjectExistedException)
                            {
                                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateOfNonExistentFolder");
                                ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), null, false);
                                throw ex;
                            }
                            base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UpdateFailed");
                            ex = new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, base.ConstructErrorXml(StatusCode.Sync_ClientServerConversion), null, false);
                            throw ex;
                        }
                    }
                    FolderTree    folderTree      = (FolderTree)base.FolderIdMappingSyncState[CustomStateDatumType.FullFolderTree];
                    ISyncItemId   syncItemId      = MailboxSyncItemId.CreateForNewItem(folderRequest.ServerId);
                    StoreObjectId defaultFolderId = base.MailboxSession.GetDefaultFolderId(DefaultFolderType.Root);
                    ISyncItemId   parentId        = folderTree.GetParentId(syncItemId);
                    if (parentId != null)
                    {
                        folderTree.UnlinkChild(parentId, syncItemId);
                    }
                    if (!defaultFolderId.Equals(folderRequest.ParentId))
                    {
                        ISyncItemId parentId2 = MailboxSyncItemId.CreateForNewItem(folderRequest.ParentId);
                        folderTree.LinkChildToParent(parentId2, syncItemId);
                    }
                }
                catch (ObjectNotFoundException innerException)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ObjectNotFoundOnUpdate");
                    AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ServerError, base.ConstructErrorXml(StatusCode.Sync_ServerError), innerException, false);
                    throw ex;
                }
                catch (ObjectExistedException innerException2)
                {
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ObjectExistedOnUpdate");
                    AirSyncPermanentException ex = new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, base.ConstructErrorXml(StatusCode.Sync_ProtocolVersionMismatch), innerException2, false);
                    throw ex;
                }
                base.FolderHierarchySync.RecordClientOperation(folder.Id.ObjectId, ChangeType.Change, 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);
                base.ProtocolLogger.IncrementValue("F", PerFolderProtocolLoggerData.ClientChanges);
            }
            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);
        }
Ejemplo n.º 27
0
        // 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);
            }
        }
Ejemplo n.º 28
0
        // 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);
        }
        // Token: 0x060013E0 RID: 5088 RVA: 0x00072734 File Offset: 0x00070934
        public IEnumerator <Attachment12Data> GetEnumerator()
        {
            Item             message        = base.XsoItem as Item;
            Attachment12Data attachmentData = null;

            if (message == null)
            {
                throw new UnexpectedTypeException("Item", base.XsoItem);
            }
            MeetingRequest meetingRequest = base.XsoItem as MeetingRequest;

            if (meetingRequest == null || !meetingRequest.IsDelegated())
            {
                string idbase = null;
                if (this.idmapping != null)
                {
                    idbase = this.idmapping[MailboxSyncItemId.CreateForNewItem(message.Id.ObjectId)];
                }
                if (idbase == null)
                {
                    idbase = message.Id.ObjectId.ToBase64String();
                }
                if (message is MessageItem && ((MessageItem)message).IsRestricted && !BodyConversionUtilities.IsMessageRestrictedAndDecoded(message) && !BodyConversionUtilities.IsIRMFailedToDecode(message))
                {
                    object prop = message.TryGetProperty(MessageItemSchema.DRMLicense);
                    if (prop is byte[][])
                    {
                        byte[][] license = (byte[][])prop;
                        if (license.Length > 0)
                        {
                            attachmentData                   = new Attachment14Data();
                            attachmentData.DisplayName       = "message.rpmsg.license";
                            attachmentData.Method            = 1;
                            attachmentData.EstimatedDataSize = (long)license[0].Length;
                            attachmentData.IsInline          = false;
                            attachmentData.FileReference     = HttpUtility.UrlEncode(idbase + ":DRMLicense");
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Add DRM license as attachment, message is MessageItem {0}, message.IsRestricted {1}, IsDecoded {2}, FailedToDecode {3}", new object[]
                            {
                                message is MessageItem,
                                ((MessageItem)message).IsRestricted,
                                BodyConversionUtilities.IsMessageRestrictedAndDecoded(message),
                                BodyConversionUtilities.IsIRMFailedToDecode(message)
                            });
                            yield return(attachmentData);
                        }
                        else
                        {
                            AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. Length = {0}", license.Length);
                        }
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. prop = {0}", new object[]
                        {
                            prop
                        });
                    }
                }
                AttachmentCollection attachmentCollection = null;
                if (BodyConversionUtilities.IsMessageRestrictedAndDecoded(message))
                {
                    attachmentCollection = ((RightsManagedMessageItem)message).ProtectedAttachmentCollection;
                }
                else
                {
                    if (BodyConversionUtilities.IsIRMFailedToDecode(message))
                    {
                        goto IL_3FC;
                    }
                    attachmentCollection = message.AttachmentCollection;
                }
                int index = -1;
                foreach (AttachmentHandle handle in attachmentCollection)
                {
                    using (Attachment attachment = attachmentCollection.Open(handle))
                    {
                        if (BodyUtility.IsClearSigned(message) && (string.Equals(attachment.FileName, "smime.p7m", StringComparison.OrdinalIgnoreCase) || string.Equals(attachment.ContentType, "multipart/signed", StringComparison.OrdinalIgnoreCase)))
                        {
                            continue;
                        }
                        attachmentData = this.GetAttachmentData(message, attachment, idbase, ref index);
                    }
                    if (attachmentData != null)
                    {
                        yield return(attachmentData);
                    }
                }
            }
IL_3FC:
            yield break;
        }
 internal void Prepopulate(Folder folder)
 {
     if (folder == null)
     {
         throw new ArgumentNullException("folder");
     }
     this.prepopulate = true;
     if (this.CustomFilterState == null)
     {
         this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>();
     }
     using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, null, new PropertyDefinition[]
     {
         ItemSchema.Id,
         CalendarItemInstanceSchema.EndTime,
         CalendarItemBaseSchema.CalendarItemType,
         StoreObjectSchema.ItemClass,
         ItemSchema.Subject,
         CalendarItemInstanceSchema.StartTime
     }))
     {
         bool flag = false;
         while (!flag)
         {
             object[][] rows = queryResult.GetRows(10000);
             flag = (rows.Length == 0);
             for (int i = 0; i < rows.Length; i++)
             {
                 StoreObjectId storeObjectId = null;
                 DateTimeCustomSyncFilter.FilterState filterState = null;
                 ISyncItemId key = null;
                 try
                 {
                     storeObjectId = ((VersionedId)rows[i][0]).ObjectId;
                     string itemClass = rows[i][3] as string;
                     key = MailboxSyncItemId.CreateForNewItem(storeObjectId);
                     if (!this.CustomFilterState.ContainsKey(key))
                     {
                         filterState = new DateTimeCustomSyncFilter.FilterState();
                         this.CustomFilterState[key] = filterState;
                     }
                     else
                     {
                         filterState = this.CustomFilterState[key];
                     }
                     if (!ObjectClass.IsCalendarItem(itemClass))
                     {
                         filterState.IsCalendarItem = false;
                     }
                     else
                     {
                         filterState.IsCalendarItem = true;
                         if (!(rows[i][2] is CalendarItemType))
                         {
                             filterState.IsCalendarItem = false;
                         }
                         else
                         {
                             filterState.IsRecurring = (CalendarItemType.RecurringMaster == (CalendarItemType)rows[i][2]);
                             if (filterState.IsRecurring)
                             {
                                 using (CalendarItem calendarItem = CalendarItem.Bind(folder.Session, storeObjectId))
                                 {
                                     if (calendarItem.Recurrence != null)
                                     {
                                         if (calendarItem.Recurrence.Range is NoEndRecurrenceRange)
                                         {
                                             filterState.DoesRecurrenceEnd = false;
                                         }
                                         else
                                         {
                                             filterState.DoesRecurrenceEnd = true;
                                             OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence();
                                             filterState.EndTime = lastOccurrence.EndTime;
                                         }
                                     }
                                     else
                                     {
                                         filterState.IsCalendarItem = false;
                                     }
                                     goto IL_1E6;
                                 }
                             }
                             if (!(rows[i][1] is ExDateTime))
                             {
                                 filterState.IsCalendarItem = false;
                             }
                             else
                             {
                                 filterState.EndTime = (ExDateTime)rows[i][1];
                             }
                             IL_1E6 :;
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     if (ex is ObjectNotFoundException)
                     {
                         this.CustomFilterState.Remove(key);
                     }
                     else
                     {
                         if (!SyncCommand.IsItemSyncTolerableException(ex))
                         {
                             throw;
                         }
                         string     text       = "Unknown";
                         ExDateTime exDateTime = ExDateTime.MinValue;
                         try
                         {
                             text       = (rows[i][4] as string);
                             exDateTime = (ExDateTime)rows[i][5];
                         }
                         catch
                         {
                         }
                         AirSyncUtility.ExceptionToStringHelper exceptionToStringHelper = new AirSyncUtility.ExceptionToStringHelper(ex);
                         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Exception was caught in Prepopulate. Item id=\"{0}\", subject=\"{1}\", meetingTime={2}\r\n{3}\r\nIgnoring exception and proceeding to next item.", new object[]
                         {
                             (storeObjectId != null) ? storeObjectId : "null",
                             text,
                             exDateTime,
                             exceptionToStringHelper
                         });
                         if (filterState != null)
                         {
                             filterState.IsCalendarItem = false;
                         }
                     }
                 }
             }
         }
     }
 }