Esempio n. 1
0
                public override void ProcessTextCode(eResponseTextContext pTextContext, cByteList pCode, cByteList pArguments, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cCommandHookStore), nameof(ProcessTextCode), pTextContext, pCode, pArguments);

                    if (pTextContext == eResponseTextContext.success || pTextContext == eResponseTextContext.failure)
                    {
                        if (pCode.Equals(kModified))
                        {
                            if (pArguments != null)
                            {
                                cBytesCursor lCursor = new cBytesCursor(pArguments);

                                if (lCursor.GetSequenceSet(out var lSequenceSet) && lCursor.Position.AtEnd && cUIntList.TryConstruct(lSequenceSet, mSelectedMailbox.MessageCache.Count, true, out var lUInts))
                                {
                                    foreach (var lUInt in lUInts)
                                    {
                                        if (!mFeedbackCollector.WasNotUnchangedSince(lUInt))
                                        {
                                            lContext.TraceWarning("likely malformed modified response: message number not recognised: ", lUInt);
                                            return;
                                        }
                                    }

                                    return;
                                }
                            }

                            lContext.TraceWarning("likely malformed modified response");
                        }
                    }
                }
Esempio n. 2
0
                public override void ProcessTextCode(eResponseTextContext pTextContext, cByteList pCode, cByteList pArguments, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cCommandHookInitial), nameof(ProcessTextCode), pTextContext, pCode, pArguments);

                    if (pTextContext == eResponseTextContext.greetingok || pTextContext == eResponseTextContext.greetingpreauth || pTextContext == eResponseTextContext.success)
                    {
                        if (pCode.Equals(kCapability))
                        {
                            if (pArguments != null)
                            {
                                cBytesCursor lCursor = new cBytesCursor(pArguments);

                                if (lCursor.ProcessCapability(out var lCapabilities, out var lAuthenticationMechanisms, lContext) && lCursor.Position.AtEnd)
                                {
                                    lContext.TraceVerbose("received capabilities: {0} {1}", lCapabilities, lAuthenticationMechanisms);
                                    Capabilities             = lCapabilities;
                                    AuthenticationMechanisms = lAuthenticationMechanisms;
                                    return;
                                }
                            }

                            lContext.TraceWarning("likely malformed capability response");
                        }
                    }
                }
Esempio n. 3
0
                public override void ProcessTextCode(eResponseTextContext pTextContext, cByteList pCode, cByteList pArguments, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cCommandHookCopy), nameof(ProcessTextCode), pTextContext, pCode, pArguments);

                    if (pTextContext == eResponseTextContext.success && pCode.Equals(kCopyUID))
                    {
                        if (pArguments != null)
                        {
                            cBytesCursor lCursor = new cBytesCursor(pArguments);

                            if (lCursor.GetNZNumber(out _, out var lDestinationUIDValidity) &&
                                lCursor.SkipByte(cASCII.SPACE) &&
                                lCursor.GetSequenceSet(out var lSourceUIDSet) &&
                                lCursor.SkipByte(cASCII.SPACE) &&
                                lCursor.GetSequenceSet(out var lCreatedUIDSet) &&
                                lCursor.Position.AtEnd &&
                                cUIntList.TryConstruct(lSourceUIDSet, -1, false, out var lSourceUIDs) &&
                                cUIntList.TryConstruct(lCreatedUIDSet, -1, false, out var lCreatedUIDs) &&
                                lSourceUIDs.Count == lCreatedUIDs.Count)
                            {
                                Feedback = new cCopyFeedback(mSourceUIDValidity, lSourceUIDs, lDestinationUIDValidity, lCreatedUIDs);
                                return;
                            }
                        }

                        lContext.TraceWarning("likely malformed copyuid response");
                    }
                }
