mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 11:33:28 +08:00
Added CreateObject(regionhandle, userID, itemID) to post objects that are to be fetched from the user's inventory server and rezzed in the region. Added all code necessary to fetch the item and the asset, and rez it inworld. The access to the item is uncap-ed and unverified -- I may place it later either under a cap or with auth verification. But in this model regions don't have the user's inventory, so they would have to guess the item IDs.
Added safemode config to Standalone Hypergrid, similar effect to AllowRegionAccessToInventory in Inventory Server. Everyone should have these vars set to their default values except me!
This commit is contained in:
@@ -33,6 +33,7 @@ using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Communications.Clients;
|
||||
|
||||
//using HyperGrid.Framework;
|
||||
//using OpenSim.Region.Communications.Hypergrid;
|
||||
@@ -50,6 +51,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
// This maps between asset UUIDs and asset servers
|
||||
private Dictionary<UUID, GridAssetClient> m_assetMap = new Dictionary<UUID, GridAssetClient>();
|
||||
|
||||
// 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
|
||||
|
||||
@@ -72,6 +77,14 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
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;
|
||||
}
|
||||
|
||||
private bool IsLocalUser(UUID userID)
|
||||
{
|
||||
CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
|
||||
@@ -275,9 +288,9 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
|
||||
#region Public interface
|
||||
|
||||
public void Get(UUID itemID, UUID ownerID)
|
||||
public void Get(UUID assetID, UUID ownerID)
|
||||
{
|
||||
if (!IsInAssetMap(itemID) && !IsLocalUser(ownerID))
|
||||
if (!IsInAssetMap(assetID) && !IsLocalUser(ownerID))
|
||||
{
|
||||
// Get the item from the remote asset server onto the local AssetCache
|
||||
// and place an entry in m_assetMap
|
||||
@@ -295,11 +308,11 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
m_assetServers.Add(userAssetURL, asscli);
|
||||
}
|
||||
|
||||
m_log.Debug("[HGScene]: Fetching object " + itemID + " to asset server " + userAssetURL);
|
||||
bool success = FetchAsset(asscli, itemID, false); // asscli.RequestAsset(item.ItemID, false);
|
||||
m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL);
|
||||
bool success = FetchAsset(asscli, assetID, false); // asscli.RequestAsset(item.ItemID, false);
|
||||
|
||||
// OK, now fetch the inside.
|
||||
Dictionary<UUID, bool> ids = SniffUUIDs(itemID);
|
||||
Dictionary<UUID, bool> ids = SniffUUIDs(assetID);
|
||||
Dump(ids);
|
||||
foreach (KeyValuePair<UUID, bool> kvp in ids)
|
||||
FetchAsset(asscli, kvp.Key, kvp.Value);
|
||||
@@ -308,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
if (success)
|
||||
{
|
||||
m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
|
||||
m_assetMap.Add(itemID, asscli);
|
||||
m_assetMap.Add(assetID, asscli);
|
||||
}
|
||||
else
|
||||
m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
|
||||
@@ -318,7 +331,36 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
}
|
||||
}
|
||||
|
||||
public void Post(UUID itemID, UUID ownerID)
|
||||
public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
|
||||
{
|
||||
if (!IsLocalUser(item.Owner))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!IsLocalUser(ownerID))
|
||||
{
|
||||
@@ -337,11 +379,11 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache!
|
||||
m_assetServers.Add(userAssetURL, asscli);
|
||||
}
|
||||
m_log.Debug("[HGScene]: Posting object " + itemID + " to asset server " + userAssetURL);
|
||||
bool success = PostAsset(asscli, itemID);
|
||||
m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
|
||||
bool success = PostAsset(asscli, assetID);
|
||||
|
||||
// Now the inside
|
||||
Dictionary<UUID, bool> ids = SniffUUIDs(itemID);
|
||||
Dictionary<UUID, bool> ids = SniffUUIDs(assetID);
|
||||
Dump(ids);
|
||||
foreach (KeyValuePair<UUID, bool> kvp in ids)
|
||||
PostAsset(asscli, kvp.Key);
|
||||
@@ -349,8 +391,8 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
if (success)
|
||||
{
|
||||
m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL);
|
||||
if (!m_assetMap.ContainsKey(itemID))
|
||||
m_assetMap.Add(itemID, asscli);
|
||||
if (!m_assetMap.ContainsKey(assetID))
|
||||
m_assetMap.Add(assetID, asscli);
|
||||
}
|
||||
else
|
||||
m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL);
|
||||
|
||||
@@ -120,6 +120,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
|
||||
{
|
||||
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
|
||||
|
||||
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);
|
||||
|
||||
@@ -1731,6 +1731,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool IncomingCreateObject(UUID userID, UUID itemID)
|
||||
{
|
||||
ScenePresence sp = GetScenePresence(userID);
|
||||
if (sp != null)
|
||||
{
|
||||
uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
|
||||
SceneObjectGroup sog = m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AddSceneObject(UUID primID, SceneObjectGroup sceneObject)
|
||||
{
|
||||
// If the user is banned, we won't let any of their objects
|
||||
|
||||
Reference in New Issue
Block a user