Redirected all calls to CachedUserProfile methods to the inventory service. Redirection of the RootFolder property is still todo. This compiles but probably inventory will be inconsistent.

arthursv
Diva Canto 2009-08-12 20:39:48 -07:00
parent 41ad610f3e
commit 7aa54593e0
11 changed files with 614 additions and 893 deletions

View File

@ -355,6 +355,15 @@ namespace OpenSim.Framework
}
protected int m_creationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
public InventoryItemBase()
{
}
public InventoryItemBase(UUID id)
{
ID = id;
}
public object Clone()
{
return MemberwiseClone();

View File

@ -191,11 +191,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
InventoryItemBase item)
{
if (XferUploaders.ContainsKey(transactionID))
{
CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
remoteClient.AgentId);
if (userInfo != null)
{
UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId);
@ -218,14 +213,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
Manager.MyScene.AssetService.Store(asset);
}
userInfo.UpdateItem(item);
}
else
{
m_log.ErrorFormat(
"[ASSET TRANSACTIONS]: Could not find user {0} for inventory item update",
remoteClient.AgentId);
}
IInventoryService invService = Manager.MyScene.InventoryService;
invService.UpdateItem(item);
}
}
}

View File

@ -32,6 +32,7 @@ using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
{
@ -214,12 +215,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
private void DoCreateItem(uint callbackID)
{
m_userTransactions.Manager.MyScene.AssetService.Store(m_asset);
CachedUserInfo userInfo =
m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
ourClient.AgentId);
if (userInfo != null)
{
IInventoryService invService = m_userTransactions.Manager.MyScene.InventoryService;
InventoryItemBase item = new InventoryItemBase();
item.Owner = ourClient.AgentId;
item.CreatorId = ourClient.AgentId.ToString();
@ -238,15 +236,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
item.Flags = (uint) wearableType;
item.CreationDate = Util.UnixTimeSinceEpoch();
userInfo.AddItem(item);
if (invService.AddItem(item))
ourClient.SendInventoryItemCreateUpdate(item, callbackID);
}
else
{
m_log.ErrorFormat(
"[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation",
ourClient.AgentId);
}
ourClient.SendAlertMessage("Unable to create inventory item");
}
/// <summary>

View File

