Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes problem when moving an email between folders with gmail #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ImapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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("* ");
}
}
}
5 changes: 5 additions & 0 deletions Pop3Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
18 changes: 18 additions & 0 deletions TextClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<string> 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));
}
Expand Down