Skip to content

Commit

Permalink
Fix for #1, #37, #38
Browse files Browse the repository at this point in the history
  • Loading branch information
andyedinborough committed Feb 29, 2012
1 parent 942d51a commit 471b64c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
17 changes: 8 additions & 9 deletions ImapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ private void Noop(bool pauseIdle) {
var tag = GetTag();
var response = SendCommandGetResponse(tag + "NOOP");
while (!response.StartsWith(tag)) {
//if (_IdleEvents != null && _IdleQueue != null) //NK: I'm not sure how to deal with this... Add to the _Responses queue?
// _IdleQueue.Enqueue(response);
response = GetResponse();
}

Expand Down Expand Up @@ -356,11 +354,11 @@ public MailMessage[] GetMessages(string start, string end, bool uid, bool header
if (uid)
UID = "UID ";
if (headersonly)
HEADERS = "[HEADER]";
HEADERS = "HEADER";
if (!setseen)
SETSEEN = ".PEEK";
string tag = GetTag();
string command = tag + UID + "FETCH " + start + ":" + end + " (" + _FetchHeaders + "UID RFC822.SIZE FLAGS BODY" + SETSEEN + HEADERS + ")";
string command = tag + UID + "FETCH " + start + ":" + end + " (" + _FetchHeaders + "UID RFC822.SIZE FLAGS BODY" + SETSEEN + "[" + HEADERS + "])";
string response;
var x = new List<MailMessage>();

Expand Down Expand Up @@ -506,11 +504,12 @@ internal override void OnLogin(string login, string password) {
throw new Exception(result);
}

if (Supports("COMPRESS=DEFLATE")) {
//SendCommandCheckOK(GetTag() + "compress deflate");
//_Reader = new System.IO.StreamReader(new System.IO.Compression.DeflateStream(_Stream, System.IO.Compression.CompressionMode.Decompress));
//_Writer = new System.IO.StreamWriter(new System.IO.Compression.DeflateStream(_Stream, System.IO.Compression.CompressionMode.Compress));
}
//if (Supports("COMPRESS=DEFLATE")) {
// SendCommandCheckOK(GetTag() + "compress deflate");
// _Stream0 = _Stream;
// // _Reader = new System.IO.StreamReader(new System.IO.Compression.DeflateStream(_Stream0, System.IO.Compression.CompressionMode.Decompress, true), System.Text.Encoding.Default);
// // _Stream = new System.IO.Compression.DeflateStream(_Stream0, System.IO.Compression.CompressionMode.Compress, true);
//}

if (Supports("X-GM-EXT-1")) {
_FetchHeaders = "X-GM-MSGID X-GM-THRID X-GM-LABELS ";
Expand Down
7 changes: 7 additions & 0 deletions Tests/Clients.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ public void TestGetSeveralMessages() {
msgs.Count(x => string.IsNullOrEmpty(x.Subject)).Should().Equal(0);
msgs.GroupBy(x => x.Subject).Count().Should().Equal(10);
}
using (var imap = GetClient<ImapClient>()) {
var msgs = imap.GetMessages(0, 9, false);
msgs.Length.Should().Equal(10);
msgs.Count(x => string.IsNullOrEmpty(x.Subject)).Should().Equal(0);
msgs.GroupBy(x => x.Subject).Count().Should().Equal(10);
msgs.GroupBy(x => x.Body).Count().Should().Equal(10);
}
}

[TestMethod]
Expand Down
4 changes: 0 additions & 4 deletions TextClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public abstract class TextClient : IDisposable {
protected TcpClient _Connection;
protected Stream _Stream;
protected StreamReader _Reader;
//protected StreamWriter _Writer;

public string Host { get; private set; }

Expand Down Expand Up @@ -57,7 +56,6 @@ public void Connect(string hostname, int port, bool ssl) {
}

_Reader = new StreamReader(_Stream);
//_Writer = new StreamWriter(_Stream);
string info = _Reader.ReadLine();
OnConnected(info);

Expand All @@ -66,7 +64,6 @@ public void Connect(string hostname, int port, bool ssl) {
} catch (Exception) {
IsConnected = false;
Utilities.TryDispose(ref _Reader);
//Utilities.TryDispose(ref _Writer);
Utilities.TryDispose(ref _Stream);
throw;
}
Expand Down Expand Up @@ -103,7 +100,6 @@ public void Disconnect() {
Logout();

Utilities.TryDispose(ref _Reader);
//Utilities.TryDispose(ref _Writer);
Utilities.TryDispose(ref _Stream);
Utilities.TryDispose(ref _Connection);
}
Expand Down

0 comments on commit 471b64c

Please sign in to comment.