@ -39,6 +39,7 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Friends
{
@ -654,8 +655,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
initiator.ControllingClient.SendAgentOnline(new UUID[] { fromAgentID });
// find the folder for the friend...
InventoryFolderImpl folder =
initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard);
//InventoryFolderImpl folder =
// initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard);
IInventoryService invService = initiator.Scene.InventoryService;
InventoryFolderBase folder = invService.GetFolderForType(toAgentID, AssetType.CallingCard);
if (folder != null)
{
// ... and add the calling card

View File

@ -33,6 +33,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Gestures
{
@ -62,42 +63,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Gestures
public virtual void ActivateGesture(IClientAPI client, UUID assetId, UUID gestureId)
{
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId);
IInventoryService invService = m_scene.InventoryService;
if (userInfo != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId);
InventoryItemBase item = invService.QueryItem(new InventoryItemBase(gestureId));
if (item != null)
{
item.Flags = 1;
userInfo.UpdateItem(item);
invService.UpdateItem(item);
}
else
m_log.ErrorFormat(
"[GESTURES]: Unable to find gesture to activate {0} for {1}", gestureId, client.Name);
}
else
m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name);
m_log.WarnFormat(
"[GESTURES]: Unable to find gesture {0} to activate for {1}", gestureId, client.Name);
}
public virtual void DeactivateGesture(IClientAPI client, UUID gestureId)
{
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId);
IInventoryService invService = m_scene.InventoryService;
if (userInfo != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId);
InventoryItemBase item = invService.QueryItem(new InventoryItemBase(gestureId));
if (item != null)
{
item.Flags = 0;
userInfo.UpdateItem(item);
invService.UpdateItem(item);
}
else
m_log.ErrorFormat(
"[GESTURES]: Unable to find gesture to deactivate {0} for {1}", gestureId, client.Name);
}
else
m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name);
}
}
}

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
@ -154,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
"into agent {1}'s inventory",
folderID, new UUID(im.toAgentID));
InventoryFolderImpl folderCopy
InventoryFolderBase folderCopy
= scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero);
if (folderCopy == null)
@ -247,35 +248,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
// It will have been pushed to the client, too
//
CachedUserInfo userInfo =
scene.CommsManager.UserProfileCacheService.
GetUserDetails(client.AgentId);
//CachedUserInfo userInfo =
// scene.CommsManager.UserProfileCacheService.
// GetUserDetails(client.AgentId);
IInventoryService invService = scene.InventoryService;
if (userInfo != null)
{
InventoryFolderImpl trashFolder =
userInfo.FindFolderForType((int)AssetType.TrashFolder);
InventoryFolderBase trashFolder =
invService.GetFolderForType(client.AgentId, AssetType.TrashFolder);
UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
InventoryItemBase item = userInfo.RootFolder.FindItem(inventoryEntityID);
InventoryItemBase item = invService.QueryItem(new InventoryItemBase(inventoryEntityID));
InventoryFolderBase folder = null;
if (item != null && trashFolder != null)
{
item.Folder = trashFolder.ID;
userInfo.DeleteItem(inventoryEntityID);
// Diva comment: can't we just update this item???
invService.DeleteItem(item);
scene.AddInventoryItem(client, item);
}
else
{
folder = userInfo.RootFolder.FindFolder(inventoryEntityID);
folder = invService.QueryFolder(new InventoryFolderBase(inventoryEntityID));
if (folder != null & trashFolder != null)
{
userInfo.MoveFolder(inventoryEntityID, trashFolder.ID);
folder.ParentID = trashFolder.ID;
invService.MoveFolder(folder);
}
}
@ -293,7 +294,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
client.SendAgentAlertMessage("Unable to delete "+
"received inventory" + reason, false);
}
}
ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
@ -405,17 +405,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
return;
}
CachedUserInfo userInfo =
scene.CommsManager.UserProfileCacheService.
GetUserDetails(user.ControllingClient.AgentId);
//CachedUserInfo userInfo =
// scene.CommsManager.UserProfileCacheService.
// GetUserDetails(user.ControllingClient.AgentId);
if (userInfo == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient");
return;
}
//if (userInfo == null)
//{
// m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient");
// return;
//}
AssetType assetType = (AssetType)msg.binaryBucket[0];
IInventoryService invService = scene.InventoryService;
if (AssetType.Folder == assetType)
{
@ -425,31 +426,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
folder.ID = folderID;
folder.Owner = user.ControllingClient.AgentId;
// Fetch from database
// Fetch from service
//
if (!userInfo.QueryFolder(folder))
folder = invService.QueryFolder(folder);
if (folder == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't find folder to give");
return;
}
// Get folder info
//
InventoryFolderImpl folderInfo = userInfo.RootFolder.FindFolder(folder.ID);
if (folderInfo == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't retrieve folder to give");
return;
}
user.ControllingClient.SendBulkUpdateInventory(folder);
user.ControllingClient.SendBulkUpdateInventory(folderInfo);
// This unelegant, slow kludge is to reload the folders and
// items. Since a folder give can transfer subfolders and
// items, this is the easiest way to pull that stuff in
//
userInfo.DropInventory();
userInfo.FetchInventory();
//// This unelegant, slow kludge is to reload the folders and
//// items. Since a folder give can transfer subfolders and
//// items, this is the easiest way to pull that stuff in
////
//userInfo.DropInventory();
//userInfo.FetchInventory();
// Deliver message
//
@ -463,20 +456,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
item.ID = itemID;
item.Owner = user.ControllingClient.AgentId;
// Fetch from database
// Fetch from service
//
if (!userInfo.QueryItem(item))
{
m_log.Debug("[INVENTORY TRANSFER] Can't find item to give");
return;
}
// Get item info
//
item = userInfo.RootFolder.FindItem(item.ID);
item = invService.QueryItem(item);
if (item == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't retrieve item to give");
m_log.Debug("[INVENTORY TRANSFER] Can't find item to give");
return;
}

View File

@ -64,6 +64,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
Dictionary<AssetType, InventoryFolderBase> folders = m_Connector.GetSystemFolders(presence.UUID);
m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}",
presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count);
if (folders.Count > 0)
lock (m_InventoryCache)
m_InventoryCache.Add(presence.UUID, folders);

