示例#1
0
        private string ZFlagNames(cFetchableFlags pFlags)
        {
            if (pFlags == null)
            {
                return(string.Empty);
            }

            StringBuilder lBuilder = new StringBuilder();
            bool          lFirst   = true;

            foreach (var lFlag in pFlags)
            {
                if (lFirst)
                {
                    lFirst = false;
                }
                else
                {
                    lBuilder.Append(" ");
                }
                lBuilder.Append(lFlag);
            }

            return(lBuilder.ToString());
        }
        internal cMailboxSelectedProperties(cMailboxSelectedProperties pSelectedProperties, bool pSelectedForUpdate, cPermanentFlags pPermanentFlags)
        {
            if (pSelectedProperties == null)
            {
                throw new ArgumentNullException(nameof(pSelectedProperties));
            }

            mBeenSelected = true;

            if (pSelectedForUpdate)
            {
                mBeenSelectedForUpdate   = true;
                mBeenSelectedReadOnly    = pSelectedProperties.mBeenSelectedReadOnly;
                mForUpdatePermanentFlags = pPermanentFlags;
                mReadOnlyPermanentFlags  = pSelectedProperties.mReadOnlyPermanentFlags;
            }
            else
            {
                mBeenSelectedForUpdate   = pSelectedProperties.mBeenSelectedForUpdate;
                mBeenSelectedReadOnly    = true;
                mForUpdatePermanentFlags = pSelectedProperties.mForUpdatePermanentFlags;
                mReadOnlyPermanentFlags  = pPermanentFlags;
            }

            mUIDNotSticky = pSelectedProperties.mUIDNotSticky;
            mMessageFlags = pSelectedProperties.mMessageFlags;
        }
示例#3
0
        private bool ZTryParseFlagNames(string pText, out cFetchableFlags rFlags)
        {
            if (pText == null)
            {
                rFlags = null; return(true);
            }

            List <string> lFlags = new List <string>();

            foreach (var lFlag in pText.Trim().Split(' '))
            {
                if (!string.IsNullOrWhiteSpace(lFlag))
                {
                    lFlags.Add(lFlag);
                }
            }

            if (lFlags.Count == 0)
            {
                rFlags = null; return(true);
            }

            try { rFlags = new cFetchableFlags(lFlags); }
            catch { rFlags = null; return(false); }

            return(true);
        }
示例#4
0
                public override eProcessDataResult ProcessData(cResponseData pData, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cCommandHookSelect), nameof(ProcessData));

                    if (mMailboxCache.SelectedMailboxDetails != null)
                    {
                        return(eProcessDataResult.notprocessed);
                    }

                    switch (pData)
                    {
                    case cResponseDataFlags lFlags:

                        mFlags = lFlags.Flags;
                        return(eProcessDataResult.processed);

                    case cResponseDataExists lExists:

                        mExists = lExists.Exists;
                        return(eProcessDataResult.processed);

                    case cResponseDataRecent lRecent:

                        mRecent = lRecent.Recent;
                        return(eProcessDataResult.processed);
                    }

                    return(eProcessDataResult.notprocessed);
                }
