[Csmail-patches] CVS: csmail/src/CSMail ChangeLog,1.48,1.49 ContentType.cs,1.4,1.5 EMailAddressList.
Status: Pre-Alpha
Brought to you by:
mastergaurav
From: Gaurav V. <mas...@us...> - 2002-09-30 04:01:40
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv3800 Modified Files: ChangeLog ContentType.cs EMailAddressList.cs HeaderList.cs IMimePart.cs Message.cs MimeBodyPart.cs MimeMessage.cs ParameterList.cs ProviderList.cs TODO Log Message: 2002-09-27 * ContentType.cs : operator ==, != - Implemented. : ctor(string) - Stubbed. * EMailAddressList.cs : ctor(string) - Stubbed. * HeaderList.cs : GetAsHeader(string) - Stubbed. * IMimePart.cs : ContentLanguage - Value is "string[]". : MimeBodyPart.cs : ContentLanguage - Value is "string[]". - To do fresh implementation. * MimeMessage.cs : ContentLanguage - Value is "string[]", - Marked virtual. : ContentMD5 { get; set; }, : ContentID { get; set; }, : Filename { get; set; }, : Subject { get; set; }, : Description { get; set; }, : Flags { get; set; } - Implemented. : ReadContent(StreamReader) - Implemented. : ReceivedDate - Readonly, implemented. : SentDate - Implemented. * Message.cs : ReceivedDate - Readonly. : ContentType - Not abstract. * ProviderList.cs : More stubs. * TODO : Add MimeMessage to the list. Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- ChangeLog 26 Sep 2002 11:52:00 -0000 1.48 +++ ChangeLog 30 Sep 2002 04:01:37 -0000 1.49 @@ -1,4 +1,32 @@ +2002-09-27 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * ContentType.cs : operator ==, != - Implemented. + : ctor(string) - Stubbed. + * EMailAddressList.cs : ctor(string) - Stubbed. + * HeaderList.cs : GetAsHeader(string) + - Stubbed. + * IMimePart.cs : ContentLanguage - Value is "string[]". + : MimeBodyPart.cs : ContentLanguage - Value is "string[]". + - To do fresh implementation. + * MimeMessage.cs : ContentLanguage - Value is "string[]", + - Marked virtual. + : ContentMD5 { get; set; }, + : ContentID { get; set; }, + : Filename { get; set; }, + : Subject { get; set; }, + : Description { get; set; }, + : Flags { get; set; } + - Implemented. + : ReadContent(StreamReader) + - Implemented. + : ReceivedDate - Readonly, implemented. + : SentDate - Implemented. + * Message.cs : ReceivedDate - Readonly. + : ContentType - Not abstract. + * ProviderList.cs : More stubs. + * TODO : Add MimeMessage to the list. + 2002-09-26 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * MimeMultipart.cs : ParseBodyParts() - Looks done. Index: ContentType.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ContentType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ContentType.cs 26 Sep 2002 09:47:10 -0000 1.4 +++ ContentType.cs 30 Sep 2002 04:01:37 -0000 1.5 @@ -37,10 +37,10 @@ } /// <summary> - /// Create an instance with the + /// Create an instance with the /// <paramref name="primary"/> as the <see cref="PrimaryType"/> /// and <paramref name="sub"/> as the <see cref="SubType"/>, - /// and a list of associated parameters. + /// and a list of associated <paramref name="parameters"/>. /// </summary> public ContentType(string primary, string sub, ParameterList parameters) { @@ -55,6 +55,19 @@ } } + /// <remarks> + /// <code> + /// <paramref name="headerValue"/> := primarytype '/' subtype [plist] + /// plist := *(; params) + /// params := key '=' value + /// </code> + /// </remarks> + [MailTODO] + public ContentType(string headerValue) + { + throw new NotImplementedException(); + } + /// <summary> /// Gets the primary type of the content. /// </summary> @@ -106,12 +119,34 @@ } } + public static bool operator == (ContentType left, ContentType right) + { + if(left == null && right == null) + return true; + + if(left == null || right == null) + return false; + + bool retVal = true; + retVal &= (String.Compare(left.PrimaryType, + right.PrimaryType, false) == 0); + retVal &= (String.Compare(left.SubType, + right.SubType, false) == 0); + return retVal; + } + + public static bool operator != (ContentType left, ContentType right) + { + return !(left == right); + } + /// <summary> /// Checks for the equality with an object. /// </summary> /// <remarks> - /// <c>obj</c> may be of type <c>ContentType</c> or - /// <c>string</c>. + /// <paramref name="obj"/> may be of type + /// <see cref="T:CSMail.ContentType"/> or + /// <see cref="T:System.String"/>. /// </remarks> public override bool Equals(object obj) { @@ -129,6 +164,8 @@ /// <summary> /// Checks for the equality. /// </summary> + /// <param name="cType">Content type to check + /// against.</param> public bool Equals(ContentType cType) { if(cType != null) Index: EMailAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddressList.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- EMailAddressList.cs 6 Sep 2002 09:30:27 -0000 1.2 +++ EMailAddressList.cs 30 Sep 2002 04:01:37 -0000 1.3 @@ -64,6 +64,12 @@ } } + [MailTODO] + public EMailAddressList(string headerValue) + { + throw new NotImplementedException(); + } + /// <summary> /// Gets or sets an address at the specified index. /// </summary> Index: HeaderList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/HeaderList.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- HeaderList.cs 24 Sep 2002 08:34:52 -0000 1.6 +++ HeaderList.cs 30 Sep 2002 04:01:37 -0000 1.7 @@ -139,6 +139,12 @@ } } + [MailTODO] + public Header[] GetAsHeader(string name) + { + throw new NotImplementedException(); + } + /// <summary> /// Returns an enumerator for the list for iteration. /// </summary> Index: IMimePart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/IMimePart.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- IMimePart.cs 5 Sep 2002 05:17:49 -0000 1.2 +++ IMimePart.cs 30 Sep 2002 04:01:37 -0000 1.3 @@ -22,7 +22,7 @@ /// <summary> /// When implemented, gets or sets the content language associated. /// </summary> - string ContentLanguage { get; set; } + string[] ContentLanguage { get; set; } /// <summary> /// When implemented, gets or sets the content-MD5 associated. /// </summary> Index: Message.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Message.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Message.cs 9 Sep 2002 11:07:22 -0000 1.8 +++ Message.cs 30 Sep 2002 04:01:37 -0000 1.9 @@ -34,6 +34,10 @@ /// Has this been message expunged from the folder? /// </summary> protected bool isExpunged; + /// <summary> + /// Holds the content type for the message. + /// </summary> + protected ContentType CType; protected Message() { @@ -51,9 +55,21 @@ this.session = session; } + public virtual ContentType ContentType + { + get + { + return CType; + } + set + { + CType = value; + } + } + public abstract MessageFlags Flags { get; set; } public abstract EMailAddressList From { get; set; } - public abstract DateTime ReceivedDate { get; set; } + public abstract DateTime ReceivedDate { get; } public abstract IAddressList Recipients { get; } public abstract DateTime SentDate { get; set; } public abstract string Subject { get; set; } @@ -69,7 +85,6 @@ 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; } Index: MimeBodyPart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeBodyPart.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MimeBodyPart.cs 24 Sep 2002 08:34:52 -0000 1.5 +++ MimeBodyPart.cs 30 Sep 2002 04:01:37 -0000 1.6 @@ -211,15 +211,16 @@ /// <summary> /// Gets or sets the value of "Content-Language" header. /// </summary> - public virtual string ContentLanguage + /// [MailTODO] + public virtual string[] ContentLanguage { get { - return Headers["Content-Language"]; + throw new NotImplementedException(); } set { - Headers["Content-Language"] = value; + throw new NotImplementedException(); } } Index: MimeMessage.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeMessage.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MimeMessage.cs 26 Sep 2002 11:52:00 -0000 1.2 +++ MimeMessage.cs 30 Sep 2002 04:01:37 -0000 1.3 @@ -8,6 +8,7 @@ * (C) Gaurav Vaish (2002) */ +using CSMail.Utils; using System; using System.IO; @@ -15,47 +16,73 @@ { public class MimeMessage : Message, IMimePart, IPart { - protected byte[] content; - protected StreamReader contentReader; - protected HeaderList headers; - protected MessageFlags flags; - protected bool isModified = false; - protected bool isSaved = false; + protected byte[] content = null; + protected StreamReader contentReader = null; + protected HeaderList headers = new HeaderList(); + protected MessageFlags flags = MessageFlags.None; + protected bool isModified = false; + protected bool isSaved = false; private bool isStrict = false; - [MailTODO] public MimeMessage(Session session) : base(session) { - throw new NotImplementedException(); + Initialize(); + CType = new ContentType("multipart", "mixed"); } - [MailTODO] public MimeMessage(Session session, StreamReader reader) : base(session) { - throw new NotImplementedException(); + Initialize(); + ParseMessage(reader); + isSaved = true; } [MailTODO] - public MimeMessage(MimeMessage message) + public MimeMessage(MimeMessage message) : base(message.session) { + flags = message.flags; + isStrict = message.isStrict; + isModified = false; throw new NotImplementedException(); + //isSaved = true; } - public override Multipart Content + [MailTODO] + private void Initialize() { - get + if(session != null) { - throw new NotImplementedException(); + String strict = (string)session.Properties["CSMail.mime.address.scrict"]; + isStrict = (strict == null || + String.Compare(strict, "false", false) != 0); } - set + throw new NotImplementedException(); + } + + [MailTODO] + protected virtual void ParseMessage(StreamReader reader) + { + headers = new HeaderList(reader); + CType = new ContentType(headers["Content-Type"]); + ReadContent(reader); + // Create the "contentStream" + throw new NotImplementedException(); + } + + private void ReadContent(StreamReader reader) + { + string data = reader.ReadToEnd(); + content = new byte[data.Length]; + for(int i = 0; i < content.Length; i++) { - throw new NotImplementedException(); + content[i] = (byte)data[i]; } } - public override ContentType ContentType + [MailTODO] + public override Multipart Content { get { @@ -71,11 +98,11 @@ { get { - throw new NotImplementedException(); + return flags; } set { - throw new NotImplementedException(); + flags = value; } } @@ -83,11 +110,11 @@ { get { - throw new NotImplementedException(); + return new EMailAddressList(headers["From"]); } set { - throw new NotImplementedException(); + headers["From"] = value.ToString(); } } @@ -95,14 +122,11 @@ { get { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); + return DateUtils.ParseToLocalTime(headers.GetAsHeader("Received")[0]); } } + [MailTODO] public override IAddressList Recipients { get @@ -115,11 +139,11 @@ { get { - throw new NotImplementedException(); + return DateUtils.ParseToLocalTime(headers.GetAsHeader("Date")[0]); } set { - throw new NotImplementedException(); + headers["Date"] = DateUtils.CreateDateHeader(value); } } @@ -127,11 +151,11 @@ { get { - throw new NotImplementedException(); + return headers["Subject"]; } set { - throw new NotImplementedException(); + headers["Subject"] = value; } } @@ -139,11 +163,11 @@ { get { - throw new NotImplementedException(); + return headers["Content-Description"]; } set { - throw new NotImplementedException(); + headers["Content-Description"] = value; } } @@ -163,11 +187,18 @@ { get { - throw new NotImplementedException(); + ParameterList list = MimeUtils.GetParametersAsList( + headers["Content-Disposition"], null); + if(list != null) + { + return list["Filename"]; + } + return null; } set { - throw new NotImplementedException(); + headers["Content-Disposition"] = "attachment ; filename=" + + "\"" + value + "\""; } } @@ -183,27 +214,28 @@ { get { - throw new NotImplementedException(); + return headers; } set { - throw new NotImplementedException(); + headers = value; } } - public string ContentID + public virtual string ContentID { get { - throw new NotImplementedException(); + return headers["Content-ID"]; } set { - throw new NotImplementedException(); + headers["Content-ID"] = value; } } - public string ContentLanguage + [MailTODO] + public virtual string[] ContentLanguage { get { @@ -215,19 +247,20 @@ } } - public string ContentMD5 + public virtual string ContentMD5 { get { - throw new NotImplementedException(); + return headers["Content-MD5"]; } set { - throw new NotImplementedException(); + headers["Content-MD5"] = value; } } - public string Text + [MailTODO] + public virtual string Text { get { @@ -239,7 +272,7 @@ } } - public TransferEncoding TransferEncoding + public virtual TransferEncoding TransferEncoding { get { Index: ParameterList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ParameterList.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ParameterList.cs 26 Sep 2002 09:47:10 -0000 1.2 +++ ParameterList.cs 30 Sep 2002 04:01:37 -0000 1.3 @@ -45,6 +45,8 @@ } } + // FIXME: The matching should be case-insensitive. + // Currently, it's all case sensitive. public string this[string name] { get Index: ProviderList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ProviderList.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ProviderList.cs 30 Aug 2002 10:31:26 -0000 1.4 +++ ProviderList.cs 30 Sep 2002 04:01:37 -0000 1.5 @@ -40,5 +40,23 @@ { return providers.GetEnumerator(); } + + [MailTODO] + public int Add(Provider[] providers) + { + throw new NotImplementedException(); + } + + [MailTODO] + public void Remove(Provider provider) + { + throw new NotImplementedException(); + } + + [MailTODO] + public void RemoveAt(int index) + { + throw new NotImplementedException(); + } } } Index: TODO =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TODO 6 Sep 2002 11:52:29 -0000 1.3 +++ TODO 30 Sep 2002 04:01:37 -0000 1.4 @@ -13,3 +13,4 @@ MimeMessage -- Implements IMimePart * Some other? -- Implements IXXXXPart * MimeMultipart -- Extends Multipart + * MimeMessage -- Extends Message. Complete it. |