コード例 #1
0
ファイル: subscribed.cs プロジェクト: bacome/imapclient
        private async Task <List <cMailbox> > ZSubscribedAsync(iMailboxHandle pMailboxHandle, bool pDescend, fMailboxCacheDataSets pDataSets, cTrace.cContext pParentContext)
        {
            var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZSubscribedAsync), pMailboxHandle, pDescend, pDataSets);

            if (pMailboxHandle == null)
            {
                throw new ArgumentNullException(nameof(pMailboxHandle));
            }
            if (pMailboxHandle.MailboxName.Delimiter == null)
            {
                return(new List <cMailbox>());
            }

            string lWildcard;

            if (pDescend)
            {
                lWildcard = "*";
            }
            else
            {
                lWildcard = "%";
            }

            string lListMailbox          = pMailboxHandle.MailboxName.Path.Replace('*', '%') + pMailboxHandle.MailboxName.Delimiter + lWildcard;
            cMailboxPathPattern lPattern = new cMailboxPathPattern(pMailboxHandle.MailboxName.Path + pMailboxHandle.MailboxName.Delimiter, lWildcard, pMailboxHandle.MailboxName.Delimiter);

            return(await ZZSubscribedAsync(lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, !pDescend, pDataSets, lContext).ConfigureAwait(false));
        }
コード例 #2
0
ファイル: rename.cs プロジェクト: bacome/imapclient
        private async Task <cMailbox> ZRenameAsync(iMailboxHandle pMailboxHandle, cMailboxName pMailboxName, cTrace.cContext pParentContext)
        {
            var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZRenameAsync), pMailboxHandle, pMailboxName);

            if (mDisposed)
            {
                throw new ObjectDisposedException(nameof(cIMAPClient));
            }

            var lSession = mSession;

            if (lSession == null || !lSession.IsConnected)
            {
                throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotConnected);
            }

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

            using (var lToken = mCancellationManager.GetToken(lContext))
            {
                var lMC            = new cMethodControl(mTimeout, lToken.CancellationToken);
                var lMailboxHandle = await lSession.RenameAsync(lMC, pMailboxHandle, pMailboxName, lContext).ConfigureAwait(false);

                return(new cMailbox(this, lMailboxHandle));
            }
        }
コード例 #3
0
        internal Task UIDFetchAsync(iMailboxHandle pMailboxHandle, cUID pUID, cSection pSection, eDecodingRequired pDecoding, Stream pStream, cBodyFetchConfiguration pConfiguration)
        {
            // note: if it fails bytes could have been written to the stream
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(UIDFetchAsync));

            return(ZUIDFetchBodyAsync(pMailboxHandle, pUID, pSection, pDecoding, pStream, pConfiguration, lContext));
        }
コード例 #4
0
            public async Task <iMailboxHandle> RenameAsync(cMethodControl pMC, iMailboxHandle pMailboxHandle, cMailboxName pMailboxName, cTrace.cContext pParentContext)
            {
                var lContext = pParentContext.NewMethod(nameof(cSession), nameof(RenameAsync), pMC, pMailboxHandle, pMailboxName);

                if (mDisposed)
                {
                    throw new ObjectDisposedException(nameof(cSession));
                }
                if (_ConnectionState != eConnectionState.notselected && _ConnectionState != eConnectionState.selected)
                {
                    throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotConnected);
                }
                if (pMailboxHandle == null)
                {
                    throw new ArgumentNullException(nameof(pMailboxHandle));
                }
                if (pMailboxName == null)
                {
                    throw new ArgumentNullException(nameof(pMailboxName));
                }

                var lItem = mMailboxCache.CheckHandle(pMailboxHandle);

                if (!mCommandPartFactory.TryAsMailbox(pMailboxName.Path, pMailboxName.Delimiter, out var lMailboxCommandPart, out _))
                {
                    throw new ArgumentOutOfRangeException(nameof(pMailboxName));
                }

                using (var lBuilder = new cCommandDetailsBuilder())
                {
                    if (!_Capabilities.QResync)
                    {
                        lBuilder.Add(await mSelectExclusiveAccess.GetBlockAsync(pMC, lContext).ConfigureAwait(false)); // block select if mailbox-data delivered during the command would be ambiguous
                    }
                    lBuilder.Add(await mMSNUnsafeBlock.GetBlockAsync(pMC, lContext).ConfigureAwait(false));            // this command is msnunsafe

                    lBuilder.Add(kRenameCommandPart, lItem.MailboxNameCommandPart, cCommandPart.Space, lMailboxCommandPart);

                    if (pMailboxHandle.MailboxName.IsInbox)
                    {
                        lItem = null;                                     // renaming the inbox has special behaviour
                    }
                    var lHook = new cRenameCommandHook(mMailboxCache, lItem, pMailboxName);
                    lBuilder.Add(lHook);

                    var lResult = await mPipeline.ExecuteAsync(pMC, lBuilder.EmitCommandDetails(), lContext).ConfigureAwait(false);

                    if (lResult.ResultType == eCommandResultType.ok)
                    {
                        lContext.TraceInformation("rename success");
                        return(lHook.MailboxHandle);
                    }

                    if (lResult.ResultType == eCommandResultType.no)
                    {
                        throw new cUnsuccessfulCompletionException(lResult.ResponseText, 0, lContext);
                    }
                    throw new cProtocolErrorException(lResult, 0, lContext);
                }
            }
