From accd89b3f1c7729e6bb34b52e8095baf9c1f440a Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Sat, 26 Apr 2008 20:31:01 +0000
Subject: * First draft implementation of copying prim inventory items back to
agent inventory * Now, if you own an item in a prim, you should be able to
successfully drag it back into your inventory * Temporarily, users which are
not owners of the item cannot copy it, even if 'everyone can copy' is set *
This is pending fixes/implementation of upstream permission implementation
---
.../Communications/Cache/InventoryFolderImpl.cs | 2 +-
OpenSim/Framework/IClientAPI.cs | 3 +
OpenSim/Region/ClientStack/ClientView.cs | 24 ++++++-
.../Region/Environment/Scenes/Scene.Inventory.cs | 81 ++++++++++++++++++++++
OpenSim/Region/Environment/Scenes/Scene.cs | 1 +
.../Scenes/SceneObjectGroup.Inventory.cs | 7 ++
.../Region/Environment/Scenes/SceneObjectGroup.cs | 2 +-
.../Scenes/SceneObjectPart.Inventory.cs | 22 ++++--
.../Region/Environment/Scenes/SceneObjectPart.cs | 11 +--
.../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 +
10 files changed, 140 insertions(+), 14 deletions(-)
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index 7812499..33d820d 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications.Cache
}
///
- /// Does this folder contain the given item?
+ /// Does this folder or any of its subfolders contain the given item?
///
///
///
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 388dfd7..dd0858a 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -408,6 +408,8 @@ namespace OpenSim.Framework
public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint localID);
+ public delegate void MoveTaskInventory(IClientAPI remoteClient, LLUUID folderID, uint localID, LLUUID itemID);
+
public delegate void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID);
public delegate void UDPAssetUploadRequest(
@@ -530,6 +532,7 @@ namespace OpenSim.Framework
event ConfirmXfer OnConfirmXfer;
event RezScript OnRezScript;
event UpdateTaskInventory OnUpdateTaskInventory;
+ event MoveTaskInventory OnMoveTaskItem;
event RemoveTaskInventory OnRemoveTaskItem;
event RequestAsset OnRequestAsset;
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index db0b2cd..35b248a 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -196,6 +196,7 @@ namespace OpenSim.Region.ClientStack
private RemoveInventoryFolder handlerRemoveInventoryFolder = null;
private RequestTaskInventory handlerRequestTaskInventory = null; //OnRequestTaskInventory;
private UpdateTaskInventory handlerUpdateTaskInventory = null; //OnUpdateTaskInventory;
+ private MoveTaskInventory handlerMoveTaskItem = null;
private RemoveTaskInventory handlerRemoveTaskItem = null; //OnRemoveTaskItem;
private RezScript handlerRezScript = null; //OnRezScript;
private RequestMapBlocks handlerRequestMapBlocks = null; //OnRequestMapBlocks;
@@ -762,6 +763,7 @@ namespace OpenSim.Region.ClientStack
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript;
public event UpdateTaskInventory OnUpdateTaskInventory;
+ public event MoveTaskInventory OnMoveTaskItem;
public event RemoveTaskInventory OnRemoveTaskItem;
public event RequestAsset OnRequestAsset;
@@ -4250,8 +4252,11 @@ namespace OpenSim.Region.ClientStack
}
}
}
+
break;
+
case PacketType.RemoveTaskInventory:
+
RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
handlerRemoveTaskItem = OnRemoveTaskItem;
@@ -4260,11 +4265,27 @@ namespace OpenSim.Region.ClientStack
{
handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
}
+
break;
+
case PacketType.MoveTaskInventory:
- m_log.Warn("[CLIENT]: unhandled MoveTaskInventory packet");
+
+ MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
+
+ handlerMoveTaskItem = OnMoveTaskItem;
+
+ if (handlerMoveTaskItem != null)
+ {
+ handlerMoveTaskItem(
+ this, moveTaskInventoryPacket.AgentData.FolderID,
+ moveTaskInventoryPacket.InventoryData.LocalID,
+ moveTaskInventoryPacket.InventoryData.ItemID);
+ }
+
break;
+
case PacketType.RezScript:
+
//Console.WriteLine(Pack.ToString());
RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
@@ -4275,6 +4296,7 @@ namespace OpenSim.Region.ClientStack
handlerRezScript(this, rezScriptx.InventoryBlock.ItemID, rezScriptx.UpdateBlock.ObjectLocalID);
}
break;
+
case PacketType.MapLayerRequest:
RequestMapLayer();
break;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 40650f3..67d3dfb 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -83,6 +83,14 @@ namespace OpenSim.Region.Environment.Scenes
}
EventManager.TriggerOnNewInventoryItemUploadComplete(remoteClient.AgentId, item.AssetID, item.Name, userlevel);
}
+ else
+ {
+ m_log.ErrorFormat(
+ "[AGENT INVENTORY]: Agent {0} {1} was not found for add of item {2} {3}",
+ remoteClient.Name, remoteClient.AgentId, item.Name, item.ID);
+
+ return;
+ }
}
///
@@ -696,6 +704,79 @@ namespace OpenSim.Region.Environment.Scenes
localID);
}
}
+
+ ///
+ /// Move the given item in the given prim to a folder in the client's inventory
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId)
+ {
+ SceneObjectGroup group = GetGroupByPrim(primLocalId);
+
+ if (null == group)
+ {
+ m_log.WarnFormat(
+ "[PRIM INVENTORY]: " +
+ "Move of inventory item {0} from prim with local id {1} failed because the prim could not be found",
+ itemId, primLocalId);
+
+ return;
+ }
+
+ TaskInventoryItem taskItem = group.GetInventoryItem(primLocalId, itemId);
+
+ if (null == taskItem)
+ {
+ // Console already notified of error in GetInventoryItem
+ return;
+ }
+
+// bool permission;
+// permission = PermissionsMngr.CanCopyObject(remoteClient.AgentId,
+// ((SceneObjectGroup) selectedEnt).UUID);
+
+ // Pending resolving upstream problems with permissions, we just won't allow anybody who is not the owner
+ // to copy
+ if (remoteClient.AgentId != taskItem.OwnerID)
+ {
+ m_log.InfoFormat(
+ "[PRIM INVENTORY]: Attempt made by {0} {1} to copy inventory item {2} {3} in prim {4} {5},"
+ + " but temporarily not allowed pending upstream bugfixes/feature implementation",
+ remoteClient.Name, remoteClient.AgentId, taskItem.Name, taskItem.ItemID, group.Name, group.UUID);
+
+ return;
+ }
+
+ InventoryItemBase agentItem = new InventoryItemBase();
+
+ agentItem.ID = LLUUID.Random();
+ agentItem.Creator = taskItem.CreatorID;
+ agentItem.Owner = remoteClient.AgentId;
+ agentItem.AssetID = taskItem.AssetID;
+ agentItem.Description = taskItem.Description;
+ agentItem.Name = taskItem.Name;
+ agentItem.AssetType = taskItem.Type;
+ agentItem.InvType = taskItem.InvType;
+ agentItem.Folder = folderId;
+ agentItem.EveryOnePermissions = taskItem.EveryoneMask;
+
+ if (remoteClient.AgentId != taskItem.OwnerID) {
+ agentItem.BasePermissions = taskItem.NextOwnerMask;
+ agentItem.CurrentPermissions = taskItem.NextOwnerMask;
+ agentItem.NextPermissions = taskItem.NextOwnerMask;
+ }
+ else
+ {
+ agentItem.BasePermissions = taskItem.BaseMask;
+ agentItem.CurrentPermissions = taskItem.OwnerMask;
+ agentItem.NextPermissions = taskItem.NextOwnerMask;
+ }
+
+ AddInventoryItem(remoteClient, agentItem);
+ }
///
/// Update an item in a prim (task) inventory.
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 9ca845f..b16b4aa 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1608,6 +1608,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnRequestTaskInventory += RequestTaskInventory;
client.OnRemoveTaskItem += RemoveTaskInventory;
client.OnUpdateTaskInventory += UpdateTaskInventory;
+ client.OnMoveTaskItem += MoveTaskInventoryItem;
client.OnGrabObject += ProcessObjectGrab;
client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index efb40dd..2d0c636 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -198,6 +198,13 @@ namespace OpenSim.Region.Environment.Scenes
taskItem.CreatorID = item.Creator;
taskItem.Type = item.AssetType;
taskItem.InvType = item.InvType;
+
+ taskItem.BaseMask = item.BasePermissions;
+ taskItem.OwnerMask = item.CurrentPermissions;
+ // FIXME: ignoring group permissions for now as they aren't stored in item
+ taskItem.EveryoneMask = item.EveryOnePermissions;
+ taskItem.NextOwnerMask = item.NextPermissions;
+
part.AddInventoryItem(taskItem);
return true;
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 7020eb8..7596e24 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -1904,7 +1904,7 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- ///
+ /// Return metadata about a prim (name, description, sale price, etc.)
///
///
public void GetProperties(IClientAPI client)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 63cfcbd..89c93fd 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -482,8 +482,9 @@ namespace OpenSim.Region.Environment.Scenes
public void RequestInventoryFile(IXfer xferManager)
{
byte[] fileData = new byte[0];
- InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
- //InventoryStringBuilder invString = new InventoryStringBuilder(UUID, LLUUID.Zero);
+ //InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
+// InventoryStringBuilder invString = new InventoryStringBuilder(UUID, LLUUID.Zero);
+ InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, LLUUID.Zero);
lock (m_taskInventory)
{
@@ -492,20 +493,28 @@ namespace OpenSim.Region.Environment.Scenes
invString.AddItemStart();
invString.AddNameValueLine("item_id", item.ItemID.ToString());
- invString.AddNameValueLine("parent_id", item.ParentID.ToString());
-// invString.AddNameValueLine("parent_id", UUID.ToString());
+ //invString.AddNameValueLine("parent_id", item.ParentID.ToString());
+ invString.AddNameValueLine("parent_id", m_folderID.ToString());
invString.AddPermissionsStart();
+
+ // FIXME: Temporary until permissions are properly sorted.
invString.AddNameValueLine("base_mask", "7fffffff");
invString.AddNameValueLine("owner_mask", "7fffffff");
-
invString.AddNameValueLine("group_mask", "7fffffff");
invString.AddNameValueLine("everyone_mask", "7fffffff");
invString.AddNameValueLine("next_owner_mask", "7fffffff");
+
// invString.AddNameValueLine("group_mask", "00000000");
// invString.AddNameValueLine("everyone_mask", "00000000");
// invString.AddNameValueLine("next_owner_mask", "00086000");
+// invString.AddNameValueLine("base_mask", Helpers.UIntToHexString(item.BaseMask));
+// invString.AddNameValueLine("owner_mask", Helpers.UIntToHexString(item.OwnerMask));
+// invString.AddNameValueLine("group_mask", Helpers.UIntToHexString(item.GroupMask));
+// invString.AddNameValueLine("everyone_mask", Helpers.UIntToHexString(item.EveryoneMask));
+// invString.AddNameValueLine("next_owner_mask", Helpers.UIntToHexString(item.NextOwnerMask));
+
invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
@@ -537,8 +546,7 @@ namespace OpenSim.Region.Environment.Scenes
fileData = Helpers.StringToField(invString.BuildString);
-// m_log.DebugFormat(
-// "[PRIM INVENTORY]: RequestInventoryFile fileData: {0}", Helpers.FieldToUTF8String(fileData));
+ //m_log.Debug("[PRIM INVENTORY]: RequestInventoryFile fileData: " + Helpers.FieldToUTF8String(fileData));
if (fileData.Length > 2)
{
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index b7e72ef..50c96e1 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -747,12 +747,15 @@ namespace OpenSim.Region.Environment.Scenes
Acceleration = new LLVector3(0, 0, 0);
m_TextureAnimation = new byte[0];
m_inventoryFileName = "inventory_" + LLUUID.Random().ToString() + ".tmp";
- m_folderID = LLUUID.Random();
+
+ // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
+ // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
+ // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log
+ m_folderID = UUID;
Flags = 0;
- Flags |= LLObject.ObjectFlags.AllowInventoryDrop |
- LLObject.ObjectFlags.CreateSelected;
-
+ Flags |= LLObject.ObjectFlags.AllowInventoryDrop |
+ LLObject.ObjectFlags.CreateSelected;
TrimPermissions();
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 2586ac5..a12404a 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -134,6 +134,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript;
public event UpdateTaskInventory OnUpdateTaskInventory;
+ public event MoveTaskInventory OnMoveTaskItem;
public event RemoveTaskInventory OnRemoveTaskItem;
public event RequestAsset OnRequestAsset;
--
cgit v1.1