View File

@ -80,17 +80,12 @@ namespace OpenSim.Region.Framework.Scenes
public bool AddInventoryItemReturned(UUID AgentId, InventoryItemBase item)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(AgentId);
if (userInfo != null)
{
userInfo.AddItem(item);
if (InventoryService.AddItem(item))
return true;
}
else
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Agent was not found for add of item {1} {2}", item.Name, item.ID);
m_log.WarnFormat(
"[AGENT INVENTORY]: Unable to add item {1} to agent {2} inventory", item.Name, AgentId);
return false;
}
@ -98,13 +93,9 @@ namespace OpenSim.Region.Framework.Scenes
public void AddInventoryItem(UUID AgentID, InventoryItemBase item)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(AgentID);
if (userInfo != null)
if (InventoryService.AddItem(item))
{
userInfo.AddItem(item);
int userlevel = 0;
if (Permissions.IsGod(AgentID))
{
@ -120,8 +111,8 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Agent {1} was not found for add of item {2} {3}",
m_log.WarnFormat(
"[AGENT INVENTORY]: Agent {1} could not add item {2} {3}",
AgentID, item.Name, item.ID);
return;
@ -135,22 +126,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="item">The item. This structure contains all the item metadata, including the folder
/// in which the item is to be placed.</param>
public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
AddInventoryItem(remoteClient.AgentId, item);
remoteClient.SendInventoryItemCreateUpdate(item, 0);
}
else
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not resolve user {0} for adding an inventory item",
remoteClient.AgentId);
}
}
/// <summary>
/// Capability originating call to update the asset of an item in an agent's inventory
@ -161,12 +140,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns></returns>
public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
{
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
if (userInfo.RootFolder != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
if (item != null)
{
@ -196,13 +170,11 @@ namespace OpenSim.Region.Framework.Scenes
item.AssetID = asset.FullID;
AssetService.Store(asset);
userInfo.UpdateItem(item);
InventoryService.UpdateItem(item);
// remoteClient.SendInventoryItemCreateUpdate(item);
return (asset.FullID);
}
}
}
else
{
m_log.ErrorFormat(
@ -343,12 +315,7 @@ namespace OpenSim.Region.Framework.Scenes
public void UpdateInventoryItemAsset(IClientAPI remoteClient, UUID transactionID,
UUID itemID, InventoryItemBase itemUpd)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null && userInfo.RootFolder != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
if (item != null)
{
@ -378,7 +345,7 @@ namespace OpenSim.Region.Framework.Scenes
item.SaleType = itemUpd.SaleType;
item.Flags = itemUpd.Flags;
userInfo.UpdateItem(item);
InventoryService.UpdateItem(item);
}
else
{
@ -396,12 +363,6 @@ namespace OpenSim.Region.Framework.Scenes
"[AGENTINVENTORY]: Item ID " + itemID + " not found for an inventory item update.");
}
}
else
{
m_log.Error(
"[AGENT INVENTORY]: Agent ID " + remoteClient.AgentId + " not found for an inventory item update.");
}
}
/// <summary>
/// Give an inventory item from one user to another
@ -445,24 +406,11 @@ namespace OpenSim.Region.Framework.Scenes
public virtual InventoryItemBase GiveInventoryItem(
UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId)
{
// Retrieve the item from the sender
CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId);
Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem");
if (senderUserInfo == null)
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to find sending user {0} for item {1}", senderId, itemId);
InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemId));
return null;
}
if (senderUserInfo.RootFolder != null)
{
InventoryItemBase item = senderUserInfo.RootFolder.FindItem(itemId);
if (item != null)
if ((item != null) && (item.Owner == senderId))
{
if (!Permissions.BypassPermissions())
{
@ -470,14 +418,6 @@ namespace OpenSim.Region.Framework.Scenes
return null;
}
CachedUserInfo recipientUserInfo
= CommsManager.UserProfileCacheService.GetUserDetails(recipient);
if (recipientUserInfo != null)
{
if (!recipientUserInfo.HasReceivedInventory)
recipientUserInfo.FetchInventory();
// Insert a copy of the item into the recipient
InventoryItemBase itemCopy = new InventoryItemBase();
itemCopy.Owner = recipient;
@ -529,39 +469,22 @@ namespace OpenSim.Region.Framework.Scenes
itemCopy.SalePrice = item.SalePrice;
itemCopy.SaleType = item.SaleType;
recipientUserInfo.AddItem(itemCopy);
InventoryService.AddItem(itemCopy);
if (!Permissions.BypassPermissions())
{
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
senderUserInfo.DeleteItem(itemId);
InventoryService.DeleteItem(new InventoryItemBase(itemId));
}
return itemCopy;
}
else
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not find userinfo for recipient user {0} of item {1}, {2} from {3}",
recipient, item.Name,
item.ID, senderId);
}
}
else
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to find item {0} to give to {1}", itemId, senderId);
return null;
}
}
else
{
m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder");
m_log.WarnFormat("[AGENT INVENTORY]: Failed to find item {0} or item does not belong to giver ", itemId);
return null;
}
return null;
}
/// <summary>
@ -578,31 +501,11 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns>
/// The inventory folder copy given, null if the copy was unsuccessful
/// </returns>
public virtual InventoryFolderImpl GiveInventoryFolder(
public virtual InventoryFolderBase GiveInventoryFolder(
UUID recipientId, UUID senderId, UUID folderId, UUID recipientParentFolderId)
{
// Retrieve the folder from the sender
CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId);
if (null == senderUserInfo)
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to find sending user {0} for folder {1}", senderId, folderId);
return null;
}
if (!senderUserInfo.HasReceivedInventory)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Could not give inventory folder - have not yet received inventory for {0}",
senderId);
return null;
}
InventoryFolderImpl folder = senderUserInfo.RootFolder.FindFolder(folderId);
//// Retrieve the folder from the sender
InventoryFolderBase folder = InventoryService.QueryFolder(new InventoryFolderBase(folderId));
if (null == folder)
{
m_log.ErrorFormat(
@ -611,48 +514,37 @@ namespace OpenSim.Region.Framework.Scenes
return null;
}
CachedUserInfo recipientUserInfo
= CommsManager.UserProfileCacheService.GetUserDetails(recipientId);
if (null == recipientUserInfo)
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to find receiving user {0} for folder {1}", recipientId, folderId);
return null;
}
if (!recipientUserInfo.HasReceivedInventory)
{
recipientUserInfo.FetchInventory();
if (!WaitForInventory(recipientUserInfo))
return null;
}
if (recipientParentFolderId == UUID.Zero)
recipientParentFolderId = recipientUserInfo.RootFolder.ID;
{
InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId);
if (recipientRootFolder != null)
recipientParentFolderId = recipientRootFolder.ID;
else
{
m_log.WarnFormat("[AGENT INVENTORY]: Unable to find root folder for receiving agent");
return null;
}
}
UUID newFolderId = UUID.Random();
recipientUserInfo.CreateFolder(folder.Name, newFolderId, (ushort)folder.Type, recipientParentFolderId);
// XXX: Messy - we should really get this back in the CreateFolder call
InventoryFolderImpl copiedFolder = recipientUserInfo.RootFolder.FindFolder(newFolderId);
InventoryFolderBase newFolder = new InventoryFolderBase(newFolderId, folder.Name, recipientId, folder.Type, recipientParentFolderId, folder.Version);
InventoryService.AddFolder(newFolder);
// Give all the subfolders
List<InventoryFolderImpl> subFolders = folder.RequestListOfFolderImpls();
foreach (InventoryFolderImpl childFolder in subFolders)
InventoryCollection contents = InventoryService.GetFolderContent(senderId, folderId);
foreach (InventoryFolderBase childFolder in contents.Folders)
{
GiveInventoryFolder(recipientId, senderId, childFolder.ID, copiedFolder.ID);
GiveInventoryFolder(recipientId, senderId, childFolder.ID, newFolder.ID);
}
// Give all the items
List<InventoryItemBase> items = folder.RequestListOfItems();
foreach (InventoryItemBase item in items)
foreach (InventoryItemBase item in contents.Items)
{
GiveInventoryItem(recipientId, senderId, item.ID, copiedFolder.ID);
GiveInventoryItem(recipientId, senderId, item.ID, newFolder.ID);
}
return copiedFolder;
return newFolder;
}
public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, UUID oldAgentID, UUID oldItemID,
@ -759,18 +651,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat(
"[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId);
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo == null)
{
m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
return;
}
if (userInfo.RootFolder != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
if (item != null)
{
@ -780,20 +661,14 @@ namespace OpenSim.Region.Framework.Scenes
}
item.Folder = folderID;
userInfo.DeleteItem(item.ID);
// Diva comment: can't we just update?
InventoryService.DeleteItem(item);
AddInventoryItem(remoteClient, item);
}
else
{
m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemID.ToString());
return;
}
}
else
{
m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemID.ToString() + ", no root folder");
m_log.Warn("[AGENT INVENTORY]: Failed to find item " + itemID.ToString());
return;
}
@ -829,11 +704,6 @@ namespace OpenSim.Region.Framework.Scenes
private void CreateNewInventoryItem(
IClientAPI remoteClient, string creatorID, UUID folderID, string name, uint flags, uint callbackID, AssetBase asset, sbyte invType,
uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
InventoryItemBase item = new InventoryItemBase();
item.Owner = remoteClient.AgentId;
@ -853,14 +723,14 @@ namespace OpenSim.Region.Framework.Scenes
item.BasePermissions = baseMask;
item.CreationDate = creationDate;
userInfo.AddItem(item);
if (InventoryService.AddItem(item))
remoteClient.SendInventoryItemCreateUpdate(item, callbackID);
}
else
{
m_dialogModule.SendAlertToUser(remoteClient, "Failed to create item");
m_log.WarnFormat(
"No user details associated with client {0} uuid {1} in CreateNewInventoryItem!",
remoteClient.Name, remoteClient.AgentId);
"Failed to add item for {0} in CreateNewInventoryItem!",
remoteClient.Name);
}
}
@ -941,19 +811,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="itemID"></param>
private void RemoveInventoryItem(IClientAPI remoteClient, UUID itemID)
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo == null)
{
m_log.WarnFormat(
"[AGENT INVENTORY]: Failed to find user {0} {1} to delete inventory item {2}",
remoteClient.Name, remoteClient.AgentId, itemID);
return;
}
userInfo.DeleteItem(itemID);
InventoryService.DeleteItem(new InventoryItemBase(itemID));
}
/// <summary>
@ -1332,19 +1190,12 @@ namespace OpenSim.Region.Framework.Scenes
public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items)
{
CachedUserInfo profile = CommsManager.UserProfileCacheService.GetUserDetails(destID);
if (profile == null || profile.RootFolder == null)
{
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Avatar {0} cannot be found to add items",
destID);
return UUID.Zero;
}
InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID);
UUID newFolderID = UUID.Random();
profile.CreateFolder(category, newFolderID, 0xffff, profile.RootFolder.ID);
InventoryFolderBase newFolder = new InventoryFolderBase(newFolderID, category, destID, 0xff, rootFolder.ID, rootFolder.Version);
InventoryService.AddFolder(newFolder);
foreach (UUID itemID in items)
{
@ -1358,19 +1209,27 @@ namespace OpenSim.Region.Framework.Scenes
}
}
ScenePresence avatar;
ScenePresence avatar = null;
if (TryGetAvatar(destID, out avatar))
{
profile.SendInventoryDecendents(avatar.ControllingClient,
profile.RootFolder.ID, true, false);
profile.SendInventoryDecendents(avatar.ControllingClient,
newFolderID, false, true);
//profile.SendInventoryDecendents(avatar.ControllingClient,
// profile.RootFolder.ID, true, false);
//profile.SendInventoryDecendents(avatar.ControllingClient,
// newFolderID, false, true);
SendInventoryUpdate(avatar.ControllingClient, rootFolder, true, false);
SendInventoryUpdate(avatar.ControllingClient, newFolder, false, true);
}
return newFolderID;
}
private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems)
{
InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID);
client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, fetchFolders, fetchItems);
}
/// <summary>
/// Update an item in a prim (task) inventory.
/// This method does not handle scripts, <see>RezScript(IClientAPI, UUID, unit)</see>
@ -1848,7 +1707,7 @@ namespace OpenSim.Region.Framework.Scenes
// Get the user info of the item destination
//
CachedUserInfo userInfo;
UUID userID = UUID.Zero;
if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
action == DeRezAction.SaveToExistingUserInventoryItem)
@ -1859,30 +1718,21 @@ namespace OpenSim.Region.Framework.Scenes
if (remoteClient == null)
return UUID.Zero;
userInfo = CommsManager.UserProfileCacheService.GetUserDetails(
remoteClient.AgentId);
userID = remoteClient.AgentId;
}
else
{
// All returns / deletes go to the object owner
//
userInfo = CommsManager.UserProfileCacheService.GetUserDetails(
objectGroup.RootPart.OwnerID);
userID = objectGroup.RootPart.OwnerID;
}
if (userInfo == null) // Can't proceed
if (userID == UUID.Zero) // Can't proceed
{
return UUID.Zero;
}
if (!userInfo.HasReceivedInventory)
{
// Async inventory requests will queue, but they will never
// execute unless inventory is actually fetched
//
userInfo.FetchInventory();
}
// 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
@ -1894,8 +1744,11 @@ namespace OpenSim.Region.Framework.Scenes
if (DeRezAction.SaveToExistingUserInventoryItem == action)
{
item = userInfo.RootFolder.FindItem(
objectGroup.RootPart.FromUserInventoryItemID);
item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID);
item = InventoryService.QueryItem(item);
//item = userInfo.RootFolder.FindItem(
// objectGroup.RootPart.FromUserInventoryItemID);
if (null == item)
{
@ -1920,53 +1773,36 @@ namespace OpenSim.Region.Framework.Scenes
// have to wait for the inventory to find
// the destination folder
//
if (!WaitForInventory(userInfo))
return UUID.Zero;
folder = userInfo.FindFolderForType(
(int)AssetType.LostAndFoundFolder);
folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
else
{
// Assume inventory skeleton was loaded during login
// and all folders can be found
//
folder = userInfo.FindFolderForType(
(int)AssetType.TrashFolder);
folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
}
}
else if (action == DeRezAction.Return)
{
// Wait if needed
//
if (!userInfo.HasReceivedInventory)
{
if (!WaitForInventory(userInfo))
return UUID.Zero;
}
// Dump to lost + found unconditionally
//
folder = userInfo.FindFolderForType(
(int)AssetType.LostAndFoundFolder);
folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
if (folderID == UUID.Zero && folder == null)
{
// Catch all. Use lost & found
//
if (!userInfo.HasReceivedInventory)
{
if (!WaitForInventory(userInfo))
return UUID.Zero;
}
folder = userInfo.FindFolderForType(
(int)AssetType.LostAndFoundFolder);
folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
}
if (folder == null) // None of the above
{
folder = userInfo.RootFolder.FindFolder(folderID);
//folder = userInfo.RootFolder.FindFolder(folderID);
folder = new InventoryFolderBase(folderID);
if (folder == null) // Nowhere to put it
{
@ -1979,7 +1815,7 @@ namespace OpenSim.Region.Framework.Scenes
item.ID = UUID.Random();
item.InvType = (int)InventoryType.Object;
item.Folder = folder.ID;
item.Owner = userInfo.UserProfile.ID;
item.Owner = userID;
}
AssetBase asset = CreateAsset(
@ -1993,7 +1829,7 @@ namespace OpenSim.Region.Framework.Scenes
if (DeRezAction.SaveToExistingUserInventoryItem == action)
{
item.AssetID = asset.FullID;
userInfo.UpdateItem(item);
InventoryService.UpdateItem(item);
}
else
{
@ -2034,7 +1870,7 @@ namespace OpenSim.Region.Framework.Scenes
item.Name = asset.Name;
item.AssetType = asset.Type;
userInfo.AddItem(item);
InventoryService.AddItem(item);
if (remoteClient != null && item.Owner == remoteClient.AgentId)
{
@ -2053,7 +1889,7 @@ namespace OpenSim.Region.Framework.Scenes
return assetID;
}
public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, UUID assetID, UUID agentID)
public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
{
SceneObjectGroup objectGroup = grp;
if (objectGroup != null)
@ -2070,43 +1906,9 @@ namespace OpenSim.Region.Framework.Scenes
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
CachedUserInfo userInfo =
CommsManager.UserProfileCacheService.GetUserDetails(agentID);
if (userInfo != null && userInfo.RootFolder != null)
{
Queue<InventoryFolderImpl> searchfolders = new Queue<InventoryFolderImpl>();
searchfolders.Enqueue(userInfo.RootFolder);
InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
UUID foundFolder = UUID.Zero;
InventoryItemBase item = null;
// search through folders to find the asset.
while (searchfolders.Count > 0)
{
InventoryFolderImpl fld = searchfolders.Dequeue();
lock (fld)
{
if (fld != null)
{
if (fld.Items.ContainsKey(assetID))
{
item = fld.Items[assetID];
foundFolder = fld.ID;
searchfolders.Clear();
break;
}
else
{
foreach (InventoryFolderImpl subfld in fld.RequestListOfFolderImpls())
{
searchfolders.Enqueue(subfld);
}
}
}
}
}
if (foundFolder != UUID.Zero && item != null)
if (item != null)
{
AssetBase asset = CreateAsset(
objectGroup.GetPartName(objectGroup.LocalId),
@ -2120,9 +1922,8 @@ namespace OpenSim.Region.Framework.Scenes
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
item.Folder = foundFolder;
userInfo.UpdateItem(item);
InventoryService.UpdateItem(item);
// this gets called when the agent loggs off!
if (remoteClient != null)
@ -2132,7 +1933,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
}
public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
{
@ -2141,11 +1941,6 @@ namespace OpenSim.Region.Framework.Scenes
{
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
CachedUserInfo userInfo =
CommsManager.UserProfileCacheService.GetUserDetails(AgentId);
if (userInfo != null)
{
AssetBase asset = CreateAsset(
grp.GetPartName(grp.LocalId),
grp.GetPartDescription(grp.LocalId),
@ -2186,16 +1981,16 @@ namespace OpenSim.Region.Framework.Scenes
// sets assetID so client can show asset as 'attached' in inventory
grp.SetFromAssetID(item.ID);
userInfo.AddItem(item);
if (InventoryService.AddItem(item))
remoteClient.SendInventoryItemCreateUpdate(item, 0);
else
m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
itemID = item.ID;
return item.AssetID;
}
return UUID.Zero;
}
return UUID.Zero;
}
/// <summary>
/// Event Handler Rez an object into a scene
@ -2261,17 +2056,7 @@ namespace OpenSim.Region.Framework.Scenes
BypassRayCast, bRayEndIsIntersection,true,scale, false);
// Rez object
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
// Do NOT use HasReceivedInventory here, this is called
// from within ItemReceive during login for attachments.
// Using HasReceivedInventory here will break attachment
// persistence!
//
if (userInfo.RootFolder != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
InventoryItemBase item = InventoryService.QueryItem(new InventoryItemBase(itemID));
if (item != null)
{
@ -2422,19 +2207,13 @@ namespace OpenSim.Region.Framework.Scenes
// copy ones will be lost, so avoid it
//
if (!attachment)
userInfo.DeleteItem(item.ID);
InventoryService.DeleteItem(item);
}
}
return rootPart.ParentGroup;
}
}
}
else
m_log.WarnFormat("[AGENT INVENTORY]: Root folder not found in {0}", RegionInfo.RegionName);
}
else
m_log.WarnFormat("[AGENT INVENTORY]: User profile not found in {0}", RegionInfo.RegionName);
return null;
}
@ -2681,14 +2460,10 @@ namespace OpenSim.Region.Framework.Scenes
ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
}
part.ParentGroup.DetachToGround();
CachedUserInfo userInfo =
CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
userInfo.DeleteItem(inventoryID);
InventoryService.DeleteItem(new InventoryItemBase(inventoryID));
remoteClient.SendRemoveInventoryItem(inventoryID);
}
}
SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
}

