From 1d234ca83f64b31b559ace3f63ebbba9f4903778 Mon Sep 17 00:00:00 2001
From: Homer Horwitz
Date: Sat, 9 May 2009 21:11:12 +0000
Subject: Fixed handling of inventory a bit - AssetType isn't InventoryType.
Those enums contain different numbers. Use AssetType for the asset type,
InventoryType for the inventory type. - The ToString method (or ToLower) of
AssetType/InventoryType doesn't necessarily return the correct LLSD string. -
Replaced several magic numbers by their corresponding enum. - Fixed the
invType for gestures and animations in the library. This should fix Mantis
#3610 and the non-terminating inventory loading
---
.../Rest/Inventory/RestInventoryServices.cs | 16 +++++------
.../Framework/Communications/Capabilities/Caps.cs | 14 ++++++++--
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 6 ++--
.../Framework/Scenes/SceneObjectPartInventory.cs | 10 +++----
.../Shared/Api/Implementation/OSSL_Api.cs | 4 +--
.../AnimationsLibrary/AnimationsLibraryItems.xml | 24 ++++++++--------
.../GesturesLibrary/GesturesLibraryItems.xml | 32 +++++++++++-----------
7 files changed, 57 insertions(+), 49 deletions(-)
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index ae242bd..5de44b6 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -2045,7 +2045,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
// good as having type be specified in the XML.
if (ic.Item.AssetType == (int) AssetType.Unknown ||
- ic.Item.InvType == (int) AssetType.Unknown)
+ ic.Item.InvType == (int) InventoryType.Unknown)
{
Rest.Log.DebugFormat("{0} Attempting to infer item type", MsgId);
@@ -2078,8 +2078,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
MsgId, parts[parts.Length-1]);
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.ImageJPEG;
- if (ic.Item.InvType == (int) AssetType.Unknown)
- ic.Item.InvType = (int) AssetType.ImageJPEG;
+ if (ic.Item.InvType == (int) InventoryType.Unknown)
+ ic.Item.InvType = (int) InventoryType.Texture;
break;
case "jpg" :
case "jpeg" :
@@ -2087,8 +2087,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
MsgId, parts[parts.Length - 1]);
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.ImageJPEG;
- if (ic.Item.InvType == (int) AssetType.Unknown)
- ic.Item.InvType = (int) AssetType.ImageJPEG;
+ if (ic.Item.InvType == (int) InventoryType.Unknown)
+ ic.Item.InvType = (int) InventoryType.Texture;
break;
case "tga" :
if (parts[parts.Length - 2].IndexOf("_texture") != -1)
@@ -2096,14 +2096,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.TextureTGA;
if (ic.Item.InvType == (int) AssetType.Unknown)
- ic.Item.InvType = (int) AssetType.TextureTGA;
+ ic.Item.InvType = (int) InventoryType.Texture;
}
else
{
if (ic.Item.AssetType == (int) AssetType.Unknown)
ic.Item.AssetType = (int) AssetType.ImageTGA;
- if (ic.Item.InvType == (int) AssetType.Unknown)
- ic.Item.InvType = (int) AssetType.ImageTGA;
+ if (ic.Item.InvType == (int) InventoryType.Unknown)
+ ic.Item.InvType = (int) InventoryType.Snapshot;
}
break;
default :
diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs
index 5809455..6e005b7 100644
--- a/OpenSim/Framework/Communications/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs
@@ -365,7 +365,7 @@ namespace OpenSim.Framework.Communications.Capabilities
public string FetchInventoryDescendentsRequest(string request, string path, string param,OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
- m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + "request is "+request);
+ m_log.Debug("[CAPS]: FetchInventoryDescendentsRequest in region: " + m_regionName + " request is "+request);
// nasty temporary hack here, the linden client falsely identifies the uuid 00000000-0000-0000-0000-000000000000 as a string which breaks us
// correctly mark it as a uuid
@@ -512,8 +512,16 @@ namespace OpenSim.Framework.Communications.Capabilities
llsdItem.item_id = invItem.ID;
llsdItem.name = invItem.Name;
llsdItem.parent_id = invItem.Folder;
- llsdItem.type = Enum.GetName(typeof(AssetType), invItem.AssetType).ToLower();
- llsdItem.inv_type = Enum.GetName(typeof(InventoryType), invItem.InvType).ToLower();
+ try
+ {
+ // TODO reevaluate after upgrade to libomv >= r2566. Probably should use UtilsConversions.
+ llsdItem.type = TaskInventoryItem.Types[invItem.AssetType];
+ llsdItem.inv_type = TaskInventoryItem.InvTypes[invItem.InvType];
+ }
+ catch (Exception e)
+ {
+ m_log.Error("[CAPS]: Problem setting asset/inventory type while converting inventory item " + invItem.Name + " to LLSD:", e);
+ }
llsdItem.permissions = new LLSDPermissions();
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 88416d3..1dcdc06 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -490,7 +490,7 @@ namespace OpenSim.Region.Framework.Scenes
if (Permissions.PropagatePermissions())
{
- if (item.InvType == 6)
+ if (item.InvType == (int)InventoryType.Object)
{
itemCopy.BasePermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
itemCopy.BasePermissions |= (item.CurrentPermissions & 7) << 13;
@@ -899,7 +899,7 @@ namespace OpenSim.Region.Framework.Scenes
TryGetAvatar(remoteClient.AgentId, out presence);
byte[] data = null;
- if (invType == 3 && presence != null) // OpenMetaverse.asset.assettype.landmark = 3 - needs to be turned into an enum
+ if (invType == (sbyte)InventoryType.Landmark && presence != null)
{
Vector3 pos = presence.AbsolutePosition;
string strdata = String.Format(
@@ -1098,7 +1098,7 @@ namespace OpenSim.Region.Framework.Scenes
if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions())
{
- if (taskItem.InvType == 6)
+ if (taskItem.InvType == (int)InventoryType.Object)
agentItem.BasePermissions = taskItem.BasePermissions & ((taskItem.CurrentPermissions & 7) << 13);
else
agentItem.BasePermissions = taskItem.BasePermissions;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 6bf1654..d03fec2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -776,7 +776,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (TaskInventoryItem item in m_items.Values)
{
- if (item.InvType != 6)
+ if (item.InvType != (int)InventoryType.Object)
{
if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0)
mask &= ~((uint)PermissionMask.Copy >> 13);
@@ -809,7 +809,7 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (TaskInventoryItem item in m_items.Values)
{
- if (item.InvType == 6 && (item.CurrentPermissions & 7) != 0)
+ if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
{
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
@@ -840,7 +840,7 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (TaskInventoryItem item in m_items.Values)
{
- if (item.InvType == 10)
+ if (item.InvType == (int)InventoryType.LSL)
{
return true;
}
@@ -866,7 +866,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (TaskInventoryItem item in m_items.Values)
{
- if (item.InvType == 10)
+ if (item.InvType == (int)InventoryType.LSL)
{
foreach (IScriptModule e in engines)
{
@@ -890,7 +890,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (TaskInventoryItem item in m_items.Values)
{
- if (item.InvType == 10)
+ if (item.InvType == (int)InventoryType.LSL)
{
foreach (IScriptModule e in engines)
{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 1cd25e7..e5c59aa 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1351,8 +1351,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch();
taskItem.Name = asset.Name;
taskItem.Description = asset.Description;
- taskItem.Type = 7;
- taskItem.InvType = 7;
+ taskItem.Type = (int)AssetType.Notecard;
+ taskItem.InvType = (int)InventoryType.Notecard;
taskItem.OwnerID = m_host.OwnerID;
taskItem.CreatorID = m_host.OwnerID;
taskItem.BasePermissions = (uint)PermissionMask.All;
diff --git a/bin/inventory/AnimationsLibrary/AnimationsLibraryItems.xml b/bin/inventory/AnimationsLibrary/AnimationsLibraryItems.xml
index 7b62a78..2a6ceb4 100644
--- a/bin/inventory/AnimationsLibrary/AnimationsLibraryItems.xml
+++ b/bin/inventory/AnimationsLibrary/AnimationsLibraryItems.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/bin/inventory/GesturesLibrary/GesturesLibraryItems.xml b/bin/inventory/GesturesLibrary/GesturesLibraryItems.xml
index de96f7b..1312129 100644
--- a/bin/inventory/GesturesLibrary/GesturesLibraryItems.xml
+++ b/bin/inventory/GesturesLibrary/GesturesLibraryItems.xml
@@ -6,7 +6,7 @@
-
+
@@ -19,7 +19,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
@@ -45,7 +45,7 @@
-
+
@@ -58,7 +58,7 @@
-
+
@@ -71,7 +71,7 @@
-
+
@@ -84,7 +84,7 @@
-
+
@@ -97,7 +97,7 @@
-
+
@@ -110,7 +110,7 @@
-
+
@@ -123,7 +123,7 @@
-
+
@@ -136,7 +136,7 @@
-
+
@@ -149,7 +149,7 @@
-
+
@@ -162,7 +162,7 @@
-
+
@@ -175,7 +175,7 @@
-
+
@@ -188,7 +188,7 @@
-
+
@@ -201,7 +201,7 @@
-
+
--
cgit v1.1