From 57ba9ef5ad05d2479a5bfb188d8a2827e63f0f0f Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 13 Jan 2012 11:35:44 -0500 Subject: [PATCH 1/7] Update RegionReadyModule Fix triggering of alerts when rezzing first script to an empty region, add login disable when loading oars. --- .../World/Archiver/ArchiverModule.cs | 10 +++- .../Interfaces/IRegionReadyModule.cs | 38 +++++++++++++ .../RegionReadyModule/RegionReadyModule.cs | 57 +++++++++++++++++-- 3 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 0707cbe745..a945fc2b10 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -98,6 +98,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; }); + + // Send a message to the region ready module + IRegionReadyModule rready = m_scene.RequestModuleInterface(); + + if (rready != null) + { + rready.OarLoadingAlert("load"); + } List mainParams = options.Parse(cmdparams); @@ -125,7 +133,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver Dictionary options = new Dictionary(); OptionSet ops = new OptionSet(); - + // legacy argument [obsolete] ops.Add("p|profile=", delegate(string v) { Console.WriteLine("\n WARNING: -profile option is obsolete and it will not work. Use -home instead.\n"); }); // preferred diff --git a/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs new file mode 100644 index 0000000000..aa4a757420 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IRegionReadyModule.cs @@ -0,0 +1,38 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +using System; + +namespace OpenSim.Region.Framework.Interfaces +{ + public interface IRegionReadyModule + { + void OarLoadingAlert(string msg); + } +} + diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 4c4f5fb890..f5d4da850a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -44,12 +44,13 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { - public class RegionReadyModule : INonSharedRegionModule + public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IConfig m_config = null; + private bool m_ScriptRez; private bool m_firstEmptyCompileQueue; private bool m_oarFileLoading; private bool m_lastOarLoadedOk; @@ -93,14 +94,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady if (!m_enabled) return; + m_scene = scene; + + m_scene.RegisterModuleInterface(this); + + m_ScriptRez = false; m_firstEmptyCompileQueue = true; m_oarFileLoading = false; m_lastOarLoadedOk = true; - m_scene = scene; - - m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; + m_scene.EventManager.OnRezScript += OnRezScript; m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); @@ -118,6 +122,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } + void OnRezScript (uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) + { + if (!m_ScriptRez) + { + m_ScriptRez = true; + m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; + m_scene.EventManager.OnRezScript -= OnRezScript; + } + } + public void RemoveRegion(Scene scene) { if (!m_enabled) @@ -125,6 +139,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; + m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled; if(m_uri != string.Empty) { @@ -148,9 +163,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } #endregion - + + void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) { + m_log.InfoFormat("[RegionReady]: Script compile queue empty!"); + if (m_firstEmptyCompileQueue || m_oarFileLoading) { OSChatMessage c = new OSChatMessage(); @@ -197,6 +215,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } + // This will be triggerd by Scene if we have no scripts + // m_ScriptsRezzing will be false if there were none + // else it will be true and we should wait on the + // empty compile queue void OnLoginsEnabled(string regionName) { if (m_disable_logins == true) @@ -205,7 +227,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { m_scene.LoginsDisabled = false; m_scene.LoginLock = false; - m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName); + + m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; + + m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", + m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); + if ( m_uri != string.Empty ) { RRAlert("enabled"); @@ -214,6 +241,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } + public void OarLoadingAlert(string msg) + { + if (msg == "load") + { + m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; + m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; + m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; + m_scene.EventManager.OnRezScript += OnRezScript; + m_oarFileLoading = true; + m_firstEmptyCompileQueue = true; + // Will need some controls around this + m_scene.LoginsDisabled = true; + m_scene.LoginLock = true; + RRAlert("loading oar"); + RRAlert("disabled"); + } + } + public void RRAlert(string status) { string request_method = "POST"; From adea92f8b70ffc94d9dcfe775af08effaecc41ca Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 13 Jan 2012 11:37:17 -0800 Subject: [PATCH 2/7] Fix llRotLookAt and llLookAt for non-physical objects. Per conversation with Melanie and Nebadon, SL behavior seems to be that non physical objects snap to the request rotation. --- .../Shared/Api/Implementation/LSL_Api.cs | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d6de39f7d4..30145c76e3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2861,11 +2861,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // we need to convert from a vector describing // the angles of rotation in radians into rotation value - LSL_Types.Quaternion rot = llEuler2Rot(angle); - Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); - m_host.startLookAt(rotation, (float)damping, (float)strength); - // Orient the object to the angle calculated - //llSetRot(rot); + LSL_Rotation rot = llEuler2Rot(angle); + + // Per discussion with Melanie, for non-physical objects llLookAt appears to simply + // set the rotation of the object, copy that behavior + if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) + { + llSetRot(rot); + } + else + { + m_host.startLookAt(Rot2Quaternion(rot), (float)damping, (float)strength); + } } public void llStopLookAt() @@ -3241,8 +3248,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRotLookAt(LSL_Rotation target, double strength, double damping) { m_host.AddScriptLPS(1); - Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); - m_host.RotLookAt(rot, (float)strength, (float)damping); + + // Per discussion with Melanie, for non-physical objects llLookAt appears to simply + // set the rotation of the object, copy that behavior + if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) + { + llSetLocalRot(target); + } + else + { + m_host.RotLookAt(Rot2Quaternion(target), (float)damping, (float)strength); + } } public LSL_Integer llStringLength(string str) From 02d6b033d0858ed955e711f4a3958d41c464f977 Mon Sep 17 00:00:00 2001 From: Bo Iwu Date: Fri, 13 Jan 2012 22:41:38 +0100 Subject: [PATCH 3/7] Fix improper code formatting introduced in 6214e6a217cf Signed-off-by: BlueWall --- .../UserManagement/UserManagementModule.cs | 64 ++++++++++++------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index bbdf92a820..b4f6b5acc6 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -335,54 +335,70 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement { UserData oldUser; //lock the whole block - prevent concurrent update - lock (m_UserCache) { + lock (m_UserCache) + { m_UserCache.TryGetValue (id, out oldUser); - if (oldUser != null) { - if (creatorData == null || creatorData == String.Empty) { + if (oldUser != null) + { + if (creatorData == null || creatorData == String.Empty) + { //ignore updates without creator data return; } //try update unknown users //and creator's home URL's - if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) { + if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) + { m_UserCache.Remove (id); -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL); - } else { +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL); + } + else + { //we have already a valid user within the cache return; } } -// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); - - UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount (m_Scenes[0].RegionInfo.ScopeID, id); - - if (account != null) { +// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); + + UserAccount account = m_Scenes [0].UserAccountService.GetUserAccount (m_Scenes [0].RegionInfo.ScopeID, id); + + if (account != null) + { AddUser (id, account.FirstName, account.LastName); - } else { + } + else + { UserData user = new UserData (); user.Id = id; - - if (creatorData != null && creatorData != string.Empty) { + + if (creatorData != null && creatorData != string.Empty) + { //creatorData = ; - + string[] parts = creatorData.Split (';'); - if (parts.Length >= 1) { - user.HomeURL = parts[0]; - try { - Uri uri = new Uri (parts[0]); + if (parts.Length >= 1) + { + user.HomeURL = parts [0]; + try + { + Uri uri = new Uri (parts [0]); user.LastName = "@" + uri.Authority; - } catch (UriFormatException) { - m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts[0]); + } + catch (UriFormatException) + { + m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts [0]); user.LastName = "@unknown"; } } if (parts.Length >= 2) - user.FirstName = parts[1].Replace (' ', '.'); - } else { + user.FirstName = parts [1].Replace (' ', '.'); + } + else + { user.FirstName = "Unknown"; user.LastName = "User"; } - + AddUserInternal (user); } } From e1a2c44ebe8f10cf00a14578e44b000ff16b68df Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 13 Jan 2012 14:48:56 -0800 Subject: [PATCH 4/7] Cleaned up the LookAt code in SOP and SOG. Added support for incrementally rotating physical objects. This does not use physics. Currently the rate of change is determined as 1 / (PI * Strength). --- .../Framework/Scenes/SceneObjectGroup.cs | 6 -- .../Framework/Scenes/SceneObjectPart.cs | 69 ++++++++----------- .../Shared/Api/Implementation/LSL_Api.cs | 8 +-- 3 files changed, 34 insertions(+), 49 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 886076499b..cad09b8c5f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1613,12 +1613,6 @@ namespace OpenSim.Region.Framework.Scenes RootPart.PhysActor.PIDActive = false; } - public void stopLookAt() - { - if (RootPart.PhysActor != null) - RootPart.PhysActor.APIDActive = false; - } - /// /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e9c33eb276..ad3bcd5246 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -217,11 +217,10 @@ namespace OpenSim.Region.Framework.Scenes public Quaternion SpinOldOrientation = Quaternion.Identity; - public Quaternion m_APIDTarget = Quaternion.Identity; - - public float m_APIDDamp = 0; - - public float m_APIDStrength = 0; + protected int m_APIDIterations = 0; + protected Quaternion m_APIDTarget = Quaternion.Identity; + protected float m_APIDDamp = 0; + protected float m_APIDStrength = 0; /// /// This part's inventory @@ -563,22 +562,21 @@ namespace OpenSim.Region.Framework.Scenes } } - - public Quaternion APIDTarget + protected Quaternion APIDTarget { get { return m_APIDTarget; } set { m_APIDTarget = value; } } - public float APIDDamp + protected float APIDDamp { get { return m_APIDDamp; } set { m_APIDDamp = value; } } - public float APIDStrength + protected float APIDStrength { get { return m_APIDStrength; } set { m_APIDStrength = value; } @@ -2696,11 +2694,6 @@ namespace OpenSim.Region.Framework.Scenes } public void RotLookAt(Quaternion target, float strength, float damping) - { - rotLookAt(target, strength, damping); - } - - public void rotLookAt(Quaternion target, float strength, float damping) { if (ParentGroup.IsAttachment) { @@ -2716,17 +2709,26 @@ namespace OpenSim.Region.Framework.Scenes APIDDamp = damping; APIDStrength = strength; APIDTarget = target; + + if (APIDStrength <= 0) + { + m_log.WarnFormat("[SceneObjectPart] Invalid rotation strength {0}",APIDStrength); + return; + } + + m_APIDIterations = 1 + (int)(Math.PI * APIDStrength); } + + // Necessary to get the lookat deltas applied + ParentGroup.QueueForUpdateCheck(); } - public void startLookAt(Quaternion rot, float damp, float strength) + public void StartLookAt(Quaternion target, float strength, float damping) { - APIDDamp = damp; - APIDStrength = strength; - APIDTarget = rot; + RotLookAt(target,strength,damping); } - public void stopLookAt() + public void StopLookAt() { APIDTarget = Quaternion.Identity; } @@ -3417,13 +3419,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public void StopLookAt() - { - ParentGroup.stopLookAt(); - - ParentGroup.ScheduleGroupForTerseUpdate(); - } - /// /// Set the text displayed for this part. /// @@ -4731,24 +4726,20 @@ namespace OpenSim.Region.Framework.Scenes { if (APIDTarget != Quaternion.Identity) { - if (Single.IsNaN(APIDTarget.W) == true) + if (m_APIDIterations <= 1) { + UpdateRotation(APIDTarget); APIDTarget = Quaternion.Identity; return; } - Quaternion rot = RotationOffset; - Quaternion dir = (rot - APIDTarget); - float speed = ((APIDStrength / APIDDamp) * (float)(Math.PI / 180.0f)); - if (dir.Z > speed) - { - rot.Z -= speed; - } - if (dir.Z < -speed) - { - rot.Z += speed; - } - rot.Normalize(); + + Quaternion rot = Quaternion.Slerp(RotationOffset,APIDTarget,1.0f/(float)m_APIDIterations); UpdateRotation(rot); + + m_APIDIterations--; + + // This ensures that we'll check this object on the next iteration + ParentGroup.QueueForUpdateCheck(); } } catch (Exception ex) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 30145c76e3..ab175ba503 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2865,13 +2865,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Per discussion with Melanie, for non-physical objects llLookAt appears to simply // set the rotation of the object, copy that behavior - if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) + if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) { llSetRot(rot); } else { - m_host.startLookAt(Rot2Quaternion(rot), (float)damping, (float)strength); + m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping); } } @@ -3251,13 +3251,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Per discussion with Melanie, for non-physical objects llLookAt appears to simply // set the rotation of the object, copy that behavior - if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) + if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) { llSetLocalRot(target); } else { - m_host.RotLookAt(Rot2Quaternion(target), (float)damping, (float)strength); + m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); } } From b5bb559cc020df0b2e7d77a46f7d47a8fed1bc9f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 14 Jan 2012 00:23:11 +0000 Subject: [PATCH 5/7] Register the UrlModule for script engine events OnScriptRemoved and OnObjectRemoved just once in the UrlModule itself, rather than repeatedly for every script. Doing this in every script is unnecessary since the event trigger is parameterized by the item id. All that would happen is 2000 scripts would trigger 1999 unnecessary calls, and a large number of initialized scripts may eventually trigger a StackOverflowException. Registration moved to UrlModule so that the handler is registered for all script engine implementations. This required moving the OnScriptRemoved and OnObjectRemoved events (only used by UrlModule in core) from IScriptEngine to IScriptModule to avoid circular references. --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 9 ++++++++- .../Region/Framework/Interfaces/IScriptModule.cs | 13 +++++++++++++ .../Region/ScriptEngine/Interfaces/IScriptEngine.cs | 7 ------- .../Shared/Api/Implementation/LSL_Api.cs | 5 ----- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 67d99e027a..93e75b3622 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -131,6 +131,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void RegionLoaded(Scene scene) { + IScriptModule[] scriptModules = scene.RequestModuleInterfaces(); + foreach (IScriptModule scriptModule in scriptModules) + { + scriptModule.OnScriptRemoved += ScriptRemoved; + scriptModule.OnObjectRemoved += ObjectRemoved; + } } public void RemoveRegion(Scene scene) @@ -160,7 +166,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.url = url; urlData.urlcode = urlcode; urlData.requests = new Dictionary(); - m_UrlMap[url] = urlData; @@ -276,6 +281,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void ScriptRemoved(UUID itemID) { +// m_log.DebugFormat("[URL MODULE]: Removing script {0}", itemID); + lock (m_UrlMap) { List removeURLs = new List(); diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 950e4b0df2..18c45dde6e 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -31,8 +31,21 @@ using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { + public delegate void ScriptRemoved(UUID script); + public delegate void ObjectRemoved(UUID prim); + public interface IScriptModule: INonSharedRegionModule { + /// + /// Triggered when a script is removed from the script module. + /// + event ScriptRemoved OnScriptRemoved; + + /// + /// Triggered when an object is removed via the script module. + /// + event ObjectRemoved OnObjectRemoved; + string ScriptEngineName { get; } string GetXMLState(UUID itemID); diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index 581a9a9443..17c270810f 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs @@ -42,10 +42,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces /// An interface for a script API module to communicate with /// the engine it's running under /// - - public delegate void ScriptRemoved(UUID script); - public delegate void ObjectRemoved(UUID prim); - public interface IScriptEngine { /// @@ -57,9 +53,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces IScriptModule ScriptModule { get; } - event ScriptRemoved OnScriptRemoved; - event ObjectRemoved OnObjectRemoved; - /// /// Post an event to a single script /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ab175ba503..fb930e013f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -126,11 +126,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_TransferModule = m_ScriptEngine.World.RequestModuleInterface(); m_UrlModule = m_ScriptEngine.World.RequestModuleInterface(); - if (m_UrlModule != null) - { - m_ScriptEngine.OnScriptRemoved += m_UrlModule.ScriptRemoved; - m_ScriptEngine.OnObjectRemoved += m_UrlModule.ObjectRemoved; - } AsyncCommands = new AsyncCommandManager(ScriptEngine); } From 82f0e193494e939d34950dda3dd108c5cfc26124 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 14 Jan 2012 00:44:19 +0000 Subject: [PATCH 6/7] Extend scripts show command to accept a single item UUID parameter to display one script's status Usage is now scripts show [] --- .../Region/ScriptEngine/XEngine/XEngine.cs | 87 ++++++++++--------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 12e1a78871..c9bbf0e0c0 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -273,11 +273,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine } MainConsole.Instance.Commands.AddCommand( - "scripts", false, "scripts show", "scripts show", "Show script information", - "Show information on all scripts known to the script engine", HandleShowScripts); + "scripts", false, "scripts show", "scripts show []", "Show script information", + "Show information on all scripts known to the script engine." + + "If a is given then only information on that script will be shown.", + HandleShowScripts); MainConsole.Instance.Commands.AddCommand( - "scripts", false, "show scripts", "show scripts", "Show script information", + "scripts", false, "show scripts", "show scripts []", "Show script information", "Synonym for scripts show command", HandleShowScripts); MainConsole.Instance.Commands.AddCommand( @@ -308,43 +310,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); } - public void HandleShowScripts(string module, string[] cmdparams) - { - lock (m_Scripts) - { - MainConsole.Instance.OutputFormat( - "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); - - foreach (IScriptInstance instance in m_Scripts.Values) - { - SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); - string status; - - if (instance.ShuttingDown) - { - status = "shutting down"; - } - else if (instance.Suspended) - { - status = "suspended"; - } - else if (!instance.Running) - { - status = "stopped"; - } - else - { - status = "running"; - } - - MainConsole.Instance.OutputFormat( - "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, - sop.AbsolutePosition, status); - } - } - } - /// /// Parse the raw item id into a script instance from the command params if it's present. /// @@ -394,6 +359,48 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + public void HandleShowScripts(string module, string[] cmdparams) + { + if (cmdparams.Length == 2) + { + lock (m_Scripts) + { + MainConsole.Instance.OutputFormat( + "Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName); + } + } + + HandleScriptsAction(cmdparams, HandleShowScript); + } + + private void HandleShowScript(IScriptInstance instance) + { + SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); + string status; + + if (instance.ShuttingDown) + { + status = "shutting down"; + } + else if (instance.Suspended) + { + status = "suspended"; + } + else if (!instance.Running) + { + status = "stopped"; + } + else + { + status = "running"; + } + + MainConsole.Instance.OutputFormat( + "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", + instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, + sop.AbsolutePosition, status); + } + private void HandleSuspendScript(IScriptInstance instance) { if (!instance.Suspended) From ec299bfa878498713e4538f825fd3a2ca92cd125 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 14 Jan 2012 05:28:57 +0100 Subject: [PATCH 7/7] Allow SmtpClients and other SSL users to work with our cert handler installed --- .../HttpRequest/ScriptsHttpRequests.cs | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 8fb5d75aec..d328eb37dc 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Mail; using System.Net.Security; using System.Text; using System.Threading; @@ -111,21 +112,36 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest X509Chain chain, SslPolicyErrors sslPolicyErrors) { - HttpWebRequest Request = (HttpWebRequest)sender; - - if (Request.Headers.Get("NoVerifyCert") != null) + // If this is a web request we need to check the headers first + // We may want to ignore SSL + if (sender is HttpWebRequest) { + HttpWebRequest Request = (HttpWebRequest)sender; + ServicePoint sp = Request.ServicePoint; + + // We don't case about encryption, get out of here + if (Request.Headers.Get("NoVerifyCert") != null) + { + return true; + } + + // If there was an upstream cert verification error, bail + if ((((int)sslPolicyErrors) & ~4) != 0) + return false; + + // Check for policy and execute it if defined + if (ServicePointManager.CertificatePolicy != null) + { + return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0); + } + return true; } - + + // If it's not HTTP, trust .NET to check it if ((((int)sslPolicyErrors) & ~4) != 0) return false; - if (ServicePointManager.CertificatePolicy != null) - { - ServicePoint sp = Request.ServicePoint; - return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0); - } return true; } #region IHttpRequestModule Members