Esempio n. 1
0
        internal static SyncEmailContext GetSyncEmailContext(ImapClientFolder folder, ImapMessageRec messageRec)
        {
            ArgumentValidator.ThrowIfNull("folder", folder);
            ArgumentValidator.ThrowIfNull("messageRec", messageRec);
            SyncEmailContext result         = default(SyncEmailContext);
            ImapMailFlags    imapMailFlags  = messageRec.ImapMailFlags;
            ImapMailFlags    imapMailFlags2 = folder.SupportedFlags;

            if (folder.DefaultFolderType.Equals(ImapDefaultFolderType.Drafts))
            {
                imapMailFlags  |= ImapMailFlags.Draft;
                imapMailFlags2 |= ImapMailFlags.Draft;
            }
            if (imapMailFlags2.HasFlag(ImapMailFlags.Draft))
            {
                result.IsDraft = new bool?(imapMailFlags.HasFlag(ImapMailFlags.Draft));
            }
            if (imapMailFlags2.HasFlag(ImapMailFlags.Seen))
            {
                result.IsRead = new bool?(imapMailFlags.HasFlag(ImapMailFlags.Seen));
            }
            if (imapMailFlags2.HasFlag(ImapMailFlags.Answered))
            {
                result.ResponseType = new SyncMessageResponseType?(imapMailFlags.HasFlag(ImapMailFlags.Answered) ? SyncMessageResponseType.Replied : SyncMessageResponseType.None);
            }
            ImapExtendedMessageRec imapExtendedMessageRec = messageRec as ImapExtendedMessageRec;

            if (imapExtendedMessageRec != null)
            {
                result.SyncMessageId = imapExtendedMessageRec.MessageId;
            }
            return(result);
        }
Esempio n. 2
0
        List <FolderRec> IMailbox.EnumerateFolderHierarchy(EnumerateFolderHierarchyFlags flags, PropTag[] additionalPtagsToLoad)
        {
            MrsTracer.Provider.Function("ImapMailbox.EnumerateFolderHierarchy({0})", new object[]
            {
                flags
            });
            base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None);
            List <FolderRec>        list  = null;
            List <ImapClientFolder> list2 = this.EnumerateFolderHierarchy();

            list2.Add(new ImapClientFolder(ImapMailbox.Root)
            {
                IsSelectable = false
            });
            list2.Add(new ImapClientFolder(ImapMailbox.IpmSubtree)
            {
                IsSelectable = false
            });
            ImapClientFolder.FindWellKnownFolders(list2);
            this.folderCache = new EntryIdMap <ImapClientFolder>();
            list             = new List <FolderRec>(list2.Count);
            foreach (ImapClientFolder imapClientFolder in list2)
            {
                FolderRec folderRec = this.CreateFolderRec(imapClientFolder);
                list.Add(folderRec);
                this.folderCache.Add(folderRec.EntryId, imapClientFolder);
            }
            return(list);
        }
Esempio n. 3
0
        public static void FindWellKnownFolders(List <ImapClientFolder> folders)
        {
            Dictionary <ImapDefaultFolderType, ImapClientFolder> dictionary = new Dictionary <ImapDefaultFolderType, ImapClientFolder>();

            foreach (ImapClientFolder imapClientFolder in folders)
            {
                bool flag;
                bool flag2;
                imapClientFolder.DefaultFolderType = ImapClientFolder.GetDefaultFolderType(imapClientFolder.Name, out flag, out flag2);
                if (imapClientFolder.DefaultFolderType != ImapDefaultFolderType.None && (flag2 || flag) && !dictionary.ContainsKey(imapClientFolder.DefaultFolderType))
                {
                    dictionary.Add(imapClientFolder.DefaultFolderType, imapClientFolder);
                }
            }
            foreach (ImapClientFolder imapClientFolder2 in folders)
            {
                imapClientFolder2.WellKnownFolderType = WellKnownFolderType.None;
                if (imapClientFolder2.DefaultFolderType != ImapDefaultFolderType.None && !dictionary.ContainsKey(imapClientFolder2.DefaultFolderType))
                {
                    dictionary.Add(imapClientFolder2.DefaultFolderType, imapClientFolder2);
                }
            }
            foreach (KeyValuePair <ImapDefaultFolderType, ImapClientFolder> keyValuePair in dictionary)
            {
                WellKnownFolderType wellKnownFolderType;
                if (ImapClientFolder.DefaultToWellKnownFolderMapping.TryGetValue(keyValuePair.Key, out wellKnownFolderType))
                {
                    ImapClientFolder value = keyValuePair.Value;
                    value.WellKnownFolderType = wellKnownFolderType;
                }
            }
        }
Esempio n. 4
0
 internal static ImapFolderState CreateNew(ImapClientFolder folder)
 {
     return(new ImapFolderState
     {
         SeqNumCrawl = int.MaxValue,
         UidNext = folder.UidNext,
         UidValidity = folder.UidValidity
     });
 }
Esempio n. 5
0
        public FolderRec CreateFolderRec(ImapClientFolder folder)
        {
            if (folder.Name.Equals(ImapMailbox.Root))
            {
                return(new FolderRec(ImapMailbox.RootEntryId, null, FolderType.Root, string.Empty, DateTime.MinValue, null));
            }
            if (folder.Name.Equals(ImapMailbox.IpmSubtree))
            {
                return(new FolderRec(ImapMailbox.IpmSubtreeEntryId, ImapMailbox.RootEntryId, FolderType.Generic, "Top of Information Store", DateTime.MinValue, null));
            }
            byte[] entryId          = ImapEntryId.CreateFolderEntryId(folder.Name);
            string parentFolderPath = folder.ParentFolderPath;

            if (string.IsNullOrEmpty(parentFolderPath))
            {
                return(new FolderRec(entryId, ImapMailbox.IpmSubtreeEntryId, FolderType.Generic, folder.ShortFolderName, DateTime.MinValue, null));
            }
            return(new FolderRec(entryId, ImapEntryId.CreateFolderEntryId(parentFolderPath), FolderType.Generic, folder.ShortFolderName, DateTime.MinValue, null));
        }
Esempio n. 6
0
 internal void Config(byte[] folderId, ImapClientFolder folder, ImapMailbox mailbox)
 {
     this.FolderId = folderId;
     this.Folder   = folder;
     this.Mailbox  = mailbox;
 }