From 16d68749a457acf079a6737f4ca9a9adb9e53e2f Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Fri, 3 Oct 2008 23:00:42 +0000 Subject: Add the missing bits for the new region-search: - Added lookup in the data-layer - MySQL works - SQLite doesn't have a grid-db, so it won't work there - I added MSSQL-code to the best of my knowledge; but I don't know MSSQL :-) - Added the plumbing up to OGS1GridServices. This speaks with the grid-server via XMLRPC. - Modified MapSearchModule to use the new data. It's backward compatible; if used with an old grid-server, it just returns one found region instead of a list. - Refactored a bit. Note: This updates data, grid-server and region code. No new files. --- OpenSim/Data/GridDataBase.cs | 3 +++ OpenSim/Data/IGridData.cs | 9 +++++++ OpenSim/Data/MSSQL/MSSQLGridData.cs | 27 ++++++++++++++++++++ OpenSim/Data/MySQL/MySQLGridData.cs | 46 +++++++++++++++++++++++++++++++++++ OpenSim/Data/SQLite/SQLiteGridData.cs | 12 +++++++++ 5 files changed, 97 insertions(+) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs index e8dbc11..1e2b6fa 100644 --- a/OpenSim/Data/GridDataBase.cs +++ b/OpenSim/Data/GridDataBase.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; using OpenMetaverse; namespace OpenSim.Data @@ -35,6 +36,7 @@ namespace OpenSim.Data public abstract RegionProfileData GetProfileByUUID(UUID UUID); public abstract RegionProfileData GetProfileByString(string regionName); public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); + public abstract List GetRegionsByName(string namePrefix, uint maxNum); public abstract bool AuthenticateSim(UUID UUID, ulong regionHandle, string simrecvkey); public abstract DataResponse AddProfile(RegionProfileData profile); public abstract ReservationData GetReservationAtPoint(uint x, uint y); @@ -44,6 +46,7 @@ namespace OpenSim.Data public abstract void Initialise(); public abstract void Initialise(string connect); public abstract void Dispose(); + public abstract string Name { get; } public abstract string Version { get; } } diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs index 132361f..a42a7d8 100644 --- a/OpenSim/Data/IGridData.cs +++ b/OpenSim/Data/IGridData.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; @@ -80,6 +81,14 @@ namespace OpenSim.Data RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); /// + /// Returns up to maxNum profiles of regions that have a name starting with namePrefix + /// + /// The name to match against + /// Maximum number of profiles to return + /// A list of sim profiles + List GetRegionsByName(string namePrefix, uint maxNum); + + /// /// Authenticates a sim by use of its recv key. /// WARNING: Insecure /// diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs index 443116a..6f94980 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs @@ -216,6 +216,33 @@ namespace OpenSim.Data.MSSQL return null; } + + /// + /// Returns up to maxNum profiles of regions that have a name starting with namePrefix + /// + /// The name to match against + /// Maximum number of profiles to return + /// A list of sim profiles + override public List GetRegionsByName (string namePrefix, uint maxNum) + { + using (AutoClosingSqlCommand command = database.Query("SELECT * FROM regions WHERE regionName LIKE @name")) + { + command.Parameters.Add(database.CreateParameter("name", namePrefix + "%")); + + List rows = new List(); + + using (SqlDataReader reader = command.ExecuteReader()) + { + while (rows.Count < maxNum && reader.Read()) + { + rows.Add(ReadSimRow(reader)); + } + } + + return rows; + } + } + /// /// Returns a sim profile from its location /// diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 1155ae3..26a8591 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -283,6 +283,52 @@ namespace OpenSim.Data.MySQL } /// + /// Returns up to maxNum profiles of regions that have a name starting with namePrefix + /// + /// The name to match against + /// Maximum number of profiles to return + /// A list of sim profiles + override public List GetRegionsByName(string namePrefix, uint maxNum) + { + MySQLSuperManager dbm = GetLockedConnection(); + + try + { + Dictionary param = new Dictionary(); + param["?name"] = namePrefix + "%"; + + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName LIKE ?name", + param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row; + + List rows = new List(); + + while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) + { + rows.Add(row); + } + reader.Close(); + result.Dispose(); + + return rows; + } + catch (Exception e) + { + dbm.Manager.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + finally + { + dbm.Release(); + } + } + + /// /// Returns a sim profile from it's location /// /// Region location handle diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs index 3e1c67a..5b0455d 100644 --- a/OpenSim/Data/SQLite/SQLiteGridData.cs +++ b/OpenSim/Data/SQLite/SQLiteGridData.cs @@ -108,6 +108,18 @@ namespace OpenSim.Data.SQLite return null; } + + /// + /// Returns up to maxNum profiles of regions that have a name starting with namePrefix + /// + /// The name to match against + /// Maximum number of profiles to return + /// A list of sim profiles + override public List GetRegionsByName (string namePrefix, uint maxNum) + { + return null; + } + /// /// Returns a sim profile from it's handle /// -- cgit v1.1