diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 1d63d2611e..34554114af 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -39,6 +39,7 @@ using OpenSim.Region.CoreModules.Avatar.InstantMessage; using OpenSim.Region.CoreModules.Scripting.DynamicTexture; using OpenSim.Region.CoreModules.Scripting.LoadImageURL; using OpenSim.Region.CoreModules.Scripting.XMLRPC; +using OpenSim.Services.Interfaces; namespace OpenSim.ApplicationPlugins.LoadRegions { @@ -130,7 +131,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions createdScenes.Add(scene); if (changed) - regionsToLoad[i].EstateSettings.Save(); + m_openSim.EstateDataService.StoreEstateSettings(regionsToLoad[i].EstateSettings); } foreach (IScene scene in createdScenes) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index e0112324b5..44da48aa65 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -694,7 +694,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController region.EstateSettings.EstateName = (string) requestData["estate_name"]; region.EstateSettings.EstateOwner = userID; // Persistence does not seem to effect the need to save a new estate - region.EstateSettings.Save(); + m_application.EstateDataService.StoreEstateSettings(region.EstateSettings); if (!m_application.EstateDataService.LinkRegion(region.RegionID, (int) region.EstateSettings.EstateID)) throw new Exception("Failed to join estate."); @@ -724,7 +724,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController // If an access specification was provided, use it. // Otherwise accept the default. newScene.RegionInfo.EstateSettings.PublicAccess = GetBoolean(requestData, "public", m_publicAccess); - newScene.RegionInfo.EstateSettings.Save(); + m_application.EstateDataService.StoreEstateSettings(newScene.RegionInfo.EstateSettings); // enable voice on newly created region if // requested by either the XmlRpc request or the @@ -910,7 +910,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController scene.RegionInfo.EstateSettings.PublicAccess = GetBoolean(requestData,"public", scene.RegionInfo.EstateSettings.PublicAccess); if (scene.RegionInfo.Persistent) - scene.RegionInfo.EstateSettings.Save(); + m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings); if (requestData.ContainsKey("enable_voice")) { @@ -1792,7 +1792,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{}; if (scene.RegionInfo.Persistent) - scene.RegionInfo.EstateSettings.Save(); + m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings); m_log.Info("[RADMIN]: Access List Clear Request complete"); } @@ -1838,7 +1838,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController } scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray(); if (scene.RegionInfo.Persistent) - scene.RegionInfo.EstateSettings.Save(); + m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings); } responseData["added"] = addedUsers; @@ -1887,7 +1887,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController } scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray(); if (scene.RegionInfo.Persistent) - scene.RegionInfo.EstateSettings.Save(); + m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings); } responseData["removed"] = removedUsers; diff --git a/OpenSim/Framework/EstateBan.cs b/OpenSim/Framework/EstateBan.cs index de9ebf65ae..ebed794619 100644 --- a/OpenSim/Framework/EstateBan.cs +++ b/OpenSim/Framework/EstateBan.cs @@ -25,6 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; +using System.Collections.Generic; +using System.Reflection; + using OpenMetaverse; namespace OpenSim.Framework @@ -111,5 +115,50 @@ namespace OpenSim.Framework } } + public EstateBan() { } + + public Dictionary ToMap() + { + Dictionary map = new Dictionary(); + PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); + foreach (PropertyInfo p in properties) + map[p.Name] = p.GetValue(this, null); + + return map; + } + + public EstateBan(Dictionary map) + { + foreach (KeyValuePair kvp in map) + { + PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance); + if (p == null) + continue; + object value = p.GetValue(this, null); + if (value is String) + p.SetValue(this, map[p.Name], null); + else if (value is UInt32) + p.SetValue(this, UInt32.Parse((string)map[p.Name]), null); + else if (value is Boolean) + p.SetValue(this, Boolean.Parse((string)map[p.Name]), null); + else if (value is UUID) + p.SetValue(this, UUID.Parse((string)map[p.Name]), null); + } + } + + + /// + /// For debugging + /// + /// + public override string ToString() + { + Dictionary map = ToMap(); + string result = string.Empty; + foreach (KeyValuePair kvp in map) + result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value, Environment.NewLine); + + return result; + } } } diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index dd3e195ff2..328fca4477 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -418,17 +418,106 @@ namespace OpenSim.Framework Dictionary map = new Dictionary(); PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo p in properties) - map[p.Name] = p.GetValue(this, null); + { + // EstateBans is a complex type, let's treat it as special + if (p.Name == "EstateBans") + continue; + object value = p.GetValue(this, null); + if (value != null) + { + if (p.PropertyType.IsArray) // of UUIDs + { + if (((Array)value).Length > 0) + { + string[] args = new string[((Array)value).Length]; + int index = 0; + foreach (object o in (Array)value) + args[index++] = o.ToString(); + map[p.Name] = String.Join(",", args); + } + } + else // simple types + map[p.Name] = value; + } + } + + // EstateBans are special + Dictionary bans = new Dictionary(); + int i = 0; + foreach (EstateBan ban in EstateBans) + bans["ban" + i++] = ban.ToMap(); + map["EstateBans"] = bans; return map; } + /// + /// For debugging + /// + /// + public override string ToString() + { + Dictionary map = ToMap(); + String result = String.Empty; + + foreach (KeyValuePair kvp in map) + { + if (kvp.Key == "EstateBans") + { + result += "EstateBans:" + Environment.NewLine; + foreach (KeyValuePair ban in (Dictionary)kvp.Value) + result += ban.Value.ToString(); + } + else + result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value.ToString(), Environment.NewLine); + } + + return result; + } + public EstateSettings(Dictionary map) { - PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); - foreach (PropertyInfo p in properties) - p.SetValue(this, map[p.Name], null); + foreach (KeyValuePair kvp in map) + { + PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance); + if (p == null) + continue; + // EstateBans is a complex type, let's treat it as special + if (p.Name == "EstateBans") + continue; + + if (p.PropertyType.IsArray) + { + string[] elements = ((string)map[p.Name]).Split(new char[] { ',' }); + UUID[] uuids = new UUID[elements.Length]; + int i = 0; + foreach (string e in elements) + uuids[i++] = new UUID(e); + p.SetValue(this, uuids, null); + } + else + { + object value = p.GetValue(this, null); + if (value is String) + p.SetValue(this, map[p.Name], null); + else if (value is UInt32) + p.SetValue(this, UInt32.Parse((string)map[p.Name]), null); + else if (value is Boolean) + p.SetValue(this, Boolean.Parse((string)map[p.Name]), null); + else if (value is UUID) + p.SetValue(this, UUID.Parse((string)map[p.Name]), null); + } + } + + // EstateBans are special + var banData = ((Dictionary)map["EstateBans"]).Values; + EstateBan[] bans = new EstateBan[banData.Count]; + int b = 0; + foreach (Dictionary ban in banData) + bans[b++] = new EstateBan(ban); + PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); + bansProperty.SetValue(this, bans, null); } } } diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 59b461439f..9e4671fae8 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -730,7 +730,7 @@ namespace OpenSim CreateRegion(regInfo, true, out scene); if (changed) - regInfo.EstateSettings.Save(); + m_estateDataService.StoreEstateSettings(regInfo.EstateSettings); } /// diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index feb3cf880a..4c1914ae90 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -232,13 +232,9 @@ namespace OpenSim module)); // Load the estate data service - IConfig estateDataConfig = Config.Configs["EstateDataStore"]; - if (estateDataConfig == null) - throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); - - module = estateDataConfig.GetString("LocalServiceModule", String.Empty); + module = Util.GetConfigVarFromSections(Config, "LocalServiceModule", new string[]{"EstateDataStore", "EstateService"}, String.Empty); if (String.IsNullOrEmpty(module)) - throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section"); + throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section"); m_estateDataService = ServerUtils.LoadPlugin(module, new object[] { Config }); if (m_estateDataService == null) @@ -555,7 +551,7 @@ namespace OpenSim else { regionInfo.EstateSettings.EstateOwner = account.PrincipalID; - regionInfo.EstateSettings.Save(); + m_estateDataService.StoreEstateSettings(regionInfo.EstateSettings); } } @@ -950,7 +946,7 @@ namespace OpenSim // back to the default. The reloading of estate settings by scene could be eliminated if it // knows that the passed in settings in RegionInfo are already valid. Also, it might be // possible to eliminate some additional later saves made by callers of this method. - regInfo.EstateSettings.Save(); + EstateDataService.StoreEstateSettings(regInfo.EstateSettings); return true; } diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index eecc4783cf..9fac9ff39d 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.World.Estate else { dbSettings.EstateOwner = account.PrincipalID; - dbSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(dbSettings); response = String.Empty; // make sure there's a log entry to document the change @@ -292,7 +292,7 @@ namespace OpenSim.Region.CoreModules.World.Estate { string oldName = dbSettings.EstateName; dbSettings.EstateName = newName; - dbSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(dbSettings); response = String.Empty; // make sure there's a log entry to document the change @@ -367,10 +367,15 @@ namespace OpenSim.Region.CoreModules.World.Estate else { EstateSettings settings = Scene.EstateDataService.CreateNewEstate(); - settings.EstateOwner = ownerID; - settings.EstateName = estateName; - settings.Save(); - response = String.Empty; + if (settings == null) + response = String.Format("Unable to create estate \"{0}\" at this simulator", estateName); + else + { + settings.EstateOwner = ownerID; + settings.EstateName = estateName; + Scene.EstateDataService.StoreEstateSettings(settings); + response = String.Empty; + } } } return response; @@ -636,13 +641,13 @@ namespace OpenSim.Region.CoreModules.World.Estate { estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); estateSettings.AddEstateUser(user); - estateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(estateSettings); } } } Scene.RegionInfo.EstateSettings.AddEstateUser(user); - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); @@ -669,13 +674,13 @@ namespace OpenSim.Region.CoreModules.World.Estate { estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); estateSettings.RemoveEstateUser(user); - estateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(estateSettings); } } } Scene.RegionInfo.EstateSettings.RemoveEstateUser(user); - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID); @@ -701,13 +706,13 @@ namespace OpenSim.Region.CoreModules.World.Estate { estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); estateSettings.AddEstateGroup(user); - estateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(estateSettings); } } } Scene.RegionInfo.EstateSettings.AddEstateGroup(user); - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID); @@ -733,13 +738,13 @@ namespace OpenSim.Region.CoreModules.World.Estate { estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); estateSettings.RemoveEstateGroup(user); - estateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(estateSettings); } } } Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user); - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID); @@ -788,7 +793,7 @@ namespace OpenSim.Region.CoreModules.World.Estate estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); estateSettings.AddBan(bitem); - estateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(estateSettings); } } } @@ -801,7 +806,7 @@ namespace OpenSim.Region.CoreModules.World.Estate item.BannedHostIPMask = "0.0.0.0"; Scene.RegionInfo.EstateSettings.AddBan(item); - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); @@ -864,13 +869,13 @@ namespace OpenSim.Region.CoreModules.World.Estate { estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); estateSettings.RemoveBan(user); - estateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(estateSettings); } } } Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID); - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); } @@ -903,13 +908,13 @@ namespace OpenSim.Region.CoreModules.World.Estate { estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); estateSettings.AddEstateManager(user); - estateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(estateSettings); } } } Scene.RegionInfo.EstateSettings.AddEstateManager(user); - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID); @@ -935,13 +940,13 @@ namespace OpenSim.Region.CoreModules.World.Estate { estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID); estateSettings.RemoveEstateManager(user); - estateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(estateSettings); } } } Scene.RegionInfo.EstateSettings.RemoveEstateManager(user); - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID); @@ -1415,7 +1420,7 @@ namespace OpenSim.Region.CoreModules.World.Estate else Scene.RegionInfo.EstateSettings.DenyMinors = false; - Scene.RegionInfo.EstateSettings.Save(); + Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings); TriggerEstateInfoChange(); Scene.TriggerEstateSunUpdate(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index de2c3f7fef..4a24980df1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1246,7 +1246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; World.RegionInfo.EstateSettings.SunPosition = sunHour; World.RegionInfo.EstateSettings.FixedSun = sunFixed; - World.RegionInfo.EstateSettings.Save(); + World.EstateDataService.StoreEstateSettings(World.RegionInfo.EstateSettings); World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle); } diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs index 684a0db9de..8fc766d9e0 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs @@ -425,7 +425,7 @@ namespace OpenSim.Services.Connectors.SimianGrid estate.EstateID, admin.Name); estate.EstateOwner = admin.PrincipalID; - estate.Save(); + scene.EstateDataService.StoreEstateSettings(estate); } else { diff --git a/prebuild.xml b/prebuild.xml index 5f936e8450..0143e26884 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1835,6 +1835,7 @@ +