コード例 #5
0
        internal void Unsubscribe(iMailboxHandle pMailboxHandle)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Unsubscribe));
            var lTask    = ZUnsubscribeAsync(pMailboxHandle, lContext);

            mSynchroniser.Wait(lTask, lContext);
        }
コード例 #6
0
        internal void Select(iMailboxHandle pMailboxHandle, bool pForUpdate)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Select));
            var lTask    = ZSelectAsync(pMailboxHandle, pForUpdate, lContext);

            mSynchroniser.Wait(lTask, lContext);
        }
コード例 #7
0
        internal void Request(iMailboxHandle pMailboxHandle, fMailboxCacheDataSets pDataSets)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Fetch));
            var lTask    = ZRequestAsync(pMailboxHandle, pDataSets, lContext);

            mSynchroniser.Wait(lTask, lContext);
        }
コード例 #8
0
            private async Task ZUIDStoreAsync(cMethodControl pMC, iMailboxHandle pMailboxHandle, uint pUIDValidity, cStoreFeedbackCollector pFeedbackCollector, eStoreOperation pOperation, cStorableFlags pFlags, ulong?pIfUnchangedSinceModSeq, cUIDStoreFeedback pFeedback, cTrace.cContext pParentContext)
            {
                var lContext = pParentContext.NewMethod(nameof(cSession), nameof(ZStoreAsync), pMC, pMailboxHandle, pUIDValidity, pFeedbackCollector, pOperation, pFlags, pIfUnchangedSinceModSeq, pFeedback);

                // no validation ... all the parameters have been validated already by the cSession by the time we get here

                using (var lBuilder = new cCommandDetailsBuilder())
                {
                    lBuilder.Add(await mSelectExclusiveAccess.GetBlockAsync(pMC, lContext).ConfigureAwait(false)); // block select

                    cSelectedMailbox lSelectedMailbox = mMailboxCache.CheckIsSelectedMailbox(pMailboxHandle, pUIDValidity);
                    if (!lSelectedMailbox.SelectedForUpdate)
                    {
                        throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotSelectedForUpdate);
                    }

                    lBuilder.Add(await mMSNUnsafeBlock.GetBlockAsync(pMC, lContext).ConfigureAwait(false)); // this command is msnunsafe

                    lBuilder.AddUIDValidity(pUIDValidity);                                                  // the command is sensitive to UIDValidity changes

                    // build the command
                    lBuilder.Add(kUIDStoreCommandPartUIDStoreSpace, new cTextCommandPart(cSequenceSet.FromUInts(pFeedbackCollector.UInts)), cCommandPart.Space);
                    if (pIfUnchangedSinceModSeq != null)
                    {
                        lBuilder.Add(kStoreCommandPartLParenUnchangedSinceSpace, new cTextCommandPart(pIfUnchangedSinceModSeq.Value), kStoreCommandPartRParenSpace);
                    }
                    lBuilder.Add(pOperation, pFlags);

                    // add the hook
                    var lHook = new cCommandHookStore(pFeedbackCollector, pFeedback, lSelectedMailbox);
                    lBuilder.Add(lHook);

                    // submit the command
                    var lResult = await mPipeline.ExecuteAsync(pMC, lBuilder.EmitCommandDetails(), lContext).ConfigureAwait(false);

                    // note: the base spec states that non-existent UIDs are ignored without comment => a NO from a UID STORE is unexpected

                    if (lResult.ResultType == eCommandResultType.ok)
                    {
                        lContext.TraceInformation("uid store success");
                        return;
                    }

                    fCapabilities lTryIgnoring;
                    if (pIfUnchangedSinceModSeq == null)
                    {
                        lTryIgnoring = 0;
                    }
                    else
                    {
                        lTryIgnoring = fCapabilities.condstore;
                    }

                    if (lResult.ResultType == eCommandResultType.no)
                    {
                        throw new cUnsuccessfulCompletionException(lResult.ResponseText, lTryIgnoring, lContext);
                    }
                    throw new cProtocolErrorException(lResult, lTryIgnoring, lContext);
                }
            }
