opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 eva 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.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
32 using Nini.Config;
33 using OpenMetaverse;
34 using OpenSim.Framework;
35 using OpenSim.Region.Framework.Interfaces;
36 using OpenSim.Region.Framework.Scenes;
37 using OpenSim.Region.ScriptEngine.Interfaces;
38 using OpenSim.Region.ScriptEngine.Shared;
39  
40 namespace OpenSim.Tests.Common
41 {
42 public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
43 {
44 public IConfigSource ConfigSource { get; private set; }
45  
46 public IConfig Config { get; private set; }
47  
48 private Scene m_scene;
49  
50 /// <summary>
51 /// Expose posted events to tests.
52 /// </summary>
53 public Dictionary<UUID, List<EventParams>> PostedEvents { get; private set; }
54  
55 /// <summary>
56 /// A very primitive way of hooking text cose to a posed event.
57 /// </summary>
58 /// <remarks>
59 /// May be replaced with something that uses more original code in the future.
60 /// </remarks>
61 public event Action<UUID, EventParams> PostEventHook;
62  
63 public void Initialise(IConfigSource source)
64 {
65 ConfigSource = source;
66  
67 // Can set later on if required
68 Config = new IniConfig("MockScriptEngine", ConfigSource);
69  
70 PostedEvents = new Dictionary<UUID, List<EventParams>>();
71 }
72  
73 public void Close()
74 {
75 }
76  
77 public void AddRegion(Scene scene)
78 {
79 m_scene = scene;
80  
81 m_scene.StackModuleInterface<IScriptModule>(this);
82 }
83  
84 public void RemoveRegion(Scene scene)
85 {
86 }
87  
88 public void RegionLoaded(Scene scene)
89 {
90 }
91  
92 public string Name { get { return "Mock Script Engine"; } }
93 public string ScriptEngineName { get { return Name; } }
94  
95 public Type ReplaceableInterface { get { return null; } }
96  
97 public event ScriptRemoved OnScriptRemoved;
98 public event ObjectRemoved OnObjectRemoved;
99  
100 public string GetXMLState (UUID itemID)
101 {
102 throw new System.NotImplementedException ();
103 }
104  
105 public bool SetXMLState(UUID itemID, string xml)
106 {
107 throw new System.NotImplementedException ();
108 }
109  
110 public bool PostScriptEvent(UUID itemID, string name, object[] args)
111 {
112 // Console.WriteLine("Posting event {0} for {1}", name, itemID);
113  
114 return PostScriptEvent(itemID, new EventParams(name, args, null));
115 }
116  
117 public bool PostScriptEvent(UUID itemID, EventParams evParams)
118 {
119 List<EventParams> eventsForItem;
120  
121 if (!PostedEvents.ContainsKey(itemID))
122 {
123 eventsForItem = new List<EventParams>();
124 PostedEvents.Add(itemID, eventsForItem);
125 }
126 else
127 {
128 eventsForItem = PostedEvents[itemID];
129 }
130  
131 eventsForItem.Add(evParams);
132  
133 if (PostEventHook != null)
134 PostEventHook(itemID, evParams);
135  
136 return true;
137 }
138  
139 public bool PostObjectEvent(uint localID, EventParams evParams)
140 {
141 return PostObjectEvent(m_scene.GetSceneObjectPart(localID), evParams);
142 }
143  
144 public bool PostObjectEvent(UUID itemID, string name, object[] args)
145 {
146 return PostObjectEvent(m_scene.GetSceneObjectPart(itemID), new EventParams(name, args, null));
147 }
148  
149 private bool PostObjectEvent(SceneObjectPart part, EventParams evParams)
150 {
151 foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems(InventoryType.LSL))
152 PostScriptEvent(item.ItemID, evParams);
153  
154 return true;
155 }
156  
157 public void SuspendScript(UUID itemID)
158 {
159 throw new System.NotImplementedException ();
160 }
161  
162 public void ResumeScript(UUID itemID)
163 {
164 throw new System.NotImplementedException ();
165 }
166  
167 public ArrayList GetScriptErrors(UUID itemID)
168 {
169 throw new System.NotImplementedException ();
170 }
171  
172 public bool HasScript(UUID itemID, out bool running)
173 {
174 throw new System.NotImplementedException ();
175 }
176  
177 public bool GetScriptState(UUID itemID)
178 {
179 throw new System.NotImplementedException ();
180 }
181  
182 public void SaveAllState()
183 {
184 throw new System.NotImplementedException ();
185 }
186  
187 public void StartProcessing()
188 {
189 throw new System.NotImplementedException ();
190 }
191  
192 public float GetScriptExecutionTime(List<UUID> itemIDs)
193 {
194 throw new System.NotImplementedException ();
195 }
196  
197 public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
198 {
199 throw new System.NotImplementedException ();
200 }
201  
202 public IScriptWorkItem QueueEventHandler(object parms)
203 {
204 throw new System.NotImplementedException ();
205 }
206  
207 public DetectParams GetDetectParams(UUID item, int number)
208 {
209 throw new System.NotImplementedException ();
210 }
211  
212 public void SetMinEventDelay(UUID itemID, double delay)
213 {
214 throw new System.NotImplementedException ();
215 }
216  
217 public int GetStartParameter(UUID itemID)
218 {
219 throw new System.NotImplementedException ();
220 }
221  
222 public void SetScriptState(UUID itemID, bool state)
223 {
224 throw new System.NotImplementedException ();
225 }
226  
227 public void SetState(UUID itemID, string newState)
228 {
229 throw new System.NotImplementedException ();
230 }
231  
232 public void ApiResetScript(UUID itemID)
233 {
234 throw new System.NotImplementedException ();
235 }
236  
237 public void ResetScript (UUID itemID)
238 {
239 throw new System.NotImplementedException ();
240 }
241  
242 public IScriptApi GetApi(UUID itemID, string name)
243 {
244 throw new System.NotImplementedException ();
245 }
246  
247 public Scene World { get { return m_scene; } }
248  
249 public IScriptModule ScriptModule { get { return this; } }
250  
251 public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
252  
253 public string ScriptClassName { get { throw new System.NotImplementedException (); } }
254  
255 public string ScriptBaseClassName { get { throw new System.NotImplementedException (); } }
256  
257 public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
258  
259 public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
260  
261 public void ClearPostedEvents()
262 {
263 PostedEvents.Clear();
264 }
265 }
266 }