From 35420b21a3a0a3e8f104f7ce1c9d6c091a8f5212 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 2 Apr 2008 15:22:39 +0000 Subject: reorganizing namespaces to put all the Data stuff into it's own namespace / dir structure. This is coming in over a few changesets so consider trunk broken for the next 30 minutes as these get pulled together. --- OpenSim/Data/AssetDataBase.cs | 20 ++ OpenSim/Data/DataStoreBase.cs | 10 + OpenSim/Data/GridDataBase.cs | 22 +++ OpenSim/Data/IGridData.cs | 118 ++++++++++++ OpenSim/Data/ILogData.cs | 91 +++++++++ OpenSim/Data/IniConfig.cs | 98 ++++++++++ OpenSim/Data/InventoryDataBase.cs | 10 + OpenSim/Data/OpenSimDataReader.cs | 64 +++++++ OpenSim/Data/OpenSimDatabaseConnector.cs | 57 ++++++ OpenSim/Data/OpenSimObjectFieldMapper.cs | 102 ++++++++++ OpenSim/Data/OpenSimTableMapper.cs | 40 ++++ OpenSim/Data/PrimitiveBaseShapeTableMapper.cs | 170 +++++++++++++++++ OpenSim/Data/Properties/AssemblyInfo.cs | 65 +++++++ OpenSim/Data/RegionProfileData.cs | 257 ++++++++++++++++++++++++++ OpenSim/Data/ReservationData.cs | 47 +++++ OpenSim/Data/UserDataBase.cs | 29 +++ 16 files changed, 1200 insertions(+) create mode 100644 OpenSim/Data/AssetDataBase.cs create mode 100644 OpenSim/Data/DataStoreBase.cs create mode 100644 OpenSim/Data/GridDataBase.cs create mode 100644 OpenSim/Data/IGridData.cs create mode 100644 OpenSim/Data/ILogData.cs create mode 100644 OpenSim/Data/IniConfig.cs create mode 100644 OpenSim/Data/InventoryDataBase.cs create mode 100644 OpenSim/Data/OpenSimDataReader.cs create mode 100644 OpenSim/Data/OpenSimDatabaseConnector.cs create mode 100644 OpenSim/Data/OpenSimObjectFieldMapper.cs create mode 100644 OpenSim/Data/OpenSimTableMapper.cs create mode 100644 OpenSim/Data/PrimitiveBaseShapeTableMapper.cs create mode 100644 OpenSim/Data/Properties/AssemblyInfo.cs create mode 100644 OpenSim/Data/RegionProfileData.cs create mode 100644 OpenSim/Data/ReservationData.cs create mode 100644 OpenSim/Data/UserDataBase.cs (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs new file mode 100644 index 0000000..0f3044e --- /dev/null +++ b/OpenSim/Data/AssetDataBase.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Data +{ + public abstract class AssetDataBase : IAssetProvider + { + public abstract AssetBase FetchAsset(LLUUID uuid); + public abstract void CreateAsset(AssetBase asset); + public abstract void UpdateAsset(AssetBase asset); + public abstract bool ExistsAsset(LLUUID uuid); + public abstract void CommitAssets(); + + public abstract string Version { get; } + public abstract string Name { get; } + public abstract void Initialise(); + } +} diff --git a/OpenSim/Data/DataStoreBase.cs b/OpenSim/Data/DataStoreBase.cs new file mode 100644 index 0000000..92604f2 --- /dev/null +++ b/OpenSim/Data/DataStoreBase.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Data +{ + public abstract class DataStoreBase + { + } +} diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs new file mode 100644 index 0000000..9d6e832 --- /dev/null +++ b/OpenSim/Data/GridDataBase.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Framework.Data +{ + public abstract class GridDataBase : IGridData + { + public abstract RegionProfileData GetProfileByHandle(ulong regionHandle); + public abstract RegionProfileData GetProfileByLLUUID(LLUUID UUID); + public abstract RegionProfileData GetProfileByString(string regionName); + public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); + public abstract bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); + public abstract void Initialise(); + public abstract void Close(); + public abstract string getName(); + public abstract string getVersion(); + public abstract DataResponse AddProfile(RegionProfileData profile); + public abstract ReservationData GetReservationAtPoint(uint x, uint y); + } +} diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs new file mode 100644 index 0000000..af51d0d --- /dev/null +++ b/OpenSim/Data/IGridData.cs @@ -0,0 +1,118 @@ +/* + * 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 OpenSim 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.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Framework.Data +{ + public enum DataResponse + { + RESPONSE_OK, + RESPONSE_AUTHREQUIRED, + RESPONSE_INVALIDCREDENTIALS, + RESPONSE_ERROR + } + + /// + /// A standard grid interface + /// + public interface IGridData + { + /// + /// Returns a sim profile from a regionHandle + /// + /// A 64bit Region Handle + /// A simprofile + RegionProfileData GetProfileByHandle(ulong regionHandle); + + /// + /// Returns a sim profile from a UUID + /// + /// A 128bit UUID + /// A sim profile + RegionProfileData GetProfileByLLUUID(LLUUID UUID); + + /// + /// Returns a sim profile from a string match + /// + /// A string for a partial region name match + /// A sim profile + RegionProfileData GetProfileByString(string regionName); + + /// + /// Returns all profiles within the specified range + /// + /// Minimum sim coordinate (X) + /// Minimum sim coordinate (Y) + /// Maximum sim coordinate (X) + /// Maximum sim coordinate (Y) + /// An array containing all the sim profiles in the specified range + RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); + + /// + /// Authenticates a sim by use of its recv key. + /// WARNING: Insecure + /// + /// The UUID sent by the sim + /// The regionhandle sent by the sim + /// The receiving key sent by the sim + /// Whether the sim has been authenticated + bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); + + /// + /// Initialises the interface + /// + void Initialise(); + + /// + /// Closes the interface + /// + void Close(); + + /// + /// The plugin being loaded + /// + /// A string containing the plugin name + string getName(); + + /// + /// The plugins version + /// + /// A string containing the plugin version + string getVersion(); + + /// + /// Adds a new profile to the database + /// + /// The profile to add + /// RESPONSE_OK if successful, error if not. + DataResponse AddProfile(RegionProfileData profile); + + ReservationData GetReservationAtPoint(uint x, uint y); + } +} diff --git a/OpenSim/Data/ILogData.cs b/OpenSim/Data/ILogData.cs new file mode 100644 index 0000000..1751ff5 --- /dev/null +++ b/OpenSim/Data/ILogData.cs @@ -0,0 +1,91 @@ +/* + * 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 OpenSim 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. + */ + +namespace OpenSim.Framework.Data +{ + /// + /// The severity of an individual log message + /// + public enum LogSeverity : int + { + /// + /// Critical: systems failure + /// + CRITICAL = 1, + /// + /// Major: warning prior to systems failure + /// + MAJOR = 2, + /// + /// Medium: an individual non-critical task failed + /// + MEDIUM = 3, + /// + /// Low: Informational warning + /// + LOW = 4, + /// + /// Info: Information + /// + INFO = 5, + /// + /// Verbose: Debug Information + /// + VERBOSE = 6 + } + + /// + /// An interface to a LogData storage system + /// + public interface ILogData + { + void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, + string logMessage); + + /// + /// Initialises the interface + /// + void Initialise(); + + /// + /// Closes the interface + /// + void Close(); + + /// + /// The plugin being loaded + /// + /// A string containing the plugin name + string getName(); + + /// + /// The plugins version + /// + /// A string containing the plugin version + string getVersion(); + } +} diff --git a/OpenSim/Data/IniConfig.cs b/OpenSim/Data/IniConfig.cs new file mode 100644 index 0000000..47e96c8 --- /dev/null +++ b/OpenSim/Data/IniConfig.cs @@ -0,0 +1,98 @@ +/* + * 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 OpenSim 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.IO; +using System.Text.RegularExpressions; + +/* + Taken from public code listing at by Alex Pinsker + http://alexpinsker.blogspot.com/2005/12/reading-ini-file-from-c_113432097333021549.html + */ + +namespace OpenSim.Framework.Data +{ + /// + /// Parse settings from ini-like files + /// + public class IniFile + { + static IniFile() + { + _iniKeyValuePatternRegex = new Regex( + @"((\s)*(?([^\=^\s^\n]+))[\s^\n]* + # key part (surrounding whitespace stripped) + \= + (\s)*(?([^\n^\s]+(\n){0,1}))) + # value part (surrounding whitespace stripped) + ", + RegexOptions.IgnorePatternWhitespace | + RegexOptions.Compiled | + RegexOptions.CultureInvariant); + } + + private static Regex _iniKeyValuePatternRegex; + + public IniFile(string iniFileName) + { + _iniFileName = iniFileName; + } + + public string ParseFileReadValue(string key) + { + using (StreamReader reader = + new StreamReader(_iniFileName)) + { + do + { + string line = reader.ReadLine(); + Match match = + _iniKeyValuePatternRegex.Match(line); + if (match.Success) + { + string currentKey = + match.Groups["Key"].Value as string; + if (currentKey != null && + currentKey.Trim().CompareTo(key) == 0) + { + string value = + match.Groups["Value"].Value as string; + return value; + } + } + } while (reader.Peek() != -1); + } + return null; + } + + public string IniFileName + { + get { return _iniFileName; } + } + + private string _iniFileName; + } +} diff --git a/OpenSim/Data/InventoryDataBase.cs b/OpenSim/Data/InventoryDataBase.cs new file mode 100644 index 0000000..afddbf1 --- /dev/null +++ b/OpenSim/Data/InventoryDataBase.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Data +{ + public abstract class InventoryDataBase + { + } +} diff --git a/OpenSim/Data/OpenSimDataReader.cs b/OpenSim/Data/OpenSimDataReader.cs new file mode 100644 index 0000000..538af8f --- /dev/null +++ b/OpenSim/Data/OpenSimDataReader.cs @@ -0,0 +1,64 @@ +/* + * 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 OpenSim 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.Data; +using libsecondlife; +using OpenSim.Framework.Data.Base; + +namespace OpenSim.Framework.Data +{ + public class OpenSimDataReader : BaseDataReader + { + public OpenSimDataReader(IDataReader source) : base(source) + { + } + + public LLVector3 GetVector(string s) + { + float x = GetFloat(s + "X"); + float y = GetFloat(s + "Y"); + float z = GetFloat(s + "Z"); + + LLVector3 vector = new LLVector3(x, y, z); + + return vector; + } + + public LLQuaternion GetQuaternion(string s) + { + float x = GetFloat(s + "X"); + float y = GetFloat(s + "Y"); + float z = GetFloat(s + "Z"); + float w = GetFloat(s + "W"); + + LLQuaternion quaternion = new LLQuaternion(x, y, z, w); + + return quaternion; + } + } +} diff --git a/OpenSim/Data/OpenSimDatabaseConnector.cs b/OpenSim/Data/OpenSimDatabaseConnector.cs new file mode 100644 index 0000000..809fd1e --- /dev/null +++ b/OpenSim/Data/OpenSimDatabaseConnector.cs @@ -0,0 +1,57 @@ +/* + * 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 OpenSim 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.Data; +using System.Data.Common; +using libsecondlife; + +using OpenSim.Framework.Data.Base; + +namespace OpenSim.Framework.Data +{ + public abstract class OpenSimDatabaseConnector : BaseDatabaseConnector + { + public OpenSimDatabaseConnector(string connectionString) : base(connectionString) + { + } + + public override object ConvertToDbType(object value) + { + if (value is LLUUID) + { + return ((LLUUID) value).UUID.ToString(); + } + + return base.ConvertToDbType(value); + } + + public override BaseDataReader CreateReader(IDataReader reader) + { + return new OpenSimDataReader(reader); + } + } +} diff --git a/OpenSim/Data/OpenSimObjectFieldMapper.cs b/OpenSim/Data/OpenSimObjectFieldMapper.cs new file mode 100644 index 0000000..dfcca1b --- /dev/null +++ b/OpenSim/Data/OpenSimObjectFieldMapper.cs @@ -0,0 +1,102 @@ +/* + * 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 OpenSim 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.Collections.Generic; +using System.Data.Common; +using System.Text; +using libsecondlife; + +using OpenSim.Framework.Data.Base; + +namespace OpenSim.Framework.Data +{ + public class OpenSimObjectFieldMapper : ObjectField + { + public OpenSimObjectFieldMapper(BaseTableMapper tableMapper, string fieldName, + ObjectGetAccessor rowMapperGetAccessor, + ObjectSetAccessor rowMapperSetAccessor) + : base(tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor) + { + } + + public override void ExpandField(TObj obj, DbCommand command, List fieldNames) + { + string fieldName = FieldName; + object value = GetParamValue(obj); + + if (ValueType == typeof(LLVector3)) + { + LLVector3 vector = (LLVector3)value; + + RawAddParam(command, fieldNames, fieldName + "X", vector.X); + RawAddParam(command, fieldNames, fieldName + "Y", vector.Y); + RawAddParam(command, fieldNames, fieldName + "Z", vector.Z); + } + else if (ValueType == typeof(LLQuaternion)) + { + LLQuaternion quaternion = (LLQuaternion)value; + + RawAddParam(command, fieldNames, fieldName + "X", quaternion.X); + RawAddParam(command, fieldNames, fieldName + "Y", quaternion.Y); + RawAddParam(command, fieldNames, fieldName + "Z", quaternion.Z); + RawAddParam(command, fieldNames, fieldName + "W", quaternion.W); + } + else + { + base.ExpandField(obj, command, fieldNames); + } + } + + protected override object GetValue(BaseDataReader reader) + { + object value; + + OpenSimDataReader osreader = (OpenSimDataReader) reader; + + if (ValueType == typeof(LLVector3)) + { + value = osreader.GetVector(FieldName); + } + else if (ValueType == typeof(LLQuaternion)) + { + value = osreader.GetQuaternion(FieldName); + } + else if (ValueType == typeof(LLUUID)) + { + Guid guid = reader.GetGuid(FieldName); + value = new LLUUID(guid); + } + else + { + value = base.GetValue(reader); + } + + return value; + } + } +} diff --git a/OpenSim/Data/OpenSimTableMapper.cs b/OpenSim/Data/OpenSimTableMapper.cs new file mode 100644 index 0000000..cd3d1af --- /dev/null +++ b/OpenSim/Data/OpenSimTableMapper.cs @@ -0,0 +1,40 @@ +/* + * 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 OpenSim 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.Data; + +using OpenSim.Framework.Data.Base; + +namespace OpenSim.Framework.Data +{ + public abstract class OpenSimTableMapper : BaseTableMapper + { + public OpenSimTableMapper(BaseDatabaseConnector database, string tableName) : base(database, tableName) + { + } + } +} diff --git a/OpenSim/Data/PrimitiveBaseShapeTableMapper.cs b/OpenSim/Data/PrimitiveBaseShapeTableMapper.cs new file mode 100644 index 0000000..51adf89 --- /dev/null +++ b/OpenSim/Data/PrimitiveBaseShapeTableMapper.cs @@ -0,0 +1,170 @@ +/* + * 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 OpenSim 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 OpenSim.Framework; +using OpenSim.Framework.Data.Base; +using libsecondlife; + +namespace OpenSim.Framework.Data +{ + public class PrimitiveBaseShapeRowMapper : BaseRowMapper + { + public Guid SceneObjectPartId; + + public PrimitiveBaseShapeRowMapper(BaseSchema schema, PrimitiveBaseShape obj) : base(schema, obj) + { + } + } + + public class PrimitiveBaseShapeTableMapper : OpenSimTableMapper + { + public PrimitiveBaseShapeTableMapper(BaseDatabaseConnector connection, string tableName) + : base(connection, tableName) + { + BaseSchema rowMapperSchema = new BaseSchema(this); + m_schema = rowMapperSchema; + + m_keyFieldMapper = rowMapperSchema.AddMapping("SceneObjectPartId", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.SceneObjectPartId; }, + delegate(PrimitiveBaseShapeRowMapper shape, Guid value) { shape.SceneObjectPartId = value; }); + + rowMapperSchema.AddMapping("PCode", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PCode; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PCode = value; }); + + rowMapperSchema.AddMapping("PathBegin", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathBegin; }, + delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathBegin = value; }); + + rowMapperSchema.AddMapping("PathEnd", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathEnd; }, + delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathEnd = value; }); + + rowMapperSchema.AddMapping("PathScaleX", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleX; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleX = value; }); + + rowMapperSchema.AddMapping("PathScaleY", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleY; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleY = value; }); + + rowMapperSchema.AddMapping("PathShearX", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearX; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearX = value; }); + + rowMapperSchema.AddMapping("PathShearY", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearY; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearY = value; }); + + rowMapperSchema.AddMapping("ProfileBegin", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileBegin; }, + delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileBegin = value; }); + + rowMapperSchema.AddMapping("ProfileEnd", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileEnd; }, + delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileEnd = value; }); + + rowMapperSchema.AddMapping("Scale", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.Scale; }, + delegate(PrimitiveBaseShapeRowMapper shape, LLVector3 value) { shape.Object.Scale = value; }); + + rowMapperSchema.AddMapping("PathTaperX", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperX; }, + delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperX = value; }); + + rowMapperSchema.AddMapping("PathTaperY", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperY; }, + delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperY = value; }); + + rowMapperSchema.AddMapping("PathTwist", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwist; }, + delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwist = value; }); + + rowMapperSchema.AddMapping("PathRadiusOffset", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRadiusOffset; }, + delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathRadiusOffset = value; }); + + rowMapperSchema.AddMapping("PathRevolutions", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRevolutions; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathRevolutions = value; }); + + rowMapperSchema.AddMapping("PathTwistBegin", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwistBegin; }, + delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwistBegin = value; }); + + rowMapperSchema.AddMapping("PathCurve", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathCurve; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathCurve = value; }); + + rowMapperSchema.AddMapping("ProfileCurve", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileCurve; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.ProfileCurve = value; }); + + rowMapperSchema.AddMapping("ProfileHollow", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileHollow; }, + delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileHollow = value; }); + + rowMapperSchema.AddMapping("TextureEntry", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.TextureEntry; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.TextureEntry = value; }); + + rowMapperSchema.AddMapping("ExtraParams", + delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ExtraParams; }, + delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; }); + } + + public override PrimitiveBaseShapeRowMapper FromReader(BaseDataReader reader) + { + PrimitiveBaseShape shape = new PrimitiveBaseShape(); + + PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper(m_schema, shape); + mapper.FillObject( reader ); + + return mapper; + } + + public bool Update(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) + { + PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape); + return Update(sceneObjectPartId, mapper); + } + + public bool Add(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) + { + PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape); + return Add(mapper); + } + + private PrimitiveBaseShapeRowMapper CreateRowMapper(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) + { + PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper( m_schema, primitiveBaseShape ); + mapper.SceneObjectPartId = sceneObjectPartId; + return mapper; + } + } +} diff --git a/OpenSim/Data/Properties/AssemblyInfo.cs b/OpenSim/Data/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7b65a09 --- /dev/null +++ b/OpenSim/Data/Properties/AssemblyInfo.cs @@ -0,0 +1,65 @@ +/* + * 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 OpenSim 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.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly : AssemblyTitle("OpenSim.Framework.Data")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Framework.Data")] +[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2008")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly : ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly : Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly : AssemblyVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Data/RegionProfileData.cs b/OpenSim/Data/RegionProfileData.cs new file mode 100644 index 0000000..96351e0 --- /dev/null +++ b/OpenSim/Data/RegionProfileData.cs @@ -0,0 +1,257 @@ +/* + * 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 OpenSim 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.Collections; +using libsecondlife; +using Nwc.XmlRpc; + +namespace OpenSim.Framework.Data +{ + /// + /// A class which contains information known to the grid server about a region + /// + public class RegionProfileData + { + /// + /// The name of the region + /// + public string regionName = String.Empty; + + /// + /// A 64-bit number combining map position into a (mostly) unique ID + /// + public ulong regionHandle; + + /// + /// OGS/OpenSim Specific ID for a region + /// + public LLUUID UUID; + + /// + /// Coordinates of the region + /// + public uint regionLocX; + public uint regionLocY; + public uint regionLocZ; // Reserved (round-robin, layers, etc) + + /// + /// Authentication secrets + /// + /// Not very secure, needs improvement. + public string regionSendKey = String.Empty; + public string regionRecvKey = String.Empty; + public string regionSecret = String.Empty; + + /// + /// Whether the region is online + /// + public bool regionOnline; + + /// + /// Information about the server that the region is currently hosted on + /// + public string serverIP = String.Empty; + public uint serverPort; + public string serverURI = String.Empty; + + public uint httpPort; + public uint remotingPort; + public string httpServerURI = String.Empty; + + /// + /// Set of optional overrides. Can be used to create non-eulicidean spaces. + /// + public ulong regionNorthOverrideHandle; + public ulong regionSouthOverrideHandle; + public ulong regionEastOverrideHandle; + public ulong regionWestOverrideHandle; + + /// + /// Optional: URI Location of the region database + /// + /// Used for floating sim pools where the region data is not nessecarily coupled to a specific server + public string regionDataURI = String.Empty; + + /// + /// Region Asset Details + /// + public string regionAssetURI = String.Empty; + + public string regionAssetSendKey = String.Empty; + public string regionAssetRecvKey = String.Empty; + + /// + /// Region Userserver Details + /// + public string regionUserURI = String.Empty; + + public string regionUserSendKey = String.Empty; + public string regionUserRecvKey = String.Empty; + + /// + /// Region Map Texture Asset + /// + public LLUUID regionMapTextureID = new LLUUID("00000000-0000-1111-9999-000000000006"); + + /// + /// this particular mod to the file provides support within the spec for RegionProfileData for the + /// owner_uuid for the region + /// + public LLUUID owner_uuid = LLUUID.Zero; + + /// + /// OGS/OpenSim Specific original ID for a region after move/split + /// + public LLUUID originUUID; + + /// + /// Get Sim profile data from grid server when in grid mode + /// + /// + /// + /// + /// + public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, + string gridserver_sendkey, string gridserver_recvkey) + { + Hashtable requestData = new Hashtable(); + requestData["region_uuid"] = region_uuid.UUID.ToString(); + requestData["authkey"] = gridserver_sendkey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); + + Hashtable responseData = (Hashtable) GridResp.Value; + + if (responseData.ContainsKey("error")) + { + return null; + } + + RegionProfileData simData = new RegionProfileData(); + simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); + simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); + simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); + simData.serverIP = (string) responseData["sim_ip"]; + simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); + simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); + simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); + simData.serverURI = (string)responseData["server_uri"]; + simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; + simData.UUID = new LLUUID((string) responseData["region_UUID"]); + simData.regionName = (string) responseData["region_name"]; + + return simData; + } + + /// + /// Request sim profile information from a grid server + /// + /// + /// + /// + /// + /// The sim profile. Null if there was a request failure + public static RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, + string gridserver_sendkey, string gridserver_recvkey) + { + Hashtable requestData = new Hashtable(); + requestData["region_handle"] = region_handle.ToString(); + requestData["authkey"] = gridserver_sendkey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); + + Hashtable responseData = (Hashtable) GridResp.Value; + + if (responseData.ContainsKey("error")) + { + return null; + } + + RegionProfileData simData = new RegionProfileData(); + simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); + simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); + simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); + simData.serverIP = (string) responseData["sim_ip"]; + simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); + simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); + simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); + simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; + simData.serverURI = (string)responseData["server_uri"]; + simData.UUID = new LLUUID((string) responseData["region_UUID"]); + simData.regionName = (string) responseData["region_name"]; + + return simData; + } + + /// + /// Request sim profile information from a grid server + /// + /// + /// + /// + /// + /// The sim profile. Null if there was a request failure + public static RegionProfileData RequestSimProfileData(string regionName, string gridserver_url, + string gridserver_sendkey, string gridserver_recvkey) + { + Hashtable requestData = new Hashtable(); + requestData["region_name_search"] = regionName; + requestData["authkey"] = gridserver_sendkey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); + + Hashtable responseData = (Hashtable)GridResp.Value; + + if (responseData.ContainsKey("error")) + { + return null; + } + + RegionProfileData simData = new RegionProfileData(); + simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); + simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); + simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); + simData.serverIP = (string)responseData["sim_ip"]; + simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); + simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); + simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; + simData.serverURI = (string)responseData["server_uri"]; + simData.UUID = new LLUUID((string)responseData["region_UUID"]); + simData.regionName = (string)responseData["region_name"]; + + return simData; + } + } +} diff --git a/OpenSim/Data/ReservationData.cs b/OpenSim/Data/ReservationData.cs new file mode 100644 index 0000000..0c2cff3 --- /dev/null +++ b/OpenSim/Data/ReservationData.cs @@ -0,0 +1,47 @@ +/* + * 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 OpenSim 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 libsecondlife; + +namespace OpenSim.Framework.Data +{ + public class ReservationData + { + public LLUUID userUUID = LLUUID.Zero; + public int reservationMinX = 0; + public int reservationMinY = 0; + public int reservationMaxX = 65536; + public int reservationMaxY = 65536; + + public string reservationName = System.String.Empty; + public string reservationCompany = System.String.Empty; + public bool status = true; + + public string gridSendKey = System.String.Empty; + public string gridRecvKey = System.String.Empty; + } +} diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs new file mode 100644 index 0000000..5e0be45 --- /dev/null +++ b/OpenSim/Data/UserDataBase.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Framework.Data +{ + public abstract class UserDataBase : IUserData + { + public abstract UserProfileData GetUserByUUID(LLUUID user); + public abstract UserProfileData GetUserByName(string fname, string lname); + public abstract UserAgentData GetAgentByUUID(LLUUID user); + public abstract UserAgentData GetAgentByName(string name); + public abstract UserAgentData GetAgentByName(string fname, string lname); + public abstract void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey); + public abstract void AddNewUserProfile(UserProfileData user); + public abstract bool UpdateUserProfile(UserProfileData user); + public abstract void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid); + public abstract void AddNewUserAgent(UserAgentData agent); + public abstract void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms); + public abstract void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend); + public abstract void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms); + public abstract List GetUserFriendList(LLUUID friendlistowner); + public abstract bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount); + public abstract bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); + public abstract string GetVersion(); + public abstract string getName(); + public abstract void Initialise(); + public abstract List GeneratePickerResults(LLUUID queryID, string query); + } +} -- cgit v1.1