Skip to content

Commit

Permalink
A bit more cleanup to the ImapEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Aug 19, 2023
1 parent 360c070 commit 8b21dd5
Showing 1 changed file with 12 additions and 30 deletions.
42 changes: 12 additions & 30 deletions MailKit/Net/Imap/ImapEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public HashSet<string> AuthenticationMechanisms {
/// </summary>
/// <remarks>
/// The compression algorithms are populated by the
/// <see cref="QueryCapabilitiesAsync"/> method.
/// <see cref="QueryCapabilities"/> and
/// <see cref="QueryCapabilitiesAsync"/> methods.
/// </remarks>
/// <value>The compression algorithms.</value>
public HashSet<string> CompressionAlgorithms {
Expand All @@ -207,7 +208,8 @@ public HashSet<string> CompressionAlgorithms {
/// </summary>
/// <remarks>
/// The threading algorithms are populated by the
/// <see cref="QueryCapabilitiesAsync"/> method.
/// <see cref="QueryCapabilities"/> and
/// <see cref="QueryCapabilitiesAsync"/> methods.
/// </remarks>
/// <value>The threading algorithms.</value>
public HashSet<ThreadingAlgorithm> ThreadingAlgorithms {
Expand Down Expand Up @@ -2433,14 +2435,14 @@ void Iterate ()
/// <summary>
/// Asynchronously iterate the command pipeline.
/// </summary>
async Task IterateAsync (bool doAsync)
async Task IterateAsync ()
{
PopNextCommand ();

current.Status = ImapCommandStatus.Active;

try {
while (await current.StepAsync (doAsync).ConfigureAwait (false)) {
while (await current.StepAsync (true).ConfigureAwait (false)) {
// more literal data to send...
}

Expand All @@ -2461,7 +2463,6 @@ async Task IterateAsync (bool doAsync)
/// Wait for the specified command to finish.
/// </summary>
/// <param name="ic">The IMAP command.</param>
/// <param name="doAsync">Whether or not asynchronous IO methods should be used.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="ic"/> is <c>null</c>.
/// </exception>
Expand All @@ -2484,7 +2485,6 @@ public ImapCommandResponse Run (ImapCommand ic)
/// Wait for the specified command to finish.
/// </summary>
/// <param name="ic">The IMAP command.</param>
/// <param name="doAsync">Whether or not asynchronous IO methods should be used.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="ic"/> is <c>null</c>.
/// </exception>
Expand All @@ -2495,7 +2495,7 @@ public async Task<ImapCommandResponse> RunAsync (ImapCommand ic)

while (ic.Status < ImapCommandStatus.Complete) {
// continue processing commands...
await IterateAsync (true).ConfigureAwait (false);
await IterateAsync ().ConfigureAwait (false);
}

ProcessResponseCodes (ic);
Expand All @@ -2511,19 +2511,14 @@ public async Task<ImapCommandResponse> RunAsync (ImapCommand ic)
/// <exception cref="System.ArgumentNullException">
/// <paramref name="ic"/> is <c>null</c>.
/// </exception>
public async Task<ImapCommandResponse> RunAsync (ImapCommand ic, bool doAsync)
public Task<ImapCommandResponse> RunAsync (ImapCommand ic, bool doAsync)
{
if (ic == null)
throw new ArgumentNullException (nameof (ic));

while (ic.Status < ImapCommandStatus.Complete) {
// continue processing commands...
await IterateAsync (doAsync).ConfigureAwait (false);
}
if (doAsync)
return RunAsync (ic);

ProcessResponseCodes (ic);
var response = Run (ic);

return ic.Response;
return Task.FromResult (response);
}

public IEnumerable<ImapCommand> CreateCommands (CancellationToken cancellationToken, ImapFolder folder, string format, IList<UniqueId> uids, params object[] args)
Expand Down Expand Up @@ -2651,19 +2646,6 @@ public Task<ImapCommandResponse> QueryCapabilitiesAsync (CancellationToken cance
return RunAsync (ic);
}

/// <summary>
/// Queries the capabilities.
/// </summary>
/// <returns>The command result.</returns>
/// <param name="doAsync">Whether or not asynchronous IO methods should be used.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public Task<ImapCommandResponse> QueryCapabilitiesAsync (bool doAsync, CancellationToken cancellationToken)
{
var ic = QueueCommand (cancellationToken, null, "CAPABILITY\r\n");

return RunAsync (ic, doAsync);
}

/// <summary>
/// Cache the specified folder.
/// </summary>
Expand Down

0 comments on commit 8b21dd5

Please sign in to comment.