aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorPixelTomsen2012-05-23 21:06:25 +0200
committerBlueWall2012-05-23 17:04:19 -0400
commitbc543c1797c629a8584dd2e74d3c5f7a67de96c9 (patch)
treeb7521f1875c349929dbfc79ef6562cf7082fd72e /OpenSim/Data
parentFormat cleanup (diff)
downloadopensim-SC_OLD-bc543c1797c629a8584dd2e74d3c5f7a67de96c9.zip
opensim-SC_OLD-bc543c1797c629a8584dd2e74d3c5f7a67de96c9.tar.gz
opensim-SC_OLD-bc543c1797c629a8584dd2e74d3c5f7a67de96c9.tar.bz2
opensim-SC_OLD-bc543c1797c629a8584dd2e74d3c5f7a67de96c9.tar.xz
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 <jamesh@bluewallgroup.com>
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLSimulationData.cs66
-rw-r--r--OpenSim/Data/MSSQL/Resources/RegionStore.migrations14
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs62
-rw-r--r--OpenSim/Data/MySQL/Resources/RegionStore.migrations11
-rw-r--r--OpenSim/Data/Null/NullSimulationData.cs18
-rw-r--r--OpenSim/Data/SQLite/Resources/RegionStore.migrations11
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs101
7 files changed, 282 insertions, 1 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
index d9dfe86..3f29f5b 100644
--- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
@@ -1181,6 +1181,72 @@ VALUES
1181 // } 1181 // }
1182 #endregion 1182 #endregion
1183 } 1183 }
1184
1185 #region Environment Settings
1186 public string LoadRegionEnvironmentSettings(UUID regionUUID)
1187 {
1188 string sql = "select * from [regionenvironment] where region_id = @region_id";
1189 using (SqlConnection conn = new SqlConnection(m_connectionString))
1190 using (SqlCommand cmd = new SqlCommand(sql, conn))
1191 {
1192 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID));
1193 conn.Open();
1194 using (SqlDataReader result = cmd.ExecuteReader())
1195 {
1196 if (!result.Read())
1197 {
1198 return String.Empty;
1199 }
1200 else
1201 {
1202 return Convert.ToString(result["llsd_settings"]);
1203 }
1204 }
1205 }
1206 }
1207
1208 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
1209 {
1210 {
1211 string sql = "DELETE FROM [regionenvironment] WHERE region_id = @region_id";
1212 using (SqlConnection conn = new SqlConnection(m_connectionString))
1213
1214 using (SqlCommand cmd = new SqlCommand(sql, conn))
1215 {
1216 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID));
1217 conn.Open();
1218 cmd.ExecuteNonQuery();
1219 }
1220
1221 sql = "INSERT INTO [regionenvironment] (region_id, llsd_settings) VALUES (@region_id, @llsd_settings)";
1222
1223 using (SqlConnection conn = new SqlConnection(m_connectionString))
1224
1225 using (SqlCommand cmd = new SqlCommand(sql, conn))
1226 {
1227 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID));
1228 cmd.Parameters.Add(_Database.CreateParameter("@llsd_settings", settings));
1229
1230 conn.Open();
1231 cmd.ExecuteNonQuery();
1232 }
1233 }
1234 }
1235
1236 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
1237 {
1238 string sql = "delete from [regionenvironment] where region_id = @region_id";
1239 using (SqlConnection conn = new SqlConnection(m_connectionString))
1240 using (SqlCommand cmd = new SqlCommand(sql, conn))
1241 {
1242 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID));
1243
1244 conn.Open();
1245 cmd.ExecuteNonQuery();
1246 }
1247 }
1248 #endregion
1249
1184 /// <summary> 1250 /// <summary>
1185 /// Loads the settings of a region. 1251 /// Loads the settings of a region.
1186 /// </summary> 1252 /// </summary>
diff --git a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
index d6a3be9..350e548 100644
--- a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
@@ -1134,3 +1134,17 @@ ALTER TABLE landaccesslist ADD Expires integer NOT NULL DEFAULT 0;
1134 1134
1135COMMIT 1135COMMIT
1136 1136
1137:VERSION 37 #---------------- Environment Settings
1138
1139BEGIN TRANSACTION
1140
1141CREATE TABLE [dbo].[regionenvironment](
1142 [region_id] [uniqueidentifier] NOT NULL,
1143 [llsd_settings] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
1144 PRIMARY KEY CLUSTERED
1145(
1146 [region_id] ASC
1147)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
1148) ON [PRIMARY]
1149
1150COMMIT
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index b2a1481..1a2e113 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -969,6 +969,68 @@ namespace OpenSim.Data.MySQL
969 } 969 }
970 } 970 }
971 971
972 #region RegionEnvironmentSettings
973 public string LoadRegionEnvironmentSettings(UUID regionUUID)
974 {
975 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
976 {
977 dbcon.Open();
978
979 string command = "select * from `regionenvironment` where region_id = ?region_id";
980
981 using (MySqlCommand cmd = new MySqlCommand(command))
982 {
983 cmd.Connection = dbcon;
984
985 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
986
987 IDataReader result = ExecuteReader(cmd);
988 if (!result.Read())
989 {
990 return String.Empty;
991 }
992 else
993 {
994 return Convert.ToString(result["llsd_settings"]);
995 }
996 }
997 }
998 }
999
1000 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
1001 {
1002 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1003 {
1004 dbcon.Open();
1005
1006 using (MySqlCommand cmd = dbcon.CreateCommand())
1007 {
1008 cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)";
1009
1010 cmd.Parameters.AddWithValue("region_id", regionUUID);
1011 cmd.Parameters.AddWithValue("llsd_settings", settings);
1012
1013 ExecuteNonQuery(cmd);
1014 }
1015 }
1016 }
1017
1018 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
1019 {
1020 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
1021 {
1022 dbcon.Open();
1023
1024 using (MySqlCommand cmd = dbcon.CreateCommand())
1025 {
1026 cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id";
1027 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1028 ExecuteNonQuery(cmd);
1029 }
1030 }
1031 }
1032 #endregion
1033
972 public void StoreRegionSettings(RegionSettings rs) 1034 public void StoreRegionSettings(RegionSettings rs)
973 { 1035 {
974 lock (m_dbLock) 1036 lock (m_dbLock)
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index 099beaf..4a925fb 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -883,4 +883,15 @@ ALTER TABLE `regionsettings` MODIFY COLUMN `TelehubObject` VARCHAR(36) NOT NULL
883 883
884COMMIT; 884COMMIT;
885 885
886:VERSION 44 #--------------------- Environment Settings
887
888BEGIN;
889
890CREATE TABLE `regionenvironment` (
891 `region_id` varchar(36) NOT NULL,
892 `llsd_settings` TEXT NOT NULL,
893 PRIMARY KEY (`region_id`)
894) ENGINE=InnoDB DEFAULT CHARSET=utf8;
895
896COMMIT;
886 897
diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs
index 18a4818..8f2314f 100644
--- a/OpenSim/Data/Null/NullSimulationData.cs
+++ b/OpenSim/Data/Null/NullSimulationData.cs
@@ -76,6 +76,24 @@ namespace OpenSim.Data.Null
76 //This connector doesn't support the windlight module yet 76 //This connector doesn't support the windlight module yet
77 } 77 }
78 78
79 #region Environment Settings
80 public string LoadRegionEnvironmentSettings(UUID regionUUID)
81 {
82 //This connector doesn't support the Environment module yet
83 return string.Empty;
84 }
85
86 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
87 {
88 //This connector doesn't support the Environment module yet
89 }
90
91 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
92 {
93 //This connector doesn't support the Environment module yet
94 }
95 #endregion
96
79 public RegionSettings LoadRegionSettings(UUID regionUUID) 97 public RegionSettings LoadRegionSettings(UUID regionUUID)
80 { 98 {
81 RegionSettings rs = new RegionSettings(); 99 RegionSettings rs = new RegionSettings();
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
index 1ceddf9..e872977 100644
--- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations
+++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
@@ -564,3 +564,14 @@ COMMIT;
564BEGIN; 564BEGIN;
565ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; 565ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
566COMMIT; 566COMMIT;
567
568:VERSION 26
569
570BEGIN;
571
572CREATE TABLE `regionenvironment` (
573 `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000' PRIMARY KEY,
574 `llsd_settings` TEXT NOT NULL
575);
576
577COMMIT;
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
61 private const string regionbanListSelect = "select * from regionban"; 61 private const string regionbanListSelect = "select * from regionban";
62 private const string regionSettingsSelect = "select * from regionsettings"; 62 private const string regionSettingsSelect = "select * from regionsettings";
63 private const string regionWindlightSelect = "select * from regionwindlight"; 63 private const string regionWindlightSelect = "select * from regionwindlight";
64 private const string regionEnvironmentSelect = "select * from regionenvironment";
64 private const string regionSpawnPointsSelect = "select * from spawn_points"; 65 private const string regionSpawnPointsSelect = "select * from spawn_points";
65 66
66 private DataSet ds; 67 private DataSet ds;
@@ -72,6 +73,7 @@ namespace OpenSim.Data.SQLite
72 private SqliteDataAdapter landAccessListDa; 73 private SqliteDataAdapter landAccessListDa;
73 private SqliteDataAdapter regionSettingsDa; 74 private SqliteDataAdapter regionSettingsDa;
74 private SqliteDataAdapter regionWindlightDa; 75 private SqliteDataAdapter regionWindlightDa;
76 private SqliteDataAdapter regionEnvironmentDa;
75 private SqliteDataAdapter regionSpawnPointsDa; 77 private SqliteDataAdapter regionSpawnPointsDa;
76 78
77 private SqliteConnection m_conn; 79 private SqliteConnection m_conn;
@@ -146,6 +148,9 @@ namespace OpenSim.Data.SQLite
146 SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn); 148 SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn);
147 regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd); 149 regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd);
148 150
151 SqliteCommand regionEnvironmentSelectCmd = new SqliteCommand(regionEnvironmentSelect, m_conn);
152 regionEnvironmentDa = new SqliteDataAdapter(regionEnvironmentSelectCmd);
153
149 SqliteCommand regionSpawnPointsSelectCmd = new SqliteCommand(regionSpawnPointsSelect, m_conn); 154 SqliteCommand regionSpawnPointsSelectCmd = new SqliteCommand(regionSpawnPointsSelect, m_conn);
150 regionSpawnPointsDa = new SqliteDataAdapter(regionSpawnPointsSelectCmd); 155 regionSpawnPointsDa = new SqliteDataAdapter(regionSpawnPointsSelectCmd);
151 156
@@ -179,6 +184,9 @@ namespace OpenSim.Data.SQLite
179 ds.Tables.Add(createRegionWindlightTable()); 184 ds.Tables.Add(createRegionWindlightTable());
180 setupRegionWindlightCommands(regionWindlightDa, m_conn); 185 setupRegionWindlightCommands(regionWindlightDa, m_conn);
181 186
187 ds.Tables.Add(createRegionEnvironmentTable());
188 setupRegionEnvironmentCommands(regionEnvironmentDa, m_conn);
189
182 ds.Tables.Add(createRegionSpawnPointsTable()); 190 ds.Tables.Add(createRegionSpawnPointsTable());
183 setupRegionSpawnPointsCommands(regionSpawnPointsDa, m_conn); 191 setupRegionSpawnPointsCommands(regionSpawnPointsDa, m_conn);
184 192
@@ -260,6 +268,15 @@ namespace OpenSim.Data.SQLite
260 268
261 try 269 try
262 { 270 {
271 regionEnvironmentDa.Fill(ds.Tables["regionenvironment"]);
272 }
273 catch (Exception e)
274 {
275 m_log.ErrorFormat("[SQLITE REGION DB]: Caught fill error on regionenvironment table :{0}", e.Message);
276 }
277
278 try
279 {
263 regionSpawnPointsDa.Fill(ds.Tables["spawn_points"]); 280 regionSpawnPointsDa.Fill(ds.Tables["spawn_points"]);
264 } 281 }
265 catch (Exception e) 282 catch (Exception e)
@@ -278,12 +295,13 @@ namespace OpenSim.Data.SQLite
278 CreateDataSetMapping(landAccessListDa, "landaccesslist"); 295 CreateDataSetMapping(landAccessListDa, "landaccesslist");
279 CreateDataSetMapping(regionSettingsDa, "regionsettings"); 296 CreateDataSetMapping(regionSettingsDa, "regionsettings");
280 CreateDataSetMapping(regionWindlightDa, "regionwindlight"); 297 CreateDataSetMapping(regionWindlightDa, "regionwindlight");
298 CreateDataSetMapping(regionEnvironmentDa, "regionenvironment");
281 CreateDataSetMapping(regionSpawnPointsDa, "spawn_points"); 299 CreateDataSetMapping(regionSpawnPointsDa, "spawn_points");
282 } 300 }
283 } 301 }
284 catch (Exception e) 302 catch (Exception e)
285 { 303 {
286 m_log.ErrorFormat("[SQLITE REGION DB]: ", e); 304 m_log.ErrorFormat("[SQLITE REGION DB]: {0} - {1}", e.Message, e.StackTrace);
287 Environment.Exit(23); 305 Environment.Exit(23);
288 } 306 }
289 return; 307 return;
@@ -341,6 +359,11 @@ namespace OpenSim.Data.SQLite
341 regionWindlightDa.Dispose(); 359 regionWindlightDa.Dispose();
342 regionWindlightDa = null; 360 regionWindlightDa = null;
343 } 361 }
362 if (regionEnvironmentDa != null)
363 {
364 regionEnvironmentDa.Dispose();
365 regionEnvironmentDa = null;
366 }
344 if (regionSpawnPointsDa != null) 367 if (regionSpawnPointsDa != null)
345 { 368 {
346 regionSpawnPointsDa.Dispose(); 369 regionSpawnPointsDa.Dispose();
@@ -474,6 +497,63 @@ namespace OpenSim.Data.SQLite
474 } 497 }
475 } 498 }
476 499
500 #region Region Environment Settings
501 public string LoadRegionEnvironmentSettings(UUID regionUUID)
502 {
503 lock (ds)
504 {
505 DataTable environmentTable = ds.Tables["regionenvironment"];
506 DataRow row = environmentTable.Rows.Find(regionUUID.ToString());
507 if (row == null)
508 {
509 return String.Empty;
510 }
511
512 return (String)row["llsd_settings"];
513 }
514 }
515
516 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
517 {
518 lock (ds)
519 {
520 DataTable environmentTable = ds.Tables["regionenvironment"];
521 DataRow row = environmentTable.Rows.Find(regionUUID.ToString());
522
523 if (row == null)
524 {
525 row = environmentTable.NewRow();
526 row["region_id"] = regionUUID.ToString();
527 row["llsd_settings"] = settings;
528 environmentTable.Rows.Add(row);
529 }
530 else
531 {
532 row["llsd_settings"] = settings;
533 }
534
535 regionEnvironmentDa.Update(ds, "regionenvironment");
536 }
537 }
538
539 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
540 {
541 lock (ds)
542 {
543 DataTable environmentTable = ds.Tables["regionenvironment"];
544 DataRow row = environmentTable.Rows.Find(regionUUID.ToString());
545
546 if (row != null)
547 {
548 row.Delete();
549 }
550
551 regionEnvironmentDa.Update(ds, "regionenvironment");
552 }
553 }
554
555 #endregion
556
477 public RegionSettings LoadRegionSettings(UUID regionUUID) 557 public RegionSettings LoadRegionSettings(UUID regionUUID)
478 { 558 {
479 lock (ds) 559 lock (ds)
@@ -1430,6 +1510,17 @@ namespace OpenSim.Data.SQLite
1430 return regionwindlight; 1510 return regionwindlight;
1431 } 1511 }
1432 1512
1513 private static DataTable createRegionEnvironmentTable()
1514 {
1515 DataTable regionEnvironment = new DataTable("regionenvironment");
1516 createCol(regionEnvironment, "region_id", typeof(String));
1517 createCol(regionEnvironment, "llsd_settings", typeof(String));
1518
1519 regionEnvironment.PrimaryKey = new DataColumn[] { regionEnvironment.Columns["region_id"] };
1520
1521 return regionEnvironment;
1522 }
1523
1433 private static DataTable createRegionSpawnPointsTable() 1524 private static DataTable createRegionSpawnPointsTable()
1434 { 1525 {
1435 DataTable spawn_points = new DataTable("spawn_points"); 1526 DataTable spawn_points = new DataTable("spawn_points");
@@ -2691,6 +2782,14 @@ namespace OpenSim.Data.SQLite
2691 da.UpdateCommand.Connection = conn; 2782 da.UpdateCommand.Connection = conn;
2692 } 2783 }
2693 2784
2785 private void setupRegionEnvironmentCommands(SqliteDataAdapter da, SqliteConnection conn)
2786 {
2787 da.InsertCommand = createInsertCommand("regionenvironment", ds.Tables["regionenvironment"]);
2788 da.InsertCommand.Connection = conn;
2789 da.UpdateCommand = createUpdateCommand("regionenvironment", "region_id=:region_id", ds.Tables["regionenvironment"]);
2790 da.UpdateCommand.Connection = conn;
2791 }
2792
2694 private void setupRegionSpawnPointsCommands(SqliteDataAdapter da, SqliteConnection conn) 2793 private void setupRegionSpawnPointsCommands(SqliteDataAdapter da, SqliteConnection conn)
2695 { 2794 {
2696 da.InsertCommand = createInsertCommand("spawn_points", ds.Tables["spawn_points"]); 2795 da.InsertCommand = createInsertCommand("spawn_points", ds.Tables["spawn_points"]);