[Csmail-patches] CVS: csmail/src/CSMail .cvsignore,NONE,1.1 AddressType.cs,NONE,1.1 AssemblyInfo.cs,
Status: Pre-Alpha
Brought to you by:
mastergaurav
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv1717/src/CSMail Added Files: .cvsignore AddressType.cs AssemblyInfo.cs BodyPart.cs BodyPartList.cs ChangeLog ConnectionEventArgs.cs ConnectionEventHandler.cs ConnectionEventType.cs ContentDisposition.cs ContentType.cs EMailAddress.cs EMailAddressList.cs Folder.cs FolderAddress.cs FolderEventArgs.cs FolderEventHandler.cs FolderEventType.cs FolderOpenMode.cs FolderSortStyle.cs FolderType.cs Header.cs HeaderList.cs IAddress.cs IAddressList.cs IEncode.cs IMimePart.cs IPart.cs InternetAddress.cs Message.cs MessageFlags.cs MessageSortStyle.cs Multipart.cs NewsAddress.cs NewsAddressList.cs Parameter.cs ParameterList.cs Provider.cs ProviderType.cs RecipientType.cs Service.cs Session.cs Store.cs TODOAttribute.cs TransferEncoding.cs URLName.cs Log Message: 2002-02-24 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * **.**/** -- Final single commit for all the files. --- NEW FILE --- *.bat --- NEW FILE --- /** * Namespace: CSMail * Enumeration: AddressType * Comment: Enumeration AddressType for various types of addresses. * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum AddressType { EmailAddress, InternetAddress, NewsAddress } } --- NEW FILE --- using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyTitle("CSMail")] [assembly: AssemblyDescription("CS Mail API")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("http://csmail.sourceforge.net/")] [assembly: AssemblyProduct("CSMail")] [assembly: AssemblyCopyright("Copyright (C) 2002, Gaurav Vaish")] [assembly: AssemblyTrademark("CS-Mail")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyName("")] --- NEW FILE --- /** * Namespace: CSMail * Class: BodyPart * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.IO; namespace CSMail { public abstract class BodyPart: IPart { private Multipart parent; public BodyPart() { } public Multipart Parent { get { return parent; } } protected Multipart ParentProperty { get { return parent; } set { parent = value; } } public abstract Multipart Content { get; set; } public abstract ContentType ContentType { get; set; } public abstract string Description { get; set; } public abstract ContentDisposition Disposition { get; set; } public abstract string Filename { get; set; } public abstract HeaderList Headers { get; set; } public abstract int Size { get; set; } public abstract int AddHeader(Header header); public abstract int AddHeaders(HeaderList headers); public abstract void Write(TextWriter writer); } } --- NEW FILE --- /** * Namespace: CSMail * Class: BodyPartList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class BodyPartList { public BodyPartList(BodyPart part) { //TODO } public BodyPartList(BodyPart[] parts) { //TODO } public BodyPartList(BodyPartList parts) { //TODO } } } --- NEW FILE --- 2002-06-20 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Session.cs: Added constructors and GetDefaultInstance(...) method 2002-06-19 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Added attribute class - MailTODOAttribute in the file TODOAttribute.cs * Folder.cs, * Message.cs, * Session.cs, * Store.cs, * Service.cs, * InternetAddress.cs, * URLName.cs : Initial implementation. * FolderEventArgs.cs : Added property NewFolder. Debugged the constructors * Header.cs : Added ToString() method. * HeaderList.cs : Now implements IEnumerable. Added methods GetEnumerator(), this[int], Add(...), IndexOf(...), Remove*(...), Exists and ToString() 2002-06-18 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Added the following objects: - BodyPart - BodyPartList - ConnectionEventArgs - ConnectionEventHandler - ContentType - EMailAddress - EMailAddressList - Folder - FolderAddress - FolderEventArgs - FolderEventHandler - Header - HeaderList - Multipart - Parameter - ParameterList - Session - IAddress - IAddressList - IEncode - IMimePart - IPart - MessageFlags 2002-06-13 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Added the enumerations: - AddressType - ConnectionEventType - ContentDisposition - Flags - FolderEventType - FolderSortStyle - MessageSortStyle - ProviderType - RecipientType - TransferEncoding --- NEW FILE --- /** * Namespace: CSMail * Class: ConnectionEventArgs * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class ConnectionEventArgs { private ConnectionEventType eventType; public ConnectionEventArgs(ConnectionEventType eventType) { this.eventType = eventType; } public ConnectionEventType EventType { get { return eventType; } } } } --- NEW FILE --- /** * Namespace: CSMail * Delegate: ConnectionEventHandler * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public delegate void ConnectionEventHandler(object sender, ConnectionEventArgs e); } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: ConnectionEventType * Comment: Enumeration ConnectionEventType contains various possible\ * events associated with a Connection. * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum ConnectionEventType { Opened, Closed, Disconnected } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: ContentDisposition * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum ContentDisposition { Attachment, Inline } } --- NEW FILE --- /** * Namespace: CSMail * Class: ContentType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class ContentType { private string primaryType; private string subType; private ParameterList parameters; public ContentType(string primary, string sub) { primaryType = primary; subType = sub; } public ContentType(string primary, string sub, ParameterList parameters) { primaryType = primary; subType = sub; this.parameters = parameters; } public string PrimaryType { get { if(primaryType != null) return primaryType; return String.Empty; } } public string SubType { get { if(subType != null) return subType; return String.Empty; } } public ParameterList Parameters { get { return parameters; } } public override bool Equals(object obj) { if(obj is ContentType) { return Equals((ContentType)obj); } if(obj is string) { return Equals((string)obj); } return false; } public bool Equals(ContentType cType) { if(cType != null) { return Equals(cType.ToString()); } return false; } public bool Equals(string cType) { return (cType.Equals(this.ToString())); } public override string ToString() { string retVal; retVal = primaryType; if(primaryType != "") retVal += "/"; retVal += SubType; if(retVal != "" && parameters!=null) { retVal += ";"; retVal += parameters.ToString(); } return retVal; } public override int GetHashCode() { return (primaryType.GetHashCode() + subType.GetHashCode()); } } } --- NEW FILE --- /** * Namespace: CSMail * Class: EMailAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class EMailAddress: IAddress { private string user; private string host; private string name; public EMailAddress(string user, string host) { this.user = user; this.host = host; } public EMailAddress(string name, string user, string host): this(user, host) { this.name = name; } public string User { get { return user; } } public string Host { get { return host; } } public string Name { get { return name; } } public AddressType AddressType { get { return AddressType.EmailAddress; } } public bool Equals(IAddress address) { if(address is EMailAddress) { EMailAddress that = (EMailAddress)address; if(this.User == that.User && this.Host == that.Host && this.Name == that.Name) return true; } return false; } public override string ToString() { string retVal = String.Empty; if(name != null && name != String.Empty) { retVal = (name + " <"); } retVal += (user + "@" + host); if(name != null && name != String.Empty) { retVal += ">"; } return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: EMailAddressList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class EMailAddressList: IAddressList, IEnumerable { private ArrayList emails; public EMailAddressList() { emails = new ArrayList(); } public EMailAddressList(EMailAddress[] addresses) { emails = new ArrayList(); foreach(EMailAddress current in addresses) { emails.Add(current); } } public EMailAddressList(EMailAddressList addresses) { emails = new ArrayList(); foreach(EMailAddress current in addresses) { emails.Add(current); } } public EMailAddress this[int index] { get { return (EMailAddress)emails[index]; } set { emails[index] = value; } } int IAddressList.Add(IAddress address) { if(address is EMailAddress) return Add((EMailAddress)address); return -1; } void IAddressList.AddAt(int index, IAddress address) { if(address is EMailAddress) AddAt(index, (EMailAddress)address); } public int Count { get { return emails.Count; } } public void Clear() { emails.Clear(); } IAddress IAddressList.GetAddress(int index) { return GetAddress(index); } void IAddressList.Remove(IAddress address) { if(address is EMailAddress) Remove((EMailAddress)address); } public int Add(EMailAddress address) { return emails.Add(address); } public int Add(EMailAddress[] addresses) { foreach(EMailAddress current in addresses) { emails.Add(current); } return emails.Count; } public int IndexOf(EMailAddress address) { return emails.IndexOf(address); } public void AddAt(int index, EMailAddress address) { emails.Insert(index, address); } public EMailAddress GetAddress(int index) { return (EMailAddress)emails[index]; } public void Remove(EMailAddress address) { emails.Remove(address); } public void RemoveAt(int index) { emails.RemoveAt(index); } public IEnumerator GetEnumerator() { return emails.GetEnumerator(); } /// <summary> /// Returns a string of comma separataed addresses. /// </summary> public override string ToString() { string retVal = ""; foreach(EMailAddress current in this) { retVal += (current.ToString() + ","); } retVal = retVal.Substring(0, retVal.Length - 1); return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Folder * Comment: An abstract class representing a folder for mail messages.\ * A folder can contain a message, a folder or both. The only\ * method to get a Folder is by using the Folder { get; }\ * property of Store or Folder. * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public abstract class Folder //: IEnumerable { private Session session; protected Folder(Session session) { this.session = session; } public abstract char Delimiter { get; } public abstract FolderType FolderType { get; } public abstract bool HasNewMessages { get; } public abstract bool IsOpen { get; } public abstract bool IsSubscribed { get; } public abstract Folder Parent { get; } public abstract string FullName { get; } public abstract MessageFlags PermanentFlags { get; } public abstract Folder[] Children { get; } public abstract Folder[] SubscribedFolders { get; } [MailTODO] public int Count { get { throw new NotImplementedException(); } } [MailTODO] public bool Exists { get { throw new NotImplementedException(); } } [MailTODO] public Message[] Messages { get { throw new NotImplementedException(); } } [MailTODO] public FolderOpenMode Mode { get { throw new NotImplementedException(); } } [MailTODO] public string Name { get { throw new NotImplementedException(); } } [MailTODO] public int NewMessageCount { get { throw new NotImplementedException(); } } [MailTODO] public Store Store { get { throw new NotImplementedException(); } } [MailTODO] public int UnreadMessageCount { get { throw new NotImplementedException(); } } [MailTODO] public URLName URL { get { throw new NotImplementedException(); } } public abstract void AppendMessages(Message[] messages); public abstract void Close(); public abstract bool Create(FolderType type); public abstract bool Delete(bool recurse); public abstract Message[] Expunge(); public abstract Folder GetFolder(string name); public abstract Message GetMessage(int index); public abstract void Open(FolderOpenMode mode); public abstract bool RenameTo(Folder newFolder); [MailTODO] ~Folder() { throw new NotImplementedException(); } [MailTODO] public Message[] GetMessages(int[] indices) { throw new NotImplementedException(); } [MailTODO] public Message[] GetMessages(int start, int stop) { throw new NotImplementedException(); } [MailTODO] public override string ToString() { throw new NotImplementedException(); } } } --- NEW FILE --- /** * Namespace: CSMail * Class: FolderAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class FolderAddress { private string protocol; private string username; private string password; private string foldername; private string hostname = null; public FolderAddress(): this("smtp", null, null) { } public FolderAddress(string protocol, string username, string password): this(protocol, username, password, "localhost", null) { } public FolderAddress(string protocol, string username, string password, string hostname, string foldername) { this.protocol = protocol; this.username = username; this.password = password; this.hostname = hostname; this.foldername = foldername; } public string Protocol { get { return protocol; } } public string Username { get { return username; } } public string Password { get { return password; } } public string Foldername { get { return foldername; } } public string Hostname { get { return hostname; } } } } --- NEW FILE --- /** * Namespace: CSMail * Class: FolderEventArgs * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class FolderEventArgs { private FolderEventType eventType; private Folder folder; private Folder newFolder; public FolderEventArgs(Folder folder, FolderEventType eventType) { if(eventType == FolderEventType.Renamed || !Enum.IsDefined(typeof(FolderEventType), eventType)) { throw new ArgumentException(); } this.eventType = eventType; this.folder = folder; } public FolderEventArgs(Folder folder, Folder newFolder) { this.folder = folder; this.newFolder = newFolder; eventType = FolderEventType.Renamed; } public FolderEventType EventType { get { return eventType; } } public Folder Folder { get { return folder; } } public Folder NewFolder { get { if(eventType == FolderEventType.Renamed) return newFolder; return null; } } } } --- NEW FILE --- /** * Namespace: CSMail * Delegate: FolderEventHandler * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public delegate void FolderEventHandler(object sender, FolderEventArgs e); } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: FolderEventType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum FolderEventType { Created, Deleted, Renamed } } --- NEW FILE --- /** * Namespace: CSMail * Enumration: FolderOpenMode * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum FolderOpenMode { ReadOnly, ReadWrite } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: FolderSortStyle * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum FolderSortStyle { Default, Name, Size } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: FolderType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum FolderType { Folders, Messages, Both } } --- NEW FILE --- /** * Namespace: CSMail * Class: Header * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class Header { private string name; private string[] values; public Header(string name, string value) { this.name = name; values = new string[1]; values[0] = value; } public Header(string name, string[] values) { this.name = name; this.values = new string[values.Length]; int i = 0; foreach(string current in values) { this.values[i++] = current; } } public string Name { get { return name; } } public string Value { get { if(values != null) return values[0]; return null; } } public string[] Values { get { return values; } } public override string ToString() { string retVal = ""; foreach(string current in Values) { retVal += (name + ": " + current + "\r\n"); } return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: HeaderList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.Collections; using System.Collections.Specialized; namespace CSMail { public class HeaderList: IEnumerable { private ArrayList headers = new ArrayList(); public HeaderList(Header header) { headers.Add(header); } public HeaderList(Header[] headers) { foreach(Header current in headers) { this.headers.Add(current); } } public HeaderList(HeaderList headers) { foreach(Header current in headers) { this.headers.Add(current); } } public int Count { get { return headers.Count; } } public Header this[int index] { get { return (Header)(headers[index]); } set { headers[index] = value; } } public IEnumerator GetEnumerator() { return headers.GetEnumerator(); } public int Add(Header header) { return headers.Add(header); } public int Add(Header[] headers) { foreach(Header current in headers) { this.headers.Add(current); } return this.headers.Count; } public int IndexOf(Header header) { return headers.IndexOf(header); } public int IndexOf(string fullHeader, bool ignoreCase) { if(fullHeader == null || fullHeader == "") { return -1; } int i=0; foreach(Header current in this) { if(String.Compare(fullHeader, current.ToString(), ignoreCase) == 0) { return i; } } return -1; } public void Remove(Header header) { headers.Remove(header); } public void RemoveAt(int index) { if(index < 0 || index > headers.Count) { return; } headers.RemoveAt(index); } public bool Exists(string fullHeader, bool ignoreCase) { if(fullHeader == null || fullHeader == "") { return false; } foreach(Header current in this) { if(String.Compare(current.ToString(), fullHeader, ignoreCase) == 0) { return true; } } return false; } public bool Exists(Header header) { return headers.Contains(header); } public void RemoveAll(string name, bool ignoreCase) { ArrayList delete = new ArrayList(); foreach(Header current in this) { if(String.Compare(name, current.Name, ignoreCase) == 0) { delete.Add(current); } } foreach(Header current in delete) { headers.Remove(current); } } public void Remove(string fullHeader, bool ignoreCase) { RemoveAt(IndexOf(fullHeader, ignoreCase)); } public override string ToString() { string retVal = ""; foreach(Header current in this) { retVal += current.ToString(); } return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public interface IAddress { AddressType AddressType { get; } bool Equals(IAddress address); } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IAddressList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public interface IAddressList { int Count { get; } int Add(IAddress address); void AddAt(int index, IAddress address); void Clear(); IAddress GetAddress(int index); void Remove(IAddress iaddress); void RemoveAt(int index); } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IEncode * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public interface IEncode { string ContentType { get; } /** * I think, I should replace them with a stream (reader) */ string DecodedData { get; } string EncodedData { get; } TransferEncoding TransferEncoding { get; set; } ContentDisposition ContentDisposition { get; set; } } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IMimePart * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public interface IMimePart: IPart { string ContentID { get; set; } string ContentLanguage { get; set; } string ContentMD5 { get; set; } //HeaderList Headers { get; set; } string Text { get; set; } TransferEncoding TransferEncoding { get; set; } } } --- NEW FILE --- /** * Namespace: CSMail * Interface: IPart * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.IO; namespace CSMail { public interface IPart { Multipart Content { get; set; } ContentType ContentType { get; set; } string Description { get; set; } ContentDisposition Disposition { get; set; } string Filename { get; set; } HeaderList Headers { get; set; } int Size { get; set; } int AddHeader(Header header); int AddHeaders(HeaderList headers); void Write(TextWriter writer); } } --- NEW FILE --- /** * Namespace: CSMail * Class: InternetAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class InternetAddress { private string hostname; private int[] ip; private bool isIP; public InternetAddress(string hostname) { hostname = hostname.Trim(); this.hostname = hostname; if(CheckIfIP(hostname)) { isIP = true; } } public InternetAddress(int[] ip) { if(!ValidIP(ip)) { throw new ArgumentException(); } this.ip = new int[4]; int i = 0; foreach(int current in ip) { this.ip[i++] = current; } hostname = ConvertToAddress(ip); this.isIP = true; } public string Hostname { get { return hostname; } } public bool IsIP { get { return isIP; } } public int[] getIP { get { if(IsIP) { return ip; } return null; } } private string ConvertToAddress(int[] ip) { string retVal = ""; foreach(int current in ip) { retVal += current.ToString() + "."; } retVal = retVal.Substring(0, retVal.Length - 1); return retVal; } private bool ValidIP(int[] ip) { if(ip.Length != 4) return false; foreach(int current in ip) { if(current < 0 || current > 255) return false; } return true; } private bool CheckIfIP(string host) { string[] seps = host.Split(new char[] {'.'}); if(seps.Length != 4) return false; int val; foreach(string current in seps) { val = Int32.Parse(current); if(val < 0 || val > 255) return false; } return true; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Message * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.IO; namespace CSMail { public abstract class Message: IPart { protected Folder folder; protected int index; protected Session session; protected Message() { } protected Message(Folder folder, int index) { this.folder = folder; this.index = index; } protected Message(Session session) { this.session = session; } public abstract MessageFlags Flags { get; set; } public abstract EMailAddressList From { get; set; } public abstract DateTime ReceivedDate { get; set; } public abstract IAddressList Recipients { get; } public abstract DateTime SentDate { get; set; } public abstract string Subject { get; set; } public abstract void AddFrom(EMailAddress address); public abstract void AddFrom(EMailAddressList address); public abstract void AddRecipient(RecipientType type, EMailAddress email); public abstract void AddRecipients(RecipientType type, EMailAddressList emails); public abstract void AddRecipient(NewsAddress email); public abstract void AddRecipients(NewsAddressList email); public abstract Message GetReplyMessage(bool toAll); public abstract IAddressList GetRecipients(RecipientType type); public abstract void SaveChanges(); public abstract Multipart Content { get; set; } public abstract ContentType ContentType { get; set; } public abstract string Description { get; set; } public abstract ContentDisposition Disposition { get; set; } public abstract string Filename { get; set; } public abstract HeaderList Headers { get; set; } public abstract int Size { get; set; } public abstract int AddHeader(Header header); public abstract int AddHeaders(HeaderList headers); public abstract void Write(TextWriter writer); [MailTODO] public virtual Folder Folder { get { throw new NotImplementedException(); } } [MailTODO] public bool IsExpunged { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } [MailTODO] public IAddressList ReplyTo { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } [MailTODO] public bool IsSet(MessageFlags flag) { throw new NotImplementedException(); } } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: MessageFlags * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { [Flags] public enum MessageFlags { None = 0x0000, Answered = 0x0001, Deleted = 0x0002, Draft = 0x0004, Flagged = 0x0010, Recent = 0x0020, Seen = 0x0040, UserDefined = 0x8000, } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: MessageSortStyle * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum MessageSortStyle { Default, From, Size, Date, Subject } } --- NEW FILE --- /** * Namespace: CSMail * Class: Multipart * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public abstract class Multipart { private IPart part; public IPart Part { get { return part; } set { part = value; } } } } --- NEW FILE --- /** * Namespace: CSMail * Class: NewsAddress * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.Collections; namespace CSMail { public class NewsAddress: IAddress { private string hostname; private ArrayList groups = new ArrayList(); public NewsAddress(string host, string group) { hostname = host; groups.Add(group); } public NewsAddress(string host, string[] groups) { if(groups == null || groups.Length == 0) { throw new ArgumentException(); } hostname = host; foreach(string current in groups) { this.groups.Add(current); } } public AddressType AddressType { get { return AddressType.NewsAddress; } } public string Hostname { get { return hostname; } } public string Group { get { if(groups.Count > 0) { return (string)groups[0]; } return null; } } public string[] Groups { get { if(groups.Count > 0) { string[] retVal = new string[groups.Count]; for(int i=0; i < groups.Count; i++) { retVal[i] = (string)groups[i]; } return retVal; } return null; } } public int Add(string group) { return groups.Add(group); } public void Remove(string group) { groups.Remove(group); } public bool Contains(string group) { return groups.Contains(group); } public override int GetHashCode() { return hostname.GetHashCode() + (Group == null ? 0xFFFF : Group.GetHashCode()); } public override bool Equals(object obj) { if(obj is NewsAddress) { return Equals((NewsAddress)obj); } return false; } public bool Equals(IAddress address) { if(address is NewsAddress) { return Equals((NewsAddress)address); } return false; } public bool Equals(NewsAddress address) { if(address.hostname == hostname && Groups != null && address.Groups != null && Groups.Length == address.Groups.Length) { for(int i=0; i < groups.Count; i++) { if(String.Compare(Groups[i], address.Groups[i], false) != 0) { return false; } } return true; } return false; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: NewsAddressList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class NewsAddressList: IAddressList, IEnumerable { private ArrayList news = new ArrayList(); public NewsAddressList() { } public NewsAddressList(NewsAddressList[] addresses) { foreach(NewsAddressList current in addresses) { news.Add(current); } } public NewsAddressList(NewsAddressList addresses) { foreach(NewsAddressList current in addresses) { news.Add(current); } } public NewsAddressList this[int index] { get { return (NewsAddressList)news[index]; } set { news[index] = value; } } int IAddressList.Add(IAddress address) { if(address is NewsAddressList) return Add((NewsAddressList)address); return -1; } void IAddressList.AddAt(int index, IAddress address) { if(address is NewsAddressList) AddAt(index, (NewsAddressList)address); } public int Count { get { return news.Count; } } public void Clear() { news.Clear(); } IAddress IAddressList.GetAddress(int index) { return GetAddress(index); } void IAddressList.Remove(IAddress address) { if(address is NewsAddressList) Remove((NewsAddressList)address); } public int Add(NewsAddressList address) { return news.Add(address); } public int Add(NewsAddressList[] addresses) { foreach(NewsAddressList current in addresses) { news.Add(current); } return news.Count; } public int IndexOf(NewsAddressList address) { return news.IndexOf(address); } public void AddAt(int index, NewsAddressList address) { news.Insert(index, address); } public NewsAddress GetAddress(int index) { return (NewsAddress)news[index]; } public void Remove(NewsAddressList address) { news.Remove(address); } public void RemoveAt(int index) { news.RemoveAt(index); } public IEnumerator GetEnumerator() { return news.GetEnumerator(); } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Parameter * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class Parameter { private string name; private string value; public Parameter(string name, string value) { this.name = name; this.value = value; } public string Name { get { return name; } } public string Value { get { return value; } } } } --- NEW FILE --- /** * Namespace: CSMail * Class: ParameterList * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; namespace CSMail { public class ParameterList: IEnumerable { private Hashtable parameters; public ParameterList(Parameter parameter) { parameters = new Hashtable(); parameters.Add(parameter.Name, parameter.Value); } public ParameterList(Parameter[] parameters) { this.parameters = new Hashtable(); foreach(Parameter current in parameters) { this.parameters.Add(current.Name, current.Value); } } public ParameterList(ParameterList parameters) { this.parameters = new Hashtable(); foreach(string name in parameters) { this.parameters.Add(name, parameters[name]); } } public string this[string name] { get { return (string)(parameters[name]); } set { parameters[name] = value; } } public int Count { get { return parameters.Count; } } public void Add(Parameter parameter) { parameters.Add(parameter.Name, parameter.Value); } public void Remove(Parameter parameter) { Remove(parameter.Name); } public void Remove(string name) { if(parameters.ContainsKey(name)) parameters.Remove(name); } /// <summary> /// Returns an Enumerator on the Name(s) of the Parameter(s) /// </summary> public IEnumerator GetEnumerator() { return (IEnumerator)(parameters.Keys); } public override string ToString() { string retVal = ""; foreach(string key in this) { retVal += (key + "=\"" + this[key] + "\";"); } retVal = retVal.Substring(0, retVal.Length - 1); return retVal; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Provider * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class Provider { private string className; private string protocol; private ProviderType type; private string vendor; private string version; internal Provider() { //TODO: Initialize the values from the configuration file Initialize(String.Empty); } internal Provider(string configFile) { Initialize(configFile); } [MailTODO] internal void Initialize(string configFile) { throw new NotImplementedException(); } public string ClassName { get { return className; } } public string Protocol { get { return protocol; } } public ProviderType ProviderType { get { return type; } } public string Vendor { get { return vendor; } } public string Version { get { return version; } } } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: ProviderType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum ProviderType { Store, Transport } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: RecipientType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { [Flags] public enum RecipientType: short { To = 0x0001, Cc = 0x0002, Bcc = 0x0004, NewsGroup = 0x0010, All = To | Cc | Bcc | NewsGroup } } --- NEW FILE --- /** * Namespace: CSMail * Class: Service * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public abstract class Service { protected bool connected; protected bool debug; protected Session session; protected URLName url; protected Service(Session session, URLName url) { this.session = session; this.url = url; } public URLName URL { get { return url; } } public bool Connected { get { return connected; } } [MailTODO] public void Close() { throw new NotImplementedException(); } [MailTODO] public void Connect() { throw new NotImplementedException(); } [MailTODO] public void Connect(InternetAddress hostname, string username, string password) { throw new NotImplementedException(); } [MailTODO] public void Connect(InternetAddress hostname, int port, string username, string password) { throw new NotImplementedException(); } [MailTODO] ~Service() { throw new NotImplementedException(); } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Session * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System.Collections; using CSMail.Utils; namespace CSMail { public class Session { private Properties properties; private Authentiactor authenticator; private Hashtable authTable; private ArrayList providers; private Hashtable provByProto; private Hashtable provByClass; private Properties addrMap; private bool debug; private static Session defaultSession; private Session() { } private Session(Properties properties, Authenticator authenticator) { this.properties = properties; this.authenticator = authenticator; this.debug = false; authTable = new Hashtable(); providers = new ArrayList(); provByProto = new Hashtable(); provByClass = new Hashtable(); addrMap = new Properties(); // debug = bool.Parse(this.properties["mail.debug"]) } public Session GetDefaultInstance(Properties properties, Authenticator authenticator) { if(defaultSession == null) { defaultSession = new Session(); // Do some initialization??? } return defaultSession; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: Store * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public abstract class Store: Service { public Store(Session session, URLName url): base(session, url) { } public abstract Folder DefaultFolder { get; } public abstract Folder this[string folderName] { get; } public abstract Folder this[URLName url] { get; } } } --- NEW FILE --- /** * Namespace: CSMail * Class: MailTODOAttribute * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { [AttributeUsage(AttributeTargets.All)] internal class MailTODOAttribute: Attribute { string comment; public MailTODOAttribute() { comment = ""; } public MailTODOAttribute(string comment) { this.comment = comment; } } } --- NEW FILE --- /** * Namespace: CSMail * Enumeration: TransferEncoding * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum TransferEncoding { Default, Bit7, Bit8, QuotedPrintable, Base64, Binary, UUEncode, UserDefined } } --- NEW FILE --- /** * Namespace: CSMail * Class: URLName * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; using System.Net; namespace CSMail { public class URLName { private string protocol = "smtp"; private string host = "localhost"; private int port = 25; private string username; private string password; private string file; private string fullUrl; public URLName(string url) { ParseURL(url); fullUrl = url; } public URLName(string protocol, string host, int port, string user, string pass, string file) { this.protocol = protocol; this.host = host; this.port = port; this.username = user; this.password = pass; this.file = file; fullUrl = protocol + "://" + host; if(user != null && user.Length > 0) { fullUrl += user; if(pass != null && pass.Length > 0) { fullUrl += ":" + pass; } fullUrl += "@"; } fullUrl += host; if(port > 0) { fullUrl += ":" + port.ToString(); } if(!file.StartsWith("/")) { fullUrl += "/"; } fullUrl += file; } public string Protocol { get { return protocol; } } public string Host { get { return host; } } public int Port { get { return port; } } public string Username { get { return username; } } public string Password { get { return password; } } public string File { get { return file; } } [MailTODO] /// <summary> /// The URL is to be of the form: /// protocol://[user[:pass@]]host[:port]/file /// </summary> private void ParseURL(string url) { throw new NotImplementedException(); } public override bool Equals(object obj) { if(obj is URLName) { return Equals((URLName)obj); } return false; } public bool Equals(URLName url) { if(url.Protocol == protocol && url.Host == host && url.Port == port && url.Username == username && url.Password == password) { return true; } return false; } public override int GetHashCode() { return fullUrl.GetHashCode(); } } } |