Start of Task Inventory (ie prim's inventory). For now, you can only move scripts into a prim (from your user inventory) and although the script will now show up in the prims inventory, you can't make any changes to it (or delete it). Also a prim's inventory is currently not saved between restarts.

afrisby
MW 2007-08-22 14:37:54 +00:00
parent de2432b73e
commit b5921e2b95
9 changed files with 200 additions and 54 deletions

View File

@ -93,6 +93,7 @@ namespace OpenSim.Framework.Interfaces
public delegate void UDPAssetUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data);
public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data);
public delegate void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName);
public delegate void ConfirmXfer(IClientAPI remoteClient, ulong xferID, uint packetID);
public interface IClientAPI
{
@ -147,6 +148,7 @@ namespace OpenSim.Framework.Interfaces
event UDPAssetUploadRequest OnAssetUploadRequest;
event XferReceive OnXferReceive;
event RequestXfer OnRequestXfer;
event ConfirmXfer OnConfirmXfer;
event RezScript OnRezScript;
event UUIDNameRequest OnNameFromUUIDRequest;

View File

@ -62,6 +62,7 @@ namespace OpenSim.Framework
public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive;
public event RequestXfer OnRequestXfer;
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript;
public event UUIDNameRequest OnNameFromUUIDRequest;

View File

@ -91,6 +91,7 @@ namespace OpenSim.Region.ClientStack
public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive;
public event RequestXfer OnRequestXfer;
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript;
public event UUIDNameRequest OnNameFromUUIDRequest;

View File

@ -383,6 +383,13 @@ namespace OpenSim.Region.ClientStack
OnXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
}
break;
case PacketType.ConfirmXferPacket:
ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
if (OnConfirmXfer != null)
{
OnConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
}
break;
case PacketType.CreateInventoryFolder:
if (this.OnCreateNewInventoryFolder != null)
{

View File

@ -189,7 +189,6 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="primLocalID"></param>
public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
{
bool hasPrim = false;
foreach (EntityBase ent in Entities.Values)
{
@ -198,7 +197,11 @@ namespace OpenSim.Region.Environment.Scenes
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
if (hasPrim != false)
{
((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID);
bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID);
if (fileChange)
{
((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, xferManager);
}
break;
}
}
@ -216,6 +219,7 @@ namespace OpenSim.Region.Environment.Scenes
if (item != null)
{
bool isTexture = false;
bool rezzed = false;
if (item.invType == 0)
{
isTexture = true;
@ -226,6 +230,7 @@ namespace OpenSim.Region.Environment.Scenes
string script = Util.FieldToString(rezAsset.Data);
//Console.WriteLine("rez script "+script);
this.EventManager.TriggerRezScript(localID, script);
rezzed = true;
}
else
{
@ -236,8 +241,31 @@ namespace OpenSim.Region.Environment.Scenes
string script = Util.FieldToString(rezAsset.Data);
// Console.WriteLine("rez script " + script);
this.EventManager.TriggerRezScript(localID, script);
rezzed = true;
}
}
if (rezzed)
{
bool hasPrim = false;
foreach (EntityBase ent in Entities.Values)
{
if (ent is SceneObjectGroup)
{
hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
if (hasPrim != false)
{
bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item);
if (added)
{
userInfo.DeleteItem(remoteClient.AgentId, item);
remoteClient.SendRemoveInventoryItem(itemID);
}
}
}
}
}
}
}
}

View File

@ -77,6 +77,7 @@ namespace OpenSim.Region.Environment.Scenes
protected AgentCircuitManager authenticateHandler;
protected RegionCommsListener regionCommsHost;
protected CommunicationsManager commsManager;
protected XferManagaer xferManager;
protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>();
protected BaseHttpServer httpListener;
@ -163,6 +164,7 @@ namespace OpenSim.Region.Environment.Scenes
m_scriptManager = new ScriptManager(this);
m_eventManager = new EventManager();
m_permissionManager = new PermissionManager(this);
xferManager = new XferManagaer();
m_eventManager.OnParcelPrimCountAdd +=
m_LandManager.addPrimToLandPrimCounts;
@ -711,6 +713,8 @@ namespace OpenSim.Region.Environment.Scenes
client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest;
client.OnXferReceive += commsManager.TransactionsManager.HandleXfer;
// client.OnRequestXfer += RequestXfer;
client.OnRequestXfer += xferManager.RequestXfer;
client.OnConfirmXfer += xferManager.AckPacket;
client.OnRezScript += RezScript;
client.OnRequestAvatarProperties += RequestAvatarProperty;

View File

