Exemplo 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);
        }
Exemplo n.º 2
0
        private IEnumerable <ImapMessageRec> GetImapMessageRecsFromResultData(ImapResultData resultData, FetchMessagesFlags fetchFlags)
        {
            IList <string>        messageUids  = resultData.MessageUids;
            IList <ImapMailFlags> messageFlags = resultData.MessageFlags;
            bool flag = messageUids != null && messageUids.Count > 0 && messageFlags != null && messageFlags.Count > 0;

            if (!flag)
            {
                return(new List <ImapMessageRec>(0));
            }
            if (fetchFlags.HasFlag(FetchMessagesFlags.IncludeExtendedData))
            {
                return(ImapExtendedMessageRec.FromImapResultData(this.folder, resultData));
            }
            return(ImapMessageRec.FromImapResultData(resultData));
        }
Exemplo n.º 3
0
        private List <MessageRec> GetMessageRecs(List <ImapMessageRec> imapMessageRecs)
        {
            if (imapMessageRecs.Count == 0)
            {
                return(new List <MessageRec>(0));
            }
            List <MessageRec> list = new List <MessageRec>(imapMessageRecs.Count);

            foreach (ImapMessageRec imapMessageRec in imapMessageRecs)
            {
                SyncEmailContext syncEmailContext = ImapFolder.GetSyncEmailContext(this.Folder, imapMessageRec);
                int messageSize = 0;
                ImapExtendedMessageRec imapExtendedMessageRec = imapMessageRec as ImapExtendedMessageRec;
                if (imapExtendedMessageRec != null)
                {
                    messageSize = (int)imapExtendedMessageRec.MessageSize;
                }
                PropValueData[] messageProps = SyncEmailUtils.GetMessageProps(syncEmailContext, this.Mailbox.ImapConnection.ConnectionContext.UserName, this.FolderId, new PropValueData[0]);
                MessageRec      item         = new MessageRec(ImapEntryId.CreateMessageEntryId(imapMessageRec.Uid, this.Folder.UidValidity, this.Folder.Name, this.Mailbox.ImapConnection.ConnectionContext.UserName), this.FolderId, CommonUtils.DefaultLastModificationTime, messageSize, MsgRecFlags.None, messageProps);
                list.Add(item);
            }
            return(list);
        }