From 42f978a478093da579907e15dc29680a3711b27e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 30 Jan 2010 09:23:07 -0800 Subject: * HGScene is no more. * Moved a few key inventory access methods from Scene.Inventory to an IInventoryAccessModule module --- OpenSim/Region/Application/HGCommands.cs | 60 -- OpenSim/Region/Application/OpenSimBase.cs | 5 - OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | 1 - .../Region/ClientStack/LindenUDP/LLClientView.cs | 1 - .../Framework/InventoryAccess/HGAssetMapper.cs | 200 +++++++ .../InventoryAccess/HGInventoryAccessModule.cs | 204 +++++++ .../Framework/InventoryAccess/HGUuidGatherer.cs | 57 ++ .../InventoryAccess/InventoryAccessModule.cs | 654 +++++++++++++++++++++ .../Resources/CoreModulePlugin.addin.xml | 2 + .../Simulation/RemoteSimulationConnector.cs | 1 - .../CoreModules/World/WorldMap/MapSearchModule.cs | 1 - .../Scenes/AsyncSceneObjectGroupDeleter.cs | 5 +- .../Framework/Scenes/Hypergrid/HGAssetMapper.cs | 264 --------- .../Scenes/Hypergrid/HGScene.Inventory.cs | 175 ------ .../Framework/Scenes/Hypergrid/HGUuidGatherer.cs | 56 -- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 519 +--------------- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 40 +- .../Shared/Api/Implementation/OSSL_Api.cs | 1 - bin/config-include/StandaloneHypergrid.ini | 1 + 19 files changed, 1158 insertions(+), 1089 deletions(-) delete mode 100644 OpenSim/Region/Application/HGCommands.cs create mode 100644 OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs create mode 100644 OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs create mode 100644 OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs create mode 100644 OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs delete mode 100644 OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs delete mode 100644 OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs delete mode 100644 OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs deleted file mode 100644 index 5b99d7d..0000000 --- a/OpenSim/Region/Application/HGCommands.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.Collections.Generic; -using System.Reflection; -using System.Xml; -using log4net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Console; -using OpenSim.Region.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; - -namespace OpenSim -{ - public class HGCommands - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, - StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) - { - SceneCommunicationService sceneGridService = new SceneCommunicationService(); - - return - new HGScene( - regionInfo, circuitManager, sceneGridService, storageManager, - m_moduleLoader, false, m_configSettings.PhysicalPrim, - m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); - } - - } -} diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index f265769..06ffa91 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -574,11 +574,6 @@ namespace OpenSim protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) { - bool hgrid = ConfigSource.Source.Configs["Startup"].GetBoolean("hypergrid", false); - if (hgrid) - return HGCommands.CreateScene(regionInfo, circuitManager, - storageManager, m_moduleLoader, m_configSettings, m_config, m_version); - SceneCommunicationService sceneGridService = new SceneCommunicationService(); return new Scene( diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index b53a2fb..9869a99 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs @@ -31,7 +31,6 @@ using OpenMetaverse; using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using log4net; using System.Reflection; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 79bea26..b888017 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -44,7 +44,6 @@ using OpenSim.Framework.Client; using OpenSim.Framework.Statistics; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using Timer = System.Timers.Timer; using AssetLandmark = OpenSim.Framework.AssetLandmark; diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs new file mode 100644 index 0000000..e303a1f --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -0,0 +1,200 @@ +/* + * 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.Collections.Generic; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; + +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Services.Interfaces; + +//using HyperGrid.Framework; +//using OpenSim.Region.Communications.Hypergrid; + +namespace OpenSim.Region.CoreModules.Framework.InventoryAccess +{ + public class HGAssetMapper + { + #region Fields + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + // This maps between inventory server urls and inventory server clients +// private Dictionary m_inventoryServers = new Dictionary(); + + private Scene m_scene; + + #endregion + + #region Constructor + + public HGAssetMapper(Scene scene) + { + m_scene = scene; + } + + #endregion + + #region Internal functions + + public AssetBase FetchAsset(string url, UUID assetID) + { + AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString()); + + if (asset != null) + { + m_log.DebugFormat("[HG ASSET MAPPER]: Copied asset {0} from {1} to local asset server. ", asset.ID, url); + return asset; + } + return null; + } + + public bool PostAsset(string url, AssetBase asset) + { + if (asset != null) + { + // See long comment in AssetCache.AddAsset + if (!asset.Temporary || asset.Local) + { + // We need to copy the asset into a new asset, because + // we need to set its ID to be URL+UUID, so that the + // HGAssetService dispatches it to the remote grid. + // It's not pretty, but the best that can be done while + // not having a global naming infrastructure + AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); + Copy(asset, asset1); + try + { + asset1.ID = url + "/" + asset.ID; + } + catch + { + m_log.Warn("[HG ASSET MAPPER]: Oops."); + } + + m_scene.AssetService.Store(asset1); + m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); + } + return true; + } + else + m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache."); + + return false; + } + + private void Copy(AssetBase from, AssetBase to) + { + to.Data = from.Data; + to.Description = from.Description; + to.FullID = from.FullID; + to.ID = from.ID; + to.Local = from.Local; + to.Name = from.Name; + to.Temporary = from.Temporary; + to.Type = from.Type; + + } + + // TODO: unused + // private void Dump(Dictionary lst) + // { + // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); + // foreach (KeyValuePair kvp in lst) + // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); + // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); + // } + + #endregion + + + #region Public interface + + public void Get(UUID assetID, UUID ownerID, string userAssetURL) + { + // Get the item from the remote asset server onto the local AssetCache + // and place an entry in m_assetMap + + m_log.Debug("[HG ASSET MAPPER]: Fetching object " + assetID + " from asset server " + userAssetURL); + AssetBase asset = FetchAsset(userAssetURL, assetID); + + if (asset != null) + { + // OK, now fetch the inside. + Dictionary ids = new Dictionary(); + HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); + uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); + foreach (UUID uuid in ids.Keys) + FetchAsset(userAssetURL, uuid); + + m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL); + + } + else + m_log.Warn("[HG ASSET MAPPER]: Could not fetch asset from remote asset server " + userAssetURL); + } + + + public void Post(UUID assetID, UUID ownerID, string userAssetURL) + { + // Post the item from the local AssetCache onto the remote asset server + // and place an entry in m_assetMap + + m_log.Debug("[HG ASSET MAPPER]: Posting object " + assetID + " to asset server " + userAssetURL); + AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); + if (asset != null) + { + Dictionary ids = new Dictionary(); + HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); + uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); + foreach (UUID uuid in ids.Keys) + { + asset = m_scene.AssetService.Get(uuid.ToString()); + if (asset == null) + m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); + else + PostAsset(userAssetURL, asset); + } + + // maybe all pieces got there... + m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); + + } + else + m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); + + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs new file mode 100644 index 0000000..ecd7002 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -0,0 +1,204 @@ +/* + * 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.Collections.Generic; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Connectors.Hypergrid; +using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Framework.InventoryAccess +{ + public class HGInventoryAccessModule : InventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static HGAssetMapper m_assMapper; + public static HGAssetMapper AssetMapper + { + get { return m_assMapper; } + } + + private bool m_Initialized = false; + + #region INonSharedRegionModule + + public override string Name + { + get { return "HGInventoryAccessModule"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("InventoryAccessModule", ""); + if (name == Name) + { + m_Enabled = true; + m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); + } + } + } + + public override void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + base.AddRegion(scene); + m_assMapper = new HGAssetMapper(scene); + scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; + + } + + #endregion + + #region Event handlers + + public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) + { + string userAssetServer = string.Empty; + if (IsForeignUser(avatarID, out userAssetServer)) + { + m_assMapper.Post(assetID, avatarID, userAssetServer); + } + } + + #endregion + + #region Overrides of Basic Inventory Access methods + /// + /// CapsUpdateInventoryItemAsset + /// + public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) + { + UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); + + UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); + + return newAssetID; + } + + /// + /// DeleteToInventory + /// + public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) + { + UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient); + + if (!assetID.Equals(UUID.Zero)) + { + UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); + } + else + m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); + + return assetID; + } + + /// + /// RezObject + /// + public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, + UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, + bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) + { + m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); + + //if (fromTaskID.Equals(UUID.Zero)) + //{ + InventoryItemBase item = new InventoryItemBase(itemID); + item.Owner = remoteClient.AgentId; + item = m_Scene.InventoryService.GetItem(item); + //if (item == null) + //{ // Fetch the item + // item = new InventoryItemBase(); + // item.Owner = remoteClient.AgentId; + // item.ID = itemID; + // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); + //} + string userAssetServer = string.Empty; + if (item != null && IsForeignUser(remoteClient.AgentId, out userAssetServer)) + { + m_assMapper.Get(item.AssetID, remoteClient.AgentId, userAssetServer); + + } + //} + + // OK, we're done fetching. Pass it up to the default RezObject + return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, + RezSelected, RemoveItem, fromTaskID, attachment); + + } + + public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) + { + string userAssetServer = string.Empty; + if (IsForeignUser(sender, out userAssetServer)) + m_assMapper.Get(item.AssetID, sender, userAssetServer); + + if (IsForeignUser(receiver, out userAssetServer)) + m_assMapper.Post(item.AssetID, receiver, userAssetServer); + } + + #endregion + + public bool IsForeignUser(UUID userID, out string assetServerURL) + { + assetServerURL = string.Empty; + UserAccount account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); + if (account == null) // foreign + { + ScenePresence sp = null; + if (m_Scene.TryGetAvatar(userID, out sp)) + { + AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); + if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) + { + assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); + return true; + } + } + } + + return false; + } + } +} diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs new file mode 100644 index 0000000..fcb544f --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs @@ -0,0 +1,57 @@ +/* + * 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.Collections.Generic; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.Framework.InventoryAccess +{ + public class HGUuidGatherer : UuidGatherer + { + protected string m_assetServerURL; + protected HGAssetMapper m_assetMapper; + + public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache) + { + m_assetMapper = assMap; + m_assetServerURL = assetServerURL; + } + + protected override AssetBase GetAsset(UUID uuid) + { + if (string.Empty == m_assetServerURL) + return m_assetCache.Get(uuid.ToString()); + else + return m_assetMapper.FetchAsset(m_assetServerURL, uuid); + } + } +} diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs new file mode 100644 index 0000000..d242a34 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -0,0 +1,654 @@ +/* + * 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.Collections.Generic; +using System.Net; +using System.Reflection; +using System.Threading; + +using OpenSim.Framework; +using OpenSim.Framework.Capabilities; +using OpenSim.Framework.Client; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Services.Interfaces; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Framework.InventoryAccess +{ + public class InventoryAccessModule : INonSharedRegionModule, IInventoryAccessModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected bool m_Enabled = false; + protected Scene m_Scene; + + #region INonSharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public virtual string Name + { + get { return "BasicInventoryAcessModule"; } + } + + public virtual void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("InventoryAccessModule", ""); + if (name == Name) + { + m_Enabled = true; + m_log.InfoFormat("[INVENTORY ACCESS MODULE]: {0} enabled.", Name); + } + } + } + + public virtual void PostInitialise() + { + } + + public virtual void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + m_Scene = scene; + + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += OnNewClient; + } + + protected virtual void OnNewClient(IClientAPI client) + { + + } + + public virtual void Close() + { + if (!m_Enabled) + return; + } + + + public virtual void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + m_Scene = null; + } + + public virtual void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + #endregion + + #region Inventory Access + + /// + /// Capability originating call to update the asset of an item in an agent's inventory + /// + /// + /// + /// + /// + public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) + { + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = m_Scene.InventoryService.GetItem(item); + + if (item != null) + { + if ((InventoryType)item.InvType == InventoryType.Notecard) + { + if (!m_Scene.Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId)) + { + remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); + return UUID.Zero; + } + + remoteClient.SendAgentAlertMessage("Notecard saved", false); + } + else if ((InventoryType)item.InvType == InventoryType.LSL) + { + if (!m_Scene.Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) + { + remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); + return UUID.Zero; + } + + remoteClient.SendAgentAlertMessage("Script saved", false); + } + + AssetBase asset = + CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); + item.AssetID = asset.FullID; + m_Scene.AssetService.Store(asset); + + m_Scene.InventoryService.UpdateItem(item); + + // remoteClient.SendInventoryItemCreateUpdate(item); + return (asset.FullID); + } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Could not find item {0} for caps inventory update", + itemID); + } + + return UUID.Zero; + } + + /// + /// Delete a scene object from a scene and place in the given avatar's inventory. + /// Returns the UUID of the newly created asset. + /// + /// + /// + /// + /// + public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, + SceneObjectGroup objectGroup, IClientAPI remoteClient) + { + UUID assetID = UUID.Zero; + + Vector3 inventoryStoredPosition = new Vector3 + (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) + ? 250 + : objectGroup.AbsolutePosition.X) + , + (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) + ? 250 + : objectGroup.AbsolutePosition.X, + objectGroup.AbsolutePosition.Z); + + Vector3 originalPosition = objectGroup.AbsolutePosition; + + objectGroup.AbsolutePosition = inventoryStoredPosition; + + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); + + objectGroup.AbsolutePosition = originalPosition; + + // Get the user info of the item destination + // + UUID userID = UUID.Zero; + + if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || + action == DeRezAction.SaveToExistingUserInventoryItem) + { + // Take or take copy require a taker + // Saving changes requires a local user + // + if (remoteClient == null) + return UUID.Zero; + + userID = remoteClient.AgentId; + } + else + { + // All returns / deletes go to the object owner + // + + userID = objectGroup.RootPart.OwnerID; + } + + if (userID == UUID.Zero) // Can't proceed + { + return UUID.Zero; + } + + // If we're returning someone's item, it goes back to the + // owner's Lost And Found folder. + // Delete is treated like return in this case + // Deleting your own items makes them go to trash + // + + InventoryFolderBase folder = null; + InventoryItemBase item = null; + + if (DeRezAction.SaveToExistingUserInventoryItem == action) + { + item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); + item = m_Scene.InventoryService.GetItem(item); + + //item = userInfo.RootFolder.FindItem( + // objectGroup.RootPart.FromUserInventoryItemID); + + if (null == item) + { + m_log.DebugFormat( + "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", + objectGroup.Name, objectGroup.UUID); + return UUID.Zero; + } + } + else + { + // Folder magic + // + if (action == DeRezAction.Delete) + { + // Deleting someone else's item + // + + + if (remoteClient == null || + objectGroup.OwnerID != remoteClient.AgentId) + { + // Folder skeleton may not be loaded and we + // have to wait for the inventory to find + // the destination folder + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + } + else + { + // Assume inventory skeleton was loaded during login + // and all folders can be found + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); + } + } + else if (action == DeRezAction.Return) + { + + // Dump to lost + found unconditionally + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + } + + if (folderID == UUID.Zero && folder == null) + { + if (action == DeRezAction.Delete) + { + // Deletes go to trash by default + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); + } + else + { + // Catch all. Use lost & found + // + + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + } + } + + if (folder == null) // None of the above + { + //folder = userInfo.RootFolder.FindFolder(folderID); + folder = new InventoryFolderBase(folderID); + + if (folder == null) // Nowhere to put it + { + return UUID.Zero; + } + } + + item = new InventoryItemBase(); + item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); + item.ID = UUID.Random(); + item.InvType = (int)InventoryType.Object; + item.Folder = folder.ID; + item.Owner = userID; + } + + AssetBase asset = CreateAsset( + objectGroup.GetPartName(objectGroup.RootPart.LocalId), + objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), + (sbyte)AssetType.Object, + Utils.StringToBytes(sceneObjectXml)); + m_Scene.AssetService.Store(asset); + assetID = asset.FullID; + + if (DeRezAction.SaveToExistingUserInventoryItem == action) + { + item.AssetID = asset.FullID; + m_Scene.InventoryService.UpdateItem(item); + } + else + { + item.AssetID = asset.FullID; + + if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) + { + uint perms = objectGroup.GetEffectivePermissions(); + uint nextPerms = (perms & 7) << 13; + if ((nextPerms & (uint)PermissionMask.Copy) == 0) + perms &= ~(uint)PermissionMask.Copy; + if ((nextPerms & (uint)PermissionMask.Transfer) == 0) + perms &= ~(uint)PermissionMask.Transfer; + if ((nextPerms & (uint)PermissionMask.Modify) == 0) + perms &= ~(uint)PermissionMask.Modify; + + item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; + item.CurrentPermissions = item.BasePermissions; + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; + item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; + item.CurrentPermissions |= 8; // Slam! + } + else + { + item.BasePermissions = objectGroup.GetEffectivePermissions(); + item.CurrentPermissions = objectGroup.GetEffectivePermissions(); + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; + item.GroupPermissions = objectGroup.RootPart.GroupMask; + + item.CurrentPermissions |= 8; // Slam! + } + + // TODO: add the new fields (Flags, Sale info, etc) + item.CreationDate = Util.UnixTimeSinceEpoch(); + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + + m_Scene.InventoryService.AddItem(item); + + if (remoteClient != null && item.Owner == remoteClient.AgentId) + { + remoteClient.SendInventoryItemCreateUpdate(item, 0); + } + else + { + ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); + if (notifyUser != null) + { + notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); + } + } + } + + return assetID; + } + + + /// + /// Rez an object into the scene from the user's inventory + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The SceneObjectGroup rezzed or null if rez was unsuccessful. + public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, + UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, + bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) + { + // Work out position details + byte bRayEndIsIntersection = (byte)0; + + if (RayEndIsIntersection) + { + bRayEndIsIntersection = (byte)1; + } + else + { + bRayEndIsIntersection = (byte)0; + } + + Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); + + + Vector3 pos = m_Scene.GetNewRezLocation( + RayStart, RayEnd, RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, scale, false); + + // Rez object + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = m_Scene.InventoryService.GetItem(item); + + if (item != null) + { + AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); + + if (rezAsset != null) + { + UUID itemId = UUID.Zero; + + // If we have permission to copy then link the rezzed object back to the user inventory + // item that it came from. This allows us to enable 'save object to inventory' + if (!m_Scene.Permissions.BypassPermissions()) + { + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) + { + itemId = item.ID; + } + } + else + { + // Brave new fullperm world + // + itemId = item.ID; + } + + string xmlData = Utils.BytesToString(rezAsset.Data); + SceneObjectGroup group + = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); + + if (!m_Scene.Permissions.CanRezObject( + group.Children.Count, remoteClient.AgentId, pos) + && !attachment) + { + // The client operates in no fail mode. It will + // have already removed the item from the folder + // if it's no copy. + // Put it back if it's not an attachment + // + if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) + remoteClient.SendBulkUpdateInventory(item); + return null; + } + + group.ResetIDs(); + + if (attachment) + { + group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; + group.RootPart.IsAttachment = true; + } + + m_Scene.AddNewSceneObject(group, true); + + // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); + // if attachment we set it's asset id so object updates can reflect that + // if not, we set it's position in world. + if (!attachment) + { + float offsetHeight = 0; + pos = m_Scene.GetNewRezLocation( + RayStart, RayEnd, RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); + pos.Z += offsetHeight; + group.AbsolutePosition = pos; + // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight); + + } + else + { + group.SetFromItemID(itemID); + } + + SceneObjectPart rootPart = null; + try + { + rootPart = group.GetChildPart(group.UUID); + } + catch (NullReferenceException) + { + string isAttachment = ""; + + if (attachment) + isAttachment = " Object was an attachment"; + + m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); + } + + // Since renaming the item in the inventory does not affect the name stored + // in the serialization, transfer the correct name from the inventory to the + // object itself before we rez. + rootPart.Name = item.Name; + rootPart.Description = item.Description; + + List partList = new List(group.Children.Values); + + group.SetGroup(remoteClient.ActiveGroupId, remoteClient); + if (rootPart.OwnerID != item.Owner) + { + //Need to kill the for sale here + rootPart.ObjectSaleType = 0; + rootPart.SalePrice = 10; + + if (m_Scene.Permissions.PropagatePermissions()) + { + if ((item.CurrentPermissions & 8) != 0) + { + foreach (SceneObjectPart part in partList) + { + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; + part.GroupMask = 0; // DO NOT propagate here + } + } + group.ApplyNextOwnerPermissions(); + } + } + + foreach (SceneObjectPart part in partList) + { + if (part.OwnerID != item.Owner) + { + part.LastOwnerID = part.OwnerID; + part.OwnerID = item.Owner; + part.Inventory.ChangeInventoryOwner(item.Owner); + } + else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam! + { + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; + + part.GroupMask = 0; // DO NOT propagate here + } + } + + rootPart.TrimPermissions(); + + if (!attachment) + { + if (group.RootPart.Shape.PCode == (byte)PCode.Prim) + { + group.ClearPartAttachmentData(); + } + } + + if (!attachment) + { + // Fire on_rez + group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0); + + rootPart.ScheduleFullUpdate(); + } + + if (!m_Scene.Permissions.BypassPermissions()) + { + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + { + // If this is done on attachments, no + // copy ones will be lost, so avoid it + // + if (!attachment) + { + List uuids = new List(); + uuids.Add(item.ID); + m_Scene.InventoryService.DeleteItems(item.Owner, uuids); + } + } + } + + return rootPart.ParentGroup; + } + } + + return null; + } + + public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) + { + } + + #endregion + + #region Misc + + /// + /// Create a new asset data structure. + /// + /// + /// + /// + /// + /// + /// + private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) + { + AssetBase asset = new AssetBase(UUID.Random(), name, assetType); + asset.Description = description; + asset.Data = (data == null) ? new byte[1] : data; + + return asset; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index e10fa60..bdacc10 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -10,6 +10,8 @@ + + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 24b5d6c..2b1f815 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -39,7 +39,6 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Services.Interfaces; using OpenSim.Services.Connectors.Simulation; diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 56200ec..56b50dc 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -32,7 +32,6 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 9a7863b..c08b961 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -32,6 +32,7 @@ using System.Timers; using log4net; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.Framework.Scenes { @@ -137,7 +138,9 @@ namespace OpenSim.Region.Framework.Scenes try { - m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); + IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); + if (invAccess != null) + invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); if (x.permissionToDelete) m_scene.DeleteSceneObject(x.objectGroup, false); } diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs deleted file mode 100644 index fdda150..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ /dev/null @@ -1,264 +0,0 @@ -/* - * 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.Collections.Generic; -using System.Reflection; -using System.Threading; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; - -using OpenSim.Region.Framework.Scenes.Serialization; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Services.Interfaces; - -//using HyperGrid.Framework; -//using OpenSim.Region.Communications.Hypergrid; - -namespace OpenSim.Region.Framework.Scenes.Hypergrid -{ - public class HGAssetMapper - { - #region Fields - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - // This maps between inventory server urls and inventory server clients -// private Dictionary m_inventoryServers = new Dictionary(); - - private Scene m_scene; - - private IHyperAssetService m_hyper; - IHyperAssetService HyperlinkAssets - { - get - { - if (m_hyper == null) - m_hyper = m_scene.RequestModuleInterface(); - return m_hyper; - } - } - - #endregion - - #region Constructor - - public HGAssetMapper(Scene scene) - { - m_scene = scene; - } - - #endregion - - #region Internal functions - -// private string UserAssetURL(UUID userID) -// { -// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); -// if (uinfo != null) -// return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; -// return null; -// } - -// private string UserInventoryURL(UUID userID) -// { -// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); -// if (uinfo != null) -// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI; -// return null; -// } - - - public AssetBase FetchAsset(string url, UUID assetID) - { - AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString()); - - if (asset != null) - { - m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url); - return asset; - } - return null; - } - - public bool PostAsset(string url, AssetBase asset) - { - if (asset != null) - { - // See long comment in AssetCache.AddAsset - if (!asset.Temporary || asset.Local) - { - // We need to copy the asset into a new asset, because - // we need to set its ID to be URL+UUID, so that the - // HGAssetService dispatches it to the remote grid. - // It's not pretty, but the best that can be done while - // not having a global naming infrastructure - AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); - Copy(asset, asset1); - try - { - asset1.ID = url + "/" + asset.ID; - } - catch - { - m_log.Warn("[HGScene]: Oops."); - } - - m_scene.AssetService.Store(asset1); - m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); - } - return true; - } - else - m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache."); - - return false; - } - - private void Copy(AssetBase from, AssetBase to) - { - to.Data = from.Data; - to.Description = from.Description; - to.FullID = from.FullID; - to.ID = from.ID; - to.Local = from.Local; - to.Name = from.Name; - to.Temporary = from.Temporary; - to.Type = from.Type; - - } - - // TODO: unused - // private void Dump(Dictionary lst) - // { - // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); - // foreach (KeyValuePair kvp in lst) - // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); - // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); - // } - - #endregion - - - #region Public interface - - public void Get(UUID assetID, UUID ownerID) - { - // Get the item from the remote asset server onto the local AssetCache - // and place an entry in m_assetMap - - string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID); - if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer())) - { - m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL); - AssetBase asset = FetchAsset(userAssetURL, assetID); - - if (asset != null) - { - // OK, now fetch the inside. - Dictionary ids = new Dictionary(); - HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); - uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); - foreach (UUID uuid in ids.Keys) - FetchAsset(userAssetURL, uuid); - - m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL); - - } - else - m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); - } - else - m_log.Debug("[HGScene]: user's asset server is the local region's asset server"); - } - - //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) - //{ - // InventoryClient invCli = null; - // string inventoryURL = UserInventoryURL(item.Owner); - // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli)) - // { - // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL); - // invCli = new InventoryClient(inventoryURL); - // m_inventoryServers.Add(inventoryURL, invCli); - // } - - // item = invCli.GetInventoryItem(item); - // if (item != null) - // { - // // Change the folder, stick it in root folder, all items flattened out here in this region cache - // item.Folder = rootFolder; - // //userInfo.AddItem(item); don't use this, it calls back to the inventory server - // lock (userInfo.RootFolder.Items) - // { - // userInfo.RootFolder.Items[item.ID] = item; - // } - - // } - // return item; - //} - - public void Post(UUID assetID, UUID ownerID) - { - // Post the item from the local AssetCache onto the remote asset server - // and place an entry in m_assetMap - - string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID); - if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer())) - { - m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); - AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); - if (asset != null) - { - Dictionary ids = new Dictionary(); - HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); - uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); - foreach (UUID uuid in ids.Keys) - { - asset = m_scene.AssetService.Get(uuid.ToString()); - if (asset == null) - m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid); - else - PostAsset(userAssetURL, asset); - } - - // maybe all pieces got there... - m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); - - } - else - m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID); - } - else - m_log.Debug("[HGScene]: user's asset server is local region's asset server"); - - } - - #endregion - - } -} diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs deleted file mode 100644 index c5f8921..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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.Reflection; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications; - -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Region.Framework.Scenes.Hypergrid -{ - public partial class HGScene : Scene - { - #region Fields - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private HGAssetMapper m_assMapper; - public HGAssetMapper AssetMapper - { - get { return m_assMapper; } - } - - private IHyperAssetService m_hyper; - private IHyperAssetService HyperAssets - { - get - { - if (m_hyper == null) - m_hyper = RequestModuleInterface(); - return m_hyper; - } - } - - #endregion - - #region Constructors - - public HGScene(RegionInfo regInfo, AgentCircuitManager authen, - SceneCommunicationService sceneGridService, - StorageManager storeManager, - ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, - bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) - : base(regInfo, authen, sceneGridService, storeManager, moduleLoader, - dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion) - { - m_log.Info("[HGScene]: Starting HGScene."); - m_assMapper = new HGAssetMapper(this); - - EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; - } - - #endregion - - #region Event handlers - - public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) - { - UserAccount userInfo = UserAccountService.GetUserAccount(RegionInfo.ScopeID, avatarID); - if (userInfo != null) - { - m_assMapper.Post(assetID, avatarID); - } - } - - #endregion - - #region Overrides of Scene.Inventory methods - - /// - /// CapsUpdateInventoryItemAsset - /// - public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) - { - UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); - - UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); - - return newAssetID; - } - - /// - /// DeleteToInventory - /// - public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) - { - UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient); - - if (!assetID.Equals(UUID.Zero)) - { - UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); - } - else - m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); - - return assetID; - } - - /// - /// RezObject - /// - public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, - UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, - bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) - { - m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); - - //if (fromTaskID.Equals(UUID.Zero)) - //{ - InventoryItemBase item = new InventoryItemBase(itemID); - item.Owner = remoteClient.AgentId; - item = InventoryService.GetItem(item); - //if (item == null) - //{ // Fetch the item - // item = new InventoryItemBase(); - // item.Owner = remoteClient.AgentId; - // item.ID = itemID; - // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); - //} - if (item != null) - { - m_assMapper.Get(item.AssetID, remoteClient.AgentId); - - } - //} - - // OK, we're done fetching. Pass it up to the default RezObject - return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, - RezSelected, RemoveItem, fromTaskID, attachment); - - } - - protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) - { - string userAssetServer = HyperAssets.GetUserAssetServer(sender); - if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) - m_assMapper.Get(item.AssetID, sender); - - userAssetServer = HyperAssets.GetUserAssetServer(receiver); - if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) - m_assMapper.Post(item.AssetID, receiver); - } - - #endregion - - } - -} diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs deleted file mode 100644 index 5d4e7ac..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.Collections.Generic; - -using OpenSim.Framework; -using OpenSim.Services.Interfaces; -using OpenMetaverse; - -namespace OpenSim.Region.Framework.Scenes.Hypergrid -{ - public class HGUuidGatherer : UuidGatherer - { - protected string m_assetServerURL; - protected HGAssetMapper m_assetMapper; - - public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache) - { - m_assetMapper = assMap; - m_assetServerURL = assetServerURL; - } - - protected override AssetBase GetAsset(UUID uuid) - { - if (string.Empty == m_assetServerURL) - return m_assetCache.Get(uuid.ToString()); - else - return m_assetMapper.FetchAsset(m_assetServerURL, uuid); - } - } -} diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 62a831e..45806dd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -126,61 +126,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Capability originating call to update the asset of an item in an agent's inventory - /// - /// - /// - /// - /// - public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) - { - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = InventoryService.GetItem(item); - - if (item != null) - { - if ((InventoryType)item.InvType == InventoryType.Notecard) - { - if (!Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId)) - { - remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); - return UUID.Zero; - } - - remoteClient.SendAgentAlertMessage("Notecard saved", false); - } - else if ((InventoryType)item.InvType == InventoryType.LSL) - { - if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) - { - remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); - return UUID.Zero; - } - - remoteClient.SendAgentAlertMessage("Script saved", false); - } - - AssetBase asset = - CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); - item.AssetID = asset.FullID; - AssetService.Store(asset); - - InventoryService.UpdateItem(item); - - // remoteClient.SendInventoryItemCreateUpdate(item); - return (asset.FullID); - } - else - { - m_log.ErrorFormat( - "[AGENT INVENTORY]: Could not find item {0} for caps inventory update", - itemID); - } - - return UUID.Zero; - } - - /// /// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[]) /// public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) @@ -189,7 +134,9 @@ namespace OpenSim.Region.Framework.Scenes if (TryGetAvatar(avatarId, out avatar)) { - return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); + IInventoryAccessModule invAccess = RequestModuleInterface(); + if (invAccess != null) + return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); } else { @@ -472,7 +419,11 @@ namespace OpenSim.Region.Framework.Scenes itemCopy.SaleType = item.SaleType; if (InventoryService.AddItem(itemCopy)) - TransferInventoryAssets(itemCopy, senderId, recipient); + { + IInventoryAccessModule invAccess = RequestModuleInterface(); + if (invAccess != null) + invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); + } if (!Permissions.BypassPermissions()) { @@ -494,10 +445,6 @@ namespace OpenSim.Region.Framework.Scenes } - protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) - { - } - /// /// Give an entire inventory folder from one user to another. The entire contents (including all descendent /// folders) is given. @@ -1605,232 +1552,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// Delete a scene object from a scene and place in the given avatar's inventory. - /// Returns the UUID of the newly created asset. - /// - /// - /// - /// - /// - public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, - SceneObjectGroup objectGroup, IClientAPI remoteClient) - { - UUID assetID = UUID.Zero; - - Vector3 inventoryStoredPosition = new Vector3 - (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) - ? 250 - : objectGroup.AbsolutePosition.X) - , - (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) - ? 250 - : objectGroup.AbsolutePosition.X, - objectGroup.AbsolutePosition.Z); - - Vector3 originalPosition = objectGroup.AbsolutePosition; - - objectGroup.AbsolutePosition = inventoryStoredPosition; - - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); - - objectGroup.AbsolutePosition = originalPosition; - - // Get the user info of the item destination - // - UUID userID = UUID.Zero; - - if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || - action == DeRezAction.SaveToExistingUserInventoryItem) - { - // Take or take copy require a taker - // Saving changes requires a local user - // - if (remoteClient == null) - return UUID.Zero; - - userID = remoteClient.AgentId; - } - else - { - // All returns / deletes go to the object owner - // - - userID = objectGroup.RootPart.OwnerID; - } - - if (userID == UUID.Zero) // Can't proceed - { - return UUID.Zero; - } - - // If we're returning someone's item, it goes back to the - // owner's Lost And Found folder. - // Delete is treated like return in this case - // Deleting your own items makes them go to trash - // - - InventoryFolderBase folder = null; - InventoryItemBase item = null; - - if (DeRezAction.SaveToExistingUserInventoryItem == action) - { - item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); - item = InventoryService.GetItem(item); - - //item = userInfo.RootFolder.FindItem( - // objectGroup.RootPart.FromUserInventoryItemID); - - if (null == item) - { - m_log.DebugFormat( - "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", - objectGroup.Name, objectGroup.UUID); - return UUID.Zero; - } - } - else - { - // Folder magic - // - if (action == DeRezAction.Delete) - { - // Deleting someone else's item - // - - - if (remoteClient == null || - objectGroup.OwnerID != remoteClient.AgentId) - { - // Folder skeleton may not be loaded and we - // have to wait for the inventory to find - // the destination folder - // - folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); - } - else - { - // Assume inventory skeleton was loaded during login - // and all folders can be found - // - folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); - } - } - else if (action == DeRezAction.Return) - { - - // Dump to lost + found unconditionally - // - folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); - } - - if (folderID == UUID.Zero && folder == null) - { - if (action == DeRezAction.Delete) - { - // Deletes go to trash by default - // - folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); - } - else - { - // Catch all. Use lost & found - // - - folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); - } - } - - if (folder == null) // None of the above - { - //folder = userInfo.RootFolder.FindFolder(folderID); - folder = new InventoryFolderBase(folderID); - - if (folder == null) // Nowhere to put it - { - return UUID.Zero; - } - } - - item = new InventoryItemBase(); - item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); - item.ID = UUID.Random(); - item.InvType = (int)InventoryType.Object; - item.Folder = folder.ID; - item.Owner = userID; - } - - AssetBase asset = CreateAsset( - objectGroup.GetPartName(objectGroup.RootPart.LocalId), - objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), - (sbyte)AssetType.Object, - Utils.StringToBytes(sceneObjectXml)); - AssetService.Store(asset); - assetID = asset.FullID; - - if (DeRezAction.SaveToExistingUserInventoryItem == action) - { - item.AssetID = asset.FullID; - InventoryService.UpdateItem(item); - } - else - { - item.AssetID = asset.FullID; - - if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions()) - { - uint perms=objectGroup.GetEffectivePermissions(); - uint nextPerms=(perms & 7) << 13; - if ((nextPerms & (uint)PermissionMask.Copy) == 0) - perms &= ~(uint)PermissionMask.Copy; - if ((nextPerms & (uint)PermissionMask.Transfer) == 0) - perms &= ~(uint)PermissionMask.Transfer; - if ((nextPerms & (uint)PermissionMask.Modify) == 0) - perms &= ~(uint)PermissionMask.Modify; - - item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; - item.CurrentPermissions = item.BasePermissions; - item.NextPermissions = objectGroup.RootPart.NextOwnerMask; - item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; - item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; - item.CurrentPermissions |= 8; // Slam! - } - else - { - item.BasePermissions = objectGroup.GetEffectivePermissions(); - item.CurrentPermissions = objectGroup.GetEffectivePermissions(); - item.NextPermissions = objectGroup.RootPart.NextOwnerMask; - item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; - item.GroupPermissions = objectGroup.RootPart.GroupMask; - - item.CurrentPermissions |= 8; // Slam! - } - - // TODO: add the new fields (Flags, Sale info, etc) - item.CreationDate = Util.UnixTimeSinceEpoch(); - item.Description = asset.Description; - item.Name = asset.Name; - item.AssetType = asset.Type; - - InventoryService.AddItem(item); - - if (remoteClient != null && item.Owner == remoteClient.AgentId) - { - remoteClient.SendInventoryItemCreateUpdate(item, 0); - } - else - { - ScenePresence notifyUser = GetScenePresence(item.Owner); - if (notifyUser != null) - { - notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); - } - } - } - - return assetID; - } - public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) { SceneObjectGroup objectGroup = grp; @@ -1971,225 +1692,11 @@ namespace OpenSim.Region.Framework.Scenes UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID) { - RezObject( - remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, - RezSelected, RemoveItem, fromTaskID, false); - } - - /// - /// Rez an object into the scene from the user's inventory - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The SceneObjectGroup rezzed or null if rez was unsuccessful. - public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, - UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, - bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) - { - // Work out position details - byte bRayEndIsIntersection = (byte)0; - - if (RayEndIsIntersection) - { - bRayEndIsIntersection = (byte)1; - } - else - { - bRayEndIsIntersection = (byte)0; - } - - Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); - - - Vector3 pos = GetNewRezLocation( - RayStart, RayEnd, RayTargetID, Quaternion.Identity, - BypassRayCast, bRayEndIsIntersection,true,scale, false); - - // Rez object - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = InventoryService.GetItem(item); - - if (item != null) - { - AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); - - if (rezAsset != null) - { - UUID itemId = UUID.Zero; - - // If we have permission to copy then link the rezzed object back to the user inventory - // item that it came from. This allows us to enable 'save object to inventory' - if (!Permissions.BypassPermissions()) - { - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) - { - itemId = item.ID; - } - } - else - { - // Brave new fullperm world - // - itemId = item.ID; - } - - string xmlData = Utils.BytesToString(rezAsset.Data); - SceneObjectGroup group - = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); - - if (!Permissions.CanRezObject( - group.Children.Count, remoteClient.AgentId, pos) - && !attachment) - { - // The client operates in no fail mode. It will - // have already removed the item from the folder - // if it's no copy. - // Put it back if it's not an attachment - // - if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) - remoteClient.SendBulkUpdateInventory(item); - return null; - } - - group.ResetIDs(); - - if (attachment) - { - group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; - group.RootPart.IsAttachment = true; - } - - AddNewSceneObject(group, true); - - // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); - // if attachment we set it's asset id so object updates can reflect that - // if not, we set it's position in world. - if (!attachment) - { - float offsetHeight = 0; - pos = GetNewRezLocation( - RayStart, RayEnd, RayTargetID, Quaternion.Identity, - BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); - pos.Z += offsetHeight; - group.AbsolutePosition = pos; - // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight); - - } - else - { - group.SetFromItemID(itemID); - } - - SceneObjectPart rootPart = null; - try - { - rootPart = group.GetChildPart(group.UUID); - } - catch (NullReferenceException) - { - string isAttachment = ""; - - if (attachment) - isAttachment = " Object was an attachment"; - - m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); - } - - // Since renaming the item in the inventory does not affect the name stored - // in the serialization, transfer the correct name from the inventory to the - // object itself before we rez. - rootPart.Name = item.Name; - rootPart.Description = item.Description; - - List partList = new List(group.Children.Values); - - group.SetGroup(remoteClient.ActiveGroupId, remoteClient); - if (rootPart.OwnerID != item.Owner) - { - //Need to kill the for sale here - rootPart.ObjectSaleType = 0; - rootPart.SalePrice = 10; - - if (Permissions.PropagatePermissions()) - { - if ((item.CurrentPermissions & 8) != 0) - { - foreach (SceneObjectPart part in partList) - { - part.EveryoneMask = item.EveryOnePermissions; - part.NextOwnerMask = item.NextPermissions; - part.GroupMask = 0; // DO NOT propagate here - } - } - group.ApplyNextOwnerPermissions(); - } - } - - foreach (SceneObjectPart part in partList) - { - if (part.OwnerID != item.Owner) - { - part.LastOwnerID = part.OwnerID; - part.OwnerID = item.Owner; - part.Inventory.ChangeInventoryOwner(item.Owner); - } - else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam! - { - part.EveryoneMask = item.EveryOnePermissions; - part.NextOwnerMask = item.NextPermissions; - - part.GroupMask = 0; // DO NOT propagate here - } - } - - rootPart.TrimPermissions(); - - if (!attachment) - { - if (group.RootPart.Shape.PCode == (byte)PCode.Prim) - { - group.ClearPartAttachmentData(); - } - } - - if (!attachment) - { - // Fire on_rez - group.CreateScriptInstances(0, true, DefaultScriptEngine, 0); - - rootPart.ScheduleFullUpdate(); - } - - if (!Permissions.BypassPermissions()) - { - if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - { - // If this is done on attachments, no - // copy ones will be lost, so avoid it - // - if (!attachment) - { - List uuids = new List(); - uuids.Add(item.ID); - InventoryService.DeleteItems(item.Owner, uuids); - } - } - } - - return rootPart.ParentGroup; - } - } - - return null; + IInventoryAccessModule invAccess = RequestModuleInterface(); + if (invAccess != null) + invAccess.RezObject( + remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, + RezSelected, RemoveItem, fromTaskID, false); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f74fd5d..fbd11c6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -35,6 +35,7 @@ using log4net; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes.Types; using OpenSim.Region.Physics.Manager; +using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.Framework.Scenes { @@ -498,27 +499,32 @@ namespace OpenSim.Region.Framework.Scenes public SceneObjectGroup RezSingleAttachment( IClientAPI remoteClient, UUID itemID, uint AttachmentPt) { - SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, - itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, - false, false, remoteClient.AgentId, true); - - - if (objatt != null) + IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface(); + if (invAccess != null) { - bool tainted = false; - if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) - tainted = true; + SceneObjectGroup objatt = invAccess.RezObject(remoteClient, + itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, + false, false, remoteClient.AgentId, true); - AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); - objatt.ScheduleGroupForFullUpdate(); - if (tainted) - objatt.HasGroupChanged = true; - // Fire after attach, so we don't get messy perms dialogs - // 3 == AttachedRez - objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); + if (objatt != null) + { + bool tainted = false; + if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) + tainted = true; + + AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); + objatt.ScheduleGroupForFullUpdate(); + if (tainted) + objatt.HasGroupChanged = true; + + // Fire after attach, so we don't get messy perms dialogs + // 3 == AttachedRez + objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); + } + return objatt; } - return objatt; + return null; } // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b28976e..fccd07e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -41,7 +41,6 @@ using OpenSim.Framework.Console; using OpenSim.Region.CoreModules.Avatar.NPC; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 395537d..686d2a4 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -21,6 +21,7 @@ SimulationServices = "RemoteSimulationConnectorModule" AvatarServices = "LocalAvatarServicesConnector" EntityTransferModule = "HGEntityTransferModule" + InventoryAccessModule = "HGInventoryAccessModule" InventoryServiceInConnector = true AssetServiceInConnector = true HGAuthServiceInConnector = true -- cgit v1.1