[Csmail-patches] CVS: csmail/src/CSMail ChangeLog,1.31,1.32 Folder.cs,1.6,1.7 HeaderList.cs,1.3,1.4
Status: Pre-Alpha
Brought to you by:
mastergaurav
From: Gaurav V. <mas...@us...> - 2002-09-06 11:52:32
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv20543 Modified Files: ChangeLog Folder.cs HeaderList.cs MailEventHandler.cs Message.cs MessagingException.cs Multipart.cs NewsAddress.cs Parameter.cs Provider.cs Service.cs Store.cs TODO Log Message: 2002-09-06 * Message.cs : IsSet(MessageFlags) - Now allows multiple flags to be set. : IsExpunged { get; } - Can only get now. : isExpunged - Changed to protected. * Parameter.cs : ToString - Implemented * Service.cs : OnConnection() - Partial implementation. * HeaderList.cs : Add(Header[]) - Fixed null element bug. : RemoveAt(int) - Fixed index bug. : Clear() - Implemented. * <Rest>.cs : Documentation Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- ChangeLog 6 Sep 2002 09:30:27 -0000 1.31 +++ ChangeLog 6 Sep 2002 11:52:29 -0000 1.32 @@ -1,6 +1,18 @@ 2002-09-06 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * Message.cs : IsSet(MessageFlags) + - Now allows multiple flags to be set. + : IsExpunged { get; } - Can only get now. + : isExpunged - Changed to protected. + * Parameter.cs : ToString - Implemented + * Service.cs : OnConnection() - Partial implementation. + * HeaderList.cs : Add(Header[]) - Fixed null element bug. + : RemoveAt(int) - Fixed index bug. + : Clear() - Implemented. + +2002-09-06 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + * EMailAddressList.cs : GetAddress(int) - Fixed index bug. : Add(EMailAddress[]) - Fixed null element bug. : ctor(EMailAddress[])- Fixed null element bug. Index: Folder.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Folder.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Folder.cs 6 Sep 2002 09:30:27 -0000 1.6 +++ Folder.cs 6 Sep 2002 11:52:29 -0000 1.7 @@ -62,13 +62,6 @@ /// messages (with their order defined) held within a folder /// should/do not change unless they are deleted by an explicit /// <see cref="Expunge"/>. - /// <p> - /// On exiting a folder, it is suggested that - /// <see cref="SaveChanges"/> method is called so that any changes are - /// not lost. Preferably, call it in a destructor or if you make your - /// implementation <c>IDisposable</c>, then in the <c>Dispose</c> - /// method. - /// </p> /// </remarks> public abstract class Folder //: IEnumerable { Index: HeaderList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/HeaderList.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- HeaderList.cs 6 Sep 2002 09:30:27 -0000 1.3 +++ HeaderList.cs 6 Sep 2002 11:52:29 -0000 1.4 @@ -71,6 +71,14 @@ } /// <summary> + /// Empties the list. + /// </summary> + public void Clear() + { + headers.Clear(); + } + + /// <summary> /// Returns the number of headers in the list. /// </summary> public int Count @@ -111,26 +119,54 @@ /// </summary> /// <param name="header">Header to be added.</param> /// <returns>Total number of elements in the list - /// after adding the new header.</returns> + /// after adding the header.</returns> public int Add(Header header) { return headers.Add(header); } + /// <summary> + /// Add a set of headers to the list. + /// </summary> + /// <param name="headers">Headers to be added.</param> + /// <returns>Total number of elements in the list + /// after adding the headers.</returns> public int Add(Header[] headers) { foreach(Header current in headers) { - this.headers.Add(current); + if(current != null) + { + this.headers.Add(current); + } } return this.headers.Count; } + /// <summary> + /// Returns the index of the header in the list. + /// </summary> + /// <param name="header">Header under consideration.</param> + /// <returns>The index (zero based) of the header + /// in the list. -1 if it does not exist.</returns> public int IndexOf(Header header) { return headers.IndexOf(header); } + /// <summary> + /// Search for a header-value with or without ignoring case. + /// </summary> + /// <remarks> + /// The value is matched against as that returned by + /// <b>Header::ToString()</b> + /// </remarks> + /// <param name="fullHeader">Value to look for.</param> + /// <param name="ignoreCase">Whether or not to ignore case.</param> + /// <returns> + /// The index of the header if found, -1 if not found or + /// if <c>fullHeader</c> is null or empty. + /// </returns> public int IndexOf(string fullHeader, bool ignoreCase) { if(fullHeader == null || fullHeader == "") @@ -150,20 +186,45 @@ return -1; } + /// <summary> + /// Removes the header from the list, if found. + /// </summary> + /// <param name="header">Header to be removed.</param> public void Remove(Header header) { headers.Remove(header); } + /// <summary> + /// Removes the header at the given index. + /// </summary> + /// <param name="index">Index at which value is to + /// be removed.</param> + /// <remarks> + /// If index < 0 or if index >= Count, no action + /// is taken. + /// </remarks> public void RemoveAt(int index) { - if(index < 0 || index > headers.Count) + if(index < 0 || index >= headers.Count) { return; } headers.RemoveAt(index); } + /// <summary> + /// Checks for existence of a header. + /// </summary> + /// <remarks> + /// The value is matched against as that returned by + /// <b>Header::ToString()</b> + /// </remarks> + /// <param name="fullHeader">Value to look for.</param> + /// <param name="ignoreCase">Whether or not to ignore case.</param> + /// <returns> + /// <c>true</c> if header is found, <c>false</c> otherwise. + /// </returns> public bool Exists(string fullHeader, bool ignoreCase) { if(fullHeader == null || fullHeader == "") @@ -181,11 +242,23 @@ return false; } + /// <summary> + /// Checks for existence of a header. + /// </summary> + /// <param name="header">Header to look for.</param> + /// <returns> + /// <c>true</c> if header is found, <c>false</c> otherwise. + /// </returns> public bool Exists(Header header) { return headers.Contains(header); } + /// <summary> + /// Removes all matching headers. + /// </summary> + /// <param name="name">Header to look for.</param> + /// <param name="ignoreCase">Whether or not to ignore case.</param> public void RemoveAll(string name, bool ignoreCase) { ArrayList delete = new ArrayList(); @@ -202,11 +275,30 @@ } } + /// <summary> + /// Removes the first matching header. + /// </summary> + /// <param name="fullHeader">Header to look for.</param> + /// <param name="ignoreCase">Whether or not to ignore case.</param> public void Remove(string fullHeader, bool ignoreCase) { RemoveAt(IndexOf(fullHeader, ignoreCase)); } + /// <summary> + /// Returns the string representation for the list. + /// </summary> + /// <returns>The string representation.</returns> + /// <remarks> + /// The value returned is a concatenation of the values + /// returned by all the headers in the list. Specifially, + /// the returned value is of the the form: + /// <code> + /// Name1: Value11\r\n + /// Name1: Value12\r\n + /// Name2: Value2\r\n + /// </code> + /// </remarks> public override string ToString() { string retVal = ""; Index: MailEventHandler.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MailEventHandler.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MailEventHandler.cs 2 Sep 2002 13:07:54 -0000 1.1 +++ MailEventHandler.cs 6 Sep 2002 11:52:29 -0000 1.2 @@ -10,6 +10,5 @@ namespace CSMail { - public delegate void MailEventHandler(object sender, - MailEventArgs e); + public delegate void MailEventHandler(object sender, MailEventArgs e); } Index: Message.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Message.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Message.cs 4 Sep 2002 06:35:42 -0000 1.6 +++ Message.cs 6 Sep 2002 11:52:29 -0000 1.7 @@ -13,6 +13,9 @@ namespace CSMail { + /// <summary> + /// Abstract class that models a message. + /// </summary> public abstract class Message: IPart { /// <summary> @@ -30,7 +33,7 @@ /// <summary> /// Has this been message expunged from the folder? /// </summary> - private bool isExpunged; + protected bool isExpunged; protected Message() { @@ -91,10 +94,6 @@ { return isExpunged; } - set - { - isExpunged = value; - } } public virtual IAddressList ReplyTo @@ -107,9 +106,7 @@ public bool IsSet(MessageFlags flag) { - if(!Enum.IsDefined(typeof(MessageFlags), flag)) - throw new ArgumentException("[IsSet] Illegal value to check"); - return ((flag & Flags) == flag); + return ((flag & Flags) != 0x0000); } } } Index: MessagingException.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MessagingException.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MessagingException.cs 6 Sep 2002 09:30:27 -0000 1.2 +++ MessagingException.cs 6 Sep 2002 11:52:29 -0000 1.3 @@ -44,5 +44,13 @@ throw new NotImplementedException(); } } + + public string BaseMessage + { + get + { + return base.Message; + } + } } } Index: Multipart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Multipart.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Multipart.cs 4 Sep 2002 07:06:08 -0000 1.2 +++ Multipart.cs 6 Sep 2002 11:52:29 -0000 1.3 @@ -12,19 +12,43 @@ namespace CSMail { + /// <summary> + /// Class that holds multiple bodyparts. + /// </summary> + /// <remarks> + /// A multipart provides mechanism to retrieve all + /// the parts within a part, recursively. + /// <p class="il"> + /// The content type of such a part is necessarily "multipart/*". + /// The various possible values include "multipart/mixed", + /// "multipart/signed", "mutlipart/alternative", + /// "multipart/related" etc. + /// </p> + /// </remarks> + /// <seealso cref="BodyPartList"/> + /// <seealso cref="BodyPart"/> public abstract class Multipart { private IPart parent; private BodyPartList bodyParts; + /// <summary> + /// The associated content type. + /// </summary> protected ContentType CType; + /// <summary> + /// Creates an instance with default settings. + /// </summary> protected Multipart() { this.CType = new ContentType("multipart", "mixed"); this.bodyParts = new BodyPartList(); } + /// <summary> + /// Returns the content type of the multipart. + /// </summary> public ContentType ContentType { get @@ -33,6 +57,9 @@ } } + /// <summary> + /// Returns the parent of this part. + /// </summary> public IPart Parent { get @@ -45,6 +72,10 @@ } } + /// <summary> + /// Returns the list of all the body-parts + /// contained in the multipart. + /// </summary> public BodyPartList BodyParts { get @@ -53,6 +84,10 @@ } } + /// <summary> + /// When implemented, writes the content to the stream. + /// </summary> + /// <param name="writer">The stream to write to.</param> public abstract void WriteTo(StreamWriter writer); } } Index: NewsAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/NewsAddress.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- NewsAddress.cs 20 Jun 2002 10:34:55 -0000 1.1 +++ NewsAddress.cs 6 Sep 2002 11:52:29 -0000 1.2 @@ -13,17 +13,32 @@ namespace CSMail { + /// <summary> + /// Class that encapsulated news address. + /// </summary> public class NewsAddress: IAddress { private string hostname; private ArrayList groups = new ArrayList(); + /// <summary> + /// Initializes the instance with a given hostname + /// and group to be connect to. + /// </summary> + /// <param name="host">Hostname to be connected to.</param> + /// <param name="group">Newsgroup to be connected to.</param> public NewsAddress(string host, string group) { hostname = host; groups.Add(group); } + /// <summary> + /// Initializes the instance with a given hostname + /// and a list groups to be connect to. + /// </summary> + /// <param name="host">Hostname to be connected to.</param> + /// <param name="groups">Newsgroups to be connected to.</param> public NewsAddress(string host, string[] groups) { if(groups == null || groups.Length == 0) @@ -37,6 +52,12 @@ } } + /// <summary> + /// The type of the address. + /// </summary> + /// <remarks> + /// It is necessarily <b>AddressType.NewsAddress</b> + /// </remarks> public AddressType AddressType { get @@ -45,6 +66,9 @@ } } + /// <summary> + /// Returns the associated hostname. + /// </summary> public string Hostname { get @@ -53,6 +77,13 @@ } } + /// <summary> + /// Returns the associated newsgroup. + /// </summary> + /// <remarks> + /// Incase a list of groups was provided, returns + /// the first group in the list. + /// </remarks> public string Group { get @@ -65,6 +96,15 @@ } } + /// <summary> + /// Returns the associated list of the groups as an array + /// of string. + /// </summary> + /// <remarks> + /// Returns a new copy list. As such, changing any values + /// after retrieving the list will not affect the + /// list stored here. + /// </remarks> public string[] Groups { get @@ -82,26 +122,53 @@ } } + /// <summary> + /// Adds a newsgroup to the list. + /// </summary> + /// <param name="group">Newsgroup to added.</param> + /// <returns>The number of elements in the final list.</returns> public int Add(string group) { return groups.Add(group); } + /// <summary> + /// Removes a newsgroup from the list. + /// </summary> + /// <param name="group">Newsgroup to be removed.</param> public void Remove(string group) { groups.Remove(group); } + /// <summary> + /// Check for existence of a newsgroup in the list. + /// </summary> + /// <remarks> + /// Currently the check is <b>case sensitive</b>. + /// </remarks> public bool Contains(string group) { return groups.Contains(group); } + /// <summary> + /// Returns the hashcode for the instance. + /// </summary> + /// <returns>The hashcode</returns> public override int GetHashCode() { return hostname.GetHashCode() + (Group == null ? 0xFFFF : Group.GetHashCode()); } + /// <summary> + /// Checks for the equality with an object. + /// </summary> + /// <param name="obj">Object to be compared to.</param> + /// <returns> + /// <c>true</c> if the two instances represent the same hostname + /// and newsgroups, <c>false</c> otherwise. + /// </returns> public override bool Equals(object obj) { if(obj is NewsAddress) @@ -111,6 +178,14 @@ return false; } + /// <summary> + /// Checks for the equality with another address. + /// </summary> + /// <param name="address">Address to be compared with.</param> + /// <returns> + /// <c>true</c> if the two instances represent the same hostname + /// and newsgroups, <c>false</c> otherwise. + /// </returns> public bool Equals(IAddress address) { if(address is NewsAddress) @@ -120,6 +195,14 @@ return false; } + /// <summary> + /// Checks for the equality with another address. + /// </summary> + /// <param name="address">Address to be compared with.</param> + /// <returns> + /// <c>true</c> if the two instances represent the same hostname + /// and newsgroups, <c>false</c> otherwise. + /// </returns> public bool Equals(NewsAddress address) { if(address.hostname == hostname && Groups != null && address.Groups != null Index: Parameter.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Parameter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Parameter.cs 20 Jun 2002 02:43:25 -0000 1.1 +++ Parameter.cs 6 Sep 2002 11:52:29 -0000 1.2 @@ -10,17 +10,29 @@ namespace CSMail { + /// <summary> + /// Class that handles a parameter. + /// </summary> public class Parameter { private string name; private string value; + /// <summary> + /// Initialized the instance with given parameter name + /// and its value. + /// </summary> + /// <param name="name">Parameter name.</param> + /// <param name="value">The value of the paramter.</param> public Parameter(string name, string value) { this.name = name; this.value = value; } + /// <summary> + /// Returns the parameter name. + /// </summary> public string Name { get @@ -29,12 +41,32 @@ } } + /// <summary> + /// Returns the parameter value. + /// </summary> public string Value { get { return value; } + } + + /// <summary> + /// Returns the string representation of the paramter. + /// </summary> + /// <remarks> + /// The returned value is of the form: + /// <code> + /// <name>=<value> + /// </code> + /// </remarks> + public override string ToString() + { + string retVal = name; + retVal += "="; + retVal += value; + return retVal; } } } Index: Provider.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Provider.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Provider.cs 4 Sep 2002 06:35:42 -0000 1.6 +++ Provider.cs 6 Sep 2002 11:52:29 -0000 1.7 @@ -33,14 +33,14 @@ this.version = version; } - /// <summary> + /// <remarks> /// Format of rawline: /// protocol = <proto>; type = <type>; class = <class>; /// vendor = <vendor>; version = <version>; /// assembly = <assembly> /// Note that they may appear in any order. Vendor and version /// may be missing. '=' may be replaced by a ':' - /// </summary> + /// </remarks> internal Provider(string rawLine) { rawLine = rawLine.Trim(); Index: Service.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Service.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Service.cs 3 Sep 2002 12:38:45 -0000 1.5 +++ Service.cs 6 Sep 2002 11:52:29 -0000 1.6 @@ -13,23 +13,50 @@ namespace CSMail { + /// <summary> + /// Mother class (abstract) for all the services. + /// </summary> + /// <seealso cref="Store"/> + /// <seealso cref="Transport"/> public abstract class Service { + /// <summary> + /// Flag to denote the connectivity status. + /// </summary> protected bool connected; + /// <summary> + /// Flag to denote the debug staus. + /// </summary> protected bool debug; + /// <summary> + /// The session associated with the service instance. + /// </summary> protected Session session; + /// <summary> + /// The URL associated with the service instance. + /// </summary> protected URLName url; private static readonly object ConnectionEvent = new object(); private EventHandlerList events; + /// <summary> + /// Initializes the instance with the session and urlname. + /// </summary> + /// <param name="session">Session to which this instance + /// is connected to.</param> + /// <param name="url">URL related to the current instance.</param> protected Service(Session session, URLName url) { this.session = session; this.url = url; } + /// <summary> + /// Returns the list of events. + /// </summary> + /// <seealso cref="EventHandlerList"/> protected EventHandlerList Events { get @@ -42,6 +69,9 @@ } } + /// <summary> + /// Returns the associated URL. + /// </summary> public URLName URL { get @@ -50,6 +80,12 @@ } } + /// <summary> + /// Returns the connectivity status. + /// </summary> + /// <remarks> + /// Returns <c>true</c> if connected, false otherwise. + /// </remarks> public bool Connected { get @@ -58,22 +94,43 @@ } } + /// <summary> + /// Closes an open connection. + /// </summary> [MailTODO] public virtual void Close() { throw new NotImplementedException(); } + /// <summary> + /// Attempts to make a connection. + /// </summary> public virtual void Connect() { Connect(null, null, null); } + /// <summary> + /// Attemps to make a connection to given address, and + /// specified username and passoword. + /// </summary> + /// <param name="hostname">Host to connect to.</param> + /// <param name="username">Username for authentication.</param> + /// <param name="password">Password for authentication.</param> public virtual void Connect(InternetAddress hostname, string username, string password) { Connect(hostname, -1, username, password); } + /// <summary> + /// Attempts to make a connection to given host at specified port, + /// with authentication. + /// </summary> + /// <param name="host">Host to connect to.</param> + /// <param name="port">Port at which connection is attempted.</param> + /// <param name="username">Username for authentication.</param> + /// <param name="password">Password for authentication.</param> [MailTODO] public virtual void Connect(InternetAddress host, int port, string username, string password) { @@ -140,6 +197,9 @@ throw new NotImplementedException(); } + /// <summary> + /// Occurs whenever connection status is changed. + /// </summary> public event ConnectionEventHandler Connection { add @@ -150,6 +210,19 @@ { Events.RemoveHandler(ConnectionEvent, value); } + } + + /// <summary> + /// Raises the <see cref="Connection"/> event. + /// </summary> + /// <param name="e">The required arguments to raise the event.</param> + [MailTODO] + public void OnConnection(ConnectionEventArgs e) + { + ConnectionEventHandler ceh = (ConnectionEventHandler)Events[ConnectionEvent]; + if(ceh != null) + ceh(this, e); + throw new NotImplementedException(); } } } Index: Store.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Store.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Store.cs 30 Aug 2002 12:39:33 -0000 1.5 +++ Store.cs 6 Sep 2002 11:52:29 -0000 1.6 @@ -52,12 +52,24 @@ [MailTODO] public void OnStoreMessage(StoreMessageEventArgs e) { + if(Events != null) + { + StoreMessageEventHandler smeh = (StoreMessageEventHandler)Events[StoreMessageEvent]; + if(smeh != null) + smeh(this, e); + } throw new NotImplementedException(); } [MailTODO] public void OnFolder(FolderEventArgs e) { + if(Events != null) + { + FolderEventHandler feh = (FolderEventHandler)Events[FolderEvent]; + if(feh != null) + feh(this, e); + } throw new NotImplementedException(); } } Index: TODO =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/TODO,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TODO 6 Sep 2002 09:08:28 -0000 1.2 +++ TODO 6 Sep 2002 11:52:29 -0000 1.3 @@ -7,6 +7,7 @@ * Done a lot! ;-) * BodyPartList -- Complete the class! + * ProviderList -- Complete the class! * InternetAddress -- Support for IP_V6. * MimeBodyPart, MimeMessage -- Implements IMimePart |