コード例 #9
0
ファイル: expunge.cs プロジェクト: bacome/imapclient
        internal void Expunge(iMailboxHandle pMailboxHandle, bool pAndUnselect)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Expunge));
            var lTask    = ZExpungeAsync(pMailboxHandle, pAndUnselect, lContext);

            mSynchroniser.Wait(lTask, lContext);
        }
コード例 #10
0
 public cCommandHookSelect(cMailboxCache pMailboxCache, cCapabilities pCapabilities, iMailboxHandle pMailboxHandle, bool pForUpdate)
 {
     mMailboxCache  = pMailboxCache ?? throw new ArgumentNullException(nameof(pMailboxCache));
     mCapabilities  = pCapabilities ?? throw new ArgumentNullException(nameof(pCapabilities));
     mMailboxHandle = pMailboxHandle ?? throw new ArgumentNullException(nameof(pMailboxHandle));
     mForUpdate     = pForUpdate;
 }
コード例 #11
0
        private async Task ZSelectAsync(iMailboxHandle pMailboxHandle, bool pForUpdate, cTrace.cContext pParentContext)
        {
            var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZSelectAsync), pMailboxHandle, pForUpdate);

            if (mDisposed)
            {
                throw new ObjectDisposedException(nameof(cIMAPClient));
            }

            var lSession = mSession;

            if (lSession == null || !lSession.IsConnected)
            {
                throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotConnected);
            }

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

            using (var lToken = mCancellationManager.GetToken(lContext))
            {
                var lMC = new cMethodControl(mTimeout, lToken.CancellationToken);
                if (pForUpdate)
                {
                    await lSession.SelectAsync(lMC, pMailboxHandle, lContext).ConfigureAwait(false);
                }
                else
                {
                    await lSession.ExamineAsync(lMC, pMailboxHandle, lContext).ConfigureAwait(false);
                }
            }
        }
コード例 #12
0
        internal cCopyFeedback Copy(iMessageHandle pSourceMessageHandle, iMailboxHandle pDestinationMailboxHandle)
        {
            var lContext = mRootContext.NewMethodV(nameof(cIMAPClient), nameof(Copy), 1);
            var lTask    = ZCopyAsync(cMessageHandleList.FromMessageHandle(pSourceMessageHandle), pDestinationMailboxHandle, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lTask.Result);
        }
コード例 #13
0
ファイル: rename.cs プロジェクト: bacome/imapclient
        internal cMailbox Rename(iMailboxHandle pMailboxHandle, cMailboxName pMailboxName)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Rename));
            var lTask    = ZRenameAsync(pMailboxHandle, pMailboxName, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lTask.Result);
        }
コード例 #14
0
ファイル: uidcopy.cs プロジェクト: bacome/imapclient
        internal cCopyFeedback UIDCopy(iMailboxHandle pSourceMailboxHandle, IEnumerable <cUID> pSourceUIDs, iMailboxHandle pDestinationMailboxHandle)
        {
            var lContext = mRootContext.NewMethodV(nameof(cIMAPClient), nameof(UIDCopy), 2);
            var lTask    = ZUIDCopyAsync(pSourceMailboxHandle, cUIDList.FromUIDs(pSourceUIDs), pDestinationMailboxHandle, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lTask.Result);
        }
