Windows project files update. Added Config.cs class.

This commit is contained in:
Jim Norman
2006-07-12 19:25:01 +00:00
parent 047578aa15
commit 2af5095c4e
23 changed files with 1162 additions and 137 deletions

View File

@@ -198,7 +198,19 @@ public class ICASAPol
XmlNode modeNode = uiNode.SelectSingleNode(xpath);
string mode = modeNode.InnerText;
UIPol uiPol = new UIPol(showInTaskBar, showSecretValue, showSecretInClearText, mode);
// Load config settings
XmlNode configNode = uiNode.SelectSingleNode("//ConfigSettings");
XmlNodeList nodeList = configNode.ChildNodes;
XmlNode node;
System.Collections.Specialized.NameValueCollection nvc = new System.Collections.Specialized.NameValueCollection();
for (int i=0; i<nodeList.Count; i++)
{
node = nodeList[i];
//Console.WriteLine(node.Name + ":"+node.InnerText);
nvc.Add(node.Name, node.InnerText);
}
UIPol uiPol = new UIPol(showInTaskBar, showSecretValue, showSecretInClearText, mode, nvc);
return uiPol;
}
}

View File

@@ -38,7 +38,7 @@ class Test
AggregationPol aggPol = new AggregationPol(storeList);
PersistencePol persistPol = new PersistencePol("linux","myfile.xml",10);
UIPol uiPol = new UIPol(true,false,true,"auto");
UIPol uiPol = new UIPol(true,false,true,"auto", null);
ArrayList linkKeyList = new ArrayList();
KWLinkKey kwLinkKey = new KWLinkKey("wallet1","folder1","kw-secret","kw-passwd");

View File

@@ -22,101 +22,137 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Xml;
using System.Xml.Serialization;
namespace Novell.CASA.CASAPolicy
{
public class UIPol : CASAPol
{
bool showInTaskBar;
public bool ShowInTaskBar
{
get
{
return showInTaskBar;
}
}
bool showSecretValue;
public bool ShowSecretValue
{
get
{
return showSecretValue;
}
}
bool showSecretInClearText;
public bool ShowSecretInClearText
{
get
{
return showSecretInClearText;
}
}
string synchEngineStartMode;
public string SynchEngineStartMode
{
get
{
return synchEngineStartMode;
}
}
public class UIPol : CASAPol
{
NameValueCollection m_nvc;
public void SetConfigSetting(string sName, string sValue)
{
if (m_nvc == null)
{
m_nvc = new NameValueCollection();
}
m_nvc.Set(sName, sValue);
}
public UIPol(bool inTrayIcon, bool inShowVals,bool inClearText,string startMode)
{
policyType = CASAPolType.UI_POL;
showInTaskBar = inTrayIcon;
showSecretValue = inShowVals;
showSecretInClearText = inClearText;
synchEngineStartMode = startMode;
}
public string GetConfigSetting(string sName)
{
if (m_nvc == null)
return null;
public override void DumpPol()
{
Console.WriteLine("\nUIPolicy");
Console.WriteLine("showInTaskBar = " + showInTaskBar);
Console.WriteLine("showSecretValue = " + showSecretValue);
Console.WriteLine("showSecretInClearText = " + showSecretInClearText);
Console.WriteLine("synchEngineStartMode = " + synchEngineStartMode);
}
return m_nvc.Get(sName);
}
public void WriteConfig()
{
ICASAPol.SetPolicy(this);
}
internal override void AppendToDoc(XmlDocument doc)
{
XmlElement elem;
XmlAttribute attr;
string xPath = "";
bool showInTaskBar;
public bool ShowInTaskBar
{
get
{
return showInTaskBar;
}
}
bool showSecretValue;
public bool ShowSecretValue
{
get
{
return showSecretValue;
}
}
bool showSecretInClearText;
public bool ShowSecretInClearText
{
get
{
return showSecretInClearText;
}
}
string synchEngineStartMode;
public string SynchEngineStartMode
{
get
{
return synchEngineStartMode;
}
}
public UIPol(bool inTrayIcon, bool inShowVals,bool inClearText,string startMode, NameValueCollection nvc)
{
policyType = CASAPolType.UI_POL;
showInTaskBar = inTrayIcon;
showSecretValue = inShowVals;
showSecretInClearText = inClearText;
synchEngineStartMode = startMode;
m_nvc = nvc;
}
public override void DumpPol()
{
Console.WriteLine("\nUIPolicy");
Console.WriteLine("showInTaskBar = " + showInTaskBar);
Console.WriteLine("showSecretValue = " + showSecretValue);
Console.WriteLine("showSecretInClearText = " + showSecretInClearText);
Console.WriteLine("synchEngineStartMode = " + synchEngineStartMode);
}
internal override void AppendToDoc(XmlDocument doc)
{
XmlElement elem;
XmlAttribute attr;
string xPath = "";
try
{
xPath = "//" + XmlConsts.CASAPolicyNode;
XmlNode rootElem = doc.SelectSingleNode(xPath);
try
{
xPath = "//" + XmlConsts.CASAPolicyNode;
XmlNode rootElem = doc.SelectSingleNode(xPath);
XmlElement uiPolElem = doc.CreateElement(XmlConsts.UIPolicyNode);
XmlElement uiPolElem = doc.CreateElement(XmlConsts.UIPolicyNode);
attr = doc.CreateAttribute(XmlConsts.ShowInTaskBarAttr);
attr.Value = showInTaskBar.ToString();
uiPolElem.SetAttributeNode(attr);
attr = doc.CreateAttribute(XmlConsts.ShowInTaskBarAttr);
attr.Value = showInTaskBar.ToString();
uiPolElem.SetAttributeNode(attr);
attr = doc.CreateAttribute(XmlConsts.ShowSecretValueAttr);
attr.Value = showSecretValue.ToString();
uiPolElem.SetAttributeNode(attr);
attr = doc.CreateAttribute(XmlConsts.ShowSecretValueAttr);
attr.Value = showSecretValue.ToString();
uiPolElem.SetAttributeNode(attr);
attr = doc.CreateAttribute(XmlConsts.ShowSecretInClearTextAttr);
attr.Value = showSecretInClearText.ToString();
uiPolElem.SetAttributeNode(attr);
attr = doc.CreateAttribute(XmlConsts.ShowSecretInClearTextAttr);
attr.Value = showSecretInClearText.ToString();
uiPolElem.SetAttributeNode(attr);
rootElem.AppendChild(uiPolElem);
rootElem.AppendChild(uiPolElem);
elem = doc.CreateElement(XmlConsts.SynchEngineStartModeNode);
elem.InnerText = synchEngineStartMode;
elem = doc.CreateElement(XmlConsts.SynchEngineStartModeNode);
elem.InnerText = synchEngineStartMode;
uiPolElem.AppendChild(elem);
uiPolElem.AppendChild(elem);
}
catch(Exception e)
{
//Console.WriteLine(e.ToString());
}
}
// write out NameValueCollection
XmlElement configElem = doc.CreateElement("ConfigSettings");
uiPolElem.AppendChild(configElem);
for (int i=0; i<m_nvc.Count; i++)
{
elem = doc.CreateElement(m_nvc.GetKey(i));
elem.InnerText = m_nvc.GetValues(i)[0];
configElem.AppendChild(elem);
}
}
catch(Exception e)
{
//Console.WriteLine(e.ToString());
}
}
}
}
}