Inventory redirects from CachedUserInfo to InventoryService COMPLETE!

arthursv
Diva Canto 2009-08-13 11:30:29 -07:00
parent 6a0f7c2275
commit 6b9cc6c48d
10 changed files with 144 additions and 388 deletions

View File

@ -6609,20 +6609,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
} }
else // Agent else // Agent
{ {
CachedUserInfo userInfo = ((Scene)m_scene).CommsManager.UserProfileCacheService.GetUserDetails(AgentId); //InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(itemID);
if (userInfo == null) IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
{ InventoryItemBase assetRequestItem = invService.QueryItem(new InventoryItemBase(itemID));
m_log.ErrorFormat(
"[CLIENT]: Could not resolve user {0} for caps inventory update",
AgentId);
break;
}
if (userInfo.RootFolder == null)
break;
InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(itemID);
if (assetRequestItem == null) if (assetRequestItem == null)
{ {
assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);

View File

@ -37,6 +37,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using BlockingQueue = OpenSim.Framework.BlockingQueue<OpenSim.Region.Framework.Interfaces.ITextureSender>; using BlockingQueue = OpenSim.Framework.BlockingQueue<OpenSim.Region.Framework.Interfaces.ITextureSender>;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Agent.TextureDownload namespace OpenSim.Region.CoreModules.Agent.TextureDownload
{ {
@ -217,7 +218,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureDownload
if (profile == null) // Deny unknown user if (profile == null) // Deny unknown user
return; return;
if (profile.RootFolder == null) // Deny no inventory IInventoryService invService = scene.InventoryService;
if (invService.GetRootFolder(client.AgentId) == null) // Deny no inventory
return; return;
if (profile.UserProfile.GodLevel < 200 && profile.RootFolder.FindAsset(e.RequestedAssetID) == null) // Deny if not owned if (profile.UserProfile.GodLevel < 200 && profile.RootFolder.FindAsset(e.RequestedAssetID) == null) // Deny if not owned

View File

@ -34,6 +34,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{ {
@ -115,9 +116,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
} }
public void SetAppearanceAssets(CachedUserInfo profile, ref AvatarAppearance appearance) public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
{ {
if (profile.RootFolder != null) IInventoryService invService = m_scene.InventoryService;
if (invService.GetRootFolder(userID) != null)
{ {
for (int i = 0; i < 13; i++) for (int i = 0; i < 13; i++)
{ {
@ -127,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
} }
else else
{ {
InventoryItemBase baseItem = profile.RootFolder.FindItem(appearance.Wearables[i].ItemID); InventoryItemBase baseItem = invService.QueryItem(new InventoryItemBase(appearance.Wearables[i].ItemID));
if (baseItem != null) if (baseItem != null)
{ {
@ -143,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
} }
else else
{ {
m_log.Error("[APPEARANCE]: you have no inventory, appearance stuff isn't going to work"); m_log.WarnFormat("[APPEARANCE]: user {0} has no inventory, appearance isn't going to work", userID);
} }
} }
@ -163,8 +166,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return; return;
} }
CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId);
AvatarAppearance avatAppearance = null; AvatarAppearance avatAppearance = null;
if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance))
{ {
@ -174,34 +175,18 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
//m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name);
if (profile != null) foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
{ {
if (profile.RootFolder != null) if (wear.Type < 13)
{ {
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
{ }
if (wear.Type < 13) }
{
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; SetAppearanceAssets(avatar.UUID, ref avatAppearance);
}
}
SetAppearanceAssets(profile, ref avatAppearance);
m_scene.CommsManager.AvatarService.UpdateUserAppearance(clientView.AgentId, avatAppearance); m_scene.CommsManager.AvatarService.UpdateUserAppearance(clientView.AgentId, avatAppearance);
avatar.Appearance = avatAppearance; avatar.Appearance = avatAppearance;
}
else
{
m_log.WarnFormat(
"[APPEARANCE]: Inventory has not yet been received for {0}, cannot set wearables",
clientView.Name);
}
}
else
{
m_log.WarnFormat("[APPEARANCE]: Cannot set wearables for {0}, no user profile found", clientView.Name);
}
} }
public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
// Temporary fix of wrong GroupPowers constants in OpenMetaverse library // Temporary fix of wrong GroupPowers constants in OpenMetaverse library
enum GroupPowers : long enum GroupPowers : long
@ -964,19 +965,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (objectID == UUID.Zero) // User inventory if (objectID == UUID.Zero) // User inventory
{ {
CachedUserInfo userInfo = IInventoryService invService = m_scene.InventoryService;
scene.CommsManager.UserProfileCacheService.GetUserDetails(user); InventoryItemBase assetRequestItem = invService.QueryItem(new InventoryItemBase(notecard));
if (userInfo == null)
{
m_log.ErrorFormat("[PERMISSIONS]: Could not find user {0} for edit notecard check", user);
return false;
}
if (userInfo.RootFolder == null)
return false;
InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(notecard);
if (assetRequestItem == null) // Library item if (assetRequestItem == null) // Library item
{ {
assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard);
@ -1394,19 +1384,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (objectID == UUID.Zero) // User inventory if (objectID == UUID.Zero) // User inventory
{ {
CachedUserInfo userInfo = IInventoryService invService = m_scene.InventoryService;
scene.CommsManager.UserProfileCacheService.GetUserDetails(user); InventoryItemBase assetRequestItem = invService.QueryItem(new InventoryItemBase(script));
if (userInfo == null)
{
m_log.ErrorFormat("[PERMISSIONS]: Could not find user {0} for administrator check", user);
return false;
}
if (userInfo.RootFolder == null)
return false;
InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(script);
if (assetRequestItem == null) // Library item if (assetRequestItem == null) // Library item
{ {
assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script);
@ -1499,19 +1478,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
if (objectID == UUID.Zero) // User inventory if (objectID == UUID.Zero) // User inventory
{ {
CachedUserInfo userInfo = IInventoryService invService = m_scene.InventoryService;
scene.CommsManager.UserProfileCacheService.GetUserDetails(user); InventoryItemBase assetRequestItem = invService.QueryItem(new InventoryItemBase(notecard));
if (userInfo == null)
{
m_log.ErrorFormat("[PERMISSIONS]: Could not find user {0} for view notecard check", user);
return false;
}
if (userInfo.RootFolder == null)
return false;
InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(notecard);
if (assetRequestItem == null) // Library item if (assetRequestItem == null) // Library item
{ {
assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard);

View File

@ -201,31 +201,31 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
} }
} }
public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
{ //{
InventoryClient invCli = null; // InventoryClient invCli = null;
string inventoryURL = UserInventoryURL(item.Owner); // string inventoryURL = UserInventoryURL(item.Owner);
if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli)) // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
{ // {
m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL); // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
invCli = new InventoryClient(inventoryURL); // invCli = new InventoryClient(inventoryURL);
m_inventoryServers.Add(inventoryURL, invCli); // m_inventoryServers.Add(inventoryURL, invCli);
} // }
item = invCli.GetInventoryItem(item); // item = invCli.GetInventoryItem(item);
if (item != null) // if (item != null)
{ // {
// Change the folder, stick it in root folder, all items flattened out here in this region cache // // Change the folder, stick it in root folder, all items flattened out here in this region cache
item.Folder = rootFolder; // item.Folder = rootFolder;
//userInfo.AddItem(item); don't use this, it calls back to the inventory server // //userInfo.AddItem(item); don't use this, it calls back to the inventory server
lock (userInfo.RootFolder.Items) // lock (userInfo.RootFolder.Items)
{ // {
userInfo.RootFolder.Items[item.ID] = item; // userInfo.RootFolder.Items[item.ID] = item;
} // }
} // }
return item; // return item;
} //}
public void Post(UUID assetID, UUID ownerID) public void Post(UUID assetID, UUID ownerID)
{ {

View File

@ -117,25 +117,20 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (fromTaskID.Equals(UUID.Zero)) if (fromTaskID.Equals(UUID.Zero))
{ {
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); InventoryItemBase item = new InventoryItemBase(itemID);
if (userInfo != null) item.Owner = remoteClient.AgentId;
item = InventoryService.QueryItem(item);
//if (item == null)
//{ // Fetch the item
// item = new InventoryItemBase();
// item.Owner = remoteClient.AgentId;
// item.ID = itemID;
// item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
//}
if (item != null)
{ {
if (userInfo.RootFolder != null) m_assMapper.Get(item.AssetID, remoteClient.AgentId);
{
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);
}
}
} }
} }

View File

@ -558,24 +558,9 @@ namespace OpenSim.Region.Framework.Scenes
if (item == null) if (item == null)
{ {
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID); item = InventoryService.QueryItem(new InventoryItemBase(oldItemID));
if (userInfo == null)
{
m_log.Error("[AGENT INVENTORY]: Failed to find user " + oldAgentID.ToString());
return;
}
if (userInfo.RootFolder != null) if (item == null)
{
item = userInfo.RootFolder.FindItem(oldItemID);
if (item == null)
{
m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
return;
}
}
else
{ {
m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString()); m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
return; return;
@ -822,28 +807,15 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="folderID"></param> /// <param name="folderID"></param>
private void RemoveInventoryFolder(IClientAPI remoteClient, UUID folderID) private void RemoveInventoryFolder(IClientAPI remoteClient, UUID folderID)
{ {
CachedUserInfo userInfo // Unclear is this handler is ever called by the Linden client, but it might
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo == null) InventoryFolderBase folder = new InventoryFolderBase(folderID);
folder.Owner = remoteClient.AgentId;
InventoryFolderBase trash = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.TrashFolder);
if (trash != null)
{ {
m_log.Warn("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString()); folder.ParentID = trash.ID;
return; InventoryService.MoveFolder(folder);
}
if (userInfo.RootFolder != null)
{
InventoryItemBase folder = userInfo.RootFolder.FindItem(folderID);
if (folder != null)
{
m_log.WarnFormat(
"[AGENT INVENTORY]: Remove folder not implemented in request by {0} {1} for {2}",
remoteClient.Name, remoteClient.AgentId, folderID);
// doesn't work just yet, commented out. will fix in next patch.
// userInfo.DeleteItem(folder);
}
} }
} }
@ -1060,20 +1032,7 @@ namespace OpenSim.Region.Framework.Scenes
return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId); return MoveTaskInventoryItem(avatar.ControllingClient, folderId, part, itemId);
} }
else else
{ {
CachedUserInfo profile = CommsManager.UserProfileCacheService.GetUserDetails(avatarId);
if (profile == null || profile.RootFolder == null)
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Avatar {0} cannot be found to add item",
avatarId);
return null;
}
if (!profile.HasReceivedInventory)
profile.FetchInventory();
InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId); InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(avatarId, part, itemId);
if (agentItem == null) if (agentItem == null)
@ -1265,39 +1224,33 @@ namespace OpenSim.Region.Framework.Scenes
UUID copyID = UUID.Random(); UUID copyID = UUID.Random();
if (itemID != UUID.Zero) if (itemID != UUID.Zero)
{ {
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
if (userInfo != null && userInfo.RootFolder != null) // Try library
if (null == item)
{ {
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
}
// Try library if (item != null)
// XXX clumsy, possibly should be one call {
if (null == item) part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID);
m_log.InfoFormat(
"[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
item.Name, primLocalID, remoteClient.Name);
part.GetProperties(remoteClient);
if (!Permissions.BypassPermissions())
{ {
item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
} RemoveInventoryItem(remoteClient, itemID);
if (item != null)
{
part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID);
m_log.InfoFormat(
"[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
item.Name, primLocalID, remoteClient.Name);
part.GetProperties(remoteClient);
if (!Permissions.BypassPermissions())
{
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
RemoveInventoryItem(remoteClient, itemID);
}
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
itemID, remoteClient.Name);
} }
} }
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
itemID, remoteClient.Name);
}
} }
} }
else // Updating existing item with new perms etc else // Updating existing item with new perms etc
@ -1334,53 +1287,48 @@ namespace OpenSim.Region.Framework.Scenes
if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory
{ {
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
if (userInfo != null && userInfo.RootFolder != null) // Try library
// XXX clumsy, possibly should be one call
if (null == item)
{ {
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID);
}
// Try library if (item != null)
// XXX clumsy, possibly should be one call {
if (null == item) SceneObjectPart part = GetSceneObjectPart(localID);
if (part != null)
{ {
item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
} return;
if (item != null) part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
{ // TODO: switch to posting on_rez here when scripts
SceneObjectPart part = GetSceneObjectPart(localID); // have state in inventory
if (part != null) part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0);
{
if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
return;
part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); // m_log.InfoFormat("[PRIMINVENTORY]: " +
// TODO: switch to posting on_rez here when scripts // "Rezzed script {0} into prim local ID {1} for user {2}",
// have state in inventory // item.inventoryName, localID, remoteClient.Name);
part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); part.GetProperties(remoteClient);
// m_log.InfoFormat("[PRIMINVENTORY]: " +
// "Rezzed script {0} into prim local ID {1} for user {2}",
// item.inventoryName, localID, remoteClient.Name);
part.GetProperties(remoteClient);
}
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Could not rez script {0} into prim local ID {1} for user {2}"
+ " because the prim could not be found in the region!",
item.Name, localID, remoteClient.Name);
}
} }
else else
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!", "[PRIM INVENTORY]: " +
itemID, remoteClient.Name); "Could not rez script {0} into prim local ID {1} for user {2}"
+ " because the prim could not be found in the region!",
item.Name, localID, remoteClient.Name);
} }
} }
else
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!",
itemID, remoteClient.Name);
}
} }
else // script has been rezzed directly into a prim's inventory else // script has been rezzed directly into a prim's inventory
{ {
@ -1670,26 +1618,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
private bool WaitForInventory(CachedUserInfo info)
{
// 200 Seconds wait. This is called in the context of the
// background delete thread, so we can afford to waste time
// here.
//
int count = 200;
while (count > 0)
{
System.Threading.Thread.Sleep(100);
count--;
if (info.HasReceivedInventory)
return true;
}
m_log.DebugFormat("Timed out waiting for inventory of user {0}",
info.UserProfile.ID.ToString());
return false;
}
/// <summary> /// <summary>
/// Delete a scene object from a scene and place in the given avatar's inventory. /// Delete a scene object from a scene and place in the given avatar's inventory.
/// Returns the UUID of the newly created asset. /// Returns the UUID of the newly created asset.

View File

@ -382,31 +382,13 @@ namespace OpenSim.Region.Framework.Scenes
return; return;
} }
CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
if (null == userProfile) if (item != null)
{ {
m_log.ErrorFormat( remoteClient.SendInventoryItemDetails(ownerID, item);
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
remoteClient.Name, remoteClient.AgentId);
return;
}
if (userProfile.HasReceivedInventory)
{
InventoryItemBase item = null;
if (userProfile.RootFolder == null)
m_log.ErrorFormat(
"[AGENT INVENTORY]: User {0} {1} does not have a root folder.",
remoteClient.Name, remoteClient.AgentId);
else
item = userProfile.RootFolder.FindItem(itemID);
if (item != null)
{
remoteClient.SendInventoryItemDetails(ownerID, item);
}
} }
// else shouldn't we send an alert message?
} }
/// <summary> /// <summary>
@ -442,6 +424,7 @@ namespace OpenSim.Region.Framework.Scenes
/// Handle the caps inventory descendents fetch. /// Handle the caps inventory descendents fetch.
/// ///
/// Since the folder structure is sent to the client on login, I believe we only need to handle items. /// Since the folder structure is sent to the client on login, I believe we only need to handle items.
/// Diva comment 8/13/2009: what if someone gave us a folder in the meantime??
/// </summary> /// </summary>
/// <param name="agentID"></param> /// <param name="agentID"></param>
/// <param name="folderID"></param> /// <param name="folderID"></param>
@ -467,59 +450,10 @@ namespace OpenSim.Region.Framework.Scenes
{ {
return fold.RequestListOfItems(); return fold.RequestListOfItems();
} }
CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(agentID);
if (null == userProfile)
{
m_log.ErrorFormat("[AGENT INVENTORY]: Could not find user profile for {0}", agentID);
return null;
}
// XXX: When a client crosses into a scene, their entire inventory is fetched InventoryCollection contents = InventoryService.GetFolderContent(agentID, folderID);
// asynchronously. If the client makes a request before the inventory is received, we need return contents.Items;
// to give the inventory a chance to come in.
//
// This is a crude way of dealing with that by retrying the lookup. It's not quite as bad
// in CAPS as doing this with the udp request, since here it won't hold up other packets.
// In fact, here we'll be generous and try for longer.
if (!userProfile.HasReceivedInventory)
{
int attempts = 0;
while (attempts++ < 30)
{
m_log.DebugFormat(
"[INVENTORY CACHE]: Poll number {0} for inventory items in folder {1} for user {2}",
attempts, folderID, agentID);
Thread.Sleep(2000);
if (userProfile.HasReceivedInventory)
{
break;
}
}
}
if (userProfile.HasReceivedInventory)
{
if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
{
return fold.RequestListOfItems();
}
else
{
m_log.WarnFormat(
"[AGENT INVENTORY]: Could not find folder {0} requested by user {1}",
folderID, agentID);
return null;
}
}
else
{
m_log.ErrorFormat("[INVENTORY CACHE]: Could not find root folder for user {0}", agentID);
return null;
}
} }
/// <summary> /// <summary>
@ -579,33 +513,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Handle an inventory folder move request from the client.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="folderID"></param>
/// <param name="parentID"></param>
public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID) public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID)
{
CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (null == userProfile)
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
remoteClient.Name, remoteClient.AgentId);
return;
}
if (!userProfile.MoveFolder(folderID, parentID))
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to move folder {0} to {1} for user {2}",
folderID, parentID, remoteClient.Name);
}
}
public void HandleMoveInventoryFolder2(IClientAPI remoteClient, UUID folderID, UUID parentID)
{ {
InventoryFolderBase folder = new InventoryFolderBase(folderID); InventoryFolderBase folder = new InventoryFolderBase(folderID);
folder = InventoryService.QueryFolder(folder); folder = InventoryService.QueryFolder(folder);
@ -628,27 +536,8 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="folderID"></param> /// <param name="folderID"></param>
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID) public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
{
CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (null == userProfile)
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
remoteClient.Name, remoteClient.AgentId);
return;
}
if (!userProfile.PurgeFolder(folderID))
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to purge folder for user {0} {1}",
remoteClient.Name, remoteClient.AgentId);
}
}
public void HandlePurgeInventoryDescendents2(IClientAPI remoteClient, UUID folderID)
{ {
InventoryFolderBase folder = new InventoryFolderBase(folderID); InventoryFolderBase folder = new InventoryFolderBase(folderID);

View File

@ -1249,11 +1249,11 @@ namespace OpenSim.Region.Framework.Scenes
} }
else // Not successful else // Not successful
{ {
CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID); //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
if (userInfo != null) //if (userInfo != null)
{ //{
userInfo.FetchInventory(); // userInfo.FetchInventory();
} //}
agent.RestoreInCurrentScene(); agent.RestoreInCurrentScene();
} }
// In any case // In any case

View File

@ -833,11 +833,11 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.SwapRootAgentCount(false); m_scene.SwapRootAgentCount(false);
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); //CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid);
if (userInfo != null) //if (userInfo != null)
userInfo.FetchInventory(); // userInfo.FetchInventory();
else //else
m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); // m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid);
// On the next prim update, all objects will be sent // On the next prim update, all objects will be sent
// //