@ -10,6 +10,7 @@ using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using OpenSim.Physics.Manager;
using OpenSim.Framework.Data;
namespace OpenSim.Region.Environment.Scenes
{
@ -518,7 +519,7 @@ namespace OpenSim.Region.Environment.Scenes
proper.ObjectData[0].FolderID = LLUUID.Zero;
proper.ObjectData[0].FromTaskID = LLUUID.Zero;
proper.ObjectData[0].GroupID = LLUUID.Zero;
proper.ObjectData[0].InventorySerial = 0;
proper.ObjectData[0].InventorySerial = (short) this.m_rootPart.InventorySerial;
proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID;
proper.ObjectData[0].ObjectID = this.UUID;
proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID;
@ -601,27 +602,45 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="localID"></param>
public void GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID)
{
SceneObjectPart part = this.GetChildPrim(localID);
if (part != null)
{
part.GetInventoryFileName(remoteClient, localID);
return part.GetInventoryFileName(remoteClient, localID);
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="partID"></param>
public void RequestInventoryFile(IClientAPI remoteClient, uint localID, ulong xferID)
public string RequestInventoryFile(uint localID, XferManagaer xferManager)
{
SceneObjectPart part = this.GetChildPrim(localID);
if (part != null)
{
part.RequestInventoryFile(remoteClient, xferID);
return part.RequestInventoryFile(xferManager);
}
return "";
}
public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item)
{
SceneObjectPart part = this.GetChildPrim(localID);
if (part != null)
{
SceneObjectPart.TaskInventoryItem taskItem = new SceneObjectPart.TaskInventoryItem();
taskItem.item_id = item.inventoryID;
taskItem.asset_id = item.assetID;
taskItem.name = item.inventoryName;
taskItem.desc = item.inventoryDescription;
taskItem.owner_id = item.avatarID;
taskItem.creator_id = item.creatorsID;
taskItem.type = taskItem.AssetTypes[item.assetType];
taskItem.inv_type = taskItem.AssetTypes[item.invType];
part.AddInventoryItem(taskItem);
return true;
}
return false;
}
/// <summary>

View File

@ -10,6 +10,7 @@ using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Framework.Utilities;
namespace OpenSim.Region.Environment.Scenes
{
@ -18,6 +19,10 @@ namespace OpenSim.Region.Environment.Scenes
{
private const uint FULL_MASK_PERMISSIONS = 2147483647;
private string m_inventoryFileName = "";
private LLUUID m_folderID = LLUUID.Zero;
protected Dictionary<LLUUID, TaskInventoryItem> TaskInventory = new Dictionary<LLUUID, TaskInventoryItem>();
public LLUUID CreatorID;
public LLUUID OwnerID;
@ -43,6 +48,16 @@ namespace OpenSim.Region.Environment.Scenes
#region Properties
/// <summary>
/// Serial count for inventory file , used to tell if inventory has changed
/// no need for this to be part of Database backup
/// </summary>
protected uint m_inventorySerial = 0;
public uint InventorySerial
{
get { return m_inventorySerial; }
}
protected LLUUID m_uuid;
public LLUUID UUID
{
@ -221,6 +236,8 @@ namespace OpenSim.Region.Environment.Scenes
this.AngularVelocity = new LLVector3(0, 0, 0);
this.Acceleration = new LLVector3(0, 0, 0);
m_inventoryFileName = "taskinventory" + LLUUID.Random().ToString();
m_folderID = LLUUID.Random();
//temporary code just so the m_flags field doesn't give a compiler warning
if (m_flags == LLObject.ObjectFlags.AllowInventoryDrop)
@ -396,9 +413,12 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Inventory
public void AddInventoryItem()
public void AddInventoryItem(TaskInventoryItem item)
{
item.parent_id = m_folderID;
item.creation_date = 1000;
this.TaskInventory.Add(item.item_id, item);
this.m_inventorySerial++;
}
public void RemoveInventoryItem()
@ -410,27 +430,35 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
/// <param name="client"></param>
/// <param name="localID"></param>
public void GetInventoryFileName(IClientAPI client, uint localID)
public bool GetInventoryFileName(IClientAPI client, uint localID)
{
if (localID == this.m_localID)
{
//client.SendTaskInventory(this.m_uuid, 1, Helpers.StringToField("primInventory2"));
client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
if (this.m_inventorySerial > 0)
{
client.SendTaskInventory(this.m_uuid, (short)m_inventorySerial, Helpers.StringToField(m_inventoryFileName));
return true;
}
else
{
client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
return false;
}
//client.SendTaskInventory(this.m_uuid, 1, Helpers.StringToField("primInventory2"));
//client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="client"></param>
/// <param name="xferID"></param>
public void RequestInventoryFile(IClientAPI client, ulong xferID)
public string RequestInventoryFile(XferManagaer xferManager)
{
byte[] fileData = new byte[0];
InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID);
foreach (TaskInventoryItem item in this.TaskInventory.Values)
{
// a test item
InventoryStringBuilder invString = new InventoryStringBuilder();
invString.AddItemStart();
invString.AddNameValueLine("item_id", LLUUID.Random().ToStringHyphenated());
invString.AddNameValueLine("parent_id", LLUUID.Zero.ToStringHyphenated());
invString.AddNameValueLine("item_id", item.item_id.ToStringHyphenated());
invString.AddNameValueLine("parent_id", item.parent_id.ToStringHyphenated());
invString.AddPermissionsStart();
invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
@ -438,26 +466,27 @@ namespace OpenSim.Region.Environment.Scenes
invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
invString.AddNameValueLine("creator_id", client.AgentId.ToStringHyphenated());
invString.AddNameValueLine("owner_id", client.AgentId.ToStringHyphenated());
invString.AddNameValueLine("last_owner_id", LLUUID.Zero.ToStringHyphenated());
invString.AddNameValueLine("group_id", LLUUID.Zero.ToStringHyphenated());
invString.AddNameValueLine("creator_id", item.creator_id.ToStringHyphenated());
invString.AddNameValueLine("owner_id", item.owner_id.ToStringHyphenated());
invString.AddNameValueLine("last_owner_id", item.last_owner_id.ToStringHyphenated());
invString.AddNameValueLine("group_id", item.group_id.ToStringHyphenated());
invString.AddSectionEnd();
invString.AddNameValueLine("asset_id", "00000000-0000-2222-3333-000000000001");
invString.AddNameValueLine("type", "lsltext");
invString.AddNameValueLine("inv_type", "lsltext");
invString.AddNameValueLine("asset_id", item.asset_id.ToStringHyphenated());
invString.AddNameValueLine("type", item.type);
invString.AddNameValueLine("inv_type", item.inv_type);
invString.AddNameValueLine("flags", "0x00");
invString.AddNameValueLine("name", "Test inventory" + "|");
invString.AddNameValueLine("desc", "test description" + "|");
invString.AddNameValueLine("creation_date", "10000");
invString.AddNameValueLine("name", item.name + "|");
invString.AddNameValueLine("desc", item.desc + "|");
invString.AddNameValueLine("creation_date", item.creation_date.ToString());
invString.AddSectionEnd();
byte[] fileInv = Helpers.StringToField(invString.BuildString);
byte[] data = new byte[fileInv.Length + 4];
Array.Copy(Helpers.IntToBytes(fileInv.Length), 0, data, 0, 4);
Array.Copy(fileInv, 0, data, 4, fileInv.Length);
client.SendXferPacket(xferID, 0 + 0x80000000, data);
}
fileData = Helpers.StringToField(invString.BuildString);
if (fileData.Length > 2)
{
xferManager.AddNewFile(m_inventoryFileName, fileData);
}
return "";
}
#endregion
@ -643,9 +672,14 @@ namespace OpenSim.Region.Environment.Scenes
{
public string BuildString = "";
public InventoryStringBuilder()
public InventoryStringBuilder(LLUUID folderID, LLUUID parentID)
{
BuildString += "\tinv_object\t0\n\t{\n";
this.AddNameValueLine("obj_id", folderID.ToStringHyphenated());
this.AddNameValueLine("parent_id", parentID.ToStringHyphenated());
this.AddNameValueLine("type", "category");
this.AddNameValueLine("name", "Contents");
this.AddSectionEnd();
}
public void AddItemStart()
@ -676,6 +710,55 @@ namespace OpenSim.Region.Environment.Scenes
BuildString += name + "\t";
BuildString += value + "\n";
}
public void Close()
{
}
}
public class TaskInventoryItem
{
public string[] AssetTypes = new string[]
{
"texture",
"sound",
"",
"",
"",
"",
"",
"",
"",
"",
"lsltext",
""
};
public LLUUID item_id = LLUUID.Zero;
public LLUUID parent_id = LLUUID.Zero;
public uint base_mask = FULL_MASK_PERMISSIONS;
public uint owner_mask = FULL_MASK_PERMISSIONS;
public uint group_mask = FULL_MASK_PERMISSIONS;
public uint everyone_mask = FULL_MASK_PERMISSIONS;
public uint next_owner_mask = FULL_MASK_PERMISSIONS;
public LLUUID creator_id = LLUUID.Zero;
public LLUUID owner_id = LLUUID.Zero;
public LLUUID last_owner_id = LLUUID.Zero;
public LLUUID group_id = LLUUID.Zero;
public LLUUID asset_id = LLUUID.Zero;
public string type = "";
public string inv_type = "";
public uint flags = 0;
public string name = "";
public string desc = "";
public uint creation_date = 0;
public string FileName = "";
public TaskInventoryItem()
{
FileName = "taskItem" + LLUUID.Random().ToString();
}
}
}
}

View File

@ -76,6 +76,7 @@ namespace SimpleApp
public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive;
public event RequestXfer OnRequestXfer;
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript;
public event UUIDNameRequest OnNameFromUUIDRequest;