From d3a20a1e9257ecec417e219ebaf079370015f06d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 21:37:06 +0000 Subject: On initial region registration, if the user chooses the option to make the region part of an existing estate, then list the existing region names. --- OpenSim/Data/MSSQL/MSSQLEstateData.cs | 17 +++++++++ OpenSim/Data/MySQL/MySQLEstateData.cs | 40 ++++++++++++++++++++++ OpenSim/Data/SQLite/SQLiteEstateData.cs | 32 +++++++++++++++++ OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs | 33 ++++++++++++++++++ OpenSim/Region/Application/OpenSimBase.cs | 13 ++++++- .../Framework/Interfaces/IEstateDataService.cs | 14 ++++++++ .../Framework/Interfaces/IEstateDataStore.cs | 14 ++++++++ .../Connectors/Simulation/EstateDataService.cs | 10 ++++++ 8 files changed, 172 insertions(+), 1 deletion(-) diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs index e9a0935..92a8d80 100644 --- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs +++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs @@ -350,26 +350,43 @@ namespace OpenSim.Data.MSSQL public EstateSettings LoadEstateSettings(int estateID) { + // TODO: Implementation! return new EstateSettings(); } + + public List LoadEstateSettingsAll() + { + // TODO: Implementation! + return new List(); + } public List GetEstates(string search) { + // TODO: Implementation! + return new List(); + } + + public List GetEstatesAll() + { + // TODO: Implementation! return new List(); } public bool LinkRegion(UUID regionID, int estateID) { + // TODO: Implementation! return false; } public List GetRegions(int estateID) { + // TODO: Implementation! return new List(); } public bool DeleteEstate(int estateID) { + // TODO: Implementation! return false; } #endregion diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index de72a6a..6d72e82 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -413,6 +413,46 @@ namespace OpenSim.Data.MySQL return DoLoad(cmd, UUID.Zero, false); } } + + public List LoadEstateSettingsAll() + { + List allEstateSettings = new List(); + + List allEstateIds = GetEstatesAll(); + + foreach (int estateId in allEstateIds) + allEstateSettings.Add(LoadEstateSettings(estateId)); + + return allEstateSettings; + } + + public List GetEstatesAll() + { + List result = new List(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select estateID from estate_settings"; + + using (IDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(Convert.ToInt32(reader["EstateID"])); + } + reader.Close(); + } + } + + dbcon.Close(); + } + + return result; + } public List GetEstates(string search) { diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index 63252aa..6afc540 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs @@ -357,6 +357,17 @@ namespace OpenSim.Data.SQLite return DoLoad(cmd, UUID.Zero, false); } + + public List LoadEstateSettingsAll() + { + List estateSettings = new List(); + + List estateIds = GetEstatesAll(); + foreach (int estateId in estateIds) + estateSettings.Add(LoadEstateSettings(estateId)); + + return estateSettings; + } public List GetEstates(string search) { @@ -379,6 +390,27 @@ namespace OpenSim.Data.SQLite return result; } + + public List GetEstatesAll() + { + List result = new List(); + + string sql = "select EstateID from estate_settings"; + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = sql; + + IDataReader r = cmd.ExecuteReader(); + + while (r.Read()) + { + result.Add(Convert.ToInt32(r["EstateID"])); + } + r.Close(); + + return result; + } public bool LinkRegion(UUID regionID, int estateID) { diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs index 547ea6b..ad28c00 100644 --- a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs @@ -100,6 +100,17 @@ namespace OpenSim.Data.SQLiteLegacy return DoLoad(cmd, regionID, create); } + + public List LoadEstateSettingsAll() + { + List estateSettings = new List(); + + List estateIds = GetEstatesAll(); + foreach (int estateId in estateIds) + estateSettings.Add(LoadEstateSettings(estateId)); + + return estateSettings; + } private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) { @@ -369,6 +380,28 @@ namespace OpenSim.Data.SQLiteLegacy return result; } + + public List GetEstatesAll() + { + List result = new List(); + + string sql = "select EstateID from estate_settings"; + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = sql; + + IDataReader r = cmd.ExecuteReader(); + + while (r.Read()) + { + result.Add(Convert.ToInt32(r["EstateID"])); + } + r.Close(); + + return result; + } + public bool LinkRegion(UUID regionID, int estateID) { SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index e950613..f804cb7 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -828,7 +828,18 @@ namespace OpenSim } else { - response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); + List estates = estateDataService.LoadEstateSettingsAll(); + + List estateNames = new List(); + foreach (EstateSettings estate in estates) + estateNames.Add(estate.EstateName); + + response + = MainConsole.Instance.CmdPrompt( + string.Format( + "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())), + "None"); + if (response == "None") continue; diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs index 95c9659..12ed9e3 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataService.cs @@ -36,8 +36,22 @@ namespace OpenSim.Region.Framework.Interfaces { EstateSettings LoadEstateSettings(UUID regionID, bool create); EstateSettings LoadEstateSettings(int estateID); + + /// + /// Load/Get all estate settings. + /// + /// An empty list if no estates were found. + List LoadEstateSettingsAll(); + void StoreEstateSettings(EstateSettings es); List GetEstates(string search); + + /// + /// Get the IDs of all estates. + /// + /// An empty list if no estates were found. + List GetEstatesAll(); + bool LinkRegion(UUID regionID, int estateID); List GetRegions(int estateID); bool DeleteEstate(int estateID); diff --git a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs index 87c7a05..d78ad78 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateDataStore.cs @@ -37,8 +37,22 @@ namespace OpenSim.Region.Framework.Interfaces EstateSettings LoadEstateSettings(UUID regionID, bool create); EstateSettings LoadEstateSettings(int estateID); + + /// + /// Load/Get all estate settings. + /// + /// An empty list if no estates were found. + List LoadEstateSettingsAll(); + void StoreEstateSettings(EstateSettings es); List GetEstates(string search); + + /// + /// Get the IDs of all estates. + /// + /// An empty list if no estates were found. + List GetEstatesAll(); + bool LinkRegion(UUID regionID, int estateID); List GetRegions(int estateID); bool DeleteEstate(int estateID); diff --git a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs b/OpenSim/Services/Connectors/Simulation/EstateDataService.cs index b6df5a2..d0588bf 100644 --- a/OpenSim/Services/Connectors/Simulation/EstateDataService.cs +++ b/OpenSim/Services/Connectors/Simulation/EstateDataService.cs @@ -90,6 +90,11 @@ namespace OpenSim.Services.Connectors { return m_database.LoadEstateSettings(estateID); } + + public List LoadEstateSettingsAll() + { + return m_database.LoadEstateSettingsAll(); + } public void StoreEstateSettings(EstateSettings es) { @@ -100,6 +105,11 @@ namespace OpenSim.Services.Connectors { return m_database.GetEstates(search); } + + public List GetEstatesAll() + { + return m_database.GetEstatesAll(); + } public bool LinkRegion(UUID regionID, int estateID) { -- cgit v1.1