diff options
author | BlueWall | 2012-01-13 11:35:44 -0500 |
---|---|---|
committer | BlueWall | 2012-01-13 11:35:44 -0500 |
commit | 57ba9ef5ad05d2479a5bfb188d8a2827e63f0f0f (patch) | |
tree | 9388e3f00b2b92a20142d7025db988bc1ad3e5cf | |
parent | Undo some prior work (diff) | |
download | opensim-SC-57ba9ef5ad05d2479a5bfb188d8a2827e63f0f0f.zip opensim-SC-57ba9ef5ad05d2479a5bfb188d8a2827e63f0f0f.tar.gz opensim-SC-57ba9ef5ad05d2479a5bfb188d8a2827e63f0f0f.tar.bz2 opensim-SC-57ba9ef5ad05d2479a5bfb188d8a2827e63f0f0f.tar.xz |
Update RegionReadyModule
Fix triggering of alerts when rezzing first script to an empty region, add login disable when loading oars.
3 files changed, 98 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 0707cbe..a945fc2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | |||
@@ -98,6 +98,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
98 | 98 | ||
99 | OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); | 99 | OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); |
100 | options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; }); | 100 | options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; }); |
101 | |||
102 | // Send a message to the region ready module | ||
103 | IRegionReadyModule rready = m_scene.RequestModuleInterface<IRegionReadyModule>(); | ||
104 | |||
105 | if (rready != null) | ||
106 | { | ||
107 | rready.OarLoadingAlert("load"); | ||
108 | } | ||
101 | 109 | ||
102 | List<string> mainParams = options.Parse(cmdparams); | 110 | List<string> mainParams = options.Parse(cmdparams); |
103 | 111 | ||
@@ -125,7 +133,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
125 | Dictionary<string, object> options = new Dictionary<string, object>(); | 133 | Dictionary<string, object> options = new Dictionary<string, object>(); |
126 | 134 | ||
127 | OptionSet ops = new OptionSet(); | 135 | OptionSet ops = new OptionSet(); |
128 | 136 | ||
129 | // legacy argument [obsolete] | 137 | // legacy argument [obsolete] |
130 | ops.Add("p|profile=", delegate(string v) { Console.WriteLine("\n WARNING: -profile option is obsolete and it will not work. Use -home instead.\n"); }); | 138 | ops.Add("p|profile=", delegate(string v) { Console.WriteLine("\n WARNING: -profile option is obsolete and it will not work. Use -home instead.\n"); }); |
131 | // preferred | 139 | // preferred |
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs new file mode 100644 index 0000000..aa4a757 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | |||
29 | using System; | ||
30 | |||
31 | namespace OpenSim.Region.Framework.Interfaces | ||
32 | { | ||
33 | public interface IRegionReadyModule | ||
34 | { | ||
35 | void OarLoadingAlert(string msg); | ||
36 | } | ||
37 | } | ||
38 | |||
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 4c4f5fb..f5d4da8 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs | |||
@@ -44,12 +44,13 @@ using OpenSim.Region.Framework.Scenes; | |||
44 | 44 | ||
45 | namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | 45 | namespace OpenSim.Region.OptionalModules.Scripting.RegionReady |
46 | { | 46 | { |
47 | public class RegionReadyModule : INonSharedRegionModule | 47 | public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule |
48 | { | 48 | { |
49 | private static readonly ILog m_log = | 49 | private static readonly ILog m_log = |
50 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 51 | ||
52 | private IConfig m_config = null; | 52 | private IConfig m_config = null; |
53 | private bool m_ScriptRez; | ||
53 | private bool m_firstEmptyCompileQueue; | 54 | private bool m_firstEmptyCompileQueue; |
54 | private bool m_oarFileLoading; | 55 | private bool m_oarFileLoading; |
55 | private bool m_lastOarLoadedOk; | 56 | private bool m_lastOarLoadedOk; |
@@ -93,14 +94,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
93 | if (!m_enabled) | 94 | if (!m_enabled) |
94 | return; | 95 | return; |
95 | 96 | ||
97 | m_scene = scene; | ||
98 | |||
99 | m_scene.RegisterModuleInterface<IRegionReadyModule>(this); | ||
100 | |||
101 | m_ScriptRez = false; | ||
96 | m_firstEmptyCompileQueue = true; | 102 | m_firstEmptyCompileQueue = true; |
97 | m_oarFileLoading = false; | 103 | m_oarFileLoading = false; |
98 | m_lastOarLoadedOk = true; | 104 | m_lastOarLoadedOk = true; |
99 | 105 | ||
100 | m_scene = scene; | ||
101 | |||
102 | m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; | ||
103 | m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; | 106 | m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; |
107 | m_scene.EventManager.OnRezScript += OnRezScript; | ||
104 | m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; | 108 | m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; |
105 | 109 | ||
106 | m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); | 110 | m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); |
@@ -118,6 +122,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
118 | } | 122 | } |
119 | } | 123 | } |
120 | 124 | ||
125 | void OnRezScript (uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) | ||
126 | { | ||
127 | if (!m_ScriptRez) | ||
128 | { | ||
129 | m_ScriptRez = true; | ||
130 | m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; | ||
131 | m_scene.EventManager.OnRezScript -= OnRezScript; | ||
132 | } | ||
133 | } | ||
134 | |||
121 | public void RemoveRegion(Scene scene) | 135 | public void RemoveRegion(Scene scene) |
122 | { | 136 | { |
123 | if (!m_enabled) | 137 | if (!m_enabled) |
@@ -125,6 +139,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
125 | 139 | ||
126 | m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; | 140 | m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; |
127 | m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; | 141 | m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; |
142 | m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled; | ||
128 | 143 | ||
129 | if(m_uri != string.Empty) | 144 | if(m_uri != string.Empty) |
130 | { | 145 | { |
@@ -148,9 +163,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
148 | } | 163 | } |
149 | 164 | ||
150 | #endregion | 165 | #endregion |
151 | 166 | ||
167 | |||
152 | void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) | 168 | void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) |
153 | { | 169 | { |
170 | m_log.InfoFormat("[RegionReady]: Script compile queue empty!"); | ||
171 | |||
154 | if (m_firstEmptyCompileQueue || m_oarFileLoading) | 172 | if (m_firstEmptyCompileQueue || m_oarFileLoading) |
155 | { | 173 | { |
156 | OSChatMessage c = new OSChatMessage(); | 174 | OSChatMessage c = new OSChatMessage(); |
@@ -197,6 +215,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
197 | } | 215 | } |
198 | } | 216 | } |
199 | 217 | ||
218 | // This will be triggerd by Scene if we have no scripts | ||
219 | // m_ScriptsRezzing will be false if there were none | ||
220 | // else it will be true and we should wait on the | ||
221 | // empty compile queue | ||
200 | void OnLoginsEnabled(string regionName) | 222 | void OnLoginsEnabled(string regionName) |
201 | { | 223 | { |
202 | if (m_disable_logins == true) | 224 | if (m_disable_logins == true) |
@@ -205,7 +227,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
205 | { | 227 | { |
206 | m_scene.LoginsDisabled = false; | 228 | m_scene.LoginsDisabled = false; |
207 | m_scene.LoginLock = false; | 229 | m_scene.LoginLock = false; |
208 | m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName); | 230 | |
231 | m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; | ||
232 | |||
233 | m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", | ||
234 | m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); | ||
235 | |||
209 | if ( m_uri != string.Empty ) | 236 | if ( m_uri != string.Empty ) |
210 | { | 237 | { |
211 | RRAlert("enabled"); | 238 | RRAlert("enabled"); |
@@ -214,6 +241,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
214 | } | 241 | } |
215 | } | 242 | } |
216 | 243 | ||
244 | public void OarLoadingAlert(string msg) | ||
245 | { | ||
246 | if (msg == "load") | ||
247 | { | ||
248 | m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; | ||
249 | m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; | ||
250 | m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; | ||
251 | m_scene.EventManager.OnRezScript += OnRezScript; | ||
252 | m_oarFileLoading = true; | ||
253 | m_firstEmptyCompileQueue = true; | ||
254 | // Will need some controls around this | ||
255 | m_scene.LoginsDisabled = true; | ||
256 | m_scene.LoginLock = true; | ||
257 | RRAlert("loading oar"); | ||
258 | RRAlert("disabled"); | ||
259 | } | ||
260 | } | ||
261 | |||
217 | public void RRAlert(string status) | 262 | public void RRAlert(string status) |
218 | { | 263 | { |
219 | string request_method = "POST"; | 264 | string request_method = "POST"; |