aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Capabilities/LLSDEnvironmentSettings.cs68
-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
-rw-r--r--OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs224
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEnvironmentModule.cs36
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs21
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs20
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationDataService.cs16
-rw-r--r--OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs35
-rw-r--r--bin/OpenSimDefaults.ini3
15 files changed, 703 insertions, 3 deletions
diff --git a/OpenSim/Capabilities/LLSDEnvironmentSettings.cs b/OpenSim/Capabilities/LLSDEnvironmentSettings.cs
new file mode 100644
index 0000000..39019af
--- /dev/null
+++ b/OpenSim/Capabilities/LLSDEnvironmentSettings.cs
@@ -0,0 +1,68 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31
32namespace OpenSim.Framework.Capabilities
33{
34 [OSDMap]
35 public class LLSDEnvironmentRequest
36 {
37 public UUID messageID;
38 public UUID regionID;
39 }
40
41 [OSDMap]
42 public class LLSDEnvironmentSetResponse
43 {
44 public UUID regionID;
45 public UUID messageID;
46 public Boolean success;
47 public String fail_reason;
48 }
49
50 public class EnvironmentSettings
51 {
52 /// <summary>
53 /// generates a empty llsd settings response for viewer
54 /// </summary>
55 /// <param name="messageID">the message UUID</param>
56 /// <param name="regionID">the region UUID</param>
57 public static string EmptySettings(UUID messageID, UUID regionID)
58 {
59 OSDArray arr = new OSDArray();
60 LLSDEnvironmentRequest msg = new LLSDEnvironmentRequest();
61 msg.messageID = messageID;
62 msg.regionID = regionID;
63 arr.Array.Add(msg);
64 return LLSDHelpers.SerialiseLLSDReply(arr);
65 }
66 }
67
68}
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"]);
diff --git a/OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs b/OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs
new file mode 100644
index 0000000..1526886
--- /dev/null
+++ b/OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs
@@ -0,0 +1,224 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Framework.Capabilities;
33using OpenSim.Framework.Servers.HttpServer;
34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes;
36using log4net;
37using Nini.Config;
38using Mono.Addins;
39
40using Caps = OpenSim.Framework.Capabilities.Caps;
41
42
43namespace OpenSim.Region.CoreModules.World.LightShare
44{
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EnvironmentModule")]
46
47 public class EnvironmentModule : INonSharedRegionModule, IEnvironmentModule
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private Scene m_scene = null;
52 private UUID regionID = UUID.Zero;
53 private static bool Enabled = false;
54
55 private static readonly string capsName = "EnvironmentSettings";
56 private static readonly string capsBase = "/CAPS/0020/";
57
58 private LLSDEnvironmentSetResponse setResponse = null;
59
60 #region INonSharedRegionModule
61 public void Initialise(IConfigSource source)
62 {
63 IConfig config = source.Configs["ClientStack.LindenCaps"];
64
65 if (null == config)
66 return;
67
68 if (config.GetString("Cap_EnvironmentSettings", String.Empty) != "localhost")
69 {
70 m_log.InfoFormat("[{0}]: Module is disabled.", Name);
71 return;
72 }
73
74 Enabled = true;
75
76 m_log.InfoFormat("[{0}]: Module is enabled.", Name);
77 }
78
79 public void Close()
80 {
81 }
82
83 public string Name
84 {
85 get { return "EnvironmentModule"; }
86 }
87
88 public Type ReplaceableInterface
89 {
90 get { return null; }
91 }
92
93 public void AddRegion(Scene scene)
94 {
95 if (!Enabled)
96 return;
97
98 scene.RegisterModuleInterface<IEnvironmentModule>(this);
99 m_scene = scene;
100 regionID = scene.RegionInfo.RegionID;
101 }
102
103 public void RegionLoaded(Scene scene)
104 {
105 if (!Enabled)
106 return;
107
108 setResponse = new LLSDEnvironmentSetResponse();
109 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
110 }
111
112 public void RemoveRegion(Scene scene)
113 {
114 if (Enabled)
115 return;
116
117 scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
118 m_scene = null;
119 }
120 #endregion
121
122 #region IEnvironmentModule
123 public void ResetEnvironmentSettings(UUID regionUUID)
124 {
125 if (!Enabled)
126 return;
127
128 m_scene.SimulationDataService.RemoveRegionEnvironmentSettings(regionUUID);
129 }
130 #endregion
131
132 #region Events
133 private void OnRegisterCaps(UUID agentID, Caps caps)
134 {
135// m_log.DebugFormat("[{0}]: Register capability for agentID {1} in region {2}",
136// Name, agentID, caps.RegionName);
137
138 string capsPath = capsBase + UUID.Random();
139
140 // Get handler
141 caps.RegisterHandler(
142 capsName,
143 new RestStreamHandler(
144 "GET",
145 capsPath,
146 (request, path, param, httpRequest, httpResponse)
147 => GetEnvironmentSettings(request, path, param, agentID, caps),
148 capsName,
149 agentID.ToString()));
150
151 // Set handler
152 caps.HttpListener.AddStreamHandler(
153 new RestStreamHandler(
154 "POST",
155 capsPath,
156 (request, path, param, httpRequest, httpResponse)
157 => SetEnvironmentSettings(request, path, param, agentID, caps),
158 capsName,
159 agentID.ToString()));
160 }
161 #endregion
162
163 private string GetEnvironmentSettings(string request, string path, string param,
164 UUID agentID, Caps caps)
165 {
166// m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}",
167// Name, agentID, caps.RegionName);
168
169 string env = String.Empty;
170
171 try
172 {
173 env = m_scene.SimulationDataService.LoadRegionEnvironmentSettings(regionID);
174 }
175 catch (Exception e)
176 {
177 m_log.ErrorFormat("[{0}]: Unable to load environment settings for region {1}, Exception: {2} - {3}",
178 Name, caps.RegionName, e.Message, e.StackTrace);
179 }
180
181 if (String.IsNullOrEmpty(env))
182 env = EnvironmentSettings.EmptySettings(UUID.Zero, regionID);
183
184 return env;
185 }
186
187 private string SetEnvironmentSettings(string request, string path, string param,
188 UUID agentID, Caps caps)
189 {
190
191// m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}",
192// Name, agentID, caps.RegionName);
193
194 setResponse.regionID = regionID;
195 setResponse.success = false;
196
197 if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false))
198 {
199 setResponse.fail_reason = "Insufficient estate permissions, settings has not been saved.";
200 return LLSDHelpers.SerialiseLLSDReply(setResponse);
201 }
202
203 try
204 {
205 m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request);
206 setResponse.success = true;
207
208 m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}",
209 Name, agentID, caps.RegionName);
210 }
211 catch (Exception e)
212 {
213 m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}",
214 Name, caps.RegionName, e.Message, e.StackTrace);
215
216 setResponse.success = false;
217 setResponse.fail_reason = String.Format("Environment Set for region {0} has failed, settings has not been saved.", caps.RegionName);
218 }
219
220 return LLSDHelpers.SerialiseLLSDReply(setResponse);
221 }
222 }
223}
224
diff --git a/OpenSim/Region/Framework/Interfaces/IEnvironmentModule.cs b/OpenSim/Region/Framework/Interfaces/IEnvironmentModule.cs
new file mode 100644
index 0000000..7a7b782
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IEnvironmentModule.cs
@@ -0,0 +1,36 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse;
29
30namespace OpenSim.Region.Framework.Interfaces
31{
32 public interface IEnvironmentModule
33 {
34 void ResetEnvironmentSettings(UUID regionUUID);
35 }
36}
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
index 5295a72..0fcafcc 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
@@ -95,5 +95,26 @@ namespace OpenSim.Region.Framework.Interfaces
95 RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID); 95 RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID);
96 void StoreRegionWindlightSettings(RegionLightShareData wl); 96 void StoreRegionWindlightSettings(RegionLightShareData wl);
97 void RemoveRegionWindlightSettings(UUID regionID); 97 void RemoveRegionWindlightSettings(UUID regionID);
98
99 /// <summary>
100 /// Load Environment settings from region storage
101 /// </summary>
102 /// <param name="regionUUID">the region UUID</param>
103 /// <returns>LLSD string for viewer</returns>
104 string LoadRegionEnvironmentSettings(UUID regionUUID);
105
106 /// <summary>
107 /// Store Environment settings into region storage
108 /// </summary>
109 /// <param name="regionUUID">the region UUID</param>
110 /// <param name="settings">LLSD string from viewer</param>
111 void StoreRegionEnvironmentSettings(UUID regionUUID, string settings);
112
113 /// <summary>
114 /// Delete Environment settings from region storage
115 /// </summary>
116 /// <param name="regionUUID">the region UUID</param>
117 void RemoveRegionEnvironmentSettings(UUID regionUUID);
118
98 } 119 }
99} 120}
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
index 615f377..e424976 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
@@ -107,6 +107,26 @@ namespace OpenSim.Region.Framework.Interfaces
107 void StoreRegionWindlightSettings(RegionLightShareData wl); 107 void StoreRegionWindlightSettings(RegionLightShareData wl);
108 void RemoveRegionWindlightSettings(UUID regionID); 108 void RemoveRegionWindlightSettings(UUID regionID);
109 109
110 /// <summary>
111 /// Load Environment settings from region storage
112 /// </summary>
113 /// <param name="regionUUID">the region UUID</param>
114 /// <returns>LLSD string for viewer</returns>
115 string LoadRegionEnvironmentSettings(UUID regionUUID);
116
117 /// <summary>
118 /// Store Environment settings into region storage
119 /// </summary>
120 /// <param name="regionUUID">the region UUID</param>
121 /// <param name="settings">LLSD string from viewer</param>
122 void StoreRegionEnvironmentSettings(UUID regionUUID, string settings);
123
124 /// <summary>
125 /// Delete Environment settings from region storage
126 /// </summary>
127 /// <param name="regionUUID">the region UUID</param>
128 void RemoveRegionEnvironmentSettings(UUID regionUUID);
129
110 void Shutdown(); 130 void Shutdown();
111 } 131 }
112} 132}
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs b/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
index ccef50b..c9cbbfa 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationDataService.cs
@@ -148,5 +148,21 @@ namespace OpenSim.Services.Connectors
148 { 148 {
149 m_database.RemoveRegionWindlightSettings(regionID); 149 m_database.RemoveRegionWindlightSettings(regionID);
150 } 150 }
151
152 public string LoadRegionEnvironmentSettings(UUID regionUUID)
153 {
154 return m_database.LoadRegionEnvironmentSettings(regionUUID);
155 }
156
157 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
158 {
159 m_database.StoreRegionEnvironmentSettings(regionUUID, settings);
160 }
161
162 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
163 {
164 m_database.RemoveRegionEnvironmentSettings(regionUUID);
165 }
166
151 } 167 }
152} 168}
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
index 579d41c..1845eb9 100644
--- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
@@ -112,6 +112,21 @@ namespace OpenSim.Data.Null
112 { 112 {
113 m_store.StoreRegionWindlightSettings(wl); 113 m_store.StoreRegionWindlightSettings(wl);
114 } 114 }
115
116 public string LoadRegionEnvironmentSettings(UUID regionUUID)
117 {
118 return m_store.LoadRegionEnvironmentSettings(regionUUID);
119 }
120
121 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
122 {
123 m_store.StoreRegionEnvironmentSettings(regionUUID, settings);
124 }
125
126 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
127 {
128 m_store.RemoveRegionEnvironmentSettings(regionUUID);
129 }
115 } 130 }
116 131
117 /// <summary> 132 /// <summary>
@@ -158,7 +173,25 @@ namespace OpenSim.Data.Null
158 { 173 {
159 //This connector doesn't support the windlight module yet 174 //This connector doesn't support the windlight module yet
160 } 175 }
161 176
177 #region Environment Settings
178 public string LoadRegionEnvironmentSettings(UUID regionUUID)
179 {
180 //This connector doesn't support the Environment module yet
181 return string.Empty;
182 }
183
184 public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
185 {
186 //This connector doesn't support the Environment module yet
187 }
188
189 public void RemoveRegionEnvironmentSettings(UUID regionUUID)
190 {
191 //This connector doesn't support the Environment module yet
192 }
193 #endregion
194
162 public RegionSettings LoadRegionSettings(UUID regionUUID) 195 public RegionSettings LoadRegionSettings(UUID regionUUID)
163 { 196 {
164 RegionSettings rs = null; 197 RegionSettings rs = null;
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini
index 7962ef8..5da3ba2 100644
--- a/bin/OpenSimDefaults.ini
+++ b/bin/OpenSimDefaults.ini
@@ -534,7 +534,7 @@
534 ; silly vanity "Facelights" dead. Sorry, head mounted miner's lamps 534 ; silly vanity "Facelights" dead. Sorry, head mounted miner's lamps
535 ; will also be affected. 535 ; will also be affected.
536 ; 536 ;
537 ;DisableFacelights = "false(1815) 537 ;DisableFacelights = false
538 538
539[ClientStack.LindenCaps] 539[ClientStack.LindenCaps]
540 ;; Long list of capabilities taken from 540 ;; Long list of capabilities taken from
@@ -549,6 +549,7 @@
549 Cap_CopyInventoryFromNotecard = "localhost" 549 Cap_CopyInventoryFromNotecard = "localhost"
550 Cap_DispatchRegionInfo = "" 550 Cap_DispatchRegionInfo = ""
551 Cap_EstateChangeInfo = "" 551 Cap_EstateChangeInfo = ""
552 Cap_EnvironmentSettings = "localhost"
552 Cap_EventQueueGet = "localhost" 553 Cap_EventQueueGet = "localhost"
553 Cap_FetchInventory = "" 554 Cap_FetchInventory = ""
554 Cap_ObjectMedia = "localhost" 555 Cap_ObjectMedia = "localhost"