[Csmail-patches] CVS: csmail/src/CSMail BodyPart.cs,1.8,1.9 ChangeLog,1.49,1.50 EMailAddressList.cs,
Status: Pre-Alpha
Brought to you by:
mastergaurav
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv8862 Modified Files: BodyPart.cs ChangeLog EMailAddressList.cs IPart.cs Message.cs MimeBodyPart.cs MimeMessage.cs NewsAddressList.cs Log Message: 2002-09-30 * EMailAddressList.cs : operator + - Stubbed. : operator = - Implemented. * BodyPart.cs : Size - Changed to "long". * IPart.cs : Size - Changed to "long". * Message.cs : Size - Changed to "long". * MimeBodyPart.cs : Size - Changed to "long". * MimeMessage.cs : Filename { set; } - Fixed bug. Now does not lose any other parameters defined. : Size { get; } - Implemented. Changed to "long" : AddRecipient(...) - Implemented. : AddRecipients(...) - Implemented. * NewsAddressList.cs : Add(NewsAddress) - Implemented. Index: BodyPart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/BodyPart.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- BodyPart.cs 26 Sep 2002 09:47:10 -0000 1.8 +++ BodyPart.cs 30 Sep 2002 12:27:22 -0000 1.9 @@ -108,7 +108,7 @@ /// <summary> /// When implemented by a class, gets the siz of content. /// </summary> - public abstract int Size { get; } + public abstract long Size { get; } /** /// <summary> Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- ChangeLog 30 Sep 2002 04:01:37 -0000 1.49 +++ ChangeLog 30 Sep 2002 12:27:22 -0000 1.50 @@ -1,4 +1,20 @@ +2002-09-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * EMailAddressList.cs : operator + - Stubbed. + : operator = - Implemented. + * BodyPart.cs : Size - Changed to "long". + * IPart.cs : Size - Changed to "long". + * Message.cs : Size - Changed to "long". + * MimeBodyPart.cs : Size - Changed to "long". + * MimeMessage.cs : Filename { set; } - Fixed bug. Now does not + lose any other parameters defined. + : Size { get; } - Implemented. + Changed to "long" + : AddRecipient(...) - Implemented. + : AddRecipients(...) - Implemented. + * NewsAddressList.cs : Add(NewsAddress) - Implemented. + 2002-09-27 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * ContentType.cs : operator ==, != - Implemented. Index: EMailAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/EMailAddressList.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- EMailAddressList.cs 30 Sep 2002 04:01:37 -0000 1.3 +++ EMailAddressList.cs 30 Sep 2002 12:27:22 -0000 1.4 @@ -138,6 +138,12 @@ } } + [MailTODO] + public bool Contains(EMailAddress address) + { + throw new NotImplementedException(); + } + /// <summary> /// Clears the list. /// </summary> @@ -272,6 +278,66 @@ public IEnumerator GetEnumerator() { return emails.GetEnumerator(); + } + + public static EMailAddressList operator +(EMailAddressList list, + EMailAddress address) + { + if(list == null && address == null) + { + return null; + } + EMailAddressList retVal = new EMailAddressList(); + if(list != null) + { + foreach(EMailAddress current in list) + { + if(!retVal.Contains(current)) + retVal.Add(current); + } + } + if(address != null && !retVal.Contains(address)) + { + retVal.Add(address); + } + return retVal; + } + + public static EMailAddressList operator +(EMailAddress address, + EMailAddressList list) + { + return (list + address); + } + + public static EMailAddressList operator +(EMailAddressList one, + EMailAddressList two) + { + if(one == null && two == null) + { + return null; + } + + EMailAddressList retVal = null; + if(one == null) + { + retVal = two; + } + + if(two == null) + { + retVal = one; + } + + if(one != null && two != null) + { + retVal = one; + foreach(EMailAddress current in two) + { + if(!retVal.Contains(current)) + retVal.Add(current); + } + } + return retVal; } /// <summary> Index: IPart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/IPart.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- IPart.cs 9 Sep 2002 09:37:54 -0000 1.3 +++ IPart.cs 30 Sep 2002 12:27:22 -0000 1.4 @@ -45,7 +45,7 @@ /// <summary> /// When implemented, gets the size of the part. /// </summary> - int Size { get; } + long Size { get; } /** /// <summary> Index: Message.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Message.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Message.cs 30 Sep 2002 04:01:37 -0000 1.9 +++ Message.cs 30 Sep 2002 12:27:22 -0000 1.10 @@ -89,7 +89,7 @@ public abstract ContentDisposition Disposition { get; set; } public abstract string Filename { get; set; } public abstract HeaderList Headers { get; set; } - public abstract int Size { get; } + public abstract long Size { get; } //public abstract int AddHeader(Header header); //public abstract int AddHeaders(HeaderList headers); Index: MimeBodyPart.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeBodyPart.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- MimeBodyPart.cs 30 Sep 2002 04:01:37 -0000 1.6 +++ MimeBodyPart.cs 30 Sep 2002 12:27:22 -0000 1.7 @@ -67,7 +67,7 @@ /// (the actual message), in bytes, for this body part. /// </value> [MailTODO] - public override int Size + public override long Size { get { Index: MimeMessage.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MimeMessage.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MimeMessage.cs 30 Sep 2002 04:01:37 -0000 1.3 +++ MimeMessage.cs 30 Sep 2002 12:27:22 -0000 1.4 @@ -22,6 +22,13 @@ protected MessageFlags flags = MessageFlags.None; protected bool isModified = false; protected bool isSaved = false; + protected StreamReader reader = null; + + protected EMailAddressList toList = new EMailAddressList(); + protected EMailAddressList ccList = new EMailAddressList(); + protected EMailAddressList bccList = new EMailAddressList(); + protected NewsAddressList ngroupList = new NewsAddressList(); + protected EMailAddressList replyList = new EMailAddressList(); private bool isStrict = false; @@ -35,7 +42,8 @@ : base(session) { Initialize(); - ParseMessage(reader); + this.reader = reader; + ParseMessage(); isSaved = true; } @@ -62,16 +70,16 @@ } [MailTODO] - protected virtual void ParseMessage(StreamReader reader) + protected virtual void ParseMessage() { headers = new HeaderList(reader); CType = new ContentType(headers["Content-Type"]); - ReadContent(reader); + ReadContent(); // Create the "contentStream" throw new NotImplementedException(); } - private void ReadContent(StreamReader reader) + private void ReadContent() { string data = reader.ReadToEnd(); content = new byte[data.Length]; @@ -187,8 +195,8 @@ { get { - ParameterList list = MimeUtils.GetParametersAsList( - headers["Content-Disposition"], null); + ParameterList list = MimeUtils.GetParametersAsList + (headers["Content-Disposition"], null); if(list != null) { return list["Filename"]; @@ -197,16 +205,36 @@ } set { - headers["Content-Disposition"] = "attachment ; filename=" - + "\"" + value + "\""; + ParameterList list = MimeUtils.GetParametersAsList + (headers["Content-Disposition"], null); + if(list == null) + { + list = new ParameterList(); + } + list.Add(new Parameter("filename", + StringUtils.Escape(value))); + headers["Content-Disposition"] = list.ToString(); } } - public override int Size + public override long Size { get { - throw new NotImplementedException(); + if(reader != null) + { + Stream baseStream = reader.BaseStream; + if(baseStream != null) + { + try + { + return baseStream.Length; + } catch(NotSupportedException) + { + } + } + } + return -1; } } @@ -284,30 +312,71 @@ } } + [MailTODO] public override void AddRecipient(RecipientType type, EMailAddress email) { - throw new NotImplementedException(); + bool valid = false; + if((type & RecipientType.To) != 0x00) + { + valid = true; + toList.Add(email); + } + if((type & RecipientType.Cc) != 0x00) + { + valid = true; + ccList.Add(email); + } + if((type & RecipientType.Bcc) != 0x00) + { + valid = true; + bccList.Add(email); + } + if((type & RecipientType.NewsGroup) == 0x00) + { + valid = false; + } + if(!valid) + { + // checking it at the end guarantees that + // the name is added to all other types + // throw an exception + throw new NotImplementedException(); + } } public override void AddRecipients(RecipientType type, EMailAddressList emails) { - throw new NotImplementedException(); + foreach(EMailAddress current in emails) + { + AddRecipient(type, current); + } } public override void AddRecipient(NewsAddress address) { - throw new NotImplementedException(); + ngroupList.Add(address); } - public override void AddRecipients(NewsAddressList address) + public override void AddRecipients(NewsAddressList addresses) { - throw new NotImplementedException(); + foreach(NewsAddress current in addresses) + { + ngroupList.Add(current); + } } public override Message GetReplyMessage(bool toAll) { + replyList = new EMailAddressList(); + if(toAll) + { + replyList = toList + ccList + bccList; + } else + { + replyList = toList; + } throw new NotImplementedException(); } Index: NewsAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/NewsAddressList.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- NewsAddressList.cs 20 Jun 2002 10:34:55 -0000 1.1 +++ NewsAddressList.cs 30 Sep 2002 12:27:22 -0000 1.2 @@ -90,6 +90,11 @@ return news.Add(address); } + public int Add(NewsAddress address) + { + return news.Add(address); + } + public int Add(NewsAddressList[] addresses) { foreach(NewsAddressList current in addresses) |