From 7cedb098699fe31ac906c95d1b1fd906dd502955 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Sun, 6 Jan 2008 01:16:06 +0000
Subject: Prim inventory phase 4. Properly recover the prim folder ID from
storage. Scripts now show up in prim inventories after region restart.
Probably doesn't yet work for any items other than scripts. Still some work
to do. No user functionality exposed. Not yet user tieable into normal
code.
---
.../Region/Environment/Scenes/SceneObjectGroup.cs | 16 ++--
.../Region/Environment/Scenes/SceneObjectPart.cs | 98 +++++++++++++++++-----
.../MonoSqliteDataStore.cs | 14 +++-
3 files changed, 97 insertions(+), 31 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 94b6797..4bbc2ed 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -1151,20 +1151,26 @@ namespace OpenSim.Region.Environment.Scenes
{
MainLog.Instance.Warn(
"SCENE",
- "Couldn't find part {0} in object group {1} ({2}) to retreive prim inventory",
- localID, LocalId, UUID);
+ "Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
+ localID, Name, UUID);
}
return false;
}
- public string RequestInventoryFile(uint localID, IXfer xferManager)
+ public void RequestInventoryFile(uint localID, IXfer xferManager)
{
SceneObjectPart part = GetChildPart(localID);
if (part != null)
{
part.RequestInventoryFile(xferManager);
}
- return "";
+ else
+ {
+ MainLog.Instance.Warn(
+ "PRIMINVENTORY",
+ "Couldn't find part {0} in object group {1}, {2} to request inventory data",
+ localID, Name, UUID);
+ }
}
public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item)
@@ -1202,7 +1208,7 @@ namespace OpenSim.Region.Environment.Scenes
taskItem.owner_id = new LLUUID(item.avatarID.ToString());
taskItem.creator_id = new LLUUID(item.creatorsID.ToString());
taskItem.type = SceneObjectPart.TaskInventoryItem.Types[item.assetType];
- taskItem.inv_type = SceneObjectPart.TaskInventoryItem.Types[item.invType];
+ taskItem.inv_type = SceneObjectPart.TaskInventoryItem.InvTypes[item.invType];
part.AddInventoryItem(taskItem);
return true;
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 051884d..2ddcf7b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -56,7 +56,21 @@ namespace OpenSim.Region.Environment.Scenes
private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647;
private string m_inventoryFileName = "";
+
+ ///
+ /// The inventory folder for this prim
+ ///
private LLUUID m_folderID = LLUUID.Zero;
+
+ ///
+ /// Exposing this is not particularly good, but it's one of the least evils at the moment to see
+ /// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
+ ///
+ public LLUUID FolderID
+ {
+ get { return m_folderID; }
+ set { m_folderID = value; }
+ }
[XmlIgnore] public PhysicsActor PhysActor = null;
@@ -67,14 +81,9 @@ namespace OpenSim.Region.Environment.Scenes
= new Dictionary();
[XmlIgnore]
- ///
- /// Not really ideal to allow this to be set, but currently expedient for inserting a prim inventory
- /// from persistence.
- ///
public IDictionary TaskInventory
{
get { return m_taskInventory; }
- set { m_taskInventory = value; }
}
public LLUUID LastOwnerID;
@@ -1059,6 +1068,10 @@ namespace OpenSim.Region.Environment.Scenes
#region Inventory
+ ///
+ /// Add an item to this prim's inventory.
+ ///
+ ///
public void AddInventoryItem(TaskInventoryItem item)
{
item.parent_id = m_folderID;
@@ -1067,6 +1080,21 @@ namespace OpenSim.Region.Environment.Scenes
m_taskInventory.Add(item.item_id, item);
m_inventorySerial++;
}
+
+ ///
+ /// Add a whole collection of items to the prim's inventory at once. We assume that the items already
+ /// have all their fields correctly filled out.
+ ///
+ ///
+ public void AddInventoryItems(ICollection items)
+ {
+ foreach (TaskInventoryItem item in items)
+ {
+ m_taskInventory.Add(item.item_id, item);
+ }
+
+ m_inventorySerial++;
+ }
public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
{
@@ -1077,7 +1105,7 @@ namespace OpenSim.Region.Environment.Scenes
string type = m_taskInventory[itemID].inv_type;
m_taskInventory.Remove(itemID);
m_inventorySerial++;
- if (type == "lsltext")
+ if (type == "lsl_text")
{
return 10;
}
@@ -1110,7 +1138,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
- public string RequestInventoryFile(IXfer xferManager)
+ public void RequestInventoryFile(IXfer xferManager)
{
byte[] fileData = new byte[0];
InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
@@ -1141,12 +1169,16 @@ namespace OpenSim.Region.Environment.Scenes
invString.AddNameValueLine("creation_date", item.creation_date.ToString());
invString.AddSectionEnd();
}
+
fileData = Helpers.StringToField(invString.BuildString);
+
+// MainLog.Instance.Verbose(
+// "PRIMINVENTORY", "RequestInventoryFile fileData: {0}", Helpers.FieldToUTF8String(fileData));
+
if (fileData.Length > 2)
{
xferManager.AddNewFile(m_inventoryFileName, fileData);
}
- return "";
}
#endregion
@@ -1707,21 +1739,43 @@ namespace OpenSim.Region.Environment.Scenes
public class TaskInventoryItem
{
+ ///
+ /// Inventory types
+ ///
+ public static string[] InvTypes = new string[]
+ {
+ "texture",
+ "sound",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "lsl_text",
+ ""
+ };
+
+ ///
+ /// Asset types
+ ///
public static string[] Types = new string[]
- {
- "texture",
- "sound",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "lsltext",
- ""
- };
+ {
+ "texture",
+ "sound",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "lsltext",
+ ""
+ };
public LLUUID item_id = LLUUID.Zero;
public LLUUID parent_id = LLUUID.Zero; //parent folder id
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index f9ab0c5..8bad730 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -340,18 +340,24 @@ namespace OpenSim.DataStore.MonoSqlite
String sql = String.Format("primID = '{0}'", prim.UUID.ToString());
DataRow[] dbItemRows = dbItems.Select(sql);
- IDictionary inventory
- = new Dictionary();
+ IList inventory = new List();
foreach (DataRow row in dbItemRows)
{
SceneObjectPart.TaskInventoryItem item = buildItem(row);
- inventory.Add(item.item_id, item);
+ inventory.Add(item);
MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.name, item.item_id);
}
- prim.TaskInventory = inventory;
+ prim.AddInventoryItems(inventory);
+
+ // XXX A nasty little hack to recover the folder id for the prim (which is currently stored in
+ // every item). This data should really be stored in the prim table itself.
+ if (dbItemRows.Length > 0)
+ {
+ prim.FolderID = inventory[0].parent_id;
+ }
}
public void StoreTerrain(double[,] ter, LLUUID regionID)
--
cgit v1.1