diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index fc57386729..1c924c0200 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -86,6 +86,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_httpd = openSim.HttpServer; m_httpd.AddXmlRPCHandler("admin_create_region", XmlRpcCreateRegionMethod); + m_httpd.AddXmlRPCHandler("admin_delete_region", XmlRpcDeleteRegionMethod); m_httpd.AddXmlRPCHandler("admin_shutdown", XmlRpcShutdownMethod); m_httpd.AddXmlRPCHandler("admin_broadcast", XmlRpcAlertMethod); m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod); @@ -344,8 +345,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController /// internal port (integer) /// external_address /// external IP address - /// datastore - /// datastore parameter (?) /// persist /// if true, persist the region info /// ('true' or 'false') @@ -378,7 +377,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController "region_master_first", "region_master_last", "region_master_password", "listen_ip", "external_address"}); - checkIntegerParams(request, new string[] { "region_x", "region_y", "listen_port"}); + checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"}); // check password if (!String.IsNullOrEmpty(requiredPassword) && @@ -390,7 +389,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController if (requestData.ContainsKey("region_id") && !String.IsNullOrEmpty((string)requestData["region_id"])) { - regionID = (string) requestData["region_id"]; + regionID = (string)requestData["region_id"]; if (m_app.SceneManager.TryGetScene(regionID, out scene)) throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, @@ -492,6 +491,68 @@ namespace OpenSim.ApplicationPlugins.RemoteController return response; } + /// + /// Delete a new region. + /// + /// incoming XML RPC request + /// + /// XmlRpcCreateRegionMethod takes the following XMLRPC + /// parameters + /// + /// parameter namedescription + /// password + /// admin password as set in OpenSim.ini + /// region_name + /// desired region name + /// region_id + /// (optional) desired region UUID + /// + /// + /// XmlRpcCreateRegionMethod returns + /// + /// namedescription + /// success + /// true or false + /// error + /// error message if success is false + /// + /// + public XmlRpcResponse XmlRpcDeleteRegionMethod(XmlRpcRequest request) + { + m_log.Info("[RADMIN]: DeleteRegion: new request"); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + try { + Hashtable requestData = (Hashtable) request.Params[0]; + checkStringParameters(request, new string[] {"password", "region_name"}); + + Scene scene = null; + string regionName = (string)requestData["region_name"]; + if (!m_app.SceneManager.TryGetScene(regionName, out scene)) + throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); + + m_app.RemoveRegion(scene, true); + + responseData["success"] = "true"; + responseData["region_name"] = regionName; + + response.Value = responseData; + } + catch (Exception e) + { + m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0}", e.Message); + m_log.DebugFormat("[RADMIN] DeleteRegion: failed {0}", e.ToString()); + + responseData["success"] = "false"; + responseData["error"] = e.Message; + + response.Value = responseData; + } + + return response; + } + /// /// Create a new user account. /// diff --git a/OpenSim/Data/RegionProfileData.cs b/OpenSim/Data/RegionProfileData.cs index b4c7b3cca8..b30fcf5d16 100644 --- a/OpenSim/Data/RegionProfileData.cs +++ b/OpenSim/Data/RegionProfileData.cs @@ -30,7 +30,6 @@ using System.Collections; using OpenMetaverse; using Nwc.XmlRpc; using OpenSim.Framework; -using OpenMetaverse; namespace OpenSim.Data { diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 925c5beda2..5cbc776531 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -196,6 +196,7 @@ namespace OpenSim.Framework public bool commFailTF = false; public ConfigurationMember configMember; public string DataStore = String.Empty; + public string RegionFile = String.Empty; public bool isSandbox = false; private EstateSettings m_estateSettings; private RegionSettings m_regionSettings; @@ -221,6 +222,7 @@ namespace OpenSim.Framework configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig); configMember.performConfigurationRetrieve(); + RegionFile = filename; } public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig) @@ -364,6 +366,7 @@ namespace OpenSim.Framework configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe, ignoreIncomingConfiguration, false); configMember.performConfigurationRetrieve(); + RegionFile = filename; } public void loadConfigurationOptionsFromMe() diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index e48df8188a..9f313ebd9c 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -311,22 +311,23 @@ namespace OpenSim break; case "remove-region": - string regName = CombineParams(cmdparams, 0); + string regRemoveName = CombineParams(cmdparams, 0); + + Scene removeScene; + if (m_sceneManager.TryGetScene(regRemoveName, out removeScene)) + RemoveRegion(removeScene, false); + else + m_console.Error("no region with that name"); + break; + + case "delete-region": + string regDeleteName = CombineParams(cmdparams, 0); Scene killScene; - if (m_sceneManager.TryGetScene(regName, out killScene)) - { - // only need to check this if we are not at the - // root level - if ((m_sceneManager.CurrentScene != null) && - (m_sceneManager.CurrentScene.RegionInfo.RegionID == killScene.RegionInfo.RegionID)) - { - m_sceneManager.TrySetCurrentScene(".."); - } - - m_regionData.Remove(killScene.RegionInfo); - m_sceneManager.CloseScene(killScene); - } + if (m_sceneManager.TryGetScene(regDeleteName, out killScene)) + RemoveRegion(killScene, true); + else + m_console.Error("no region with that name"); break; case "restart": @@ -610,6 +611,7 @@ namespace OpenSim m_console.Notice("force-update - force an update of prims in the scene"); m_console.Notice("restart - disconnects all clients and restarts the sims in the instance."); m_console.Notice("remove-region [name] - remove a region"); + m_console.Notice("delete-region [name] - delete a region"); m_console.Notice("load-xml [filename] - load prims from XML (DEPRECATED)"); m_console.Notice("save-xml [filename] - save prims to XML (DEPRECATED)"); m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format"); diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 4a022644f8..e5cf07a98f 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -589,6 +589,37 @@ namespace OpenSim return clientServer; } + public void RemoveRegion(Scene scene, bool cleanup) + { + // only need to check this if we are not at the + // root level + if ((m_sceneManager.CurrentScene != null) && + (m_sceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID)) + { + m_sceneManager.TrySetCurrentScene(".."); + } + + scene.DeleteAllSceneObjects(); + m_regionData.Remove(scene.RegionInfo); + m_sceneManager.CloseScene(scene); + + if (!cleanup) + return; + + if (!String.IsNullOrEmpty(scene.RegionInfo.RegionFile)) + { + File.Delete(scene.RegionInfo.RegionFile); + m_log.InfoFormat("[OPENSIM MAIN] deleting region file \"{0}\"", scene.RegionInfo.RegionFile); + } + } + + public void RemoveRegion(string name, bool cleanUp) + { + Scene target; + if (m_sceneManager.TryGetScene(name, out target)) + RemoveRegion(target, cleanUp); + } + protected override StorageManager CreateStorageManager(string connectionstring, string estateconnectionstring) { return new StorageManager(m_storageDll, connectionstring, estateconnectionstring); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 8ee217958b..88f2928b81 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -624,7 +624,7 @@ namespace OpenSim.Region.Environment.Scenes // close the inner scene m_innerScene.Close(); // De-register with region communications (events cleanup) - UnRegisterReginWithComms(); + UnRegisterRegionWithComms(); // Shut down all non shared modules. foreach (IRegionModule module in Modules.Values) @@ -1775,10 +1775,9 @@ namespace OpenSim.Region.Environment.Scenes /// true if the object was in the scene, false if it was not public bool UnlinkSceneObject(UUID uuid, bool resultOfLinkingObjects) { - if (m_innerScene.DeleteSceneObject(uuid,resultOfLinkingObjects)) + if (m_innerScene.DeleteSceneObject(uuid, resultOfLinkingObjects)) { m_storageManager.DataStore.RemoveObject(uuid, m_regInfo.RegionID); - return true; } @@ -2568,7 +2567,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void UnRegisterReginWithComms() + public void UnRegisterRegionWithComms() { m_sceneGridService.KiPrimitive -= SendKiPrimitive; m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;