View File

@ -435,17 +435,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
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;
}
userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems);
SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems);
}
/// <summary>
@ -543,19 +533,10 @@ namespace OpenSim.Region.Framework.Scenes
public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType,
string folderName, UUID parentID)
{
CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (null == userProfile)
InventoryFolderBase folder = new InventoryFolderBase(folderID, folderName, remoteClient.AgentId, (short)folderType, parentID, 1);
if (!InventoryService.AddFolder(folder))
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
remoteClient.Name, remoteClient.AgentId);
return;
}
if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID))
{
m_log.ErrorFormat(
m_log.WarnFormat(
"[AGENT INVENTORY]: Failed to move create folder for user {0} {1}",
remoteClient.Name, remoteClient.AgentId);
}

View File

@ -3510,11 +3510,6 @@ namespace OpenSim.Region.Framework.Scenes
case 2: // Sell a copy
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
CachedUserInfo userInfo =
CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
uint perms=group.GetEffectivePermissions();
if ((perms & (uint)PermissionMask.Transfer) == 0)
@ -3560,9 +3555,8 @@ namespace OpenSim.Region.Framework.Scenes
item.CurrentPermissions |= 8; // Slam!
item.CreationDate = Util.UnixTimeSinceEpoch();
userInfo.AddItem(item);
if (InventoryService.AddItem(item))
remoteClient.SendInventoryItemCreateUpdate(item, 0);
}
else
{
m_dialogModule.SendAlertToUser(remoteClient, "Cannot buy now. Your inventory is unavailable");
@ -3577,8 +3571,8 @@ namespace OpenSim.Region.Framework.Scenes
foreach (UUID invID in invList)
{
TaskInventoryItem item = part.Inventory.GetInventoryItem(invID);
if ((item.CurrentPermissions &
TaskInventoryItem item1 = part.Inventory.GetInventoryItem(invID);
if ((item1.CurrentPermissions &
(uint)PermissionMask.Transfer) == 0)
{
okToSell = false;

View File

@ -542,7 +542,7 @@ namespace OpenSim.Region.Framework.Scenes
group.DetachToInventoryPrep();
m_log.Debug("[DETACH]: Saving attachpoint: " +
((uint)group.GetAttachmentPoint()).ToString());
m_parentScene.updateKnownAsset(remoteClient, group,
m_parentScene.UpdateKnownItem(remoteClient, group,
group.GetFromAssetID(), group.OwnerID);
m_parentScene.DeleteSceneObject(group, false);
return;
@ -1307,7 +1307,7 @@ namespace OpenSim.Region.Framework.Scenes
group.UpdateGroupPosition(pos);
group.RootPart.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos;
m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(), group.OwnerID);
m_parentScene.UpdateKnownItem(remoteClient, group, group.GetFromAssetID(), group.OwnerID);
group.SetAttachmentPoint(attachmentPoint);
}