From bc543c1797c629a8584dd2e74d3c5f7a67de96c9 Mon Sep 17 00:00:00 2001 From: PixelTomsen Date: Wed, 23 May 2012 21:06:25 +0200 Subject: Environment Module - allows Environment settings for Viewer3 warning: includes database region store migrations for mssql, mysql, sqlite enable/disable this module: Cap_EnvironmentSettings = "localhost" (for enable) Cap_EnvironmentSettings = "" (for disable) at ClientStack.LindenCaps section (OpenSimDefaults.ini file) or owerwrite in OpenSim.ini mantis: http://opensimulator.org/mantis/view.php?id=5860 Signed-off-by: BlueWall --- OpenSim/Data/SQLite/SQLiteSimulationData.cs | 101 +++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/SQLite/SQLiteSimulationData.cs') diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 7e7c08a..f40e866 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs @@ -61,6 +61,7 @@ namespace OpenSim.Data.SQLite private const string regionbanListSelect = "select * from regionban"; private const string regionSettingsSelect = "select * from regionsettings"; private const string regionWindlightSelect = "select * from regionwindlight"; + private const string regionEnvironmentSelect = "select * from regionenvironment"; private const string regionSpawnPointsSelect = "select * from spawn_points"; private DataSet ds; @@ -72,6 +73,7 @@ namespace OpenSim.Data.SQLite private SqliteDataAdapter landAccessListDa; private SqliteDataAdapter regionSettingsDa; private SqliteDataAdapter regionWindlightDa; + private SqliteDataAdapter regionEnvironmentDa; private SqliteDataAdapter regionSpawnPointsDa; private SqliteConnection m_conn; @@ -146,6 +148,9 @@ namespace OpenSim.Data.SQLite SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn); regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd); + SqliteCommand regionEnvironmentSelectCmd = new SqliteCommand(regionEnvironmentSelect, m_conn); + regionEnvironmentDa = new SqliteDataAdapter(regionEnvironmentSelectCmd); + SqliteCommand regionSpawnPointsSelectCmd = new SqliteCommand(regionSpawnPointsSelect, m_conn); regionSpawnPointsDa = new SqliteDataAdapter(regionSpawnPointsSelectCmd); @@ -179,6 +184,9 @@ namespace OpenSim.Data.SQLite ds.Tables.Add(createRegionWindlightTable()); setupRegionWindlightCommands(regionWindlightDa, m_conn); + ds.Tables.Add(createRegionEnvironmentTable()); + setupRegionEnvironmentCommands(regionEnvironmentDa, m_conn); + ds.Tables.Add(createRegionSpawnPointsTable()); setupRegionSpawnPointsCommands(regionSpawnPointsDa, m_conn); @@ -260,6 +268,15 @@ namespace OpenSim.Data.SQLite try { + regionEnvironmentDa.Fill(ds.Tables["regionenvironment"]); + } + catch (Exception e) + { + m_log.ErrorFormat("[SQLITE REGION DB]: Caught fill error on regionenvironment table :{0}", e.Message); + } + + try + { regionSpawnPointsDa.Fill(ds.Tables["spawn_points"]); } catch (Exception e) @@ -278,12 +295,13 @@ namespace OpenSim.Data.SQLite CreateDataSetMapping(landAccessListDa, "landaccesslist"); CreateDataSetMapping(regionSettingsDa, "regionsettings"); CreateDataSetMapping(regionWindlightDa, "regionwindlight"); + CreateDataSetMapping(regionEnvironmentDa, "regionenvironment"); CreateDataSetMapping(regionSpawnPointsDa, "spawn_points"); } } catch (Exception e) { - m_log.ErrorFormat("[SQLITE REGION DB]: ", e); + m_log.ErrorFormat("[SQLITE REGION DB]: {0} - {1}", e.Message, e.StackTrace); Environment.Exit(23); } return; @@ -341,6 +359,11 @@ namespace OpenSim.Data.SQLite regionWindlightDa.Dispose(); regionWindlightDa = null; } + if (regionEnvironmentDa != null) + { + regionEnvironmentDa.Dispose(); + regionEnvironmentDa = null; + } if (regionSpawnPointsDa != null) { regionSpawnPointsDa.Dispose(); @@ -474,6 +497,63 @@ namespace OpenSim.Data.SQLite } } + #region Region Environment Settings + public string LoadRegionEnvironmentSettings(UUID regionUUID) + { + lock (ds) + { + DataTable environmentTable = ds.Tables["regionenvironment"]; + DataRow row = environmentTable.Rows.Find(regionUUID.ToString()); + if (row == null) + { + return String.Empty; + } + + return (String)row["llsd_settings"]; + } + } + + public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) + { + lock (ds) + { + DataTable environmentTable = ds.Tables["regionenvironment"]; + DataRow row = environmentTable.Rows.Find(regionUUID.ToString()); + + if (row == null) + { + row = environmentTable.NewRow(); + row["region_id"] = regionUUID.ToString(); + row["llsd_settings"] = settings; + environmentTable.Rows.Add(row); + } + else + { + row["llsd_settings"] = settings; + } + + regionEnvironmentDa.Update(ds, "regionenvironment"); + } + } + + public void RemoveRegionEnvironmentSettings(UUID regionUUID) + { + lock (ds) + { + DataTable environmentTable = ds.Tables["regionenvironment"]; + DataRow row = environmentTable.Rows.Find(regionUUID.ToString()); + + if (row != null) + { + row.Delete(); + } + + regionEnvironmentDa.Update(ds, "regionenvironment"); + } + } + + #endregion + public RegionSettings LoadRegionSettings(UUID regionUUID) { lock (ds) @@ -1430,6 +1510,17 @@ namespace OpenSim.Data.SQLite return regionwindlight; } + private static DataTable createRegionEnvironmentTable() + { + DataTable regionEnvironment = new DataTable("regionenvironment"); + createCol(regionEnvironment, "region_id", typeof(String)); + createCol(regionEnvironment, "llsd_settings", typeof(String)); + + regionEnvironment.PrimaryKey = new DataColumn[] { regionEnvironment.Columns["region_id"] }; + + return regionEnvironment; + } + private static DataTable createRegionSpawnPointsTable() { DataTable spawn_points = new DataTable("spawn_points"); @@ -2691,6 +2782,14 @@ namespace OpenSim.Data.SQLite da.UpdateCommand.Connection = conn; } + private void setupRegionEnvironmentCommands(SqliteDataAdapter da, SqliteConnection conn) + { + da.InsertCommand = createInsertCommand("regionenvironment", ds.Tables["regionenvironment"]); + da.InsertCommand.Connection = conn; + da.UpdateCommand = createUpdateCommand("regionenvironment", "region_id=:region_id", ds.Tables["regionenvironment"]); + da.UpdateCommand.Connection = conn; + } + private void setupRegionSpawnPointsCommands(SqliteDataAdapter da, SqliteConnection conn) { da.InsertCommand = createInsertCommand("spawn_points", ds.Tables["spawn_points"]); -- cgit v1.1