first stab at implementation of CopyInventoryItem

afrisby
Jeff Ames 2007-11-18 13:50:46 +00:00
parent 46ccfa1741
commit d10c79d421
10 changed files with 150 additions and 73 deletions

View File

@ -239,6 +239,17 @@ namespace OpenSim.Framework.Communications.Cache
//Todo should delete it from memory too
}
public AssetBase CopyAsset(LLUUID assetID)
{
AssetBase asset = GetAsset(assetID);
if (asset == null)
return null;
asset.FullID = LLUUID.Random(); // TODO: check for conflicts
AddAsset(asset);
return asset;
}
/// <summary>
///
/// </summary>

View File

@ -88,7 +88,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000002");
item.inventoryDescription = "Plywood texture";
item.inventoryName = "Plywood";
item.assetType = 0;
item.assetType = (int) AssetType.Texture;
item.invType = (int) InventoryType.Texture;
item.parentFolderID = m_textureFolder.folderID;
item.inventoryBasePermissions = 0x7FFFFFFF;
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
@ -103,7 +104,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000003");
item.inventoryDescription = "Rocks texture";
item.inventoryName = "Rocks";
item.assetType = 0;
item.assetType = (int) AssetType.Texture;
item.invType = (int) InventoryType.Texture;
item.parentFolderID = m_textureFolder.folderID;
item.inventoryBasePermissions = 0x7FFFFFFF;
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
@ -118,7 +120,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000001");
item.inventoryDescription = "Bricks texture";
item.inventoryName = "Bricks";
item.assetType = 0;
item.assetType = (int) AssetType.Texture;
item.invType = (int) InventoryType.Texture;
item.parentFolderID = m_textureFolder.folderID;
item.inventoryBasePermissions = 0x7FFFFFFF;
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
@ -133,7 +136,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000004");
item.inventoryDescription = "Granite texture";
item.inventoryName = "Granite";
item.assetType = 0;
item.assetType = (int) AssetType.Texture;
item.invType = (int) InventoryType.Texture;
item.parentFolderID = m_textureFolder.folderID;
item.inventoryBasePermissions = 0x7FFFFFFF;
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
@ -148,7 +152,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("00000000-0000-0000-9999-000000000005");
item.inventoryDescription = "Hardwood texture";
item.inventoryName = "Hardwood";
item.assetType = 0;
item.assetType = (int) AssetType.Texture;
item.invType = (int) InventoryType.Texture;
item.parentFolderID = m_textureFolder.folderID;
item.inventoryBasePermissions = 0x7FFFFFFF;
item.inventoryEveryOnePermissions = 0x7FFFFFFF;
@ -163,8 +168,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
item.inventoryDescription = "Default Shape";
item.inventoryName = "Default Shape";
item.assetType = 13;
item.invType = 18;
item.assetType = (int) AssetType.Bodypart;
item.invType = (int) InventoryType.Wearable;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 0;
item.inventoryNextPermissions = 0;
@ -177,8 +182,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb");
item.inventoryDescription = "Default Skin";
item.inventoryName = "Default Skin";
item.assetType = 13;
item.invType = 18;
item.assetType = (int) AssetType.Bodypart;
item.invType = (int) InventoryType.Wearable;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 0;
item.inventoryNextPermissions = 0;
@ -191,8 +196,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111110");
item.inventoryDescription = "Default Shirt";
item.inventoryName = "Default Shirt";
item.assetType = 5;
item.invType = 18;
item.assetType = (int) AssetType.Clothing;
item.invType = (int) InventoryType.Wearable;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 0;
item.inventoryNextPermissions = 0;
@ -205,8 +210,8 @@ namespace OpenSim.Framework.Communications.Cache
item.assetID = new LLUUID("00000000-38f9-1111-024e-222222111120");
item.inventoryDescription = "Default Pants";
item.inventoryName = "Default Pants";
item.assetType = 5;
item.invType = 18;
item.assetType = (int) AssetType.Clothing;
item.invType = (int) InventoryType.Wearable;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 0;
item.inventoryNextPermissions = 0;

