From 8eeb3f2fd21c05f0bfd141e333f34c4c69e8865b Mon Sep 17 00:00:00 2001 From: randomhuman Date: Fri, 13 Aug 2010 16:08:43 +0100 Subject: Updated the create_region command in the RemoteAdmin plugin to properly support estates without seeking further input on the console. --- .../LoadRegions/LoadRegionsPlugin.cs | 2 + .../RemoteController/RemoteAdminPlugin.cs | 92 +++++++++++++++------- OpenSim/Region/Application/OpenSim.cs | 10 ++- OpenSim/Region/Application/OpenSimBase.cs | 54 +++++++++++++ .../Region/ClientStack/RegionApplicationBase.cs | 5 ++ OpenSim/Region/Framework/Scenes/Scene.cs | 39 --------- 6 files changed, 134 insertions(+), 68 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 1e85a22..b16f46c 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -122,7 +122,9 @@ namespace OpenSim.ApplicationPlugins.LoadRegions m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() + ")"); + m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]); m_openSim.CreateRegion(regionsToLoad[i], true, out scene); + regionsToLoad[i].EstateSettings.Save(); if (scene != null) { m_newRegionCreatedHandler = OnNewRegionCreated; diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 7e4a8e8..da3d3c2 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -444,12 +444,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController /// desired region X coordinate (integer) /// region_y /// desired region Y coordinate (integer) - /// region_master_first - /// firstname of region master - /// region_master_last - /// lastname of region master - /// region_master_uuid - /// explicit UUID to use for master avatar (optional) + /// estate_owner_first + /// firstname of estate owner (formerly region master) + /// (required if new estate is being created, optional otherwise) + /// estate_owner_last + /// lastname of estate owner (formerly region master) + /// (required if new estate is being created, optional otherwise) + /// estate_owner_uuid + /// explicit UUID to use for estate owner (optional) /// listen_ip /// internal IP address (dotted quad) /// listen_port @@ -465,6 +467,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController /// enable_voice /// if true, enable voice on all parcels, /// ('true' or 'false') (optional, default: false) + /// estate_name + /// the name of the estate to join (or to create if it doesn't + /// already exist) /// /// /// XmlRpcCreateRegionMethod returns @@ -503,9 +508,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController { "password", "region_name", - "region_master_first", "region_master_last", - "region_master_password", - "listen_ip", "external_address" + "listen_ip", "external_address", + "estate_name" }); CheckIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"}); @@ -576,18 +580,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController region.ExternalHostName = (string) requestData["external_address"]; - string masterFirst = (string) requestData["region_master_first"]; - string masterLast = (string) requestData["region_master_last"]; - string masterPassword = (string) requestData["region_master_password"]; - - UUID userID = UUID.Zero; - if (requestData.ContainsKey("region_master_uuid")) - { - // ok, client wants us to use an explicit UUID - // regardless of what the avatar name provided - userID = new UUID((string) requestData["estate_owner_uuid"]); - } - bool persist = Convert.ToBoolean((string) requestData["persist"]); if (persist) { @@ -622,7 +614,55 @@ namespace OpenSim.ApplicationPlugins.RemoteController { region.Persistent = false; } - + + // Set the estate + + // Check for an existing estate + List estateIDs = m_application.StorageManager.EstateDataStore.GetEstates((string) requestData["estate_name"]); + if (estateIDs.Count < 1) + { + UUID userID = UUID.Zero; + if (requestData.ContainsKey("estate_owner_uuid")) + { + // ok, client wants us to use an explicit UUID + // regardless of what the avatar name provided + userID = new UUID((string) requestData["estate_owner_uuid"]); + } + else if (requestData.ContainsKey("estate_owner_first") & requestData.ContainsKey("estate_owner_last")) + { + // We need to look up the UUID for the avatar with the provided name. + string ownerFirst = (string) requestData["estate_owner_first"]; + string ownerLast = (string) requestData["estate_owner_last"]; + + Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene; + IUserAccountService accountService = currentOrFirst.UserAccountService; + UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID, + ownerFirst, ownerLast); + userID = user.PrincipalID; + } + else + { + throw new Exception("Estate owner details not provided."); + } + + // Create a new estate with the name provided + region.EstateSettings = m_application.StorageManager.EstateDataStore.LoadEstateSettings(region.RegionID, true); + + 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(); + } + else + { + int estateID = estateIDs[0]; + + region.EstateSettings = m_application.StorageManager.EstateDataStore.LoadEstateSettings(estateID); + + if (!m_application.StorageManager.EstateDataStore.LinkRegion(region.RegionID, estateID)) + throw new Exception("Failed to join estate."); + } + // Create the region and perform any initial initialization IScene newScene; @@ -631,9 +671,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.EstateOwner = userID; - if (persist) - newScene.RegionInfo.EstateSettings.Save(); + newScene.RegionInfo.EstateSettings.Save(); // enable voice on newly created region if // requested by either the XmlRpc request or the @@ -1497,7 +1535,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController if (destinationFolder.Type != (short)AssetType.Clothing) { destinationFolder = new InventoryFolderBase(); - + destinationFolder.ID = UUID.Random(); destinationFolder.Name = "Clothing"; destinationFolder.Owner = destination; @@ -2982,7 +3020,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController /// private bool ChangeUserPassword(string firstName, string lastName, string password) { - Scene scene = m_application.SceneManager.CurrentOrFirstScene; + Scene scene = m_application.SceneManager.CurrentOrFirstScene; IUserAccountService userAccountService = scene.UserAccountService; IAuthenticationService authenticationService = scene.AuthenticationService; diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index c541249..d9ec287 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -530,7 +530,10 @@ namespace OpenSim regionFile = cmd[3]; IScene scene; - CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true, out scene); + RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source); + PopulateRegionEstateInfo(regInfo); + CreateRegion(regInfo, true, out scene); + regInfo.EstateSettings.Save(); } else if (cmd[3].EndsWith(".ini")) { @@ -541,7 +544,10 @@ namespace OpenSim regionFile = cmd[3]; IScene scene; - CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]), true, out scene); + RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]); + PopulateRegionEstateInfo(regInfo); + CreateRegion(regInfo, true, out scene); + regInfo.EstateSettings.Save(); } else { diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index e148cde..eb18e83 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -790,6 +790,60 @@ namespace OpenSim { regionnum = m_sceneManager.Scenes.Count; } + + /// + /// Load the estate information for the provided RegionInfo object. + /// + /// + /// A + /// + public void PopulateRegionEstateInfo(RegionInfo regInfo) + { + if (m_storageManager.EstateDataStore != null) + { + regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(regInfo.RegionID, false); + } + + if (regInfo.EstateSettings.EstateID == 0) // No record at all + { + MainConsole.Instance.Output("Your region is not part of an estate."); + while (true) + { + string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List() {"yes", "no"}); + if (response == "no") + { + // Create a new estate + regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(regInfo.RegionID, true); + + regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); + //regInfo.EstateSettings.Save(); + break; + } + else + { + response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); + if (response == "None") + continue; + + List estateIDs = m_storageManager.EstateDataStore.GetEstates(response); + if (estateIDs.Count < 1) + { + MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); + continue; + } + + int estateID = estateIDs[0]; + + regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); + + if (m_storageManager.EstateDataStore.LinkRegion(regInfo.RegionID, estateID)) + break; + + MainConsole.Instance.Output("Joining the estate failed. Please try again."); + } + } + } + } } diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index e683821..46b68ec 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -58,6 +58,11 @@ namespace OpenSim.Region.ClientStack protected StorageManager m_storageManager; + public StorageManager StorageManager + { + get { return m_storageManager; } + } + protected ClientStackManager m_clientStackManager; public SceneManager SceneManager diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f62851a..18705a8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -544,45 +544,6 @@ namespace OpenSim.Region.Framework.Scenes if (m_storageManager.EstateDataStore != null) { m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); - if (m_regInfo.EstateSettings.EstateID == 0) // No record at all - { - MainConsole.Instance.Output("Your region is not part of an estate."); - while (true) - { - string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List() {"yes", "no"}); - if (response == "no") - { - // Create a new estate - m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); - - m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName); - m_regInfo.EstateSettings.Save(); - break; - } - else - { - response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); - if (response == "None") - continue; - - List estateIDs = m_storageManager.EstateDataStore.GetEstates(response); - if (estateIDs.Count < 1) - { - MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); - continue; - } - - int estateID = estateIDs[0]; - - m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); - - if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) - break; - - MainConsole.Instance.Output("Joining the estate failed. Please try again."); - } - } - } } #endregion Region Settings -- cgit v1.1