From 7df2cfe1d2f68b105014338dd3923fc315c72afa Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 27 Dec 2023 12:10:58 -0500 Subject: [PATCH] more refactoring --- MailKit/Net/Imap/AsyncImapClient.cs | 2 +- MailKit/Net/Imap/ImapClient.cs | 9 +------ MailKit/Net/Imap/ImapFolder.cs | 37 +++++++++-------------------- 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/MailKit/Net/Imap/AsyncImapClient.cs b/MailKit/Net/Imap/AsyncImapClient.cs index d5b26d34cb..7abb3a0edf 100644 --- a/MailKit/Net/Imap/AsyncImapClient.cs +++ b/MailKit/Net/Imap/AsyncImapClient.cs @@ -1093,7 +1093,7 @@ public async Task DisableNotifyAsync (CancellationToken cancellationToken = defa await engine.RunAsync (ic).ConfigureAwait (false); - ProcessDisableNotifyResponse (ic); + ProcessNotifyResponse (ic, false); } /// diff --git a/MailKit/Net/Imap/ImapClient.cs b/MailKit/Net/Imap/ImapClient.cs index 12ef90019d..54ccb27962 100644 --- a/MailKit/Net/Imap/ImapClient.cs +++ b/MailKit/Net/Imap/ImapClient.cs @@ -2078,13 +2078,6 @@ ImapCommand QueueDisableNotifyCommand (CancellationToken cancellationToken) return ic; } - void ProcessDisableNotifyResponse (ImapCommand ic) - { - ic.ThrowIfNotOk ("NOTIFY"); - - engine.NotifySelectedNewExpunge = false; - } - /// /// Disable any previously requested notification events from the IMAP server. /// @@ -2124,7 +2117,7 @@ public void DisableNotify (CancellationToken cancellationToken = default) engine.Run (ic); - ProcessDisableNotifyResponse (ic); + ProcessNotifyResponse (ic, false); } #endregion diff --git a/MailKit/Net/Imap/ImapFolder.cs b/MailKit/Net/Imap/ImapFolder.cs index 9e1903aad2..c5f69d3f83 100644 --- a/MailKit/Net/Imap/ImapFolder.cs +++ b/MailKit/Net/Imap/ImapFolder.cs @@ -5295,12 +5295,7 @@ ImapCommand QueueGetIndexesCommand (IList uids, CancellationToken canc IList 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; @@ -5334,12 +5329,8 @@ void ValidateArguments (IList 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) { @@ -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); + } + /// /// Copy the specified messages to the destination folder. /// @@ -5513,24 +5511,11 @@ public override async Task CopyToAsync (IList 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); } ///