From 8741676bc3681e2045084e17f86196693d9156d3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 18:32:03 +0100 Subject: Revert "Revert "Trigger changed event with CHANGED_TELEPORT when teleporting to another region."" This reverts commit 6c01ebb87541ecf66d678606bb97d996bee51953. --- OpenSim/Region/Framework/Scenes/Scene.cs | 15 ++++++--------- .../Region/ScriptEngine/Interfaces/IScriptInstance.cs | 3 ++- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 17 ++++++++++------- 3 files changed, 18 insertions(+), 17 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d17814d..792115a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2391,16 +2391,14 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); return false; } - - newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 2); + + newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); newObject.ResumeScripts(); // Do this as late as possible so that listeners have full access to the incoming object EventManager.TriggerOnIncomingSceneObject(newObject); - TriggerChangedTeleport(newObject); - return true; } @@ -2527,7 +2525,7 @@ namespace OpenSim.Region.Framework.Scenes return true; } - private void TriggerChangedTeleport(SceneObjectGroup sog) + private int GetStateSource(SceneObjectGroup sog) { ScenePresence sp = GetScenePresence(sog.OwnerID); @@ -2538,13 +2536,12 @@ namespace OpenSim.Region.Framework.Scenes if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default)) { // This will get your attention - //m_log.Error("[XXX] Triggering "); + //m_log.Error("[XXX] Triggering CHANGED_TELEPORT"); - // Trigger CHANGED_TELEPORT - sp.Scene.EventManager.TriggerOnScriptChangedEvent(sog.LocalId, (uint)Changed.TELEPORT); + return 5; // StateSource.Teleporting } - } + return 2; // StateSource.PrimCrossing } #endregion diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 0c99d8c..8b7871b 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -42,7 +42,8 @@ namespace OpenSim.Region.ScriptEngine.Interfaces NewRez = 1, PrimCrossing = 2, ScriptedRez = 3, - AttachedRez = 4 + AttachedRez = 4, + Teleporting = 5 } public interface IScriptWorkItem diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 5288cd3..9548253 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -391,19 +391,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } else if (m_stateSource == StateSource.RegionStart) { -// m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); + //m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); PostEvent(new EventParams("changed", - new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, - new DetectParams[0])); + new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, new DetectParams[0])); } - else if (m_stateSource == StateSource.PrimCrossing) + else if (m_stateSource == StateSource.PrimCrossing || m_stateSource == StateSource.Teleporting) { // CHANGED_REGION PostEvent(new EventParams("changed", - new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, - new DetectParams[0])); + new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, new DetectParams[0])); + + // CHANGED_TELEPORT + if (m_stateSource == StateSource.Teleporting) + PostEvent(new EventParams("changed", + new Object[] { new LSL_Types.LSLInteger((int)Changed.TELEPORT) }, new DetectParams[0])); } - } + } else { Start(); -- cgit v1.1 From 4407c4700ff67a0c64918765b8f6cae155ec015c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 19:02:42 +0100 Subject: Fix status responses in remote admin --- OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index a75cc60..9659883 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -2636,8 +2636,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController string text; int health = scene.GetHealth(out flags, out text); responseData["health"] = health; - responseData["flags"] = health; - responseData["message"] = health; + responseData["flags"] = flags; + responseData["message"] = text; response.Value = responseData; } -- cgit v1.1 From 8e3bacc691926340c049e2082b46e4d22a72b6ff Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Dec 2010 23:06:44 +0100 Subject: When linking something, immediately persist the linked set. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b2d9358..ecc7f40 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1639,6 +1639,7 @@ namespace OpenSim.Region.Framework.Scenes { parentGroup.areUpdatesSuspended = false; parentGroup.HasGroupChanged = true; + parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); parentGroup.ScheduleGroupForFullUpdate(); Monitor.Exit(m_updateLock); } -- cgit v1.1 From df860516bf4fa4e4196be4d5fc26db71d98334f4 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 3 Dec 2010 16:17:50 -0800 Subject: Various bug fixes for appearance handling: more aggressive reset of textures and vparams when appearance is not cached and when wearables change. Send appearance to the viewer with initial data. Cleaned up (and added) debugging. --- OpenSim/Framework/AvatarAppearance.cs | 36 +++++--- OpenSim/Framework/Capabilities/Caps.cs | 4 + .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 99 ++++++++++++++-------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 46 ++++++---- 4 files changed, 123 insertions(+), 62 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 2906af8..18a5733 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -48,7 +48,7 @@ namespace OpenSim.Framework public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; protected UUID m_owner; - protected int m_serial = 1; + protected int m_serial = 0; protected byte[] m_visualparams; protected Primitive.TextureEntry m_texture; protected AvatarWearable[] m_wearables; @@ -103,7 +103,7 @@ namespace OpenSim.Framework { // m_log.WarnFormat("[AVATAR APPEARANCE]: create empty appearance for {0}",owner); - m_serial = 1; + m_serial = 0; m_owner = owner; SetDefaultWearables(); @@ -127,7 +127,7 @@ namespace OpenSim.Framework { // m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID); - m_serial = 1; + m_serial = 0; m_owner = avatarID; if (wearables != null) @@ -160,7 +160,7 @@ namespace OpenSim.Framework if (appearance == null) { - m_serial = 1; + m_serial = 0; m_owner = UUID.Zero; SetDefaultWearables(); @@ -229,6 +229,24 @@ namespace OpenSim.Framework m_wearables = AvatarWearable.DefaultWearables; } + /// + /// Invalidate all of the baked textures in the appearance, useful + /// if you know that none are valid + /// + public virtual void ResetAppearance() + { + m_serial = 0; + + SetDefaultParams(); + SetDefaultTexture(); + + //for (int i = 0; i < BAKE_INDICES.Length; i++) + // { + // int idx = BAKE_INDICES[i]; + // m_texture.FaceTextures[idx].TextureID = UUID.Zero; + // } + } + protected virtual void SetDefaultParams() { m_visualparams = new byte[] { 33,61,85,23,58,127,63,85,63,42,0,85,63,36,85,95,153,63,34,0,63,109,88,132,63,136,81,85,103,136,127,0,150,150,150,127,0,0,0,0,0,127,0,0,255,127,114,127,99,63,127,140,127,127,0,0,0,191,0,104,0,0,0,0,0,0,0,0,0,145,216,133,0,127,0,127,170,0,0,127,127,109,85,127,127,63,85,42,150,150,150,150,150,150,150,25,150,150,150,0,127,0,0,144,85,127,132,127,85,0,127,127,127,127,127,127,59,127,85,127,127,106,47,79,127,127,204,2,141,66,0,0,127,127,0,0,0,0,127,0,159,0,0,178,127,36,85,131,127,127,127,153,95,0,140,75,27,127,127,0,150,150,198,0,0,63,30,127,165,209,198,127,127,153,204,51,51,255,255,255,204,0,255,150,150,150,150,150,150,150,150,150,150,0,150,150,150,150,150,0,127,127,150,150,150,150,150,150,150,150,0,0,150,51,132,150,150,150 }; @@ -240,9 +258,10 @@ namespace OpenSim.Framework protected virtual void SetDefaultTexture() { - m_texture = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97")); - for (uint i = 0; i < TEXTURE_COUNT; i++) - m_texture.CreateFace(i).TextureID = new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE); + m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); + + // for (uint i = 0; i < TEXTURE_COUNT; i++) + // m_texture.CreateFace(i).TextureID = new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE); } /// @@ -274,9 +293,6 @@ namespace OpenSim.Framework } changed = true; - -// if (newface != null) -// m_log.WarnFormat("[AVATAR APPEARANCE]: index {0}, new texture id {1}",i,newface.TextureID); } m_texture = textureEntry; diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index e7f2e13..63e1e34 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs @@ -990,6 +990,7 @@ namespace OpenSim.Framework.Capabilities public void BakedTextureUploaded(UUID assetID, byte[] data) { // m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString()); + AssetBase asset; asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString()); asset.Data = data; @@ -1331,6 +1332,7 @@ namespace OpenSim.Framework.Capabilities newAssetID = UUID.Random(); uploaderPath = path; httpListener = httpServer; + m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID); } /// @@ -1358,6 +1360,8 @@ namespace OpenSim.Framework.Capabilities handlerUpLoad(newAssetID, data); } + m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID); + return res; } } diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index ab1c206..7d6d191 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -115,8 +115,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory #endregion + /// + /// Check for the existence of the baked texture assets. Request a rebake + /// unless checkonly is true. + /// + /// + /// public bool ValidateBakedTextureCache(IClientAPI client) { + return ValidateBakedTextureCache(client, true); + } + + private bool ValidateBakedTextureCache(IClientAPI client, bool checkonly) + { ScenePresence sp = m_scene.GetScenePresence(client.AgentId); if (sp == null) { @@ -131,15 +142,33 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory { int idx = AvatarAppearance.BAKE_INDICES[i]; Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; - if (face == null || face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) + + // if there is no texture entry, skip it + if (face == null) continue; + // if the texture is one of the "defaults" then skip it + // this should probably be more intelligent (skirt texture doesnt matter + // if the avatar isnt wearing a skirt) but if any of the main baked + // textures is default then the rest should be as well + if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) + continue; + defonly = false; // found a non-default texture reference if (! CheckBakedTextureAsset(client,face.TextureID,idx)) - return false; + { + // the asset didn't exist if we are only checking, then we found a bad + // one and we're done otherwise, ask for a rebake + if (checkonly) return false; + + m_log.InfoFormat("[AVFACTORY] missing baked texture {0}, request rebake",face.TextureID); + client.SendRebakeAvatarTextures(face.TextureID); + } } + m_log.InfoFormat("[AVFACTORY]: complete texture check for {0}",client.AgentId); + // If we only found default textures, then the appearance is not cached return (defonly ? false : true); } @@ -158,55 +187,43 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return; } - // m_log.WarnFormat("[AVFACTORY]: Start SetAppearance for {0}",client.AgentId); + m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}",client.AgentId); + // TODO: This is probably not necessary any longer, just assume the + // textureEntry set implies that the appearance transaction is complete bool changed = false; // Process the texture entry transactionally, this doesn't guarantee that Appearance is // going to be handled correctly but it does serialize the updates to the appearance lock (m_setAppearanceLock) { + // Process the visual params, this may change height as well + if (visualParams != null) + { + changed = sp.Appearance.SetVisualParams(visualParams); + if (sp.Appearance.AvatarHeight > 0) + sp.SetHeight(sp.Appearance.AvatarHeight); + } + + // Process the baked texture array if (textureEntry != null) { - changed = sp.Appearance.SetTextureEntries(textureEntry); + changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; - // m_log.WarnFormat("[AVFACTORY]: Prepare to check textures for {0}",client.AgentId); + m_log.InfoFormat("[AVFACTORY]: received texture update for {0}",client.AgentId); + Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client,false); }); - for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) - { - int idx = AvatarAppearance.BAKE_INDICES[i]; - Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; - if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) - Util.FireAndForget(delegate(object o) { - if (! CheckBakedTextureAsset(client,face.TextureID,idx)) - client.SendRebakeAvatarTextures(face.TextureID); - }); - } + // This appears to be set only in the final stage of the appearance + // update transaction. In theory, we should be able to do an immediate + // appearance send and save here. - m_log.WarnFormat("[AVFACTORY]: Complete texture check for {0}",client.AgentId); + QueueAppearanceSave(client.AgentId); + QueueAppearanceSend(client.AgentId); } - // Process the visual params, this may change height as well - if (visualParams != null) - { - if (sp.Appearance.SetVisualParams(visualParams)) - { - changed = true; - if (sp.Appearance.AvatarHeight > 0) - sp.SetHeight(sp.Appearance.AvatarHeight); - } - } } - - // If something changed in the appearance then queue an appearance save - if (changed) - QueueAppearanceSave(client.AgentId); - - // And always queue up an appearance update to send out - QueueAppearanceSend(client.AgentId); - - // m_log.WarnFormat("[AVFACTORY]: Complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); + // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); } /// @@ -229,6 +246,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory #region UpdateAppearanceTimer + /// + /// Queue up a request to send appearance, makes it possible to + /// accumulate changes without sending out each one separately. + /// public void QueueAppearanceSend(UUID agentid) { // m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); @@ -268,6 +289,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // Send the appearance to everyone in the scene sp.SendAppearanceToAllOtherAgents(); + + // Send animations back to the avatar as well + sp.Animator.SendAnimPack(); } private void HandleAppearanceSave(UUID agentid) @@ -353,9 +377,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId); + // we need to clean out the existing textures + sp.Appearance.ResetAppearance(); + // operate on a copy of the appearance so we don't have to lock anything AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false); - + foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) { if (wear.Type < AvatarWearable.MAX_WEARABLES) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 82214bf..a1c80e5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2418,30 +2418,44 @@ namespace OpenSim.Region.Framework.Scenes // the inventory arrives // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); - // This agent just became root. We are going to tell everyone about it. The process of - // getting other avatars information was initiated in the constructor... don't do it - // again here... - SendAvatarDataToAllAgents(); + bool cachedappearance = false; // We have an appearance but we may not have the baked textures. Check the asset cache // to see if all the baked textures are already here. if (m_scene.AvatarFactory != null) { - if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient)) - { -// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); - SendAppearanceToAgent(this); - - // If the avatars baked textures are all in the cache, then we have a - // complete appearance... send it out, if not, then we'll send it when - // the avatar finishes updating its appearance - SendAppearanceToAllOtherAgents(); - } + cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient); } else { m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name); } + + // If we aren't using a cached appearance, then clear out the baked textures + if (! cachedappearance) + { + m_appearance.ResetAppearance(); + if (m_scene.AvatarFactory != null) + m_scene.AvatarFactory.QueueAppearanceSave(UUID); + } + + // This agent just became root. We are going to tell everyone about it. The process of + // getting other avatars information was initiated in the constructor... don't do it + // again here... this comes after the cached appearance check because the avatars + // appearance goes into the avatar update packet + SendAvatarDataToAllAgents(); + SendAppearanceToAgent(this); + + // If we are using the the cached appearance then send it out to everyone + if (cachedappearance) + { + m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); + + // If the avatars baked textures are all in the cache, then we have a + // complete appearance... send it out, if not, then we'll send it when + // the avatar finishes updating its appearance + SendAppearanceToAllOtherAgents(); + } } /// @@ -2501,7 +2515,7 @@ namespace OpenSim.Region.Framework.Scenes /// Send avatar data to an agent. /// /// - private void SendAvatarDataToAgent(ScenePresence avatar) + public void SendAvatarDataToAgent(ScenePresence avatar) { // m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); @@ -2569,7 +2583,7 @@ namespace OpenSim.Region.Framework.Scenes /// Send appearance data to an agent. /// /// - private void SendAppearanceToAgent(ScenePresence avatar) + public void SendAppearanceToAgent(ScenePresence avatar) { // m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); -- cgit v1.1 From b69c5d663339c7509767b0852b9fc50822ba94cc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Dec 2010 23:50:09 +0000 Subject: minor: change OpenSimBase log messages associated with newer module loader to make the association clear --- OpenSim/Region/Application/OpenSimBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 74ad168..36d5e51 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -352,13 +352,13 @@ namespace OpenSim m_moduleLoader.InitialiseSharedModules(scene); // Use this in the future, the line above will be deprecated soon - m_log.Info("[MODULES]: Loading Region's modules (new style)"); + m_log.Info("[REGIONMODULE]: Loading Region's modules (new style)"); IRegionModulesController controller; if (ApplicationRegistry.TryGet(out controller)) { controller.AddRegionToModules(scene); } - else m_log.Error("[MODULES]: The new RegionModulesController is missing..."); + else m_log.Error("[REGIONMODULE]: The new RegionModulesController is missing..."); scene.SetModuleInterfaces(); -- cgit v1.1 From 2486d96d062067f77151d516abe99f87b378ddad Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Dec 2010 00:56:53 +0000 Subject: minor: correction to logging category --- OpenSim/Region/Application/OpenSimBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 36d5e51..eee2300 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -352,13 +352,13 @@ namespace OpenSim m_moduleLoader.InitialiseSharedModules(scene); // Use this in the future, the line above will be deprecated soon - m_log.Info("[REGIONMODULE]: Loading Region's modules (new style)"); + m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)"); IRegionModulesController controller; if (ApplicationRegistry.TryGet(out controller)) { controller.AddRegionToModules(scene); } - else m_log.Error("[REGIONMODULE]: The new RegionModulesController is missing..."); + else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing..."); scene.SetModuleInterfaces(); -- cgit v1.1 From 0ab774d484a58a73b2aa26b9f10d9df9aea1777a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Dec 2010 01:06:29 +0000 Subject: add warning decals and information to RegionModule.cs in probably non-functional OpenSim.Region.Examples.SimpleModule project --- OpenSim/Region/Examples/SimpleModule/RegionModule.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs index 6da41db..9bcda74 100644 --- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs +++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs @@ -34,6 +34,15 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.Examples.SimpleModule { + /// + /// Example region module. + /// + /// + /// This is an old and unmaintained region module which uses the old style module interface. It is not loaded into + /// OpenSim by default. If you want to try enabling it, look in the bin folder of this project. + /// Please see the README.txt in this project on the filesystem for some more information. + /// Nonetheless, it may contain some useful example code so has been left here for now. + /// public class RegionModule : IRegionModule { #region IRegionModule Members -- cgit v1.1 From a06032d96eec260f3cda48131e99c5dfb485aa28 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Dec 2010 01:36:35 +0000 Subject: Add the most bare bones non-shared region module example. Not active unless the correct line is uncommented. --- .../BareBonesNonShared/BareBonesNonSharedModule.cs | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs new file mode 100644 index 0000000..a2a6b50 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs @@ -0,0 +1,83 @@ +/* + * 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; +using System.Reflection; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared +{ + /// + /// Simplest possible example of a non-shared region module. + /// + /// + /// This module is the simplest possible example of a non-shared region module (a module where each scene/region + /// in the simulator has its own copy). If anybody wants to create a more complex example in the future then + /// please create a separate example. + /// + /// This module is not active by default. If you want to see it in action, + /// then just uncomment the line below starting with [Extension(Path... + /// + //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")] + public class BareBonesNonSharedModule : INonSharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public string Name { get { return "Bare Bones Non Shared Module"; } } + + public Type ReplaceableInterface { get { return null; } } + + public void Initialise(IConfigSource source) + { + m_log.DebugFormat("[BARE BONES]: INITIALIZED MODULE"); + } + + public void Close() + { + m_log.DebugFormat("[BARE BONES]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { + m_log.DebugFormat("[BARE BONES]: REGION {0} ADDED", scene.RegionInfo.RegionName); + } + + public void RemoveRegion(Scene scene) + { + m_log.DebugFormat("[BARE BONES]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { + m_log.DebugFormat("[BARE BONES]: REGION {0} LOADED", scene.RegionInfo.RegionName); + } + } +} \ No newline at end of file -- cgit v1.1 From c010491d340ed66fd5b6044f708669e3aac609b4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Dec 2010 01:38:32 +0000 Subject: correct the id of the example module --- .../Example/BareBonesNonShared/BareBonesNonSharedModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs index a2a6b50..5ece77d 100644 --- a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs +++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared /// This module is not active by default. If you want to see it in action, /// then just uncomment the line below starting with [Extension(Path... /// - //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")] + //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesNonSharedModule")] public class BareBonesNonSharedModule : INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 510b55c7f08e01b1d7ff14cbfdea367b9744dc23 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Dec 2010 02:38:26 +0000 Subject: refactor some common code in RegionModulesControllerPlugin also some minor doc changes in BareBonesNonSharedModule --- .../RegionModulesControllerPlugin.cs | 100 ++++++++++----------- .../BareBonesNonShared/BareBonesNonSharedModule.cs | 15 ++-- 2 files changed, 54 insertions(+), 61 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs index 9d79b3a..49bd911 100644 --- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs +++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs @@ -62,7 +62,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController new List(); #region IApplicationPlugin implementation - + public void Initialise (OpenSimBase openSim) { m_openSim = openSim; @@ -91,66 +91,24 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController { if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) { - // Get the config string - string moduleString = - modulesConfig.GetString("Setup_" + node.Id, String.Empty); - - // We have a selector - if (moduleString != String.Empty) + if (CheckModuleEnabled(node, modulesConfig)) { - // Allow disabling modules even if they don't have - // support for it - if (moduleString == "disabled") - continue; - - // Split off port, if present - string[] moduleParts = moduleString.Split(new char[] { '/' }, 2); - // Format is [port/][class] - string className = moduleParts[0]; - if (moduleParts.Length > 1) - className = moduleParts[1]; - - // Match the class name if given - if (className != String.Empty && - node.Type.ToString() != className) - continue; + m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); + m_sharedModules.Add(node); } - - m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type); - m_sharedModules.Add(node); } else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) { - // Get the config string - string moduleString = - modulesConfig.GetString("Setup_" + node.Id, String.Empty); - - // We have a selector - if (moduleString != String.Empty) + if (CheckModuleEnabled(node, modulesConfig)) { - // Allow disabling modules even if they don't have - // support for it - if (moduleString == "disabled") - continue; - - // Split off port, if present - string[] moduleParts = moduleString.Split(new char[] { '/' }, 2); - // Format is [port/][class] - string className = moduleParts[0]; - if (moduleParts.Length > 1) - className = moduleParts[1]; - - // Match the class name if given - if (className != String.Empty && - node.Type.ToString() != className) - continue; + m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); + m_nonSharedModules.Add(node); } - - m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type); - m_nonSharedModules.Add(node); } else + { m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); + } } // Load and init the module. We try a constructor with a port @@ -197,8 +155,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController m_sharedInstances.Add(module); module.Initialise(m_openSim.ConfigSource.Source); } - - } public void PostInitialise () @@ -210,7 +166,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController { module.PostInitialise(); } - } #endregion @@ -244,7 +199,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController #endregion - public string Version { get @@ -262,6 +216,42 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController } #region IRegionModulesController implementation + + /// + /// Check that the given module is no disabled in the [Modules] section of the config files. + /// + /// + /// The config section + /// true if the module is enabled, false if it is disabled + protected bool CheckModuleEnabled(TypeExtensionNode node, IConfig modulesConfig) + { + // Get the config string + string moduleString = + modulesConfig.GetString("Setup_" + node.Id, String.Empty); + + // We have a selector + if (moduleString != String.Empty) + { + // Allow disabling modules even if they don't have + // support for it + if (moduleString == "disabled") + return false; + + // Split off port, if present + string[] moduleParts = moduleString.Split(new char[] { '/' }, 2); + // Format is [port/][class] + string className = moduleParts[0]; + if (moduleParts.Length > 1) + className = moduleParts[1]; + + // Match the class name if given + if (className != String.Empty && + node.Type.ToString() != className) + return false; + } + + return true; + } // The root of all evil. // This is where we handle adding the modules to scenes when they diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs index 5ece77d..7d37135 100644 --- a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs +++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs @@ -41,10 +41,13 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared /// /// This module is the simplest possible example of a non-shared region module (a module where each scene/region /// in the simulator has its own copy). If anybody wants to create a more complex example in the future then - /// please create a separate example. + /// please create a separate class. /// /// This module is not active by default. If you want to see it in action, /// then just uncomment the line below starting with [Extension(Path... + /// + /// When the module is enabled it will print messages when it receives certain events to the screen and the log + /// file. /// //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesNonSharedModule")] public class BareBonesNonSharedModule : INonSharedRegionModule @@ -57,27 +60,27 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared public void Initialise(IConfigSource source) { - m_log.DebugFormat("[BARE BONES]: INITIALIZED MODULE"); + m_log.DebugFormat("[BARE BONES NON SHARED]: INITIALIZED MODULE"); } public void Close() { - m_log.DebugFormat("[BARE BONES]: CLOSED MODULE"); + m_log.DebugFormat("[BARE BONES NON SHARED]: CLOSED MODULE"); } public void AddRegion(Scene scene) { - m_log.DebugFormat("[BARE BONES]: REGION {0} ADDED", scene.RegionInfo.RegionName); + m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName); } public void RemoveRegion(Scene scene) { - m_log.DebugFormat("[BARE BONES]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName); } public void RegionLoaded(Scene scene) { - m_log.DebugFormat("[BARE BONES]: REGION {0} LOADED", scene.RegionInfo.RegionName); + m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName); } } } \ No newline at end of file -- cgit v1.1 From 57b5263ecf9b78534d71e147a7dc152d19cbc4a4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Dec 2010 02:46:59 +0000 Subject: add bare bones shared example module --- .../BareBonesShared/BareBonesSharedModule.cs | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs new file mode 100644 index 0000000..aa40c25 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs @@ -0,0 +1,91 @@ +/* + * 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; +using System.Reflection; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Example.BareBonesShared +{ + /// + /// Simplest possible example of a shared region module. + /// + /// + /// This module is the simplest possible example of a shared region module (a module which is shared by every + /// scene/region running on the simulator). If anybody wants to create a more complex example in the future then + /// please create a separate class. + /// + /// This module is not active by default. If you want to see it in action, + /// then just uncomment the line below starting with [Extension(Path... + /// + /// When the module is enabled it will print messages when it receives certain events to the screen and the log + /// file. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")] + public class BareBonesSharedModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public string Name { get { return "Bare Bones Shared Module"; } } + + public Type ReplaceableInterface { get { return null; } } + + public void Initialise(IConfigSource source) + { + m_log.DebugFormat("[BARE BONES SHARED]: INITIALIZED MODULE"); + } + + public void PostInitialise() + { + m_log.DebugFormat("[BARE BONES SHARED]: POST INITIALIZED MODULE"); + } + + public void Close() + { + m_log.DebugFormat("[BARE BONES SHARED]: CLOSED MODULE"); + } + + public void AddRegion(Scene scene) + { + m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName); + } + + public void RemoveRegion(Scene scene) + { + m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName); + } + + public void RegionLoaded(Scene scene) + { + m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName); + } + } +} \ No newline at end of file -- cgit v1.1 From f268cd7c53591a320c7b02d56af1566e7571c2aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Dec 2010 02:47:29 +0000 Subject: comment out the extension attribute --- .../OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs index aa40c25..781fe95 100644 --- a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs +++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesShared /// When the module is enabled it will print messages when it receives certain events to the screen and the log /// file. /// - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")] + //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")] public class BareBonesSharedModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 7b6b4501b7177d43e1ec11b29ba9ba6c55af9c64 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 4 Dec 2010 02:49:41 +0000 Subject: minor: add class doc line to older region module example code pointing towards newer --- OpenSim/Region/Examples/SimpleModule/RegionModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs index 9bcda74..088b818 100644 --- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs +++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs @@ -42,6 +42,8 @@ namespace OpenSim.Region.Examples.SimpleModule /// OpenSim by default. If you want to try enabling it, look in the bin folder of this project. /// Please see the README.txt in this project on the filesystem for some more information. /// Nonetheless, it may contain some useful example code so has been left here for now. + /// + /// You can see bare bones examples of the more modern region module system in OpenSim/Region/OptionalModules/Example /// public class RegionModule : IRegionModule { -- cgit v1.1 From da91a2ab7eaea0b66e0a019f4284d780612b24c6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 4 Dec 2010 04:33:14 +0100 Subject: Convert the agent asset transactions module to a new style module. Refactor to remove the property "MyScene" and the pointless circular refs to the managing classes. Converted the module to a non-shared module. Reformatted source for 80 columns. Removed the special role the module had in the old loader. --- .../LoadRegions/LoadRegionsPlugin.cs | 4 +- .../AssetTransaction/AgentAssetsTransactions.cs | 115 ++++++-------- .../AssetTransaction/AssetTransactionModule.cs | 166 +++++++++++---------- .../Agent/AssetTransaction/AssetXferUploader.cs | 43 +++--- 4 files changed, 158 insertions(+), 170 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index b16f46c..7ef0f5f 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -106,8 +106,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); - m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule..."); - m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); +// m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule..."); +// m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); m_log.Info("[LOADREGIONSPLUGIN]: Done."); if (!CheckRegionsForSanity(regionsToLoad)) diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 3d6e7f3..0af113a 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -41,19 +41,22 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// public class AgentAssetTransactions { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); // Fields private bool m_dumpAssetsToFile; - public AssetTransactionModule Manager; + private Scene m_Scene; public UUID UserID; - public Dictionary XferUploaders = new Dictionary(); + public Dictionary XferUploaders = + new Dictionary(); // Methods - public AgentAssetTransactions(UUID agentID, AssetTransactionModule manager, bool dumpAssetsToFile) + public AgentAssetTransactions(UUID agentID, Scene scene, + bool dumpAssetsToFile) { + m_Scene = scene; UserID = agentID; - Manager = manager; m_dumpAssetsToFile = dumpAssetsToFile; } @@ -61,7 +64,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (!XferUploaders.ContainsKey(transactionID)) { - AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); + AssetXferUploader uploader = new AssetXferUploader(m_Scene, + m_dumpAssetsToFile); lock (XferUploaders) { @@ -88,22 +92,25 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } } - public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, + UUID transactionID, UUID folderID, uint callbackID, + string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { if (XferUploaders.ContainsKey(transactionID)) { - XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, - callbackID, description, name, invType, type, - wearableType, nextOwnerMask); + XferUploaders[transactionID].RequestCreateInventoryItem( + remoteClient, transactionID, folderID, + callbackID, description, name, invType, type, + wearableType, nextOwnerMask); } } /// - /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. + /// Get an uploaded asset. If the data is successfully retrieved, + /// the transaction will be removed. /// /// /// The asset if the upload has completed, null if it has not. @@ -125,48 +132,21 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction return null; } - //private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) - //{ - // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); - // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( - // ourClient.AgentId); - - // if (userInfo != null) - // { - // InventoryItemBase item = new InventoryItemBase(); - // item.Owner = ourClient.AgentId; - // item.Creator = ourClient.AgentId; - // item.ID = UUID.Random(); - // item.AssetID = asset.FullID; - // item.Description = asset.Description; - // item.Name = asset.Name; - // item.AssetType = asset.Type; - // item.InvType = asset.Type; - // item.Folder = inventoryFolderID; - // item.BasePermissions = 0x7fffffff; - // item.CurrentPermissions = 0x7fffffff; - // item.EveryOnePermissions = 0; - // item.NextPermissions = nextPerms; - // item.Flags = wearableType; - // item.CreationDate = Util.UnixTimeSinceEpoch(); - - // userInfo.AddItem(item); - // ourClient.SendInventoryItemCreateUpdate(item); - // } - // else - // { - // m_log.ErrorFormat( - // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", - // ourClient.AgentId); - // } - //} - - public void RequestUpdateTaskInventoryItem( - IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) + public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, + SceneObjectPart part, UUID transactionID, + TaskInventoryItem item) { if (XferUploaders.ContainsKey(transactionID)) { - AssetBase asset = XferUploaders[transactionID].GetAssetData(); + AssetBase asset = GetTransactionAsset(transactionID); + + // Only legacy viewers use this, and they prefer CAPS, which + // we have, so this really never runs. + // Allow it, but only for "safe" types. + if ((InventoryType)item.InvType != InventoryType.Notecard && + (InventoryType)item.InvType != InventoryType.LSL) + return; + if (asset != null) { m_log.DebugFormat( @@ -178,32 +158,23 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction asset.Type = (sbyte)item.Type; item.AssetID = asset.FullID; - Manager.MyScene.AssetService.Store(asset); + m_Scene.AssetService.Store(asset); - if (part.Inventory.UpdateInventoryItem(item)) - { - if ((InventoryType)item.InvType == InventoryType.Notecard) - remoteClient.SendAgentAlertMessage("Notecard saved", false); - else if ((InventoryType)item.InvType == InventoryType.LSL) - remoteClient.SendAgentAlertMessage("Script saved", false); - else - remoteClient.SendAgentAlertMessage("Item saved", false); - - part.GetProperties(remoteClient); - } + part.Inventory.UpdateInventoryItem(item); } } } - - public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, - InventoryItemBase item) + public void RequestUpdateInventoryItem(IClientAPI remoteClient, + UUID transactionID, InventoryItemBase item) { - if (XferUploaders.ContainsKey(transactionID)) + if (XferUploaders.ContainsKey(transactionID)) { - UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); + UUID assetID = UUID.Combine(transactionID, + remoteClient.SecureSessionId); - AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); + AssetBase asset = m_Scene.AssetService.Get( + assetID.ToString()); if (asset == null) { @@ -219,10 +190,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction asset.Type = (sbyte)item.AssetType; item.AssetID = asset.FullID; - Manager.MyScene.AssetService.Store(asset); + m_Scene.AssetService.Store(asset); } - IInventoryService invService = Manager.MyScene.InventoryService; + IInventoryService invService = m_Scene.InventoryService; invService.UpdateItem(item); } } diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index ae31050..82558de 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs @@ -34,22 +34,19 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using Mono.Addins; namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { - public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetTransactionModule")] + public class AssetTransactionModule : INonSharedRegionModule, + IAgentAssetTransactions { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); - private readonly Dictionary RegisteredScenes = new Dictionary(); + protected Scene m_Scene; private bool m_dumpAssetsToFile = false; - private Scene m_scene = null; - - [Obsolete] - public Scene MyScene - { - get{ return m_scene;} - } /// /// Each agent has its own singleton collection of transactions @@ -57,33 +54,24 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private Dictionary AgentTransactions = new Dictionary(); + #region IRegionModule Members - public AssetTransactionModule() + public void Initialise(IConfigSource config) { - //m_log.Debug("creating AgentAssetTransactionModule"); } - #region IRegionModule Members - - public void Initialise(Scene scene, IConfigSource config) + public void AddRegion(Scene scene) { - if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) - { - // m_log.Debug("initialising AgentAssetTransactionModule"); - RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); - scene.RegisterModuleInterface(this); - - scene.EventManager.OnNewClient += NewClient; - } + m_Scene = scene; + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += NewClient; + } - // EVIL HACK! - // This needs killing! - // - if (m_scene == null) - m_scene = scene; + public void RegionLoaded(Scene scene) + { } - public void PostInitialise() + public void RemoveRegion(Scene scene) { } @@ -96,9 +84,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction get { return "AgentTransactionModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return typeof(IAgentAssetTransactions); } } #endregion @@ -111,8 +99,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction #region AgentAssetTransactions /// - /// Get the collection of asset transactions for the given user. If one does not already exist, it - /// is created. + /// Get the collection of asset transactions for the given user. + /// If one does not already exist, it is created. /// /// /// @@ -122,7 +110,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (!AgentTransactions.ContainsKey(userID)) { - AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); + AgentAssetTransactions transactions = + new AgentAssetTransactions(userID, m_Scene, + m_dumpAssetsToFile); + AgentTransactions.Add(userID, transactions); } @@ -131,8 +122,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } /// - /// Remove the given agent asset transactions. This should be called when a client is departing - /// from a scene (and hence won't be making any more transactions here). + /// Remove the given agent asset transactions. This should be called + /// when a client is departing from a scene (and hence won't be making + /// any more transactions here). /// /// public void RemoveAgentAssetTransactions(UUID userID) @@ -146,10 +138,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } /// - /// Create an inventory item from data that has been received through a transaction. - /// - /// This is called when new clothing or body parts are created. It may also be called in other - /// situations. + /// Create an inventory item from data that has been received through + /// a transaction. + /// This is called when new clothing or body parts are created. + /// It may also be called in other situations. /// /// /// @@ -161,61 +153,72 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// /// /// - public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) + public void HandleItemCreationFromTransaction(IClientAPI remoteClient, + UUID transactionID, UUID folderID, uint callbackID, + string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - // m_log.DebugFormat( - // "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); +// m_log.DebugFormat( +// "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); - transactions.RequestCreateInventoryItem( - remoteClient, transactionID, folderID, callbackID, description, - name, invType, type, wearableType, nextOwnerMask); + transactions.RequestCreateInventoryItem(remoteClient, transactionID, + folderID, callbackID, description, name, invType, type, + wearableType, nextOwnerMask); } /// - /// Update an inventory item with data that has been received through a transaction. + /// Update an inventory item with data that has been received through a + /// transaction. /// - /// This is called when clothing or body parts are updated (for instance, with new textures or - /// colours). It may also be called in other situations. + /// This is called when clothing or body parts are updated (for + /// instance, with new textures or colours). It may also be called in + /// other situations. /// /// /// /// - public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, - InventoryItemBase item) + public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, + UUID transactionID, InventoryItemBase item) { - // m_log.DebugFormat( - // "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", - // item.Name); +// m_log.DebugFormat( +// "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", +// item.Name); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); - transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); + transactions.RequestUpdateInventoryItem(remoteClient, + transactionID, item); } /// - /// Update a task inventory item with data that has been received through a transaction. + /// Update a task inventory item with data that has been received + /// through a transaction. /// - /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent - /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction + /// This is currently called when, for instance, a notecard in a prim + /// is saved. The data is sent up through a single AssetUploadRequest. + /// A subsequent UpdateTaskInventory then references the transaction /// and comes through this method. /// /// /// /// - public void HandleTaskItemUpdateFromTransaction( - IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) + public void HandleTaskItemUpdateFromTransaction(IClientAPI remoteClient, + SceneObjectPart part, UUID transactionID, + TaskInventoryItem item) { - // m_log.DebugFormat( - // "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", - // item.Name); +// m_log.DebugFormat( +// "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", +// item.Name); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); - transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item); + transactions.RequestUpdateTaskInventoryItem(remoteClient, part, + transactionID, item); } /// @@ -227,8 +230,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// /// /// - public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, - byte[] data, bool storeLocal, bool tempFile) + public void HandleUDPUploadRequest(IClientAPI remoteClient, + UUID assetID, UUID transaction, sbyte type, byte[] data, + bool storeLocal, bool tempFile) { // m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile); @@ -251,27 +255,33 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } } - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); + + AssetXferUploader uploader = + transactions.RequestXferUploader(transaction); - AssetXferUploader uploader = transactions.RequestXferUploader(transaction); if (uploader != null) { - uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); + uploader.Initialise(remoteClient, assetID, transaction, type, + data, storeLocal, tempFile); } } /// - /// Handle asset transfer data packets received in response to the asset upload request in - /// HandleUDPUploadRequest() + /// Handle asset transfer data packets received in response to the + /// asset upload request in HandleUDPUploadRequest() /// /// /// /// /// - public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) + public void HandleXfer(IClientAPI remoteClient, ulong xferID, + uint packetID, byte[] data) { //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); transactions.HandleXfer(xferID, packetID, data); } diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index 4609738..a7929ba 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -31,7 +31,7 @@ using System.Reflection; using log4net; using OpenMetaverse; using OpenSim.Framework; - +using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Agent.AssetTransaction @@ -50,17 +50,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private bool m_finished = false; private string m_name = String.Empty; private bool m_storeLocal; - private AgentAssetTransactions m_userTransactions; private uint nextPerm = 0; private IClientAPI ourClient; private UUID TransactionID = UUID.Zero; private sbyte type = 0; private byte wearableType = 0; public ulong XferID; + private Scene m_Scene; - public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) + public AssetXferUploader(Scene scene, bool dumpAssetToFile) { - m_userTransactions = transactions; + m_Scene = scene; m_dumpAssetToFile = dumpAssetToFile; } @@ -108,11 +108,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// /// /// True if the transfer is complete, false otherwise - public bool Initialise(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, - bool storeLocal, bool tempFile) + public bool Initialise(IClientAPI remoteClient, UUID assetID, + UUID transaction, sbyte type, byte[] data, bool storeLocal, + bool tempFile) { ourClient = remoteClient; - m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId.ToString()); + m_asset = new AssetBase(assetID, "blank", type, + remoteClient.AgentId.ToString()); m_asset.Data = data; m_asset.Description = "empty"; m_asset.Local = storeLocal; @@ -137,12 +139,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction protected void RequestStartXfer() { XferID = Util.GetNextXferID(); - ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID, 0, new byte[0]); + ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID, + 0, new byte[0]); } protected void SendCompleteMessage() { - ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); + ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, + m_asset.FullID); m_finished = true; if (m_createItem) @@ -151,18 +155,20 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } else if (m_storeLocal) { - m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); + m_Scene.AssetService.Store(m_asset); } m_log.DebugFormat( - "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.FullID, TransactionID); + "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", + m_asset.FullID, TransactionID); if (m_dumpAssetToFile) { DateTime now = DateTime.Now; string filename = - String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, - now.Hour, now.Minute, now.Second, m_asset.Name, m_asset.Type); + String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", + now.Year, now.Month, now.Day, now.Hour, now.Minute, + now.Second, m_asset.Name, m_asset.Type); SaveAssetToFile(filename, m_asset.Data); } } @@ -181,9 +187,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction fs.Close(); } - public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, + UUID transactionID, UUID folderID, uint callbackID, + string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { if (TransactionID == transactionID) { @@ -212,7 +219,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private void DoCreateItem(uint callbackID) { - m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); + m_Scene.AssetService.Store(m_asset); InventoryItemBase item = new InventoryItemBase(); item.Owner = ourClient.AgentId; @@ -232,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction item.Flags = (uint) wearableType; item.CreationDate = Util.UnixTimeSinceEpoch(); - if (m_userTransactions.Manager.MyScene.AddInventoryItem(item)) + if (m_Scene.AddInventoryItem(item)) ourClient.SendInventoryItemCreateUpdate(item, callbackID); else ourClient.SendAlertMessage("Unable to create inventory item"); -- cgit v1.1 From ea17b262a35df16ebdd79891520907b05d3b78a6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 4 Dec 2010 04:33:14 +0100 Subject: Convert the agent asset transactions module to a new style module. Refactor to remove the property "MyScene" and the pointless circular refs to the managing classes. Converted the module to a non-shared module. Reformatted source for 80 columns. Removed the special role the module had in the old loader. --- .../LoadRegions/LoadRegionsPlugin.cs | 4 +- .../AssetTransaction/AgentAssetsTransactions.cs | 115 ++++++-------- .../AssetTransaction/AssetTransactionModule.cs | 166 +++++++++++---------- .../Agent/AssetTransaction/AssetXferUploader.cs | 43 +++--- 4 files changed, 158 insertions(+), 170 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index b16f46c..7ef0f5f 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -106,8 +106,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); - m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule..."); - m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); +// m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule..."); +// m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); m_log.Info("[LOADREGIONSPLUGIN]: Done."); if (!CheckRegionsForSanity(regionsToLoad)) diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 3d6e7f3..0af113a 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -41,19 +41,22 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// public class AgentAssetTransactions { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); // Fields private bool m_dumpAssetsToFile; - public AssetTransactionModule Manager; + private Scene m_Scene; public UUID UserID; - public Dictionary XferUploaders = new Dictionary(); + public Dictionary XferUploaders = + new Dictionary(); // Methods - public AgentAssetTransactions(UUID agentID, AssetTransactionModule manager, bool dumpAssetsToFile) + public AgentAssetTransactions(UUID agentID, Scene scene, + bool dumpAssetsToFile) { + m_Scene = scene; UserID = agentID; - Manager = manager; m_dumpAssetsToFile = dumpAssetsToFile; } @@ -61,7 +64,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (!XferUploaders.ContainsKey(transactionID)) { - AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); + AssetXferUploader uploader = new AssetXferUploader(m_Scene, + m_dumpAssetsToFile); lock (XferUploaders) { @@ -88,22 +92,25 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } } - public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, + UUID transactionID, UUID folderID, uint callbackID, + string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { if (XferUploaders.ContainsKey(transactionID)) { - XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, - callbackID, description, name, invType, type, - wearableType, nextOwnerMask); + XferUploaders[transactionID].RequestCreateInventoryItem( + remoteClient, transactionID, folderID, + callbackID, description, name, invType, type, + wearableType, nextOwnerMask); } } /// - /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. + /// Get an uploaded asset. If the data is successfully retrieved, + /// the transaction will be removed. /// /// /// The asset if the upload has completed, null if it has not. @@ -125,48 +132,21 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction return null; } - //private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) - //{ - // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); - // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( - // ourClient.AgentId); - - // if (userInfo != null) - // { - // InventoryItemBase item = new InventoryItemBase(); - // item.Owner = ourClient.AgentId; - // item.Creator = ourClient.AgentId; - // item.ID = UUID.Random(); - // item.AssetID = asset.FullID; - // item.Description = asset.Description; - // item.Name = asset.Name; - // item.AssetType = asset.Type; - // item.InvType = asset.Type; - // item.Folder = inventoryFolderID; - // item.BasePermissions = 0x7fffffff; - // item.CurrentPermissions = 0x7fffffff; - // item.EveryOnePermissions = 0; - // item.NextPermissions = nextPerms; - // item.Flags = wearableType; - // item.CreationDate = Util.UnixTimeSinceEpoch(); - - // userInfo.AddItem(item); - // ourClient.SendInventoryItemCreateUpdate(item); - // } - // else - // { - // m_log.ErrorFormat( - // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", - // ourClient.AgentId); - // } - //} - - public void RequestUpdateTaskInventoryItem( - IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) + public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient, + SceneObjectPart part, UUID transactionID, + TaskInventoryItem item) { if (XferUploaders.ContainsKey(transactionID)) { - AssetBase asset = XferUploaders[transactionID].GetAssetData(); + AssetBase asset = GetTransactionAsset(transactionID); + + // Only legacy viewers use this, and they prefer CAPS, which + // we have, so this really never runs. + // Allow it, but only for "safe" types. + if ((InventoryType)item.InvType != InventoryType.Notecard && + (InventoryType)item.InvType != InventoryType.LSL) + return; + if (asset != null) { m_log.DebugFormat( @@ -178,32 +158,23 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction asset.Type = (sbyte)item.Type; item.AssetID = asset.FullID; - Manager.MyScene.AssetService.Store(asset); + m_Scene.AssetService.Store(asset); - if (part.Inventory.UpdateInventoryItem(item)) - { - if ((InventoryType)item.InvType == InventoryType.Notecard) - remoteClient.SendAgentAlertMessage("Notecard saved", false); - else if ((InventoryType)item.InvType == InventoryType.LSL) - remoteClient.SendAgentAlertMessage("Script saved", false); - else - remoteClient.SendAgentAlertMessage("Item saved", false); - - part.GetProperties(remoteClient); - } + part.Inventory.UpdateInventoryItem(item); } } } - - public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, - InventoryItemBase item) + public void RequestUpdateInventoryItem(IClientAPI remoteClient, + UUID transactionID, InventoryItemBase item) { - if (XferUploaders.ContainsKey(transactionID)) + if (XferUploaders.ContainsKey(transactionID)) { - UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); + UUID assetID = UUID.Combine(transactionID, + remoteClient.SecureSessionId); - AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); + AssetBase asset = m_Scene.AssetService.Get( + assetID.ToString()); if (asset == null) { @@ -219,10 +190,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction asset.Type = (sbyte)item.AssetType; item.AssetID = asset.FullID; - Manager.MyScene.AssetService.Store(asset); + m_Scene.AssetService.Store(asset); } - IInventoryService invService = Manager.MyScene.InventoryService; + IInventoryService invService = m_Scene.InventoryService; invService.UpdateItem(item); } } diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index ae31050..82558de 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs @@ -34,22 +34,19 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using Mono.Addins; namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { - public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetTransactionModule")] + public class AssetTransactionModule : INonSharedRegionModule, + IAgentAssetTransactions { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); - private readonly Dictionary RegisteredScenes = new Dictionary(); + protected Scene m_Scene; private bool m_dumpAssetsToFile = false; - private Scene m_scene = null; - - [Obsolete] - public Scene MyScene - { - get{ return m_scene;} - } /// /// Each agent has its own singleton collection of transactions @@ -57,33 +54,24 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private Dictionary AgentTransactions = new Dictionary(); + #region IRegionModule Members - public AssetTransactionModule() + public void Initialise(IConfigSource config) { - //m_log.Debug("creating AgentAssetTransactionModule"); } - #region IRegionModule Members - - public void Initialise(Scene scene, IConfigSource config) + public void AddRegion(Scene scene) { - if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) - { - // m_log.Debug("initialising AgentAssetTransactionModule"); - RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); - scene.RegisterModuleInterface(this); - - scene.EventManager.OnNewClient += NewClient; - } + m_Scene = scene; + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += NewClient; + } - // EVIL HACK! - // This needs killing! - // - if (m_scene == null) - m_scene = scene; + public void RegionLoaded(Scene scene) + { } - public void PostInitialise() + public void RemoveRegion(Scene scene) { } @@ -96,9 +84,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction get { return "AgentTransactionModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return typeof(IAgentAssetTransactions); } } #endregion @@ -111,8 +99,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction #region AgentAssetTransactions /// - /// Get the collection of asset transactions for the given user. If one does not already exist, it - /// is created. + /// Get the collection of asset transactions for the given user. + /// If one does not already exist, it is created. /// /// /// @@ -122,7 +110,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (!AgentTransactions.ContainsKey(userID)) { - AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); + AgentAssetTransactions transactions = + new AgentAssetTransactions(userID, m_Scene, + m_dumpAssetsToFile); + AgentTransactions.Add(userID, transactions); } @@ -131,8 +122,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } /// - /// Remove the given agent asset transactions. This should be called when a client is departing - /// from a scene (and hence won't be making any more transactions here). + /// Remove the given agent asset transactions. This should be called + /// when a client is departing from a scene (and hence won't be making + /// any more transactions here). /// /// public void RemoveAgentAssetTransactions(UUID userID) @@ -146,10 +138,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } /// - /// Create an inventory item from data that has been received through a transaction. - /// - /// This is called when new clothing or body parts are created. It may also be called in other - /// situations. + /// Create an inventory item from data that has been received through + /// a transaction. + /// This is called when new clothing or body parts are created. + /// It may also be called in other situations. /// /// /// @@ -161,61 +153,72 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// /// /// - public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) + public void HandleItemCreationFromTransaction(IClientAPI remoteClient, + UUID transactionID, UUID folderID, uint callbackID, + string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - // m_log.DebugFormat( - // "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); +// m_log.DebugFormat( +// "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); - transactions.RequestCreateInventoryItem( - remoteClient, transactionID, folderID, callbackID, description, - name, invType, type, wearableType, nextOwnerMask); + transactions.RequestCreateInventoryItem(remoteClient, transactionID, + folderID, callbackID, description, name, invType, type, + wearableType, nextOwnerMask); } /// - /// Update an inventory item with data that has been received through a transaction. + /// Update an inventory item with data that has been received through a + /// transaction. /// - /// This is called when clothing or body parts are updated (for instance, with new textures or - /// colours). It may also be called in other situations. + /// This is called when clothing or body parts are updated (for + /// instance, with new textures or colours). It may also be called in + /// other situations. /// /// /// /// - public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, - InventoryItemBase item) + public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, + UUID transactionID, InventoryItemBase item) { - // m_log.DebugFormat( - // "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", - // item.Name); +// m_log.DebugFormat( +// "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", +// item.Name); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); - transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); + transactions.RequestUpdateInventoryItem(remoteClient, + transactionID, item); } /// - /// Update a task inventory item with data that has been received through a transaction. + /// Update a task inventory item with data that has been received + /// through a transaction. /// - /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent - /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction + /// This is currently called when, for instance, a notecard in a prim + /// is saved. The data is sent up through a single AssetUploadRequest. + /// A subsequent UpdateTaskInventory then references the transaction /// and comes through this method. /// /// /// /// - public void HandleTaskItemUpdateFromTransaction( - IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) + public void HandleTaskItemUpdateFromTransaction(IClientAPI remoteClient, + SceneObjectPart part, UUID transactionID, + TaskInventoryItem item) { - // m_log.DebugFormat( - // "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", - // item.Name); +// m_log.DebugFormat( +// "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", +// item.Name); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); - transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item); + transactions.RequestUpdateTaskInventoryItem(remoteClient, part, + transactionID, item); } /// @@ -227,8 +230,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// /// /// - public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, - byte[] data, bool storeLocal, bool tempFile) + public void HandleUDPUploadRequest(IClientAPI remoteClient, + UUID assetID, UUID transaction, sbyte type, byte[] data, + bool storeLocal, bool tempFile) { // m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile); @@ -251,27 +255,33 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } } - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); + + AssetXferUploader uploader = + transactions.RequestXferUploader(transaction); - AssetXferUploader uploader = transactions.RequestXferUploader(transaction); if (uploader != null) { - uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); + uploader.Initialise(remoteClient, assetID, transaction, type, + data, storeLocal, tempFile); } } /// - /// Handle asset transfer data packets received in response to the asset upload request in - /// HandleUDPUploadRequest() + /// Handle asset transfer data packets received in response to the + /// asset upload request in HandleUDPUploadRequest() /// /// /// /// /// - public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) + public void HandleXfer(IClientAPI remoteClient, ulong xferID, + uint packetID, byte[] data) { //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); - AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); + AgentAssetTransactions transactions = + GetUserTransactions(remoteClient.AgentId); transactions.HandleXfer(xferID, packetID, data); } diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index 4609738..a7929ba 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -31,7 +31,7 @@ using System.Reflection; using log4net; using OpenMetaverse; using OpenSim.Framework; - +using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Agent.AssetTransaction @@ -50,17 +50,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private bool m_finished = false; private string m_name = String.Empty; private bool m_storeLocal; - private AgentAssetTransactions m_userTransactions; private uint nextPerm = 0; private IClientAPI ourClient; private UUID TransactionID = UUID.Zero; private sbyte type = 0; private byte wearableType = 0; public ulong XferID; + private Scene m_Scene; - public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) + public AssetXferUploader(Scene scene, bool dumpAssetToFile) { - m_userTransactions = transactions; + m_Scene = scene; m_dumpAssetToFile = dumpAssetToFile; } @@ -108,11 +108,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// /// /// True if the transfer is complete, false otherwise - public bool Initialise(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, - bool storeLocal, bool tempFile) + public bool Initialise(IClientAPI remoteClient, UUID assetID, + UUID transaction, sbyte type, byte[] data, bool storeLocal, + bool tempFile) { ourClient = remoteClient; - m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId.ToString()); + m_asset = new AssetBase(assetID, "blank", type, + remoteClient.AgentId.ToString()); m_asset.Data = data; m_asset.Description = "empty"; m_asset.Local = storeLocal; @@ -137,12 +139,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction protected void RequestStartXfer() { XferID = Util.GetNextXferID(); - ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID, 0, new byte[0]); + ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID, + 0, new byte[0]); } protected void SendCompleteMessage() { - ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); + ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, + m_asset.FullID); m_finished = true; if (m_createItem) @@ -151,18 +155,20 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } else if (m_storeLocal) { - m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); + m_Scene.AssetService.Store(m_asset); } m_log.DebugFormat( - "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.FullID, TransactionID); + "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", + m_asset.FullID, TransactionID); if (m_dumpAssetToFile) { DateTime now = DateTime.Now; string filename = - String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, - now.Hour, now.Minute, now.Second, m_asset.Name, m_asset.Type); + String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", + now.Year, now.Month, now.Day, now.Hour, now.Minute, + now.Second, m_asset.Name, m_asset.Type); SaveAssetToFile(filename, m_asset.Data); } } @@ -181,9 +187,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction fs.Close(); } - public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, - uint callbackID, string description, string name, sbyte invType, - sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, + UUID transactionID, UUID folderID, uint callbackID, + string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { if (TransactionID == transactionID) { @@ -212,7 +219,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private void DoCreateItem(uint callbackID) { - m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); + m_Scene.AssetService.Store(m_asset); InventoryItemBase item = new InventoryItemBase(); item.Owner = ourClient.AgentId; @@ -232,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction item.Flags = (uint) wearableType; item.CreationDate = Util.UnixTimeSinceEpoch(); - if (m_userTransactions.Manager.MyScene.AddInventoryItem(item)) + if (m_Scene.AddInventoryItem(item)) ourClient.SendInventoryItemCreateUpdate(item, callbackID); else ourClient.SendAlertMessage("Unable to create inventory item"); -- cgit v1.1 From f41dfbabc8e31ed9e38e50cdfa9963ac05b1648c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 4 Dec 2010 05:01:44 +0100 Subject: Simplify updating of agent inventory assets. Make newly created asset IDs random rather than using IDs known by the client ahead of time. --- .../AssetTransaction/AgentAssetsTransactions.cs | 25 ++++++---------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 0af113a..c66a4ea 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -149,10 +149,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction if (asset != null) { - m_log.DebugFormat( - "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}", - item.Name, part.Name, transactionID); - + asset.FullID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; asset.Type = (sbyte)item.Type; @@ -170,20 +167,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (XferUploaders.ContainsKey(transactionID)) { - UUID assetID = UUID.Combine(transactionID, - remoteClient.SecureSessionId); - - AssetBase asset = m_Scene.AssetService.Get( - assetID.ToString()); - - if (asset == null) - { - asset = GetTransactionAsset(transactionID); - } + AssetBase asset = GetTransactionAsset(transactionID); - if (asset != null && asset.FullID == assetID) + if (asset != null) { - // Assets never get updated, new ones get created asset.FullID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; @@ -191,10 +178,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction item.AssetID = asset.FullID; m_Scene.AssetService.Store(asset); - } - IInventoryService invService = m_Scene.InventoryService; - invService.UpdateItem(item); + IInventoryService invService = m_Scene.InventoryService; + invService.UpdateItem(item); + } } } } -- cgit v1.1 From 96446adfa4dd91194c6ce6383927cdece8bdda1f Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 4 Dec 2010 07:06:30 +0100 Subject: Monitor the UUIDs used to create and update wearable assets. Reject any changed texture that is not present in the user's inventory full perm. This will prevent "UUID snatching", a copybot-type of attack that can cause clothing makers to be forced to destroy and replace legit items in order to invalidate the copies. --- .../AssetTransaction/AgentAssetsTransactions.cs | 10 ++ .../Agent/AssetTransaction/AssetXferUploader.cs | 115 +++++++++++++++++++++ 2 files changed, 125 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index c66a4ea..85e1c99 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -167,6 +167,16 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (XferUploaders.ContainsKey(transactionID)) { + // Here we need to get the old asset to extract the + // texture UUIDs if it's a wearable. + if (item.AssetType == (int)AssetType.Bodypart || + item.AssetType == (int)AssetType.Clothing) + { + AssetBase oldAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); + if (oldAsset != null) + XferUploaders[transactionID].SetOldData(oldAsset.Data); + } + AssetBase asset = GetTransactionAsset(transactionID); if (asset != null) diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index a7929ba..b8c8c85 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -28,6 +28,7 @@ using System; using System.IO; using System.Reflection; +using System.Collections.Generic; using log4net; using OpenMetaverse; using OpenSim.Framework; @@ -38,6 +39,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { public class AssetXferUploader { + // Viewer's notion of the default texture + private UUID defaultID = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private AssetBase m_asset; @@ -55,6 +58,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private UUID TransactionID = UUID.Zero; private sbyte type = 0; private byte wearableType = 0; + private byte[] m_oldData = null; public ulong XferID; private Scene m_Scene; @@ -219,6 +223,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction private void DoCreateItem(uint callbackID) { + ValidateAssets(); m_Scene.AssetService.Store(m_asset); InventoryItemBase item = new InventoryItemBase(); @@ -245,6 +250,71 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction ourClient.SendAlertMessage("Unable to create inventory item"); } + private void ValidateAssets() + { + if (m_asset.Type == (sbyte)AssetType.Clothing || + m_asset.Type == (sbyte)AssetType.Bodypart) + { + string content = System.Text.Encoding.ASCII.GetString(m_asset.Data); + string[] lines = content.Split(new char[] {'\n'}); + + List validated = new List(); + + Dictionary allowed = ExtractTexturesFromOldData(); + + int textures = 0; + + foreach (string line in lines) + { + try + { + if (line.StartsWith("textures ")) + { + textures = Convert.ToInt32(line.Substring(9)); + validated.Add(line); + } + else if (textures > 0) + { + string[] parts = line.Split(new char[] {' '}); + + UUID tx = new UUID(parts[1]); + int id = Convert.ToInt32(parts[0]); + + if (tx == defaultID || tx == UUID.Zero || + (allowed.ContainsKey(id) && allowed[id] == tx)) + { + validated.Add(parts[0] + " " + tx.ToString()); + } + else + { + int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx); + int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy); + + if ((perms & full) != full) + { + m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId); + validated.Add(parts[0] + " " + defaultID.ToString()); + } + } + textures--; + } + else + { + validated.Add(line); + } + } + catch + { + // If it's malformed, skip it + } + } + + string final = String.Join("\n", validated.ToArray()); + + m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final); + } + } + /// /// Get the asset data uploaded in this transfer. /// @@ -253,10 +323,55 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction { if (m_finished) { + ValidateAssets(); return m_asset; } return null; } + + public void SetOldData(byte[] d) + { + m_oldData = d; + } + + private Dictionary ExtractTexturesFromOldData() + { + Dictionary result = new Dictionary(); + if (m_oldData == null) + return result; + + string content = System.Text.Encoding.ASCII.GetString(m_oldData); + string[] lines = content.Split(new char[] {'\n'}); + + int textures = 0; + + foreach (string line in lines) + { + try + { + if (line.StartsWith("textures ")) + { + textures = Convert.ToInt32(line.Substring(9)); + } + else if (textures > 0) + { + string[] parts = line.Split(new char[] {' '}); + + UUID tx = new UUID(parts[1]); + int id = Convert.ToInt32(parts[0]); + result[id] = tx; + textures--; + } + } + catch + { + // If it's malformed, skip it + } + } + + return result; + } } } + -- cgit v1.1 From 4b979362e9076344c9e96698f6cf8605945ffe61 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 4 Dec 2010 14:41:57 +0100 Subject: Add some safeguards: DOn't send someone else's HUDs, don't send deleted prims Removed some unneccessarily wordy core comments --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 9189260..478cfe6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3604,24 +3604,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_killRecord.Contains(part.ParentGroup.RootPart.LocalId)) continue; - // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client - // will never receive an update after a prim kill. Even then, keeping the kill record may be a good - // safety measure. - // - // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update - // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs - // updates and kills on different threads with different scheduling strategies, hence this protection. - // - // This doesn't appear to apply to child prims - a client will happily ignore these updates - // after the root prim has been deleted. if (m_killRecord.Contains(part.LocalId)) - { - // m_log.WarnFormat( - // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted", - // part.LocalId, Name); continue; - } + if (part.ParentGroup.IsDeleted) + continue; + + if (part.ParentGroup.IsAttachment) + { // Someone else's HUD, why are we getting these? + if (part.ParentGroup.OwnerID != AgentId && + part.ParentGroup.RootPart.Shape.State >= 30) + continue; + } + if (part.ParentGroup.IsAttachment && m_disableFacelights) { if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand && -- cgit v1.1