diff --git a/ImapClient.cs b/ImapClient.cs index 16a00a0..d5c617e 100644 --- a/ImapClient.cs +++ b/ImapClient.cs @@ -254,7 +254,7 @@ public virtual void Copy(string messageset, string destination) { prefix = "UID "; } string command = string.Concat(GetTag(), prefix, "COPY ", messageset, " " + destination.QuoteString()); - SendCommandCheckOK(command); + SendCommandCheckOK(command, s => { } ); IdleResume(); } @@ -826,5 +826,10 @@ internal bool IsResultOK(string response) { response = response.Substring(response.IndexOf(" ")).Trim(); return response.ToUpper().StartsWith("OK"); } + + protected override bool isUntaggedResponse(string response) + { + return response.Trim().StartsWith("* "); + } } } diff --git a/Pop3Client.cs b/Pop3Client.cs index 5de8bd4..9d5881a 100644 --- a/Pop3Client.cs +++ b/Pop3Client.cs @@ -82,5 +82,10 @@ public virtual void DeleteMessage(int index) { public virtual void DeleteMessage(AE.Net.Mail.MailMessage msg) { DeleteMessage(msg.Uid); } + + protected override bool isUntaggedResponse(string response) + { + return false; + } } } \ No newline at end of file diff --git a/TextClient.cs b/TextClient.cs index 6795dd0..e4e886a 100644 --- a/TextClient.cs +++ b/TextClient.cs @@ -33,6 +33,7 @@ public TextClient() { internal abstract void OnLogin(string username, string password); internal abstract void OnLogout(); internal abstract void CheckResultOK(string result); + protected abstract bool isUntaggedResponse(string response); protected virtual void OnConnected(string result) { CheckResultOK(result); @@ -117,6 +118,23 @@ protected virtual string GetResponse(int timeout) { return _Stream.ReadLine(ref max, Encoding, null, timeout); } + protected virtual void SendCommandCheckOK(string command, Action unilateralUntaggedCallback) + { + SendCommand(command); + + while (true) + { + var response = GetResponse(); + if (isUntaggedResponse(response)) + unilateralUntaggedCallback(response); + else + { + CheckResultOK(response); + return; + } + } + } + protected virtual void SendCommandCheckOK(string command) { CheckResultOK(SendCommandGetResponse(command)); }