From 03f246d6fea009f1812019f5f036987b96b47a2b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 18 Sep 2008 15:44:05 +0000 Subject: adds support to delete a region completely and offers that functionality via the console command "delete-region" and also via RemoteAdminPlugin. minor typo fix. --- .../RemoteController/RemoteAdminPlugin.cs | 69 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) (limited to 'OpenSim/ApplicationPlugins') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index fc57386..1c924c0 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, @@ -493,6 +492,68 @@ namespace OpenSim.ApplicationPlugins.RemoteController } /// + /// 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. /// /// incoming XML RPC request -- cgit v1.1