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); }
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); }
/// <summary> /// Gets a list of mailboxes using an IMAP wildcard search. /// </summary> /// <param name="pListMailbox">The search string possibly including IMAP wildcards.</param> /// <param name="pDelimiter">The hierarchy delimiter used in <paramref name="pListMailbox"/>.</param> /// <param name="pDataSets">The sets of data to fetch into cache for the returned mailboxes.</param> /// <returns></returns> /// <remarks> /// <para> /// The IMAP wildcards are; /// <list type="bullet"> /// <item><token>*</token><description>Matches zero or more characters.</description></item> /// <item><token>%</token><description>Matches zero or more characters but not the hierarchy delimiter.</description></item> /// </list> /// </para> /// <para> /// <paramref name="pDelimiter"/> is used in preparing <paramref name="pListMailbox"/> for sending to the server. /// It should be correctly specified. /// The value specified does not affect what character is not matched by the % wildcard. /// </para> /// </remarks> public List <cMailbox> Mailboxes(string pListMailbox, char?pDelimiter, fMailboxCacheDataSets pDataSets) { var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Mailboxes)); var lTask = ZMailboxesAsync(pListMailbox, pDelimiter, pDataSets, lContext); mSynchroniser.Wait(lTask, lContext); return(lTask.Result); }
public frmMailboxes(cIMAPClient pClient, bool pSubscriptions, fMailboxCacheDataSets pDataSets, Action <Form> pDisplaySelectedMailbox, Action <Form> pDisplayUID) { mClient = pClient; mSubscriptions = pSubscriptions; mDataSets = pDataSets; mDisplaySelectedMailbox = pDisplaySelectedMailbox; mDisplayUID = pDisplayUID; InitializeComponent(); }
private void cmdSubscriptions_Click(object sender, EventArgs e) { fMailboxCacheDataSets lDataSets = 0; if (chkMList.Checked) { lDataSets |= fMailboxCacheDataSets.list; } if (chkMLSub.Checked) { lDataSets |= fMailboxCacheDataSets.lsub; } if (chkMStatus.Checked) { lDataSets |= fMailboxCacheDataSets.status; } ZUnnamedChildAdd(new frmMailboxes(mClient, true, lDataSets, ZDisplaySelectedMailbox, ZDisplayUID)); }
/// <summary> /// Asynchronously gets a list of mailboxes using an IMAP wildcard search. /// </summary> /// <param name="pListMailbox">The search string possibly including IMAP wildcards.</param> /// <param name="pDelimiter">The hierarchy delimiter used in <paramref name="pListMailbox"/>.</param> /// <param name="pDataSets">The sets of data to fetch into cache for the returned mailboxes.</param> /// <inheritdoc cref="Mailboxes(string, char?, fMailboxCacheDataSets)" select="returns|remarks"/> public Task <List <cMailbox> > MailboxesAsync(string pListMailbox, char?pDelimiter, fMailboxCacheDataSets pDataSets) { var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(MailboxesAsync)); return(ZMailboxesAsync(pListMailbox, pDelimiter, pDataSets, lContext)); }
// common processing private async Task <List <cMailbox> > ZZMailboxesAsync(string pListMailbox, char?pDelimiter, cMailboxPathPattern pPattern, fMailboxCacheDataSets pDataSets, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZZMailboxesAsync), pListMailbox, pDelimiter, pPattern, pDataSets); if (mDisposed) { throw new ObjectDisposedException(nameof(cIMAPClient)); } var lSession = mSession; if (lSession == null || !lSession.IsConnected) { throw new InvalidOperationException(kInvalidOperationExceptionMessage.NotConnected); } if (pListMailbox == null) { throw new ArgumentNullException(nameof(pListMailbox)); } if (pPattern == null) { throw new ArgumentNullException(nameof(pPattern)); } List <iMailboxHandle> lMailboxHandles; using (var lToken = mCancellationManager.GetToken(lContext)) { var lMC = new cMethodControl(mTimeout, lToken.CancellationToken); var lCapabilities = lSession.Capabilities; bool lLSub = (pDataSets & fMailboxCacheDataSets.lsub) != 0; bool lStatus = (pDataSets & fMailboxCacheDataSets.status) != 0; Task <List <iMailboxHandle> > lListTask; Task lLSubTask; if (lCapabilities.ListExtended) { bool lListStatus = lStatus && lCapabilities.ListStatus; lListTask = lSession.ListExtendedAsync(lMC, eListExtendedSelect.exists, mMailboxReferrals, pListMailbox, pDelimiter, pPattern, lListStatus, lContext); if (lLSub && (mMailboxCacheDataItems & fMailboxCacheDataItems.subscribed) == 0) { if (mMailboxReferrals) { lLSubTask = lSession.ListExtendedAsync(lMC, eListExtendedSelect.subscribed, true, pListMailbox, pDelimiter, pPattern, false, lContext); } else { lLSubTask = lSession.LSubAsync(lMC, pListMailbox, pDelimiter, pPattern, false, lContext); } } else { lLSubTask = null; } lMailboxHandles = await lListTask.ConfigureAwait(false); if (lStatus && !lListStatus) { await ZRequestStatus(lMC, lSession, lMailboxHandles, lContext).ConfigureAwait(false); } } else { if (mMailboxReferrals && lCapabilities.MailboxReferrals) { lListTask = lSession.RListAsync(lMC, pListMailbox, pDelimiter, pPattern, lContext); } else { lListTask = lSession.ListMailboxesAsync(lMC, pListMailbox, pDelimiter, pPattern, lContext); } if (lLSub) { if (mMailboxReferrals && lCapabilities.MailboxReferrals) { lLSubTask = lSession.RLSubAsync(lMC, pListMailbox, pDelimiter, pPattern, false, lContext); } else { lLSubTask = lSession.LSubAsync(lMC, pListMailbox, pDelimiter, pPattern, false, lContext); } } else { lLSubTask = null; } lMailboxHandles = await lListTask.ConfigureAwait(false); if (lStatus) { await ZRequestStatus(lMC, lSession, lMailboxHandles, lContext).ConfigureAwait(false); } } if (lLSubTask != null) { await lLSubTask.ConfigureAwait(false); } } List <cMailbox> lMailboxes = new List <cMailbox>(); foreach (var lMailboxHandle in lMailboxHandles) { lMailboxes.Add(new cMailbox(this, lMailboxHandle)); } return(lMailboxes); }
private Task <List <cMailbox> > ZMailboxesAsync(cNamespaceName pNamespaceName, fMailboxCacheDataSets pDataSets, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZMailboxesAsync), pNamespaceName, pDataSets); if (pNamespaceName == null) { throw new ArgumentNullException(nameof(pNamespaceName)); } string lListMailbox = pNamespaceName.Prefix.Replace('*', '%') + "%"; cMailboxPathPattern lPattern = new cMailboxPathPattern(pNamespaceName.Prefix, "%", pNamespaceName.Delimiter); return(ZZMailboxesAsync(lListMailbox, pNamespaceName.Delimiter, lPattern, pDataSets, lContext)); }
private async Task ZRequestAsync(iMailboxHandle pMailboxHandle, fMailboxCacheDataSets pDataSets, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZRequestAsync), pMailboxHandle, pDataSets); 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 (pMailboxHandle.MailboxName == null) { throw new ArgumentOutOfRangeException(nameof(pMailboxHandle)); } if (pDataSets == 0) { return; } using (var lToken = mCancellationManager.GetToken(lContext)) { var lMC = new cMethodControl(mTimeout, lToken.CancellationToken); if (pDataSets == fMailboxCacheDataSets.status) { await lSession.StatusAsync(lMC, pMailboxHandle, lContext).ConfigureAwait(false); return; } string lListMailbox = pMailboxHandle.MailboxName.Path.Replace('*', '%'); cMailboxPathPattern lPattern = new cMailboxPathPattern(pMailboxHandle.MailboxName.Path, string.Empty, pMailboxHandle.MailboxName.Delimiter); var lCapabilities = lSession.Capabilities; bool lList = (pDataSets & fMailboxCacheDataSets.list) != 0; bool lLSub = (pDataSets & fMailboxCacheDataSets.lsub) != 0; bool lStatus = (pDataSets & fMailboxCacheDataSets.status) != 0; bool lListStatus = lStatus && lCapabilities.ListStatus; List <Task> lTasks = new List <Task>(); if (lCapabilities.ListExtended && (lList || (lLSub && (mMailboxReferrals || lListStatus)))) { if (lList) { lTasks.Add(lSession.ListExtendedAsync(lMC, eListExtendedSelect.exists, mMailboxReferrals, lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, lListStatus, lContext)); if (lLSub) { lTasks.Add(lSession.ListExtendedAsync(lMC, eListExtendedSelect.subscribed, mMailboxReferrals, lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, false, lContext)); } } else if (lLSub) { lTasks.Add(lSession.ListExtendedAsync(lMC, eListExtendedSelect.subscribed, mMailboxReferrals, lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, lListStatus, lContext)); } if (lStatus && !lListStatus) { lTasks.Add(lSession.StatusAsync(lMC, pMailboxHandle, lContext)); } } else { if (lList) { if (mMailboxReferrals && lCapabilities.MailboxReferrals) { lTasks.Add(lSession.RListAsync(lMC, lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, lContext)); } else { lTasks.Add(lSession.ListMailboxesAsync(lMC, lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, lContext)); } } if (lLSub) { if (mMailboxReferrals && lCapabilities.MailboxReferrals) { lTasks.Add(lSession.RLSubAsync(lMC, lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, false, lContext)); } else { lTasks.Add(lSession.LSubAsync(lMC, lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, false, lContext)); } } if (lStatus) { lTasks.Add(lSession.StatusAsync(lMC, pMailboxHandle, lContext)); } } await Task.WhenAll(lTasks).ConfigureAwait(false); } }
internal Task RequestAsync(iMailboxHandle pMailboxHandle, fMailboxCacheDataSets pDataSets) { var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Fetch)); return(ZRequestAsync(pMailboxHandle, pDataSets, lContext)); }
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); }
internal Task <List <cMailbox> > MailboxesAsync(iMailboxHandle pMailboxHandle, fMailboxCacheDataSets pDataSets) { var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(MailboxesAsync)); return(ZMailboxesAsync(pMailboxHandle, pDataSets, lContext)); }
/// <summary> /// Asynchronously gets the subscribed mailboxes in the namespace. /// </summary> /// <param name="pDescend">If <see langword="true"/> all subscribed mailboxes in the namespace are returned, if <see langword="false"/> only mailboxes at the top level of hierarchy are returned.</param> /// <param name="pDataSets">The sets of data to fetch into cache for the returned mailboxes.</param> /// <returns></returns> /// <inheritdoc cref="Subscribed(bool, fMailboxCacheDataSets)" select="returns|remarks"/> public Task <List <cMailbox> > SubscribedAsync(bool pDescend = true, fMailboxCacheDataSets pDataSets = 0) => Client.SubscribedAsync(NamespaceName, pDescend, pDataSets);
/// <summary> /// Asynchronously gets the mailboxes at the top level of hierarchy in the namespace. /// </summary> /// <param name="pDataSets">The sets of data to fetch into cache for the returned mailboxes.</param> /// <returns></returns> public Task <List <cMailbox> > MailboxesAsync(fMailboxCacheDataSets pDataSets = 0) => Client.MailboxesAsync(NamespaceName, pDataSets);
/// <summary> /// Gets the mailboxes at the top level of hierarchy in the namespace. /// </summary> /// <param name="pDataSets">The sets of data to fetch into cache for the returned mailboxes.</param> /// <returns></returns> public List <cMailbox> Mailboxes(fMailboxCacheDataSets pDataSets = 0) => Client.Mailboxes(NamespaceName, pDataSets);
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)); }
internal Task <List <cMailbox> > SubscribedAsync(iMailboxHandle pMailboxHandle, bool pDescend, fMailboxCacheDataSets pDataSets) { var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(SubscribedAsync)); return(ZSubscribedAsync(pMailboxHandle, pDescend, pDataSets, lContext)); }
private Task <List <cMailbox> > ZMailboxesAsync(string pListMailbox, char?pDelimiter, fMailboxCacheDataSets pDataSets, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZMailboxesAsync), pListMailbox, pDelimiter, pDataSets); if (string.IsNullOrEmpty(pListMailbox)) { throw new ArgumentOutOfRangeException(nameof(pListMailbox)); } cMailboxPathPattern lPattern = new cMailboxPathPattern(string.Empty, pListMailbox, pDelimiter); return(ZZMailboxesAsync(pListMailbox, pDelimiter, lPattern, pDataSets, lContext)); }
/// <summary> /// Gets a list subscribed mailboxes using an IMAP wildcard search. /// </summary> /// <param name="pListMailbox">The search string possibly including IMAP wildcards.</param> /// <param name="pDelimiter">The hierarchy delimiter used in <paramref name="pListMailbox"/>.</param> /// <param name="pHasSubscribedChildren">Specifies if mailboxes that are not themselves subscribed, but that have subscribed children, are included in the returned list.</param> /// <param name="pDataSets">The sets of data to fetch into cache for the returned mailboxes.</param> /// <inheritdoc cref="Mailboxes(string, char?, fMailboxCacheDataSets)" select="returns|remarks"/> public List <cMailbox> Subscribed(string pListMailbox, char?pDelimiter, bool pHasSubscribedChildren, fMailboxCacheDataSets pDataSets) { var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(Subscribed)); var lTask = ZSubscribedAsync(pListMailbox, pDelimiter, pHasSubscribedChildren, pDataSets, lContext); mSynchroniser.Wait(lTask, lContext); return(lTask.Result); }
/// <summary> /// Asynchronously gets a list subscribed mailboxes using an IMAP wildcard search. /// </summary> /// <param name="pListMailbox">The search string possibly including IMAP wildcards.</param> /// <param name="pDelimiter">The hierarchy delimiter used in <paramref name="pListMailbox"/>.</param> /// <param name="pHasSubscribedChildren">Specifies if mailboxes that are not themselves subscribed, but that have subscribed children, are included in the returned list.</param> /// <param name="pDataSets">The sets of data to fetch into cache for the returned mailboxes.</param> /// <inheritdoc cref="Mailboxes(string, char?, fMailboxCacheDataSets)" select="returns|remarks"/> public Task <List <cMailbox> > SubscribedAsync(string pListMailbox, char?pDelimiter, bool pHasSubscribedChildren, fMailboxCacheDataSets pDataSets) { var lContext = mRootContext.NewMethod(nameof(cIMAPClient), nameof(SubscribedAsync)); return(ZSubscribedAsync(pListMailbox, pDelimiter, pHasSubscribedChildren, pDataSets, lContext)); }
private async Task <List <cMailbox> > ZMailboxesAsync(iMailboxHandle pMailboxHandle, fMailboxCacheDataSets pDataSets, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZMailboxesAsync), pMailboxHandle, pDataSets); if (pMailboxHandle == null) { throw new ArgumentNullException(nameof(pMailboxHandle)); } if (pMailboxHandle.MailboxName.Delimiter == null) { return(new List <cMailbox>()); } string lListMailbox = pMailboxHandle.MailboxName.Path.Replace('*', '%') + pMailboxHandle.MailboxName.Delimiter + "%"; cMailboxPathPattern lPattern = new cMailboxPathPattern(pMailboxHandle.MailboxName.Path + pMailboxHandle.MailboxName.Delimiter, "%", pMailboxHandle.MailboxName.Delimiter); return(await ZZMailboxesAsync(lListMailbox, pMailboxHandle.MailboxName.Delimiter, lPattern, pDataSets, lContext).ConfigureAwait(false)); }
private Task <List <cMailbox> > ZSubscribedAsync(cNamespaceName pNamespaceName, bool pDescend, fMailboxCacheDataSets pDataSets, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cIMAPClient), nameof(ZSubscribedAsync), pNamespaceName, pDescend, pDataSets); if (pNamespaceName == null) { throw new ArgumentNullException(nameof(pNamespaceName)); } string lWildcard; if (pDescend) { lWildcard = "*"; } else { lWildcard = "%"; } string lListMailbox = pNamespaceName.Prefix.Replace('*', '%') + lWildcard; cMailboxPathPattern lPattern = new cMailboxPathPattern(pNamespaceName.Prefix, lWildcard, pNamespaceName.Delimiter); return(ZZSubscribedAsync(lListMailbox, pNamespaceName.Delimiter, lPattern, !pDescend, pDataSets, lContext)); }