View File

@ -74,7 +74,10 @@ namespace OpenSim.Framework.Communications.Cache
public CachedUserInfo GetUserDetails(LLUUID userID)
{
return m_userProfiles[userID];
if (m_userProfiles.ContainsKey(userID))
return m_userProfiles[userID];
else
return null;
}
public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType,

View File

@ -272,6 +272,9 @@ namespace OpenSim.Framework
public delegate void UpdateInventoryItemTransaction(
IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID);
public delegate void CopyInventoryItem(
IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName);
public delegate void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID);
public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint localID);
@ -344,6 +347,7 @@ namespace OpenSim.Framework
event FetchInventory OnFetchInventory;
event RequestTaskInventory OnRequestTaskInventory;
event UpdateInventoryItemTransaction OnUpdateInventoryItem;
event CopyInventoryItem OnCopyInventoryItem;
event UDPAssetUploadRequest OnAssetUploadRequest;
event XferReceive OnXferReceive;
event RequestXfer OnRequestXfer;

View File

@ -96,6 +96,7 @@ namespace OpenSim.Region.ClientStack
public event FetchInventory OnFetchInventory;
public event RequestTaskInventory OnRequestTaskInventory;
public event UpdateInventoryItemTransaction OnUpdateInventoryItem;
public event CopyInventoryItem OnCopyInventoryItem;
public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive;
public event RequestXfer OnRequestXfer;

View File

@ -563,6 +563,16 @@ namespace OpenSim.Region.ClientStack
}
}*/
break;
case PacketType.CopyInventoryItem:
CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket) Pack;
if (OnCopyInventoryItem != null)
{
foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
{
OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, datablock.OldItemID, datablock.NewFolderID, Util.FieldToString(datablock.NewName));
}
}
break;
case PacketType.RequestTaskInventory:
RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket) Pack;
if (OnRequestTaskInventory != null)

View File

