* HGScene is no more.
* Moved a few key inventory access methods from Scene.Inventory to an IInventoryAccessModule moduleslimupdates
parent
81a6f9a515
commit
42f978a478
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -574,11 +574,6 @@ namespace OpenSim
|
||||||
protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
|
protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
|
||||||
AgentCircuitManager circuitManager)
|
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();
|
SceneCommunicationService sceneGridService = new SceneCommunicationService();
|
||||||
|
|
||||||
return new Scene(
|
return new Scene(
|
||||||
|
|
|
@ -31,7 +31,6 @@ using OpenMetaverse;
|
||||||
using OpenMetaverse.Imaging;
|
using OpenMetaverse.Imaging;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes.Hypergrid;
|
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using log4net;
|
using log4net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
|
@ -44,7 +44,6 @@ using OpenSim.Framework.Client;
|
||||||
using OpenSim.Framework.Statistics;
|
using OpenSim.Framework.Statistics;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Region.Framework.Scenes.Hypergrid;
|
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using Timer = System.Timers.Timer;
|
using Timer = System.Timers.Timer;
|
||||||
using AssetLandmark = OpenSim.Framework.AssetLandmark;
|
using AssetLandmark = OpenSim.Framework.AssetLandmark;
|
||||||
|
|
|
@ -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<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
|
||||||
|
|
||||||
|
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<UUID, bool> lst)
|
||||||
|
// {
|
||||||
|
// m_log.Debug("XXX -------- UUID DUMP ------- XXX");
|
||||||
|
// foreach (KeyValuePair<UUID, bool> 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<UUID, int> ids = new Dictionary<UUID, int>();
|
||||||
|
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<UUID, int> ids = new Dictionary<UUID, int>();
|
||||||
|
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
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
|
@ -25,56 +25,67 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
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 log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.Communications;
|
|
||||||
|
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
using OpenSim.Services.Interfaces;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
|
||||||
{
|
{
|
||||||
public partial class HGScene : Scene
|
public class HGInventoryAccessModule : InventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule
|
||||||
{
|
{
|
||||||
#region Fields
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private HGAssetMapper m_assMapper;
|
private static HGAssetMapper m_assMapper;
|
||||||
public HGAssetMapper AssetMapper
|
public static HGAssetMapper AssetMapper
|
||||||
{
|
{
|
||||||
get { return m_assMapper; }
|
get { return m_assMapper; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private IHyperAssetService m_hyper;
|
private bool m_Initialized = false;
|
||||||
private IHyperAssetService HyperAssets
|
|
||||||
|
#region INonSharedRegionModule
|
||||||
|
|
||||||
|
public override string Name
|
||||||
{
|
{
|
||||||
get
|
get { return "HGInventoryAccessModule"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Initialise(IConfigSource source)
|
||||||
|
{
|
||||||
|
IConfig moduleConfig = source.Configs["Modules"];
|
||||||
|
if (moduleConfig != null)
|
||||||
{
|
{
|
||||||
if (m_hyper == null)
|
string name = moduleConfig.GetString("InventoryAccessModule", "");
|
||||||
m_hyper = RequestModuleInterface<IHyperAssetService>();
|
if (name == Name)
|
||||||
return m_hyper;
|
{
|
||||||
|
m_Enabled = true;
|
||||||
|
m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
public override void AddRegion(Scene scene)
|
||||||
|
|
||||||
#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.");
|
if (!m_Enabled)
|
||||||
m_assMapper = new HGAssetMapper(this);
|
return;
|
||||||
|
|
||||||
|
base.AddRegion(scene);
|
||||||
|
m_assMapper = new HGAssetMapper(scene);
|
||||||
|
scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
|
||||||
|
|
||||||
EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -83,17 +94,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||||
|
|
||||||
public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
|
public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
|
||||||
{
|
{
|
||||||
UserAccount userInfo = UserAccountService.GetUserAccount(RegionInfo.ScopeID, avatarID);
|
string userAssetServer = string.Empty;
|
||||||
if (userInfo != null)
|
if (IsForeignUser(avatarID, out userAssetServer))
|
||||||
{
|
{
|
||||||
m_assMapper.Post(assetID, avatarID);
|
m_assMapper.Post(assetID, avatarID, userAssetServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Overrides of Scene.Inventory methods
|
#region Overrides of Basic Inventory Access methods
|
||||||
|
|
||||||
///
|
///
|
||||||
/// CapsUpdateInventoryItemAsset
|
/// CapsUpdateInventoryItemAsset
|
||||||
///
|
///
|
||||||
|
@ -136,7 +146,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||||
//{
|
//{
|
||||||
InventoryItemBase item = new InventoryItemBase(itemID);
|
InventoryItemBase item = new InventoryItemBase(itemID);
|
||||||
item.Owner = remoteClient.AgentId;
|
item.Owner = remoteClient.AgentId;
|
||||||
item = InventoryService.GetItem(item);
|
item = m_Scene.InventoryService.GetItem(item);
|
||||||
//if (item == null)
|
//if (item == null)
|
||||||
//{ // Fetch the item
|
//{ // Fetch the item
|
||||||
// item = new InventoryItemBase();
|
// item = new InventoryItemBase();
|
||||||
|
@ -144,32 +154,51 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||||
// item.ID = itemID;
|
// item.ID = itemID;
|
||||||
// item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
|
// item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
|
||||||
//}
|
//}
|
||||||
if (item != null)
|
string userAssetServer = string.Empty;
|
||||||
|
if (item != null && IsForeignUser(remoteClient.AgentId, out userAssetServer))
|
||||||
{
|
{
|
||||||
m_assMapper.Get(item.AssetID, remoteClient.AgentId);
|
m_assMapper.Get(item.AssetID, remoteClient.AgentId, userAssetServer);
|
||||||
|
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// OK, we're done fetching. Pass it up to the default RezObject
|
// OK, we're done fetching. Pass it up to the default RezObject
|
||||||
return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
|
return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
|
||||||
RezSelected, RemoveItem, fromTaskID, attachment);
|
RezSelected, RemoveItem, fromTaskID, attachment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
|
public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
|
||||||
{
|
{
|
||||||
string userAssetServer = HyperAssets.GetUserAssetServer(sender);
|
string userAssetServer = string.Empty;
|
||||||
if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
|
if (IsForeignUser(sender, out userAssetServer))
|
||||||
m_assMapper.Get(item.AssetID, sender);
|
m_assMapper.Get(item.AssetID, sender, userAssetServer);
|
||||||
|
|
||||||
userAssetServer = HyperAssets.GetUserAssetServer(receiver);
|
if (IsForeignUser(receiver, out userAssetServer))
|
||||||
if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
|
m_assMapper.Post(item.AssetID, receiver, userAssetServer);
|
||||||
m_assMapper.Post(item.AssetID, receiver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -29,10 +29,11 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
|
||||||
namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
{
|
{
|
||||||
public class HGUuidGatherer : UuidGatherer
|
public class HGUuidGatherer : UuidGatherer
|
||||||
{
|
{
|
|
@ -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<IInventoryAccessModule>(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
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Capability originating call to update the asset of an item in an agent's inventory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
|
/// <param name="itemID"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a scene object from a scene and place in the given avatar's inventory.
|
||||||
|
/// Returns the UUID of the newly created asset.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
/// <param name="folderID"></param>
|
||||||
|
/// <param name="objectGroup"></param>
|
||||||
|
/// <param name="remoteClient"> </param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rez an object into the scene from the user's inventory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
|
/// <param name="itemID"></param>
|
||||||
|
/// <param name="RayEnd"></param>
|
||||||
|
/// <param name="RayStart"></param>
|
||||||
|
/// <param name="RayTargetID"></param>
|
||||||
|
/// <param name="BypassRayCast"></param>
|
||||||
|
/// <param name="RayEndIsIntersection"></param>
|
||||||
|
/// <param name="RezSelected"></param>
|
||||||
|
/// <param name="RemoveItem"></param>
|
||||||
|
/// <param name="fromTaskID"></param>
|
||||||
|
/// <param name="attachment"></param>
|
||||||
|
/// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
|
||||||
|
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<SceneObjectPart> partList = new List<SceneObjectPart>(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<UUID> uuids = new List<UUID>();
|
||||||
|
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
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new asset data structure.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
/// <param name="invType"></param>
|
||||||
|
/// <param name="assetType"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,8 @@
|
||||||
<Extension path = "/OpenSim/RegionModules">
|
<Extension path = "/OpenSim/RegionModules">
|
||||||
<RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" />
|
<RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" />
|
||||||
<RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" />
|
<RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" />
|
||||||
|
<RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.InventoryAccessModule" />
|
||||||
|
<RegionModule id="HGInventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.HGInventoryAccessModule" />
|
||||||
<RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" />
|
<RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" />
|
||||||
<RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" />
|
<RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" />
|
||||||
<RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" />
|
<RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" />
|
||||||
|
|
|
@ -39,7 +39,6 @@ using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Region.Framework.Scenes.Hypergrid;
|
|
||||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using OpenSim.Services.Connectors.Simulation;
|
using OpenSim.Services.Connectors.Simulation;
|
||||||
|
|
|
@ -32,7 +32,6 @@ using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Region.Framework.Scenes.Hypergrid;
|
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ using System.Timers;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Region.Framework.Scenes
|
namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
|
@ -137,7 +138,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient);
|
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
|
||||||
|
if (invAccess != null)
|
||||||
|
invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient);
|
||||||
if (x.permissionToDelete)
|
if (x.permissionToDelete)
|
||||||
m_scene.DeleteSceneObject(x.objectGroup, false);
|
m_scene.DeleteSceneObject(x.objectGroup, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
|
|
||||||
|
|
||||||
private Scene m_scene;
|
|
||||||
|
|
||||||
private IHyperAssetService m_hyper;
|
|
||||||
IHyperAssetService HyperlinkAssets
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (m_hyper == null)
|
|
||||||
m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
|
|
||||||
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<UUID, bool> lst)
|
|
||||||
// {
|
|
||||||
// m_log.Debug("XXX -------- UUID DUMP ------- XXX");
|
|
||||||
// foreach (KeyValuePair<UUID, bool> 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<UUID, int> ids = new Dictionary<UUID, int>();
|
|
||||||
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<UUID, int> ids = new Dictionary<UUID, int>();
|
|
||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -125,61 +125,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
remoteClient.SendInventoryItemCreateUpdate(item, 0);
|
remoteClient.SendInventoryItemCreateUpdate(item, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Capability originating call to update the asset of an item in an agent's inventory
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="remoteClient"></param>
|
|
||||||
/// <param name="itemID"></param>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
|
/// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -189,7 +134,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (TryGetAvatar(avatarId, out avatar))
|
if (TryGetAvatar(avatarId, out avatar))
|
||||||
{
|
{
|
||||||
return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
|
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
||||||
|
if (invAccess != null)
|
||||||
|
return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -472,7 +419,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
itemCopy.SaleType = item.SaleType;
|
itemCopy.SaleType = item.SaleType;
|
||||||
|
|
||||||
if (InventoryService.AddItem(itemCopy))
|
if (InventoryService.AddItem(itemCopy))
|
||||||
TransferInventoryAssets(itemCopy, senderId, recipient);
|
{
|
||||||
|
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
||||||
|
if (invAccess != null)
|
||||||
|
invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
|
||||||
|
}
|
||||||
|
|
||||||
if (!Permissions.BypassPermissions())
|
if (!Permissions.BypassPermissions())
|
||||||
{
|
{
|
||||||
|
@ -494,10 +445,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Give an entire inventory folder from one user to another. The entire contents (including all descendent
|
/// Give an entire inventory folder from one user to another. The entire contents (including all descendent
|
||||||
/// folders) is given.
|
/// folders) is given.
|
||||||
|
@ -1605,232 +1552,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete a scene object from a scene and place in the given avatar's inventory.
|
|
||||||
/// Returns the UUID of the newly created asset.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="action"></param>
|
|
||||||
/// <param name="folderID"></param>
|
|
||||||
/// <param name="objectGroup"></param>
|
|
||||||
/// <param name="remoteClient"> </param>
|
|
||||||
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)
|
public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
|
||||||
{
|
{
|
||||||
SceneObjectGroup objectGroup = grp;
|
SceneObjectGroup objectGroup = grp;
|
||||||
|
@ -1971,225 +1692,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
|
UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
|
||||||
bool RezSelected, bool RemoveItem, UUID fromTaskID)
|
bool RezSelected, bool RemoveItem, UUID fromTaskID)
|
||||||
{
|
{
|
||||||
RezObject(
|
IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
|
||||||
remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
|
if (invAccess != null)
|
||||||
RezSelected, RemoveItem, fromTaskID, false);
|
invAccess.RezObject(
|
||||||
}
|
remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
|
||||||
|
RezSelected, RemoveItem, fromTaskID, false);
|
||||||
/// <summary>
|
|
||||||
/// Rez an object into the scene from the user's inventory
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="remoteClient"></param>
|
|
||||||
/// <param name="itemID"></param>
|
|
||||||
/// <param name="RayEnd"></param>
|
|
||||||
/// <param name="RayStart"></param>
|
|
||||||
/// <param name="RayTargetID"></param>
|
|
||||||
/// <param name="BypassRayCast"></param>
|
|
||||||
/// <param name="RayEndIsIntersection"></param>
|
|
||||||
/// <param name="RezSelected"></param>
|
|
||||||
/// <param name="RemoveItem"></param>
|
|
||||||
/// <param name="fromTaskID"></param>
|
|
||||||
/// <param name="attachment"></param>
|
|
||||||
/// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
|
|
||||||
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<SceneObjectPart> partList = new List<SceneObjectPart>(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<UUID> uuids = new List<UUID>();
|
|
||||||
uuids.Add(item.ID);
|
|
||||||
InventoryService.DeleteItems(item.Owner, uuids);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rootPart.ParentGroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -35,6 +35,7 @@ using log4net;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Scenes.Types;
|
using OpenSim.Region.Framework.Scenes.Types;
|
||||||
using OpenSim.Region.Physics.Manager;
|
using OpenSim.Region.Physics.Manager;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Region.Framework.Scenes
|
namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
|
@ -498,27 +499,32 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public SceneObjectGroup RezSingleAttachment(
|
public SceneObjectGroup RezSingleAttachment(
|
||||||
IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
|
IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
|
||||||
{
|
{
|
||||||
SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient,
|
IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface<IInventoryAccessModule>();
|
||||||
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
|
if (invAccess != null)
|
||||||
false, false, remoteClient.AgentId, true);
|
|
||||||
|
|
||||||
|
|
||||||
if (objatt != null)
|
|
||||||
{
|
{
|
||||||
bool tainted = false;
|
SceneObjectGroup objatt = invAccess.RezObject(remoteClient,
|
||||||
if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
|
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
|
||||||
tainted = 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
|
if (objatt != null)
|
||||||
// 3 == AttachedRez
|
{
|
||||||
objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
|
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.
|
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
|
||||||
|
|
|
@ -41,7 +41,6 @@ using OpenSim.Framework.Console;
|
||||||
using OpenSim.Region.CoreModules.Avatar.NPC;
|
using OpenSim.Region.CoreModules.Avatar.NPC;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Region.Framework.Scenes.Hypergrid;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
using OpenSim.Region.ScriptEngine.Shared;
|
||||||
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
|
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
|
||||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
SimulationServices = "RemoteSimulationConnectorModule"
|
SimulationServices = "RemoteSimulationConnectorModule"
|
||||||
AvatarServices = "LocalAvatarServicesConnector"
|
AvatarServices = "LocalAvatarServicesConnector"
|
||||||
EntityTransferModule = "HGEntityTransferModule"
|
EntityTransferModule = "HGEntityTransferModule"
|
||||||
|
InventoryAccessModule = "HGInventoryAccessModule"
|
||||||
InventoryServiceInConnector = true
|
InventoryServiceInConnector = true
|
||||||
AssetServiceInConnector = true
|
AssetServiceInConnector = true
|
||||||
HGAuthServiceInConnector = true
|
HGAuthServiceInConnector = true
|
||||||
|
|
Loading…
Reference in New Issue