コード例 #15
0
ファイル: subscribed.cs プロジェクト: bacome/imapclient
        internal List <cMailbox> Subscribed(iMailboxHandle pMailboxHandle, bool pDescend, fMailboxCacheDataSets pDataSets)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Subscribed));
            var lTask    = ZSubscribedAsync(pMailboxHandle, pDescend, pDataSets, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lTask.Result);
        }
コード例 #16
0
        internal List <cMessage> Messages(iMailboxHandle pMailboxHandle, cFilter pFilter, cSort pSort, cMessageCacheItems pItems, cMessageFetchConfiguration pConfiguration)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Messages));
            var lTask    = ZMessagesAsync(pMailboxHandle, pFilter, pSort, pItems, pConfiguration, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lTask.Result);
        }
コード例 #17
0
        internal List <cMessage> Messages(iMailboxHandle pMailboxHandle, IEnumerable <cUID> pUIDs, cMessageCacheItems pItems, cCacheItemFetchConfiguration pConfiguration)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Messages));
            var lTask    = ZUIDFetchCacheItemsAsync(pMailboxHandle, cUIDList.FromUIDs(pUIDs), pItems, pConfiguration, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lTask.Result);
        }
コード例 #18
0
        internal cMessageHandleList SetUnseenCount(iMailboxHandle pMailboxHandle)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Messages));
            var lTask    = ZSetUnseenCountAsync(pMailboxHandle, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lTask.Result);
        }
コード例 #19
0
ファイル: mailboxes.cs プロジェクト: bacome/imapclient
        internal List <cMailbox> Mailboxes(iMailboxHandle pMailboxHandle, fMailboxCacheDataSets pDataSets)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Mailboxes));
            var lTask    = ZMailboxesAsync(pMailboxHandle, pDataSets, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lTask.Result);
        }
コード例 #20
0
ファイル: create.cs プロジェクト: bacome/imapclient
                public override void CommandCompleted(cCommandResult pResult, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cCreateCommandHook), nameof(CommandCompleted), pResult);

                    if (pResult.ResultType == eCommandResultType.ok)
                    {
                        MailboxHandle = mCache.Create(mMailboxName, lContext);
                    }
                }
コード例 #21
0
ファイル: uidstore.cs プロジェクト: bacome/imapclient
        internal async Task <cUIDStoreFeedback> UIDStoreAsync(iMailboxHandle pMailboxHandle, IEnumerable <cUID> pUIDs, eStoreOperation pOperation, cStorableFlags pFlags, ulong?pIfUnchangedSinceModSeq)
        {
            var lContext  = mRootContext.NewMethod(nameof(cIMAPClient), nameof(UIDStore));
            var lFeedback = new cUIDStoreFeedback(pUIDs, pOperation, pFlags);

            await ZUIDStoreAsync(pMailboxHandle, lFeedback, pOperation, pFlags, pIfUnchangedSinceModSeq, lContext).ConfigureAwait(false);

            return(lFeedback);
        }
コード例 #22
0
ファイル: uidstore.cs プロジェクト: bacome/imapclient
        internal cUIDStoreFeedback UIDStore(iMailboxHandle pMailboxHandle, IEnumerable <cUID> pUIDs, eStoreOperation pOperation, cStorableFlags pFlags, ulong?pIfUnchangedSinceModSeq)
        {
            var lContext  = mRootContext.NewMethod(nameof(cIMAPClient), nameof(UIDStore));
            var lFeedback = new cUIDStoreFeedback(pUIDs, pOperation, pFlags);
            var lTask     = ZUIDStoreAsync(pMailboxHandle, lFeedback, pOperation, pFlags, pIfUnchangedSinceModSeq, lContext);

            mSynchroniser.Wait(lTask, lContext);
            return(lFeedback);
        }
