Пример #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);
        }
Пример #2
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);
        }
Пример #3
0
        public static PropValueData[] GetMessageProps(SyncEmailContext context, string accountName, byte[] folderId, params PropValueData[] extraProps)
        {
            ArgumentValidator.ThrowIfNullOrEmpty("accountName", accountName);
            ArgumentValidator.ThrowIfNull("folderId", folderId);
            List <PropValueData> list = new List <PropValueData>(SyncEmailUtils.SyncEmailPropTags.Length + 3);

            list.Add(new PropValueData(SyncEmailUtils.SyncMessageIdPTag, context.SyncMessageId));
            list.Add(new PropValueData(SyncEmailUtils.SyncAccountNamePTag, accountName));
            list.Add(new PropValueData(SyncEmailUtils.SyncFolderIdPTag, folderId));
            foreach (PropTag propTag in SyncEmailUtils.SyncEmailPropTags)
            {
                PropTag propTag2 = propTag;
                if (propTag2 != PropTag.MessageFlags)
                {
                    if (propTag2 != (PropTag)276824067U)
                    {
                        if (propTag2 == PropTag.SpamConfidenceLevel)
                        {
                            list.Add(new PropValueData(propTag, -1));
                        }
                    }
                    else if (context.ResponseType != null)
                    {
                        list.Add(new PropValueData(propTag, (int)SyncEmailUtils.GetIconIndex(context.ResponseType)));
                    }
                }
                else
                {
                    list.Add(new PropValueData(propTag, (int)SyncEmailUtils.GetMessageFlags(context.IsRead, context.IsDraft)));
                }
            }
            if (extraProps != null)
            {
                list.AddRange(extraProps);
            }
            return(list.ToArray());
        }