Пример #1
0
        private static void EnumerateChanges(GlobCountSet sourceUidSet, GlobCountSet targetUidSet, uint uidNext, Action <uint> uidInclusionAction, Action <uint> uidExclusionAction)
        {
            uint highestUid = uidNext - 1U;

            if (sourceUidSet == null || targetUidSet == null)
            {
                return;
            }
            if (sourceUidSet.IsEmpty && targetUidSet.IsEmpty)
            {
                return;
            }
            if (sourceUidSet.IsEmpty)
            {
                ImapFolderState.PerformAction(targetUidSet, highestUid, uidExclusionAction);
                return;
            }
            if (targetUidSet.IsEmpty)
            {
                ImapFolderState.PerformAction(sourceUidSet, highestUid, uidInclusionAction);
                return;
            }
            GlobCountSet globCountSet  = GlobCountSet.Subtract(sourceUidSet, targetUidSet);
            GlobCountSet globCountSet2 = GlobCountSet.Subtract(targetUidSet, sourceUidSet);

            if (globCountSet != null && !globCountSet.IsEmpty)
            {
                ImapFolderState.PerformAction(globCountSet, highestUid, uidInclusionAction);
            }
            if (globCountSet2 != null && !globCountSet2.IsEmpty)
            {
                ImapFolderState.PerformAction(globCountSet2, highestUid, uidExclusionAction);
            }
        }
Пример #2
0
 private static byte[] SerializeUidSet(GlobCountSet uidSet)
 {
     if (uidSet == null)
     {
         return(null);
     }
     return(BufferWriter.Serialize(new BufferWriter.SerializeDelegate(uidSet.Serialize)));
 }
Пример #3
0
 internal ImapFolderState(int seqNumCrawl, uint uidNext, uint uidValidity, GlobCountSet uidReadSet, GlobCountSet uidDeletedSet)
 {
     this.SeqNumCrawl   = seqNumCrawl;
     this.UidNext       = uidNext;
     this.UidValidity   = uidValidity;
     this.uidReadSet    = uidReadSet;
     this.uidDeletedSet = uidDeletedSet;
 }
Пример #4
0
 private static void PerformAction(GlobCountSet uidSet, uint highestUid, Action <uint> action)
 {
     foreach (GlobCountRange globCountRange in uidSet)
     {
         uint num = (uint)globCountRange.LowBound;
         while (num <= (uint)globCountRange.HighBound && num <= highestUid)
         {
             action(num);
             num += 1U;
         }
     }
 }
Пример #5
0
        private static GlobCountSet ParseUidSet(byte[] input)
        {
            if (input == null)
            {
                return(null);
            }
            GlobCountSet result;

            using (BufferReader bufferReader = Reader.CreateBufferReader(input))
            {
                try
                {
                    result = GlobCountSet.Parse(bufferReader);
                }
                catch (BufferParseException innerException)
                {
                    throw new CorruptSyncStateException(innerException);
                }
            }
            return(result);
        }
Пример #6
0
        internal static ImapFolderState Create(List <MessageRec> messages, int seqNumCrawl, uint uidNext, uint uidValidity)
        {
            if (messages.Count == 0)
            {
                return(new ImapFolderState
                {
                    SeqNumCrawl = seqNumCrawl,
                    UidNext = uidNext,
                    UidValidity = uidValidity
                });
            }
            Dictionary <uint, MessageRec> dictionary = new Dictionary <uint, MessageRec>();

            foreach (MessageRec messageRec in messages)
            {
                uint key = ImapEntryId.ParseUid(messageRec.EntryId);
                dictionary.Add(key, messageRec);
            }
            GlobCountSet globCountSet  = new GlobCountSet();
            GlobCountSet globCountSet2 = new GlobCountSet();

            for (uint num = uidNext - 1U; num > 0U; num -= 1U)
            {
                MessageRec messageRec2 = null;
                if (!dictionary.TryGetValue(num, out messageRec2))
                {
                    globCountSet2.Insert((ulong)num);
                }
                else
                {
                    MessageFlags messageFlags = (MessageFlags)((int)messageRec2[PropTag.MessageFlags]);
                    if (messageFlags.HasFlag(MessageFlags.Read))
                    {
                        globCountSet.Insert((ulong)num);
                    }
                }
            }
            return(new ImapFolderState(seqNumCrawl, uidNext, uidValidity, globCountSet, globCountSet2));
        }