From b5921e2b95305d2918f94f52a560f8c004b8bcb4 Mon Sep 17 00:00:00 2001
From: MW
Date: Wed, 22 Aug 2007 14:37:54 +0000
Subject: 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.
---
.../Region/Environment/Scenes/Scene.Inventory.cs | 32 +++-
OpenSim/Region/Environment/Scenes/Scene.cs | 4 +
.../Region/Environment/Scenes/SceneObjectGroup.cs | 39 +++--
.../Region/Environment/Scenes/SceneObjectPart.cs | 173 +++++++++++++++------
4 files changed, 191 insertions(+), 57 deletions(-)
(limited to 'OpenSim/Region/Environment')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 765fafc..bf7bb7e 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -189,7 +189,6 @@ namespace OpenSim.Region.Environment.Scenes
///
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);
+ }
+ }
+ }
+ }
+
+ }
}
}
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index d625dec..d3aafcc 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -77,6 +77,7 @@ namespace OpenSim.Region.Environment.Scenes
protected AgentCircuitManager authenticateHandler;
protected RegionCommsListener regionCommsHost;
protected CommunicationsManager commsManager;
+ protected XferManagaer xferManager;
protected Dictionary capsHandlers = new Dictionary();
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;
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 2151ded..219de84 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -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
///
///
///
- 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;
}
- ///
- ///
- ///
- ///
- ///
- public void RequestInventoryFile(IClientAPI remoteClient, uint localID, ulong xferID)
+ public string RequestInventoryFile(uint localID, XferManagaer xferManager)
+ {
+ SceneObjectPart part = this.GetChildPrim(localID);
+ if (part != null)
+ {
+ return part.RequestInventoryFile(xferManager);
+ }
+ return "";
+ }
+
+ public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item)
{
SceneObjectPart part = this.GetChildPrim(localID);
if (part != null)
{
- part.RequestInventoryFile(remoteClient, xferID);
+ 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;
+
}
///
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 904b158..5fa79fb 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -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 TaskInventory = new Dictionary();
public LLUUID CreatorID;
public LLUUID OwnerID;
@@ -43,6 +48,16 @@ namespace OpenSim.Region.Environment.Scenes
#region Properties
+ ///
+ /// Serial count for inventory file , used to tell if inventory has changed
+ /// no need for this to be part of Database backup
+ ///
+ 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,54 +430,63 @@ namespace OpenSim.Region.Environment.Scenes
///
///
///
- public void GetInventoryFileName(IClientAPI client, uint localID)
+ public bool GetInventoryFileName(IClientAPI client, uint localID)
{
if (localID == this.m_localID)
{
+ 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]);
+ //client.SendTaskInventory(this.m_uuid, 0, new byte[0]);
}
+ return false;
}
- ///
- ///
- ///
- ///
- ///
- public void RequestInventoryFile(IClientAPI client, ulong xferID)
- {
- // a test item
- InventoryStringBuilder invString = new InventoryStringBuilder();
- invString.AddItemStart();
- invString.AddNameValueLine("item_id", LLUUID.Random().ToStringHyphenated());
- invString.AddNameValueLine("parent_id", LLUUID.Zero.ToStringHyphenated());
-
- invString.AddPermissionsStart();
- invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
- invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
- 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.AddSectionEnd();
-
- invString.AddNameValueLine("asset_id", "00000000-0000-2222-3333-000000000001");
- invString.AddNameValueLine("type", "lsltext");
- invString.AddNameValueLine("inv_type", "lsltext");
- invString.AddNameValueLine("flags", "0x00");
- invString.AddNameValueLine("name", "Test inventory" + "|");
- invString.AddNameValueLine("desc", "test description" + "|");
- invString.AddNameValueLine("creation_date", "10000");
- 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);
+ 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)
+ {
+ invString.AddItemStart();
+ invString.AddNameValueLine("item_id", item.item_id.ToStringHyphenated());
+ invString.AddNameValueLine("parent_id", item.parent_id.ToStringHyphenated());
+
+ invString.AddPermissionsStart();
+ invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
+ 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", item.asset_id.ToStringHyphenated());
+ invString.AddNameValueLine("type", item.type);
+ invString.AddNameValueLine("inv_type", item.inv_type);
+ invString.AddNameValueLine("flags", "0x00");
+ invString.AddNameValueLine("name", item.name + "|");
+ invString.AddNameValueLine("desc", item.desc + "|");
+ invString.AddNameValueLine("creation_date", item.creation_date.ToString());
+ invString.AddSectionEnd();
+ }
+ 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();
+ }
}
}
}
--
cgit v1.1