Skip to content

Commit

Permalink
more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Dec 27, 2023
1 parent 9df57f7 commit 7df2cfe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
2 changes: 1 addition & 1 deletion MailKit/Net/Imap/AsyncImapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ public async Task DisableNotifyAsync (CancellationToken cancellationToken = defa

await engine.RunAsync (ic).ConfigureAwait (false);

ProcessDisableNotifyResponse (ic);
ProcessNotifyResponse (ic, false);
}

/// <summary>
Expand Down
9 changes: 1 addition & 8 deletions MailKit/Net/Imap/ImapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2078,13 +2078,6 @@ ImapCommand QueueDisableNotifyCommand (CancellationToken cancellationToken)
return ic;
}

void ProcessDisableNotifyResponse (ImapCommand ic)
{
ic.ThrowIfNotOk ("NOTIFY");

engine.NotifySelectedNewExpunge = false;
}

/// <summary>
/// Disable any previously requested notification events from the IMAP server.
/// </summary>
Expand Down Expand Up @@ -2124,7 +2117,7 @@ public void DisableNotify (CancellationToken cancellationToken = default)

engine.Run (ic);

ProcessDisableNotifyResponse (ic);
ProcessNotifyResponse (ic, false);
}

#endregion
Expand Down
37 changes: 11 additions & 26 deletions MailKit/Net/Imap/ImapFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5295,12 +5295,7 @@ ImapCommand QueueGetIndexesCommand (IList<UniqueId> uids, CancellationToken canc

IList<int> ProcessGetIndexesResponse (ImapCommand ic)
{
var results = (SearchResults) ic.UserData;

ProcessResponseCodes (ic, null);

ic.ThrowIfNotOk ("SEARCH");

var results = ProcessSearchResponse (ic);
var indexes = new int[results.UniqueIds.Count];
for (int i = 0; i < indexes.Length; i++)
indexes[i] = (int) results.UniqueIds[i].Id - 1;
Expand Down Expand Up @@ -5334,12 +5329,8 @@ void ValidateArguments (IList<UniqueId> uids, IMailFolder destination)
CheckValidDestination (destination);
}

void ProcessCopyToResponse (ImapCommand ic, IMailFolder destination, ref UniqueIdSet src, ref UniqueIdSet dest)
void GetCopiedUids (ImapCommand ic, ref UniqueIdSet src, ref UniqueIdSet dest)
{
ProcessResponseCodes (ic, destination);

ic.ThrowIfNotOk ("COPY");

var copy = (CopyUidResponseCode) ic.GetResponseCode (ImapResponseCodeType.CopyUid);

if (copy != null) {
Expand All @@ -5353,6 +5344,13 @@ void ProcessCopyToResponse (ImapCommand ic, IMailFolder destination, ref UniqueI
}
}

void ProcessCopyToResponse (ImapCommand ic, IMailFolder destination, ref UniqueIdSet src, ref UniqueIdSet dest)
{
ProcessCopyToResponse (ic, destination);

GetCopiedUids (ic, ref src, ref dest);
}

/// <summary>
/// Copy the specified messages to the destination folder.
/// </summary>
Expand Down Expand Up @@ -5513,24 +5511,11 @@ public override async Task<UniqueIdMap> CopyToAsync (IList<UniqueId> uids, IMail
return new UniqueIdMap (src, dest);
}

// FIXME: This is identical to the ProcessCopyToResponse() implementation *except* for the ImapCommandException.Create() call...
void ProcessMoveToResponse (ImapCommand ic, IMailFolder destination, ref UniqueIdSet src, ref UniqueIdSet dest)
{
ProcessResponseCodes (ic, destination);

ic.ThrowIfNotOk ("MOVE");

var copy = (CopyUidResponseCode) ic.GetResponseCode (ImapResponseCodeType.CopyUid);
ProcessMoveToResponse (ic, destination);

if (copy != null) {
if (dest == null) {
dest = copy.DestUidSet;
src = copy.SrcUidSet;
} else {
dest.AddRange (copy.DestUidSet);
src.AddRange (copy.SrcUidSet);
}
}
GetCopiedUids (ic, ref src, ref dest);
}

/// <summary>
Expand Down

0 comments on commit 7df2cfe

Please sign in to comment.