* 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
0.6.0-stable
Justin Clarke Casey 2008-04-26 20:31:01 +00:00
parent 323038ceb9
commit accd89b3f1
10 changed files with 140 additions and 14 deletions

View File

@ -92,7 +92,7 @@ namespace OpenSim.Framework.Communications.Cache
}
/// <summary>
/// Does this folder contain the given item?
/// Does this folder or any of its subfolders contain the given item?
/// </summary>
/// <param name="itemID"></param>
/// <returns></returns>

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}
/// <summary>
@ -696,6 +704,79 @@ namespace OpenSim.Region.Environment.Scenes
localID);
}
}
/// <summary>
/// Move the given item in the given prim to a folder in the client's inventory
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="folderID"></param>
/// <param name="primLocalID"></param>
/// <param name="itemID"></param>
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);
}
/// <summary>
/// Update an item in a prim (task) inventory.

View File

@ -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;

View File

@ -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;

View File

@ -1904,7 +1904,7 @@ namespace OpenSim.Region.Environment.Scenes
}
/// <summary>
///
/// Return metadata about a prim (name, description, sale price, etc.)
/// </summary>
/// <param name="client"></param>
public void GetProperties(IClientAPI client)

View File

@ -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)
{

View File

@ -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();

View File

@ -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;