[Csmail-patches] CVS: csmail/src/CSMail ProviderSearchType.cs,NONE,1.1 ChangeLog,1.12,1.13 Provider.
Status: Pre-Alpha
Brought to you by:
mastergaurav
From: Gaurav V. <mas...@us...> - 2002-08-30 08:41:32
|
Update of /cvsroot/csmail/csmail/src/CSMail In directory usw-pr-cvs1:/tmp/cvs-serv14026 Modified Files: ChangeLog Provider.cs ProviderList.cs Session.cs Added Files: ProviderSearchType.cs Log Message: 2002-08-30 * Session.cs : providers - Changed to ProviderList : provByProto, provByClass - Removed members : LoadProviders - Implemented : LoadAddressMap() - Implemented : LoadAddressMap(string) - Implemented : LoadAddressMap(string, bool) - Implemented : * Provider.cs : ToString() - Added assembly : SetProperly(...) - Added assembly : operator == - Added null comparision * ProviderList.cs : Add(Provider) - Stubbed : this[ProviderSearchType, string] - Stubbed * ProviderSearchType.cs : Added enumeration. --- NEW FILE --- /** * Namespace: CSMail * Class: ProviderSearchType * * Author: Gaurav Vaish * Maintainer: mastergaurav AT users DOT sf DOT net * * (C) Gaurav Vaish (2002) */ namespace CSMail { public enum ProviderSearchType { ClassName, Protocol } } Index: ChangeLog =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ChangeLog,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ChangeLog 29 Aug 2002 11:32:31 -0000 1.12 +++ ChangeLog 30 Aug 2002 08:41:28 -0000 1.13 @@ -1,4 +1,24 @@ +2002-08-30 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> + + * Session.cs : providers - Changed to ProviderList + : provByProto, + provByClass - Removed members + : LoadProviders - Implemented + : LoadAddressMap() - Implemented + : LoadAddressMap(string) + - Implemented + : LoadAddressMap(string, bool) + - Implemented + : + * Provider.cs : ToString() - Added assembly + : SetProperly(...) - Added assembly + : operator == - Added null comparision + * ProviderList.cs : Add(Provider) - Stubbed + : this[ProviderSearchType, string] + - Stubbed + * ProviderSearchType.cs : Added enumeration. + 2002-08-29 Gaurav Vaish <mastergaurav AT users DOT sf DOT net> * Constants.cs : Added class. Index: Provider.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Provider.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Provider.cs 29 Aug 2002 11:32:31 -0000 1.4 +++ Provider.cs 30 Aug 2002 08:41:28 -0000 1.5 @@ -36,7 +36,8 @@ /// <summary> /// Format of rawline: /// protocol = <proto>; type = <type>; class = <class>; - /// vendor = <vendor>; version = <version> + /// 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> @@ -87,6 +88,8 @@ break; case "version" : this.version = value; break; + case "assembly": this.assembly = value; + break; default : break; } } @@ -170,6 +173,11 @@ public static bool operator == (Provider obj1, Provider obj2) { + if(obj1 == null && obj2 == null) + { + return true; + } + if(obj1 != null && obj2 != null) { return obj1.Equals(obj2); @@ -190,7 +198,7 @@ public override string ToString() { String retVal = "CSMail.Provider["; - switch(type) + switch(this.type) { case ProviderType.Store: retVal += "STORE,"; break; @@ -198,11 +206,13 @@ break; default : break; } - retVal += (protocol + "," + className); + retVal += (this.protocol + "," + this.className); + if(assembly != null) + retVal += ("," + this.assembly); if(vendor != null) - retVal += ("," + vendor); + retVal += ("," + this.vendor); if(version != null) - retVal += ("," + version); + retVal += ("," + this.version); retVal += "]"; return retVal; } Index: ProviderList.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/ProviderList.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ProviderList.cs 29 Aug 2002 11:32:31 -0000 1.2 +++ ProviderList.cs 30 Aug 2002 08:41:28 -0000 1.3 @@ -8,6 +8,7 @@ * (C) Gaurav Vaish (2002) */ +using System; using System.Collections; namespace CSMail @@ -18,6 +19,21 @@ public ProviderList() { + } + + [MailTODO] + public Provider this[ProviderSearchType type, string key] + { + get + { + throw new NotImplementedException(); + } + } + + [MailTODO] + public int Add(Provider prov) + { + throw new NotImplementedException(); } public IEnumerator GetEnumerator() Index: Session.cs =================================================================== RCS file: /cvsroot/csmail/csmail/src/CSMail/Session.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Session.cs 29 Aug 2002 11:32:31 -0000 1.7 +++ Session.cs 30 Aug 2002 08:41:28 -0000 1.8 @@ -20,9 +20,9 @@ private readonly Properties properties; private readonly Authenticator authenticator; private Hashtable authTable; - private ArrayList providers; - private Hashtable provByProto; - private Hashtable provByClass; + private ProviderList providers; + //private Hashtable provByProto; + //private Hashtable provByClass; private Properties addrMap; private bool debug; @@ -43,9 +43,9 @@ this.areDirsSet = false; authTable = new Hashtable(); - providers = new ArrayList(); - provByProto = new Hashtable(); - provByClass = new Hashtable(); + providers = new ProviderList(); + //provByProto = new Hashtable(); + //provByClass = new Hashtable(); addrMap = new Properties(); dirsToSearch = new ArrayList(); @@ -110,7 +110,9 @@ { // Load from the file. if(!areDirsSet) + { SetDirsToSearch(); + } foreach(string current in dirsToSearch) { LoadProviders(current); @@ -123,12 +125,27 @@ LoadProviders(path, true); } - [MailTODO] private void LoadProviders(string path, bool fromDefault) { string file = path + Path.DirectorySeparatorChar; file += (fromDefault ? Constants.ProviderFileDefault : Constants.ProviderFile); - throw new NotImplementedException(); + + if(File.Exists(file)) + { + TextReader reader = new StreamReader(File.OpenRead(file)); + string currentLine = String.Empty; + while( (currentLine = reader.ReadLine()) != null) + { + currentLine = currentLine.Trim(); + if(currentLine.Length > 0 && currentLine[0] != '#') + { + Provider toAdd = new Provider(currentLine); + providers.Add(toAdd); + //provByProto.Add(toAdd.Protocol, toAdd); + //provByClass.Add(toAdd.ClassName, toAdd); + } + } + } } /// <summary> @@ -141,13 +158,44 @@ /// /// * To be provided later by CSMail itself. /// </summary> - [MonoTODO] private void LoadAddressMap() { // Load from the file. if(!areDirsSet) SetDirsToSearch(); - throw new NotImplementedException(); + foreach(string current in dirsToSearch) + { + LoadAddressMap(current); + } + } + + private void LoadAddressMap(string path) + { + LoadAddressMap(path, true); + LoadAddressMap(path, false); + } + + private void LoadAddressMap(string path, bool fromDefault) + { + string file = path + Path.DirectorySeparatorChar; + file += (fromDefault ? Constants.AddressMapFile : Constants.AddressMapFileDefault); + + if(File.Exists(file)) + { + TextReader reader = new StreamReader(File.OpenRead(file)); + string currentLine = String.Empty; + string key; + string value; + while( (currentLine = reader.ReadLine()) != null) + { + currentLine = currentLine.Trim(); + if(currentLine.Length > 0 && currentLine[0] != '#') + { + Properties.GetKeyValue(currentLine, out key, out value); + addrMap[key] = value; + } + } + } } private void SetDirsToSearch() |