aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Scripting
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs48
-rw-r--r--OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs110
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs34
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs40
-rw-r--r--OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs18
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs64
-rw-r--r--OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs397
-rw-r--r--OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs82
9 files changed, 566 insertions, 229 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index 93a045e..9d77b19 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -37,10 +37,12 @@ using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using log4net; 38using log4net;
39using System.Reflection; 39using System.Reflection;
40using Mono.Addins;
40 41
41namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture 42namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
42{ 43{
43 public class DynamicTextureModule : IRegionModule, IDynamicTextureManager 44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DynamicTextureModule")]
45 public class DynamicTextureModule : ISharedRegionModule, IDynamicTextureManager
44 { 46 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 48
@@ -81,6 +83,16 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
81 /// </remarks> 83 /// </remarks>
82 private Cache m_reuseableDynamicTextures; 84 private Cache m_reuseableDynamicTextures;
83 85
86 /// <summary>
87 /// This constructor is only here because of the Unit Tests...
88 /// Don't use it.
89 /// </summary>
90 public DynamicTextureModule()
91 {
92 m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative);
93 m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0);
94 }
95
84 #region IDynamicTextureManager Members 96 #region IDynamicTextureManager Members
85 97
86 public void RegisterRender(string handleType, IDynamicTextureRender render) 98 public void RegisterRender(string handleType, IDynamicTextureRender render)
@@ -323,17 +335,30 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
323 335
324 #endregion 336 #endregion
325 337
326 #region IRegionModule Members 338 #region ISharedRegionModule Members
327 339
328 public void Initialise(Scene scene, IConfigSource config) 340 public void Initialise(IConfigSource config)
329 { 341 {
330 IConfig texturesConfig = config.Configs["Textures"]; 342 IConfig texturesConfig = config.Configs["Textures"];
331 if (texturesConfig != null) 343 if (texturesConfig != null)
332 { 344 {
333 ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); 345 ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false);
334 ReuseLowDataTextures = texturesConfig.GetBoolean("ReuseDynamicLowDataTextures", false); 346 ReuseLowDataTextures = texturesConfig.GetBoolean("ReuseDynamicLowDataTextures", false);
347
348 if (ReuseTextures)
349 {
350 m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative);
351 m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0);
352 }
335 } 353 }
354 }
336 355
356 public void PostInitialise()
357 {
358 }
359
360 public void AddRegion(Scene scene)
361 {
337 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) 362 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
338 { 363 {
339 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); 364 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
@@ -341,13 +366,14 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
341 } 366 }
342 } 367 }
343 368
344 public void PostInitialise() 369 public void RegionLoaded(Scene scene)
345 { 370 {
346 if (ReuseTextures) 371 }
347 { 372
348 m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative); 373 public void RemoveRegion(Scene scene)
349 m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0); 374 {
350 } 375 if (RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
376 RegisteredScenes.Remove(scene.RegionInfo.RegionID);
351 } 377 }
352 378
353 public void Close() 379 public void Close()
@@ -359,9 +385,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
359 get { return "DynamicTextureModule"; } 385 get { return "DynamicTextureModule"; }
360 } 386 }
361 387
362 public bool IsSharedModule 388 public Type ReplaceableInterface
363 { 389 {
364 get { return true; } 390 get { return null; }
365 } 391 }
366 392
367 #endregion 393 #endregion
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
index e91e8b9..d943b20 100644
--- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
@@ -37,10 +37,12 @@ using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using Mono.Addins;
40 41
41namespace OpenSim.Region.CoreModules.Scripting.EmailModules 42namespace OpenSim.Region.CoreModules.Scripting.EmailModules
42{ 43{
43 public class EmailModule : IRegionModule, IEmailModule 44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EmailModule")]
45 public class EmailModule : ISharedRegionModule, IEmailModule
44 { 46 {
45 // 47 //
46 // Log 48 // Log
@@ -72,31 +74,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
72 74
73 private bool m_Enabled = false; 75 private bool m_Enabled = false;
74 76
75 public void InsertEmail(UUID to, Email email) 77 #region ISharedRegionModule
76 {
77 // It's tempting to create the queue here. Don't; objects which have
78 // not yet called GetNextEmail should have no queue, and emails to them
79 // should be silently dropped.
80
81 lock (m_MailQueues)
82 {
83 if (m_MailQueues.ContainsKey(to))
84 {
85 if (m_MailQueues[to].Count >= m_MaxQueueSize)
86 {
87 // fail silently
88 return;
89 }
90
91 lock (m_MailQueues[to])
92 {
93 m_MailQueues[to].Add(email);
94 }
95 }
96 }
97 }
98 78
99 public void Initialise(Scene scene, IConfigSource config) 79 public void Initialise(IConfigSource config)
100 { 80 {
101 m_Config = config; 81 m_Config = config;
102 IConfig SMTPConfig; 82 IConfig SMTPConfig;
@@ -129,36 +109,44 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
129 SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); 109 SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT);
130 SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); 110 SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN);
131 SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); 111 SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD);
132 m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize); 112 m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize);
133 } 113 }
134 catch (Exception e) 114 catch (Exception e)
135 { 115 {
136 m_log.Error("[EMAIL] DefaultEmailModule not configured: "+ e.Message); 116 m_log.Error("[EMAIL] DefaultEmailModule not configured: " + e.Message);
137 m_Enabled = false; 117 m_Enabled = false;
138 return; 118 return;
139 } 119 }
140 120
141 // It's a go! 121 }
142 if (m_Enabled) 122
123 public void AddRegion(Scene scene)
124 {
125 if (!m_Enabled)
126 return;
127
128 // It's a go!
129 lock (m_Scenes)
143 { 130 {
144 lock (m_Scenes) 131 // Claim the interface slot
145 { 132 scene.RegisterModuleInterface<IEmailModule>(this);
146 // Claim the interface slot
147 scene.RegisterModuleInterface<IEmailModule>(this);
148 133
149 // Add to scene list 134 // Add to scene list
150 if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle)) 135 if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle))
151 { 136 {
152 m_Scenes[scene.RegionInfo.RegionHandle] = scene; 137 m_Scenes[scene.RegionInfo.RegionHandle] = scene;
153 } 138 }
154 else 139 else
155 { 140 {
156 m_Scenes.Add(scene.RegionInfo.RegionHandle, scene); 141 m_Scenes.Add(scene.RegionInfo.RegionHandle, scene);
157 }
158 } 142 }
159
160 m_log.Info("[EMAIL] Activated DefaultEmailModule");
161 } 143 }
144
145 m_log.Info("[EMAIL] Activated DefaultEmailModule");
146 }
147
148 public void RemoveRegion(Scene scene)
149 {
162 } 150 }
163 151
164 public void PostInitialise() 152 public void PostInitialise()
@@ -174,9 +162,39 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
174 get { return "DefaultEmailModule"; } 162 get { return "DefaultEmailModule"; }
175 } 163 }
176 164
177 public bool IsSharedModule 165 public Type ReplaceableInterface
166 {
167 get { return null; }
168 }
169
170 public void RegionLoaded(Scene scene)
178 { 171 {
179 get { return true; } 172 }
173
174 #endregion
175
176 public void InsertEmail(UUID to, Email email)
177 {
178 // It's tempting to create the queue here. Don't; objects which have
179 // not yet called GetNextEmail should have no queue, and emails to them
180 // should be silently dropped.
181
182 lock (m_MailQueues)
183 {
184 if (m_MailQueues.ContainsKey(to))
185 {
186 if (m_MailQueues[to].Count >= m_MaxQueueSize)
187 {
188 // fail silently
189 return;
190 }
191
192 lock (m_MailQueues[to])
193 {
194 m_MailQueues[to].Add(email);
195 }
196 }
197 }
180 } 198 }
181 199
182 private bool IsLocal(UUID objectID) 200 private bool IsLocal(UUID objectID)
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index d328eb3..a676971 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer; 41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using Mono.Addins;
44 45
45/***************************************************** 46/*****************************************************
46 * 47 *
@@ -87,7 +88,8 @@ using OpenSim.Region.Framework.Scenes;
87 88
88namespace OpenSim.Region.CoreModules.Scripting.HttpRequest 89namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
89{ 90{
90 public class HttpRequestModule : IRegionModule, IHttpRequestModule 91 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HttpRequestModule")]
92 public class HttpRequestModule : ISharedRegionModule, IHttpRequestModule
91 { 93 {
92 private object HttpListLock = new object(); 94 private object HttpListLock = new object();
93 private int httpTimeout = 30000; 95 private int httpTimeout = 30000;
@@ -270,24 +272,38 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
270 272
271 #endregion 273 #endregion
272 274
273 #region IRegionModule Members 275 #region ISharedRegionModule Members
274 276
275 public void Initialise(Scene scene, IConfigSource config) 277 public void Initialise(IConfigSource config)
276 { 278 {
277 m_scene = scene;
278
279 m_scene.RegisterModuleInterface<IHttpRequestModule>(this);
280
281 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); 279 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
282 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); 280 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
283 281
284 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); 282 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>();
285 } 283 }
286 284
285 public void AddRegion(Scene scene)
286 {
287 m_scene = scene;
288
289 m_scene.RegisterModuleInterface<IHttpRequestModule>(this);
290 }
291
292 public void RemoveRegion(Scene scene)
293 {
294 scene.UnregisterModuleInterface<IHttpRequestModule>(this);
295 if (scene == m_scene)
296 m_scene = null;
297 }
298
287 public void PostInitialise() 299 public void PostInitialise()
288 { 300 {
289 } 301 }
290 302
303 public void RegionLoaded(Scene scene)
304 {
305 }
306
291 public void Close() 307 public void Close()
292 { 308 {
293 } 309 }
@@ -297,9 +313,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
297 get { return m_name; } 313 get { return m_name; }
298 } 314 }
299 315
300 public bool IsSharedModule 316 public Type ReplaceableInterface
301 { 317 {
302 get { return true; } 318 get { return null; }
303 } 319 }
304 320
305 #endregion 321 #endregion
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 53a9679..a654477 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Collections; 31using System.Collections;
32using System.Reflection; 32using System.Reflection;
33using log4net; 33using log4net;
34using Mono.Addins;
34using Nini.Config; 35using Nini.Config;
35using OpenMetaverse; 36using OpenMetaverse;
36using OpenSim.Framework; 37using OpenSim.Framework;
@@ -94,6 +95,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
94 /// <summary> 95 /// <summary>
95 /// This module provides external URLs for in-world scripts. 96 /// This module provides external URLs for in-world scripts.
96 /// </summary> 97 /// </summary>
98 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UrlModule")]
97 public class UrlModule : ISharedRegionModule, IUrlModule 99 public class UrlModule : ISharedRegionModule, IUrlModule
98 { 100 {
99 private static readonly ILog m_log = 101 private static readonly ILog m_log =
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
index 45e6527..65737fa 100644
--- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
@@ -37,10 +37,12 @@ using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using log4net; 38using log4net;
39using System.Reflection; 39using System.Reflection;
40using Mono.Addins;
40 41
41namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL 42namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
42{ 43{
43 public class LoadImageURLModule : IRegionModule, IDynamicTextureRender 44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LoadImageURLModule")]
45 public class LoadImageURLModule : ISharedRegionModule, IDynamicTextureRender
44 { 46 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 48
@@ -104,22 +106,32 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
104 106
105 #endregion 107 #endregion
106 108
107 #region IRegionModule Members 109 #region ISharedRegionModule Members
108 110
109 public void Initialise(Scene scene, IConfigSource config) 111 public void Initialise(IConfigSource config)
110 { 112 {
111 if (m_scene == null)
112 {
113 m_scene = scene;
114 }
115
116 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); 113 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
117 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); 114 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
118 } 115 }
119 116
120 public void PostInitialise() 117 public void PostInitialise()
121 { 118 {
122 if (m_scene != null) 119 }
120
121 public void AddRegion(Scene scene)
122 {
123 if (m_scene == null)
124 m_scene = scene;
125
126 }
127
128 public void RemoveRegion(Scene scene)
129 {
130 }
131
132 public void RegionLoaded(Scene scene)
133 {
134 if (m_textureManager == null && m_scene == scene)
123 { 135 {
124 m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); 136 m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
125 if (m_textureManager != null) 137 if (m_textureManager != null)
@@ -138,9 +150,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
138 get { return m_name; } 150 get { return m_name; }
139 } 151 }
140 152
141 public bool IsSharedModule 153 public Type ReplaceableInterface
142 { 154 {
143 get { return true; } 155 get { return null; }
144 } 156 }
145 157
146 #endregion 158 #endregion
@@ -172,6 +184,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
172 184
173 private void HttpRequestReturn(IAsyncResult result) 185 private void HttpRequestReturn(IAsyncResult result)
174 { 186 {
187 if (m_textureManager == null)
188 {
189 m_log.WarnFormat("[LOADIMAGEURLMODULE]: No texture manager. Can't function.");
190 return;
191 }
192
175 RequestState state = (RequestState) result.AsyncState; 193 RequestState state = (RequestState) result.AsyncState;
176 WebRequest request = (WebRequest) state.Request; 194 WebRequest request = (WebRequest) state.Request;
177 Stream stream = null; 195 Stream stream = null;
diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 98396ff..f6e1d39 100644
--- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -38,7 +38,7 @@ using OpenMetaverse;
38using System.Linq; 38using System.Linq;
39using System.Linq.Expressions; 39using System.Linq.Expressions;
40 40
41namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms 41namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
42{ 42{
43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] 43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")]
44 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms 44 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
@@ -361,6 +361,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
361 return null; 361 return null;
362 } 362 }
363 363
364 /// <summary>
365 /// Get all registered constants
366 /// </summary>
367 public Dictionary<string, object> GetConstants()
368 {
369 Dictionary<string, object> ret = new Dictionary<string, object>();
370
371 lock (m_constants)
372 {
373 foreach (KeyValuePair<string, object> kvp in m_constants)
374 ret[kvp.Key] = kvp.Value;
375 }
376
377 return ret;
378 }
379
364#endregion 380#endregion
365 381
366 } 382 }
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index b4e3d77..689e8a7 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -40,12 +40,14 @@ using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using log4net; 41using log4net;
42using System.Reflection; 42using System.Reflection;
43using Mono.Addins;
43 44
44//using Cairo; 45//using Cairo;
45 46
46namespace OpenSim.Region.CoreModules.Scripting.VectorRender 47namespace OpenSim.Region.CoreModules.Scripting.VectorRender
47{ 48{
48 public class VectorRenderModule : IRegionModule, IDynamicTextureRender 49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "VectorRenderModule")]
50 public class VectorRenderModule : ISharedRegionModule, IDynamicTextureRender
49 { 51 {
50 // These fields exist for testing purposes, please do not remove. 52 // These fields exist for testing purposes, please do not remove.
51// private static bool s_flipper; 53// private static bool s_flipper;
@@ -56,6 +58,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
56 58
57 private Scene m_scene; 59 private Scene m_scene;
58 private IDynamicTextureManager m_textureManager; 60 private IDynamicTextureManager m_textureManager;
61
59 private Graphics m_graph; 62 private Graphics m_graph;
60 private string m_fontName = "Arial"; 63 private string m_fontName = "Arial";
61 64
@@ -103,6 +106,11 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
103 106
104 public bool AsyncConvertData(UUID id, string bodyData, string extraParams) 107 public bool AsyncConvertData(UUID id, string bodyData, string extraParams)
105 { 108 {
109 if (m_textureManager == null)
110 {
111 m_log.Warn("[VECTORRENDERMODULE]: No texture manager. Can't function");
112 return false;
113 }
106 // XXX: This isn't actually being done asynchronously! 114 // XXX: This isn't actually being done asynchronously!
107 m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams)); 115 m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams));
108 116
@@ -131,45 +139,49 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
131 139
132 #endregion 140 #endregion
133 141
134 #region IRegionModule Members 142 #region ISharedRegionModule Members
135 143
136 public void Initialise(Scene scene, IConfigSource config) 144 public void Initialise(IConfigSource config)
137 { 145 {
138 if (m_scene == null)
139 {
140 m_scene = scene;
141 }
142
143 if (m_graph == null)
144 {
145 // We won't dispose of these explicitly since this module is only removed when the entire simulator
146 // is shut down.
147 Bitmap bitmap = new Bitmap(1024, 1024, PixelFormat.Format32bppArgb);
148 m_graph = Graphics.FromImage(bitmap);
149 }
150
151 IConfig cfg = config.Configs["VectorRender"]; 146 IConfig cfg = config.Configs["VectorRender"];
152 if (null != cfg) 147 if (null != cfg)
153 { 148 {
154 m_fontName = cfg.GetString("font_name", m_fontName); 149 m_fontName = cfg.GetString("font_name", m_fontName);
155 } 150 }
156 m_log.DebugFormat("[VECTORRENDERMODULE]: using font \"{0}\" for text rendering.", m_fontName); 151 m_log.DebugFormat("[VECTORRENDERMODULE]: using font \"{0}\" for text rendering.", m_fontName);
152
153 // We won't dispose of these explicitly since this module is only removed when the entire simulator
154 // is shut down.
155 Bitmap bitmap = new Bitmap(1024, 1024, PixelFormat.Format32bppArgb);
156 m_graph = Graphics.FromImage(bitmap);
157 } 157 }
158 158
159 public void PostInitialise() 159 public void PostInitialise()
160 { 160 {
161 m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); 161 }
162 if (m_textureManager != null) 162
163 public void AddRegion(Scene scene)
164 {
165 if (m_scene == null)
163 { 166 {
164 m_textureManager.RegisterRender(GetContentType(), this); 167 m_scene = scene;
165 } 168 }
169 }
166 170
167 // This code exists for testing purposes, please do not remove. 171 public void RegionLoaded(Scene scene)
168// s_asset1Data = m_scene.AssetService.Get("00000000-0000-1111-9999-000000000001").Data; 172 {
169// s_asset1Data = m_scene.AssetService.Get("9f4acf0d-1841-4e15-bdb8-3a12efc9dd8f").Data; 173 if (m_textureManager == null && m_scene == scene)
174 {
175 m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
176 if (m_textureManager != null)
177 {
178 m_textureManager.RegisterRender(GetContentType(), this);
179 }
180 }
181 }
170 182
171 // Terrain dirt - smallest bin/assets file (6004 bytes) 183 public void RemoveRegion(Scene scene)
172// s_asset2Data = m_scene.AssetService.Get("b8d3965a-ad78-bf43-699b-bff8eca6c975").Data; 184 {
173 } 185 }
174 186
175 public void Close() 187 public void Close()
@@ -181,9 +193,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
181 get { return "VectorRenderModule"; } 193 get { return "VectorRenderModule"; }
182 } 194 }
183 195
184 public bool IsSharedModule 196 public Type ReplaceableInterface
185 { 197 {
186 get { return true; } 198 get { return null; }
187 } 199 }
188 200
189 #endregion 201 #endregion
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index 8358bc0..2c2c99c 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -28,8 +28,13 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text.RegularExpressions;
32
31using Nini.Config; 33using Nini.Config;
34using Mono.Addins;
35
32using OpenMetaverse; 36using OpenMetaverse;
37
33using OpenSim.Framework; 38using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
@@ -85,7 +90,8 @@ using OpenSim.Region.Framework.Scenes;
85 90
86namespace OpenSim.Region.CoreModules.Scripting.WorldComm 91namespace OpenSim.Region.CoreModules.Scripting.WorldComm
87{ 92{
88 public class WorldCommModule : IRegionModule, IWorldComm 93 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WorldCommModule")]
94 public class WorldCommModule : IWorldComm, INonSharedRegionModule
89 { 95 {
90 // private static readonly ILog m_log = 96 // private static readonly ILog m_log =
91 // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 97 // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -98,9 +104,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
98 private int m_saydistance = 20; 104 private int m_saydistance = 20;
99 private int m_shoutdistance = 100; 105 private int m_shoutdistance = 100;
100 106
101 #region IRegionModule Members 107 #region INonSharedRegionModule Members
102 108
103 public void Initialise(Scene scene, IConfigSource config) 109 public void Initialise(IConfigSource config)
104 { 110 {
105 // wrap this in a try block so that defaults will work if 111 // wrap this in a try block so that defaults will work if
106 // the config file doesn't specify otherwise. 112 // the config file doesn't specify otherwise.
@@ -108,29 +114,49 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
108 int maxhandles = 64; 114 int maxhandles = 64;
109 try 115 try
110 { 116 {
111 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 117 m_whisperdistance = config.Configs["Chat"].GetInt(
112 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 118 "whisper_distance", m_whisperdistance);
113 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 119 m_saydistance = config.Configs["Chat"].GetInt(
114 maxlisteners = config.Configs["LL-Functions"].GetInt("max_listens_per_region", maxlisteners); 120 "say_distance", m_saydistance);
115 maxhandles = config.Configs["LL-Functions"].GetInt("max_listens_per_script", maxhandles); 121 m_shoutdistance = config.Configs["Chat"].GetInt(
122 "shout_distance", m_shoutdistance);
123 maxlisteners = config.Configs["LL-Functions"].GetInt(
124 "max_listens_per_region", maxlisteners);
125 maxhandles = config.Configs["LL-Functions"].GetInt(
126 "max_listens_per_script", maxhandles);
116 } 127 }
117 catch (Exception) 128 catch (Exception)
118 { 129 {
119 } 130 }
120 if (maxlisteners < 1) maxlisteners = int.MaxValue; 131 if (maxlisteners < 1) maxlisteners = int.MaxValue;
121 if (maxhandles < 1) maxhandles = int.MaxValue; 132 if (maxhandles < 1) maxhandles = int.MaxValue;
133 m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
134 m_pendingQ = new Queue();
135 m_pending = Queue.Synchronized(m_pendingQ);
136 }
122 137
138 public void PostInitialise()
139 {
140 }
141
142 public void AddRegion(Scene scene)
143 {
123 m_scene = scene; 144 m_scene = scene;
124 m_scene.RegisterModuleInterface<IWorldComm>(this); 145 m_scene.RegisterModuleInterface<IWorldComm>(this);
125 m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
126 m_scene.EventManager.OnChatFromClient += DeliverClientMessage; 146 m_scene.EventManager.OnChatFromClient += DeliverClientMessage;
127 m_scene.EventManager.OnChatBroadcast += DeliverClientMessage; 147 m_scene.EventManager.OnChatBroadcast += DeliverClientMessage;
128 m_pendingQ = new Queue();
129 m_pending = Queue.Synchronized(m_pendingQ);
130 } 148 }
131 149
132 public void PostInitialise() 150 public void RegionLoaded(Scene scene) { }
151
152 public void RemoveRegion(Scene scene)
133 { 153 {
154 if (scene != m_scene)
155 return;
156
157 m_scene.UnregisterModuleInterface<IWorldComm>(this);
158 m_scene.EventManager.OnChatBroadcast -= DeliverClientMessage;
159 m_scene.EventManager.OnChatBroadcast -= DeliverClientMessage;
134 } 160 }
135 161
136 public void Close() 162 public void Close()
@@ -142,10 +168,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
142 get { return "WorldCommModule"; } 168 get { return "WorldCommModule"; }
143 } 169 }
144 170
145 public bool IsSharedModule 171 public Type ReplaceableInterface { get { return null; } }
146 {
147 get { return false; }
148 }
149 172
150 #endregion 173 #endregion
151 174
@@ -170,12 +193,42 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
170 /// <param name="hostID">UUID of the SceneObjectPart</param> 193 /// <param name="hostID">UUID of the SceneObjectPart</param>
171 /// <param name="channel">channel to listen on</param> 194 /// <param name="channel">channel to listen on</param>
172 /// <param name="name">name to filter on</param> 195 /// <param name="name">name to filter on</param>
173 /// <param name="id">key to filter on (user given, could be totally faked)</param> 196 /// <param name="id">
197 /// key to filter on (user given, could be totally faked)
198 /// </param>
174 /// <param name="msg">msg to filter on</param> 199 /// <param name="msg">msg to filter on</param>
175 /// <returns>number of the scripts handle</returns> 200 /// <returns>number of the scripts handle</returns>
176 public int Listen(uint localID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg) 201 public int Listen(uint localID, UUID itemID, UUID hostID, int channel,
202 string name, UUID id, string msg)
177 { 203 {
178 return m_listenerManager.AddListener(localID, itemID, hostID, channel, name, id, msg); 204 return m_listenerManager.AddListener(localID, itemID, hostID,
205 channel, name, id, msg);
206 }
207
208 /// <summary>
209 /// Create a listen event callback with the specified filters.
210 /// The parameters localID,itemID are needed to uniquely identify
211 /// the script during 'peek' time. Parameter hostID is needed to
212 /// determine the position of the script.
213 /// </summary>
214 /// <param name="localID">localID of the script engine</param>
215 /// <param name="itemID">UUID of the script engine</param>
216 /// <param name="hostID">UUID of the SceneObjectPart</param>
217 /// <param name="channel">channel to listen on</param>
218 /// <param name="name">name to filter on</param>
219 /// <param name="id">
220 /// key to filter on (user given, could be totally faked)
221 /// </param>
222 /// <param name="msg">msg to filter on</param>
223 /// <param name="regexBitfield">
224 /// Bitfield indicating which strings should be processed as regex.
225 /// </param>
226 /// <returns>number of the scripts handle</returns>
227 public int Listen(uint localID, UUID itemID, UUID hostID, int channel,
228 string name, UUID id, string msg, int regexBitfield)
229 {
230 return m_listenerManager.AddListener(localID, itemID, hostID,
231 channel, name, id, msg, regexBitfield);
179 } 232 }
180 233
181 /// <summary> 234 /// <summary>
@@ -224,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
224 277
225 if ((source = m_scene.GetSceneObjectPart(id)) != null) 278 if ((source = m_scene.GetSceneObjectPart(id)) != null)
226 position = source.AbsolutePosition; 279 position = source.AbsolutePosition;
227 else if ((avatar = m_scene.GetScenePresence(id)) != null) 280 else if ((avatar = m_scene.GetScenePresence(id)) != null)
228 position = avatar.AbsolutePosition; 281 position = avatar.AbsolutePosition;
229 else if (ChatTypeEnum.Region == type) 282 else if (ChatTypeEnum.Region == type)
230 position = CenterOfRegion; 283 position = CenterOfRegion;
@@ -247,7 +300,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
247 /// <param name="name">name of sender (object or avatar)</param> 300 /// <param name="name">name of sender (object or avatar)</param>
248 /// <param name="id">key of sender (object or avatar)</param> 301 /// <param name="id">key of sender (object or avatar)</param>
249 /// <param name="msg">msg to sent</param> 302 /// <param name="msg">msg to sent</param>
250 public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position) 303 public void DeliverMessage(ChatTypeEnum type, int channel,
304 string name, UUID id, string msg, Vector3 position)
251 { 305 {
252 // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", 306 // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}",
253 // type, channel, name, id, msg); 307 // type, channel, name, id, msg);
@@ -255,17 +309,21 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
255 // Determine which listen event filters match the given set of arguments, this results 309 // Determine which listen event filters match the given set of arguments, this results
256 // in a limited set of listeners, each belonging a host. If the host is in range, add them 310 // in a limited set of listeners, each belonging a host. If the host is in range, add them
257 // to the pending queue. 311 // to the pending queue.
258 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 312 foreach (ListenerInfo li
313 in m_listenerManager.GetListeners(UUID.Zero, channel,
314 name, id, msg))
259 { 315 {
260 // Dont process if this message is from yourself! 316 // Dont process if this message is from yourself!
261 if (li.GetHostID().Equals(id)) 317 if (li.GetHostID().Equals(id))
262 continue; 318 continue;
263 319
264 SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); 320 SceneObjectPart sPart = m_scene.GetSceneObjectPart(
321 li.GetHostID());
265 if (sPart == null) 322 if (sPart == null)
266 continue; 323 continue;
267 324
268 double dis = Util.GetDistanceTo(sPart.AbsolutePosition, position); 325 double dis = Util.GetDistanceTo(sPart.AbsolutePosition,
326 position);
269 switch (type) 327 switch (type)
270 { 328 {
271 case ChatTypeEnum.Whisper: 329 case ChatTypeEnum.Whisper:
@@ -308,14 +366,16 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
308 /// <param name='msg'> 366 /// <param name='msg'>
309 /// Message. 367 /// Message.
310 /// </param> 368 /// </param>
311 public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) 369 public void DeliverMessageTo(UUID target, int channel, Vector3 pos,
370 string name, UUID id, string msg)
312 { 371 {
313 // Is id an avatar? 372 // Is id an avatar?
314 ScenePresence sp = m_scene.GetScenePresence(target); 373 ScenePresence sp = m_scene.GetScenePresence(target);
315 374
316 if (sp != null) 375 if (sp != null)
317 { 376 {
318 // ignore if a child agent this is restricted to inside one region 377 // ignore if a child agent this is restricted to inside one
378 // region
319 if (sp.IsChildAgent) 379 if (sp.IsChildAgent)
320 return; 380 return;
321 381
@@ -324,8 +384,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
324 // non zero channel messages only go to the attachments 384 // non zero channel messages only go to the attachments
325 if (channel == 0) 385 if (channel == 0)
326 { 386 {
327 m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); 387 m_scene.SimChatToAgent(target, Utils.StringToBytes(msg),
328 } 388 pos, name, id, false);
389 }
329 else 390 else
330 { 391 {
331 List<SceneObjectGroup> attachments = sp.GetAttachments(); 392 List<SceneObjectGroup> attachments = sp.GetAttachments();
@@ -341,13 +402,18 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
341 } 402 }
342 403
343 // Need to check each attachment 404 // Need to check each attachment
344 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 405 foreach (ListenerInfo li
406 in m_listenerManager.GetListeners(UUID.Zero,
407 channel, name, id, msg))
345 { 408 {
346 if (li.GetHostID().Equals(id)) 409 if (li.GetHostID().Equals(id))
347 continue; 410 continue;
348 411
349 if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) 412 if (m_scene.GetSceneObjectPart(
413 li.GetHostID()) == null)
414 {
350 continue; 415 continue;
416 }
351 417
352 if (targets.Contains(li.GetHostID())) 418 if (targets.Contains(li.GetHostID()))
353 QueueMessage(new ListenerInfo(li, name, id, msg)); 419 QueueMessage(new ListenerInfo(li, name, id, msg));
@@ -358,17 +424,20 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
358 } 424 }
359 425
360 // No avatar found so look for an object 426 // No avatar found so look for an object
361 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 427 foreach (ListenerInfo li
428 in m_listenerManager.GetListeners(UUID.Zero, channel,
429 name, id, msg))
362 { 430 {
363 // Dont process if this message is from yourself! 431 // Dont process if this message is from yourself!
364 if (li.GetHostID().Equals(id)) 432 if (li.GetHostID().Equals(id))
365 continue; 433 continue;
366 434
367 SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); 435 SceneObjectPart sPart = m_scene.GetSceneObjectPart(
436 li.GetHostID());
368 if (sPart == null) 437 if (sPart == null)
369 continue; 438 continue;
370 439
371 if ( li.GetHostID().Equals(target)) 440 if (li.GetHostID().Equals(target))
372 { 441 {
373 QueueMessage(new ListenerInfo(li, name, id, msg)); 442 QueueMessage(new ListenerInfo(li, name, id, msg));
374 break; 443 break;
@@ -422,9 +491,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
422 private void DeliverClientMessage(Object sender, OSChatMessage e) 491 private void DeliverClientMessage(Object sender, OSChatMessage e)
423 { 492 {
424 if (null != e.Sender) 493 if (null != e.Sender)
425 DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position); 494 {
495 DeliverMessage(e.Type, e.Channel, e.Sender.Name,
496 e.Sender.AgentId, e.Message, e.Position);
497 }
426 else 498 else
427 DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position); 499 {
500 DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero,
501 e.Message, e.Position);
502 }
428 } 503 }
429 504
430 public Object[] GetSerializationData(UUID itemID) 505 public Object[] GetSerializationData(UUID itemID)
@@ -441,7 +516,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
441 516
442 public class ListenerManager 517 public class ListenerManager
443 { 518 {
444 private Dictionary<int, List<ListenerInfo>> m_listeners = new Dictionary<int, List<ListenerInfo>>(); 519 private Dictionary<int, List<ListenerInfo>> m_listeners =
520 new Dictionary<int, List<ListenerInfo>>();
445 private int m_maxlisteners; 521 private int m_maxlisteners;
446 private int m_maxhandles; 522 private int m_maxhandles;
447 private int m_curlisteners; 523 private int m_curlisteners;
@@ -465,15 +541,25 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
465 m_curlisteners = 0; 541 m_curlisteners = 0;
466 } 542 }
467 543
468 public int AddListener(uint localID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg) 544 public int AddListener(uint localID, UUID itemID, UUID hostID,
545 int channel, string name, UUID id, string msg)
546 {
547 return AddListener(localID, itemID, hostID, channel, name, id,
548 msg, 0);
549 }
550
551 public int AddListener(uint localID, UUID itemID, UUID hostID,
552 int channel, string name, UUID id, string msg,
553 int regexBitfield)
469 { 554 {
470 // do we already have a match on this particular filter event? 555 // do we already have a match on this particular filter event?
471 List<ListenerInfo> coll = GetListeners(itemID, channel, name, id, msg); 556 List<ListenerInfo> coll = GetListeners(itemID, channel, name, id,
557 msg);
472 558
473 if (coll.Count > 0) 559 if (coll.Count > 0)
474 { 560 {
475 // special case, called with same filter settings, return same handle 561 // special case, called with same filter settings, return same
476 // (2008-05-02, tested on 1.21.1 server, still holds) 562 // handle (2008-05-02, tested on 1.21.1 server, still holds)
477 return coll[0].GetHandle(); 563 return coll[0].GetHandle();
478 } 564 }
479 565
@@ -485,16 +571,19 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
485 571
486 if (newHandle > 0) 572 if (newHandle > 0)
487 { 573 {
488 ListenerInfo li = new ListenerInfo(newHandle, localID, itemID, hostID, channel, name, id, msg); 574 ListenerInfo li = new ListenerInfo(newHandle, localID,
575 itemID, hostID, channel, name, id, msg,
576 regexBitfield);
489 577
490 List<ListenerInfo> listeners; 578 List<ListenerInfo> listeners;
491 if (!m_listeners.TryGetValue(channel,out listeners)) 579 if (!m_listeners.TryGetValue(
492 { 580 channel, out listeners))
493 listeners = new List<ListenerInfo>(); 581 {
494 m_listeners.Add(channel, listeners); 582 listeners = new List<ListenerInfo>();
495 } 583 m_listeners.Add(channel, listeners);
496 listeners.Add(li); 584 }
497 m_curlisteners++; 585 listeners.Add(li);
586 m_curlisteners++;
498 587
499 return newHandle; 588 return newHandle;
500 } 589 }
@@ -507,11 +596,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
507 { 596 {
508 lock (m_listeners) 597 lock (m_listeners)
509 { 598 {
510 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 599 foreach (KeyValuePair<int, List<ListenerInfo>> lis
600 in m_listeners)
511 { 601 {
512 foreach (ListenerInfo li in lis.Value) 602 foreach (ListenerInfo li in lis.Value)
513 { 603 {
514 if (li.GetItemID().Equals(itemID) && li.GetHandle().Equals(handle)) 604 if (li.GetItemID().Equals(itemID) &&
605 li.GetHandle().Equals(handle))
515 { 606 {
516 lis.Value.Remove(li); 607 lis.Value.Remove(li);
517 if (lis.Value.Count == 0) 608 if (lis.Value.Count == 0)
@@ -534,13 +625,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
534 625
535 lock (m_listeners) 626 lock (m_listeners)
536 { 627 {
537 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 628 foreach (KeyValuePair<int, List<ListenerInfo>> lis
629 in m_listeners)
538 { 630 {
539 foreach (ListenerInfo li in lis.Value) 631 foreach (ListenerInfo li in lis.Value)
540 { 632 {
541 if (li.GetItemID().Equals(itemID)) 633 if (li.GetItemID().Equals(itemID))
542 { 634 {
543 // store them first, else the enumerated bails on us 635 // store them first, else the enumerated bails on
636 // us
544 removedListeners.Add(li); 637 removedListeners.Add(li);
545 } 638 }
546 } 639 }
@@ -567,11 +660,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
567 { 660 {
568 lock (m_listeners) 661 lock (m_listeners)
569 { 662 {
570 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 663 foreach (KeyValuePair<int, List<ListenerInfo>> lis
664 in m_listeners)
571 { 665 {
572 foreach (ListenerInfo li in lis.Value) 666 foreach (ListenerInfo li in lis.Value)
573 { 667 {
574 if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) 668 if (li.GetItemID().Equals(itemID) &&
669 li.GetHandle() == handle)
575 { 670 {
576 li.Activate(); 671 li.Activate();
577 // only one, bail out 672 // only one, bail out
@@ -586,11 +681,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
586 { 681 {
587 lock (m_listeners) 682 lock (m_listeners)
588 { 683 {
589 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 684 foreach (KeyValuePair<int, List<ListenerInfo>> lis
685 in m_listeners)
590 { 686 {
591 foreach (ListenerInfo li in lis.Value) 687 foreach (ListenerInfo li in lis.Value)
592 { 688 {
593 if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) 689 if (li.GetItemID().Equals(itemID) &&
690 li.GetHandle() == handle)
594 { 691 {
595 li.Deactivate(); 692 li.Deactivate();
596 // only one, bail out 693 // only one, bail out
@@ -601,19 +698,24 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
601 } 698 }
602 } 699 }
603 700
604 // non-locked access, since its always called in the context of the lock 701 /// <summary>
702 /// non-locked access, since its always called in the context of the
703 /// lock
704 /// </summary>
705 /// <param name="itemID"></param>
706 /// <returns></returns>
605 private int GetNewHandle(UUID itemID) 707 private int GetNewHandle(UUID itemID)
606 { 708 {
607 List<int> handles = new List<int>(); 709 List<int> handles = new List<int>();
608 710
609 // build a list of used keys for this specific itemID... 711 // build a list of used keys for this specific itemID...
610 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 712 foreach (KeyValuePair<int, List<ListenerInfo>> lis in m_listeners)
611 { 713 {
612 foreach (ListenerInfo li in lis.Value) 714 foreach (ListenerInfo li in lis.Value)
613 { 715 {
614 if (li.GetItemID().Equals(itemID)) 716 if (li.GetItemID().Equals(itemID))
615 handles.Add(li.GetHandle()); 717 handles.Add(li.GetHandle());
616 } 718 }
617 } 719 }
618 720
619 // Note: 0 is NOT a valid handle for llListen() to return 721 // Note: 0 is NOT a valid handle for llListen() to return
@@ -626,17 +728,46 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
626 return -1; 728 return -1;
627 } 729 }
628 730
629 // Theres probably a more clever and efficient way to 731 /// These are duplicated from ScriptBaseClass
630 // do this, maybe with regex. 732 /// http://opensimulator.org/mantis/view.php?id=6106#c21945
631 // PM2008: Ha, one could even be smart and define a specialized Enumerator. 733 #region Constants for the bitfield parameter of osListenRegex
632 public List<ListenerInfo> GetListeners(UUID itemID, int channel, string name, UUID id, string msg) 734
735 /// <summary>
736 /// process name parameter as regex
737 /// </summary>
738 public const int OS_LISTEN_REGEX_NAME = 0x1;
739
740 /// <summary>
741 /// process message parameter as regex
742 /// </summary>
743 public const int OS_LISTEN_REGEX_MESSAGE = 0x2;
744
745 #endregion
746
747 /// <summary>
748 /// Get listeners matching the input parameters.
749 /// </summary>
750 /// <remarks>
751 /// Theres probably a more clever and efficient way to do this, maybe
752 /// with regex.
753 /// PM2008: Ha, one could even be smart and define a specialized
754 /// Enumerator.
755 /// </remarks>
756 /// <param name="itemID"></param>
757 /// <param name="channel"></param>
758 /// <param name="name"></param>
759 /// <param name="id"></param>
760 /// <param name="msg"></param>
761 /// <returns></returns>
762 public List<ListenerInfo> GetListeners(UUID itemID, int channel,
763 string name, UUID id, string msg)
633 { 764 {
634 List<ListenerInfo> collection = new List<ListenerInfo>(); 765 List<ListenerInfo> collection = new List<ListenerInfo>();
635 766
636 lock (m_listeners) 767 lock (m_listeners)
637 { 768 {
638 List<ListenerInfo> listeners; 769 List<ListenerInfo> listeners;
639 if (!m_listeners.TryGetValue(channel,out listeners)) 770 if (!m_listeners.TryGetValue(channel, out listeners))
640 { 771 {
641 return collection; 772 return collection;
642 } 773 }
@@ -647,11 +778,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
647 { 778 {
648 continue; 779 continue;
649 } 780 }
650 if (!itemID.Equals(UUID.Zero) && !li.GetItemID().Equals(itemID)) 781 if (!itemID.Equals(UUID.Zero) &&
782 !li.GetItemID().Equals(itemID))
651 { 783 {
652 continue; 784 continue;
653 } 785 }
654 if (li.GetName().Length > 0 && !li.GetName().Equals(name)) 786 if (li.GetName().Length > 0 && (
787 ((li.RegexBitfield & OS_LISTEN_REGEX_NAME) != OS_LISTEN_REGEX_NAME && !li.GetName().Equals(name)) ||
788 ((li.RegexBitfield & OS_LISTEN_REGEX_NAME) == OS_LISTEN_REGEX_NAME && !Regex.IsMatch(name, li.GetName()))
789 ))
655 { 790 {
656 continue; 791 continue;
657 } 792 }
@@ -659,7 +794,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
659 { 794 {
660 continue; 795 continue;
661 } 796 }
662 if (li.GetMessage().Length > 0 && !li.GetMessage().Equals(msg)) 797 if (li.GetMessage().Length > 0 && (
798 ((li.RegexBitfield & OS_LISTEN_REGEX_MESSAGE) != OS_LISTEN_REGEX_MESSAGE && !li.GetMessage().Equals(msg)) ||
799 ((li.RegexBitfield & OS_LISTEN_REGEX_MESSAGE) == OS_LISTEN_REGEX_MESSAGE && !Regex.IsMatch(msg, li.GetMessage()))
800 ))
663 { 801 {
664 continue; 802 continue;
665 } 803 }
@@ -692,10 +830,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
692 { 830 {
693 int idx = 0; 831 int idx = 0;
694 Object[] item = new Object[6]; 832 Object[] item = new Object[6];
833 int dataItemLength = 6;
695 834
696 while (idx < data.Length) 835 while (idx < data.Length)
697 { 836 {
698 Array.Copy(data, idx, item, 0, 6); 837 dataItemLength = (idx + 7 == data.Length || (idx + 7 < data.Length && data[idx + 7] is bool)) ? 7 : 6;
838 item = new Object[dataItemLength];
839 Array.Copy(data, idx, item, 0, dataItemLength);
699 840
700 ListenerInfo info = 841 ListenerInfo info =
701 ListenerInfo.FromData(localID, itemID, hostID, item); 842 ListenerInfo.FromData(localID, itemID, hostID, item);
@@ -703,39 +844,98 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
703 lock (m_listeners) 844 lock (m_listeners)
704 { 845 {
705 if (!m_listeners.ContainsKey((int)item[2])) 846 if (!m_listeners.ContainsKey((int)item[2]))
706 m_listeners.Add((int)item[2], new List<ListenerInfo>()); 847 {
848 m_listeners.Add((int)item[2],
849 new List<ListenerInfo>());
850 }
707 m_listeners[(int)item[2]].Add(info); 851 m_listeners[(int)item[2]].Add(info);
708 } 852 }
709 853
710 idx+=6; 854 idx += dataItemLength;
711 } 855 }
712 } 856 }
713 } 857 }
714 858
715 public class ListenerInfo: IWorldCommListenerInfo 859 public class ListenerInfo : IWorldCommListenerInfo
716 { 860 {
717 private bool m_active; // Listener is active or not 861 /// <summary>
718 private int m_handle; // Assigned handle of this listener 862 /// Listener is active or not
719 private uint m_localID; // Local ID from script engine 863 /// </summary>
720 private UUID m_itemID; // ID of the host script engine 864 private bool m_active;
721 private UUID m_hostID; // ID of the host/scene part
722 private int m_channel; // Channel
723 private UUID m_id; // ID to filter messages from
724 private string m_name; // Object name to filter messages from
725 private string m_message; // The message
726 865
727 public ListenerInfo(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message) 866 /// <summary>
867 /// Assigned handle of this listener
868 /// </summary>
869 private int m_handle;
870
871 /// <summary>
872 /// Local ID from script engine
873 /// </summary>
874 private uint m_localID;
875
876 /// <summary>
877 /// ID of the host script engine
878 /// </summary>
879 private UUID m_itemID;
880
881 /// <summary>
882 /// ID of the host/scene part
883 /// </summary>
884 private UUID m_hostID;
885
886 /// <summary>
887 /// Channel
888 /// </summary>
889 private int m_channel;
890
891 /// <summary>
892 /// ID to filter messages from
893 /// </summary>
894 private UUID m_id;
895
896 /// <summary>
897 /// Object name to filter messages from
898 /// </summary>
899 private string m_name;
900
901 /// <summary>
902 /// The message
903 /// </summary>
904 private string m_message;
905
906 public ListenerInfo(int handle, uint localID, UUID ItemID,
907 UUID hostID, int channel, string name, UUID id,
908 string message)
909 {
910 Initialise(handle, localID, ItemID, hostID, channel, name, id,
911 message, 0);
912 }
913
914 public ListenerInfo(int handle, uint localID, UUID ItemID,
915 UUID hostID, int channel, string name, UUID id,
916 string message, int regexBitfield)
728 { 917 {
729 Initialise(handle, localID, ItemID, hostID, channel, name, id, message); 918 Initialise(handle, localID, ItemID, hostID, channel, name, id,
919 message, regexBitfield);
730 } 920 }
731 921
732 public ListenerInfo(ListenerInfo li, string name, UUID id, string message) 922 public ListenerInfo(ListenerInfo li, string name, UUID id,
923 string message)
733 { 924 {
734 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message); 925 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID,
926 li.m_channel, name, id, message, 0);
735 } 927 }
736 928
737 private void Initialise(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, 929 public ListenerInfo(ListenerInfo li, string name, UUID id,
738 UUID id, string message) 930 string message, int regexBitfield)
931 {
932 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID,
933 li.m_channel, name, id, message, regexBitfield);
934 }
935
936 private void Initialise(int handle, uint localID, UUID ItemID,
937 UUID hostID, int channel, string name, UUID id,
938 string message, int regexBitfield)
739 { 939 {
740 m_active = true; 940 m_active = true;
741 m_handle = handle; 941 m_handle = handle;
@@ -746,11 +946,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
746 m_name = name; 946 m_name = name;
747 m_id = id; 947 m_id = id;
748 m_message = message; 948 m_message = message;
949 RegexBitfield = regexBitfield;
749 } 950 }
750 951
751 public Object[] GetSerializationData() 952 public Object[] GetSerializationData()
752 { 953 {
753 Object[] data = new Object[6]; 954 Object[] data = new Object[7];
754 955
755 data[0] = m_active; 956 data[0] = m_active;
756 data[1] = m_handle; 957 data[1] = m_handle;
@@ -758,16 +959,22 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
758 data[3] = m_name; 959 data[3] = m_name;
759 data[4] = m_id; 960 data[4] = m_id;
760 data[5] = m_message; 961 data[5] = m_message;
962 data[6] = RegexBitfield;
761 963
762 return data; 964 return data;
763 } 965 }
764 966
765 public static ListenerInfo FromData(uint localID, UUID ItemID, UUID hostID, Object[] data) 967 public static ListenerInfo FromData(uint localID, UUID ItemID,
968 UUID hostID, Object[] data)
766 { 969 {
767 ListenerInfo linfo = new ListenerInfo((int)data[1], localID, 970 ListenerInfo linfo = new ListenerInfo((int)data[1], localID,
768 ItemID, hostID, (int)data[2], (string)data[3], 971 ItemID, hostID, (int)data[2], (string)data[3],
769 (UUID)data[4], (string)data[5]); 972 (UUID)data[4], (string)data[5]);
770 linfo.m_active=(bool)data[0]; 973 linfo.m_active = (bool)data[0];
974 if (data.Length >= 7)
975 {
976 linfo.RegexBitfield = (int)data[6];
977 }
771 978
772 return linfo; 979 return linfo;
773 } 980 }
@@ -826,5 +1033,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
826 { 1033 {
827 return m_id; 1034 return m_id;
828 } 1035 }
1036
1037 public int RegexBitfield { get; private set; }
829 } 1038 }
830} 1039}
diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
index 0003af2..385f5ad 100644
--- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework.Servers;
40using OpenSim.Framework.Servers.HttpServer; 40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using Mono.Addins;
43 44
44/***************************************************** 45/*****************************************************
45 * 46 *
@@ -76,7 +77,8 @@ using OpenSim.Region.Framework.Scenes;
76 77
77namespace OpenSim.Region.CoreModules.Scripting.XMLRPC 78namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
78{ 79{
79 public class XMLRPCModule : IRegionModule, IXMLRPC 80 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XMLRPCModule")]
81 public class XMLRPCModule : ISharedRegionModule, IXMLRPC
80 { 82 {
81 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 83 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
82 84
@@ -86,6 +88,10 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
86 private Dictionary<UUID, RPCChannelInfo> m_openChannels; 88 private Dictionary<UUID, RPCChannelInfo> m_openChannels;
87 private Dictionary<UUID, SendRemoteDataRequest> m_pendingSRDResponses; 89 private Dictionary<UUID, SendRemoteDataRequest> m_pendingSRDResponses;
88 private int m_remoteDataPort = 0; 90 private int m_remoteDataPort = 0;
91 public int Port
92 {
93 get { return m_remoteDataPort; }
94 }
89 95
90 private Dictionary<UUID, RPCRequestInfo> m_rpcPending; 96 private Dictionary<UUID, RPCRequestInfo> m_rpcPending;
91 private Dictionary<UUID, RPCRequestInfo> m_rpcPendingResponses; 97 private Dictionary<UUID, RPCRequestInfo> m_rpcPendingResponses;
@@ -94,34 +100,24 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
94 private int RemoteReplyScriptWait = 300; 100 private int RemoteReplyScriptWait = 300;
95 private object XMLRPCListLock = new object(); 101 private object XMLRPCListLock = new object();
96 102
97 #region IRegionModule Members 103 #region ISharedRegionModule Members
98 104
99 public void Initialise(Scene scene, IConfigSource config) 105 public void Initialise(IConfigSource config)
100 { 106 {
101 // We need to create these early because the scripts might be calling 107 // We need to create these early because the scripts might be calling
102 // But since this gets called for every region, we need to make sure they 108 // But since this gets called for every region, we need to make sure they
103 // get called only one time (or we lose any open channels) 109 // get called only one time (or we lose any open channels)
104 if (null == m_openChannels) 110 m_openChannels = new Dictionary<UUID, RPCChannelInfo>();
105 { 111 m_rpcPending = new Dictionary<UUID, RPCRequestInfo>();
106 m_openChannels = new Dictionary<UUID, RPCChannelInfo>(); 112 m_rpcPendingResponses = new Dictionary<UUID, RPCRequestInfo>();
107 m_rpcPending = new Dictionary<UUID, RPCRequestInfo>(); 113 m_pendingSRDResponses = new Dictionary<UUID, SendRemoteDataRequest>();
108 m_rpcPendingResponses = new Dictionary<UUID, RPCRequestInfo>();
109 m_pendingSRDResponses = new Dictionary<UUID, SendRemoteDataRequest>();
110 114
111 try 115 try
112 { 116 {
113 m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort); 117 m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort);
114 }
115 catch (Exception)
116 {
117 }
118 } 118 }
119 119 catch (Exception)
120 if (!m_scenes.Contains(scene))
121 { 120 {
122 m_scenes.Add(scene);
123
124 scene.RegisterModuleInterface<IXMLRPC>(this);
125 } 121 }
126 } 122 }
127 123
@@ -131,32 +127,56 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
131 { 127 {
132 // Start http server 128 // Start http server
133 // Attach xmlrpc handlers 129 // Attach xmlrpc handlers
134// m_log.InfoFormat( 130 // m_log.InfoFormat(
135// "[XML RPC MODULE]: Starting up XMLRPC Server on port {0} for llRemoteData commands.", 131 // "[XML RPC MODULE]: Starting up XMLRPC Server on port {0} for llRemoteData commands.",
136// m_remoteDataPort); 132 // m_remoteDataPort);
137 133
138 IHttpServer httpServer = MainServer.GetHttpServer((uint)m_remoteDataPort); 134 IHttpServer httpServer = MainServer.GetHttpServer((uint)m_remoteDataPort);
139 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); 135 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
140 } 136 }
141 } 137 }
142 138
143 public void Close() 139 public void AddRegion(Scene scene)
140 {
141 if (!IsEnabled())
142 return;
143
144 if (!m_scenes.Contains(scene))
145 {
146 m_scenes.Add(scene);
147
148 scene.RegisterModuleInterface<IXMLRPC>(this);
149 }
150 }
151
152 public void RegionLoaded(Scene scene)
144 { 153 {
145 } 154 }
146 155
147 public string Name 156 public void RemoveRegion(Scene scene)
148 { 157 {
149 get { return m_name; } 158 if (!IsEnabled())
159 return;
160
161 if (m_scenes.Contains(scene))
162 {
163 scene.UnregisterModuleInterface<IXMLRPC>(this);
164 m_scenes.Remove(scene);
165 }
150 } 166 }
151 167
152 public bool IsSharedModule 168 public void Close()
153 { 169 {
154 get { return true; }
155 } 170 }
156 171
157 public int Port 172 public string Name
158 { 173 {
159 get { return m_remoteDataPort; } 174 get { return m_name; }
175 }
176
177 public Type ReplaceableInterface
178 {
179 get { return null; }
160 } 180 }
161 181
162 #endregion 182 #endregion