private IEnumerable <MessageRec> CreateMessageRecsForAdditions(List <AddCommand> additions) { foreach (AddCommand addition in additions) { yield return(new MessageRec(EasMailbox.GetEntryId(addition.ServerId), base.EntryId, EasFolder.GetCreationTimestamp(addition.ApplicationData.DateReceived), (int)((addition.ApplicationData.Body == null) ? 0U : addition.ApplicationData.Body.EstimatedDataSize), MsgRecFlags.None, this.GetAdditionalProps(addition))); } yield break; }
private byte[] GetParentId(Add add) { if (add.GetEasFolderType() != EasFolderType.UserCalendar) { return(EasMailbox.GetEntryId(add.ParentId)); } return(this.defaultCalendarId); }
protected IEnumerable <MessageRec> CreateMessageRecsForDeletions(List <DeleteCommand> deletions) { foreach (DeleteCommand delete in deletions) { yield return(new MessageRec(EasMailbox.GetEntryId(delete.ServerId), base.EntryId, DateTime.MinValue, 0, MsgRecFlags.Deleted, this.GetAdditionalProps(delete))); } yield break; }
protected EasFolderBase(string serverId, string parentId, string displayName, EasFolderType folderType) { this.serverId = serverId; this.parentId = parentId; this.displayName = displayName; this.folderType = folderType; this.EntryId = EasMailbox.GetEntryId(serverId); }
internal byte[] CreateCalendarEvent(string clientId, string syncKey, out string newSyncKey, string folderId, Event theEvent, IList <Event> exceptionalEvents, IList <string> deletedOccurrences, UserSmtpAddress userSmtpAddress) { SyncRequest syncRequest = EasRequestGenerator.CreateSyncRequestForCreateCalendarEvent(syncKey, clientId, folderId, theEvent, exceptionalEvents, deletedOccurrences, userSmtpAddress); SyncResponse syncResponse = this.SyncCreation(clientId, syncRequest); newSyncKey = syncResponse.Collections[0].SyncKey; return(EasMailbox.GetEntryId(syncResponse.AddResponses[0].ServerId)); }
private IEnumerable <MessageRec> CreateMessageRecsForChanges(List <ChangeCommand> changes) { foreach (ChangeCommand change in changes) { int estimatedDataSize = (int)((change.ApplicationData.Body == null) ? 0U : change.ApplicationData.Body.EstimatedDataSize); yield return(new MessageRec(EasMailbox.GetEntryId(change.ServerId), base.EntryId, DateTime.MinValue, estimatedDataSize, MsgRecFlags.None, this.GetAdditionalProps(change))); } yield break; }
private List <MessageRec> CreateMessageRecsForFetches(IReadOnlyCollection <Fetch> fetches) { List <MessageRec> list = new List <MessageRec>(fetches.Count); foreach (Fetch fetch in fetches) { if (fetch.Status == 1) { list.Add(new MessageRec(EasMailbox.GetEntryId(fetch.ServerId), base.EntryId, EasFolder.GetCreationTimestamp(fetch.Properties.DateReceived), (int)fetch.Properties.Body.EstimatedDataSize, MsgRecFlags.None, this.GetAdditionalProps(fetch))); } } return(list); }
protected override MailboxChangesManifest RunManualHierarchySync(bool catchup, SyncHierarchyManifestState hierState) { MrsTracer.Provider.Function("EasSourceMailbox.RunManualHierarchySync", new object[0]); base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None); EasHierarchySyncState easHierarchySyncState = EasHierarchySyncState.Deserialize(hierState.ProviderSyncState); hierState.ProviderSyncState = null; EasHierarchySyncState easHierarchySyncState2 = base.RefreshFolderCache(); EntryIdMap <EasHierarchySyncState.EasFolderData> entryIdMap = new EntryIdMap <EasHierarchySyncState.EasFolderData>(); foreach (EasHierarchySyncState.EasFolderData easFolderData in easHierarchySyncState.FolderData) { entryIdMap[EasMailbox.GetEntryId(easFolderData.ServerId)] = easFolderData; } EntryIdMap <EasHierarchySyncState.EasFolderData> entryIdMap2 = new EntryIdMap <EasHierarchySyncState.EasFolderData>(); foreach (EasHierarchySyncState.EasFolderData easFolderData2 in easHierarchySyncState2.FolderData) { entryIdMap2[EasMailbox.GetEntryId(easFolderData2.ServerId)] = easFolderData2; } MailboxChangesManifest mailboxChangesManifest = new MailboxChangesManifest(); mailboxChangesManifest.DeletedFolders = new List <byte[]>(); foreach (byte[] array in entryIdMap.Keys) { if (!entryIdMap2.ContainsKey(array)) { mailboxChangesManifest.DeletedFolders.Add(array); } } mailboxChangesManifest.ChangedFolders = new List <byte[]>(); foreach (KeyValuePair <byte[], EasHierarchySyncState.EasFolderData> keyValuePair in entryIdMap2) { byte[] key = keyValuePair.Key; EasHierarchySyncState.EasFolderData value = keyValuePair.Value; EasHierarchySyncState.EasFolderData easFolderData3; if (entryIdMap.TryGetValue(key, out easFolderData3)) { if (easFolderData3.ParentId != value.ParentId || easFolderData3.DisplayName != value.DisplayName) { mailboxChangesManifest.ChangedFolders.Add(key); } } else { mailboxChangesManifest.ChangedFolders.Add(key); } } return(mailboxChangesManifest); }
protected void RefreshFolderCache(EasHierarchySyncState state) { IReadOnlyCollection <Add> folders = state.Folders; EntryIdMap <Add> entryIdMap = new EntryIdMap <Add>(folders.Count); this.defaultCalendarId = null; foreach (Add add in folders) { EasFolderType easFolderType = add.GetEasFolderType(); if (easFolderType == EasFolderType.Calendar) { this.defaultCalendarId = EasMailbox.GetEntryId(add.ServerId); } EasFolderType easFolderType2 = easFolderType; if (easFolderType2 == EasFolderType.UserGeneric) { goto IL_8B; } bool flag; switch (easFolderType2) { case EasFolderType.Contacts: case EasFolderType.UserContacts: flag = !ConfigBase <MRSConfigSchema> .GetConfig <bool>("DisableContactSync"); goto IL_9D; case EasFolderType.UserMail: case EasFolderType.UserCalendar: goto IL_8B; } flag = EasMailbox.folderTypeMap.ContainsKey(easFolderType); IL_9D: if (flag) { entryIdMap.Add(EasMailbox.GetEntryId(add.ServerId), add); continue; } MrsTracer.Provider.Debug("EasMailbox.RefreshFolderCache: ignore {0} folder '{1}' since it is not supported yet", new object[] { easFolderType, add.DisplayName }); continue; IL_8B: flag = true; goto IL_9D; } this.EasFolderCache = entryIdMap; }
List <WellKnownFolder> IMailbox.DiscoverWellKnownFolders(int flags) { List <WellKnownFolder> list = new List <WellKnownFolder>(this.EasFolderCache.Count + 1); foreach (Add add in this.EasFolderCache.Values) { WellKnownFolderType wkfType; if (EasMailbox.folderTypeMap.TryGetValue(add.GetEasFolderType(), out wkfType)) { list.Add(new WellKnownFolder((int)wkfType, EasMailbox.GetEntryId(add.ServerId))); } } list.Add(new WellKnownFolder(3, EasSyntheticFolder.IpmSubtreeFolder.EntryId)); return(list); }
private MailboxChangesManifest GetFolderChangesOnServer(string syncKey, out string newSyncKey, out IReadOnlyCollection <Add> newFolders) { newFolders = null; FolderSyncResponse folderSyncResponse = base.EasConnectionWrapper.FolderSync(syncKey); newSyncKey = folderSyncResponse.SyncKey; MailboxChangesManifest mailboxChangesManifest = new MailboxChangesManifest(); mailboxChangesManifest.ChangedFolders = new List <byte[]>(0); mailboxChangesManifest.DeletedFolders = new List <byte[]>(0); if (folderSyncResponse.Changes != null) { List <Add> additions = folderSyncResponse.Changes.Additions; if (additions != null && additions.Count > 0) { mailboxChangesManifest.ChangedFolders.Capacity += additions.Count; foreach (Add add in additions) { mailboxChangesManifest.ChangedFolders.Add(EasMailbox.GetEntryId(add.ServerId)); } newFolders = additions; } List <Update> updates = folderSyncResponse.Changes.Updates; if (updates != null && updates.Count > 0) { mailboxChangesManifest.ChangedFolders.Capacity += updates.Count; foreach (Update update in updates) { mailboxChangesManifest.ChangedFolders.Add(EasMailbox.GetEntryId(update.ServerId)); } } List <Delete> deletions = folderSyncResponse.Changes.Deletions; if (deletions != null && deletions.Count > 0) { mailboxChangesManifest.DeletedFolders.Capacity = deletions.Count; foreach (Delete delete in deletions) { mailboxChangesManifest.DeletedFolders.Add(EasMailbox.GetEntryId(delete.ServerId)); } } } return(mailboxChangesManifest); }
private byte[] MoveItem(byte[] messageEntryId, byte[] sourceFolderEntryId, byte[] destFolderEntryId, out bool isPermanentDeletionMove) { isPermanentDeletionMove = false; base.CheckDisposed(); Add add; if (!base.EasFolderCache.TryGetValue(sourceFolderEntryId, out add)) { MrsTracer.Provider.Warning("Source folder {0} doesn't exist", new object[] { TraceUtils.DumpBytes(sourceFolderEntryId) }); throw new EasObjectNotFoundException(EasMailbox.GetStringId(sourceFolderEntryId)); } Add add2; if (!base.EasFolderCache.TryGetValue(destFolderEntryId, out add2)) { MrsTracer.Provider.Warning("Destination folder {0} doesn't exist", new object[] { TraceUtils.DumpBytes(destFolderEntryId) }); throw new EasObjectNotFoundException(EasMailbox.GetStringId(destFolderEntryId)); } string stringId = EasMailbox.GetStringId(messageEntryId); if (add2.Type == 4 && EasFolder.IsCalendarFolder((EasFolderType)add.Type)) { this.DeleteItem(messageEntryId, sourceFolderEntryId); isPermanentDeletionMove = true; return(null); } string stringId2 = base.EasConnectionWrapper.MoveItem(stringId, add.ServerId, add2.ServerId); return(EasMailbox.GetEntryId(stringId2)); }
private FolderRec CreateGenericFolderRec(Add add) { return(new FolderRec(EasMailbox.GetEntryId(add.ServerId), this.GetParentId(add), FolderType.Generic, EasMailbox.GetFolderClass(add), add.DisplayName, DateTime.MinValue, null)); }
protected static FolderRec CreateGenericFolderRec(EasFolderBase folder) { return(new FolderRec(folder.EntryId, EasMailbox.GetEntryId(folder.ParentId), FolderType.Generic, folder.DisplayName, DateTime.MinValue, null)); }