Esempio n. 4
0
                public void ProcessTextCode(eResponseTextContext pTextContext, cResponseData pData, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cSelectedMailbox), nameof(ProcessTextCode), pTextContext, pData);

                    switch (pData)
                    {
                    case cResponseDataPermanentFlags lPermanentFlags:

                        mMailboxCacheItem.SetPermanentFlags(mSelectedForUpdate, lPermanentFlags.Flags, lContext);
                        return;

                    case cResponseDataUIDValidity lUIDValidity:

                        mCache = new cSelectedMailboxCache(mCache, lUIDValidity.UIDValidity, lContext);
                        return;

                    case cResponseDataAccess lAccess:

                        if (lAccess.ReadOnly != mAccessReadOnly)
                        {
                            mAccessReadOnly = lAccess.ReadOnly;
                            mSynchroniser.InvokeMailboxPropertiesChanged(mMailboxCacheItem, fMailboxProperties.isaccessreadonly, lContext);
                        }

                        return;
                    }

                    mCache.ProcessTextCode(pTextContext, pData, lContext);
                }
Esempio n. 5
0
                public void ProcessTextCode(eResponseTextContext pTextContext, cResponseData pData, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cMailboxCache), nameof(ProcessTextCode), pTextContext, pData);

                    if (mSelectedMailbox != null)
                    {
                        mSelectedMailbox.ProcessTextCode(pTextContext, pData, lContext);
                    }
                }
Esempio n. 6
0
                    public void ProcessTextCode(eResponseTextContext pTextContext, cByteList pCode, cByteList pArguments, cTrace.cContext pParentContext)
                    {
                        var lContext = pParentContext.NewMethod(nameof(cActiveCommands), nameof(ProcessTextCode), pTextContext, pCode, pArguments);

                        foreach (var lCommand in this)
                        {
                            lCommand.Hook.ProcessTextCode(pTextContext, pCode, pArguments, lContext);
                        }
                    }
Esempio n. 7
0
                    public void ProcessTextCode(eResponseTextContext pTextContext, cResponseData pData, cTrace.cContext pParentContext)
                    {
                        var lContext = pParentContext.NewMethod(nameof(cActiveCommands), nameof(ProcessTextCode), pTextContext, pData);

                        foreach (var lCommand in this)
                        {
                            lCommand.Hook.ProcessTextCode(pTextContext, pData, lContext);
                        }
                    }
Esempio n. 8
0
                public void ProcessTextCode(eResponseTextContext pTextContext, cResponseData pData, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cSelectedMailboxCache), nameof(ProcessTextCode), pTextContext, pData);

                    if (pData is cResponseDataUIDNext lUIDNext)
                    {
                        ZUIDNext(lUIDNext.UIDNext, lContext);
                    }
                    else if (pTextContext == eResponseTextContext.success && pData is cResponseDataHighestModSeq lHighestModSeq)
                    {
                        ZHighestModSeq(lHighestModSeq.HighestModSeq, lContext);
                    }
                }
Esempio n. 9
0
            public void InvokeResponseText(eResponseTextContext pTextContext, cResponseText pResponseText, cTrace.cContext pParentContext)
            {
                if (ResponseText == null)
                {
                    return;                       // pre-check for efficiency only
                }
                var lContext = pParentContext.NewMethod(nameof(cCallbackSynchroniser), nameof(InvokeResponseText), pTextContext, pResponseText);

                if (mDisposed)
                {
                    throw new ObjectDisposedException(nameof(cCallbackSynchroniser));
                }
                ZInvokeAndForget(new cResponseTextEventArgs(pTextContext, pResponseText), lContext);
                // NOTE the event is fired by parallel code in the ZInvokeEvents routine: when adding an event you must put code there also
            }
