diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting')
8 files changed, 135 insertions, 396 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index 311531c..e68764a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
59 | private Dictionary<UUID,JsonStore> m_JsonValueStore; | 59 | private Dictionary<UUID,JsonStore> m_JsonValueStore; |
60 | private UUID m_sharedStore; | 60 | private UUID m_sharedStore; |
61 | 61 | ||
62 | #region IRegionModule Members | 62 | #region Region Module interface |
63 | 63 | ||
64 | // ----------------------------------------------------------------- | 64 | // ----------------------------------------------------------------- |
65 | /// <summary> | 65 | /// <summary> |
@@ -175,14 +175,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
175 | /// | 175 | /// |
176 | /// </summary> | 176 | /// </summary> |
177 | // ----------------------------------------------------------------- | 177 | // ----------------------------------------------------------------- |
178 | public bool CreateStore(string value, out UUID result) | 178 | public bool CreateStore(string value, ref UUID result) |
179 | { | 179 | { |
180 | result = UUID.Zero; | 180 | if (result == UUID.Zero) |
181 | result = UUID.Random(); | ||
182 | |||
183 | JsonStore map = null; | ||
181 | 184 | ||
182 | if (! m_enabled) return false; | 185 | if (! m_enabled) return false; |
183 | 186 | ||
184 | UUID uuid = UUID.Random(); | ||
185 | JsonStore map = null; | ||
186 | 187 | ||
187 | try | 188 | try |
188 | { | 189 | { |
@@ -195,9 +196,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
195 | } | 196 | } |
196 | 197 | ||
197 | lock (m_JsonValueStore) | 198 | lock (m_JsonValueStore) |
198 | m_JsonValueStore.Add(uuid,map); | 199 | m_JsonValueStore.Add(result,map); |
199 | 200 | ||
200 | result = uuid; | ||
201 | return true; | 201 | return true; |
202 | } | 202 | } |
203 | 203 | ||
@@ -231,7 +231,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
231 | if (! m_JsonValueStore.TryGetValue(storeID,out map)) | 231 | if (! m_JsonValueStore.TryGetValue(storeID,out map)) |
232 | { | 232 | { |
233 | m_log.InfoFormat("[JsonStore] Missing store {0}",storeID); | 233 | m_log.InfoFormat("[JsonStore] Missing store {0}",storeID); |
234 | return true; | 234 | return false; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index eaba816..0c175ca 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
58 | private IScriptModuleComms m_comms; | 58 | private IScriptModuleComms m_comms; |
59 | private IJsonStoreModule m_store; | 59 | private IJsonStoreModule m_store; |
60 | 60 | ||
61 | #region IRegionModule Members | 61 | #region Region Module interface |
62 | 62 | ||
63 | // ----------------------------------------------------------------- | 63 | // ----------------------------------------------------------------- |
64 | /// <summary> | 64 | /// <summary> |
@@ -227,7 +227,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
227 | protected UUID JsonCreateStore(UUID hostID, UUID scriptID, string value) | 227 | protected UUID JsonCreateStore(UUID hostID, UUID scriptID, string value) |
228 | { | 228 | { |
229 | UUID uuid = UUID.Zero; | 229 | UUID uuid = UUID.Zero; |
230 | if (! m_store.CreateStore(value, out uuid)) | 230 | if (! m_store.CreateStore(value, ref uuid)) |
231 | GenerateRuntimeError("Failed to create Json store"); | 231 | GenerateRuntimeError("Failed to create Json store"); |
232 | 232 | ||
233 | return uuid; | 233 | return uuid; |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 03481d2..6fb28e2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | |||
@@ -43,13 +43,17 @@ using OpenMetaverse; | |||
43 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
44 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Region.Framework.Scenes; | 45 | using OpenSim.Region.Framework.Scenes; |
46 | using Mono.Addins; | ||
46 | 47 | ||
47 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 48 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
48 | { | 49 | { |
49 | public class MRMModule : IRegionModule, IMRMModule | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MRMModule")] |
51 | public class MRMModule : INonSharedRegionModule, IMRMModule | ||
50 | { | 52 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | private Scene m_scene; | 54 | private Scene m_scene; |
55 | private bool m_Enabled; | ||
56 | private bool m_Hidden; | ||
53 | 57 | ||
54 | private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>(); | 58 | private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>(); |
55 | 59 | ||
@@ -67,7 +71,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
67 | m_extensions[typeof (T)] = instance; | 71 | m_extensions[typeof (T)] = instance; |
68 | } | 72 | } |
69 | 73 | ||
70 | public void Initialise(Scene scene, IConfigSource source) | 74 | #region INonSharedRegionModule |
75 | |||
76 | public void Initialise(IConfigSource source) | ||
71 | { | 77 | { |
72 | if (source.Configs["MRM"] != null) | 78 | if (source.Configs["MRM"] != null) |
73 | { | 79 | { |
@@ -76,23 +82,60 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
76 | if (source.Configs["MRM"].GetBoolean("Enabled", false)) | 82 | if (source.Configs["MRM"].GetBoolean("Enabled", false)) |
77 | { | 83 | { |
78 | m_log.Info("[MRM]: Enabling MRM Module"); | 84 | m_log.Info("[MRM]: Enabling MRM Module"); |
79 | m_scene = scene; | 85 | m_Enabled = true; |
86 | m_Hidden = source.Configs["MRM"].GetBoolean("Hidden", false); | ||
87 | } | ||
88 | } | ||
89 | } | ||
80 | 90 | ||
81 | // when hidden, we don't listen for client initiated script events | 91 | public void AddRegion(Scene scene) |
82 | // only making the MRM engine available for region modules | 92 | { |
83 | if (!source.Configs["MRM"].GetBoolean("Hidden", false)) | 93 | if (!m_Enabled) |
84 | { | 94 | return; |
85 | scene.EventManager.OnRezScript += EventManager_OnRezScript; | ||
86 | scene.EventManager.OnStopScript += EventManager_OnStopScript; | ||
87 | } | ||
88 | 95 | ||
89 | scene.EventManager.OnFrame += EventManager_OnFrame; | 96 | m_scene = scene; |
90 | 97 | ||
91 | scene.RegisterModuleInterface<IMRMModule>(this); | 98 | // when hidden, we don't listen for client initiated script events |
92 | } | 99 | // only making the MRM engine available for region modules |
100 | if (!m_Hidden) | ||
101 | { | ||
102 | scene.EventManager.OnRezScript += EventManager_OnRezScript; | ||
103 | scene.EventManager.OnStopScript += EventManager_OnStopScript; | ||
93 | } | 104 | } |
105 | |||
106 | scene.EventManager.OnFrame += EventManager_OnFrame; | ||
107 | |||
108 | scene.RegisterModuleInterface<IMRMModule>(this); | ||
109 | } | ||
110 | |||
111 | public void RegionLoaded(Scene scene) | ||
112 | { | ||
94 | } | 113 | } |
95 | 114 | ||
115 | public void RemoveRegion(Scene scene) | ||
116 | { | ||
117 | } | ||
118 | |||
119 | public void Close() | ||
120 | { | ||
121 | foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts) | ||
122 | { | ||
123 | pair.Value.Stop(); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | public string Name | ||
128 | { | ||
129 | get { return "MiniRegionModule"; } | ||
130 | } | ||
131 | |||
132 | public Type ReplaceableInterface | ||
133 | { | ||
134 | get { return null; } | ||
135 | } | ||
136 | |||
137 | #endregion | ||
138 | |||
96 | void EventManager_OnStopScript(uint localID, UUID itemID) | 139 | void EventManager_OnStopScript(uint localID, UUID itemID) |
97 | { | 140 | { |
98 | if (m_scripts.ContainsKey(itemID)) | 141 | if (m_scripts.ContainsKey(itemID)) |
@@ -293,28 +336,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
293 | mmb.InitMiniModule(world, host, itemID); | 336 | mmb.InitMiniModule(world, host, itemID); |
294 | } | 337 | } |
295 | 338 | ||
296 | public void PostInitialise() | ||
297 | { | ||
298 | } | ||
299 | |||
300 | public void Close() | ||
301 | { | ||
302 | foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts) | ||
303 | { | ||
304 | pair.Value.Stop(); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | public string Name | ||
309 | { | ||
310 | get { return "MiniRegionModule"; } | ||
311 | } | ||
312 | |||
313 | public bool IsSharedModule | ||
314 | { | ||
315 | get { return false; } | ||
316 | } | ||
317 | |||
318 | /// <summary> | 339 | /// <summary> |
319 | /// Stolen from ScriptEngine Common | 340 | /// Stolen from ScriptEngine Common |
320 | /// </summary> | 341 | /// </summary> |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index aa23fee..5ed1514 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | |||
@@ -821,8 +821,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
821 | { | 821 | { |
822 | if (!CanEdit()) | 822 | if (!CanEdit()) |
823 | return; | 823 | return; |
824 | 824 | ISoundModule module = m_rootScene.RequestModuleInterface<ISoundModule>(); | |
825 | GetSOP().SendSound(asset.ToString(), volume, true, 0, 0, false, false); | 825 | if (module != null) |
826 | { | ||
827 | module.SendSound(GetSOP().UUID, asset, volume, true, 0, 0, false, false); | ||
828 | } | ||
826 | } | 829 | } |
827 | 830 | ||
828 | #endregion | 831 | #endregion |
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index fff3a32..c550c44 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs | |||
@@ -32,6 +32,7 @@ using System.Net; | |||
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Text; | 33 | using System.Text; |
34 | using log4net; | 34 | using log4net; |
35 | using Mono.Addins; | ||
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenMetaverse.StructuredData; | 38 | using OpenMetaverse.StructuredData; |
@@ -42,6 +43,7 @@ using OpenSim.Services.Interfaces; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | 44 | namespace OpenSim.Region.OptionalModules.Scripting.RegionReady |
44 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionReadyModule")] | ||
45 | public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule | 47 | public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule |
46 | { | 48 | { |
47 | private static readonly ILog m_log = | 49 | private static readonly ILog m_log = |
@@ -181,7 +183,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
181 | } | 183 | } |
182 | } | 184 | } |
183 | 185 | ||
184 | void OnOarFileLoaded(Guid requestId, string message) | 186 | void OnOarFileLoaded(Guid requestId, List<UUID> loadedScenes, string message) |
185 | { | 187 | { |
186 | m_oarFileLoading = true; | 188 | m_oarFileLoading = true; |
187 | 189 | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs deleted file mode 100644 index c5c96a9..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ /dev/null | |||
@@ -1,324 +0,0 @@ | |||
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 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using Nini.Config; | ||
32 | using log4net; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using Mono.Addins; | ||
37 | using OpenMetaverse; | ||
38 | using System.Linq; | ||
39 | using System.Linq.Expressions; | ||
40 | |||
41 | namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms | ||
42 | { | ||
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] | ||
44 | class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms | ||
45 | { | ||
46 | private static readonly ILog m_log = | ||
47 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private Dictionary<string,object> m_constants = new Dictionary<string,object>(); | ||
50 | |||
51 | #region ScriptInvocation | ||
52 | protected class ScriptInvocationData | ||
53 | { | ||
54 | public Delegate ScriptInvocationDelegate { get; private set; } | ||
55 | public string FunctionName { get; private set; } | ||
56 | public Type[] TypeSignature { get; private set; } | ||
57 | public Type ReturnType { get; private set; } | ||
58 | |||
59 | public ScriptInvocationData(string fname, Delegate fn, Type[] callsig, Type returnsig) | ||
60 | { | ||
61 | FunctionName = fname; | ||
62 | ScriptInvocationDelegate = fn; | ||
63 | TypeSignature = callsig; | ||
64 | ReturnType = returnsig; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | private Dictionary<string,ScriptInvocationData> m_scriptInvocation = new Dictionary<string,ScriptInvocationData>(); | ||
69 | #endregion | ||
70 | |||
71 | private IScriptModule m_scriptModule = null; | ||
72 | public event ScriptCommand OnScriptCommand; | ||
73 | |||
74 | #region RegionModuleInterface | ||
75 | public void Initialise(IConfigSource config) | ||
76 | { | ||
77 | } | ||
78 | |||
79 | public void AddRegion(Scene scene) | ||
80 | { | ||
81 | scene.RegisterModuleInterface<IScriptModuleComms>(this); | ||
82 | } | ||
83 | |||
84 | public void RemoveRegion(Scene scene) | ||
85 | { | ||
86 | } | ||
87 | |||
88 | public void RegionLoaded(Scene scene) | ||
89 | { | ||
90 | m_scriptModule = scene.RequestModuleInterface<IScriptModule>(); | ||
91 | |||
92 | if (m_scriptModule != null) | ||
93 | m_log.Info("[MODULE COMMANDS]: Script engine found, module active"); | ||
94 | } | ||
95 | |||
96 | public string Name | ||
97 | { | ||
98 | get { return "ScriptModuleCommsModule"; } | ||
99 | } | ||
100 | |||
101 | public Type ReplaceableInterface | ||
102 | { | ||
103 | get { return null; } | ||
104 | } | ||
105 | |||
106 | public void Close() | ||
107 | { | ||
108 | } | ||
109 | #endregion | ||
110 | |||
111 | #region ScriptModuleComms | ||
112 | |||
113 | public void RaiseEvent(UUID script, string id, string module, string command, string k) | ||
114 | { | ||
115 | ScriptCommand c = OnScriptCommand; | ||
116 | |||
117 | if (c == null) | ||
118 | return; | ||
119 | |||
120 | c(script, id, module, command, k); | ||
121 | } | ||
122 | |||
123 | public void DispatchReply(UUID script, int code, string text, string k) | ||
124 | { | ||
125 | if (m_scriptModule == null) | ||
126 | return; | ||
127 | |||
128 | Object[] args = new Object[] {-1, code, text, k}; | ||
129 | |||
130 | m_scriptModule.PostScriptEvent(script, "link_message", args); | ||
131 | } | ||
132 | |||
133 | public void RegisterScriptInvocation(object target, string meth) | ||
134 | { | ||
135 | MethodInfo mi = target.GetType().GetMethod(meth, | ||
136 | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); | ||
137 | if (mi == null) | ||
138 | { | ||
139 | m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth); | ||
140 | return; | ||
141 | } | ||
142 | |||
143 | RegisterScriptInvocation(target, mi); | ||
144 | } | ||
145 | |||
146 | public void RegisterScriptInvocation(object target, string[] meth) | ||
147 | { | ||
148 | foreach (string m in meth) | ||
149 | RegisterScriptInvocation(target, m); | ||
150 | } | ||
151 | |||
152 | public void RegisterScriptInvocation(object target, MethodInfo mi) | ||
153 | { | ||
154 | m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, target.GetType().Name); | ||
155 | |||
156 | Type delegateType; | ||
157 | var typeArgs = mi.GetParameters() | ||
158 | .Select(p => p.ParameterType) | ||
159 | .ToList(); | ||
160 | |||
161 | if (mi.ReturnType == typeof(void)) | ||
162 | { | ||
163 | delegateType = Expression.GetActionType(typeArgs.ToArray()); | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | typeArgs.Add(mi.ReturnType); | ||
168 | delegateType = Expression.GetFuncType(typeArgs.ToArray()); | ||
169 | } | ||
170 | |||
171 | Delegate fcall = Delegate.CreateDelegate(delegateType, target, mi); | ||
172 | |||
173 | lock (m_scriptInvocation) | ||
174 | { | ||
175 | ParameterInfo[] parameters = fcall.Method.GetParameters (); | ||
176 | if (parameters.Length < 2) // Must have two UUID params | ||
177 | return; | ||
178 | |||
179 | // Hide the first two parameters | ||
180 | Type[] parmTypes = new Type[parameters.Length - 2]; | ||
181 | for (int i = 2 ; i < parameters.Length ; i++) | ||
182 | parmTypes[i - 2] = parameters[i].ParameterType; | ||
183 | m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | public Delegate[] GetScriptInvocationList() | ||
188 | { | ||
189 | List<Delegate> ret = new List<Delegate>(); | ||
190 | |||
191 | lock (m_scriptInvocation) | ||
192 | { | ||
193 | foreach (ScriptInvocationData d in m_scriptInvocation.Values) | ||
194 | ret.Add(d.ScriptInvocationDelegate); | ||
195 | } | ||
196 | return ret.ToArray(); | ||
197 | } | ||
198 | |||
199 | public string LookupModInvocation(string fname) | ||
200 | { | ||
201 | lock (m_scriptInvocation) | ||
202 | { | ||
203 | ScriptInvocationData sid; | ||
204 | if (m_scriptInvocation.TryGetValue(fname,out sid)) | ||
205 | { | ||
206 | if (sid.ReturnType == typeof(string)) | ||
207 | return "modInvokeS"; | ||
208 | else if (sid.ReturnType == typeof(int)) | ||
209 | return "modInvokeI"; | ||
210 | else if (sid.ReturnType == typeof(float)) | ||
211 | return "modInvokeF"; | ||
212 | else if (sid.ReturnType == typeof(UUID)) | ||
213 | return "modInvokeK"; | ||
214 | else if (sid.ReturnType == typeof(OpenMetaverse.Vector3)) | ||
215 | return "modInvokeV"; | ||
216 | else if (sid.ReturnType == typeof(OpenMetaverse.Quaternion)) | ||
217 | return "modInvokeR"; | ||
218 | else if (sid.ReturnType == typeof(object[])) | ||
219 | return "modInvokeL"; | ||
220 | |||
221 | m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | return null; | ||
226 | } | ||
227 | |||
228 | public Delegate LookupScriptInvocation(string fname) | ||
229 | { | ||
230 | lock (m_scriptInvocation) | ||
231 | { | ||
232 | ScriptInvocationData sid; | ||
233 | if (m_scriptInvocation.TryGetValue(fname,out sid)) | ||
234 | return sid.ScriptInvocationDelegate; | ||
235 | } | ||
236 | |||
237 | return null; | ||
238 | } | ||
239 | |||
240 | public Type[] LookupTypeSignature(string fname) | ||
241 | { | ||
242 | lock (m_scriptInvocation) | ||
243 | { | ||
244 | ScriptInvocationData sid; | ||
245 | if (m_scriptInvocation.TryGetValue(fname,out sid)) | ||
246 | return sid.TypeSignature; | ||
247 | } | ||
248 | |||
249 | return null; | ||
250 | } | ||
251 | |||
252 | public Type LookupReturnType(string fname) | ||
253 | { | ||
254 | lock (m_scriptInvocation) | ||
255 | { | ||
256 | ScriptInvocationData sid; | ||
257 | if (m_scriptInvocation.TryGetValue(fname,out sid)) | ||
258 | return sid.ReturnType; | ||
259 | } | ||
260 | |||
261 | return null; | ||
262 | } | ||
263 | |||
264 | public object InvokeOperation(UUID hostid, UUID scriptid, string fname, params object[] parms) | ||
265 | { | ||
266 | List<object> olist = new List<object>(); | ||
267 | olist.Add(hostid); | ||
268 | olist.Add(scriptid); | ||
269 | foreach (object o in parms) | ||
270 | olist.Add(o); | ||
271 | Delegate fn = LookupScriptInvocation(fname); | ||
272 | return fn.DynamicInvoke(olist.ToArray()); | ||
273 | } | ||
274 | |||
275 | /// <summary> | ||
276 | /// Operation to for a region module to register a constant to be used | ||
277 | /// by the script engine | ||
278 | /// </summary> | ||
279 | public void RegisterConstant(string cname, object value) | ||
280 | { | ||
281 | m_log.DebugFormat("[MODULE COMMANDS] register constant <{0}> with value {1}",cname,value.ToString()); | ||
282 | lock (m_constants) | ||
283 | { | ||
284 | m_constants.Add(cname,value); | ||
285 | } | ||
286 | } | ||
287 | |||
288 | /// <summary> | ||
289 | /// Operation to check for a registered constant | ||
290 | /// </summary> | ||
291 | public object LookupModConstant(string cname) | ||
292 | { | ||
293 | // m_log.DebugFormat("[MODULE COMMANDS] lookup constant <{0}>",cname); | ||
294 | |||
295 | lock (m_constants) | ||
296 | { | ||
297 | object value = null; | ||
298 | if (m_constants.TryGetValue(cname,out value)) | ||
299 | return value; | ||
300 | } | ||
301 | |||
302 | return null; | ||
303 | } | ||
304 | |||
305 | /// <summary> | ||
306 | /// Get all registered constants | ||
307 | /// </summary> | ||
308 | public Dictionary<string, object> GetConstants() | ||
309 | { | ||
310 | Dictionary<string, object> ret = new Dictionary<string, object>(); | ||
311 | |||
312 | lock (m_constants) | ||
313 | { | ||
314 | foreach (KeyValuePair<string, object> kvp in m_constants) | ||
315 | ret[kvp.Key] = kvp.Value; | ||
316 | } | ||
317 | |||
318 | return ret; | ||
319 | } | ||
320 | |||
321 | #endregion | ||
322 | |||
323 | } | ||
324 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs index 2187449..6120a81 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using log4net; | 32 | using log4net; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using Mono.Addins; | ||
35 | 36 | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
@@ -49,7 +50,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
49 | public string uri; | 50 | public string uri; |
50 | } | 51 | } |
51 | 52 | ||
52 | public class XmlRpcGridRouter : IRegionModule, IXmlRpcRouter | 53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGridRouter")] |
54 | public class XmlRpcGridRouter : INonSharedRegionModule, IXmlRpcRouter | ||
53 | { | 55 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 57 | ||
@@ -59,9 +61,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
59 | private bool m_Enabled = false; | 61 | private bool m_Enabled = false; |
60 | private string m_ServerURI = String.Empty; | 62 | private string m_ServerURI = String.Empty; |
61 | 63 | ||
62 | public void Initialise(Scene scene, IConfigSource config) | 64 | #region INonSharedRegionModule |
65 | |||
66 | public void Initialise(IConfigSource config) | ||
63 | { | 67 | { |
64 | IConfig startupConfig = config.Configs["Startup"]; | 68 | IConfig startupConfig = config.Configs["XMLRPC"]; |
65 | if (startupConfig == null) | 69 | if (startupConfig == null) |
66 | return; | 70 | return; |
67 | 71 | ||
@@ -74,16 +78,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
74 | m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling"); | 78 | m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling"); |
75 | return; | 79 | return; |
76 | } | 80 | } |
77 | |||
78 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
79 | m_Enabled = true; | 81 | m_Enabled = true; |
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
83 | public void PostInitialise() | 85 | public void AddRegion(Scene scene) |
86 | { | ||
87 | if (!m_Enabled) | ||
88 | return; | ||
89 | |||
90 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
91 | } | ||
92 | |||
93 | public void RegionLoaded(Scene scene) | ||
84 | { | 94 | { |
85 | } | 95 | } |
86 | 96 | ||
97 | public void RemoveRegion(Scene scene) | ||
98 | { | ||
99 | if (!m_Enabled) | ||
100 | return; | ||
101 | |||
102 | scene.UnregisterModuleInterface<IXmlRpcRouter>(this); | ||
103 | } | ||
104 | |||
87 | public void Close() | 105 | public void Close() |
88 | { | 106 | { |
89 | } | 107 | } |
@@ -93,11 +111,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
93 | get { return "XmlRpcGridRouterModule"; } | 111 | get { return "XmlRpcGridRouterModule"; } |
94 | } | 112 | } |
95 | 113 | ||
96 | public bool IsSharedModule | 114 | public Type ReplaceableInterface |
97 | { | 115 | { |
98 | get { return false; } | 116 | get { return null; } |
99 | } | 117 | } |
100 | 118 | ||
119 | #endregion | ||
120 | |||
101 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) | 121 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) |
102 | { | 122 | { |
103 | if (!m_Channels.ContainsKey(itemID)) | 123 | if (!m_Channels.ContainsKey(itemID)) |
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs index 11c87f8..4bde52a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs | |||
@@ -31,6 +31,7 @@ using System.Reflection; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using Mono.Addins; | ||
34 | 35 | ||
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
@@ -39,32 +40,46 @@ using OpenSim.Region.Framework.Scenes; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule | 41 | namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule |
41 | { | 42 | { |
42 | public class XmlRpcRouter : IRegionModule, IXmlRpcRouter | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcRouter")] |
44 | public class XmlRpcRouter : INonSharedRegionModule, IXmlRpcRouter | ||
43 | { | 45 | { |
44 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | private bool m_enabled = false; | 47 | |
46 | public void Initialise(Scene scene, IConfigSource config) | 48 | private bool m_Enabled; |
49 | |||
50 | #region INonSharedRegionModule | ||
51 | |||
52 | public void Initialise(IConfigSource config) | ||
47 | { | 53 | { |
48 | IConfig startupConfig = config.Configs["XMLRPC"]; | 54 | IConfig startupConfig = config.Configs["XMLRPC"]; |
49 | if (startupConfig == null) | 55 | if (startupConfig == null) |
50 | return; | 56 | return; |
51 | 57 | ||
52 | if (startupConfig.GetString("XmlRpcRouterModule", | 58 | if (startupConfig.GetString("XmlRpcRouterModule", |
53 | "") == "XmlRpcRouterModule") | 59 | "XmlRpcRouterModule") == "XmlRpcRouterModule") |
54 | { | 60 | m_Enabled = true; |
55 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | 61 | } |
56 | m_enabled = true; | 62 | |
57 | } | 63 | public void AddRegion(Scene scene) |
58 | else | 64 | { |
59 | { | 65 | if (!m_Enabled) |
60 | m_enabled = false; | 66 | return; |
61 | } | 67 | |
68 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
62 | } | 69 | } |
63 | 70 | ||
64 | public void PostInitialise() | 71 | public void RegionLoaded(Scene scene) |
65 | { | 72 | { |
66 | } | 73 | } |
67 | 74 | ||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | if (!m_Enabled) | ||
78 | return; | ||
79 | |||
80 | scene.UnregisterModuleInterface<IXmlRpcRouter>(this); | ||
81 | } | ||
82 | |||
68 | public void Close() | 83 | public void Close() |
69 | { | 84 | { |
70 | } | 85 | } |
@@ -74,14 +89,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule | |||
74 | get { return "XmlRpcRouterModule"; } | 89 | get { return "XmlRpcRouterModule"; } |
75 | } | 90 | } |
76 | 91 | ||
77 | public bool IsSharedModule | 92 | public Type ReplaceableInterface |
78 | { | 93 | { |
79 | get { return false; } | 94 | get { return null; } |
80 | } | 95 | } |
81 | 96 | ||
97 | #endregion | ||
98 | |||
82 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) | 99 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) |
83 | { | 100 | { |
84 | if (m_enabled) | 101 | if (m_Enabled) |
85 | { | 102 | { |
86 | scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] { uri }); | 103 | scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] { uri }); |
87 | } | 104 | } |