コード例 #23
0
        private async Task ZUIDFetchBodyAsync(iMailboxHandle pMailboxHandle, cUID pUID, cSection pSection, eDecodingRequired pDecoding, Stream pStream, cBodyFetchConfiguration pConfiguration, cTrace.cContext pParentContext)
        {
            var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZUIDFetchBodyAsync), pMailboxHandle, pUID, pSection, pDecoding);

            if (mDisposed)
            {
                throw new ObjectDisposedException(nameof(cIMAPClient));
            }

            var lSession = mSession;

            if (lSession == null || lSession.ConnectionState != eConnectionState.selected)
            {
                throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotSelected);
            }

            if (pMailboxHandle == null)
            {
                throw new ArgumentNullException(nameof(pMailboxHandle));
            }
            if (pUID == null)
            {
                throw new ArgumentNullException(nameof(pUID));
            }
            if (pSection == null)
            {
                throw new ArgumentNullException(nameof(pSection));
            }
            if (pStream == null)
            {
                throw new ArgumentNullException(nameof(pStream));
            }

            if (!pStream.CanWrite)
            {
                throw new ArgumentOutOfRangeException(nameof(pStream));
            }

            if (pConfiguration == null)
            {
                using (var lToken = mCancellationManager.GetToken(lContext))
                {
                    var lMC         = new cMethodControl(mTimeout, lToken.CancellationToken);
                    var lProgress   = new cProgress();
                    var lWriteSizer = new cBatchSizer(mFetchBodyWriteConfiguration);
                    await lSession.UIDFetchBodyAsync(lMC, pMailboxHandle, pUID, pSection, pDecoding, pStream, lProgress, lWriteSizer, lContext).ConfigureAwait(false);
                }
            }
            else
            {
                var lMC         = new cMethodControl(pConfiguration.Timeout, pConfiguration.CancellationToken);
                var lProgress   = new cProgress(mSynchroniser, pConfiguration.Increment);
                var lWriteSizer = new cBatchSizer(pConfiguration.Write ?? mFetchBodyWriteConfiguration);
                await lSession.UIDFetchBodyAsync(lMC, pMailboxHandle, pUID, pSection, pDecoding, pStream, lProgress, lWriteSizer, lContext).ConfigureAwait(false);
            }
        }
コード例 #24
0
 public cMailboxCacheItem CheckHandle(iMailboxHandle pMailboxHandle)
 {
     if (!(pMailboxHandle is cMailboxCacheItem lItem))
     {
         throw new ArgumentOutOfRangeException(nameof(pMailboxHandle));
     }
     if (!ReferenceEquals(lItem.MailboxCache, this))
     {
         throw new ArgumentOutOfRangeException(nameof(pMailboxHandle));
     }
     return(lItem);
 }
コード例 #25
0
ファイル: store.cs プロジェクト: bacome/imapclient
            public async Task UIDStoreAsync(cMethodControl pMC, iMailboxHandle pMailboxHandle, cUIDStoreFeedback pFeedback, eStoreOperation pOperation, cStorableFlags pFlags, ulong?pIfUnchangedSinceModSeq, cTrace.cContext pParentContext)
            {
                var lContext = pParentContext.NewMethod(nameof(cSession), nameof(UIDStoreAsync), pMC, pMailboxHandle, pFeedback, pOperation, pFlags, pIfUnchangedSinceModSeq);

                if (mDisposed)
                {
                    throw new ObjectDisposedException(nameof(cSession));
                }
                if (_ConnectionState != eConnectionState.selected)
                {
                    throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotSelected);
                }

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

                if (pFeedback.Count == 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(pFeedback));
                }

                if (pIfUnchangedSinceModSeq == 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(pIfUnchangedSinceModSeq));
                }
                if (pIfUnchangedSinceModSeq != null && !_Capabilities.CondStore)
                {
                    throw new InvalidOperationException(kInvalidOperationExceptionMessage.CondStoreNotInUse);
                }

                uint lUIDValidity = pFeedback[0].UID.UIDValidity;

                cSelectedMailbox lSelectedMailbox = mMailboxCache.CheckIsSelectedMailbox(pMailboxHandle, lUIDValidity); // to be repeated inside the select lock

                if (!lSelectedMailbox.SelectedForUpdate)
                {
                    throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotSelectedForUpdate);                                      // to be repeated inside the select lock
                }
                cStoreFeedbackCollector lFeedbackCollector = new cStoreFeedbackCollector(pFeedback);

                await ZUIDStoreAsync(pMC, pMailboxHandle, lUIDValidity, lFeedbackCollector, pOperation, pFlags, pIfUnchangedSinceModSeq, pFeedback, lContext).ConfigureAwait(false);
            }