@ -31,6 +31,7 @@ using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Environment.Scenes
@ -82,24 +83,18 @@ namespace OpenSim.Region.Environment.Scenes
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
if (item != null)
{
AssetBase asset;
asset = new AssetBase();
asset.FullID = LLUUID.Random();
asset.Type = (sbyte) item.assetType;
asset.InvType = (sbyte) item.invType;
asset.Name = item.inventoryName;
asset.Data = data;
AssetBase asset = CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, (sbyte) item.assetType, data);
AssetCache.AddAsset(asset);
item.assetID = asset.FullID;
userInfo.UpdateItem(remoteClient.AgentId, item);
// remoteClient.SendInventoryItemUpdate(item);
if (item.invType == 7)
if ((InventoryType) item.invType == InventoryType.Notecard)
{
//do we want to know about updated note cards?
}
else if (item.invType == 10)
else if ((InventoryType) item.invType == InventoryType.LSL)
{
// do we want to know about updated scripts
}
@ -160,6 +155,75 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName)
{
InventoryItemBase item = CommsManager.UserProfileCache.libraryRoot.HasItem(oldItemID);
if (item == null)
{
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(oldAgentID);
if (userInfo == null)
{
MainLog.Instance.Warn("INVENTORY", "Failed to find user " + oldAgentID.ToString());
return;
}
item = userInfo.RootFolder.HasItem(oldItemID);
if (item == null)
{
MainLog.Instance.Warn("INVENTORY", "Failed to find item " + oldItemID.ToString());
return;
}
}
AssetBase asset = AssetCache.CopyAsset(item.assetID);
if (asset == null)
{
MainLog.Instance.Warn("INVENTORY", "Failed to find asset " + item.assetID.ToString());
return;
}
asset.Name = (newName.Length == 0) ? item.inventoryName : newName;
// TODO: preserve current permissions?
CreateNewInventoryItem(remoteClient, newFolderID, callbackID, asset, item.inventoryNextPermissions);
}
private AssetBase CreateAsset(string name, string description, sbyte invType, sbyte assetType, byte[] data)
{
AssetBase asset = new AssetBase();
asset.Name = name;
asset.Description = description;
asset.InvType = invType;
asset.Type = assetType;
asset.FullID = LLUUID.Random(); // TODO: check for conflicts
asset.Data = (data == null) ? new byte[1] : data;
return asset;
}
private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID,
AssetBase asset, uint nextOwnerMask)
{
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
InventoryItemBase item = new InventoryItemBase();
item.avatarID = remoteClient.AgentId;
item.creatorsID = remoteClient.AgentId;
item.inventoryID = LLUUID.Random();
item.assetID = asset.FullID;
item.inventoryDescription = asset.Description;
item.inventoryName = asset.Name;
item.assetType = asset.Type;
item.invType = asset.InvType;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 2147483647;
item.inventoryNextPermissions = nextOwnerMask;
userInfo.AddItem(remoteClient.AgentId, item);
remoteClient.SendInventoryItemUpdate(item);
}
}
/// <summary>
/// temporary method to test out creating new inventory items
/// </summary>
@ -174,7 +238,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="wearableType"></param>
/// <param name="nextOwnerMask"></param>
public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID,
uint callbackID, string description, string name, sbyte invType, sbyte type,
uint callbackID, string description, string name, sbyte invType, sbyte assetType,
byte wearableType, uint nextOwnerMask)
{
if (transActionID == LLUUID.Zero)
@ -182,37 +246,17 @@ namespace OpenSim.Region.Environment.Scenes
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
AssetBase asset = new AssetBase();
asset.Name = name;
asset.Description = description;
asset.InvType = invType;
asset.Type = type;
asset.FullID = LLUUID.Random();
asset.Data = new byte[1];
AssetBase asset = CreateAsset(name, description, invType, assetType, null);
AssetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase();
item.avatarID = remoteClient.AgentId;
item.creatorsID = remoteClient.AgentId;
item.inventoryID = LLUUID.Random();
item.assetID = asset.FullID;
item.inventoryDescription = description;
item.inventoryName = name;
item.assetType = invType;
item.invType = invType;
item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 2147483647;
item.inventoryNextPermissions = nextOwnerMask;
userInfo.AddItem(remoteClient.AgentId, item);
remoteClient.SendInventoryItemUpdate(item);
CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, nextOwnerMask);
}
}
else
{
CommsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID,
callbackID, description, name, invType,
type, wearableType, nextOwnerMask);
assetType, wearableType, nextOwnerMask);
//System.Console.WriteLine("request to create inventory item from transaction " + transActionID);
}
}
@ -348,21 +392,18 @@ namespace OpenSim.Region.Environment.Scenes
CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
AssetBase asset = new AssetBase();
asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId);
asset.Description =
((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId);
asset.InvType = 6;
asset.Type = 6;
asset.FullID = LLUUID.Random();
asset.Data = Helpers.StringToField(sceneObjectXml);
AssetBase asset = CreateAsset(
((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId),
((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId),
(sbyte) InventoryType.Object,
(sbyte) AssetType.Object, // TODO: after libSL r1357, this becomes AssetType.Primitive
Helpers.StringToField(sceneObjectXml));
AssetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase();
item.avatarID = remoteClient.AgentId;
item.creatorsID = remoteClient.AgentId;
item.inventoryID = LLUUID.Random();
item.inventoryID = LLUUID.Random(); // TODO: check for conflicts
item.assetID = asset.FullID;
item.inventoryDescription = asset.Description;
item.inventoryName = asset.Name;

View File

@ -789,6 +789,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnRequestTaskInventory += RequestTaskInventory;
client.OnFetchInventory += CommsManager.UserProfileCache.HandleFetchInventory;
client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset;
client.OnCopyInventoryItem += CopyInventoryItem;
client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;
client.OnRezScript += RezScript;

View File

@ -106,6 +106,7 @@ namespace SimpleApp
public event FetchInventory OnFetchInventory;
public event RequestTaskInventory OnRequestTaskInventory;
public event UpdateInventoryItemTransaction OnUpdateInventoryItem;
public event CopyInventoryItem OnCopyInventoryItem;
public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive;
public event RequestXfer OnRequestXfer;

View File

@ -416,57 +416,57 @@
<Section Name="Skin">
<Key Name="assetID" Value="77c41e39-38f9-f75a-024e-585989bbabbb"/>
<Key Name="name" Value="Skin"/>
<Key Name="assetType" Value="0" />
<Key Name="inventoryType" Value="0" />
<Key Name="assetType" Value="13" />
<Key Name="inventoryType" Value="18" />
<Key Name="fileName" Value="base_skin.dat"/>
</Section>
<Section Name="Skin">
<Key Name="assetID" Value="77c41e39-38f9-f75a-024e-585989bbabbc"/>
<Key Name="name" Value="Jim Skin"/>
<Key Name="assetType" Value="0" />
<Key Name="inventoryType" Value="0" />
<Key Name="assetType" Value="13" />
<Key Name="inventoryType" Value="18" />
<Key Name="fileName" Value="jim_skin.dat"/>
</Section>
<Section Name="Skin">
<Key Name="assetID" Value="77c41e39-38f9-f75a-024e-585989bbabbd"/>
<Key Name="name" Value="Goblin Skin"/>
<Key Name="assetType" Value="0" />
<Key Name="inventoryType" Value="0" />
<Key Name="assetType" Value="13" />
<Key Name="inventoryType" Value="18" />
<Key Name="fileName" Value="goblin_skin.dat"/>
</Section>
<Section Name="Shape">
<Key Name="assetID" Value="66c41e39-38f9-f75a-024e-585989bfab73"/>
<Key Name="name" Value="Shape"/>
<Key Name="assetType" Value="0" />
<Key Name="inventoryType" Value="0" />
<Key Name="assetType" Value="13" />
<Key Name="inventoryType" Value="18" />
<Key Name="fileName" Value="base_shape.dat"/>
</Section>
<Section Name="Shape">
<Key Name="assetID" Value="66c41e39-38f9-f75a-024e-585989bfab74"/>
<Key Name="name" Value="Jim Shape"/>
<Key Name="assetType" Value="0" />
<Key Name="inventoryType" Value="0" />
<Key Name="assetType" Value="13" />
<Key Name="inventoryType" Value="18" />
<Key Name="fileName" Value="jim_shape.dat"/>
</Section>
<Section Name="Shape">
<Key Name="assetID" Value="66c41e39-38f9-f75a-024e-585989bfab75"/>
<Key Name="name" Value="Little Goblin Shape"/>
<Key Name="assetType" Value="0" />
<Key Name="inventoryType" Value="0" />
<Key Name="assetType" Value="13" />
<Key Name="inventoryType" Value="18" />
<Key Name="fileName" Value="little_goblin_shape.dat"/>
</Section>
<Section Name="Shirt">
<Key Name="assetID" Value="00000000-38f9-1111-024e-222222111110"/>
<Key Name="name" Value="Shirt"/>
<Key Name="assetType" Value="0" />
<Key Name="inventoryType" Value="0" />
<Key Name="assetType" Value="5" />
<Key Name="inventoryType" Value="18" />
<Key Name="fileName" Value="newshirt.dat"/>
</Section>
<Section Name="Pants">
<Key Name="assetID" Value="00000000-38f9-1111-024e-222222111120"/>
<Key Name="name" Value="Pants"/>
<Key Name="assetType" Value="0" />
<Key Name="inventoryType" Value="0" />
<Key Name="assetType" Value="5" />
<Key Name="inventoryType" Value="18" />
<Key Name="fileName" Value="newpants.dat"/>
</Section>
<Section Name="Moon">