diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 86 |
1 files changed, 63 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 6861272..597f2eb 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 | |||
55 | public int DebugLevel { get; set; } | 55 | public int DebugLevel { get; set; } |
56 | 56 | ||
57 | private Scene m_scene; | 57 | private Scene m_scene; |
58 | private IRegionConsole m_regionConsole; | ||
58 | private IInventoryAccessModule m_invAccessModule; | 59 | private IInventoryAccessModule m_invAccessModule; |
59 | 60 | ||
60 | /// <summary> | 61 | /// <summary> |
@@ -88,8 +89,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
88 | // disabled. Registering only when enabled allows for other attachments module implementations. | 89 | // disabled. Registering only when enabled allows for other attachments module implementations. |
89 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | 90 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); |
90 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 91 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
91 | m_scene.EventManager.OnStartScript += (localID, itemID) => HandleScriptStateChange(localID, true); | 92 | m_scene.EventManager.OnStartScript += (localID, itemID) => OnScriptStateChange(localID, true); |
92 | m_scene.EventManager.OnStopScript += (localID, itemID) => HandleScriptStateChange(localID, false); | 93 | m_scene.EventManager.OnStopScript += (localID, itemID) => OnScriptStateChange(localID, false); |
93 | 94 | ||
94 | MainConsole.Instance.Commands.AddCommand( | 95 | MainConsole.Instance.Commands.AddCommand( |
95 | "Debug", | 96 | "Debug", |
@@ -113,6 +114,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
113 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI | 114 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI |
114 | } | 115 | } |
115 | 116 | ||
117 | public void RemoveRegion(Scene scene) | ||
118 | { | ||
119 | m_scene.UnregisterModuleInterface<IAttachmentsModule>(this); | ||
120 | |||
121 | if (Enabled) | ||
122 | m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; | ||
123 | } | ||
124 | |||
125 | public void RegionLoaded(Scene scene) | ||
126 | { | ||
127 | if (!Enabled) | ||
128 | return; | ||
129 | |||
130 | m_invAccessModule = m_scene.RequestModuleInterface<IInventoryAccessModule>(); | ||
131 | m_regionConsole = scene.RequestModuleInterface<IRegionConsole>(); | ||
132 | if (m_regionConsole != null) | ||
133 | { | ||
134 | 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); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | public void Close() | ||
139 | { | ||
140 | if (!Enabled) | ||
141 | return; | ||
142 | RemoveRegion(m_scene); | ||
143 | } | ||
144 | |||
116 | private void HandleDebugAttachmentsLog(string module, string[] args) | 145 | private void HandleDebugAttachmentsLog(string module, string[] args) |
117 | { | 146 | { |
118 | int debugLevel; | 147 | int debugLevel; |
@@ -135,12 +164,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
135 | MainConsole.Instance.OutputFormat("Debug logging level: {0}", DebugLevel); | 164 | MainConsole.Instance.OutputFormat("Debug logging level: {0}", DebugLevel); |
136 | } | 165 | } |
137 | 166 | ||
167 | private void SendConsoleOutput(UUID agentID, string text) | ||
168 | { | ||
169 | if (m_regionConsole == null) | ||
170 | return; | ||
171 | |||
172 | m_regionConsole.SendConsoleOutput(agentID, text); | ||
173 | } | ||
174 | |||
175 | private void HandleSetAutoGrantAttachPerms(string module, string[] parms) | ||
176 | { | ||
177 | UUID agentID = new UUID(parms[parms.Length - 1]); | ||
178 | Array.Resize(ref parms, parms.Length - 1); | ||
179 | |||
180 | if (parms.Length != 3) | ||
181 | { | ||
182 | SendConsoleOutput(agentID, "Command parameter error"); | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | string val = parms[2]; | ||
187 | if (val != "true" && val != "false") | ||
188 | { | ||
189 | SendConsoleOutput(agentID, "Command parameter error"); | ||
190 | return; | ||
191 | } | ||
192 | |||
193 | m_scene.StoreExtraSetting("auto_grant_attach_perms", val); | ||
194 | |||
195 | SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val)); | ||
196 | } | ||
197 | |||
138 | /// <summary> | 198 | /// <summary> |
139 | /// Listen for client triggered running state changes so that we can persist the script's object if necessary. | 199 | /// Listen for client triggered running state changes so that we can persist the script's object if necessary. |
140 | /// </summary> | 200 | /// </summary> |
141 | /// <param name='localID'></param> | 201 | /// <param name='localID'></param> |
142 | /// <param name='itemID'></param> | 202 | /// <param name='itemID'></param> |
143 | private void HandleScriptStateChange(uint localID, bool started) | 203 | private void OnScriptStateChange(uint localID, bool started) |
144 | { | 204 | { |
145 | SceneObjectGroup sog = m_scene.GetGroupByPrim(localID); | 205 | SceneObjectGroup sog = m_scene.GetGroupByPrim(localID); |
146 | if (sog != null && sog.IsAttachment) | 206 | if (sog != null && sog.IsAttachment) |
@@ -161,26 +221,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
161 | } | 221 | } |
162 | } | 222 | } |
163 | 223 | ||
164 | public void RemoveRegion(Scene scene) | ||
165 | { | ||
166 | m_scene.UnregisterModuleInterface<IAttachmentsModule>(this); | ||
167 | |||
168 | if (Enabled) | ||
169 | m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; | ||
170 | } | ||
171 | |||
172 | public void RegionLoaded(Scene scene) | ||
173 | { | ||
174 | m_invAccessModule = m_scene.RequestModuleInterface<IInventoryAccessModule>(); | ||
175 | if (!Enabled) | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | public void Close() | ||
180 | { | ||
181 | RemoveRegion(m_scene); | ||
182 | } | ||
183 | |||
184 | #endregion | 224 | #endregion |
185 | 225 | ||
186 | #region IAttachmentsModule | 226 | #region IAttachmentsModule |