示例#5
0
        internal static void _Tests(cTrace.cContext pParentContext)
        {
            bool lFailed;

            var lFlags = new cStorableFlagList();

            lFlags.Add("a");
            lFlags.Add("b");
            lFlags.Add(kMessageFlag.Answered, kMessageFlag.Deleted);
            lFlags.Add(kMessageFlag.Answered, kMessageFlag.Deleted, kMessageFlag.Forwarded);
            lFlags.Add(@"\answereD");
            lFlags.Add(@"\ansWereD", "A", @"\deleteD");

            lFailed = false;
            try { lFlags.Add("fr ed"); }
            catch { lFailed = true; }
            if (!lFailed)
            {
                throw new cTestsException($"{nameof(cStorableFlagList)}.1");
            }

            lFailed = false;
            try { lFlags.Add(kMessageFlag.Answered, kMessageFlag.Deleted, kMessageFlag.Draft, kMessageFlag.Recent); }
            catch { lFailed = true; }
            if (!lFailed)
            {
                throw new cTestsException($"{nameof(cStorableFlagList)}.1");
            }

            if (lFlags.Count != 5)
            {
                throw new cTestsException($"{nameof(cStorableFlagList)}.2");
            }
            if (!lFlags.Contains("A") || !lFlags.Contains("B") || !lFlags.Contains(@"\aNswereD") || lFlags.Contains(kMessageFlag.Draft) || !lFlags.Contains("$forwarded"))
            {
                throw new cTestsException($"{nameof(cStorableFlagList)}.3");
            }

            cStorableFlags  lF1 = new cStorableFlags("a", "A", "b", @"\answered", "\\deleted", kMessageFlag.Forwarded);
            cFetchableFlags lF2 = new cFetchableFlags("a", "A", "b", @"\answered", "\\deleted", kMessageFlag.Recent);
            cStorableFlags  lF3 = new cStorableFlags("a", "b", "\\deleted", kMessageFlag.Forwarded);

            if (!lFlags.Contains(lF1) || lFlags.Contains(lF2) || !lFlags.Contains(lF3))
            {
                throw new cTestsException($"{nameof(cStorableFlagList)}.4");
            }

            lFlags.Remove("A");
            if (lFlags.Count != 4 || lFlags.Contains(lF1) || lFlags.Contains(lF3))
            {
                throw new cTestsException($"{nameof(cStorableFlagList)}.5");
            }

            lFlags.Remove("B", "$forwarded", @"\answered");
            if (lFlags.Count != 1 || lFlags.Contains(lF3))
            {
                throw new cTestsException($"{nameof(cStorableFlagList)}.6");
            }
        }
示例#6
0
 public cFilterFlagsContain(cFetchableFlags pFlags)
 {
     if (pFlags == null || pFlags.Count == 0)
     {
         throw new ArgumentOutOfRangeException(nameof(pFlags));
     }
     Flags = pFlags;
 }
示例#7
0
 public cFilterFlagsContain(params string[] pFlags)
 {
     if (pFlags == null || pFlags.Length == 0)
     {
         throw new ArgumentOutOfRangeException(nameof(pFlags));
     }
     Flags = new cFetchableFlags(pFlags);
 }
 private cMailboxSelectedProperties()
 {
     mBeenSelected            = false;
     mBeenSelectedForUpdate   = false;
     mBeenSelectedReadOnly    = false;
     mUIDNotSticky            = null;
     mMessageFlags            = null;
     mForUpdatePermanentFlags = null;
     mReadOnlyPermanentFlags  = null;
 }
示例#9
0
                public void SetMessageFlags(cFetchableFlags pMessageFlags, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cMailboxCacheItem), nameof(SetMessageFlags), pMessageFlags);

                    if (pMessageFlags == null)
                    {
                        throw new ArgumentNullException(nameof(pMessageFlags));
                    }
                    ZSetSelectedProperties(new cMailboxSelectedProperties(mSelectedProperties, pMessageFlags), lContext);
                }
示例#10
0
                public void SetSelectedProperties(bool pUIDNotSticky, cFetchableFlags pMessageFlags, bool pSelectedForUpdate, cPermanentFlags pPermanentFlags, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cMailboxCacheItem), nameof(SetMessageFlags), pUIDNotSticky, pMessageFlags, pSelectedForUpdate, pPermanentFlags);

                    if (pMessageFlags == null)
                    {
                        throw new ArgumentNullException(nameof(pMessageFlags));
                    }
                    ZSetSelectedProperties(new cMailboxSelectedProperties(mSelectedProperties, pUIDNotSticky, pMessageFlags, pSelectedForUpdate, pPermanentFlags), lContext);
                }
