aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Configuration
diff options
context:
space:
mode:
authorSean Dague2007-07-30 20:11:40 +0000
committerSean Dague2007-07-30 20:11:40 +0000
commit74bb5282a09ec095a7ff810c62f79cc64e187686 (patch)
treee0a9b703bfcbbab59b04351dd71508fa913e741a /OpenSim/Framework/Configuration
parentadded OnDisconnectUser event to required classes (diff)
downloadopensim-SC-74bb5282a09ec095a7ff810c62f79cc64e187686.zip
opensim-SC-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.gz
opensim-SC-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.bz2
opensim-SC-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.xz
mass update of files to have native line endings
Diffstat (limited to 'OpenSim/Framework/Configuration')
-rw-r--r--OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs178
-rw-r--r--OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs68
-rw-r--r--OpenSim/Framework/Configuration/XML/XmlConfiguration.cs266
3 files changed, 256 insertions, 256 deletions
diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs
index d72c40f..8b74195 100644
--- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs
+++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs
@@ -1,89 +1,89 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Net; 3using System.Net;
4using System.IO; 4using System.IO;
5using System.Text; 5using System.Text;
6 6
7using OpenSim.Framework.Configuration.Interfaces; 7using OpenSim.Framework.Configuration.Interfaces;
8 8
9namespace OpenSim.Framework.Configuration.HTTP 9namespace OpenSim.Framework.Configuration.HTTP
10{ 10{
11 public class HTTPConfiguration : IGenericConfig 11 public class HTTPConfiguration : IGenericConfig
12 { 12 {
13 RemoteConfigSettings remoteConfigSettings; 13 RemoteConfigSettings remoteConfigSettings;
14 14
15 XmlConfiguration xmlConfig; 15 XmlConfiguration xmlConfig;
16 16
17 private string configFileName = ""; 17 private string configFileName = "";
18 18
19 public HTTPConfiguration() 19 public HTTPConfiguration()
20 { 20 {
21 remoteConfigSettings = new RemoteConfigSettings("remoteconfig.xml"); 21 remoteConfigSettings = new RemoteConfigSettings("remoteconfig.xml");
22 xmlConfig = new XmlConfiguration(); 22 xmlConfig = new XmlConfiguration();
23 } 23 }
24 24
25 public void SetFileName(string fileName) 25 public void SetFileName(string fileName)
26 { 26 {
27 configFileName = fileName; 27 configFileName = fileName;
28 } 28 }
29 29
30 public void LoadData() 30 public void LoadData()
31 { 31 {
32 try 32 try
33 { 33 {
34 StringBuilder sb = new StringBuilder(); 34 StringBuilder sb = new StringBuilder();
35 35
36 byte[] buf = new byte[8192]; 36 byte[] buf = new byte[8192];
37 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.remoteConfigSettings.baseConfigURL + this.configFileName); 37 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.remoteConfigSettings.baseConfigURL + this.configFileName);
38 HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 38 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
39 39
40 Stream resStream = response.GetResponseStream(); 40 Stream resStream = response.GetResponseStream();
41 41
42 string tempString = null; 42 string tempString = null;
43 int count = 0; 43 int count = 0;
44 44
45 do 45 do
46 { 46 {
47 count = resStream.Read(buf, 0, buf.Length); 47 count = resStream.Read(buf, 0, buf.Length);
48 if (count != 0) 48 if (count != 0)
49 { 49 {
50 tempString = Encoding.ASCII.GetString(buf, 0, count); 50 tempString = Encoding.ASCII.GetString(buf, 0, count);
51 sb.Append(tempString); 51 sb.Append(tempString);
52 } 52 }
53 } 53 }
54 while (count > 0); 54 while (count > 0);
55 LoadDataFromString(sb.ToString()); 55 LoadDataFromString(sb.ToString());
56 } 56 }
57 catch (WebException) 57 catch (WebException)
58 { 58 {
59 Console.MainLog.Instance.Warn("Unable to connect to remote configuration file (" + remoteConfigSettings.baseConfigURL + configFileName + "). Creating local file instead."); 59 Console.MainLog.Instance.Warn("Unable to connect to remote configuration file (" + remoteConfigSettings.baseConfigURL + configFileName + "). Creating local file instead.");
60 xmlConfig.SetFileName(configFileName); 60 xmlConfig.SetFileName(configFileName);
61 xmlConfig.LoadData(); 61 xmlConfig.LoadData();
62 } 62 }
63 } 63 }
64 64
65 public void LoadDataFromString(string data) 65 public void LoadDataFromString(string data)
66 { 66 {
67 xmlConfig.LoadDataFromString(data); 67 xmlConfig.LoadDataFromString(data);
68 68
69 } 69 }
70 70
71 public string GetAttribute(string attributeName) 71 public string GetAttribute(string attributeName)
72 { 72 {
73 return xmlConfig.GetAttribute(attributeName); 73 return xmlConfig.GetAttribute(attributeName);
74 } 74 }
75 75
76 public bool SetAttribute(string attributeName, string attributeValue) 76 public bool SetAttribute(string attributeName, string attributeValue)
77 { 77 {
78 return true; 78 return true;
79 } 79 }
80 80
81 public void Commit() 81 public void Commit()
82 { 82 {
83 } 83 }
84 84
85 public void Close() 85 public void Close()
86 { 86 {
87 } 87 }
88 } 88 }
89} 89}
diff --git a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs
index e3cfac7..77719ee 100644
--- a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs
+++ b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs
@@ -1,34 +1,34 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using OpenSim.Framework.Configuration; 5using OpenSim.Framework.Configuration;
6 6
7namespace OpenSim.Framework.Configuration.HTTP 7namespace OpenSim.Framework.Configuration.HTTP
8{ 8{
9 public class RemoteConfigSettings 9 public class RemoteConfigSettings
10 { 10 {
11 private ConfigurationMember configMember; 11 private ConfigurationMember configMember;
12 12
13 public string baseConfigURL = ""; 13 public string baseConfigURL = "";
14 public RemoteConfigSettings(string filename) 14 public RemoteConfigSettings(string filename)
15 { 15 {
16 configMember = new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, handleIncomingConfiguration); 16 configMember = new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, handleIncomingConfiguration);
17 configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll"); 17 configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll");
18 configMember.performConfigurationRetrieve(); 18 configMember.performConfigurationRetrieve();
19 } 19 }
20 20
21 public void loadConfigurationOptions() 21 public void loadConfigurationOptions()
22 { 22 {
23 configMember.addConfigurationOption("base_config_url", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "URL Containing Configuration Files", "http://localhost/", false); 23 configMember.addConfigurationOption("base_config_url", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "URL Containing Configuration Files", "http://localhost/", false);
24 } 24 }
25 public bool handleIncomingConfiguration(string configuration_key, object configuration_result) 25 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
26 { 26 {
27 if (configuration_key == "base_config_url") 27 if (configuration_key == "base_config_url")
28 { 28 {
29 baseConfigURL = (string)configuration_result; 29 baseConfigURL = (string)configuration_result;
30 } 30 }
31 return true; 31 return true;
32 } 32 }
33 } 33 }
34} 34}
diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
index 5b66035..72faed6 100644
--- a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
+++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs
@@ -1,133 +1,133 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Xml; 30using System.Xml;
31 31
32using OpenSim.Framework.Interfaces; 32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Configuration.Interfaces; 33using OpenSim.Framework.Configuration.Interfaces;
34 34
35namespace OpenSim.Framework.Configuration 35namespace OpenSim.Framework.Configuration
36{ 36{
37 public class XmlConfiguration : IGenericConfig 37 public class XmlConfiguration : IGenericConfig
38 { 38 {
39 private XmlDocument doc; 39 private XmlDocument doc;
40 private XmlNode rootNode; 40 private XmlNode rootNode;
41 private XmlNode configNode; 41 private XmlNode configNode;
42 private string fileName; 42 private string fileName;
43 private bool createdFile = false; 43 private bool createdFile = false;
44 44
45 public void SetFileName(string file) 45 public void SetFileName(string file)
46 { 46 {
47 fileName = file; 47 fileName = file;
48 } 48 }
49 49
50 private void LoadDataToClass() 50 private void LoadDataToClass()
51 { 51 {
52 rootNode = doc.FirstChild; 52 rootNode = doc.FirstChild;
53 if (rootNode.Name != "Root") 53 if (rootNode.Name != "Root")
54 throw new Exception("Error: Invalid .xml File. Missing <Root>"); 54 throw new Exception("Error: Invalid .xml File. Missing <Root>");
55 55
56 configNode = rootNode.FirstChild; 56 configNode = rootNode.FirstChild;
57 if (configNode.Name != "Config") 57 if (configNode.Name != "Config")
58 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); 58 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
59 } 59 }
60 public void LoadData() 60 public void LoadData()
61 { 61 {
62 doc = new XmlDocument(); 62 doc = new XmlDocument();
63 if (File.Exists(fileName)) 63 if (File.Exists(fileName))
64 { 64 {
65 XmlTextReader reader = new XmlTextReader(fileName); 65 XmlTextReader reader = new XmlTextReader(fileName);
66 reader.WhitespaceHandling = WhitespaceHandling.None; 66 reader.WhitespaceHandling = WhitespaceHandling.None;
67 doc.Load(reader); 67 doc.Load(reader);
68 reader.Close(); 68 reader.Close();
69 } 69 }
70 else 70 else
71 { 71 {
72 createdFile = true; 72 createdFile = true;
73 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); 73 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
74 doc.AppendChild(rootNode); 74 doc.AppendChild(rootNode);
75 configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); 75 configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
76 rootNode.AppendChild(configNode); 76 rootNode.AppendChild(configNode);
77 } 77 }
78 78
79 LoadDataToClass(); 79 LoadDataToClass();
80 80
81 if (createdFile) 81 if (createdFile)
82 { 82 {
83 this.Commit(); 83 this.Commit();
84 } 84 }
85 } 85 }
86 86
87 public void LoadDataFromString(string data) 87 public void LoadDataFromString(string data)
88 { 88 {
89 doc = new XmlDocument(); 89 doc = new XmlDocument();
90 doc.LoadXml(data); 90 doc.LoadXml(data);
91 91
92 LoadDataToClass(); 92 LoadDataToClass();
93 } 93 }
94 public string GetAttribute(string attributeName) 94 public string GetAttribute(string attributeName)
95 { 95 {
96 string result = null; 96 string result = null;
97 if (configNode.Attributes[attributeName] != null) 97 if (configNode.Attributes[attributeName] != null)
98 { 98 {
99 result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; 99 result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
100 } 100 }
101 return result; 101 return result;
102 } 102 }
103 103
104 public bool SetAttribute(string attributeName, string attributeValue) 104 public bool SetAttribute(string attributeName, string attributeValue)
105 { 105 {
106 if (configNode.Attributes[attributeName] != null) 106 if (configNode.Attributes[attributeName] != null)
107 { 107 {
108 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; 108 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
109 } 109 }
110 else 110 else
111 { 111 {
112 XmlAttribute attri; 112 XmlAttribute attri;
113 attri = doc.CreateAttribute(attributeName); 113 attri = doc.CreateAttribute(attributeName);
114 attri.Value = attributeValue; 114 attri.Value = attributeValue;
115 configNode.Attributes.Append(attri); 115 configNode.Attributes.Append(attri);
116 } 116 }
117 return true; 117 return true;
118 } 118 }
119 119
120 public void Commit() 120 public void Commit()
121 { 121 {
122 doc.Save(fileName); 122 doc.Save(fileName);
123 } 123 }
124 124
125 public void Close() 125 public void Close()
126 { 126 {
127 configNode = null; 127 configNode = null;
128 rootNode = null; 128 rootNode = null;
129 doc = null; 129 doc = null;
130 } 130 }
131 131
132 } 132 }
133} 133}