Permalink
Browse files

Refactoring, Cleanup, Comments

3.4.0.1
  • Loading branch information...
1 parent b385ec7 commit 3676780f1b2cee7b192b504c3408a1118e0f9dd9 @smiley22 committed Jan 17, 2014
Showing with 488 additions and 599 deletions.
  1. +4 −6 AuthMethod.cs
  2. +7 −8 Exceptions.cs
  3. +8 −10 FetchOptions.cs
  4. +4 −5 IImapClient.cs
  5. +6 −9 IdleEvents.cs
  6. +11 −16 ImapClient.cs
  7. +3 −4 MIMEPart.cs
  8. +68 −82 MailMessage.cs
  9. +23 −22 MailboxFlags.cs
  10. +14 −17 MailboxInfo.cs
  11. +7 −12 MailboxQuota.cs
  12. +4 −4 MailboxStatus.cs
  13. +85 −103 MessageBuilder.cs
  14. +5 −7 MessageFlags.cs
  15. +2 −2 Properties/AssemblyInfo.cs
  16. +4 −6 SafeQueue.cs
  17. +150 −163 SearchCondition.cs
  18. +83 −123 Util.cs
View
@@ -6,13 +6,11 @@ namespace S22.Imap {
/// </summary>
public enum AuthMethod {
/// <summary>
- /// Automatically selects the most-secure authentication mechanism
- /// supported by the server.
+ /// Automatically selects the most-secure authentication mechanism supported by the server.
/// </summary>
Auto,
/// <summary>
- /// Login using plaintext password authentication. This is
- /// the default supported by most servers.
+ /// Login using plaintext password authentication; This is supported by most servers.
/// </summary>
Login,
/// <summary>
@@ -44,8 +42,8 @@ public enum AuthMethod {
/// </summary>
Ntlmv2,
/// <summary>
- /// Login using the NTLM/NTLMv2 authentication mechanism via
- /// Microsoft's Security Support Provider Interface (SSPI).
+ /// Login using the NTLM/NTLMv2 authentication mechanism via Microsoft's Security Support
+ /// Provider Interface (SSPI).
/// </summary>
NtlmOverSspi,
/// <summary>
View
@@ -3,9 +3,9 @@
namespace S22.Imap {
/// <summary>
- /// The exception is thrown when an unexpected response is received from the server.
+ /// The exception that is thrown when an unexpected response is received from the server.
/// </summary>
- [Serializable()]
+ [Serializable]
public class BadServerResponseException : Exception {
/// <summary>
/// Initializes a new instance of the BadServerResponseException class
@@ -40,10 +40,9 @@ protected BadServerResponseException(SerializationInfo info, StreamingContext co
}
/// <summary>
- /// This exception is thrown when the supplied credentials in a login attempt were rejected
- /// by the server.
+ /// The exception that is thrown when the supplied credentials were rejected by the server.
/// </summary>
- [Serializable()]
+ [Serializable]
public class InvalidCredentialsException : Exception {
/// <summary>
/// Initializes a new instance of the InvalidCredentialsException class
@@ -78,10 +77,10 @@ protected InvalidCredentialsException(SerializationInfo info, StreamingContext c
}
/// <summary>
- /// This exception is thrown when a client has not authenticated with the server and
- /// attempts to call a method which can only be called in an authenticated context.
+ /// The exception that is thrown when a client has not authenticated with the server and
+ /// attempts to call a method which can only be called when authenticated.
/// </summary>
- [Serializable()]
+ [Serializable]
public class NotAuthenticatedException : Exception {
/// <summary>
/// Initializes a new instance of the NotAuthenticatedException class
View
@@ -2,29 +2,27 @@
namespace S22.Imap {
/// <summary>
- /// Fetch options that can be used with the GetMessage and GetMessages methods
- /// to selectively retrieve parts of a mail message while skipping others.
+ /// Defines the different means by which mail messages may be fetched from the server.
/// </summary>
public enum FetchOptions {
/// <summary>
/// Fetches the entire mail message with all of its content.
/// </summary>
Normal,
/// <summary>
- /// Only the mail message headers will be retrieved, while the actual content will
- /// not be downloaded. If this option is specified, only the header fields of the
- /// returned MailMessage object will be initialized.
+ /// Only the mail message headers will be retrieved, while the actual content will not be
+ /// downloaded. If this option is specified, only the header fields of the returned MailMessage
+ /// object will be initialized.
/// </summary>
HeadersOnly,
/// <summary>
- /// Retrieves the mail message, but will only download content that has a
- /// content-type of text. This will retrieve text as well as html representations,
- /// but no inline content or attachments.
+ /// Retrieves the mail message, but will only download content that has a content-type of text.
+ /// This will retrieve text as well as HTML representation, while skipping inline content and
+ /// attachments.
/// </summary>
TextOnly,
/// <summary>
- /// Retrieves the mail message, but skips any content that has been marked as
- /// attachment.
+ /// Retrieves the mail message, but skips any content that is an attachment.
/// </summary>
NoAttachments
}
View
@@ -9,13 +9,12 @@ namespace S22.Imap {
/// </summary>
public interface IImapClient : IDisposable {
/// <summary>
- /// The default mailbox to operate on, when no specific mailbox name is indicated
- /// to methods that operate on mailboxes. The default value for this property is "INBOX".
+ /// The default mailbox to operate on.
/// </summary>
- /// <exception cref="ArgumentNullException">The value specified for a set operation is
+ /// <exception cref="ArgumentNullException">The property is being set and the value is
/// null.</exception>
- /// <exception cref="ArgumentException">The value specified for a set operation is equal
- /// to the empty string.</exception>
+ /// <exception cref="ArgumentException">The property is being set and the value is the empty
+ /// string.</exception>
/// <remarks>The default value for this property is "INBOX" which is a special name reserved
/// to mean "the primary mailbox for this user on this server".</remarks>
string DefaultMailbox { get; set; }
View
@@ -2,21 +2,18 @@
namespace S22.Imap {
/// <summary>
- /// Provides data for IMAP idle notification events, such as the NewMessage and
- /// MessageDelete events.
+ /// Provides data for IMAP idle notification events.
/// </summary>
public class IdleMessageEventArgs : EventArgs {
/// <summary>
/// Initializes a new instance of the IdleMessageEventArgs class and sets the
/// MessageCount attribute to the value of the <paramref name="MessageCount"/>
/// parameter.
/// </summary>
- /// <param name="MessageCount">The number of messages in the selected
+ /// <param name="MessageCount">The number of messages in the selected mailbox.</param>
+ /// <param name="MessageUID"> The unique identifier (UID) of the newest message in the
/// mailbox.</param>
- /// <param name="MessageUID"> The unique identifier (UID) of the newest
- /// message in the mailbox.</param>
- /// <param name="Client">The instance of the ImapClient class that raised
- /// the event.</param>
+ /// <param name="Client">The instance of the ImapClient class that raised the event.</param>
internal IdleMessageEventArgs(uint MessageCount, uint MessageUID,
ImapClient Client) {
this.MessageCount = MessageCount;
@@ -35,8 +32,8 @@ public class IdleMessageEventArgs : EventArgs {
/// <summary>
/// The unique identifier (UID) of the newest message in the mailbox.
/// </summary>
- /// <remarks>The UID can be passed to the GetMessage method in order to retrieve
- /// the mail message from the server.</remarks>
+ /// <remarks>The UID can be passed to the GetMessage method in order to retrieve the mail
+ /// message from the server.</remarks>
public uint MessageUID {
get;
private set;
View
@@ -46,13 +46,12 @@ public class ImapClient : IImapClient
static readonly TraceSource ts = new TraceSource("S22.Imap");
/// <summary>
- /// The default mailbox to operate on, when no specific mailbox name is indicated
- /// to methods that operate on mailboxes. The default value for this property is "INBOX".
+ /// The default mailbox to operate on.
/// </summary>
- /// <exception cref="ArgumentNullException">The value specified for a set operation is
+ /// <exception cref="ArgumentNullException">The property is being set and the value is
/// null.</exception>
- /// <exception cref="ArgumentException">The value specified for a set operation is equal
- /// to the empty string.</exception>
+ /// <exception cref="ArgumentException">The property is being set and the value is the empty
+ /// string.</exception>
/// <remarks>The default value for this property is "INBOX" which is a special name reserved
/// to mean "the primary mailbox for this user on this server".</remarks>
public string DefaultMailbox {
@@ -218,7 +217,7 @@ public class ImapClient : IImapClient
sslStream.AuthenticateAsClient(hostname);
stream = sslStream;
}
- // Server issues an untagged OK greeting upon connect.
+ // The server issues an untagged OK greeting upon connect.
string greeting = GetResponse();
if (!IsResponseOK(greeting))
throw new BadServerResponseException(greeting);
@@ -840,7 +839,6 @@ public class ImapClient : IImapClient
if (mailbox == null)
mailbox = defaultMailbox;
MailboxStatus status = GetMailboxStatus(mailbox);
-
// Collect quota information if the server supports it.
UInt64 used = 0, free = 0;
if (Supports("QUOTA")) {
@@ -854,10 +852,9 @@ public class ImapClient : IImapClient
}
// Try to collect special-use flags.
IEnumerable<MailboxFlag> flags = GetMailboxFlags(mailbox);
-
ResumeIdling();
- return new MailboxInfo(mailbox, flags, status.Messages,
- status.Unread, status.NextUID, used, free);
+ return new MailboxInfo(mailbox, flags, status.Messages, status.Unread, status.NextUID,
+ used, free);
}
}
@@ -901,8 +898,7 @@ public class ImapClient : IImapClient
string response = SendCommandGetResponse(tag + command + " \"\" " +
Util.UTF7Encode(mailbox).QuoteString());
while (response.StartsWith("*")) {
- Match m = Regex.Match(response,
- "\\* X?LIST \\((.*)\\)\\s+\"([^\"]+)\"\\s+(.+)");
+ Match m = Regex.Match(response, "\\* X?LIST \\((.*)\\)\\s+\"([^\"]+)\"\\s+(.+)");
if (m.Success) {
string[] flags = m.Groups[1].Value.Split(' ');
foreach (string f in flags) {
@@ -1301,8 +1297,8 @@ public class ImapClient : IImapClient
string response = SendCommandGetResponse(tag + "APPEND " +
Util.UTF7Encode(mailbox).QuoteString() + (seen ? @" (\Seen)" : "") +
" {" + mime822.Length + "}");
- // The server is required to send a continuation response before we can go ahead with the
- // actual message data.
+ // The server must send a continuation response before we can go ahead with the actual
+ // message data.
if (!response.StartsWith("+"))
throw new BadServerResponseException(response);
response = SendCommandGetResponse(mime822);
@@ -1420,8 +1416,7 @@ public class ImapClient : IImapClient
PauseIdling();
SelectMailbox(mailbox);
string tag = GetTag();
- string response = SendCommandGetResponse(tag + "UID FETCH " + uid +
- " (BODYSTRUCTURE)");
+ string response = SendCommandGetResponse(tag + "UID FETCH " + uid + " (BODYSTRUCTURE)");
string structure = String.Empty;
while (response.StartsWith("*")) {
Match m = Regex.Match(response,
View
@@ -3,13 +3,12 @@
namespace S22.Imap {
/// <summary>
- /// Represents a part of a MIME multi-part message. Each part consists
- /// of its own content header and a content body.
+ /// Represents a part of a MIME multi-part message. Each part consists of its own content header
+ /// and a content body.
/// </summary>
internal class MIMEPart {
/// <summary>
- /// A collection containing the content header information as
- /// key-value pairs.
+ /// A collection containing the content header information as key-value pairs.
/// </summary>
public NameValueCollection header {
get;
Oops, something went wrong.

0 comments on commit 3676780

Please sign in to comment.