コード例 #26
0
ファイル: uidstore.cs プロジェクト: bacome/imapclient
        private async Task ZUIDStoreAsync(iMailboxHandle pMailboxHandle, cUIDStoreFeedback pFeedback, eStoreOperation pOperation, cStorableFlags pFlags, ulong?pIfUnchangedSinceModSeq, cTrace.cContext pParentContext)
        {
            var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZUIDStoreAsync), pFeedback, pOperation, pFlags, pIfUnchangedSinceModSeq);

            if (mDisposed)
            {
                throw new ObjectDisposedException(nameof(cIMAPClient));
            }

            var lSession = mSession;

            if (lSession == null || lSession.SelectedMailboxDetails?.SelectedForUpdate != true)
            {
                throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotSelectedForUpdate);
            }

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

            if (pIfUnchangedSinceModSeq == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pIfUnchangedSinceModSeq));
            }
            if (pIfUnchangedSinceModSeq != null && !lSession.Capabilities.CondStore)
            {
                throw new InvalidOperationException(kInvalidOperationExceptionMessage.CondStoreNotInUse);
            }

            if (pFeedback.Count == 0)
            {
                return;
            }
            // it is valid to add or remove zero flags according to the ABNF (!)

            using (var lToken = mCancellationManager.GetToken(lContext))
            {
                var lMC = new cMethodControl(mTimeout, lToken.CancellationToken);
                await lSession.UIDStoreAsync(lMC, pMailboxHandle, pFeedback, pOperation, pFlags, pIfUnchangedSinceModSeq, lContext).ConfigureAwait(false);
            }
        }
コード例 #27
0
            public void InvokeMailboxMessageDelivery(iMailboxHandle pMailboxHandle, cMessageHandleList pMessageHandles, cTrace.cContext pParentContext)
            {
                if (MailboxMessageDelivery == null)
                {
                    return;                                 // pre-check for efficiency only
                }
                var lContext = pParentContext.NewMethod(nameof(cCallbackSynchroniser), nameof(InvokeMailboxMessageDelivery), pMailboxHandle, pMessageHandles);

                if (mDisposed)
                {
                    throw new ObjectDisposedException(nameof(cCallbackSynchroniser));
                }
                ZInvokeAndForget(new cMailboxMessageDeliveryEventArgs(pMailboxHandle, pMessageHandles), lContext);
                // NOTE the event is fired by parallel code in the ZInvokeEvents routine: when adding an event you must put code there also
            }
コード例 #28
0
        internal async Task <cMessage> MessageAsync(iMailboxHandle pMailboxHandle, cUID pUID, cMessageCacheItems pItems)
        {
            var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(MessageAsync));
            var lResult  = await ZUIDFetchCacheItemsAsync(pMailboxHandle, cUIDList.FromUID(pUID), pItems, null, lContext).ConfigureAwait(false);

            if (lResult.Count == 0)
            {
                return(null);
            }
            if (lResult.Count == 1)
            {
                return(lResult[0]);
            }
            throw new cInternalErrorException(lContext);
        }
コード例 #29
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);
                }
コード例 #30
0
 public cSelectedMailbox CheckIsSelectedMailbox(iMailboxHandle pMailboxHandle, uint?pUIDValidity)
 {
     if (pMailboxHandle == null)
     {
         throw new ArgumentNullException(nameof(pMailboxHandle));
     }
     if (mSelectedMailbox == null || !ReferenceEquals(pMailboxHandle, mSelectedMailbox.MailboxHandle))
     {
         throw new InvalidOperationException(kInvalidOperationExceptionMessage.MailboxNotSelected);
     }
     if (pUIDValidity != null && pUIDValidity != mSelectedMailbox.MessageCache.UIDValidity)
     {
         throw new cUIDValidityException();
     }
     return(mSelectedMailbox);
 }