From 16bdb53683bf15a39f77603d558eda026fd4d21e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 4 Aug 2010 00:45:15 +0200 Subject: [PATCH 1/4] Allow specifying default region flags. Correct a typo. --- OpenSim/Services/GridService/GridService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index f49d86d50a..ebaed42dc5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -124,7 +124,7 @@ namespace OpenSim.Services.GridService { // Regions reserved for the null key cannot be taken. if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString()) - return "Region location us reserved"; + return "Region location is reserved"; // Treat it as an auth request // @@ -210,6 +210,7 @@ namespace OpenSim.Services.GridService { int newFlags = 0; string regionName = rdata.RegionName.Trim().Replace(' ', '_'); + newFlags = ParseFlags(newFlags, gridConfig.GetString("DefaultRegionFlags", String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty)); rdata.Data["flags"] = newFlags.ToString(); From 9c7e35860e290e6bb77da7749d4d3b82a5c75418 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Aug 2010 01:00:06 +0100 Subject: [PATCH 2/4] re-Add the XML configuration loader dll. It's gone AWOL in a cleanup, but still needed for web-loading region configs and for loading legacy XML region files --- bin/OpenSim.Framework.Configuration.XML.dll | Bin 0 -> 5120 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100755 bin/OpenSim.Framework.Configuration.XML.dll diff --git a/bin/OpenSim.Framework.Configuration.XML.dll b/bin/OpenSim.Framework.Configuration.XML.dll new file mode 100755 index 0000000000000000000000000000000000000000..de0b87527cde5700c62ae33cb93a1ac6aab990cd GIT binary patch literal 5120 zcmeHLTWlOx8UD}gdTnpWG~T$eLoS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 zL%nTT!t)`}c`D+oY@P}@{UR!7mS(_Df==kay6C&T11_MVl6I!>6EAfe$|HJ)-<- Date: Wed, 4 Aug 2010 01:09:51 +0100 Subject: [PATCH 3/4] Revert "re-Add the XML configuration loader dll. It's gone AWOL in a cleanup, but" This reverts commit 9c7e35860e290e6bb77da7749d4d3b82a5c75418. --- bin/OpenSim.Framework.Configuration.XML.dll | Bin 5120 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 bin/OpenSim.Framework.Configuration.XML.dll diff --git a/bin/OpenSim.Framework.Configuration.XML.dll b/bin/OpenSim.Framework.Configuration.XML.dll deleted file mode 100755 index de0b87527cde5700c62ae33cb93a1ac6aab990cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5120 zcmeHLTWlOx8UD}gdTnpWG~T$eLoSTtG;FOhaw3Psr4+~ZI&teunq504qDscQV|&Q# zoXyN^V&_t&qKb+{rNRTKLWq|lQG^f=NK{2gl_(NIwB;f2z(pz-1s;%)xb>~!`_GwO zuN`v{$^#Od&H2yy|MQ>kznuTfj5B@iMM@D-8vX8FqE|6;8&UM1lbcvJKk%AK-|Bp` z?^QANW?yN=i>z8GmqVv&m7O4vv9;)0VLhG}RdEsRQ2*A)gk=S^UW;g!CnH1^ zPQ>PRLA$Y8{IB>O7EwowQU&~}7T%8C)foI6+d#0UVnsZy%_6#Bhf!FDQ29232?uJT zx3m#>Z-=fgp~xwt3+RlMLvLv#M58UNn%;eAhXr}FjaYhmE*Y7d!JOmSx}6`B;kfTl zJ6=H5s4PR*wJW|)4I~}6L2dN)e&icT5ed*&!8gxsYw-Ij-EZV!Iy-Q{NZo+l^Z?Lz z4rb`%i50`RhV^s^Qj^GE_6A7WxW@ERKBo|*7NxLq6}l`ApKj_x3|*#L_hM6*?d%!c zMYk~myUWOC^01#ZqBb_dHjQiSP#!g(9cFdSNA2LZwf9OSEvubtmz|im%Pi>eGHdqS z07^RXy+=9!4E)SWltLo{ZGs(^+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`8_zJ$%SvzF@$0UN zM$fcM>sZ<^lC|@NOLfQh5Wy@wEqYaZ0-uKN6&YTnx!CimEQ2L)dE5&L9bU?CZGAQw zEXgF?_0^(t*}WId9#cT|(BVMsh3P4JY+6?8zWeyUqpZGIkhBdbG8^Fw8IG8J7MZp@>Svw}LBaVK_4a?E$4sL3}c6QQgohhBjmXMH`R zPUAEcU~$W(`tml0}aXVI3|h-9!n=tJdISSaie7UfJchMdulk z_~9G%sRD)gN%Tj_!jmVU%eenOo(C21Hmy<>oJA9m_;?1{m``IK;pahn8T@0^zon7r5N4W$*b8Eq5Q?rorn!fVjM-tOa-CftGR+Jt=Q`6C&Wec6)3a|;InGF9SHmRJykMxoeiDZj0~F3 zCp?ejl}Hf1wX*jorMc4RXWug4?)&nO|EhzzAC%vZ_(mtXxe-l&bqsDHXT4MC3nTd3 zL%nTT!t)`}c`D+oY@P}@{UR!7mS(_Df==kay6C&T11_MVl6I!>6EAfe$|HJ)-<- Date: Wed, 4 Aug 2010 01:10:01 +0100 Subject: [PATCH 4/4] Revert "remove long unused OpenSim/Framework/Configuration/* projects" This reverts commit cdd3f17b2bee58def470635cfc06e26b0d0145b2. --- .../Configuration/HTTP/HTTPConfiguration.cs | 119 +++++++++++++++ .../HTTP/RemoteConfigSettings.cs | 63 ++++++++ .../Configuration/XML/XmlConfiguration.cs | 141 ++++++++++++++++++ prebuild.xml | 52 +++++++ 4 files changed, 375 insertions(+) create mode 100644 OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs create mode 100644 OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs create mode 100644 OpenSim/Framework/Configuration/XML/XmlConfiguration.cs diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs new file mode 100644 index 0000000000..3dce578193 --- /dev/null +++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs @@ -0,0 +1,119 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; +using log4net; +using OpenSim.Framework.Configuration.XML; + +namespace OpenSim.Framework.Configuration.HTTP +{ + public class HTTPConfiguration : IGenericConfig + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private RemoteConfigSettings remoteConfigSettings; + + private XmlConfiguration xmlConfig; + + private string configFileName = String.Empty; + + public HTTPConfiguration() + { + remoteConfigSettings = new RemoteConfigSettings("remoteconfig.xml"); + xmlConfig = new XmlConfiguration(); + } + + public void SetFileName(string fileName) + { + configFileName = fileName; + } + + public void LoadData() + { + try + { + StringBuilder sb = new StringBuilder(); + + byte[] buf = new byte[8192]; + HttpWebRequest request = + (HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName); + HttpWebResponse response = (HttpWebResponse) request.GetResponse(); + + Stream resStream = response.GetResponseStream(); + + string tempString = null; + int count = 0; + + do + { + count = resStream.Read(buf, 0, buf.Length); + if (count != 0) + { + tempString = Util.UTF8.GetString(buf, 0, count); + sb.Append(tempString); + } + } while (count > 0); + LoadDataFromString(sb.ToString()); + } + catch (WebException) + { + m_log.Warn("Unable to connect to remote configuration file (" + + remoteConfigSettings.baseConfigURL + configFileName + + "). Creating local file instead."); + xmlConfig.SetFileName(configFileName); + xmlConfig.LoadData(); + } + } + + public void LoadDataFromString(string data) + { + xmlConfig.LoadDataFromString(data); + } + + public string GetAttribute(string attributeName) + { + return xmlConfig.GetAttribute(attributeName); + } + + public bool SetAttribute(string attributeName, string attributeValue) + { + return true; + } + + public void Commit() + { + } + + public void Close() + { + } + } +} diff --git a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs new file mode 100644 index 0000000000..10bc88aa6c --- /dev/null +++ b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs @@ -0,0 +1,63 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace OpenSim.Framework.Configuration.HTTP +{ + public class RemoteConfigSettings + { + private ConfigurationMember configMember; + + public string baseConfigURL = String.Empty; + + public RemoteConfigSettings(string filename) + { + configMember = + new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, + handleIncomingConfiguration,true); + configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll"); + configMember.performConfigurationRetrieve(); + } + + public void loadConfigurationOptions() + { + configMember.addConfigurationOption("base_config_url", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "URL Containing Configuration Files", "http://localhost/", false); + } + + public bool handleIncomingConfiguration(string configuration_key, object configuration_result) + { + if (configuration_key == "base_config_url") + { + baseConfigURL = (string) configuration_result; + } + return true; + } + } +} diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs new file mode 100644 index 0000000000..43162fc227 --- /dev/null +++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs @@ -0,0 +1,141 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.IO; +using System.Xml; + +namespace OpenSim.Framework.Configuration.XML +{ + public class XmlConfiguration : IGenericConfig + { + private XmlDocument doc; + private XmlNode rootNode; + private XmlNode configNode; + private string fileName; + private bool createdFile = false; + + public void SetFileName(string file) + { + fileName = file; + } + + private void LoadDataToClass() + { + rootNode = doc.SelectSingleNode("Root"); + if (null == rootNode) + throw new Exception("Error: Invalid .xml File. Missing "); + + configNode = rootNode.SelectSingleNode("Config"); + if (null == configNode) + throw new Exception("Error: Invalid .xml File. should contain a "); + } + + public void LoadData() + { + lock (this) + { + doc = new XmlDocument(); + if (File.Exists(fileName)) + { + XmlTextReader reader = new XmlTextReader(fileName); + reader.WhitespaceHandling = WhitespaceHandling.None; + doc.Load(reader); + reader.Close(); + } + else + { + createdFile = true; + rootNode = doc.CreateNode(XmlNodeType.Element, "Root", String.Empty); + doc.AppendChild(rootNode); + configNode = doc.CreateNode(XmlNodeType.Element, "Config", String.Empty); + rootNode.AppendChild(configNode); + } + + LoadDataToClass(); + + if (createdFile) + { + Commit(); + } + } + } + + public void LoadDataFromString(string data) + { + doc = new XmlDocument(); + doc.LoadXml(data); + + LoadDataToClass(); + } + + public string GetAttribute(string attributeName) + { + string result = null; + if (configNode.Attributes[attributeName] != null) + { + result = ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value; + } + return result; + } + + public bool SetAttribute(string attributeName, string attributeValue) + { + if (configNode.Attributes[attributeName] != null) + { + ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; + } + else + { + XmlAttribute attri; + attri = doc.CreateAttribute(attributeName); + attri.Value = attributeValue; + configNode.Attributes.Append(attri); + } + return true; + } + + public void Commit() + { + if (fileName == null || fileName == String.Empty) + return; + + if (!Directory.Exists(Util.configDir())) + { + Directory.CreateDirectory(Util.configDir()); + } + doc.Save(fileName); + } + + public void Close() + { + configNode = null; + rootNode = null; + doc = null; + } + } +} diff --git a/prebuild.xml b/prebuild.xml index 5f55461268..8a6d3a1e7a 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -255,6 +255,58 @@ + + + + ../../../../bin/ + + + + + ../../../../bin/ + + + + ../../../../bin/ + + + + + + + + + + + + + + + + ../../../../bin/ + + + + + ../../../../bin/ + + + + ../../../../bin/ + + + + + + + + + + + + + +