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.
afrisby
Justin Clarke Casey 2008-01-06 01:16:06 +00:00
parent 1867fbaa67
commit 7cedb09869
3 changed files with 97 additions and 31 deletions

View File

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

View File

@ -56,8 +56,22 @@ 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 = "";
/// <summary>
/// The inventory folder for this prim
/// </summary>
private LLUUID m_folderID = LLUUID.Zero;
/// <summary>
/// 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.
/// </summary>
public LLUUID FolderID
{
get { return m_folderID; }
set { m_folderID = value; }
}
[XmlIgnore] public PhysicsActor PhysActor = null;
/// <summary>
@ -67,14 +81,9 @@ namespace OpenSim.Region.Environment.Scenes
= new Dictionary<LLUUID, TaskInventoryItem>();
[XmlIgnore]
/// <summary>
/// Not really ideal to allow this to be set, but currently expedient for inserting a prim inventory
/// from persistence.
/// </summary>
public IDictionary<LLUUID, TaskInventoryItem> TaskInventory
{
get { return m_taskInventory; }
set { m_taskInventory = value; }
}
public LLUUID LastOwnerID;
@ -1059,6 +1068,10 @@ namespace OpenSim.Region.Environment.Scenes
#region Inventory
/// <summary>
/// Add an item to this prim's inventory.
/// </summary>
/// <param name="item"></param>
public void AddInventoryItem(TaskInventoryItem item)
{
item.parent_id = m_folderID;
@ -1068,6 +1081,21 @@ namespace OpenSim.Region.Environment.Scenes
m_inventorySerial++;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="items"></param>
public void AddInventoryItems(ICollection<TaskInventoryItem> items)
{
foreach (TaskInventoryItem item in items)
{
m_taskInventory.Add(item.item_id, item);
}
m_inventorySerial++;
}
public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
{
if (localID == LocalID)
@ -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,6 +1739,28 @@ namespace OpenSim.Region.Environment.Scenes
public class TaskInventoryItem
{
/// <summary>
/// Inventory types
/// </summary>
public static string[] InvTypes = new string[]
{
"texture",
"sound",
"",
"",
"",
"",
"",
"",
"",
"",
"lsl_text",
""
};
/// <summary>
/// Asset types
/// </summary>
public static string[] Types = new string[]
{
"texture",

View File

@ -340,18 +340,24 @@ namespace OpenSim.DataStore.MonoSqlite
String sql = String.Format("primID = '{0}'", prim.UUID.ToString());
DataRow[] dbItemRows = dbItems.Select(sql);
IDictionary<LLUUID, SceneObjectPart.TaskInventoryItem> inventory
= new Dictionary<LLUUID, SceneObjectPart.TaskInventoryItem>();
IList<SceneObjectPart.TaskInventoryItem> inventory = new List<SceneObjectPart.TaskInventoryItem>();
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)