Esempio n. 10
0
                public override void ProcessTextCode(eResponseTextContext pTextContext, cResponseData pData, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cCommandHookSelect), nameof(ProcessTextCode), pTextContext, pData);

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

                    if (pTextContext == eResponseTextContext.information)
                    {
                        switch (pData)
                        {
                        case cResponseDataPermanentFlags lFlags:

                            mPermanentFlags = lFlags.Flags;
                            return;

                        case cResponseDataUIDNext lUIDNext:

                            mUIDNext = lUIDNext.UIDNext;
                            return;

                        case cResponseDataUIDValidity lUIDValidity:

                            mUIDValidity = lUIDValidity.UIDValidity;
                            return;

                        case cResponseDataHighestModSeq lHighestModSeq:

                            mHighestModSeq = lHighestModSeq.HighestModSeq;
                            return;
                        }
                    }
                    else if (pTextContext == eResponseTextContext.success && pData is cResponseDataAccess lAccess)
                    {
                        mAccessReadOnly = lAccess.ReadOnly;
                    }
                }
Esempio n. 11
0
                public override void ProcessTextCode(eResponseTextContext pTextContext, cByteList pCode, cByteList pArguments, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cCommandHookSelect), nameof(ProcessTextCode), pTextContext, pCode, pArguments);

                    if (mMailboxCache.SelectedMailboxDetails == null)
                    {
                        if (pTextContext == eResponseTextContext.information && pCode.Equals(kNoModSeq) && pArguments == null)
                        {
                            mHighestModSeq = 0;
                        }
                        else if (pTextContext == eResponseTextContext.warning && pCode.Equals(kUIDNotSticky) && pArguments == null)
                        {
                            mUIDNotSticky = true;
                        }
                    }
                    else
                    {
                        // the spec (rfc 7162) doesn't specify where this comes - although the only example is of an untagged OK
                        if (pCode.Equals(kClosed) && pArguments == null)
                        {
                            mMailboxCache.Unselect(lContext);
                        }
                    }
                }
