diff options
Diffstat (limited to 'OpenSim/Framework/Configuration')
3 files changed, 30 insertions, 32 deletions
diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs index efe6ebb..0d48683 100644 --- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs +++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs | |||
@@ -26,21 +26,18 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.IO; | 29 | using System.IO; |
30 | using System.Net; | ||
33 | using System.Text; | 31 | using System.Text; |
34 | 32 | using OpenSim.Framework.Console; | |
35 | using OpenSim.Framework; | ||
36 | 33 | ||
37 | namespace OpenSim.Framework.Configuration.HTTP | 34 | namespace OpenSim.Framework.Configuration.HTTP |
38 | { | 35 | { |
39 | public class HTTPConfiguration : IGenericConfig | 36 | public class HTTPConfiguration : IGenericConfig |
40 | { | 37 | { |
41 | RemoteConfigSettings remoteConfigSettings; | 38 | private RemoteConfigSettings remoteConfigSettings; |
42 | 39 | ||
43 | XmlConfiguration xmlConfig; | 40 | private XmlConfiguration xmlConfig; |
44 | 41 | ||
45 | private string configFileName = ""; | 42 | private string configFileName = ""; |
46 | 43 | ||
@@ -62,8 +59,9 @@ namespace OpenSim.Framework.Configuration.HTTP | |||
62 | StringBuilder sb = new StringBuilder(); | 59 | StringBuilder sb = new StringBuilder(); |
63 | 60 | ||
64 | byte[] buf = new byte[8192]; | 61 | byte[] buf = new byte[8192]; |
65 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.remoteConfigSettings.baseConfigURL + this.configFileName); | 62 | HttpWebRequest request = |
66 | HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | 63 | (HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName); |
64 | HttpWebResponse response = (HttpWebResponse) request.GetResponse(); | ||
67 | 65 | ||
68 | Stream resStream = response.GetResponseStream(); | 66 | Stream resStream = response.GetResponseStream(); |
69 | 67 | ||
@@ -78,13 +76,14 @@ namespace OpenSim.Framework.Configuration.HTTP | |||
78 | tempString = Encoding.ASCII.GetString(buf, 0, count); | 76 | tempString = Encoding.ASCII.GetString(buf, 0, count); |
79 | sb.Append(tempString); | 77 | sb.Append(tempString); |
80 | } | 78 | } |
81 | } | 79 | } while (count > 0); |
82 | while (count > 0); | ||
83 | LoadDataFromString(sb.ToString()); | 80 | LoadDataFromString(sb.ToString()); |
84 | } | 81 | } |
85 | catch (WebException) | 82 | catch (WebException) |
86 | { | 83 | { |
87 | Console.MainLog.Instance.Warn("Unable to connect to remote configuration file (" + remoteConfigSettings.baseConfigURL + configFileName + "). Creating local file instead."); | 84 | MainLog.Instance.Warn("Unable to connect to remote configuration file (" + |
85 | remoteConfigSettings.baseConfigURL + configFileName + | ||
86 | "). Creating local file instead."); | ||
88 | xmlConfig.SetFileName(configFileName); | 87 | xmlConfig.SetFileName(configFileName); |
89 | xmlConfig.LoadData(); | 88 | xmlConfig.LoadData(); |
90 | } | 89 | } |
@@ -93,7 +92,6 @@ namespace OpenSim.Framework.Configuration.HTTP | |||
93 | public void LoadDataFromString(string data) | 92 | public void LoadDataFromString(string data) |
94 | { | 93 | { |
95 | xmlConfig.LoadDataFromString(data); | 94 | xmlConfig.LoadDataFromString(data); |
96 | |||
97 | } | 95 | } |
98 | 96 | ||
99 | public string GetAttribute(string attributeName) | 97 | public string GetAttribute(string attributeName) |
@@ -114,4 +112,4 @@ namespace OpenSim.Framework.Configuration.HTTP | |||
114 | { | 112 | { |
115 | } | 113 | } |
116 | } | 114 | } |
117 | } | 115 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs index 3ac03bb..332066c 100644 --- a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs +++ b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs | |||
@@ -26,12 +26,6 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | |||
35 | namespace OpenSim.Framework.Configuration.HTTP | 29 | namespace OpenSim.Framework.Configuration.HTTP |
36 | { | 30 | { |
37 | public class RemoteConfigSettings | 31 | public class RemoteConfigSettings |
@@ -39,24 +33,30 @@ namespace OpenSim.Framework.Configuration.HTTP | |||
39 | private ConfigurationMember configMember; | 33 | private ConfigurationMember configMember; |
40 | 34 | ||
41 | public string baseConfigURL = ""; | 35 | public string baseConfigURL = ""; |
36 | |||
42 | public RemoteConfigSettings(string filename) | 37 | public RemoteConfigSettings(string filename) |
43 | { | 38 | { |
44 | configMember = new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, handleIncomingConfiguration); | 39 | configMember = |
40 | new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, | ||
41 | handleIncomingConfiguration); | ||
45 | configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll"); | 42 | configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll"); |
46 | configMember.performConfigurationRetrieve(); | 43 | configMember.performConfigurationRetrieve(); |
47 | } | 44 | } |
48 | 45 | ||
49 | public void loadConfigurationOptions() | 46 | public void loadConfigurationOptions() |
50 | { | 47 | { |
51 | configMember.addConfigurationOption("base_config_url", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "URL Containing Configuration Files", "http://localhost/", false); | 48 | configMember.addConfigurationOption("base_config_url", |
49 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
50 | "URL Containing Configuration Files", "http://localhost/", false); | ||
52 | } | 51 | } |
52 | |||
53 | public bool handleIncomingConfiguration(string configuration_key, object configuration_result) | 53 | public bool handleIncomingConfiguration(string configuration_key, object configuration_result) |
54 | { | 54 | { |
55 | if (configuration_key == "base_config_url") | 55 | if (configuration_key == "base_config_url") |
56 | { | 56 | { |
57 | baseConfigURL = (string)configuration_result; | 57 | baseConfigURL = (string) configuration_result; |
58 | } | 58 | } |
59 | return true; | 59 | return true; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } | 62 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs index 52db852..152dec5 100644 --- a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs +++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs | |||
@@ -25,12 +25,11 @@ | |||
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 | */ |
28 | |||
28 | using System; | 29 | using System; |
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Xml; | 31 | using System.Xml; |
31 | 32 | ||
32 | using OpenSim.Framework; | ||
33 | |||
34 | namespace OpenSim.Framework.Configuration | 33 | namespace OpenSim.Framework.Configuration |
35 | { | 34 | { |
36 | public class XmlConfiguration : IGenericConfig | 35 | public class XmlConfiguration : IGenericConfig |
@@ -56,6 +55,7 @@ namespace OpenSim.Framework.Configuration | |||
56 | if (configNode.Name != "Config") | 55 | if (configNode.Name != "Config") |
57 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | 56 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); |
58 | } | 57 | } |
58 | |||
59 | public void LoadData() | 59 | public void LoadData() |
60 | { | 60 | { |
61 | lock (this) | 61 | lock (this) |
@@ -81,7 +81,7 @@ namespace OpenSim.Framework.Configuration | |||
81 | 81 | ||
82 | if (createdFile) | 82 | if (createdFile) |
83 | { | 83 | { |
84 | this.Commit(); | 84 | Commit(); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | } | 87 | } |
@@ -93,12 +93,13 @@ namespace OpenSim.Framework.Configuration | |||
93 | 93 | ||
94 | LoadDataToClass(); | 94 | LoadDataToClass(); |
95 | } | 95 | } |
96 | |||
96 | public string GetAttribute(string attributeName) | 97 | public string GetAttribute(string attributeName) |
97 | { | 98 | { |
98 | string result = null; | 99 | string result = null; |
99 | if (configNode.Attributes[attributeName] != null) | 100 | if (configNode.Attributes[attributeName] != null) |
100 | { | 101 | { |
101 | result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; | 102 | result = ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value; |
102 | } | 103 | } |
103 | return result; | 104 | return result; |
104 | } | 105 | } |
@@ -107,7 +108,7 @@ namespace OpenSim.Framework.Configuration | |||
107 | { | 108 | { |
108 | if (configNode.Attributes[attributeName] != null) | 109 | if (configNode.Attributes[attributeName] != null) |
109 | { | 110 | { |
110 | ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; | 111 | ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; |
111 | } | 112 | } |
112 | else | 113 | else |
113 | { | 114 | { |
@@ -124,7 +125,7 @@ namespace OpenSim.Framework.Configuration | |||
124 | if (!Directory.Exists(Util.configDir())) | 125 | if (!Directory.Exists(Util.configDir())) |
125 | { | 126 | { |
126 | Directory.CreateDirectory(Util.configDir()); | 127 | Directory.CreateDirectory(Util.configDir()); |
127 | } | 128 | } |
128 | doc.Save(fileName); | 129 | doc.Save(fileName); |
129 | } | 130 | } |
130 | 131 | ||
@@ -134,6 +135,5 @@ namespace OpenSim.Framework.Configuration | |||
134 | rootNode = null; | 135 | rootNode = null; |
135 | doc = null; | 136 | doc = null; |
136 | } | 137 | } |
137 | |||
138 | } | 138 | } |
139 | } | 139 | } \ No newline at end of file |