From cba65b19358fc27adfe4dc4717f170897f4da4e8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 23 Oct 2018 11:02:16 +0100 Subject: [PATCH] recover the inword region console comand Set AutoGrantAttachPerms --- .../Avatar/Attachments/AttachmentsModule.cs | 86 ++++++++++++++----- 1 file changed, 63 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 6861272f99..597f2ebe10 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public int DebugLevel { get; set; } private Scene m_scene; + private IRegionConsole m_regionConsole; private IInventoryAccessModule m_invAccessModule; /// @@ -88,8 +89,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // disabled. Registering only when enabled allows for other attachments module implementations. m_scene.RegisterModuleInterface(this); m_scene.EventManager.OnNewClient += SubscribeToClientEvents; - m_scene.EventManager.OnStartScript += (localID, itemID) => HandleScriptStateChange(localID, true); - m_scene.EventManager.OnStopScript += (localID, itemID) => HandleScriptStateChange(localID, false); + m_scene.EventManager.OnStartScript += (localID, itemID) => OnScriptStateChange(localID, true); + m_scene.EventManager.OnStopScript += (localID, itemID) => OnScriptStateChange(localID, false); MainConsole.Instance.Commands.AddCommand( "Debug", @@ -113,6 +114,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI } + public void RemoveRegion(Scene scene) + { + m_scene.UnregisterModuleInterface(this); + + if (Enabled) + m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; + } + + public void RegionLoaded(Scene scene) + { + if (!Enabled) + return; + + m_invAccessModule = m_scene.RequestModuleInterface(); + m_regionConsole = scene.RequestModuleInterface(); + if (m_regionConsole != null) + { + m_regionConsole.AddCommand("AttachModule", false, "set auto_grant_attach_perms", "set auto_grant_attach_perms true|false", "Allow objects owned by the region owner or estate managers to obtain attach permissions without asking the user", HandleSetAutoGrantAttachPerms); + } + } + + public void Close() + { + if (!Enabled) + return; + RemoveRegion(m_scene); + } + private void HandleDebugAttachmentsLog(string module, string[] args) { int debugLevel; @@ -135,12 +164,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments MainConsole.Instance.OutputFormat("Debug logging level: {0}", DebugLevel); } + private void SendConsoleOutput(UUID agentID, string text) + { + if (m_regionConsole == null) + return; + + m_regionConsole.SendConsoleOutput(agentID, text); + } + + private void HandleSetAutoGrantAttachPerms(string module, string[] parms) + { + UUID agentID = new UUID(parms[parms.Length - 1]); + Array.Resize(ref parms, parms.Length - 1); + + if (parms.Length != 3) + { + SendConsoleOutput(agentID, "Command parameter error"); + return; + } + + string val = parms[2]; + if (val != "true" && val != "false") + { + SendConsoleOutput(agentID, "Command parameter error"); + return; + } + + m_scene.StoreExtraSetting("auto_grant_attach_perms", val); + + SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val)); + } + /// /// Listen for client triggered running state changes so that we can persist the script's object if necessary. /// /// /// - private void HandleScriptStateChange(uint localID, bool started) + private void OnScriptStateChange(uint localID, bool started) { SceneObjectGroup sog = m_scene.GetGroupByPrim(localID); if (sog != null && sog.IsAttachment) @@ -161,26 +221,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public void RemoveRegion(Scene scene) - { - m_scene.UnregisterModuleInterface(this); - - if (Enabled) - m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; - } - - public void RegionLoaded(Scene scene) - { - m_invAccessModule = m_scene.RequestModuleInterface(); - if (!Enabled) - return; - } - - public void Close() - { - RemoveRegion(m_scene); - } - #endregion #region IAttachmentsModule