From 38ca31b37a6ac8fe74b77e4488112eb77d612827 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 4 Dec 2008 19:57:36 +0000
Subject: * Put in the code necessary to allow inventory transfer of whole
folders (and their contents) between agents, not just single items * However,
this is not currently activated since it's not absolutely fully tested and
there's a bug lurking in there to do with the sending of the
BulkInventoryUpdate packets
---
.../Region/Environment/Scenes/Scene.Inventory.cs | 119 ++++++++++++++++++++-
.../Region/Environment/Scenes/Tests/TestClient.cs | 5 +-
2 files changed, 119 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index d1e0c24..3d6a905 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -400,11 +400,11 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- /// Give an inventory item from one avatar to another
+ /// Give an inventory item from one user to another
///
///
/// ID of the sender of the item
- ///
+ ///
public virtual void GiveInventoryItem(IClientAPI recipientClient, UUID senderId, UUID itemId)
{
InventoryItemBase itemCopy = GiveInventoryItem(recipientClient.AgentId, senderId, itemId);
@@ -413,8 +413,34 @@ namespace OpenSim.Region.Environment.Scenes
recipientClient.SendBulkUpdateInventory(itemCopy);
}
+ ///
+ /// Give an inventory item from one user to another
+ ///
+ ///
+ /// ID of the sender of the item
+ ///
+ /// The inventory item copy given, null if the give was unsuccessful
public virtual InventoryItemBase GiveInventoryItem(UUID recipient, UUID senderId, UUID itemId)
{
+ return GiveInventoryItem(recipient, senderId, itemId, UUID.Zero);
+ }
+
+ ///
+ /// Give an inventory item from one user to another
+ ///
+ ///
+ /// ID of the sender of the item
+ ///
+ ///
+ /// The id of the folder in which the copy item should go. If UUID.Zero then the item is placed in the most
+ /// appropriate default folder.
+ ///
+ ///
+ /// The inventory item copy given, null if the give was unsuccessful
+ ///
+ public virtual InventoryItemBase GiveInventoryItem(
+ UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId)
+ {
// Retrieve the item from the sender
CachedUserInfo senderUserInfo = CommsManager.UserProfileCacheService.GetUserDetails(senderId);
@@ -438,7 +464,6 @@ namespace OpenSim.Region.Environment.Scenes
return null;
}
- // TODO get recipient's root folder
CachedUserInfo recipientUserInfo
= CommsManager.UserProfileCacheService.GetUserDetails(recipient);
@@ -457,7 +482,8 @@ namespace OpenSim.Region.Environment.Scenes
itemCopy.Name = item.Name;
itemCopy.AssetType = item.AssetType;
itemCopy.InvType = item.InvType;
- itemCopy.Folder = UUID.Zero;
+ itemCopy.Folder = recipientFolderId;
+
if (Permissions.PropagatePermissions())
{
if (item.InvType == 6)
@@ -529,8 +555,93 @@ namespace OpenSim.Region.Environment.Scenes
m_log.Error("[AGENT INVENTORY]: Failed to find item " + itemId.ToString() + ", no root folder");
return null;
}
+
return null;
}
+
+ ///
+ /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
+ /// folders) is given.
+ ///
+ ///
+ /// ID of the sender of the item
+ ///
+ ///
+ /// The id of the receipient folder in which the send folder should be placed. If UUID.Zero then the
+ /// recipient folder is the root folder
+ ///
+ ///
+ /// The inventory folder copy given, null if the copy was unsuccessful
+ ///
+ public virtual InventoryFolderImpl 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);
+
+ if (null == folder)
+ {
+ m_log.ErrorFormat(
+ "[AGENT INVENTORY]: Could not find inventory folder {0} to give", folderId);
+
+ 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 (recipientParentFolderId == UUID.Zero)
+ recipientParentFolderId = recipientUserInfo.RootFolder.ID;
+
+ 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);
+
+ // Give all the subfolders
+ List subFolders = folder.RequestListOfFolderImpls();
+ foreach (InventoryFolderImpl childFolder in subFolders)
+ {
+ GiveInventoryFolder(recipientId, senderId, childFolder.ID, copiedFolder.ID);
+ }
+
+ // Give all the items
+ List items = folder.RequestListOfItems();
+ foreach (InventoryItemBase item in items)
+ {
+ GiveInventoryItem(recipientId, senderId, item.ID, copiedFolder.ID);
+ }
+
+ return copiedFolder;
+ }
public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, UUID oldAgentID, UUID oldItemID,
UUID newFolderID, string newName)
diff --git a/OpenSim/Region/Environment/Scenes/Tests/TestClient.cs b/OpenSim/Region/Environment/Scenes/Tests/TestClient.cs
index 69e45bb..cecb115 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/TestClient.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/TestClient.cs
@@ -538,6 +538,9 @@ namespace OpenSim.Region.Environment.Scenes.Tests
public virtual void SendBulkUpdateInventory(InventoryItemBase item)
{
}
+
+ public void SendBulkUpdateInventory(InventoryFolderBase folderBase)
+ {}
public UUID GetDefaultAnimation(string name)
{
@@ -561,8 +564,8 @@ namespace OpenSim.Region.Environment.Scenes.Tests
int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
{
-
}
+
public virtual void SendNameReply(UUID profileId, string firstname, string lastname)
{
}
--
cgit v1.1