[Csmail-patches] CVS: csmail/src/CSMail Authenticator.cs,NONE,1.1 IllegalStateException.cs,NONE,1.1
Status: Pre-Alpha
Brought to you by:
mastergaurav
From: Gaurav V. <mas...@us...> - 2002-08-28 10:17:15
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv23610 Modified Files: ChangeLog Folder.cs FolderOpenMode.cs InternetAddress.cs InternetAddressList.cs MessageFlags.cs Session.cs Added Files: Authenticator.cs IllegalStateException.cs MessageRemovedException.cs Log Message: 2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Authenticator.cs : Added class. * IllegalStateException.cs : Added exception class. * FolderOpenMode.cs : Added fields "Default", "NotSet" * MessageFlags.cs : Reformatting of flags. * Folder.cs : Constructor. Parameter is Store, not Session : Count { get; } - Made abstract : Exists { get; } - Made abstract : Messages { get; } - Made abstract : Mode { get; } - Implemented : Name { get; } - Made abstract : Store { get; } - Implemented : URL { get; } - Implemented : DeletedMessageCount { get; } - Added, implemented : NewMessageCount { get; } - Added, implemented : UnreadMessageCount { get; } - Implemented : Destructor - Removed : GetMessages(int, int) - Implemented : GetMessages(int[]) - Implemented * InternetAddressList.cs : Removed "public" from IAdress.Add(IAddress) : Implemented the "IAddressList" methods. * Session.cs : Typo bug fixed. * InternetAddress.cs : Fixed minor bugs. --- NEW FILE --- /** * Namespace: CSMail * Class: Authenticator * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public class Authenticator { public Authenticator() { } } } --- NEW FILE --- /** * Namespace: CSMail * Class: IllegalStateException * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class IllegalStateException : Exception { public IllegalStateException() : base() { } public IllegalStateException(string message) : base(message) { } } } --- NEW FILE --- /** * Namespace: CSMail * Class: MessageRemovedException * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ using System; namespace CSMail { public class MessageRemovedException : Exception { public MessageRemovedException() : base() { } public MessageRemovedException(string message) : base(message) { } } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ChangeLog 26 Jul 2002 06:54:13 -0000 1.5 +++ ChangeLog 28 Aug 2002 10:17:12 -0000 1.6 @@ -1,4 +1,30 @@ +2002-08-28 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * Authenticator.cs : Added class. + * IllegalStateException.cs : Added exception class. + * FolderOpenMode.cs : Added fields "Default", "NotSet" + * MessageFlags.cs : Reformatting of flags. + * Folder.cs : Constructor. Parameter is Store, not Session + : Count { get; } - Made abstract + : Exists { get; } - Made abstract + : Messages { get; } - Made abstract + : Mode { get; } - Implemented + : Name { get; } - Made abstract + : Store { get; } - Implemented + : URL { get; } - Implemented + : DeletedMessageCount { get; } - Added, + implemented + : NewMessageCount { get; } - Added, implemented + : UnreadMessageCount { get; } - Implemented + : Destructor - Removed + : GetMessages(int, int) - Implemented + : GetMessages(int[]) - Implemented + * InternetAddressList.cs : Removed "public" from IAdress.Add(IAddress) + : Implemented the "IAddressList" methods. + * Session.cs : Typo bug fixed. + * InternetAddress.cs : Fixed minor bugs. + 2002-07-26 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * InternetAddressList.cs : Completed. Well almost. Index: Folder.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Folder.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Folder.cs 20 Jun 2002 02:43:24 -0000 1.1 +++ Folder.cs 28 Aug 2002 10:17:12 -0000 1.2 @@ -18,93 +18,97 @@ { public abstract class Folder //: IEnumerable { - private Session session; + protected Store store; + protected FolderOpenMode mode; - protected Folder(Session session) + private object lockObj; + + protected Folder(Store store) { - this.session = session; + this.store = store; + this.mode = FolderOpenMode.NotSet; + this.lockObj = new object(); } public abstract char Delimiter { get; } public abstract FolderType FolderType { get; } + public abstract bool Exists { get; } public abstract bool HasNewMessages { get; } public abstract bool IsOpen { get; } public abstract bool IsSubscribed { get; } + public abstract char Separator { get; } public abstract Folder Parent { get; } + public abstract int Count { get; } public abstract string FullName { get; } + public abstract string Name { get; } public abstract MessageFlags PermanentFlags { get; } public abstract Folder[] Children { get; } public abstract Folder[] SubscribedFolders { get; } + public abstract Message[] Messages { get; } - [MailTODO] - public int Count + public FolderOpenMode Mode { get { - throw new NotImplementedException(); + if(IsOpen) + { + return this.mode; + } + throw new IllegalStateException("[Mode] Folder closed"); } } - [MailTODO] - public bool Exists + public int NewMessageCount { get { - throw new NotImplementedException(); + return getMessageCount(MessageFlags.Recent); } } - - [MailTODO] - public Message[] Messages + + public int UnreadMessageCount { get { - throw new NotImplementedException(); + return getMessageCount(MessageFlags.Seen); } } - [MailTODO] - public FolderOpenMode Mode + public int DeletedMessageCount { get { - throw new NotImplementedException(); + return getMessageCount(MessageFlags.Deleted); } } - [MailTODO] - public string Name + private int getMessageCount(MessageFlags flag) { - get + if(!IsOpen) { - throw new NotImplementedException(); + return -1; } - } - [MailTODO] - public int NewMessageCount - { - get + int rv = 0; + int mc = Count; + for(int i = 0; i < mc; i++) { - throw new NotImplementedException(); + try + { + if(Messages[i].IsSet(flag)) + rv++; + } catch(MessageRemovedException) + { + } } + return rv; } - [MailTODO] public Store Store { get { - throw new NotImplementedException(); - } - } - - [MailTODO] - public int UnreadMessageCount - { - get - { - throw new NotImplementedException(); + return this.store; } } @@ -113,7 +117,11 @@ { get { - throw new NotImplementedException(); + URLName retVal = Store.URL; + String fn = (FullName == null ? String.Empty : FullName); + char c = Separator; + return new URLName(retVal.Protocol, retVal.Host, retVal.Port, + retVal.Username, retVal.Password, null); } } @@ -127,28 +135,43 @@ 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(); + int len = indices.Length; + Message[] retVal = new Message[len]; + for(int i = 0; i < len; i++) + { + retVal[i] = Messages[indices[i]]; + } + return retVal; } - [MailTODO] public Message[] GetMessages(int start, int stop) { - throw new NotImplementedException(); + if(start > stop) + return null; + Message[] retVal = new Message[stop - start + 1]; + for(int i = 0; i < (stop - start + 1); i++) + { + retVal[i] = Messages[i + start]; + } + return retVal; } [MailTODO] public override string ToString() { - throw new NotImplementedException(); + String fn = FullName; + if(fn != null) + return fn.ToString(); + return base.ToString(); } } } Index: FolderOpenMode.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/FolderOpenMode.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FolderOpenMode.cs 20 Jun 2002 02:43:24 -0000 1.1 +++ FolderOpenMode.cs 28 Aug 2002 10:17:12 -0000 1.2 @@ -12,6 +12,8 @@ { public enum FolderOpenMode { + Default, + NotSet, ReadOnly, ReadWrite } Index: InternetAddress.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/InternetAddress.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- InternetAddress.cs 26 Jul 2002 06:54:13 -0000 1.3 +++ InternetAddress.cs 28 Aug 2002 10:17:12 -0000 1.4 @@ -29,8 +29,8 @@ { hostname = hostname.Trim(); this.hostname = hostname; - this.protocol = procotol; - if(CheckIfIP(hostname)) + this.protocol = protocol; + if(CheckIfIP4(hostname)) { isIP = true; } @@ -43,11 +43,11 @@ /// </summary> public InternetAddress(int[] ip, string protocol) { - if(!ValidIP(ip)) + if(!ValidIP4(ip)) { throw new ArgumentException(); } - this.protocol = procotol; + this.protocol = protocol; this.ip = new int[4]; int i = 0; foreach(int current in ip) @@ -135,7 +135,7 @@ public override string ToString() { string retVal; - retVal = procotol + "://"; + retVal = protocol + "://"; retVal += hostname; return retVal; } Index: InternetAddressList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/InternetAddressList.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- InternetAddressList.cs 26 Jul 2002 06:54:13 -0000 1.2 +++ InternetAddressList.cs 28 Aug 2002 10:17:12 -0000 1.3 @@ -61,7 +61,7 @@ { if(index < 0 || index > Count) return null; - return addresses[index]; + return (InternetAddress)addresses[index]; } } @@ -82,7 +82,17 @@ return addresses.Count; } - public int IAddress.Add(IAddress address) + public void AddAt(int index, InternetAddress address) + { + addresses.Insert(index, address); + } + + public InternetAddress GetAddress(int index) + { + return (InternetAddress)addresses[index]; + } + + int IAddressList.Add(IAddress address) { if(address is InternetAddress) { @@ -91,6 +101,28 @@ return addresses.Count; } + void IAddressList.AddAt(int index, IAddress address) + { + if(address is InternetAddress) + AddAt(index, (InternetAddress)address); + } + + IAddress IAddressList.GetAddress(int index) + { + return (IAddress)GetAddress(index); + } + + void IAddressList.Remove(IAddress address) + { + if(address is InternetAddress) + Remove((InternetAddress)address); + } + + public void Remove(InternetAddress address) + { + addresses.Remove(address); + } + public void Clear() { addresses.Clear(); @@ -109,7 +141,7 @@ i = 0; foreach(InternetAddress current in this) { - if(String.Compare(current.Hostname, current, ignoreCase) == 0) + if(String.Compare(current.Hostname, address, ignoreCase) == 0) { return i; } @@ -119,11 +151,6 @@ return -1; } - public void Remove(InternetAddress address) - { - addresses.Remove(address); - } - public void RemoveAt(int index) { if(index >= 0 && index < Count) @@ -148,7 +175,7 @@ index = FindByValue(current, ignoreCase); if(index >= 0 && index < Count) { - if(!delete.Contains(this[index]) + if(!delete.Contains(this[index])) { delete.Add(this[index]); } @@ -162,11 +189,16 @@ } } + public IEnumerator GetEnumerator() + { + return addresses.GetEnumerator(); + } + /// <summary> /// Returns a CRLF separated list of Addresses. /// Do I need to take care of anything??? /// </summray> - public string ToString() + public override string ToString() { string retVal = String.Empty; foreach(InternetAddress current in this) Index: MessageFlags.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/MessageFlags.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MessageFlags.cs 20 Jun 2002 02:43:25 -0000 1.1 +++ MessageFlags.cs 28 Aug 2002 10:17:12 -0000 1.2 @@ -16,12 +16,12 @@ public enum MessageFlags { None = 0x0000, - Answered = 0x0001, - Deleted = 0x0002, - Draft = 0x0004, - Flagged = 0x0010, - Recent = 0x0020, - Seen = 0x0040, - UserDefined = 0x8000, + Answered = 0x0001 << 0, + Deleted = 0x0001 << 1, + Draft = 0x0001 << 2, + Flagged = 0x0001 << 3, + Recent = 0x0001 << 4, + Seen = 0x0001 << 5, + UserDefined = 0x0001 << 15, } } Index: Session.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Session.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Session.cs 20 Jun 2002 11:16:13 -0000 1.2 +++ Session.cs 28 Aug 2002 10:17:12 -0000 1.3 @@ -16,7 +16,7 @@ public class Session { private Properties properties; - private Authentiactor authenticator; + private Authenticator authenticator; private Hashtable authTable; private ArrayList providers; private Hashtable provByProto; @@ -40,7 +40,7 @@ providers = new ArrayList(); provByProto = new Hashtable(); provByClass = new Hashtable(); - addrMap = new Properties(); + //addrMap = new Properties(); // debug = bool.Parse(this.properties["mail.debug"]) } |