Esempio n. 12
0
                    public cResponseText Process(eResponseTextContext pTextContext, cBytesCursor pCursor, iTextCodeProcessor pTextCodeProcessor, cTrace.cContext pParentContext)
                    {
                        var lContext = pParentContext.NewMethod(nameof(cResponseTextProcessor), nameof(Process), pTextContext);

                        cResponseText lResponseText;

                        var lBookmarkBeforeLBRACET = pCursor.Position;

                        if (pCursor.SkipByte(cASCII.LBRACKET))
                        {
                            if (ZTryGetCodeAndArguments(pCursor, out var lCodeBytes, out var lArgumentsBytes))
                            {
                                string lText = pCursor.GetRestAsString();

                                if (lArgumentsBytes == null)
                                {
                                    eResponseTextCode lCode;

                                    if (lCodeBytes.Equals(kAlert))
                                    {
                                        lCode = eResponseTextCode.alert;
                                    }
                                    else if (lCodeBytes.Equals(kParse))
                                    {
                                        lCode = eResponseTextCode.parse;
                                    }
                                    else if (lCodeBytes.Equals(kTryCreate))
                                    {
                                        lCode = eResponseTextCode.trycreate;
                                    }
                                    else if (lCodeBytes.Equals(kUnavailable))
                                    {
                                        lCode = eResponseTextCode.unavailable;
                                    }
                                    else if (lCodeBytes.Equals(kAuthenticationFailed))
                                    {
                                        lCode = eResponseTextCode.authenticationfailed;
                                    }
                                    else if (lCodeBytes.Equals(kAuthorizationFailed))
                                    {
                                        lCode = eResponseTextCode.authorizationfailed;
                                    }
                                    else if (lCodeBytes.Equals(kExpired))
                                    {
                                        lCode = eResponseTextCode.expired;
                                    }
                                    else if (lCodeBytes.Equals(kPrivacyRequired))
                                    {
                                        lCode = eResponseTextCode.privacyrequired;
                                    }
                                    else if (lCodeBytes.Equals(kContactAdmin))
                                    {
                                        lCode = eResponseTextCode.contactadmin;
                                    }
                                    else if (lCodeBytes.Equals(kNoPerm))
                                    {
                                        lCode = eResponseTextCode.noperm;
                                    }
                                    else if (lCodeBytes.Equals(kInUse))
                                    {
                                        lCode = eResponseTextCode.inuse;
                                    }
                                    else if (lCodeBytes.Equals(kExpungeIssued))
                                    {
                                        lCode = eResponseTextCode.expungeissued;
                                    }
                                    else if (lCodeBytes.Equals(kCorruption))
                                    {
                                        lCode = eResponseTextCode.corruption;
                                    }
                                    else if (lCodeBytes.Equals(kServerBug))
                                    {
                                        lCode = eResponseTextCode.serverbug;
                                    }
                                    else if (lCodeBytes.Equals(kClientBug))
                                    {
                                        lCode = eResponseTextCode.clientbug;
                                    }
                                    else if (lCodeBytes.Equals(kCannot))
                                    {
                                        lCode = eResponseTextCode.cannot;
                                    }
                                    else if (lCodeBytes.Equals(kLimit))
                                    {
                                        lCode = eResponseTextCode.limit;
                                    }
                                    else if (lCodeBytes.Equals(kOverQuota))
                                    {
                                        lCode = eResponseTextCode.overquota;
                                    }
                                    else if (lCodeBytes.Equals(kAlreadyExists))
                                    {
                                        lCode = eResponseTextCode.alreadyexists;
                                    }
                                    else if (lCodeBytes.Equals(kNonExistent))
                                    {
                                        lCode = eResponseTextCode.nonexistent;
                                    }
                                    else if (lCodeBytes.Equals(kBadCharset))
                                    {
                                        lCode = eResponseTextCode.badcharset;
                                    }
                                    else if (lCodeBytes.Equals(kUseAttr))
                                    {
                                        lCode = eResponseTextCode.useattr;
                                    }
                                    else if (lCodeBytes.Equals(kUnknownCTE))
                                    {
                                        lCode = eResponseTextCode.unknowncte;
                                    }
                                    else
                                    {
                                        lCode = eResponseTextCode.other;
                                        ZProcess(pTextContext, lCodeBytes, null, pTextCodeProcessor, lContext);
                                    }

                                    lResponseText = new cResponseText(lCodeBytes, lCode, lText);
                                }
                                else
                                {
                                    eResponseTextCode lCode;
                                    cStrings          lArguments;

                                    if (lCodeBytes.Equals(kBadCharset))
                                    {
                                        lCode      = eResponseTextCode.badcharset;
                                        lArguments = ZProcessCharsets(lArgumentsBytes);
                                    }
                                    else if (lCodeBytes.Equals(kReferral))
                                    {
                                        lCode      = eResponseTextCode.referral;
                                        lArguments = ZProcessReferrals(lArgumentsBytes, lContext);
                                    }
                                    else
                                    {
                                        lCode      = eResponseTextCode.other;
                                        lArguments = null;
                                        ZProcess(pTextContext, lCodeBytes, lArgumentsBytes, pTextCodeProcessor, lContext);
                                    }

                                    lResponseText = new cResponseText(lCodeBytes, lArgumentsBytes, lCode, lArguments, lText);
                                }
                            }
                            else
                            {
                                lContext.TraceWarning("likely badly formed response text code");
                                pCursor.Position = lBookmarkBeforeLBRACET;
                                lResponseText    = new cResponseText(pCursor.GetRestAsString());
                            }
                        }
Esempio n. 13
0
 internal cResponseTextEventArgs(eResponseTextContext pContext, cResponseText pText)
 {
     Context = pContext;
     Text    = pText;
 }
Esempio n. 14
0
 public virtual void ProcessTextCode(eResponseTextContext pTextContext, cByteList pCode, cByteList pArguments, cTrace.cContext pParentContext)
 {
 }
Esempio n. 15
0
 public virtual void ProcessTextCode(eResponseTextContext pTextContext, cResponseData pData, cTrace.cContext pParentContext)
 {
 }