示例#11
0
 public cResponseDataFetch(uint pMSN, fMessageCacheAttributes pAttributes, cFetchableFlags pFlags, cEnvelope pEnvelope, DateTime?pReceived, IList <byte> pRFC822, IList <byte> pRFC822Header, IList <byte> pRFC822Text, uint?pSize, cBodyPart pBody, cBodyPart pBodyStructure, IList <cBody> pBodies, uint?pUID, cHeaderFields pHeaderFields, IDictionary <string, uint> pBinarySizes, ulong?pModSeq)
 {
     MSN           = pMSN;
     Attributes    = pAttributes;
     Flags         = pFlags;
     Envelope      = pEnvelope;
     Received      = pReceived;
     RFC822        = pRFC822 == null ? null : new cBytes(pRFC822);
     RFC822Header  = pRFC822Header == null ? null : new cBytes(pRFC822Header);
     RFC822Text    = pRFC822Text == null ? null : new cBytes(pRFC822Text);
     Size          = pSize;
     Body          = pBody;
     BodyStructure = pBodyStructure;
     Bodies        = new ReadOnlyCollection <cBody>(pBodies);
     UID           = pUID;
     HeaderFields  = pHeaderFields;
     BinarySizes   = new cBinarySizes(pBinarySizes);
     ModSeq        = pModSeq;
 }
        internal cMailboxSelectedProperties(cMailboxSelectedProperties pSelectedProperties, cFetchableFlags pMessageFlags)
        {
            if (pSelectedProperties == null)
            {
                throw new ArgumentNullException(nameof(pSelectedProperties));
            }
            if (pMessageFlags == null)
            {
                throw new ArgumentNullException(nameof(pMessageFlags));
            }

            mBeenSelected            = true;
            mBeenSelectedForUpdate   = pSelectedProperties.mBeenSelectedForUpdate;
            mBeenSelectedReadOnly    = pSelectedProperties.mBeenSelectedReadOnly;
            mUIDNotSticky            = pSelectedProperties.mUIDNotSticky;
            mMessageFlags            = pMessageFlags;
            mForUpdatePermanentFlags = pSelectedProperties.mForUpdatePermanentFlags;
            mReadOnlyPermanentFlags  = pSelectedProperties.mReadOnlyPermanentFlags;
        }
示例#13
0
 /// <inheritdoc cref="FlagsContain(string[])"/>
 public static cFilter FlagsContain(cFetchableFlags pFlags) => new cFilterFlagsContain(pFlags);
示例#14
0
 public cResponseDataFlags(cFetchableFlags pFlags)
 {
     Flags = pFlags;
 }
示例#15
0
                public void Select(iMailboxHandle pMailboxHandle, bool pForUpdate, bool pAccessReadOnly, bool pUIDNotSticky, cFetchableFlags pFlags, cPermanentFlags pPermanentFlags, int pExists, int pRecent, uint pUIDNext, uint pUIDValidity, uint pHighestModSeq, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cMailboxCache), nameof(Select), pMailboxHandle, pForUpdate, pAccessReadOnly, pUIDNotSticky, pFlags, pPermanentFlags, pExists, pRecent, pUIDNext, pUIDValidity, pHighestModSeq);

                    if (mSelectedMailbox != null)
                    {
                        throw new InvalidOperationException();
                    }

                    if (pMailboxHandle == null)
                    {
                        throw new ArgumentNullException(nameof(pMailboxHandle));
                    }
                    if (pFlags == null)
                    {
                        throw new ArgumentNullException(nameof(pFlags));
                    }

                    var lItem = CheckHandle(pMailboxHandle);

                    if (pExists < 0)
                    {
                        throw new ArgumentOutOfRangeException(nameof(pExists));
                    }
                    if (pRecent < 0)
                    {
                        throw new ArgumentOutOfRangeException(nameof(pRecent));
                    }

                    mSelectedMailbox = new cSelectedMailbox(mSynchroniser, lItem, pForUpdate, pAccessReadOnly, pExists, pRecent, pUIDNext, pUIDValidity, pHighestModSeq, lContext);

                    lItem.SetSelectedProperties(pUIDNotSticky, pFlags, pForUpdate, pPermanentFlags, lContext);

                    fMailboxProperties lProperties = fMailboxProperties.isselected;

                    if (pForUpdate)
                    {
                        lProperties |= fMailboxProperties.isselectedforupdate;
                    }
                    if (pAccessReadOnly)
                    {
                        lProperties |= fMailboxProperties.isaccessreadonly;
                    }

                    mSetState(eConnectionState.selected, lContext);
                    mSynchroniser.InvokeMailboxPropertiesChanged(pMailboxHandle, lProperties, lContext);
                    mSynchroniser.InvokePropertyChanged(nameof(cIMAPClient.SelectedMailbox), lContext);
                }