aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2012-11-11 16:31:01 +0000
committerMelanie2012-11-11 16:31:01 +0000
commit389077345f9fc78fddcaa39e29daa532a32815d6 (patch)
treea455d88d93ac5fe984ebf5342276ca1ddc831442
parentMerge branch 'master' into careminster (diff)
parentDeleted 2 obsolete modules: OGSRadmin and OpenGridProtocol. They were still I... (diff)
downloadopensim-SC_OLD-389077345f9fc78fddcaa39e29daa532a32815d6.zip
opensim-SC_OLD-389077345f9fc78fddcaa39e29daa532a32815d6.tar.gz
opensim-SC_OLD-389077345f9fc78fddcaa39e29daa532a32815d6.tar.bz2
opensim-SC_OLD-389077345f9fc78fddcaa39e29daa532a32815d6.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs87
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs117
-rw-r--r--OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs24
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs42
-rw-r--r--OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs33
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs37
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs29
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs144
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs33
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs50
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs50
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs39
-rw-r--r--OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs211
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs150
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs1297
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml7
-rw-r--r--OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs262
-rw-r--r--OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs53
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs62
-rw-r--r--OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/Wind/WindModule.cs182
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs70
-rw-r--r--OpenSim/Region/DataSnapshot/DataSnapshotManager.cs158
-rw-r--r--OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs1
-rw-r--r--OpenSim/Region/Framework/Interfaces/ICloudModule.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IDialogModule.cs157
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISunModule.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWindModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs90
-rw-r--r--OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml1
-rw-r--r--OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs30
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs18
-rw-r--r--bin/OpenSimDefaults.ini3
35 files changed, 1319 insertions, 2169 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 5bbdce8..05d5577 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -55,8 +55,8 @@ namespace OpenSim.Region.ClientStack.Linden
55 public OSDMap body; 55 public OSDMap body;
56 } 56 }
57 57
58 //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 58 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
59 public class EventQueueGetModule : IEventQueue, IRegionModule 59 public class EventQueueGetModule : IEventQueue, INonSharedRegionModule
60 { 60 {
61 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 61 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
62 62
@@ -66,8 +66,6 @@ namespace OpenSim.Region.ClientStack.Linden
66 public int DebugLevel { get; set; } 66 public int DebugLevel { get; set; }
67 67
68 protected Scene m_scene; 68 protected Scene m_scene;
69 private IConfigSource m_gConfig;
70 bool enabledYN;
71 69
72 private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); 70 private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>();
73 71
@@ -75,60 +73,46 @@ namespace OpenSim.Region.ClientStack.Linden
75 private Dictionary<UUID, UUID> m_QueueUUIDAvatarMapping = new Dictionary<UUID, UUID>(); 73 private Dictionary<UUID, UUID> m_QueueUUIDAvatarMapping = new Dictionary<UUID, UUID>();
76 private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>(); 74 private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>();
77 75
78 #region IRegionModule methods 76 #region INonSharedRegionModule methods
79 public virtual void Initialise(Scene scene, IConfigSource config) 77 public virtual void Initialise(IConfigSource config)
80 { 78 {
81 m_gConfig = config; 79 }
82
83 IConfig startupConfig = m_gConfig.Configs["Startup"];
84
85 ReadConfigAndPopulate(scene, startupConfig, "Startup");
86
87 if (enabledYN)
88 {
89 m_scene = scene;
90 scene.RegisterModuleInterface<IEventQueue>(this);
91
92 // Register fallback handler
93 // Why does EQG Fail on region crossings!
94
95 //scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack);
96 80
97// scene.EventManager.OnNewClient += OnNewClient; 81 public void AddRegion(Scene scene)
82 {
83 m_scene = scene;
84 scene.RegisterModuleInterface<IEventQueue>(this);
98 85
99 // TODO: Leaving these open, or closing them when we 86 scene.EventManager.OnClientClosed += ClientClosed;
100 // become a child is incorrect. It messes up TP in a big 87 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
101 // way. CAPS/EQ need to be active as long as the UDP 88 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
102 // circuit is there.
103 89
104 scene.EventManager.OnClientClosed += ClientClosed; 90 MainConsole.Instance.Commands.AddCommand(
105 91 "Debug",
106 scene.EventManager.OnMakeChildAgent += MakeChildAgent; 92 false,
107 scene.EventManager.OnRegisterCaps += OnRegisterCaps; 93 "debug eq",
108 94 "debug eq [0|1|2]",
109 MainConsole.Instance.Commands.AddCommand( 95 "Turn on event queue debugging\n"
110 "Debug", 96 + " <= 0 - turns off all event queue logging\n"
111 false, 97 + " >= 1 - turns on outgoing event logging\n"
112 "debug eq", 98 + " >= 2 - turns on poll notification",
113 "debug eq [0|1|2]", 99 HandleDebugEq);
114 "Turn on event queue debugging\n"
115 + " <= 0 - turns off all event queue logging\n"
116 + " >= 1 - turns on outgoing event logging\n"
117 + " >= 2 - turns on poll notification",
118 HandleDebugEq);
119 }
120 else
121 {
122 m_gConfig = null;
123 }
124 } 100 }
125 101
126 private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p) 102 public void RemoveRegion(Scene scene)
127 { 103 {
128 enabledYN = startupConfig.GetBoolean("EventQueue", true); 104 if (m_scene != scene)
105 return;
106
107 scene.EventManager.OnClientClosed -= ClientClosed;
108 scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
109 scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
110
111 scene.UnregisterModuleInterface<IEventQueue>(this);
112 m_scene = null;
129 } 113 }
130 114
131 public void PostInitialise() 115 public void RegionLoaded(Scene scene)
132 { 116 {
133 } 117 }
134 118
@@ -141,10 +125,11 @@ namespace OpenSim.Region.ClientStack.Linden
141 get { return "EventQueueGetModule"; } 125 get { return "EventQueueGetModule"; }
142 } 126 }
143 127
144 public bool IsSharedModule 128 public Type ReplaceableInterface
145 { 129 {
146 get { return false; } 130 get { return null; }
147 } 131 }
132
148 #endregion 133 #endregion
149 134
150 protected void HandleDebugEq(string module, string[] args) 135 protected void HandleDebugEq(string module, string[] args)
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
index 4ccfc43..642d8b4 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
@@ -32,6 +32,7 @@ using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenMetaverse.StructuredData; 34using OpenMetaverse.StructuredData;
35using Mono.Addins;
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
37using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
@@ -41,30 +42,60 @@ using Caps=OpenSim.Framework.Capabilities.Caps;
41 42
42namespace OpenSim.Region.ClientStack.Linden 43namespace OpenSim.Region.ClientStack.Linden
43{ 44{
44 public class ObjectAdd : IRegionModule 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
46 public class ObjectAdd : INonSharedRegionModule
45 { 47 {
46// private static readonly ILog m_log = 48// private static readonly ILog m_log =
47// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 50
49 private Scene m_scene; 51 private Scene m_scene;
50 #region IRegionModule Members
51 52
52 public void Initialise(Scene pScene, IConfigSource pSource) 53 #region INonSharedRegionModule Members
54
55 public void Initialise(IConfigSource pSource)
56 {
57 }
58
59 public void AddRegion(Scene scene)
53 { 60 {
54 m_scene = pScene; 61 m_scene = scene;
55 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 62 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
56 } 63 }
57 64
58 public void PostInitialise() 65 public void RemoveRegion(Scene scene)
59 { 66 {
60 67 if (m_scene == scene)
68 {
69 m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
70 m_scene = null;
71 }
61 } 72 }
62 73
74 public void RegionLoaded(Scene scene)
75 {
76 }
77
78 public void Close()
79 {
80 }
81
82 public string Name
83 {
84 get { return "ObjectAddModule"; }
85 }
86
87 public Type ReplaceableInterface
88 {
89 get { return null; }
90 }
91
92 #endregion
93
63 public void RegisterCaps(UUID agentID, Caps caps) 94 public void RegisterCaps(UUID agentID, Caps caps)
64 { 95 {
65 UUID capuuid = UUID.Random(); 96 UUID capuuid = UUID.Random();
66 97
67// m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/"); 98 // m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/");
68 99
69 caps.RegisterHandler( 100 caps.RegisterHandler(
70 "ObjectAdd", 101 "ObjectAdd",
@@ -73,7 +104,7 @@ namespace OpenSim.Region.ClientStack.Linden
73 "/CAPS/OA/" + capuuid + "/", 104 "/CAPS/OA/" + capuuid + "/",
74 httpMethod => ProcessAdd(httpMethod, agentID, caps), 105 httpMethod => ProcessAdd(httpMethod, agentID, caps),
75 "ObjectAdd", 106 "ObjectAdd",
76 agentID.ToString()));; 107 agentID.ToString())); ;
77 } 108 }
78 109
79 public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) 110 public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap)
@@ -84,7 +115,7 @@ namespace OpenSim.Region.ClientStack.Linden
84 responsedata["keepalive"] = false; 115 responsedata["keepalive"] = false;
85 responsedata["str_response_string"] = "Request wasn't what was expected"; 116 responsedata["str_response_string"] = "Request wasn't what was expected";
86 ScenePresence avatar; 117 ScenePresence avatar;
87 118
88 if (!m_scene.TryGetScenePresence(AgentId, out avatar)) 119 if (!m_scene.TryGetScenePresence(AgentId, out avatar))
89 return responsedata; 120 return responsedata;
90 121
@@ -127,7 +158,7 @@ namespace OpenSim.Region.ClientStack.Linden
127 158
128 if (r.Type != OSDType.Map) // not a proper req 159 if (r.Type != OSDType.Map) // not a proper req
129 return responsedata; 160 return responsedata;
130 161
131 OSDMap rm = (OSDMap)r; 162 OSDMap rm = (OSDMap)r;
132 163
133 if (rm.ContainsKey("ObjectData")) //v2 164 if (rm.ContainsKey("ObjectData")) //v2
@@ -138,7 +169,7 @@ namespace OpenSim.Region.ClientStack.Linden
138 return responsedata; 169 return responsedata;
139 } 170 }
140 171
141 OSDMap ObjMap = (OSDMap) rm["ObjectData"]; 172 OSDMap ObjMap = (OSDMap)rm["ObjectData"];
142 173
143 bypass_raycast = ObjMap["BypassRaycast"].AsBoolean(); 174 bypass_raycast = ObjMap["BypassRaycast"].AsBoolean();
144 everyone_mask = readuintval(ObjMap["EveryoneMask"]); 175 everyone_mask = readuintval(ObjMap["EveryoneMask"]);
@@ -181,7 +212,7 @@ namespace OpenSim.Region.ClientStack.Linden
181 responsedata["str_response_string"] = "Has Profile key, but data not in expected format"; 212 responsedata["str_response_string"] = "Has Profile key, but data not in expected format";
182 return responsedata; 213 return responsedata;
183 } 214 }
184 215
185 OSDMap ProfileMap = (OSDMap)ObjMap["Profile"]; 216 OSDMap ProfileMap = (OSDMap)ObjMap["Profile"];
186 217
187 profile_begin = ProfileMap["Begin"].AsInteger(); 218 profile_begin = ProfileMap["Begin"].AsInteger();
@@ -190,14 +221,14 @@ namespace OpenSim.Region.ClientStack.Linden
190 hollow = ProfileMap["Hollow"].AsInteger(); 221 hollow = ProfileMap["Hollow"].AsInteger();
191 } 222 }
192 ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean(); 223 ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean();
193 224
194 ray_target_id = ObjMap["RayTargetId"].AsUUID(); 225 ray_target_id = ObjMap["RayTargetId"].AsUUID();
195 state = ObjMap["State"].AsInteger(); 226 state = ObjMap["State"].AsInteger();
196 try 227 try
197 { 228 {
198 ray_end = ((OSDArray) ObjMap["RayEnd"]).AsVector3(); 229 ray_end = ((OSDArray)ObjMap["RayEnd"]).AsVector3();
199 ray_start = ((OSDArray) ObjMap["RayStart"]).AsVector3(); 230 ray_start = ((OSDArray)ObjMap["RayStart"]).AsVector3();
200 scale = ((OSDArray) ObjMap["Scale"]).AsVector3(); 231 scale = ((OSDArray)ObjMap["Scale"]).AsVector3();
201 rotation = ((OSDArray)ObjMap["Rotation"]).AsQuaternion(); 232 rotation = ((OSDArray)ObjMap["Rotation"]).AsQuaternion();
202 } 233 }
203 catch (Exception) 234 catch (Exception)
@@ -214,7 +245,7 @@ namespace OpenSim.Region.ClientStack.Linden
214 return responsedata; 245 return responsedata;
215 } 246 }
216 247
217 OSDMap AgentDataMap = (OSDMap) rm["AgentData"]; 248 OSDMap AgentDataMap = (OSDMap)rm["AgentData"];
218 249
219 //session_id = AgentDataMap["SessionId"].AsUUID(); 250 //session_id = AgentDataMap["SessionId"].AsUUID();
220 group_id = AgentDataMap["GroupId"].AsUUID(); 251 group_id = AgentDataMap["GroupId"].AsUUID();
@@ -251,21 +282,21 @@ namespace OpenSim.Region.ClientStack.Linden
251 profile_begin = rm["profile_begin"].AsInteger(); 282 profile_begin = rm["profile_begin"].AsInteger();
252 profile_curve = rm["profile_curve"].AsInteger(); 283 profile_curve = rm["profile_curve"].AsInteger();
253 profile_end = rm["profile_end"].AsInteger(); 284 profile_end = rm["profile_end"].AsInteger();
254 285
255 ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean(); 286 ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean();
256 287
257 ray_target_id = rm["ray_target_id"].AsUUID(); 288 ray_target_id = rm["ray_target_id"].AsUUID();
258 289
259 290
260 //session_id = rm["session_id"].AsUUID(); 291 //session_id = rm["session_id"].AsUUID();
261 state = rm["state"].AsInteger(); 292 state = rm["state"].AsInteger();
262 try 293 try
263 { 294 {
264 ray_end = ((OSDArray)rm["ray_end"]).AsVector3(); 295 ray_end = ((OSDArray)rm["ray_end"]).AsVector3();
265 ray_start = ((OSDArray)rm["ray_start"]).AsVector3(); 296 ray_start = ((OSDArray)rm["ray_start"]).AsVector3();
266 rotation = ((OSDArray)rm["rotation"]).AsQuaternion(); 297 rotation = ((OSDArray)rm["rotation"]).AsQuaternion();
267 scale = ((OSDArray)rm["scale"]).AsVector3(); 298 scale = ((OSDArray)rm["scale"]).AsVector3();
268 } 299 }
269 catch (Exception) 300 catch (Exception)
270 { 301 {
271 responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format"; 302 responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format";
@@ -273,9 +304,9 @@ namespace OpenSim.Region.ClientStack.Linden
273 } 304 }
274 } 305 }
275 306
276
277 307
278 Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false); 308
309 Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false);
279 310
280 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); 311 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
281 312
@@ -286,17 +317,17 @@ namespace OpenSim.Region.ClientStack.Linden
286 pbs.PathRevolutions = (byte)path_revolutions; 317 pbs.PathRevolutions = (byte)path_revolutions;
287 pbs.PathScaleX = (byte)path_scale_x; 318 pbs.PathScaleX = (byte)path_scale_x;
288 pbs.PathScaleY = (byte)path_scale_y; 319 pbs.PathScaleY = (byte)path_scale_y;
289 pbs.PathShearX = (byte) path_shear_x; 320 pbs.PathShearX = (byte)path_shear_x;
290 pbs.PathShearY = (byte)path_shear_y; 321 pbs.PathShearY = (byte)path_shear_y;
291 pbs.PathSkew = (sbyte)path_skew; 322 pbs.PathSkew = (sbyte)path_skew;
292 pbs.PathTaperX = (sbyte)path_taper_x; 323 pbs.PathTaperX = (sbyte)path_taper_x;
293 pbs.PathTaperY = (sbyte)path_taper_y; 324 pbs.PathTaperY = (sbyte)path_taper_y;
294 pbs.PathTwist = (sbyte)path_twist; 325 pbs.PathTwist = (sbyte)path_twist;
295 pbs.PathTwistBegin = (sbyte)path_twist_begin; 326 pbs.PathTwistBegin = (sbyte)path_twist_begin;
296 pbs.HollowShape = (HollowShape) hollow; 327 pbs.HollowShape = (HollowShape)hollow;
297 pbs.PCode = (byte)p_code; 328 pbs.PCode = (byte)p_code;
298 pbs.ProfileBegin = (ushort) profile_begin; 329 pbs.ProfileBegin = (ushort)profile_begin;
299 pbs.ProfileCurve = (byte) profile_curve; 330 pbs.ProfileCurve = (byte)profile_curve;
300 pbs.ProfileEnd = (ushort)profile_end; 331 pbs.ProfileEnd = (ushort)profile_end;
301 pbs.Scale = scale; 332 pbs.Scale = scale;
302 pbs.State = (byte)state; 333 pbs.State = (byte)state;
@@ -306,7 +337,7 @@ namespace OpenSim.Region.ClientStack.Linden
306 if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) 337 if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
307 { 338 {
308 // rez ON the ground, not IN the ground 339 // rez ON the ground, not IN the ground
309 // pos.Z += 0.25F; 340 // pos.Z += 0.25F;
310 341
311 obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs); 342 obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs);
312 } 343 }
@@ -323,13 +354,13 @@ namespace OpenSim.Region.ClientStack.Linden
323 rootpart.GroupMask = group_mask; 354 rootpart.GroupMask = group_mask;
324 rootpart.NextOwnerMask = next_owner_mask; 355 rootpart.NextOwnerMask = next_owner_mask;
325 rootpart.Material = (byte)material; 356 rootpart.Material = (byte)material;
326 357
327 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); 358 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
328 359
329 responsedata["int_response_code"] = 200; //501; //410; //404; 360 responsedata["int_response_code"] = 200; //501; //410; //404;
330 responsedata["content_type"] = "text/plain"; 361 responsedata["content_type"] = "text/plain";
331 responsedata["keepalive"] = false; 362 responsedata["keepalive"] = false;
332 responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>",ConvertUintToBytes(obj.LocalId)); 363 responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(obj.LocalId));
333 364
334 return responsedata; 365 return responsedata;
335 } 366 }
@@ -347,24 +378,8 @@ namespace OpenSim.Region.ClientStack.Linden
347 byte[] resultbytes = Utils.UIntToBytes(val); 378 byte[] resultbytes = Utils.UIntToBytes(val);
348 if (BitConverter.IsLittleEndian) 379 if (BitConverter.IsLittleEndian)
349 Array.Reverse(resultbytes); 380 Array.Reverse(resultbytes);
350 return String.Format("<binary encoding=\"base64\">{0}</binary>",Convert.ToBase64String(resultbytes)); 381 return String.Format("<binary encoding=\"base64\">{0}</binary>", Convert.ToBase64String(resultbytes));
351 }
352
353 public void Close()
354 {
355
356 }
357
358 public string Name
359 {
360 get { return "ObjectAddModule"; }
361 }
362
363 public bool IsSharedModule
364 {
365 get { return false; }
366 } 382 }
367 383
368 #endregion
369 } 384 }
370} 385}
diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
index bfe2a71..1749dcf 100644
--- a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs
@@ -36,13 +36,17 @@ using OpenSim.Region.Framework.Scenes;
36 36
37namespace OpenSim.Region.CoreModules.Agent.IPBan 37namespace OpenSim.Region.CoreModules.Agent.IPBan
38{ 38{
39 public class IPBanModule : IRegionModule 39 public class IPBanModule : ISharedRegionModule
40 { 40 {
41 #region Implementation of IRegionModule 41 #region Implementation of ISharedRegionModule
42 42
43 private List<string> m_bans = new List<string>(); 43 private List<string> m_bans = new List<string>();
44 44
45 public void Initialise(Scene scene, IConfigSource source) 45 public void Initialise(IConfigSource source)
46 {
47 }
48
49 public void AddRegion(Scene scene)
46 { 50 {
47 new SceneBanner(scene, m_bans); 51 new SceneBanner(scene, m_bans);
48 52
@@ -50,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
50 { 54 {
51 foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans) 55 foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans)
52 { 56 {
53 if (!String.IsNullOrEmpty(ban.BannedHostIPMask)) 57 if (!String.IsNullOrEmpty(ban.BannedHostIPMask))
54 m_bans.Add(ban.BannedHostIPMask); 58 m_bans.Add(ban.BannedHostIPMask);
55 if (!String.IsNullOrEmpty(ban.BannedHostNameMask)) 59 if (!String.IsNullOrEmpty(ban.BannedHostNameMask))
56 m_bans.Add(ban.BannedHostNameMask); 60 m_bans.Add(ban.BannedHostNameMask);
@@ -58,6 +62,14 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
58 } 62 }
59 } 63 }
60 64
65 public void RemoveRegion(Scene scene)
66 {
67 }
68
69 public void RegionLoaded(Scene scene)
70 {
71 }
72
61 public void PostInitialise() 73 public void PostInitialise()
62 { 74 {
63 if (File.Exists("bans.txt")) 75 if (File.Exists("bans.txt"))
@@ -80,9 +92,9 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan
80 get { return "IPBanModule"; } 92 get { return "IPBanModule"; }
81 } 93 }
82 94
83 public bool IsSharedModule 95 public Type ReplaceableInterface
84 { 96 {
85 get { return true; } 97 get { return null; }
86 } 98 }
87 99
88 #endregion 100 #endregion
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index a1a2501..2879154 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
45{ 45{
46 public delegate void J2KDecodeDelegate(UUID assetID); 46 public delegate void J2KDecodeDelegate(UUID assetID);
47 47
48 public class J2KDecoderModule : IRegionModule, IJ2KDecoder 48 public class J2KDecoderModule : ISharedRegionModule, IJ2KDecoder
49 { 49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
@@ -56,26 +56,21 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
56 /// <summary>Cache that will store decoded JPEG2000 layer boundary data</summary> 56 /// <summary>Cache that will store decoded JPEG2000 layer boundary data</summary>
57 private IImprovedAssetCache m_cache; 57 private IImprovedAssetCache m_cache;
58 /// <summary>Reference to a scene (doesn't matter which one as long as it can load the cache module)</summary> 58 /// <summary>Reference to a scene (doesn't matter which one as long as it can load the cache module)</summary>
59 private UUID m_CreatorID = UUID.Zero;
59 private Scene m_scene; 60 private Scene m_scene;
60 61
61 #region IRegionModule 62 #region ISharedRegionModule
62 63
63 private bool m_useCSJ2K = true; 64 private bool m_useCSJ2K = true;
64 65
65 public string Name { get { return "J2KDecoderModule"; } } 66 public string Name { get { return "J2KDecoderModule"; } }
66 public bool IsSharedModule { get { return true; } }
67 67
68 public J2KDecoderModule() 68 public J2KDecoderModule()
69 { 69 {
70 } 70 }
71 71
72 public void Initialise(Scene scene, IConfigSource source) 72 public void Initialise(IConfigSource source)
73 { 73 {
74 if (m_scene == null)
75 m_scene = scene;
76
77 scene.RegisterModuleInterface<IJ2KDecoder>(this);
78
79 IConfig startupConfig = source.Configs["Startup"]; 74 IConfig startupConfig = source.Configs["Startup"];
80 if (startupConfig != null) 75 if (startupConfig != null)
81 { 76 {
@@ -83,6 +78,24 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
83 } 78 }
84 } 79 }
85 80
81 public void AddRegion(Scene scene)
82 {
83 if (m_scene == null)
84 {
85 m_scene = scene;
86 m_CreatorID = scene.RegionInfo.RegionID;
87 }
88
89 scene.RegisterModuleInterface<IJ2KDecoder>(this);
90
91 }
92
93 public void RemoveRegion(Scene scene)
94 {
95 if (m_scene == scene)
96 m_scene = null;
97 }
98
86 public void PostInitialise() 99 public void PostInitialise()
87 { 100 {
88 m_cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); 101 m_cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
@@ -92,6 +105,15 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
92 { 105 {
93 } 106 }
94 107
108 public void RegionLoaded(Scene scene)
109 {
110 }
111
112 public Type ReplaceableInterface
113 {
114 get { return null; }
115 }
116
95 #endregion IRegionModule 117 #endregion IRegionModule
96 118
97 #region IJ2KDecoder 119 #region IJ2KDecoder
@@ -279,7 +301,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
279 { 301 {
280 string assetID = "j2kCache_" + AssetId.ToString(); 302 string assetID = "j2kCache_" + AssetId.ToString();
281 303
282 AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_scene.RegionInfo.RegionID.ToString()); 304 AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_CreatorID.ToString());
283 layerDecodeAsset.Local = true; 305 layerDecodeAsset.Local = true;
284 layerDecodeAsset.Temporary = true; 306 layerDecodeAsset.Temporary = true;
285 307
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
index 78d597d..8237faf 100644
--- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
@@ -35,9 +35,12 @@ using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37 37
38using Mono.Addins;
39
38namespace OpenSim.Region.CoreModules.Agent.Xfer 40namespace OpenSim.Region.CoreModules.Agent.Xfer
39{ 41{
40 public class XferModule : IRegionModule, IXfer 42 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
43 public class XferModule : INonSharedRegionModule, IXfer
41 { 44 {
42 private Scene m_scene; 45 private Scene m_scene;
43 private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>(); 46 private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>();
@@ -59,9 +62,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
59 public int Count; 62 public int Count;
60 } 63 }
61 64
62 #region IRegionModule Members 65 #region INonSharedRegionModule Members
66
67 public void Initialise(IConfigSource config)
68 {
69 }
63 70
64 public void Initialise(Scene scene, IConfigSource config) 71 public void AddRegion(Scene scene)
65 { 72 {
66 m_scene = scene; 73 m_scene = scene;
67 m_scene.EventManager.OnNewClient += NewClient; 74 m_scene.EventManager.OnNewClient += NewClient;
@@ -69,22 +76,30 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
69 m_scene.RegisterModuleInterface<IXfer>(this); 76 m_scene.RegisterModuleInterface<IXfer>(this);
70 } 77 }
71 78
72 public void PostInitialise() 79 public void RemoveRegion(Scene scene)
73 { 80 {
81 m_scene.EventManager.OnNewClient -= NewClient;
82
83 m_scene.UnregisterModuleInterface<IXfer>(this);
84 m_scene = null;
74 } 85 }
75 86
76 public void Close() 87 public void RegionLoaded(Scene scene)
77 { 88 {
78 } 89 }
79 90
80 public string Name 91 public Type ReplaceableInterface
81 { 92 {
82 get { return "XferModule"; } 93 get { return null; }
83 } 94 }
84 95
85 public bool IsSharedModule 96 public void Close()
86 { 97 {
87 get { return false; } 98 }
99
100 public string Name
101 {
102 get { return "XferModule"; }
88 } 103 }
89 104
90 #endregion 105 #endregion
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index d1a563c..cef8029 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -49,8 +49,8 @@ using OpenSim.Region.Framework.Scenes;
49using OpenSim.Services.Interfaces; 49using OpenSim.Services.Interfaces;
50 50
51 51
52[assembly: Addin("FlotsamAssetCache", "1.1")] 52//[assembly: Addin("FlotsamAssetCache", "1.1")]
53[assembly: AddinDependency("OpenSim", "0.5")] 53//[assembly: AddinDependency("OpenSim", "0.5")]
54 54
55namespace OpenSim.Region.CoreModules.Asset 55namespace OpenSim.Region.CoreModules.Asset
56{ 56{
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index e3bf997..5b04a39 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -39,9 +39,12 @@ using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41 41
42using Mono.Addins;
43
42namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory 44namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
43{ 45{
44 public class AvatarFactoryModule : IAvatarFactoryModule, IRegionModule 46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
47 public class AvatarFactoryModule : IAvatarFactoryModule, INonSharedRegionModule
45 { 48 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 50
@@ -61,10 +64,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
61 64
62 #region IRegionModule 65 #region IRegionModule
63 66
64 public void Initialise(Scene scene, IConfigSource config) 67 public void Initialise(IConfigSource config)
65 { 68 {
66 scene.RegisterModuleInterface<IAvatarFactoryModule>(this);
67 scene.EventManager.OnNewClient += SubscribeToClientEvents;
68 69
69 IConfig appearanceConfig = config.Configs["Appearance"]; 70 IConfig appearanceConfig = config.Configs["Appearance"];
70 if (appearanceConfig != null) 71 if (appearanceConfig != null)
@@ -74,11 +75,29 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
74 // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); 75 // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime);
75 } 76 }
76 77
78 }
79
80 public void AddRegion(Scene scene)
81 {
77 if (m_scene == null) 82 if (m_scene == null)
78 m_scene = scene; 83 m_scene = scene;
84
85 scene.RegisterModuleInterface<IAvatarFactoryModule>(this);
86 scene.EventManager.OnNewClient += SubscribeToClientEvents;
79 } 87 }
80 88
81 public void PostInitialise() 89 public void RemoveRegion(Scene scene)
90 {
91 if (scene == m_scene)
92 {
93 scene.UnregisterModuleInterface<IAvatarFactoryModule>(this);
94 scene.EventManager.OnNewClient -= SubscribeToClientEvents;
95 }
96
97 m_scene = null;
98 }
99
100 public void RegionLoaded(Scene scene)
82 { 101 {
83 m_updateTimer.Enabled = false; 102 m_updateTimer.Enabled = false;
84 m_updateTimer.AutoReset = true; 103 m_updateTimer.AutoReset = true;
@@ -100,6 +119,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
100 get { return false; } 119 get { return false; }
101 } 120 }
102 121
122 public Type ReplaceableInterface
123 {
124 get { return null; }
125 }
126
127
103 private void SubscribeToClientEvents(IClientAPI client) 128 private void SubscribeToClientEvents(IClientAPI client)
104 { 129 {
105 client.OnRequestWearables += Client_OnRequestWearables; 130 client.OnRequestWearables += Client_OnRequestWearables;
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index 3a91465..c1a22bf 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -33,9 +33,12 @@ using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenMetaverse; 34using OpenMetaverse;
35 35
36using Mono.Addins;
37
36namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule 38namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
37{ 39{
38 public class CombatModule : IRegionModule 40 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
41 public class CombatModule : ISharedRegionModule
39 { 42 {
40 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41 44
@@ -54,7 +57,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
54 /// </summary> 57 /// </summary>
55 /// <param name="scene"></param> 58 /// <param name="scene"></param>
56 /// <param name="config"></param> 59 /// <param name="config"></param>
57 public void Initialise(Scene scene, IConfigSource config) 60 public void Initialise(IConfigSource config)
61 {
62 }
63
64 public void AddRegion(Scene scene)
58 { 65 {
59 lock (m_scenel) 66 lock (m_scenel)
60 { 67 {
@@ -72,6 +79,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
72 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; 79 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
73 } 80 }
74 81
82 public void RemoveRegion(Scene scene)
83 {
84 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle))
85 m_scenel.Remove(scene.RegionInfo.RegionHandle);
86
87 scene.EventManager.OnAvatarKilled -= KillAvatar;
88 scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
89 }
90
91 public void RegionLoaded(Scene scene)
92 {
93 }
94
75 public void PostInitialise() 95 public void PostInitialise()
76 { 96 {
77 } 97 }
@@ -85,11 +105,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
85 get { return "CombatModule"; } 105 get { return "CombatModule"; }
86 } 106 }
87 107
88 public bool IsSharedModule 108 public Type ReplaceableInterface
89 { 109 {
90 get { return true; } 110 get { return null; }
91 } 111 }
92 112
113
93 private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar) 114 private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar)
94 { 115 {
95 string deadAvatarMessage; 116 string deadAvatarMessage;
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index 3c294bb..db5a788 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -32,6 +32,7 @@ using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using Mono.Addins;
35 36
36using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
@@ -39,16 +40,27 @@ using OpenSim.Services.Interfaces;
39 40
40namespace OpenSim.Region.CoreModules.Avatar.Dialog 41namespace OpenSim.Region.CoreModules.Avatar.Dialog
41{ 42{
42 public class DialogModule : IRegionModule, IDialogModule 43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
43 { 44 public class DialogModule : IDialogModule, INonSharedRegionModule
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 47
46 protected Scene m_scene; 48 protected Scene m_scene;
47 49
48 public void Initialise(Scene scene, IConfigSource source) 50 public void Initialise(IConfigSource source) { }
51
52 public Type ReplaceableInterface { get { return null; } }
53
54 public void AddRegion(Scene scene)
49 { 55 {
50 m_scene = scene; 56 m_scene = scene;
51 m_scene.RegisterModuleInterface<IDialogModule>(this); 57 m_scene.RegisterModuleInterface<IDialogModule>(this);
58 }
59
60 public void RegionLoaded(Scene scene)
61 {
62 if (scene != m_scene)
63 return;
52 64
53 m_scene.AddCommand( 65 m_scene.AddCommand(
54 "Users", this, "alert", "alert <message>", 66 "Users", this, "alert", "alert <message>",
@@ -56,46 +68,59 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
56 HandleAlertConsoleCommand); 68 HandleAlertConsoleCommand);
57 69
58 m_scene.AddCommand( 70 m_scene.AddCommand(
59 "Users", this, "alert-user", "alert-user <first> <last> <message>", 71 "Users", this, "alert-user",
72 "alert-user <first> <last> <message>",
60 "Send an alert to a user", 73 "Send an alert to a user",
61 HandleAlertConsoleCommand); 74 HandleAlertConsoleCommand);
62 } 75 }
63 76
64 public void PostInitialise() {} 77 public void RemoveRegion(Scene scene)
65 public void Close() {} 78 {
79 if (scene != m_scene)
80 return;
81
82 m_scene.UnregisterModuleInterface<IDialogModule>(this);
83 }
84
85 public void Close() { }
66 public string Name { get { return "Dialog Module"; } } 86 public string Name { get { return "Dialog Module"; } }
67 public bool IsSharedModule { get { return false; } } 87
68
69 public void SendAlertToUser(IClientAPI client, string message) 88 public void SendAlertToUser(IClientAPI client, string message)
70 { 89 {
71 SendAlertToUser(client, message, false); 90 SendAlertToUser(client, message, false);
72 } 91 }
73 92
74 public void SendAlertToUser(IClientAPI client, string message, bool modal) 93 public void SendAlertToUser(IClientAPI client, string message,
94 bool modal)
75 { 95 {
76 client.SendAgentAlertMessage(message, modal); 96 client.SendAgentAlertMessage(message, modal);
77 } 97 }
78 98
79 public void SendAlertToUser(UUID agentID, string message) 99 public void SendAlertToUser(UUID agentID, string message)
80 { 100 {
81 SendAlertToUser(agentID, message, false); 101 SendAlertToUser(agentID, message, false);
82 } 102 }
83 103
84 public void SendAlertToUser(UUID agentID, string message, bool modal) 104 public void SendAlertToUser(UUID agentID, string message, bool modal)
85 { 105 {
86 ScenePresence sp = m_scene.GetScenePresence(agentID); 106 ScenePresence sp = m_scene.GetScenePresence(agentID);
87 107
88 if (sp != null) 108 if (sp != null)
89 sp.ControllingClient.SendAgentAlertMessage(message, modal); 109 sp.ControllingClient.SendAgentAlertMessage(message, modal);
90 } 110 }
91 111
92 public void SendAlertToUser(string firstName, string lastName, string message, bool modal) 112 public void SendAlertToUser(string firstName, string lastName,
113 string message, bool modal)
93 { 114 {
94 ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); 115 ScenePresence presence = m_scene.GetScenePresence(firstName,
116 lastName);
95 if (presence != null) 117 if (presence != null)
96 presence.ControllingClient.SendAgentAlertMessage(message, modal); 118 {
119 presence.ControllingClient.SendAgentAlertMessage(message,
120 modal);
121 }
97 } 122 }
98 123
99 public void SendGeneralAlert(string message) 124 public void SendGeneralAlert(string message)
100 { 125 {
101 m_scene.ForEachRootClient(delegate(IClientAPI client) 126 m_scene.ForEachRootClient(delegate(IClientAPI client)
@@ -104,11 +129,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
104 }); 129 });
105 } 130 }
106 131
107 public void SendDialogToUser( 132 public void SendDialogToUser(UUID avatarID, string objectName,
108 UUID avatarID, string objectName, UUID objectID, UUID ownerID, 133 UUID objectID, UUID ownerID, string message, UUID textureID,
109 string message, UUID textureID, int ch, string[] buttonlabels) 134 int ch, string[] buttonlabels)
110 { 135 {
111 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID); 136 UserAccount account = m_scene.UserAccountService.GetUserAccount(
137 m_scene.RegionInfo.ScopeID, ownerID);
112 string ownerFirstName, ownerLastName; 138 string ownerFirstName, ownerLastName;
113 if (account != null) 139 if (account != null)
114 { 140 {
@@ -123,29 +149,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
123 149
124 ScenePresence sp = m_scene.GetScenePresence(avatarID); 150 ScenePresence sp = m_scene.GetScenePresence(avatarID);
125 if (sp != null) 151 if (sp != null)
126 sp.ControllingClient.SendDialog( 152 {
127 objectName, objectID, ownerID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); 153 sp.ControllingClient.SendDialog(objectName, objectID, ownerID,
154 ownerFirstName, ownerLastName, message, textureID, ch,
155 buttonlabels);
156 }
128 } 157 }
129 158
130 public void SendUrlToUser( 159 public void SendUrlToUser(UUID avatarID, string objectName,
131 UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) 160 UUID objectID, UUID ownerID, bool groupOwned, string message,
161 string url)
132 { 162 {
133 ScenePresence sp = m_scene.GetScenePresence(avatarID); 163 ScenePresence sp = m_scene.GetScenePresence(avatarID);
134 164
135 if (sp != null) 165 if (sp != null)
136 sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); 166 {
167 sp.ControllingClient.SendLoadURL(objectName, objectID,
168 ownerID, groupOwned, message, url);
169 }
137 } 170 }
138 171
139 public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid) 172 public void SendTextBoxToUser(UUID avatarid, string message,
173 int chatChannel, string name, UUID objectid, UUID ownerid)
140 { 174 {
141 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); 175 UserAccount account = m_scene.UserAccountService.GetUserAccount(
176 m_scene.RegionInfo.ScopeID, ownerid);
142 string ownerFirstName, ownerLastName; 177 string ownerFirstName, ownerLastName;
143 UUID ownerID = UUID.Zero; 178 UUID ownerID = UUID.Zero;
144 if (account != null) 179 if (account != null)
145 { 180 {
146 ownerFirstName = account.FirstName; 181 ownerFirstName = account.FirstName;
147 ownerLastName = account.LastName; 182 ownerLastName = account.LastName;
148 ownerID = account.PrincipalID; 183 ownerID = account.PrincipalID;
149 } 184 }
150 else 185 else
151 { 186 {
@@ -154,29 +189,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
154 } 189 }
155 190
156 ScenePresence sp = m_scene.GetScenePresence(avatarid); 191 ScenePresence sp = m_scene.GetScenePresence(avatarid);
157 192
158 if (sp != null) 193 if (sp != null)
159 sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerID, ownerFirstName, ownerLastName, objectid); 194 {
195 sp.ControllingClient.SendTextBoxRequest(message, chatChannel,
196 name, ownerID, ownerFirstName, ownerLastName,
197 objectid);
198 }
160 } 199 }
161 200
162 public void SendNotificationToUsersInRegion( 201 public void SendNotificationToUsersInRegion(UUID fromAvatarID,
163 UUID fromAvatarID, string fromAvatarName, string message) 202 string fromAvatarName, string message)
164 { 203 {
165 m_scene.ForEachRootClient(delegate(IClientAPI client) 204 m_scene.ForEachRootClient(delegate(IClientAPI client)
166 { 205 {
167 client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); 206 client.SendBlueBoxMessage(fromAvatarID, fromAvatarName,
207 message);
168 }); 208 });
169 } 209 }
170 210
171 /// <summary> 211 /// <summary>
172 /// Handle an alert command from the console. 212 /// Handle an alert command from the console.
173 /// </summary> 213 /// </summary>
174 /// <param name="module"></param> 214 /// <param name="module"></param>
175 /// <param name="cmdparams"></param> 215 /// <param name="cmdparams"></param>
176 public void HandleAlertConsoleCommand(string module, string[] cmdparams) 216 public void HandleAlertConsoleCommand(string module,
217 string[] cmdparams)
177 { 218 {
178 if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) 219 if (m_scene.ConsoleScene() != null &&
220 m_scene.ConsoleScene() != m_scene)
221 {
179 return; 222 return;
223 }
180 224
181 string message = string.Empty; 225 string message = string.Empty;
182 226
@@ -184,7 +228,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
184 { 228 {
185 message = CombineParams(cmdparams, 1); 229 message = CombineParams(cmdparams, 1);
186 m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}", 230 m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}",
187 m_scene.RegionInfo.RegionName, message); 231 m_scene.RegionInfo.RegionName, message);
188 SendGeneralAlert(message); 232 SendGeneralAlert(message);
189 } 233 }
190 else if (cmdparams.Length > 3) 234 else if (cmdparams.Length > 3)
@@ -192,9 +236,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
192 string firstName = cmdparams[1]; 236 string firstName = cmdparams[1];
193 string lastName = cmdparams[2]; 237 string lastName = cmdparams[2];
194 message = CombineParams(cmdparams, 3); 238 message = CombineParams(cmdparams, 3);
195 m_log.InfoFormat( 239 m_log.InfoFormat("[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
196 "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", 240 m_scene.RegionInfo.RegionName, firstName, lastName,
197 m_scene.RegionInfo.RegionName, firstName, lastName, message); 241 message);
198 SendAlertToUser(firstName, lastName, message, false); 242 SendAlertToUser(firstName, lastName, message, false);
199 } 243 }
200 else 244 else
@@ -212,7 +256,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
212 { 256 {
213 result += commandParams[i] + " "; 257 result += commandParams[i] + " ";
214 } 258 }
215 259
216 return result; 260 return result;
217 } 261 }
218 } 262 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
index 7df2beb..de70dba 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Reflection; 29using System.Reflection;
29using log4net; 30using log4net;
30using Nini.Config; 31using Nini.Config;
@@ -35,26 +36,46 @@ using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
36using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
37 38
39using Mono.Addins;
40
38namespace OpenSim.Region.CoreModules.Avatar.Gestures 41namespace OpenSim.Region.CoreModules.Avatar.Gestures
39{ 42{
40 public class GesturesModule : IRegionModule 43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
44 public class GesturesModule : INonSharedRegionModule
41 { 45 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 47
44 protected Scene m_scene; 48 protected Scene m_scene;
45 49
46 public void Initialise(Scene scene, IConfigSource source) 50 public void Initialise(IConfigSource source)
51 {
52 }
53
54 public void AddRegion(Scene scene)
47 { 55 {
48 m_scene = scene; 56 m_scene = scene;
49 57
50 m_scene.EventManager.OnNewClient += OnNewClient; 58 m_scene.EventManager.OnNewClient += OnNewClient;
51 } 59 }
60
61 public void RegionLoaded(Scene scene)
62 {
63 }
64
65 public void RemoveRegion(Scene scene)
66 {
67 m_scene.EventManager.OnNewClient -= OnNewClient;
68 m_scene = null;
69 }
52 70
53 public void PostInitialise() {}
54 public void Close() {} 71 public void Close() {}
55 public string Name { get { return "Gestures Module"; } } 72 public string Name { get { return "Gestures Module"; } }
56 public bool IsSharedModule { get { return false; } } 73
57 74 public Type ReplaceableInterface
75 {
76 get { return null; }
77 }
78
58 private void OnNewClient(IClientAPI client) 79 private void OnNewClient(IClientAPI client)
59 { 80 {
60 client.OnActivateGesture += ActivateGesture; 81 client.OnActivateGesture += ActivateGesture;
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 82816d9..e7a9f53 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using Nini.Config; 30using Nini.Config;
30using OpenMetaverse; 31using OpenMetaverse;
@@ -50,9 +51,12 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray; 51using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap; 52using OSDMap = OpenMetaverse.StructuredData.OSDMap;
52 53
54using Mono.Addins;
55
53namespace OpenSim.Region.CoreModules.Avatar.Gods 56namespace OpenSim.Region.CoreModules.Avatar.Gods
54{ 57{
55 public class GodsModule : IRegionModule, IGodsModule 58 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
59 public class GodsModule : INonSharedRegionModule, IGodsModule
56 { 60 {
57 private static readonly ILog m_log = 61 private static readonly ILog m_log =
58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 62 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -66,10 +70,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
66 protected Dictionary<UUID, string> m_capsDict = 70 protected Dictionary<UUID, string> m_capsDict =
67 new Dictionary<UUID, string>(); 71 new Dictionary<UUID, string>();
68 72
69 public void Initialise(Scene scene, IConfigSource source) 73 protected IDialogModule DialogModule
74 {
75 get
76 {
77 if (m_dialogModule == null)
78 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
79
80 return m_dialogModule;
81 }
82 }
83
84 public void Initialise(IConfigSource source)
85 {
86 }
87
88 public void AddRegion(Scene scene)
70 { 89 {
71 m_scene = scene; 90 m_scene = scene;
72 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
73 m_scene.RegisterModuleInterface<IGodsModule>(this); 91 m_scene.RegisterModuleInterface<IGodsModule>(this);
74 m_scene.EventManager.OnNewClient += SubscribeToClientEvents; 92 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
75 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; 93 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
@@ -77,12 +95,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
77 scene.EventManager.OnIncomingInstantMessage += 95 scene.EventManager.OnIncomingInstantMessage +=
78 OnIncomingInstantMessage; 96 OnIncomingInstantMessage;
79 } 97 }
80 98
81 public void PostInitialise() {} 99 public void RemoveRegion(Scene scene)
100 {
101 m_scene.UnregisterModuleInterface<IGodsModule>(this);
102 m_scene.EventManager.OnNewClient -= SubscribeToClientEvents;
103 m_scene = null;
104 }
105
106 public void RegionLoaded(Scene scene)
107 {
108 }
109
82 public void Close() {} 110 public void Close() {}
83 public string Name { get { return "Gods Module"; } } 111 public string Name { get { return "Gods Module"; } }
84 public bool IsSharedModule { get { return false; } } 112
85 113 public Type ReplaceableInterface
114 {
115 get { return null; }
116 }
117
86 public void SubscribeToClientEvents(IClientAPI client) 118 public void SubscribeToClientEvents(IClientAPI client)
87 { 119 {
88 client.OnGodKickUser += KickUser; 120 client.OnGodKickUser += KickUser;
@@ -172,8 +204,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
172 } 204 }
173 else 205 else
174 { 206 {
175 if (m_dialogModule != null) 207 if (DialogModule != null)
176 m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied"); 208 DialogModule.SendAlertToUser(agentID, "Request for god powers denied");
177 } 209 }
178 } 210 }
179 } 211 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
index b258e13..27f94ea 100644
--- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using log4net; 31using log4net;
@@ -34,9 +35,12 @@ using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
36 37
38using Mono.Addins;
39
37namespace OpenSim.Region.CoreModules.Avatar.Groups 40namespace OpenSim.Region.CoreModules.Avatar.Groups
38{ 41{
39 public class GroupsModule : IRegionModule 42 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
43 public class GroupsModule : ISharedRegionModule
40 { 44 {
41 private static readonly ILog m_log = 45 private static readonly ILog m_log =
42 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -55,9 +59,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
55 private static GroupMembershipData osGroup = 59 private static GroupMembershipData osGroup =
56 new GroupMembershipData(); 60 new GroupMembershipData();
57 61
58 #region IRegionModule Members 62 private bool m_Enabled = false;
63
64 #region ISharedRegionModule Members
59 65
60 public void Initialise(Scene scene, IConfigSource config) 66 public void Initialise(IConfigSource config)
61 { 67 {
62 IConfig groupsConfig = config.Configs["Groups"]; 68 IConfig groupsConfig = config.Configs["Groups"];
63 69
@@ -67,7 +73,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
67 } 73 }
68 else 74 else
69 { 75 {
70 if (!groupsConfig.GetBoolean("Enabled", false)) 76 m_Enabled = groupsConfig.GetBoolean("Enabled", false);
77 if (!m_Enabled)
71 { 78 {
72 m_log.Info("[GROUPS]: Groups disabled in configuration"); 79 m_log.Info("[GROUPS]: Groups disabled in configuration");
73 return; 80 return;
@@ -77,6 +84,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
77 return; 84 return;
78 } 85 }
79 86
87 }
88
89 public void AddRegion(Scene scene)
90 {
91 if (!m_Enabled)
92 return;
93
80 lock (m_SceneList) 94 lock (m_SceneList)
81 { 95 {
82 if (!m_SceneList.Contains(scene)) 96 if (!m_SceneList.Contains(scene))
@@ -96,7 +110,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
96 110
97 scene.EventManager.OnNewClient += OnNewClient; 111 scene.EventManager.OnNewClient += OnNewClient;
98 scene.EventManager.OnClientClosed += OnClientClosed; 112 scene.EventManager.OnClientClosed += OnClientClosed;
99// scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 113 // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
114 }
115
116 public void RemoveRegion(Scene scene)
117 {
118 if (!m_Enabled)
119 return;
120
121 lock (m_SceneList)
122 {
123 if (m_SceneList.Contains(scene))
124 m_SceneList.Remove(scene);
125 }
126
127 scene.EventManager.OnNewClient -= OnNewClient;
128 scene.EventManager.OnClientClosed -= OnClientClosed;
129 }
130
131 public void RegionLoaded(Scene scene)
132 {
100 } 133 }
101 134
102 public void PostInitialise() 135 public void PostInitialise()
@@ -105,6 +138,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
105 138
106 public void Close() 139 public void Close()
107 { 140 {
141 if (!m_Enabled)
142 return;
143
108// m_log.Debug("[GROUPS]: Shutting down group module."); 144// m_log.Debug("[GROUPS]: Shutting down group module.");
109 145
110 lock (m_ClientMap) 146 lock (m_ClientMap)
@@ -123,9 +159,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups
123 get { return "GroupsModule"; } 159 get { return "GroupsModule"; }
124 } 160 }
125 161
126 public bool IsSharedModule 162 public Type ReplaceableInterface
127 { 163 {
128 get { return true; } 164 get { return null; }
129 } 165 }
130 166
131 #endregion 167 #endregion
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 765b960..50c51d3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -39,20 +39,18 @@ using OpenSim.Framework.Console;
39using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
42using Mono.Addins;
42 43
43namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver 44namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
44{ 45{
45 /// <summary> 46 /// <summary>
46 /// This module loads and saves OpenSimulator inventory archives 47 /// This module loads and saves OpenSimulator inventory archives
47 /// </summary> 48 /// </summary>
48 public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule 49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
50 public class InventoryArchiverModule : ISharedRegionModule, IInventoryArchiverModule
49 { 51 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 53
52 public string Name { get { return "Inventory Archiver Module"; } }
53
54 public bool IsSharedModule { get { return true; } }
55
56 /// <value> 54 /// <value>
57 /// Enable or disable checking whether the iar user is actually logged in 55 /// Enable or disable checking whether the iar user is actually logged in
58 /// </value> 56 /// </value>
@@ -99,9 +97,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
99// public InventoryArchiverModule(bool disablePresenceChecks) 97// public InventoryArchiverModule(bool disablePresenceChecks)
100// { 98// {
101// DisablePresenceChecks = disablePresenceChecks; 99// DisablePresenceChecks = disablePresenceChecks;
102// } 100 // }
101
102 #region ISharedRegionModule
103 103
104 public void Initialise(Scene scene, IConfigSource source) 104 public void Initialise(IConfigSource source)
105 {
106 }
107
108 public void AddRegion(Scene scene)
105 { 109 {
106 if (m_scenes.Count == 0) 110 if (m_scenes.Count == 0)
107 { 111 {
@@ -144,10 +148,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
144 m_scenes[scene.RegionInfo.RegionID] = scene; 148 m_scenes[scene.RegionInfo.RegionID] = scene;
145 } 149 }
146 150
147 public void PostInitialise() {} 151 public void RemoveRegion(Scene scene)
152 {
153 }
148 154
149 public void Close() {} 155 public void Close() {}
150 156
157 public void RegionLoaded(Scene scene)
158 {
159 }
160
161 public void PostInitialise()
162 {
163 }
164
165 public Type ReplaceableInterface
166 {
167 get { return null; }
168 }
169
170 public string Name { get { return "Inventory Archiver Module"; } }
171
172 #endregion
173
151 /// <summary> 174 /// <summary>
152 /// Trigger the inventory archive saved event. 175 /// Trigger the inventory archive saved event.
153 /// </summary> 176 /// </summary>
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
index e411585..d2198f1 100644
--- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs
@@ -38,10 +38,12 @@ using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts;
38using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; 38using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors;
39using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using Mono.Addins;
41 42
42namespace OpenSim.Region.CoreModules.Framework.Monitoring 43namespace OpenSim.Region.CoreModules.Framework.Monitoring
43{ 44{
44 public class MonitorModule : IRegionModule 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
46 public class MonitorModule : INonSharedRegionModule
45 { 47 {
46 /// <summary> 48 /// <summary>
47 /// Is this module enabled? 49 /// Is this module enabled?
@@ -62,14 +64,14 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
62 private readonly List<IAlert> m_alerts = new List<IAlert>(); 64 private readonly List<IAlert> m_alerts = new List<IAlert>();
63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 65 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
64 66
65 #region Implementation of IRegionModule
66
67 public MonitorModule() 67 public MonitorModule()
68 { 68 {
69 Enabled = true; 69 Enabled = true;
70 } 70 }
71 71
72 public void Initialise(Scene scene, IConfigSource source) 72 #region Implementation of INonSharedRegionModule
73
74 public void Initialise(IConfigSource source)
73 { 75 {
74 IConfig cnfg = source.Configs["Monitoring"]; 76 IConfig cnfg = source.Configs["Monitoring"];
75 77
@@ -79,6 +81,13 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
79 if (!Enabled) 81 if (!Enabled)
80 return; 82 return;
81 83
84 }
85
86 public void AddRegion(Scene scene)
87 {
88 if (!Enabled)
89 return;
90
82 m_scene = scene; 91 m_scene = scene;
83 92
84 m_scene.AddCommand("General", this, "monitor report", 93 m_scene.AddCommand("General", this, "monitor report",
@@ -89,101 +98,42 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
89 MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID, StatsPage); 98 MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID, StatsPage);
90 MainServer.Instance.AddHTTPHandler( 99 MainServer.Instance.AddHTTPHandler(
91 "/monitorstats/" + Uri.EscapeDataString(m_scene.RegionInfo.RegionName), StatsPage); 100 "/monitorstats/" + Uri.EscapeDataString(m_scene.RegionInfo.RegionName), StatsPage);
101
102 AddMonitors();
92 } 103 }
93 104
94 public void DebugMonitors(string module, string[] args) 105 public void RemoveRegion(Scene scene)
95 { 106 {
96 foreach (IMonitor monitor in m_staticMonitors) 107 if (!Enabled)
97 { 108 return;
98 MainConsole.Instance.OutputFormat(
99 "[MONITOR MODULE]: {0} reports {1} = {2}",
100 m_scene.RegionInfo.RegionName, monitor.GetFriendlyName(), monitor.GetFriendlyValue());
101 }
102 109
103 foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats()) 110 MainServer.Instance.RemoveHTTPHandler("GET", "/monitorstats/" + m_scene.RegionInfo.RegionID);
104 { 111 MainServer.Instance.RemoveHTTPHandler("GET", "/monitorstats/" + Uri.EscapeDataString(m_scene.RegionInfo.RegionName));
105 MainConsole.Instance.OutputFormat( 112 m_scene = null;
106 "[MONITOR MODULE]: {0} reports {1} = {2}",
107 m_scene.RegionInfo.RegionName, tuple.Key, tuple.Value);
108 }
109 } 113 }
110 114
111 public void TestAlerts() 115 public void Close()
112 { 116 {
113 foreach (IAlert alert in m_alerts)
114 {
115 alert.Test();
116 }
117 } 117 }
118 118
119 public Hashtable StatsPage(Hashtable request) 119 public string Name
120 { 120 {
121 // If request was for a specific monitor 121 get { return "Region Health Monitoring Module"; }
122 // eg url/?monitor=Monitor.Name 122 }
123 if (request.ContainsKey("monitor"))
124 {
125 string monID = (string) request["monitor"];
126
127 foreach (IMonitor monitor in m_staticMonitors)
128 {
129 string elemName = monitor.ToString();
130 if (elemName.StartsWith(monitor.GetType().Namespace))
131 elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1);
132
133 if (elemName == monID || monitor.ToString() == monID)
134 {
135 Hashtable ereply3 = new Hashtable();
136
137 ereply3["int_response_code"] = 404; // 200 OK
138 ereply3["str_response_string"] = monitor.GetValue().ToString();
139 ereply3["content_type"] = "text/plain";
140
141 return ereply3;
142 }
143 }
144
145 // FIXME: Arguably this should also be done with dynamic monitors but I'm not sure what the above code
146 // is even doing. Why are we inspecting the type of the monitor???
147
148 // No monitor with that name
149 Hashtable ereply2 = new Hashtable();
150
151 ereply2["int_response_code"] = 404; // 200 OK
152 ereply2["str_response_string"] = "No such monitor";
153 ereply2["content_type"] = "text/plain";
154
155 return ereply2;
156 }
157
158 string xml = "<data>";
159 foreach (IMonitor monitor in m_staticMonitors)
160 {
161 string elemName = monitor.GetName();
162 xml += "<" + elemName + ">" + monitor.GetValue().ToString() + "</" + elemName + ">";
163// m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue());
164 }
165
166 foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats())
167 {
168 xml += "<" + tuple.Key + ">" + tuple.Value + "</" + tuple.Key + ">";
169 }
170
171 xml += "</data>";
172
173 Hashtable ereply = new Hashtable();
174
175 ereply["int_response_code"] = 200; // 200 OK
176 ereply["str_response_string"] = xml;
177 ereply["content_type"] = "text/xml";
178 123
179 return ereply; 124 public void RegionLoaded(Scene scene)
125 {
180 } 126 }
181 127
182 public void PostInitialise() 128 public Type ReplaceableInterface
183 { 129 {
184 if (!Enabled) 130 get { return null; }
185 return; 131 }
132
133 #endregion
186 134
135 public void AddMonitors()
136 {
187 m_staticMonitors.Add(new AgentCountMonitor(m_scene)); 137 m_staticMonitors.Add(new AgentCountMonitor(m_scene));
188 m_staticMonitors.Add(new ChildAgentCountMonitor(m_scene)); 138 m_staticMonitors.Add(new ChildAgentCountMonitor(m_scene));
189 m_staticMonitors.Add(new GCMemoryMonitor()); 139 m_staticMonitors.Add(new GCMemoryMonitor());
@@ -196,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
196 m_staticMonitors.Add(new EventFrameMonitor(m_scene)); 146 m_staticMonitors.Add(new EventFrameMonitor(m_scene));
197 m_staticMonitors.Add(new LandFrameMonitor(m_scene)); 147 m_staticMonitors.Add(new LandFrameMonitor(m_scene));
198 m_staticMonitors.Add(new LastFrameTimeMonitor(m_scene)); 148 m_staticMonitors.Add(new LastFrameTimeMonitor(m_scene));
199 149
200 m_staticMonitors.Add( 150 m_staticMonitors.Add(
201 new GenericMonitor( 151 new GenericMonitor(
202 m_scene, 152 m_scene,
@@ -357,25 +307,98 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
357 } 307 }
358 } 308 }
359 309
360 void OnTriggerAlert(System.Type reporter, string reason, bool fatal) 310 public void DebugMonitors(string module, string[] args)
361 { 311 {
362 m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")"); 312 foreach (IMonitor monitor in m_staticMonitors)
313 {
314 MainConsole.Instance.OutputFormat(
315 "[MONITOR MODULE]: {0} reports {1} = {2}",
316 m_scene.RegionInfo.RegionName, monitor.GetFriendlyName(), monitor.GetFriendlyValue());
317 }
318
319 foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats())
320 {
321 MainConsole.Instance.OutputFormat(
322 "[MONITOR MODULE]: {0} reports {1} = {2}",
323 m_scene.RegionInfo.RegionName, tuple.Key, tuple.Value);
324 }
363 } 325 }
364 326
365 public void Close() 327 public void TestAlerts()
366 { 328 {
329 foreach (IAlert alert in m_alerts)
330 {
331 alert.Test();
332 }
367 } 333 }
368 334
369 public string Name 335 public Hashtable StatsPage(Hashtable request)
370 { 336 {
371 get { return "Region Health Monitoring Module"; } 337 // If request was for a specific monitor
338 // eg url/?monitor=Monitor.Name
339 if (request.ContainsKey("monitor"))
340 {
341 string monID = (string) request["monitor"];
342
343 foreach (IMonitor monitor in m_staticMonitors)
344 {
345 string elemName = monitor.ToString();
346 if (elemName.StartsWith(monitor.GetType().Namespace))
347 elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1);
348
349 if (elemName == monID || monitor.ToString() == monID)
350 {
351 Hashtable ereply3 = new Hashtable();
352
353 ereply3["int_response_code"] = 404; // 200 OK
354 ereply3["str_response_string"] = monitor.GetValue().ToString();
355 ereply3["content_type"] = "text/plain";
356
357 return ereply3;
358 }
359 }
360
361 // FIXME: Arguably this should also be done with dynamic monitors but I'm not sure what the above code
362 // is even doing. Why are we inspecting the type of the monitor???
363
364 // No monitor with that name
365 Hashtable ereply2 = new Hashtable();
366
367 ereply2["int_response_code"] = 404; // 200 OK
368 ereply2["str_response_string"] = "No such monitor";
369 ereply2["content_type"] = "text/plain";
370
371 return ereply2;
372 }
373
374 string xml = "<data>";
375 foreach (IMonitor monitor in m_staticMonitors)
376 {
377 string elemName = monitor.GetName();
378 xml += "<" + elemName + ">" + monitor.GetValue().ToString() + "</" + elemName + ">";
379// m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue());
380 }
381
382 foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats())
383 {
384 xml += "<" + tuple.Key + ">" + tuple.Value + "</" + tuple.Key + ">";
385 }
386
387 xml += "</data>";
388
389 Hashtable ereply = new Hashtable();
390
391 ereply["int_response_code"] = 200; // 200 OK
392 ereply["str_response_string"] = xml;
393 ereply["content_type"] = "text/xml";
394
395 return ereply;
372 } 396 }
373 397
374 public bool IsSharedModule 398 void OnTriggerAlert(System.Type reporter, string reason, bool fatal)
375 { 399 {
376 get { return false; } 400 m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")");
377 } 401 }
378 402
379 #endregion
380 } 403 }
381} 404}
diff --git a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs
deleted file mode 100644
index 2cc0a07..0000000
--- a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs
+++ /dev/null
@@ -1,150 +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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text;
34using log4net;
35using Nini.Config;
36using Nwc.XmlRpc;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Servers;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes;
43
44namespace OpenSim.Region.CoreModules.InterGrid
45{
46 public class OGSRadmin : IRegionModule
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 private readonly List<Scene> m_scenes = new List<Scene>();
50 private IConfigSource m_settings;
51
52 #region Implementation of IRegionModuleBase
53
54 public string Name
55 {
56 get { return "OGS Supporting RAdmin"; }
57 }
58
59
60 public void Initialise(IConfigSource source)
61 {
62 m_settings = source;
63 }
64
65 public void Close()
66 {
67
68 }
69
70 public void AddRegion(Scene scene)
71 {
72 lock (m_scenes)
73 m_scenes.Add(scene);
74 }
75
76 public void RemoveRegion(Scene scene)
77 {
78 lock (m_scenes)
79 m_scenes.Remove(scene);
80 }
81
82 public void RegionLoaded(Scene scene)
83 {
84
85 }
86
87 public void PostInitialise()
88 {
89 if (m_settings.Configs["Startup"].GetBoolean("gridmode", false))
90 {
91 MainServer.Instance.AddXmlRPCHandler("grid_message", GridWideMessage);
92 }
93 }
94
95 #endregion
96
97 #region IRegionModule
98
99 public void Initialise(Scene scene, IConfigSource source)
100 {
101 m_settings = source;
102
103 lock (m_scenes)
104 m_scenes.Add(scene);
105 }
106
107 public bool IsSharedModule
108 {
109 get { return true; }
110 }
111
112 #endregion
113
114 public XmlRpcResponse GridWideMessage(XmlRpcRequest req, IPEndPoint remoteClient)
115 {
116 XmlRpcResponse response = new XmlRpcResponse();
117 Hashtable responseData = new Hashtable();
118
119 Hashtable requestData = (Hashtable)req.Params[0];
120
121 // REFACTORING PROBLEM. This authorization needs to be replaced with some other
122 //if ((!requestData.Contains("password") || (string)requestData["password"] != m_com.NetworkServersInfo.GridRecvKey))
123 //{
124 // responseData["accepted"] = false;
125 // responseData["success"] = false;
126 // responseData["error"] = "Invalid Key";
127 // response.Value = responseData;
128 // return response;
129 //}
130
131 string message = (string)requestData["message"];
132 string user = (string)requestData["user"];
133 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
134
135 lock (m_scenes)
136 foreach (Scene scene in m_scenes)
137 {
138 IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
139 if (dialogModule != null)
140 dialogModule.SendNotificationToUsersInRegion(UUID.Random(), user, message);
141 }
142
143 responseData["accepted"] = true;
144 responseData["success"] = true;
145 response.Value = responseData;
146
147 return response;
148 }
149 }
150}
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
deleted file mode 100644
index 4a76b00..0000000
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ /dev/null
@@ -1,1297 +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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Net.Security;
33using System.Reflection;
34using System.Security.Cryptography.X509Certificates;
35using System.Threading;
36using System.Web;
37using log4net;
38using Nini.Config;
39using OpenMetaverse;
40using OpenMetaverse.StructuredData;
41using OpenSim.Framework;
42using OpenSim.Framework.Capabilities;
43using OpenSim.Framework.Monitoring;
44using OpenSim.Framework.Servers;
45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes;
47using Caps=OpenSim.Framework.Capabilities.Caps;
48using OSDArray=OpenMetaverse.StructuredData.OSDArray;
49using OSDMap=OpenMetaverse.StructuredData.OSDMap;
50
51namespace OpenSim.Region.CoreModules.InterGrid
52{
53 public struct OGPState
54 {
55 public string first_name;
56 public string last_name;
57 public UUID agent_id;
58 public UUID local_agent_id;
59 public UUID region_id;
60 public uint circuit_code;
61 public UUID secure_session_id;
62 public UUID session_id;
63 public bool agent_access;
64 public string sim_access;
65 public uint god_level;
66 public bool god_overide;
67 public bool identified;
68 public bool transacted;
69 public bool age_verified;
70 public bool allow_redirect;
71 public int limited_to_estate;
72 public string inventory_host;
73 public bool src_can_see_mainland;
74 public int src_estate_id;
75 public int src_version;
76 public int src_parent_estate_id;
77 public bool visible_to_parent;
78 public string teleported_into_region;
79 }
80
81 public class OpenGridProtocolModule : IRegionModule
82 {
83 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
84 private List<Scene> m_scene = new List<Scene>();
85
86 private Dictionary<string, AgentCircuitData> CapsLoginID = new Dictionary<string, AgentCircuitData>();
87 private Dictionary<UUID, OGPState> m_OGPState = new Dictionary<UUID, OGPState>();
88 private Dictionary<string, string> m_loginToRegionState = new Dictionary<string, string>();
89
90
91 private string LastNameSuffix = "_EXTERNAL";
92 private string FirstNamePrefix = "";
93 private string httpsCN = "";
94 private bool httpSSL = false;
95 private uint httpsslport = 0;
96// private bool GridMode = false;
97
98 #region IRegionModule Members
99
100 public void Initialise(Scene scene, IConfigSource config)
101 {
102 bool enabled = false;
103 IConfig cfg = null;
104 IConfig httpcfg = null;
105// IConfig startupcfg = null;
106 try
107 {
108 cfg = config.Configs["OpenGridProtocol"];
109 } catch (NullReferenceException)
110 {
111 enabled = false;
112 }
113
114 try
115 {
116 httpcfg = config.Configs["Network"];
117 }
118 catch (NullReferenceException)
119 {
120
121 }
122// try
123// {
124// startupcfg = config.Configs["Startup"];
125// }
126// catch (NullReferenceException)
127// {
128//
129// }
130
131// if (startupcfg != null)
132// {
133// GridMode = enabled = startupcfg.GetBoolean("gridmode", false);
134// }
135
136 if (cfg != null)
137 {
138 enabled = cfg.GetBoolean("ogp_enabled", false);
139 LastNameSuffix = cfg.GetString("ogp_lastname_suffix", "_EXTERNAL");
140 FirstNamePrefix = cfg.GetString("ogp_firstname_prefix", "");
141 if (enabled)
142 {
143 m_log.Warn("[OGP]: Open Grid Protocol is on, Listening for Clients on /agent/");
144 lock (m_scene)
145 {
146 if (m_scene.Count == 0)
147 {
148 MainServer.Instance.AddLLSDHandler("/agent/", ProcessAgentDomainMessage);
149 MainServer.Instance.AddLLSDHandler("/", ProcessRegionDomainSeed);
150 try
151 {
152 ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation;
153 }
154 catch (NotImplementedException)
155 {
156 try
157 {
158#pragma warning disable 0612, 0618
159 // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this!
160 ServicePointManager.CertificatePolicy = new MonoCert();
161#pragma warning restore 0612, 0618
162 }
163 catch (Exception)
164 {
165 m_log.Error("[OGP]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions.");
166 }
167 }
168
169 }
170 // can't pick the region 'agent' because it would conflict with our agent domain handler
171 // a zero length region name would conflict with are base region seed cap
172 if (!SceneListDuplicateCheck(scene.RegionInfo.RegionName) && scene.RegionInfo.RegionName.ToLower() != "agent" && scene.RegionInfo.RegionName.Length > 0)
173 {
174 MainServer.Instance.AddLLSDHandler(
175 "/" + HttpUtility.UrlPathEncode(scene.RegionInfo.RegionName.ToLower()),
176 ProcessRegionDomainSeed);
177 }
178
179 if (!m_scene.Contains(scene))
180 m_scene.Add(scene);
181 }
182 }
183 }
184 lock (m_scene)
185 {
186 if (m_scene.Count == 1)
187 {
188 if (httpcfg != null)
189 {
190 httpSSL = httpcfg.GetBoolean("http_listener_ssl", false);
191 httpsCN = httpcfg.GetString("http_listener_cn", scene.RegionInfo.ExternalHostName);
192 if (httpsCN.Length == 0)
193 httpsCN = scene.RegionInfo.ExternalHostName;
194 httpsslport = (uint)httpcfg.GetInt("http_listener_sslport",((int)scene.RegionInfo.HttpPort + 1));
195 }
196 }
197 }
198 }
199
200 public void PostInitialise()
201 {
202 }
203
204 public void Close()
205 {
206 //scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
207 }
208
209 public string Name
210 {
211 get { return "OpenGridProtocolModule"; }
212 }
213
214 public bool IsSharedModule
215 {
216 get { return true; }
217 }
218
219 #endregion
220
221 public OSD ProcessRegionDomainSeed(string path, OSD request, string endpoint)
222 {
223 string[] pathSegments = path.Split('/');
224
225 if (pathSegments.Length <= 1)
226 {
227 return GenerateNoHandlerMessage();
228
229 }
230
231 return GenerateRezAvatarRequestMessage(pathSegments[1]);
232
233
234
235 //m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}",
236 // path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]);
237 //return new OSDMap();
238
239 }
240
241 public OSD ProcessAgentDomainMessage(string path, OSD request, string endpoint)
242 {
243 // /agent/*
244
245 string[] pathSegments = path.Split('/');
246 if (pathSegments.Length <= 1)
247 {
248 return GenerateNoHandlerMessage();
249
250 }
251 if (pathSegments[0].Length == 0 && pathSegments[1].Length == 0)
252 {
253 return GenerateRezAvatarRequestMessage("");
254 }
255 m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}",
256 path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]);
257
258 switch (pathSegments[pathSegments.Length - 1])
259 {
260 case "rez_avatar":
261 return RezAvatarMethod(path, request);
262 //break;
263 case "derez_avatar":
264 return DerezAvatarMethod(path, request);
265 //break;
266
267 }
268 if (path.Length < 2)
269 {
270 return GenerateNoHandlerMessage();
271 }
272
273 switch (pathSegments[pathSegments.Length - 2] + "/" + pathSegments[pathSegments.Length - 1])
274 {
275 case "rez_avatar/rez":
276 return RezAvatarMethod(path, request);
277 //break;
278 case "rez_avatar/request":
279 return RequestRezAvatarMethod(path, request);
280 case "rez_avatar/place":
281 return RequestRezAvatarMethod(path, request);
282 case "rez_avatar/derez":
283 return DerezAvatarMethod(path, request);
284 //break;
285 default:
286 return GenerateNoHandlerMessage();
287 }
288 //return null;
289 }
290
291 private OSD GenerateRezAvatarRequestMessage(string regionname)
292 {
293 Scene region = null;
294 bool usedroot = false;
295
296 if (regionname.Length == 0)
297 {
298 region = GetRootScene();
299 usedroot = true;
300 }
301 else
302 {
303 region = GetScene(HttpUtility.UrlDecode(regionname).ToLower());
304 }
305
306 // this shouldn't happen since we don't listen for a region that is down.. but
307 // it might if the region was taken down or is in the middle of restarting
308
309 if (region == null)
310 {
311 region = GetRootScene();
312 usedroot = true;
313 }
314
315 UUID statekeeper = UUID.Random();
316
317
318
319
320 RegionInfo reg = region.RegionInfo;
321
322 OSDMap responseMap = new OSDMap();
323 string rezHttpProtocol = "http://";
324 //string regionCapsHttpProtocol = "http://";
325 string httpaddr = reg.ExternalHostName;
326 string urlport = reg.HttpPort.ToString();
327 string requestpath = "/agent/" + statekeeper + "/rez_avatar/request";
328
329 if (!usedroot)
330 {
331 lock (m_loginToRegionState)
332 {
333 if (!m_loginToRegionState.ContainsKey(requestpath))
334 {
335 m_loginToRegionState.Add(requestpath, region.RegionInfo.RegionName.ToLower());
336 }
337 }
338 }
339
340 if (httpSSL)
341 {
342 rezHttpProtocol = "https://";
343 //regionCapsHttpProtocol = "https://";
344 urlport = httpsslport.ToString();
345
346 if (httpsCN.Length > 0)
347 httpaddr = httpsCN;
348 }
349
350 responseMap["connect"] = OSD.FromBoolean(true);
351 OSDMap capabilitiesMap = new OSDMap();
352 capabilitiesMap["rez_avatar/request"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + requestpath);
353 responseMap["capabilities"] = capabilitiesMap;
354
355 return responseMap;
356 }
357
358 // Using OpenSim.Framework.Capabilities.Caps here one time..
359 // so the long name is probably better then a using statement
360 public void OnRegisterCaps(UUID agentID, Caps caps)
361 {
362 /* If we ever want to register our own caps here....
363 *
364 string capsBase = "/CAPS/" + caps.CapsObjectPath;
365 caps.RegisterHandler("CAPNAME",
366 new RestStreamHandler("POST", capsBase + CAPSPOSTFIX!,
367 delegate(string request, string path, string param,
368 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
369 {
370 return METHODHANDLER(request, path, param,
371 agentID, caps);
372 }));
373
374 *
375 */
376 }
377
378 public OSD RequestRezAvatarMethod(string path, OSD request)
379 {
380 //m_log.Debug("[REQUESTREZAVATAR]: " + request.ToString());
381
382 OSDMap requestMap = (OSDMap)request;
383
384
385 Scene homeScene = null;
386
387 lock (m_loginToRegionState)
388 {
389 if (m_loginToRegionState.ContainsKey(path))
390 {
391 homeScene = GetScene(m_loginToRegionState[path]);
392 m_loginToRegionState.Remove(path);
393
394 if (homeScene == null)
395 homeScene = GetRootScene();
396 }
397 else
398 {
399 homeScene = GetRootScene();
400 }
401 }
402
403 // Homescene is still null, we must have no regions that are up
404 if (homeScene == null)
405 return GenerateNoHandlerMessage();
406
407 RegionInfo reg = homeScene.RegionInfo;
408 ulong regionhandle = GetOSCompatibleRegionHandle(reg);
409 //string RegionURI = reg.ServerURI;
410 //int RegionPort = (int)reg.HttpPort;
411
412 UUID RemoteAgentID = requestMap["agent_id"].AsUUID();
413
414 // will be used in the future. The client always connects with the aditi agentid currently
415 UUID LocalAgentID = RemoteAgentID;
416
417 string FirstName = requestMap["first_name"].AsString();
418 string LastName = requestMap["last_name"].AsString();
419
420 FirstName = FirstNamePrefix + FirstName;
421 LastName = LastName + LastNameSuffix;
422
423 OGPState userState = GetOGPState(LocalAgentID);
424
425 userState.first_name = requestMap["first_name"].AsString();
426 userState.last_name = requestMap["last_name"].AsString();
427 userState.age_verified = requestMap["age_verified"].AsBoolean();
428 userState.transacted = requestMap["transacted"].AsBoolean();
429 userState.agent_access = requestMap["agent_access"].AsBoolean();
430 userState.allow_redirect = requestMap["allow_redirect"].AsBoolean();
431 userState.identified = requestMap["identified"].AsBoolean();
432 userState.god_level = (uint)requestMap["god_level"].AsInteger();
433 userState.sim_access = requestMap["sim_access"].AsString();
434 userState.agent_id = RemoteAgentID;
435 userState.limited_to_estate = requestMap["limited_to_estate"].AsInteger();
436 userState.src_can_see_mainland = requestMap["src_can_see_mainland"].AsBoolean();
437 userState.src_estate_id = requestMap["src_estate_id"].AsInteger();
438 userState.local_agent_id = LocalAgentID;
439 userState.teleported_into_region = reg.RegionName.ToLower();
440
441 UpdateOGPState(LocalAgentID, userState);
442
443 OSDMap responseMap = new OSDMap();
444
445 if (RemoteAgentID == UUID.Zero)
446 {
447 responseMap["connect"] = OSD.FromBoolean(false);
448 responseMap["message"] = OSD.FromString("No agent ID was specified in rez_avatar/request");
449 m_log.Error("[OGP]: rez_avatar/request failed because no avatar UUID was provided in the request body");
450 return responseMap;
451 }
452
453 responseMap["sim_host"] = OSD.FromString(reg.ExternalHostName);
454
455 // DEPRECATED
456 responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(reg.ExternalHostName).ToString());
457
458 responseMap["connect"] = OSD.FromBoolean(true);
459 responseMap["sim_port"] = OSD.FromInteger(reg.InternalEndPoint.Port);
460 responseMap["region_x"] = OSD.FromInteger(reg.RegionLocX * (uint)Constants.RegionSize); // LLX
461 responseMap["region_y"] = OSD.FromInteger(reg.RegionLocY * (uint)Constants.RegionSize); // LLY
462 responseMap["region_id"] = OSD.FromUUID(reg.originRegionID);
463
464 if (reg.RegionSettings.Maturity == 1)
465 {
466 responseMap["sim_access"] = OSD.FromString("Mature");
467 }
468 else if (reg.RegionSettings.Maturity == 2)
469 {
470 responseMap["sim_access"] = OSD.FromString("Adult");
471 }
472 else
473 {
474 responseMap["sim_access"] = OSD.FromString("PG");
475 }
476
477 // Generate a dummy agent for the user so we can get back a CAPS path
478 AgentCircuitData agentData = new AgentCircuitData();
479 agentData.AgentID = LocalAgentID;
480 agentData.BaseFolder = UUID.Zero;
481 agentData.CapsPath = CapsUtil.GetRandomCapsObjectPath();
482 agentData.child = false;
483 agentData.circuitcode = (uint)(Util.RandomClass.Next());
484 agentData.firstname = FirstName;
485 agentData.lastname = LastName;
486 agentData.SecureSessionID = UUID.Random();
487 agentData.SessionID = UUID.Random();
488 agentData.startpos = new Vector3(128f, 128f, 100f);
489
490 // Pre-Fill our region cache with information on the agent.
491 UserAgentData useragent = new UserAgentData();
492 useragent.AgentIP = "unknown";
493 useragent.AgentOnline = true;
494 useragent.AgentPort = (uint)0;
495 useragent.Handle = regionhandle;
496 useragent.InitialRegion = reg.originRegionID;
497 useragent.LoginTime = Util.UnixTimeSinceEpoch();
498 useragent.LogoutTime = 0;
499 useragent.Position = agentData.startpos;
500 useragent.Region = reg.originRegionID;
501 useragent.SecureSessionID = agentData.SecureSessionID;
502 useragent.SessionID = agentData.SessionID;
503
504 UserProfileData userProfile = new UserProfileData();
505 userProfile.AboutText = "OGP User";
506 userProfile.CanDoMask = (uint)0;
507 userProfile.Created = Util.UnixTimeSinceEpoch();
508 userProfile.CurrentAgent = useragent;
509 userProfile.CustomType = "OGP";
510 userProfile.FirstLifeAboutText = "I'm testing OpenGrid Protocol";
511 userProfile.FirstLifeImage = UUID.Zero;
512 userProfile.FirstName = agentData.firstname;
513 userProfile.GodLevel = 0;
514 userProfile.HomeLocation = agentData.startpos;
515 userProfile.HomeLocationX = agentData.startpos.X;
516 userProfile.HomeLocationY = agentData.startpos.Y;
517 userProfile.HomeLocationZ = agentData.startpos.Z;
518 userProfile.HomeLookAt = Vector3.Zero;
519 userProfile.HomeLookAtX = userProfile.HomeLookAt.X;
520 userProfile.HomeLookAtY = userProfile.HomeLookAt.Y;
521 userProfile.HomeLookAtZ = userProfile.HomeLookAt.Z;
522 userProfile.HomeRegion = reg.RegionHandle;
523 userProfile.HomeRegionID = reg.originRegionID;
524 userProfile.HomeRegionX = reg.RegionLocX;
525 userProfile.HomeRegionY = reg.RegionLocY;
526 userProfile.ID = agentData.AgentID;
527 userProfile.Image = UUID.Zero;
528 userProfile.LastLogin = Util.UnixTimeSinceEpoch();
529 userProfile.Partner = UUID.Zero;
530 userProfile.PasswordHash = "$1$";
531 userProfile.PasswordSalt = "";
532 userProfile.SurName = agentData.lastname;
533 //userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL;
534 userProfile.UserFlags = 0;
535 //userProfile.UserInventoryURI = homeScene.CommsManager.NetworkServersInfo.InventoryURL;
536 userProfile.WantDoMask = 0;
537 userProfile.WebLoginKey = UUID.Random();
538
539 // !!! REFACTORING PROBLEM. This needs to be changed for 0.7
540 //
541 //// Do caps registration
542 //// get seed capagentData.firstname = FirstName;agentData.lastname = LastName;
543 //if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode)
544 //{
545 // homeScene.CommsManager.UserAdminService.AddUser(
546 // agentData.firstname, agentData.lastname, CreateRandomStr(7), "",
547 // homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID);
548
549 // UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID);
550 // if (userProfile2 != null)
551 // {
552 // userProfile = userProfile2;
553 // userProfile.AboutText = "OGP USER";
554 // userProfile.FirstLifeAboutText = "OGP USER";
555 // homeScene.CommsManager.UserService.UpdateUserProfile(userProfile);
556 // }
557 //}
558
559 //// Stick our data in the cache so the region will know something about us
560 //homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile);
561
562 // Call 'new user' event handler
563 string reason;
564 if (!homeScene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason))
565 {
566 responseMap["connect"] = OSD.FromBoolean(false);
567 responseMap["message"] = OSD.FromString(String.Format("Connection refused: {0}", reason));
568 m_log.ErrorFormat("[OGP]: rez_avatar/request failed: {0}", reason);
569 return responseMap;
570 }
571
572
573 //string raCap = string.Empty;
574
575 UUID AvatarRezCapUUID = LocalAgentID;
576 string rezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/rez";
577 string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez";
578 // Get a reference to the user's cap so we can pull out the Caps Object Path
579 Caps userCap
580 = homeScene.CapsModule.GetCapsForUser(agentData.AgentID);
581
582 string rezHttpProtocol = "http://";
583 string regionCapsHttpProtocol = "http://";
584 string httpaddr = reg.ExternalHostName;
585 string urlport = reg.HttpPort.ToString();
586
587 if (httpSSL)
588 {
589 rezHttpProtocol = "https://";
590 regionCapsHttpProtocol = "https://";
591 urlport = httpsslport.ToString();
592
593 if (httpsCN.Length > 0)
594 httpaddr = httpsCN;
595 }
596
597 // DEPRECATED
598 responseMap["seed_capability"]
599 = OSD.FromString(
600 regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + "/" + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath));
601
602 // REPLACEMENT
603 responseMap["region_seed_capability"]
604 = OSD.FromString(
605 regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + "/" + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath));
606
607 responseMap["rez_avatar"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath);
608 responseMap["rez_avatar/rez"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath);
609 responseMap["rez_avatar/derez"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + derezAvatarPath);
610
611 // Add the user to the list of CAPS that are outstanding.
612 // well allow the caps hosts in this dictionary
613 lock (CapsLoginID)
614 {
615 if (CapsLoginID.ContainsKey(rezAvatarPath))
616 {
617 CapsLoginID[rezAvatarPath] = agentData;
618
619 // This is a joke, if you didn't notice... It's so unlikely to happen, that I'll print this message if it does occur!
620 m_log.Error("[OGP]: Holy anomoly batman! Caps path already existed! All the UUID Duplication worries were founded!");
621 }
622 else
623 {
624 CapsLoginID.Add(rezAvatarPath, agentData);
625 }
626 }
627
628 //m_log.Debug("Response:" + responseMap.ToString());
629 return responseMap;
630 }
631
632 public OSD RezAvatarMethod(string path, OSD request)
633 {
634 m_log.WarnFormat("[REZAVATAR]: {0}", request.ToString());
635
636 OSDMap responseMap = new OSDMap();
637
638 AgentCircuitData userData = null;
639
640 // Only people we've issued a cap can go further
641 if (TryGetAgentCircuitData(path,out userData))
642 {
643 OSDMap requestMap = (OSDMap)request;
644
645 // take these values to start. There's a few more
646 UUID SecureSessionID=requestMap["secure_session_id"].AsUUID();
647 UUID SessionID = requestMap["session_id"].AsUUID();
648 int circuitcode = requestMap["circuit_code"].AsInteger();
649 OSDArray Parameter = new OSDArray();
650 if (requestMap.ContainsKey("parameter"))
651 {
652 Parameter = (OSDArray)requestMap["parameter"];
653 }
654
655 //int version = 1;
656 int estateID = 1;
657 int parentEstateID = 1;
658 UUID regionID = UUID.Zero;
659 bool visibleToParent = true;
660
661 for (int i = 0; i < Parameter.Count; i++)
662 {
663 OSDMap item = (OSDMap)Parameter[i];
664// if (item.ContainsKey("version"))
665// {
666// version = item["version"].AsInteger();
667// }
668 if (item.ContainsKey("estate_id"))
669 {
670 estateID = item["estate_id"].AsInteger();
671 }
672 if (item.ContainsKey("parent_estate_id"))
673 {
674 parentEstateID = item["parent_estate_id"].AsInteger();
675
676 }
677 if (item.ContainsKey("region_id"))
678 {
679 regionID = item["region_id"].AsUUID();
680
681 }
682 if (item.ContainsKey("visible_to_parent"))
683 {
684 visibleToParent = item["visible_to_parent"].AsBoolean();
685 }
686 }
687 //Update our Circuit data with the real values
688 userData.SecureSessionID = SecureSessionID;
689 userData.SessionID = SessionID;
690
691 OGPState userState = GetOGPState(userData.AgentID);
692
693 // Locate a home scene suitable for the user.
694 Scene homeScene = null;
695
696 homeScene = GetScene(userState.teleported_into_region);
697
698 if (homeScene == null)
699 homeScene = GetRootScene();
700
701 if (homeScene != null)
702 {
703 // Get a referenceokay - to their Cap object so we can pull out the capobjectroot
704 Caps userCap
705 = homeScene.CapsModule.GetCapsForUser(userData.AgentID);
706
707 //Update the circuit data in the region so this user is authorized
708 homeScene.UpdateCircuitData(userData);
709 homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode);
710
711 // Load state
712
713
714 // Keep state changes
715 userState.first_name = requestMap["first_name"].AsString();
716 userState.secure_session_id = requestMap["secure_session_id"].AsUUID();
717 userState.age_verified = requestMap["age_verified"].AsBoolean();
718 userState.region_id = homeScene.RegionInfo.originRegionID; // replace 0000000 with our regionid
719 userState.transacted = requestMap["transacted"].AsBoolean();
720 userState.agent_access = requestMap["agent_access"].AsBoolean();
721 userState.inventory_host = requestMap["inventory_host"].AsString();
722 userState.identified = requestMap["identified"].AsBoolean();
723 userState.session_id = requestMap["session_id"].AsUUID();
724 userState.god_level = (uint)requestMap["god_level"].AsInteger();
725 userState.last_name = requestMap["last_name"].AsString();
726 userState.god_overide = requestMap["god_override"].AsBoolean();
727 userState.circuit_code = (uint)requestMap["circuit_code"].AsInteger();
728 userState.limited_to_estate = requestMap["limited_to_estate"].AsInteger();
729 userState.src_estate_id = estateID;
730 userState.region_id = regionID;
731 userState.src_parent_estate_id = parentEstateID;
732 userState.visible_to_parent = visibleToParent;
733
734 // Save state changes
735 UpdateOGPState(userData.AgentID, userState);
736
737 // Get the region information for the home region.
738 RegionInfo reg = homeScene.RegionInfo;
739
740 // Dummy positional and look at info.. we don't have it.
741 OSDArray PositionArray = new OSDArray();
742 PositionArray.Add(OSD.FromInteger(128));
743 PositionArray.Add(OSD.FromInteger(128));
744 PositionArray.Add(OSD.FromInteger(40));
745
746 OSDArray LookAtArray = new OSDArray();
747 LookAtArray.Add(OSD.FromInteger(1));
748 LookAtArray.Add(OSD.FromInteger(1));
749 LookAtArray.Add(OSD.FromInteger(1));
750
751 // Our region's X and Y position in OpenSimulator space.
752 uint fooX = reg.RegionLocX;
753 uint fooY = reg.RegionLocY;
754 m_log.InfoFormat("[OGP]: region x({0}) region y({1})", fooX, fooY);
755 m_log.InfoFormat("[OGP]: region http {0} {1}", reg.ServerURI, reg.HttpPort);
756 m_log.InfoFormat("[OGO]: region UUID {0} ", reg.RegionID);
757
758 // Convert the X and Y position to LL space
759 responseMap["region_x"] = OSD.FromInteger(fooX * (uint)Constants.RegionSize); // convert it to LL X
760 responseMap["region_y"] = OSD.FromInteger(fooY * (uint)Constants.RegionSize); // convert it to LL Y
761
762 // Give em a new seed capability
763 responseMap["seed_capability"] = OSD.FromString("http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + userCap.CapsObjectPath + "0000/");
764 responseMap["region"] = OSD.FromUUID(reg.originRegionID);
765 responseMap["look_at"] = LookAtArray;
766
767 responseMap["sim_port"] = OSD.FromInteger(reg.InternalEndPoint.Port);
768 responseMap["sim_host"] = OSD.FromString(reg.ExternalHostName);// + ":" + reg.InternalEndPoint.Port.ToString());
769
770 // DEPRECATED
771 responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(reg.ExternalHostName).ToString());
772
773 responseMap["session_id"] = OSD.FromUUID(SessionID);
774 responseMap["secure_session_id"] = OSD.FromUUID(SecureSessionID);
775 responseMap["circuit_code"] = OSD.FromInteger(circuitcode);
776
777 responseMap["position"] = PositionArray;
778
779 responseMap["region_id"] = OSD.FromUUID(reg.originRegionID);
780
781 responseMap["sim_access"] = OSD.FromString("Mature");
782
783 responseMap["connect"] = OSD.FromBoolean(true);
784
785
786
787 m_log.InfoFormat("[OGP]: host: {0}, IP {1}", responseMap["sim_host"].ToString(), responseMap["sim_ip"].ToString());
788 }
789 }
790
791 return responseMap;
792 }
793
794 public OSD DerezAvatarMethod(string path, OSD request)
795 {
796 m_log.ErrorFormat("DerezPath: {0}, Request: {1}", path, request.ToString());
797
798 //LLSD llsdResponse = null;
799 OSDMap responseMap = new OSDMap();
800
801 string[] PathArray = path.Split('/');
802 m_log.InfoFormat("[OGP]: prefix {0}, uuid {1}, suffix {2}", PathArray[1], PathArray[2], PathArray[3]);
803 string uuidString = PathArray[2];
804 m_log.InfoFormat("[OGP]: Request to Derez avatar with UUID {0}", uuidString);
805 UUID userUUID = UUID.Zero;
806 if (UUID.TryParse(uuidString, out userUUID))
807 {
808 UUID RemoteID = (UUID)uuidString;
809 UUID LocalID = RemoteID;
810 // FIXME: TODO: Routine to map RemoteUUIDs to LocalUUIds
811 // would be done already.. but the client connects with the Aditi UUID
812 // regardless over the UDP stack
813
814 OGPState userState = GetOGPState(LocalID);
815 if (userState.agent_id != UUID.Zero)
816 {
817 //OSDMap outboundRequestMap = new OSDMap();
818 OSDMap inboundRequestMap = (OSDMap)request;
819 string rezAvatarString = inboundRequestMap["rez_avatar"].AsString();
820 if (rezAvatarString.Length == 0)
821 {
822 rezAvatarString = inboundRequestMap["rez_avatar/rez"].AsString();
823 }
824 OSDArray LookAtArray = new OSDArray();
825 LookAtArray.Add(OSD.FromInteger(1));
826 LookAtArray.Add(OSD.FromInteger(1));
827 LookAtArray.Add(OSD.FromInteger(1));
828
829 OSDArray PositionArray = new OSDArray();
830 PositionArray.Add(OSD.FromInteger(128));
831 PositionArray.Add(OSD.FromInteger(128));
832 PositionArray.Add(OSD.FromInteger(40));
833
834 OSDArray lookArray = new OSDArray();
835 lookArray.Add(OSD.FromInteger(128));
836 lookArray.Add(OSD.FromInteger(128));
837 lookArray.Add(OSD.FromInteger(40));
838
839 responseMap["connect"] = OSD.FromBoolean(true);// it's okay to give this user up
840 responseMap["look_at"] = LookAtArray;
841
842 m_log.WarnFormat("[OGP]: Invoking rez_avatar on host:{0} for avatar: {1} {2}", rezAvatarString, userState.first_name, userState.last_name);
843
844 OSDMap rezResponseMap = invokeRezAvatarCap(responseMap, rezAvatarString,userState);
845
846 // If invoking it returned an error, parse and end
847 if (rezResponseMap.ContainsKey("connect"))
848 {
849 if (rezResponseMap["connect"].AsBoolean() == false)
850 {
851 return responseMap;
852 }
853 }
854
855 string rezRespSeedCap = "";
856
857 // DEPRECATED
858 if (rezResponseMap.ContainsKey("seed_capability"))
859 rezRespSeedCap = rezResponseMap["seed_capability"].AsString();
860
861 // REPLACEMENT
862 if (rezResponseMap.ContainsKey("region_seed_capability"))
863 rezRespSeedCap = rezResponseMap["region_seed_capability"].AsString();
864
865 // REPLACEMENT
866 if (rezResponseMap.ContainsKey("rez_avatar/rez"))
867 rezRespSeedCap = rezResponseMap["rez_avatar/rez"].AsString();
868
869 // DEPRECATED
870 string rezRespSim_ip = rezResponseMap["sim_ip"].AsString();
871
872 string rezRespSim_host = rezResponseMap["sim_host"].AsString();
873
874 int rrPort = rezResponseMap["sim_port"].AsInteger();
875 int rrX = rezResponseMap["region_x"].AsInteger();
876 int rrY = rezResponseMap["region_y"].AsInteger();
877 m_log.ErrorFormat("X:{0}, Y:{1}", rrX, rrY);
878 UUID rrRID = rezResponseMap["region_id"].AsUUID();
879 OSDArray RezResponsePositionArray = null;
880 string rrAccess = rezResponseMap["sim_access"].AsString();
881 if (rezResponseMap.ContainsKey("position"))
882 {
883 RezResponsePositionArray = (OSDArray)rezResponseMap["position"];
884 }
885 // DEPRECATED
886 responseMap["seed_capability"] = OSD.FromString(rezRespSeedCap);
887
888 // REPLACEMENT r3
889 responseMap["region_seed_capability"] = OSD.FromString(rezRespSeedCap);
890
891 // DEPRECATED
892 responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(rezRespSim_ip).ToString());
893
894 responseMap["sim_host"] = OSD.FromString(rezRespSim_host);
895 responseMap["sim_port"] = OSD.FromInteger(rrPort);
896 responseMap["region_x"] = OSD.FromInteger(rrX);
897 responseMap["region_y"] = OSD.FromInteger(rrY);
898 responseMap["region_id"] = OSD.FromUUID(rrRID);
899 responseMap["sim_access"] = OSD.FromString(rrAccess);
900
901 if (RezResponsePositionArray != null)
902 {
903 responseMap["position"] = RezResponsePositionArray;
904 }
905 responseMap["look_at"] = lookArray;
906 responseMap["connect"] = OSD.FromBoolean(true);
907
908 ShutdownConnection(LocalID,this);
909 // PLEASE STOP CHANGING THIS TO an M_LOG, M_LOG DOESN'T WORK ON MULTILINE .TOSTRINGS
910 Console.WriteLine("RESPONSEDEREZ: " + responseMap.ToString());
911 return responseMap;
912 }
913 else
914 {
915 return GenerateNoStateMessage(LocalID);
916 }
917 }
918 else
919 {
920 return GenerateNoHandlerMessage();
921 }
922
923 //return responseMap;
924 }
925
926 private OSDMap invokeRezAvatarCap(OSDMap responseMap, string CapAddress, OGPState userState)
927 {
928 Scene reg = GetRootScene();
929
930 WebRequest DeRezRequest = WebRequest.Create(CapAddress);
931 DeRezRequest.Method = "POST";
932 DeRezRequest.ContentType = "application/xml+llsd";
933
934 OSDMap RAMap = new OSDMap();
935 OSDMap AgentParms = new OSDMap();
936 OSDMap RegionParms = new OSDMap();
937
938 OSDArray Parameter = new OSDArray(2);
939
940 OSDMap version = new OSDMap();
941 version["version"] = OSD.FromInteger(userState.src_version);
942 Parameter.Add(version);
943
944 OSDMap SrcData = new OSDMap();
945 SrcData["estate_id"] = OSD.FromInteger(reg.RegionInfo.EstateSettings.EstateID);
946 SrcData["parent_estate_id"] = OSD.FromInteger((reg.RegionInfo.EstateSettings.ParentEstateID == 100 ? 1 : reg.RegionInfo.EstateSettings.ParentEstateID));
947 SrcData["region_id"] = OSD.FromUUID(reg.RegionInfo.originRegionID);
948 SrcData["visible_to_parent"] = OSD.FromBoolean(userState.visible_to_parent);
949 Parameter.Add(SrcData);
950
951 AgentParms["first_name"] = OSD.FromString(userState.first_name);
952 AgentParms["last_name"] = OSD.FromString(userState.last_name);
953 AgentParms["agent_id"] = OSD.FromUUID(userState.agent_id);
954 RegionParms["region_id"] = OSD.FromUUID(userState.region_id);
955 AgentParms["circuit_code"] = OSD.FromInteger(userState.circuit_code);
956 AgentParms["secure_session_id"] = OSD.FromUUID(userState.secure_session_id);
957 AgentParms["session_id"] = OSD.FromUUID(userState.session_id);
958 AgentParms["agent_access"] = OSD.FromBoolean(userState.agent_access);
959 AgentParms["god_level"] = OSD.FromInteger(userState.god_level);
960 AgentParms["god_overide"] = OSD.FromBoolean(userState.god_overide);
961 AgentParms["identified"] = OSD.FromBoolean(userState.identified);
962 AgentParms["transacted"] = OSD.FromBoolean(userState.transacted);
963 AgentParms["age_verified"] = OSD.FromBoolean(userState.age_verified);
964 AgentParms["limited_to_estate"] = OSD.FromInteger(userState.limited_to_estate);
965 AgentParms["inventory_host"] = OSD.FromString(userState.inventory_host);
966
967 // version 1
968 RAMap = AgentParms;
969
970 // Planned for version 2
971 // RAMap["agent_params"] = AgentParms;
972
973 RAMap["region_params"] = RegionParms;
974 RAMap["parameter"] = Parameter;
975
976 string RAMapString = RAMap.ToString();
977 m_log.InfoFormat("[OGP] RAMap string {0}", RAMapString);
978 OSD LLSDofRAMap = RAMap; // RENAME if this works
979
980 m_log.InfoFormat("[OGP]: LLSD of map as string was {0}", LLSDofRAMap.ToString());
981 //m_log.InfoFormat("[OGP]: LLSD+XML: {0}", LLSDParser.SerializeXmlString(LLSDofRAMap));
982 byte[] buffer = OSDParser.SerializeLLSDXmlBytes(LLSDofRAMap);
983
984 //string bufferDump = System.Text.Encoding.ASCII.GetString(buffer);
985 //m_log.InfoFormat("[OGP]: buffer form is {0}",bufferDump);
986 //m_log.InfoFormat("[OGP]: LLSD of map was {0}",buffer.Length);
987
988 Stream os = null;
989 try
990 { // send the Post
991 DeRezRequest.ContentLength = buffer.Length; //Count bytes to send
992 os = DeRezRequest.GetRequestStream();
993 os.Write(buffer, 0, buffer.Length); //Send it
994 os.Close();
995 m_log.InfoFormat("[OGP]: Derez Avatar Posted Rez Avatar request to remote sim {0}", CapAddress);
996 }
997 catch (WebException ex)
998 {
999 m_log.InfoFormat("[OGP] Bad send on de_rez_avatar {0}", ex.Message);
1000 responseMap["connect"] = OSD.FromBoolean(false);
1001
1002 return responseMap;
1003 }
1004
1005 m_log.Info("[OGP] waiting for a reply after rez avatar send");
1006 string rez_avatar_reply = null;
1007 { // get the response
1008 try
1009 {
1010 WebResponse webResponse = DeRezRequest.GetResponse();
1011 if (webResponse == null)
1012 {
1013 m_log.Info("[OGP:] Null reply on rez_avatar post");
1014 }
1015
1016 StreamReader sr = new StreamReader(webResponse.GetResponseStream());
1017 rez_avatar_reply = sr.ReadToEnd().Trim();
1018 m_log.InfoFormat("[OGP]: rez_avatar reply was {0} ", rez_avatar_reply);
1019
1020 }
1021 catch (WebException ex)
1022 {
1023 m_log.InfoFormat("[OGP]: exception on read after send of rez avatar {0}", ex.Message);
1024 responseMap["connect"] = OSD.FromBoolean(false);
1025
1026 return responseMap;
1027 }
1028 OSD rezResponse = null;
1029 try
1030 {
1031 rezResponse = OSDParser.DeserializeLLSDXml(rez_avatar_reply);
1032
1033 responseMap = (OSDMap)rezResponse;
1034 }
1035 catch (Exception ex)
1036 {
1037 m_log.InfoFormat("[OGP]: exception on parse of rez reply {0}", ex.Message);
1038 responseMap["connect"] = OSD.FromBoolean(false);
1039
1040 return responseMap;
1041 }
1042 }
1043 return responseMap;
1044 }
1045
1046 public OSD GenerateNoHandlerMessage()
1047 {
1048 OSDMap map = new OSDMap();
1049 map["reason"] = OSD.FromString("LLSDRequest");
1050 map["message"] = OSD.FromString("No handler registered for LLSD Requests");
1051 map["login"] = OSD.FromString("false");
1052 map["connect"] = OSD.FromString("false");
1053 return map;
1054 }
1055 public OSD GenerateNoStateMessage(UUID passedAvatar)
1056 {
1057 OSDMap map = new OSDMap();
1058 map["reason"] = OSD.FromString("derez failed");
1059 map["message"] = OSD.FromString("Unable to locate OGP state for avatar " + passedAvatar.ToString());
1060 map["login"] = OSD.FromString("false");
1061 map["connect"] = OSD.FromString("false");
1062 return map;
1063 }
1064 private bool TryGetAgentCircuitData(string path, out AgentCircuitData userdata)
1065 {
1066 userdata = null;
1067 lock (CapsLoginID)
1068 {
1069 if (CapsLoginID.ContainsKey(path))
1070 {
1071 userdata = CapsLoginID[path];
1072 DiscardUsedCap(path);
1073 return true;
1074 }
1075 }
1076 return false;
1077 }
1078
1079 private void DiscardUsedCap(string path)
1080 {
1081 CapsLoginID.Remove(path);
1082 }
1083
1084 private Scene GetRootScene()
1085 {
1086 Scene ReturnScene = null;
1087 lock (m_scene)
1088 {
1089 if (m_scene.Count > 0)
1090 {
1091 ReturnScene = m_scene[0];
1092 }
1093 }
1094
1095 return ReturnScene;
1096 }
1097
1098 private Scene GetScene(string scenename)
1099 {
1100 Scene ReturnScene = null;
1101 lock (m_scene)
1102 {
1103 foreach (Scene s in m_scene)
1104 {
1105 if (s.RegionInfo.RegionName.ToLower() == scenename)
1106 {
1107 ReturnScene = s;
1108 break;
1109 }
1110 }
1111 }
1112
1113 return ReturnScene;
1114 }
1115
1116 private ulong GetOSCompatibleRegionHandle(RegionInfo reg)
1117 {
1118 return Util.UIntsToLong(reg.RegionLocX, reg.RegionLocY);
1119 }
1120
1121 private OGPState InitializeNewState()
1122 {
1123 OGPState returnState = new OGPState();
1124 returnState.first_name = "";
1125 returnState.last_name = "";
1126 returnState.agent_id = UUID.Zero;
1127 returnState.local_agent_id = UUID.Zero;
1128 returnState.region_id = UUID.Zero;
1129 returnState.circuit_code = 0;
1130 returnState.secure_session_id = UUID.Zero;
1131 returnState.session_id = UUID.Zero;
1132 returnState.agent_access = true;
1133 returnState.god_level = 0;
1134 returnState.god_overide = false;
1135 returnState.identified = false;
1136 returnState.transacted = false;
1137 returnState.age_verified = false;
1138 returnState.limited_to_estate = 1;
1139 returnState.inventory_host = "http://inv4.mysql.aditi.lindenlab.com";
1140 returnState.allow_redirect = true;
1141 returnState.sim_access = "";
1142 returnState.src_can_see_mainland = true;
1143 returnState.src_estate_id = 1;
1144 returnState.src_version = 1;
1145 returnState.src_parent_estate_id = 1;
1146 returnState.visible_to_parent = true;
1147 returnState.teleported_into_region = "";
1148
1149 return returnState;
1150 }
1151
1152 private OGPState GetOGPState(UUID agentId)
1153 {
1154 lock (m_OGPState)
1155 {
1156 if (m_OGPState.ContainsKey(agentId))
1157 {
1158 return m_OGPState[agentId];
1159 }
1160 else
1161 {
1162 return InitializeNewState();
1163 }
1164 }
1165 }
1166
1167 public void DeleteOGPState(UUID agentId)
1168 {
1169 lock (m_OGPState)
1170 {
1171 if (m_OGPState.ContainsKey(agentId))
1172 m_OGPState.Remove(agentId);
1173 }
1174 }
1175
1176 private void UpdateOGPState(UUID agentId, OGPState state)
1177 {
1178 lock (m_OGPState)
1179 {
1180 if (m_OGPState.ContainsKey(agentId))
1181 {
1182 m_OGPState[agentId] = state;
1183 }
1184 else
1185 {
1186 m_OGPState.Add(agentId,state);
1187 }
1188 }
1189 }
1190 private bool SceneListDuplicateCheck(string str)
1191 {
1192 // no lock, called from locked space!
1193 bool found = false;
1194
1195 foreach (Scene s in m_scene)
1196 {
1197 if (s.RegionInfo.RegionName == str)
1198 {
1199 found = true;
1200 break;
1201 }
1202 }
1203
1204 return found;
1205 }
1206
1207 public void ShutdownConnection(UUID avatarId, OpenGridProtocolModule mod)
1208 {
1209 Scene homeScene = GetRootScene();
1210 ScenePresence avatar = null;
1211 if (homeScene.TryGetScenePresence(avatarId,out avatar))
1212 {
1213 KillAUser ku = new KillAUser(avatar,mod);
1214 Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true, true);
1215 }
1216 }
1217
1218// private string CreateRandomStr(int len)
1219// {
1220// Random rnd = new Random(Environment.TickCount);
1221// string returnstring = "";
1222// string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
1223//
1224// for (int i = 0; i < len; i++)
1225// {
1226// returnstring += chars.Substring(rnd.Next(chars.Length), 1);
1227// }
1228// return returnstring;
1229// }
1230
1231 // Temporary hack to allow teleporting to and from Vaak
1232 private static bool customXertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
1233 {
1234 //if (cert.Subject == "E=root@lindenlab.com, CN=*.vaak.lindenlab.com, O=\"Linden Lab, Inc.\", L=San Francisco, S=California, C=US")
1235 //{
1236 return true;
1237 //}
1238
1239 //return false;
1240 }
1241 }
1242
1243 public class KillAUser
1244 {
1245 private ScenePresence avToBeKilled = null;
1246 private OpenGridProtocolModule m_mod = null;
1247
1248 public KillAUser(ScenePresence avatar, OpenGridProtocolModule mod)
1249 {
1250 avToBeKilled = avatar;
1251 m_mod = mod;
1252 }
1253
1254 public void ShutdownNoLogout()
1255 {
1256 UUID avUUID = UUID.Zero;
1257
1258 if (avToBeKilled != null)
1259 {
1260 avUUID = avToBeKilled.UUID;
1261 avToBeKilled.MakeChildAgent();
1262
1263 avToBeKilled.ControllingClient.SendLogoutPacketWhenClosing = false;
1264
1265 int sleepMS = 30000;
1266 while (sleepMS > 0)
1267 {
1268 Watchdog.UpdateThread();
1269 Thread.Sleep(1000);
1270 sleepMS -= 1000;
1271 }
1272
1273 // test for child agent because they might have come back
1274 if (avToBeKilled.IsChildAgent)
1275 {
1276 m_mod.DeleteOGPState(avUUID);
1277 avToBeKilled.ControllingClient.Close();
1278 }
1279 }
1280
1281 Watchdog.RemoveThread();
1282 }
1283
1284 }
1285
1286 public class MonoCert : ICertificatePolicy
1287 {
1288 #region ICertificatePolicy Members
1289
1290 public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
1291 {
1292 return true;
1293 }
1294
1295 #endregion
1296 }
1297}
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 6c73d91..81f1ff6 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -38,6 +38,13 @@
38 <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> 38 <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" />
39 <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> 39 <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/>
40 <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> 40 <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/>
41 <RegionModule id="SunModule" type="OpenSim.Region.CoreModules.SunModule"/>
42 <RegionModule id="WindModule" type="OpenSim.Region.CoreModules.WindModule"/>
43 <RegionModule id="MapSearchModule" type="OpenSim.Region.CoreModules.World.WorldMap.MapSearchModule"/>
44 <RegionModule id="VegetationModule" type="OpenSim.Region.CoreModules.Avatar.Vegetation.VegetationModule"/>
45 <RegionModule id="IPBanModule" type="OpenSim.Region.CoreModules.Agent.IPBan.IPBanModule"/>
46 <RegionModule id="J2KDecoderModule" type="OpenSim.Region.CoreModules.Agent.TextureSender.J2KDecoderModule"/>
47 <RegionModule id="CloudModule" type="OpenSim.Region.CoreModules.CloudModule"/>
41 <!-- Service connectors OUT modules --> 48 <!-- Service connectors OUT modules -->
42 <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> 49 <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" />
43 <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> 50 <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" />
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index e167e31..5f9aa42 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -29,8 +29,12 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text.RegularExpressions; 31using System.Text.RegularExpressions;
32
32using Nini.Config; 33using Nini.Config;
34using Mono.Addins;
35
33using OpenMetaverse; 36using OpenMetaverse;
37
34using OpenSim.Framework; 38using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
@@ -86,7 +90,8 @@ using OpenSim.Region.Framework.Scenes;
86 90
87namespace OpenSim.Region.CoreModules.Scripting.WorldComm 91namespace OpenSim.Region.CoreModules.Scripting.WorldComm
88{ 92{
89 public class WorldCommModule : IRegionModule, IWorldComm 93 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
94 public class WorldCommModule : IWorldComm, INonSharedRegionModule
90 { 95 {
91 // private static readonly ILog m_log = 96 // private static readonly ILog m_log =
92 // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 97 // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -101,9 +106,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
101 private int m_saydistance = 20; 106 private int m_saydistance = 20;
102 private int m_shoutdistance = 100; 107 private int m_shoutdistance = 100;
103 108
104 #region IRegionModule Members 109 #region INonSharedRegionModule Members
105 110
106 public void Initialise(Scene scene, IConfigSource config) 111 public void Initialise(IConfigSource config)
107 { 112 {
108 // wrap this in a try block so that defaults will work if 113 // wrap this in a try block so that defaults will work if
109 // the config file doesn't specify otherwise. 114 // the config file doesn't specify otherwise.
@@ -111,29 +116,49 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
111 int maxhandles = 64; 116 int maxhandles = 64;
112 try 117 try
113 { 118 {
114 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 119 m_whisperdistance = config.Configs["Chat"].GetInt(
115 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 120 "whisper_distance", m_whisperdistance);
116 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 121 m_saydistance = config.Configs["Chat"].GetInt(
117 maxlisteners = config.Configs["LL-Functions"].GetInt("max_listens_per_region", maxlisteners); 122 "say_distance", m_saydistance);
118 maxhandles = config.Configs["LL-Functions"].GetInt("max_listens_per_script", maxhandles); 123 m_shoutdistance = config.Configs["Chat"].GetInt(
124 "shout_distance", m_shoutdistance);
125 maxlisteners = config.Configs["LL-Functions"].GetInt(
126 "max_listens_per_region", maxlisteners);
127 maxhandles = config.Configs["LL-Functions"].GetInt(
128 "max_listens_per_script", maxhandles);
119 } 129 }
120 catch (Exception) 130 catch (Exception)
121 { 131 {
122 } 132 }
123 if (maxlisteners < 1) maxlisteners = int.MaxValue; 133 if (maxlisteners < 1) maxlisteners = int.MaxValue;
124 if (maxhandles < 1) maxhandles = int.MaxValue; 134 if (maxhandles < 1) maxhandles = int.MaxValue;
135 m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
136 m_pendingQ = new Queue();
137 m_pending = Queue.Synchronized(m_pendingQ);
138 }
139
140 public void PostInitialise()
141 {
142 }
125 143
144 public void AddRegion(Scene scene)
145 {
126 m_scene = scene; 146 m_scene = scene;
127 m_scene.RegisterModuleInterface<IWorldComm>(this); 147 m_scene.RegisterModuleInterface<IWorldComm>(this);
128 m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
129 m_scene.EventManager.OnChatFromClient += DeliverClientMessage; 148 m_scene.EventManager.OnChatFromClient += DeliverClientMessage;
130 m_scene.EventManager.OnChatBroadcast += DeliverClientMessage; 149 m_scene.EventManager.OnChatBroadcast += DeliverClientMessage;
131 m_pendingQ = new Queue();
132 m_pending = Queue.Synchronized(m_pendingQ);
133 } 150 }
134 151
135 public void PostInitialise() 152 public void RegionLoaded(Scene scene) { }
153
154 public void RemoveRegion(Scene scene)
136 { 155 {
156 if (scene != m_scene)
157 return;
158
159 m_scene.UnregisterModuleInterface<IWorldComm>(this);
160 m_scene.EventManager.OnChatBroadcast -= DeliverClientMessage;
161 m_scene.EventManager.OnChatBroadcast -= DeliverClientMessage;
137 } 162 }
138 163
139 public void Close() 164 public void Close()
@@ -145,10 +170,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
145 get { return "WorldCommModule"; } 170 get { return "WorldCommModule"; }
146 } 171 }
147 172
148 public bool IsSharedModule 173 public Type ReplaceableInterface { get { return null; } }
149 {
150 get { return false; }
151 }
152 174
153 #endregion 175 #endregion
154 176
@@ -257,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
257 279
258 if ((source = m_scene.GetSceneObjectPart(id)) != null) 280 if ((source = m_scene.GetSceneObjectPart(id)) != null)
259 position = source.AbsolutePosition; 281 position = source.AbsolutePosition;
260 else if ((avatar = m_scene.GetScenePresence(id)) != null) 282 else if ((avatar = m_scene.GetScenePresence(id)) != null)
261 position = avatar.AbsolutePosition; 283 position = avatar.AbsolutePosition;
262 else if (ChatTypeEnum.Region == type) 284 else if (ChatTypeEnum.Region == type)
263 position = CenterOfRegion; 285 position = CenterOfRegion;
@@ -280,7 +302,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
280 /// <param name="name">name of sender (object or avatar)</param> 302 /// <param name="name">name of sender (object or avatar)</param>
281 /// <param name="id">key of sender (object or avatar)</param> 303 /// <param name="id">key of sender (object or avatar)</param>
282 /// <param name="msg">msg to sent</param> 304 /// <param name="msg">msg to sent</param>
283 public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position) 305 public void DeliverMessage(ChatTypeEnum type, int channel,
306 string name, UUID id, string msg, Vector3 position)
284 { 307 {
285 // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", 308 // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}",
286 // type, channel, name, id, msg); 309 // type, channel, name, id, msg);
@@ -288,17 +311,21 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
288 // Determine which listen event filters match the given set of arguments, this results 311 // Determine which listen event filters match the given set of arguments, this results
289 // in a limited set of listeners, each belonging a host. If the host is in range, add them 312 // in a limited set of listeners, each belonging a host. If the host is in range, add them
290 // to the pending queue. 313 // to the pending queue.
291 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 314 foreach (ListenerInfo li
315 in m_listenerManager.GetListeners(UUID.Zero, channel,
316 name, id, msg))
292 { 317 {
293 // Dont process if this message is from yourself! 318 // Dont process if this message is from yourself!
294 if (li.GetHostID().Equals(id)) 319 if (li.GetHostID().Equals(id))
295 continue; 320 continue;
296 321
297 SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); 322 SceneObjectPart sPart = m_scene.GetSceneObjectPart(
323 li.GetHostID());
298 if (sPart == null) 324 if (sPart == null)
299 continue; 325 continue;
300 326
301 double dis = Util.GetDistanceTo(sPart.AbsolutePosition, position); 327 double dis = Util.GetDistanceTo(sPart.AbsolutePosition,
328 position);
302 switch (type) 329 switch (type)
303 { 330 {
304 case ChatTypeEnum.Whisper: 331 case ChatTypeEnum.Whisper:
@@ -400,11 +427,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
400 if (li.GetHostID().Equals(id)) 427 if (li.GetHostID().Equals(id))
401 continue; 428 continue;
402 429
403 SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); 430 SceneObjectPart sPart = m_scene.GetSceneObjectPart(
431 li.GetHostID());
404 if (sPart == null) 432 if (sPart == null)
405 continue; 433 continue;
406 434
407 if ( li.GetHostID().Equals(target)) 435 if (li.GetHostID().Equals(target))
408 { 436 {
409 QueueMessage(new ListenerInfo(li, name, id, msg)); 437 QueueMessage(new ListenerInfo(li, name, id, msg));
410 break; 438 break;
@@ -458,9 +486,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
458 private void DeliverClientMessage(Object sender, OSChatMessage e) 486 private void DeliverClientMessage(Object sender, OSChatMessage e)
459 { 487 {
460 if (null != e.Sender) 488 if (null != e.Sender)
461 DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position); 489 {
490 DeliverMessage(e.Type, e.Channel, e.Sender.Name,
491 e.Sender.AgentId, e.Message, e.Position);
492 }
462 else 493 else
463 DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position); 494 {
495 DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero,
496 e.Message, e.Position);
497 }
464 } 498 }
465 499
466 public Object[] GetSerializationData(UUID itemID) 500 public Object[] GetSerializationData(UUID itemID)
@@ -477,7 +511,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
477 511
478 public class ListenerManager 512 public class ListenerManager
479 { 513 {
480 private Dictionary<int, List<ListenerInfo>> m_listeners = new Dictionary<int, List<ListenerInfo>>(); 514 private Dictionary<int, List<ListenerInfo>> m_listeners =
515 new Dictionary<int, List<ListenerInfo>>();
481 private int m_maxlisteners; 516 private int m_maxlisteners;
482 private int m_maxhandles; 517 private int m_maxhandles;
483 private int m_curlisteners; 518 private int m_curlisteners;
@@ -535,14 +570,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
535 itemID, hostID, channel, name, id, msg, 570 itemID, hostID, channel, name, id, msg,
536 regexBitfield); 571 regexBitfield);
537 572
538 List<ListenerInfo> listeners; 573 List<ListenerInfo> listeners;
539 if (!m_listeners.TryGetValue(channel,out listeners)) 574 if (!m_listeners.TryGetValue(
540 { 575 channel, out listeners))
541 listeners = new List<ListenerInfo>(); 576 {
542 m_listeners.Add(channel, listeners); 577 listeners = new List<ListenerInfo>();
543 } 578 m_listeners.Add(channel, listeners);
544 listeners.Add(li); 579 }
545 m_curlisteners++; 580 listeners.Add(li);
581 m_curlisteners++;
546 582
547 return newHandle; 583 return newHandle;
548 } 584 }
@@ -555,11 +591,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
555 { 591 {
556 lock (m_listeners) 592 lock (m_listeners)
557 { 593 {
558 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 594 foreach (KeyValuePair<int, List<ListenerInfo>> lis
595 in m_listeners)
559 { 596 {
560 foreach (ListenerInfo li in lis.Value) 597 foreach (ListenerInfo li in lis.Value)
561 { 598 {
562 if (li.GetItemID().Equals(itemID) && li.GetHandle().Equals(handle)) 599 if (li.GetItemID().Equals(itemID) &&
600 li.GetHandle().Equals(handle))
563 { 601 {
564 lis.Value.Remove(li); 602 lis.Value.Remove(li);
565 if (lis.Value.Count == 0) 603 if (lis.Value.Count == 0)
@@ -582,13 +620,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
582 620
583 lock (m_listeners) 621 lock (m_listeners)
584 { 622 {
585 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 623 foreach (KeyValuePair<int, List<ListenerInfo>> lis
624 in m_listeners)
586 { 625 {
587 foreach (ListenerInfo li in lis.Value) 626 foreach (ListenerInfo li in lis.Value)
588 { 627 {
589 if (li.GetItemID().Equals(itemID)) 628 if (li.GetItemID().Equals(itemID))
590 { 629 {
591 // store them first, else the enumerated bails on us 630 // store them first, else the enumerated bails on
631 // us
592 removedListeners.Add(li); 632 removedListeners.Add(li);
593 } 633 }
594 } 634 }
@@ -615,11 +655,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
615 { 655 {
616 lock (m_listeners) 656 lock (m_listeners)
617 { 657 {
618 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 658 foreach (KeyValuePair<int, List<ListenerInfo>> lis
659 in m_listeners)
619 { 660 {
620 foreach (ListenerInfo li in lis.Value) 661 foreach (ListenerInfo li in lis.Value)
621 { 662 {
622 if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) 663 if (li.GetItemID().Equals(itemID) &&
664 li.GetHandle() == handle)
623 { 665 {
624 li.Activate(); 666 li.Activate();
625 // only one, bail out 667 // only one, bail out
@@ -634,11 +676,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
634 { 676 {
635 lock (m_listeners) 677 lock (m_listeners)
636 { 678 {
637 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 679 foreach (KeyValuePair<int, List<ListenerInfo>> lis
680 in m_listeners)
638 { 681 {
639 foreach (ListenerInfo li in lis.Value) 682 foreach (ListenerInfo li in lis.Value)
640 { 683 {
641 if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) 684 if (li.GetItemID().Equals(itemID) &&
685 li.GetHandle() == handle)
642 { 686 {
643 li.Deactivate(); 687 li.Deactivate();
644 // only one, bail out 688 // only one, bail out
@@ -649,19 +693,24 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
649 } 693 }
650 } 694 }
651 695
652 // non-locked access, since its always called in the context of the lock 696 /// <summary>
697 /// non-locked access, since its always called in the context of the
698 /// lock
699 /// </summary>
700 /// <param name="itemID"></param>
701 /// <returns></returns>
653 private int GetNewHandle(UUID itemID) 702 private int GetNewHandle(UUID itemID)
654 { 703 {
655 List<int> handles = new List<int>(); 704 List<int> handles = new List<int>();
656 705
657 // build a list of used keys for this specific itemID... 706 // build a list of used keys for this specific itemID...
658 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 707 foreach (KeyValuePair<int, List<ListenerInfo>> lis in m_listeners)
659 { 708 {
660 foreach (ListenerInfo li in lis.Value) 709 foreach (ListenerInfo li in lis.Value)
661 { 710 {
662 if (li.GetItemID().Equals(itemID)) 711 if (li.GetItemID().Equals(itemID))
663 handles.Add(li.GetHandle()); 712 handles.Add(li.GetHandle());
664 } 713 }
665 } 714 }
666 715
667 // Note: 0 is NOT a valid handle for llListen() to return 716 // Note: 0 is NOT a valid handle for llListen() to return
@@ -690,17 +739,30 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
690 739
691 #endregion 740 #endregion
692 741
693 // Theres probably a more clever and efficient way to 742 /// <summary>
694 // do this, maybe with regex. 743 /// Get listeners matching the input parameters.
695 // PM2008: Ha, one could even be smart and define a specialized Enumerator. 744 /// </summary>
696 public List<ListenerInfo> GetListeners(UUID itemID, int channel, string name, UUID id, string msg) 745 /// <remarks>
746 /// Theres probably a more clever and efficient way to do this, maybe
747 /// with regex.
748 /// PM2008: Ha, one could even be smart and define a specialized
749 /// Enumerator.
750 /// </remarks>
751 /// <param name="itemID"></param>
752 /// <param name="channel"></param>
753 /// <param name="name"></param>
754 /// <param name="id"></param>
755 /// <param name="msg"></param>
756 /// <returns></returns>
757 public List<ListenerInfo> GetListeners(UUID itemID, int channel,
758 string name, UUID id, string msg)
697 { 759 {
698 List<ListenerInfo> collection = new List<ListenerInfo>(); 760 List<ListenerInfo> collection = new List<ListenerInfo>();
699 761
700 lock (m_listeners) 762 lock (m_listeners)
701 { 763 {
702 List<ListenerInfo> listeners; 764 List<ListenerInfo> listeners;
703 if (!m_listeners.TryGetValue(channel,out listeners)) 765 if (!m_listeners.TryGetValue(channel, out listeners))
704 { 766 {
705 return collection; 767 return collection;
706 } 768 }
@@ -711,7 +773,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
711 { 773 {
712 continue; 774 continue;
713 } 775 }
714 if (!itemID.Equals(UUID.Zero) && !li.GetItemID().Equals(itemID)) 776 if (!itemID.Equals(UUID.Zero) &&
777 !li.GetItemID().Equals(itemID))
715 { 778 {
716 continue; 779 continue;
717 } 780 }
@@ -776,28 +839,68 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
776 lock (m_listeners) 839 lock (m_listeners)
777 { 840 {
778 if (!m_listeners.ContainsKey((int)item[2])) 841 if (!m_listeners.ContainsKey((int)item[2]))
779 m_listeners.Add((int)item[2], new List<ListenerInfo>()); 842 {
843 m_listeners.Add((int)item[2],
844 new List<ListenerInfo>());
845 }
780 m_listeners[(int)item[2]].Add(info); 846 m_listeners[(int)item[2]].Add(info);
781 } 847 }
782 848
783 idx+=dataItemLength; 849 idx += dataItemLength;
784 } 850 }
785 } 851 }
786 } 852 }
787 853
788 public class ListenerInfo : IWorldCommListenerInfo 854 public class ListenerInfo : IWorldCommListenerInfo
789 { 855 {
790 private bool m_active; // Listener is active or not 856 /// <summary>
791 private int m_handle; // Assigned handle of this listener 857 /// Listener is active or not
792 private uint m_localID; // Local ID from script engine 858 /// </summary>
793 private UUID m_itemID; // ID of the host script engine 859 private bool m_active;
794 private UUID m_hostID; // ID of the host/scene part 860
795 private int m_channel; // Channel 861 /// <summary>
796 private UUID m_id; // ID to filter messages from 862 /// Assigned handle of this listener
797 private string m_name; // Object name to filter messages from 863 /// </summary>
798 private string m_message; // The message 864 private int m_handle;
799 865
800 public ListenerInfo(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message) 866 /// <summary>
867 /// Local ID from script engine
868 /// </summary>
869 private uint m_localID;
870
871 /// <summary>
872 /// ID of the host script engine
873 /// </summary>
874 private UUID m_itemID;
875
876 /// <summary>
877 /// ID of the host/scene part
878 /// </summary>
879 private UUID m_hostID;
880
881 /// <summary>
882 /// Channel
883 /// </summary>
884 private int m_channel;
885
886 /// <summary>
887 /// ID to filter messages from
888 /// </summary>
889 private UUID m_id;
890
891 /// <summary>
892 /// Object name to filter messages from
893 /// </summary>
894 private string m_name;
895
896 /// <summary>
897 /// The message
898 /// </summary>
899 private string m_message;
900
901 public ListenerInfo(int handle, uint localID, UUID ItemID,
902 UUID hostID, int channel, string name, UUID id,
903 string message)
801 { 904 {
802 Initialise(handle, localID, ItemID, hostID, channel, name, id, 905 Initialise(handle, localID, ItemID, hostID, channel, name, id,
803 message, 0); 906 message, 0);
@@ -811,17 +914,23 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
811 message, regexBitfield); 914 message, regexBitfield);
812 } 915 }
813 916
814 public ListenerInfo(ListenerInfo li, string name, UUID id, string message) 917 public ListenerInfo(ListenerInfo li, string name, UUID id,
918 string message)
815 { 919 {
816 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message, 0); 920 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID,
921 li.m_channel, name, id, message, 0);
817 } 922 }
818 923
819 public ListenerInfo(ListenerInfo li, string name, UUID id, string message, int regexBitfield) 924 public ListenerInfo(ListenerInfo li, string name, UUID id,
925 string message, int regexBitfield)
820 { 926 {
821 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message, regexBitfield); 927 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID,
928 li.m_channel, name, id, message, regexBitfield);
822 } 929 }
823 930
824 private void Initialise(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message, int regexBitfield) 931 private void Initialise(int handle, uint localID, UUID ItemID,
932 UUID hostID, int channel, string name, UUID id,
933 string message, int regexBitfield)
825 { 934 {
826 m_active = true; 935 m_active = true;
827 m_handle = handle; 936 m_handle = handle;
@@ -850,9 +959,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
850 return data; 959 return data;
851 } 960 }
852 961
853 public static ListenerInfo FromData(uint localID, UUID ItemID, UUID hostID, Object[] data) 962 public static ListenerInfo FromData(uint localID, UUID ItemID,
963 UUID hostID, Object[] data)
854 { 964 {
855 ListenerInfo linfo = new ListenerInfo((int)data[1], localID, ItemID, hostID, (int)data[2], (string)data[3], (UUID)data[4], (string)data[5]); 965 ListenerInfo linfo = new ListenerInfo((int)data[1], localID,
966 ItemID, hostID, (int)data[2], (string)data[3],
967 (UUID)data[4], (string)data[5]);
856 linfo.m_active = (bool)data[0]; 968 linfo.m_active = (bool)data[0];
857 if (data.Length >= 7) 969 if (data.Length >= 7)
858 { 970 {
diff --git a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
index 5fa3dc2..2ec6ff9 100644
--- a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
+++ b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
@@ -35,7 +35,7 @@ using OpenSim.Region.Framework.Scenes;
35 35
36namespace OpenSim.Region.CoreModules 36namespace OpenSim.Region.CoreModules
37{ 37{
38 public class CloudModule : ICloudModule 38 public class CloudModule : ICloudModule, INonSharedRegionModule
39 { 39 {
40// private static readonly log4net.ILog m_log 40// private static readonly log4net.ILog m_log
41// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 41// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules
48 private float m_cloudDensity = 1.0F; 48 private float m_cloudDensity = 1.0F;
49 private float[] cloudCover = new float[16 * 16]; 49 private float[] cloudCover = new float[16 * 16];
50 50
51 public void Initialise(Scene scene, IConfigSource config) 51 public void Initialise(IConfigSource config)
52 { 52 {
53 IConfig cloudConfig = config.Configs["Cloud"]; 53 IConfig cloudConfig = config.Configs["Cloud"];
54 54
@@ -59,21 +59,40 @@ namespace OpenSim.Region.CoreModules
59 m_frameUpdateRate = cloudConfig.GetInt("cloud_update_rate", 1000); 59 m_frameUpdateRate = cloudConfig.GetInt("cloud_update_rate", 1000);
60 } 60 }
61 61
62 if (m_enabled) 62 }
63 {
64 63
65 m_scene = scene; 64 public void AddRegion(Scene scene)
65 {
66 if (!m_enabled)
67 return;
66 68
67 scene.EventManager.OnNewClient += CloudsToClient; 69 m_scene = scene;
68 scene.RegisterModuleInterface<ICloudModule>(this);
69 scene.EventManager.OnFrame += CloudUpdate;
70 70
71 GenerateCloudCover(); 71 scene.EventManager.OnNewClient += CloudsToClient;
72 scene.RegisterModuleInterface<ICloudModule>(this);
73 scene.EventManager.OnFrame += CloudUpdate;
72 74
73 m_ready = true; 75 GenerateCloudCover();
74 76
75 } 77 m_ready = true;
78 }
79
80 public void RemoveRegion(Scene scene)
81 {
82 if (!m_enabled)
83 return;
76 84
85 m_ready = false;
86 // Remove our hooks
87 m_scene.EventManager.OnNewClient -= CloudsToClient;
88 m_scene.EventManager.OnFrame -= CloudUpdate;
89 m_scene.UnregisterModuleInterface<ICloudModule>(this);
90
91 m_scene = null;
92 }
93
94 public void RegionLoaded(Scene scene)
95 {
77 } 96 }
78 97
79 public void PostInitialise() 98 public void PostInitialise()
@@ -82,13 +101,6 @@ namespace OpenSim.Region.CoreModules
82 101
83 public void Close() 102 public void Close()
84 { 103 {
85 if (m_enabled)
86 {
87 m_ready = false;
88 // Remove our hooks
89 m_scene.EventManager.OnNewClient -= CloudsToClient;
90 m_scene.EventManager.OnFrame -= CloudUpdate;
91 }
92 } 104 }
93 105
94 public string Name 106 public string Name
@@ -96,12 +108,11 @@ namespace OpenSim.Region.CoreModules
96 get { return "CloudModule"; } 108 get { return "CloudModule"; }
97 } 109 }
98 110
99 public bool IsSharedModule 111 public Type ReplaceableInterface
100 { 112 {
101 get { return false; } 113 get { return null; }
102 } 114 }
103 115
104
105 public float CloudCover(int x, int y, int z) 116 public float CloudCover(int x, int y, int z)
106 { 117 {
107 float cover = 0f; 118 float cover = 0f;
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index 9a954b8..bdbf273 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -267,26 +267,17 @@ namespace OpenSim.Region.CoreModules
267 return GetCurrentSunHour() + 6.0f; 267 return GetCurrentSunHour() + 6.0f;
268 } 268 }
269 269
270 #region IRegion Methods 270 #region INonSharedRegion Methods
271 271
272 // Called immediately after the module is loaded for a given region 272 // Called immediately after the module is loaded for a given region
273 // i.e. Immediately after instance creation. 273 // i.e. Immediately after instance creation.
274 public void Initialise(Scene scene, IConfigSource config) 274 public void Initialise(IConfigSource config)
275 { 275 {
276 m_scene = scene;
277 m_frame = 0; 276 m_frame = 0;
278 277
279 // This one puts an entry in the main help screen 278 // This one puts an entry in the main help screen
280// m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); 279// m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null);
281 280
282 // This one enables the ability to type just "sun" without any parameters
283// m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand);
284 foreach (KeyValuePair<string, string> kvp in GetParamList())
285 {
286 string sunCommand = string.Format("sun {0}", kvp.Key);
287 m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand);
288 }
289
290 TimeZone local = TimeZone.CurrentTimeZone; 281 TimeZone local = TimeZone.CurrentTimeZone;
291 TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; 282 TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
292 m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); 283 m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset);
@@ -358,15 +349,6 @@ namespace OpenSim.Region.CoreModules
358 HorizonShift = m_HorizonShift; // Z axis translation 349 HorizonShift = m_HorizonShift; // Z axis translation
359 // HoursToRadians = (SunCycle/24)*VWTimeRatio; 350 // HoursToRadians = (SunCycle/24)*VWTimeRatio;
360 351
361 // Insert our event handling hooks
362
363 scene.EventManager.OnFrame += SunUpdate;
364 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
365 scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate;
366 scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour;
367
368 ready = true;
369
370 m_log.Debug("[SUN]: Mode is " + m_RegionMode); 352 m_log.Debug("[SUN]: Mode is " + m_RegionMode);
371 m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); 353 m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days");
372 m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); 354 m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift);
@@ -376,14 +358,37 @@ namespace OpenSim.Region.CoreModules
376 break; 358 break;
377 } 359 }
378 360
379 scene.RegisterModuleInterface<ISunModule>(this);
380 } 361 }
381 362
382 public void PostInitialise() 363 public Type ReplaceableInterface
383 { 364 {
365 get { return null; }
384 } 366 }
385 367
386 public void Close() 368 public void AddRegion(Scene scene)
369 {
370 m_scene = scene;
371 // Insert our event handling hooks
372
373 scene.EventManager.OnFrame += SunUpdate;
374 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
375 scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate;
376 scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour;
377
378 scene.RegisterModuleInterface<ISunModule>(this);
379
380 // This one enables the ability to type just "sun" without any parameters
381 // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand);
382 foreach (KeyValuePair<string, string> kvp in GetParamList())
383 {
384 string sunCommand = string.Format("sun {0}", kvp.Key);
385 m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand);
386 }
387
388 ready = true;
389 }
390
391 public void RemoveRegion(Scene scene)
387 { 392 {
388 ready = false; 393 ready = false;
389 394
@@ -394,14 +399,17 @@ namespace OpenSim.Region.CoreModules
394 m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; 399 m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour;
395 } 400 }
396 401
397 public string Name 402 public void RegionLoaded(Scene scene)
398 { 403 {
399 get { return "SunModule"; }
400 } 404 }
401 405
402 public bool IsSharedModule 406 public void Close()
403 { 407 {
404 get { return false; } 408 }
409
410 public string Name
411 {
412 get { return "SunModule"; }
405 } 413 }
406 414
407 #endregion 415 #endregion
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
index f5f35bb..528da0e3 100644
--- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
+++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
@@ -36,7 +36,7 @@ using OpenSim.Region.Framework.Scenes;
36 36
37namespace OpenSim.Region.CoreModules.Avatar.Vegetation 37namespace OpenSim.Region.CoreModules.Avatar.Vegetation
38{ 38{
39 public class VegetationModule : IRegionModule, IVegetationModule 39 public class VegetationModule : INonSharedRegionModule, IVegetationModule
40 { 40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 42
@@ -45,16 +45,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Vegetation
45 protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.Grass, PCode.NewTree, PCode.Tree }; 45 protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.Grass, PCode.NewTree, PCode.Tree };
46 public PCode[] CreationCapabilities { get { return creationCapabilities; } } 46 public PCode[] CreationCapabilities { get { return creationCapabilities; } }
47 47
48 public void Initialise(Scene scene, IConfigSource source) 48 public void Initialise(IConfigSource source)
49 {
50 }
51
52 public void AddRegion(Scene scene)
49 { 53 {
50 m_scene = scene; 54 m_scene = scene;
51 m_scene.RegisterModuleInterface<IVegetationModule>(this); 55 m_scene.RegisterModuleInterface<IVegetationModule>(this);
52 } 56 }
53 57
54 public void PostInitialise() {} 58 public void RemoveRegion(Scene scene)
59 {
60 m_scene.UnregisterModuleInterface<IVegetationModule>(this);
61 }
62
55 public void Close() {} 63 public void Close() {}
56 public string Name { get { return "Vegetation Module"; } } 64 public string Name { get { return "Vegetation Module"; } }
57 public bool IsSharedModule { get { return false; } } 65
66 public Type ReplaceableInterface
67 {
68 get { return null; }
69 }
70
71 public void RegionLoaded(Scene scene)
72 {
73 }
58 74
59 public SceneObjectGroup AddTree( 75 public SceneObjectGroup AddTree(
60 UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree) 76 UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree)
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
index 7b6fbda..0186a41 100644
--- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
+++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
@@ -52,31 +52,31 @@ namespace OpenSim.Region.CoreModules
52 private bool m_ready = false; 52 private bool m_ready = false;
53 53
54 private bool m_enabled = false; 54 private bool m_enabled = false;
55 55 private IConfig m_windConfig;
56 private IWindModelPlugin m_activeWindPlugin = null; 56 private IWindModelPlugin m_activeWindPlugin = null;
57 private const string m_dWindPluginName = "SimpleRandomWind"; 57 private string m_dWindPluginName = "SimpleRandomWind";
58 private Dictionary<string, IWindModelPlugin> m_availableWindPlugins = new Dictionary<string, IWindModelPlugin>(); 58 private Dictionary<string, IWindModelPlugin> m_availableWindPlugins = new Dictionary<string, IWindModelPlugin>();
59 59
60 // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m 60 // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m
61 private Vector2[] windSpeeds = new Vector2[16 * 16]; 61 private Vector2[] windSpeeds = new Vector2[16 * 16];
62 62
63 #region IRegion Methods 63 #region INonSharedRegionModule Methods
64 64
65 public void Initialise(Scene scene, IConfigSource config) 65 public void Initialise(IConfigSource config)
66 { 66 {
67 IConfig windConfig = config.Configs["Wind"]; 67 m_windConfig = config.Configs["Wind"];
68 string desiredWindPlugin = m_dWindPluginName; 68 string desiredWindPlugin = m_dWindPluginName;
69 69
70 if (windConfig != null) 70 if (m_windConfig != null)
71 { 71 {
72 m_enabled = windConfig.GetBoolean("enabled", true); 72 m_enabled = m_windConfig.GetBoolean("enabled", true);
73 73
74 m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150); 74 m_frameUpdateRate = m_windConfig.GetInt("wind_update_rate", 150);
75 75
76 // Determine which wind model plugin is desired 76 // Determine which wind model plugin is desired
77 if (windConfig.Contains("wind_plugin")) 77 if (m_windConfig.Contains("wind_plugin"))
78 { 78 {
79 desiredWindPlugin = windConfig.GetString("wind_plugin"); 79 m_dWindPluginName = m_windConfig.GetString("wind_plugin", m_dWindPluginName);
80 } 80 }
81 } 81 }
82 82
@@ -84,104 +84,111 @@ namespace OpenSim.Region.CoreModules
84 { 84 {
85 m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate); 85 m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);
86 86
87 m_scene = scene; 87 }
88 m_frame = 0;
89
90 // Register all the Wind Model Plug-ins
91 foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
92 {
93 m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
94 m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
95 }
96 88
97 // Check for desired plugin 89 }
98 if (m_availableWindPlugins.ContainsKey(desiredWindPlugin))
99 {
100 m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin];
101 90
102 m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin); 91 public void AddRegion(Scene scene)
92 {
93 if (!m_enabled)
94 return;
103 95
104 if (windConfig != null) 96 m_scene = scene;
105 { 97 m_frame = 0;
106 m_activeWindPlugin.Initialise();
107 m_activeWindPlugin.WindConfig(m_scene, windConfig);
108 }
109 }
110 98
99 // Register all the Wind Model Plug-ins
100 foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
101 {
102 m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
103 m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
104 }
111 105
112 // if the plug-in wasn't found, default to no wind. 106 // Check for desired plugin
113 if (m_activeWindPlugin == null) 107 if (m_availableWindPlugins.ContainsKey(m_dWindPluginName))
114 { 108 {
115 m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin); 109 m_activeWindPlugin = m_availableWindPlugins[m_dWindPluginName];
116 m_log.ErrorFormat("[WIND] Defaulting to no wind.");
117 }
118 110
119 // This one puts an entry in the main help screen 111 m_log.InfoFormat("[WIND] {0} plugin found, initializing.", m_dWindPluginName);
120// m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null);
121
122 // This one enables the ability to type just the base command without any parameters
123// m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand);
124 112
125 // Get a list of the parameters for each plugin 113 if (m_windConfig != null)
126 foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
127 { 114 {
128// m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand); 115 m_activeWindPlugin.Initialise();
129 m_scene.AddCommand( 116 m_activeWindPlugin.WindConfig(m_scene, m_windConfig);
130 "Regions",
131 this,
132 "wind base wind_update_rate",
133 "wind base wind_update_rate [<value>]",
134 "Get or set the wind update rate.",
135 "",
136 HandleConsoleBaseCommand);
137
138 foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams())
139 {
140 string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key);
141 m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} [<value>]", windCommand), kvp.Value, "", HandleConsoleParamCommand);
142 }
143 } 117 }
118 }
144 119
145 // Register event handlers for when Avatars enter the region, and frame ticks
146 m_scene.EventManager.OnFrame += WindUpdate;
147 m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;
148 120
149 // Register the wind module 121 // if the plug-in wasn't found, default to no wind.
150 m_scene.RegisterModuleInterface<IWindModule>(this); 122 if (m_activeWindPlugin == null)
123 {
124 m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", m_dWindPluginName);
125 m_log.ErrorFormat("[WIND] Defaulting to no wind.");
126 }
151 127
152 // Generate initial wind values 128 // This one puts an entry in the main help screen
153 GenWindPos(); 129 // m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null);
154 130
155 // Mark Module Ready for duty 131 // This one enables the ability to type just the base command without any parameters
156 m_ready = true; 132 // m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand);
157 133
134 // Get a list of the parameters for each plugin
135 foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
136 {
137 // m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand);
138 m_scene.AddCommand(
139 "Regions",
140 this,
141 "wind base wind_update_rate",
142 "wind base wind_update_rate [<value>]",
143 "Get or set the wind update rate.",
144 "",
145 HandleConsoleBaseCommand);
146
147 foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams())
148 {
149 string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key);
150 m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} [<value>]", windCommand), kvp.Value, "", HandleConsoleParamCommand);
151 }
158 } 152 }
159 153
160 } 154 // Register event handlers for when Avatars enter the region, and frame ticks
155 m_scene.EventManager.OnFrame += WindUpdate;
156 m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;
161 157
162 public void PostInitialise() 158 // Register the wind module
163 { 159 m_scene.RegisterModuleInterface<IWindModule>(this);
160
161 // Generate initial wind values
162 GenWindPos();
163
164 // Mark Module Ready for duty
165 m_ready = true;
164 } 166 }
165 167
166 public void Close() 168 public void RemoveRegion(Scene scene)
167 { 169 {
168 if (m_enabled) 170 if (!m_enabled)
171 return;
172
173 m_ready = false;
174
175 // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ??
176 m_activeWindPlugin = null;
177 foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
169 { 178 {
170 m_ready = false; 179 windPlugin.Dispose();
180 }
171 181
172 // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ?? 182 m_availableWindPlugins.Clear();
173 m_activeWindPlugin = null;
174 foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
175 {
176 windPlugin.Dispose();
177 }
178 183
179 m_availableWindPlugins.Clear(); 184 // Remove our hooks
185 m_scene.EventManager.OnFrame -= WindUpdate;
186 m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
180 187
181 // Remove our hooks 188 }
182 m_scene.EventManager.OnFrame -= WindUpdate; 189
183 m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; 190 public void Close()
184 } 191 {
185 } 192 }
186 193
187 public string Name 194 public string Name
@@ -189,11 +196,14 @@ namespace OpenSim.Region.CoreModules
189 get { return "WindModule"; } 196 get { return "WindModule"; }
190 } 197 }
191 198
192 public bool IsSharedModule 199 public Type ReplaceableInterface
193 { 200 {
194 get { return false; } 201 get { return null; }
195 } 202 }
196 203
204 public void RegionLoaded(Scene scene)
205 {
206 }
197 207
198 #endregion 208 #endregion
199 209
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 2417b1a..dc0c110 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -24,6 +24,7 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27using System;
27using System.Collections.Generic; 28using System.Collections.Generic;
28using System.Reflection; 29using System.Reflection;
29using log4net; 30using log4net;
@@ -37,16 +38,21 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37 38
38namespace OpenSim.Region.CoreModules.World.WorldMap 39namespace OpenSim.Region.CoreModules.World.WorldMap
39{ 40{
40 public class MapSearchModule : IRegionModule 41 public class MapSearchModule : ISharedRegionModule
41 { 42 {
42 private static readonly ILog m_log = 43 private static readonly ILog m_log =
43 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 45
45 Scene m_scene = null; // only need one for communication with GridService 46 Scene m_scene = null; // only need one for communication with GridService
46 List<Scene> m_scenes = new List<Scene>(); 47 List<Scene> m_scenes = new List<Scene>();
48 List<UUID> m_Clients;
47 49
48 #region IRegionModule Members 50 #region ISharedRegionModule Members
49 public void Initialise(Scene scene, IConfigSource source) 51 public void Initialise(IConfigSource source)
52 {
53 }
54
55 public void AddRegion(Scene scene)
50 { 56 {
51 if (m_scene == null) 57 if (m_scene == null)
52 { 58 {
@@ -55,6 +61,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
55 61
56 m_scenes.Add(scene); 62 m_scenes.Add(scene);
57 scene.EventManager.OnNewClient += OnNewClient; 63 scene.EventManager.OnNewClient += OnNewClient;
64 m_Clients = new List<UUID>();
65 }
66
67 public void RemoveRegion(Scene scene)
68 {
69 m_scenes.Remove(scene);
70 if (m_scene == scene && m_scenes.Count > 0)
71 m_scene = m_scenes[0];
72
73 scene.EventManager.OnNewClient -= OnNewClient;
58 } 74 }
59 75
60 public void PostInitialise() 76 public void PostInitialise()
@@ -72,16 +88,44 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
72 get { return "MapSearchModule"; } 88 get { return "MapSearchModule"; }
73 } 89 }
74 90
75 public bool IsSharedModule 91 public Type ReplaceableInterface
76 { 92 {
77 get { return true; } 93 get { return null; }
78 } 94 }
79 95
96 public void RegionLoaded(Scene scene)
97 {
98 }
80 #endregion 99 #endregion
81 100
82 private void OnNewClient(IClientAPI client) 101 private void OnNewClient(IClientAPI client)
83 { 102 {
84 client.OnMapNameRequest += OnMapNameRequest; 103 client.OnMapNameRequest += OnMapNameRequestHandler;
104 }
105
106 private void OnMapNameRequestHandler(IClientAPI remoteClient, string mapName, uint flags)
107 {
108 lock (m_Clients)
109 {
110 if (m_Clients.Contains(remoteClient.AgentId))
111 return;
112
113 m_Clients.Add(remoteClient.AgentId);
114 }
115
116 Util.FireAndForget(delegate
117 {
118 try
119 {
120 OnMapNameRequest(remoteClient, mapName, flags);
121 }
122 finally
123 {
124 lock (m_Clients)
125 m_Clients.Remove(remoteClient.AgentId);
126 }
127 });
128
85 } 129 }
86 130
87 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) 131 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
@@ -175,6 +219,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
175 }); 219 });
176 } 220 }
177 221
222 private void AddFinalBlock(List<MapBlockData> blocks)
223 {
224 // final block, closing the search result
225 MapBlockData data = new MapBlockData();
226 data.Agents = 0;
227 data.Access = 255;
228 data.MapImageId = UUID.Zero;
229 data.Name = "";
230 data.RegionFlags = 0;
231 data.WaterHeight = 0; // not used
232 data.X = 0;
233 data.Y = 0;
234 blocks.Add(data);
235 }
178// private Scene GetClientScene(IClientAPI client) 236// private Scene GetClientScene(IClientAPI client)
179// { 237// {
180// foreach (Scene s in m_scenes) 238// foreach (Scene s in m_scenes)
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
index 5540656..9794549 100644
--- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
@@ -35,15 +35,20 @@ using System.Xml;
35using log4net; 35using log4net;
36using Nini.Config; 36using Nini.Config;
37using OpenMetaverse; 37using OpenMetaverse;
38using Mono.Addins;
38using OpenSim.Framework; 39using OpenSim.Framework;
39using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
40using OpenSim.Region.DataSnapshot.Interfaces; 41using OpenSim.Region.DataSnapshot.Interfaces;
41using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
43 44
45[assembly: Addin("DataSnapshot", "0.1")]
46[assembly: AddinDependency("OpenSim", "0.5")]
47
44namespace OpenSim.Region.DataSnapshot 48namespace OpenSim.Region.DataSnapshot
45{ 49{
46 public class DataSnapshotManager : IRegionModule, IDataSnapshot 50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
51 public class DataSnapshotManager : ISharedRegionModule, IDataSnapshot
47 { 52 {
48 #region Class members 53 #region Class members
49 //Information from config 54 //Information from config
@@ -95,7 +100,7 @@ namespace OpenSim.Region.DataSnapshot
95 100
96 #region IRegionModule 101 #region IRegionModule
97 102
98 public void Initialise(Scene scene, IConfigSource config) 103 public void Initialise(IConfigSource config)
99 { 104 {
100 if (!m_configLoaded) 105 if (!m_configLoaded)
101 { 106 {
@@ -133,82 +138,121 @@ namespace OpenSim.Region.DataSnapshot
133 m_enabled = false; 138 m_enabled = false;
134 return; 139 return;
135 } 140 }
136 }
137 141
138 if (m_enabled) 142 if (m_enabled)
139 { 143 m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname);
140 //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer 144 }
141 new DataRequestHandler(scene, this);
142 145
143 m_hostname = scene.RegionInfo.ExternalHostName; 146 }
144 m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname);
145 147
146 MakeEverythingStale(); 148 }
147 149
148 if (m_dataServices != "" && m_dataServices != "noservices") 150 public void AddRegion(Scene scene)
149 NotifyDataServices(m_dataServices, "online"); 151 {
150 } 152 if (!m_enabled)
151 } 153 return;
152 154
153 if (m_enabled) 155 m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName);
154 {
155 m_log.Info("[DATASNAPSHOT]: Scene added to module.");
156 156
157 m_snapStore.AddScene(scene); 157 m_snapStore.AddScene(scene);
158 m_scenes.Add(scene); 158 m_scenes.Add(scene);
159 159
160 Assembly currentasm = Assembly.GetExecutingAssembly(); 160 Assembly currentasm = Assembly.GetExecutingAssembly();
161 161
162 foreach (Type pluginType in currentasm.GetTypes()) 162 foreach (Type pluginType in currentasm.GetTypes())
163 {
164 if (pluginType.IsPublic)
163 { 165 {
164 if (pluginType.IsPublic) 166 if (!pluginType.IsAbstract)
165 { 167 {
166 if (!pluginType.IsAbstract) 168 if (pluginType.GetInterface("IDataSnapshotProvider") != null)
167 { 169 {
168 if (pluginType.GetInterface("IDataSnapshotProvider") != null) 170 IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType);
169 { 171 module.Initialize(scene, this);
170 IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); 172 module.OnStale += MarkDataStale;
171 module.Initialize(scene, this);
172 module.OnStale += MarkDataStale;
173 173
174 m_dataproviders.Add(module); 174 m_dataproviders.Add(module);
175 m_snapStore.AddProvider(module); 175 m_snapStore.AddProvider(module);
176 176
177 m_log.Info("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); 177 m_log.Debug("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name);
178 }
179 } 178 }
180 } 179 }
181 } 180 }
181 }
182 }
183
184 public void RemoveRegion(Scene scene)
185 {
186 if (!m_enabled)
187 return;
188
189 m_log.Info("[DATASNAPSHOT]: Region " + scene.RegionInfo.RegionName + " is being removed, removing from indexing");
190 Scene restartedScene = SceneForUUID(scene.RegionInfo.RegionID);
191
192 m_scenes.Remove(restartedScene);
193 m_snapStore.RemoveScene(restartedScene);
182 194
183 //scene.OnRestart += OnSimRestart; 195 //Getting around the fact that we can't remove objects from a collection we are enumerating over
184 scene.EventManager.OnShutdown += delegate() { OnSimRestart(scene.RegionInfo); }; 196 List<IDataSnapshotProvider> providersToRemove = new List<IDataSnapshotProvider>();
197
198 foreach (IDataSnapshotProvider provider in m_dataproviders)
199 {
200 if (provider.GetParentScene == restartedScene)
201 {
202 providersToRemove.Add(provider);
203 }
185 } 204 }
186 else 205
206 foreach (IDataSnapshotProvider provider in providersToRemove)
187 { 207 {
188 //m_log.Debug("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); 208 m_dataproviders.Remove(provider);
209 m_snapStore.RemoveProvider(provider);
189 } 210 }
211
212 m_snapStore.RemoveScene(restartedScene);
190 } 213 }
191 214
192 public void Close() 215 public void PostInitialise()
193 { 216 {
194 if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") 217 if (!m_enabled)
195 NotifyDataServices(m_dataServices, "offline"); 218 return;
219
220 //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer
221 new DataRequestHandler(m_scenes[0], this);
222
223 m_hostname = m_scenes[0].RegionInfo.ExternalHostName;
224
225 if (m_dataServices != "" && m_dataServices != "noservices")
226 NotifyDataServices(m_dataServices, "online");
196 } 227 }
197 228
229 public void RegionLoaded(Scene scene)
230 {
231 if (!m_enabled)
232 return;
233
234 m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName);
235 m_snapStore.ForceSceneStale(scene);
236 }
198 237
199 public bool IsSharedModule 238 public void Close()
200 { 239 {
201 get { return true; } 240 if (!m_enabled)
241 return;
242
243 if (m_enabled && m_dataServices != "" && m_dataServices != "noservices")
244 NotifyDataServices(m_dataServices, "offline");
202 } 245 }
203 246
247
204 public string Name 248 public string Name
205 { 249 {
206 get { return "External Data Generator"; } 250 get { return "External Data Generator"; }
207 } 251 }
208 252
209 public void PostInitialise() 253 public Type ReplaceableInterface
210 { 254 {
211 255 get { return null; }
212 } 256 }
213 257
214 #endregion 258 #endregion
@@ -399,35 +443,7 @@ namespace OpenSim.Region.DataSnapshot
399 m_snapStore.ForceSceneStale(scene); 443 m_snapStore.ForceSceneStale(scene);
400 } 444 }
401 } 445 }
402
403 #endregion 446 #endregion
404 447
405 public void OnSimRestart(RegionInfo thisRegion)
406 {
407 m_log.Info("[DATASNAPSHOT]: Region " + thisRegion.RegionName + " is restarting, removing from indexing");
408 Scene restartedScene = SceneForUUID(thisRegion.RegionID);
409
410 m_scenes.Remove(restartedScene);
411 m_snapStore.RemoveScene(restartedScene);
412
413 //Getting around the fact that we can't remove objects from a collection we are enumerating over
414 List<IDataSnapshotProvider> providersToRemove = new List<IDataSnapshotProvider>();
415
416 foreach (IDataSnapshotProvider provider in m_dataproviders)
417 {
418 if (provider.GetParentScene == restartedScene)
419 {
420 providersToRemove.Add(provider);
421 }
422 }
423
424 foreach (IDataSnapshotProvider provider in providersToRemove)
425 {
426 m_dataproviders.Remove(provider);
427 m_snapStore.RemoveProvider(provider);
428 }
429
430 m_snapStore.RemoveScene(restartedScene);
431 }
432 } 448 }
433} 449}
diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs
index 59cdab9..3b3db65 100644
--- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs
@@ -32,6 +32,5 @@ namespace OpenSim.Region.DataSnapshot.Interfaces
32 public interface IDataSnapshot 32 public interface IDataSnapshot
33 { 33 {
34 XmlDocument GetSnapshot(string regionName); 34 XmlDocument GetSnapshot(string regionName);
35 void MakeEverythingStale();
36 } 35 }
37} 36}
diff --git a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs
index 7296ac3..54172bd 100644
--- a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs
@@ -27,7 +27,7 @@
27 27
28namespace OpenSim.Region.Framework.Interfaces 28namespace OpenSim.Region.Framework.Interfaces
29{ 29{
30 public interface ICloudModule : IRegionModule 30 public interface ICloudModule
31 { 31 {
32 /// <summary> 32 /// <summary>
33 /// Retrieves the cloud density at the given region coordinates 33 /// Retrieves the cloud density at the given region coordinates
diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
index be9764a..4d35c1c 100644
--- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs
@@ -33,95 +33,140 @@ namespace OpenSim.Region.Framework.Interfaces
33 public interface IDialogModule 33 public interface IDialogModule
34 { 34 {
35 /// <summary> 35 /// <summary>
36 /// Send a non-modal alert message to a particular user. This can disappear from the user's view after a 36 /// Send a non-modal alert message to a particular user. This can
37 /// small interval. 37 /// disappear from the user's view after a small interval.
38 /// </summary> 38 /// </summary>
39 /// <param name="client"></param> 39 /// <param name="client">
40 /// <param name="message"></param> 40 /// IClientAPI object representing the user.
41 /// </param>
42 /// <param name="message">Message text to send to the user.</param>
41 void SendAlertToUser(IClientAPI client, string message); 43 void SendAlertToUser(IClientAPI client, string message);
42 44
43 /// <summary> 45 /// <summary>
44 /// Send an alert message to a particular user. 46 /// Send an alert message to a particular user.
45 /// </summary> 47 /// </summary>
46 /// <param name="client"></param> 48 /// <param name="client">
47 /// <param name="message"></param> 49 /// IClientAPI object representing the user.
48 /// <param name="modal"></param> 50 /// </param>
51 /// <param name="message">Message text to send to the user.</param>
52 /// <param name="modal">Flag to control modality.</param>
49 void SendAlertToUser(IClientAPI client, string message, bool modal); 53 void SendAlertToUser(IClientAPI client, string message, bool modal);
50 54
51 /// <summary> 55 /// <summary>
52 /// Send a non-modal alert message to a particular user. 56 /// Send a non-modal alert message to a particular user.
53 /// </summary> 57 /// </summary>
54 /// <param name="agentID"></param> 58 /// <param name="agentID">UUID of agent representing the user.</param>
55 /// <param name="message"></param> 59 /// <param name="message">Message text to send to the user.</param>
56 void SendAlertToUser(UUID agentID, string message); 60 void SendAlertToUser(UUID agentID, string message);
57 61
58 /// <summary> 62 /// <summary>
59 /// Send an alert message to a particular user. 63 /// Send an alert message to a particular user.
60 /// </summary> 64 /// </summary>
61 /// <param name="agentID"></param> 65 /// <param name="agentID">UUID of agent representing the user.</param>
62 /// <param name="message"></param> 66 /// <param name="message">Message text to send to the user.</param>
63 /// <param name="modal"></param> 67 /// <param name="modal">Flag to control modality.</param>
64 void SendAlertToUser(UUID agentID, string message, bool modal); 68 void SendAlertToUser(UUID agentID, string message, bool modal);
65 69
66 /// <summary> 70 /// <summary>
67 /// Send an alert message to a particular user. 71 /// Send an alert message to a particular user.
68 /// </summary> 72 /// </summary>
69 /// <param name="firstName"></param> 73 /// <param name="firstName">Account first name</param>
70 /// <param name="lastName"></param> 74 /// <param name="lastName">Account last name</param>
71 /// <param name="message"></param> 75 /// <param name="message">Message text to send to the user.</param>
72 /// <param name="modal"></param> 76 /// <param name="modal">Flag to control modality.</param>
73 void SendAlertToUser(string firstName, string lastName, string message, bool modal); 77 void SendAlertToUser(string firstName, string lastName,
74 78 string message, bool modal);
79
75 /// <summary> 80 /// <summary>
76 /// Send an alert message to all users in the scene. 81 /// Send an alert message to all users in the scene.
77 /// </summary> 82 /// </summary>
78 /// <param name="message"></param> 83 /// <param name="message">Message text to send to all users.</param>
79 void SendGeneralAlert(string message); 84 void SendGeneralAlert(string message);
80 85
81 /// <summary> 86 /// <summary>
82 /// Send a dialog box to a particular user. 87 /// Send a dialog box to a particular user.
83 /// </summary> 88 /// </summary>
84 /// <param name="avatarID"></param> 89 /// <param name="avatarID">
85 /// <param name="objectName"></param> 90 /// UUID of the avatar representing the user.
86 /// <param name="objectID"></param> 91 /// </param>
87 /// <param name="ownerID"></param> 92 /// <param name="objectName">
88 /// <param name="message"></param> 93 /// Name of the object sending the dialog.
89 /// <param name="textureID"></param> 94 /// </param>
90 /// <param name="ch"></param> 95 /// <param name="objectID">
91 /// <param name="buttonlabels"></param> 96 /// UUID of the object sending the dialog.
92 void SendDialogToUser( 97 /// </param>
93 UUID avatarID, string objectName, UUID objectID, UUID ownerID, 98 /// <param name="ownerID">
94 string message, UUID textureID, int ch, string[] buttonlabels); 99 /// UUID of the user that owns the object.
95 100 /// </param>
101 /// <param name="message">Message text to send to the user.</param>
102 /// <param name="textureID">
103 /// Texture UUID to pass along with the dialog.
104 /// </param>
105 /// <param name="ch">
106 /// Channel on which the selected button text should be broadcast.
107 /// </param>
108 /// <param name="buttonlabels">Dialog button text.</param>
109 void SendDialogToUser(UUID avatarID, string objectName, UUID objectID,
110 UUID ownerID, string message, UUID textureID, int ch,
111 string[] buttonlabels);
112
96 /// <summary> 113 /// <summary>
97 /// Send a url to a particular user. 114 /// Send a url to a particular user.
98 /// </summary> 115 /// </summary>
99 /// <param name="avatarID"></param> 116 /// <param name="avatarID">
100 /// <param name="objectName"></param> 117 /// UUID of the avatar representing the user.
101 /// <param name="objectID"></param> 118 /// </param>
102 /// <param name="ownerID"></param> 119 /// <param name="objectName">
103 /// <param name="groupOwned"></param> 120 /// Name of the object sending the dialog.
104 /// <param name="message"></param> 121 /// </param>
105 /// <param name="url"></param> 122 /// <param name="objectID">
106 void SendUrlToUser( 123 /// UUID of the object sending the dialog.
107 UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url); 124 /// </param>
108 125 /// <param name="ownerID">
126 /// UUID of the user that owns the object.
127 /// </param>
128 /// <param name="groupOwned">
129 /// Flag indicating whether or not the object is group-owned.
130 /// </param>
131 /// <param name="message">Message text to send to the user.</param>
132 /// <param name="url">Url to send to the user.</param>
133 void SendUrlToUser(UUID avatarID, string objectName, UUID objectID,
134 UUID ownerID, bool groupOwned, string message, string url);
135
109 /// <summary> 136 /// <summary>
110 /// Send a notification to all users in the scene. This notification should remain around until the 137 /// Send a notification to all users in the scene. This notification
111 /// user explicitly dismisses it. 138 /// should remain around until the user explicitly dismisses it.
112 /// </summary> 139 /// </summary>
113 /// 140 /// <remarks>
114 /// On the Linden Labs Second Client (as of 1.21), this is a big blue box message on the upper right of the 141 /// On the Linden Labs Second Client (as of 1.21), this is a big blue
115 /// screen. 142 /// box message on the upper right of the screen.
116 /// 143 /// </remarks>
117 /// <param name="fromAvatarID">The user sending the message</param> 144 /// <param name="fromAvatarID">The user sending the message</param>
118 /// <param name="fromAvatarName">The name of the user doing the sending</param> 145 /// <param name="fromAvatarName">
146 /// The name of the user doing the sending
147 /// </param>
119 /// <param name="message">The message being sent to the user</param> 148 /// <param name="message">The message being sent to the user</param>
120 void SendNotificationToUsersInRegion(UUID fromAvatarID, string fromAvatarName, string message); 149 void SendNotificationToUsersInRegion(UUID fromAvatarID,
121 150 string fromAvatarName, string message);
151
122 /// <summary> 152 /// <summary>
123 /// Send a textbox entry for the client to respond to 153 /// Send a textbox entry for the client to respond to
124 /// </summary> 154 /// </summary>
125 void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid); 155 /// <param name="avatarID">
156 /// UUID of the avatar representing the user.
157 /// </param>
158 /// <param name="message">Message text to send to the user.</param>
159 /// <param name="chatChannel">
160 /// Chat channel that the user's input should be broadcast on.
161 /// </param>
162 /// <param name="name">Name of the object sending the dialog.</param>
163 /// <param name="objectid">
164 /// UUID of the object sending the dialog.
165 /// </param>
166 /// <param name="ownerid">
167 /// UUID of the user that owns the object.
168 /// </param>
169 void SendTextBoxToUser(UUID avatarid, string message, int chatChannel,
170 string name, UUID objectid, UUID ownerid);
126 } 171 }
127} 172}
diff --git a/OpenSim/Region/Framework/Interfaces/ISunModule.cs b/OpenSim/Region/Framework/Interfaces/ISunModule.cs
index 819ae11..8231716 100644
--- a/OpenSim/Region/Framework/Interfaces/ISunModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISunModule.cs
@@ -29,7 +29,7 @@ using OpenMetaverse;
29 29
30namespace OpenSim.Region.Framework.Interfaces 30namespace OpenSim.Region.Framework.Interfaces
31{ 31{
32 public interface ISunModule : IRegionModule 32 public interface ISunModule : INonSharedRegionModule
33 { 33 {
34 double GetSunParameter(string param); 34 double GetSunParameter(string param);
35 35
diff --git a/OpenSim/Region/Framework/Interfaces/IWindModule.cs b/OpenSim/Region/Framework/Interfaces/IWindModule.cs
index 10ecc32..4a26a71 100644
--- a/OpenSim/Region/Framework/Interfaces/IWindModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWindModule.cs
@@ -29,7 +29,7 @@ using OpenMetaverse;
29 29
30namespace OpenSim.Region.Framework.Interfaces 30namespace OpenSim.Region.Framework.Interfaces
31{ 31{
32 public interface IWindModule : IRegionModule 32 public interface IWindModule : INonSharedRegionModule
33 { 33 {
34 34
35 /// <summary> 35 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 6208a57..c9d1205 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1954,8 +1954,19 @@ namespace OpenSim.Region.Framework.Scenes
1954 } 1954 }
1955 } 1955 }
1956 1956
1957 public virtual void DeRezObjects(IClientAPI remoteClient, List<uint> localIDs, 1957 /// <summary>
1958 UUID groupID, DeRezAction action, UUID destinationID) 1958 /// Derez one or more objects from the scene.
1959 /// </summary>
1960 /// <remarks>
1961 /// Won't actually remove the scene object in the case where the object is being copied to a user inventory.
1962 /// </remarks>
1963 /// <param name='remoteClient'>Client requesting derez</param>
1964 /// <param name='localIDs'>Local ids of root parts of objects to delete.</param>
1965 /// <param name='groupID'>Not currently used. Here because the client passes this to us.</param>
1966 /// <param name='action'>DeRezAction</param>
1967 /// <param name='destinationID'>User folder ID to place derezzed object</param>
1968 public virtual void DeRezObjects(
1969 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID)
1959 { 1970 {
1960 // First, see of we can perform the requested action and 1971 // First, see of we can perform the requested action and
1961 // build a list of eligible objects 1972 // build a list of eligible objects
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 3398a53..5b334c6 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using System.Threading; 31using System.Threading;
31using NUnit.Framework; 32using NUnit.Framework;
@@ -33,6 +34,7 @@ using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces;
36using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock; 39using OpenSim.Tests.Common.Mock;
38 40
@@ -42,7 +44,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
42 /// Basic scene object tests (create, read and delete but not update). 44 /// Basic scene object tests (create, read and delete but not update).
43 /// </summary> 45 /// </summary>
44 [TestFixture] 46 [TestFixture]
45 public class SceneObjectBasicTests 47 public class SceneObjectBasicTests : OpenSimTestCase
46 { 48 {
47// [TearDown] 49// [TearDown]
48// public void TearDown() 50// public void TearDown()
@@ -237,38 +239,60 @@ namespace OpenSim.Region.Framework.Scenes.Tests
237 /// <summary> 239 /// <summary>
238 /// Test deleting an object asynchronously to user inventory. 240 /// Test deleting an object asynchronously to user inventory.
239 /// </summary> 241 /// </summary>
240 //[Test] 242// [Test]
241 //public void TestDeleteSceneObjectAsyncToUserInventory() 243 public void TestDeleteSceneObjectAsyncToUserInventory()
242 //{ 244 {
243 // TestHelper.InMethod(); 245 TestHelpers.InMethod();
244 // //log4net.Config.XmlConfigurator.Configure(); 246 TestHelpers.EnableLogging();
245 247
246 // UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); 248 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
247 // string myObjectName = "Fred"; 249 string myObjectName = "Fred";
248 250
249 // TestScene scene = SceneSetupHelpers.SetupScene(); 251 TestScene scene = new SceneHelpers().SetupScene();
250 // SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene, myObjectName); 252
251 253 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
252 // Assert.That( 254 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
253 // scene.CommsManager.UserAdminService.AddUser( 255 sogd.Enabled = false;
254 // "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), 256
255 // Is.EqualTo(agentId)); 257 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId);
256 258
257 // IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); 259// Assert.That(
258 260// scene.CommsManager.UserAdminService.AddUser(
259 // CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId); 261// "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId),
260 // Assert.That(userInfo, Is.Not.Null); 262// Is.EqualTo(agentId));
261 // Assert.That(userInfo.RootFolder, Is.Not.Null); 263
262 264 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
263 // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); 265 InventoryFolderBase folder1
264 266 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1");
265 // // Check that we now have the taken part in our inventory 267
266 // Assert.That(myObjectName, Is.EqualTo(userInfo.RootFolder.FindItemByPath(myObjectName).Name)); 268 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
267 269 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);
268 // // Check that the taken part has actually disappeared 270
269 // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 271 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
270 // Assert.That(retrievedPart, Is.Null); 272
271 //} 273 Assert.That(retrievedPart, Is.Not.Null);
274 Assert.That(so.IsDeleted, Is.False);
275
276 sogd.InventoryDeQueueAndDelete();
277
278 Assert.That(so.IsDeleted, Is.True);
279
280 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
281 Assert.That(retrievedPart2, Is.Null);
282
283// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);
284
285 InventoryItemBase retrievedItem
286 = UserInventoryHelpers.GetInventoryItem(
287 scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName);
288
289 // Check that we now have the taken part in our inventory
290 Assert.That(retrievedItem, Is.Not.Null);
291
292 // Check that the taken part has actually disappeared
293// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
294// Assert.That(retrievedPart, Is.Null);
295 }
272 296
273 /// <summary> 297 /// <summary>
274 /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not 298 /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not
diff --git a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml b/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml
index 8691343..a372d37 100644
--- a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml
+++ b/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml
@@ -14,5 +14,6 @@
14 <RegionModule id="VivoxVoice" type="OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice.VivoxVoiceModule" /> 14 <RegionModule id="VivoxVoice" type="OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice.VivoxVoiceModule" />
15 <RegionModule id="WorldViewModule" type="OpenSim.Region.OptionalModules.World.WorldView.WorldViewModule" /> 15 <RegionModule id="WorldViewModule" type="OpenSim.Region.OptionalModules.World.WorldView.WorldViewModule" />
16 <RegionModule id="AutoBackupModule" type="OpenSim.Region.OptionalModules.World.AutoBackup.AutoBackupModule" /> 16 <RegionModule id="AutoBackupModule" type="OpenSim.Region.OptionalModules.World.AutoBackup.AutoBackupModule" />
17 <RegionModule id="TreePopulatorModule" type="OpenSim.Region.OptionalModules.World.TreePopulator.TreePopulatorModule" />
17 </Extension> 18 </Extension>
18</Addin> 19</Addin>
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index 51b0592..6ebdf4d 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
46 /// <summary> 46 /// <summary>
47 /// Version 2.02 - Still hacky 47 /// Version 2.02 - Still hacky
48 /// </summary> 48 /// </summary>
49 public class TreePopulatorModule : IRegionModule, ICommandableModule, IVegetationModule 49 public class TreePopulatorModule : INonSharedRegionModule, ICommandableModule, IVegetationModule
50 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private readonly Commander m_commander = new Commander("tree"); 52 private readonly Commander m_commander = new Commander("tree");
@@ -170,13 +170,9 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
170 170
171 #region IRegionModule Members 171 #region IRegionModule Members
172 172
173 public void Initialise(Scene scene, IConfigSource config) 173 public void Initialise(IConfigSource config)
174 { 174 {
175 175
176 m_scene = scene;
177 m_scene.RegisterModuleInterface<IRegionModule>(this);
178 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
179
180 // ini file settings 176 // ini file settings
181 try 177 try
182 { 178 {
@@ -201,7 +197,20 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
201 m_log.Debug("[TREES]: Initialised tree module"); 197 m_log.Debug("[TREES]: Initialised tree module");
202 } 198 }
203 199
204 public void PostInitialise() 200 public void AddRegion(Scene scene)
201 {
202 m_scene = scene;
203 //m_scene.RegisterModuleInterface<IRegionModule>(this);
204 m_scene.RegisterModuleCommander(m_commander);
205 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
206
207 }
208
209 public void RemoveRegion(Scene scene)
210 {
211 }
212
213 public void RegionLoaded(Scene scene)
205 { 214 {
206 ReloadCopse(); 215 ReloadCopse();
207 if (m_copse.Count > 0) 216 if (m_copse.Count > 0)
@@ -220,11 +229,12 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
220 get { return "TreePopulatorModule"; } 229 get { return "TreePopulatorModule"; }
221 } 230 }
222 231
223 public bool IsSharedModule 232 public Type ReplaceableInterface
224 { 233 {
225 get { return false; } 234 get { return null; }
226 } 235 }
227 236
237
228 #endregion 238 #endregion
229 239
230 //-------------------------------------------------------------- 240 //--------------------------------------------------------------
@@ -448,8 +458,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
448 m_commander.RegisterCommand("reload", treeReloadCommand); 458 m_commander.RegisterCommand("reload", treeReloadCommand);
449 m_commander.RegisterCommand("remove", treeRemoveCommand); 459 m_commander.RegisterCommand("remove", treeRemoveCommand);
450 m_commander.RegisterCommand("statistics", treeStatisticsCommand); 460 m_commander.RegisterCommand("statistics", treeStatisticsCommand);
451
452 m_scene.RegisterModuleCommander(m_commander);
453 } 461 }
454 462
455 /// <summary> 463 /// <summary>
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index fc49169..f9c1ac2 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -141,9 +141,9 @@ namespace OpenSim.Tests.Common
141 TestScene testScene = new TestScene( 141 TestScene testScene = new TestScene(
142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null); 142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null);
143 143
144 IRegionModule godsModule = new GodsModule(); 144 INonSharedRegionModule godsModule = new GodsModule();
145 godsModule.Initialise(testScene, new IniConfigSource()); 145 godsModule.Initialise(new IniConfigSource());
146 testScene.AddModule(godsModule.Name, godsModule); 146 godsModule.AddRegion(testScene);
147 147
148 // Add scene to services 148 // Add scene to services
149 m_assetService.AddRegion(testScene); 149 m_assetService.AddRegion(testScene);
@@ -385,18 +385,18 @@ namespace OpenSim.Tests.Common
385 385
386 foreach (IRegionModuleBase module in newModules) 386 foreach (IRegionModuleBase module in newModules)
387 { 387 {
388 if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise();
389 }
390
391 foreach (IRegionModuleBase module in newModules)
392 {
393 foreach (Scene scene in scenes) 388 foreach (Scene scene in scenes)
394 { 389 {
395 module.AddRegion(scene); 390 module.AddRegion(scene);
396 scene.AddRegionModule(module.Name, module); 391 scene.AddRegionModule(module.Name, module);
397 } 392 }
398 } 393 }
399 394
395 foreach (IRegionModuleBase module in newModules)
396 {
397 if (module is ISharedRegionModule) ((ISharedRegionModule)module).PostInitialise();
398 }
399
400 // RegionLoaded is fired after all modules have been appropriately added to all scenes 400 // RegionLoaded is fired after all modules have been appropriately added to all scenes
401 foreach (IRegionModuleBase module in newModules) 401 foreach (IRegionModuleBase module in newModules)
402 foreach (Scene scene in scenes) 402 foreach (Scene scene in scenes)
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini
index ae5e788..45682a0 100644
--- a/bin/OpenSimDefaults.ini
+++ b/bin/OpenSimDefaults.ini
@@ -57,9 +57,6 @@
57 ; ## CLIENTS 57 ; ## CLIENTS
58 ; ## 58 ; ##
59 59
60 ; Enables EventQueueGet Service.
61 EventQueue = true
62
63 ; Set this to the DLL containing the client stack to use. 60 ; Set this to the DLL containing the client stack to use.
64 clientstack_plugin="OpenSim.Region.ClientStack.LindenUDP.dll" 61 clientstack_plugin="OpenSim.Region.ClientStack.LindenUDP.dll"
65 62