From 959872315f67a1a33a2bae7330749f7dd74a4774 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sat, 8 Aug 2015 12:12:50 -0700
Subject: WARNING: massive refactor to follow libomv's latest changes regarding
inventory folders. The newest version of libomv itself is committed here.
Basically, everything that was using the AssetType enum has been combed
through; many of those uses were changed to the new FolderType enum. This
means that from now on, [new] root folders have code 8 (FolderType.Root), as
the viewers expect, as opposed to 9, which was what we had been doing. Normal
folders are as they were, -1. Also now sending folder code 100 for Suitcase
folders to viewers, with no filter. All tests pass, but fingers crossed!
---
OpenSim/Framework/AssetBase.cs | 10 +---
OpenSim/Framework/InventoryFolderBase.cs | 3 +
OpenSim/Framework/InventoryItemBase.cs | 6 +-
OpenSim/Framework/SLUtil.cs | 68 ++++++++++++++--------
.../Framework/Serialization/ArchiveConstants.cs | 10 +---
OpenSim/Framework/Tests/AssetBaseTest.cs | 4 --
6 files changed, 53 insertions(+), 48 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs
index 153a1d0..2f04d2e 100644
--- a/OpenSim/Framework/AssetBase.cs
+++ b/OpenSim/Framework/AssetBase.cs
@@ -136,7 +136,7 @@ namespace OpenSim.Framework
get
{
return
- (Type == (sbyte) AssetType.Animation ||
+ (Type == (sbyte)AssetType.Animation ||
Type == (sbyte)AssetType.Gesture ||
Type == (sbyte)AssetType.Simstate ||
Type == (sbyte)AssetType.Unknown ||
@@ -146,13 +146,9 @@ namespace OpenSim.Framework
Type == (sbyte)AssetType.Texture ||
Type == (sbyte)AssetType.TextureTGA ||
Type == (sbyte)AssetType.Folder ||
- Type == (sbyte)AssetType.RootFolder ||
- Type == (sbyte)AssetType.LostAndFoundFolder ||
- Type == (sbyte)AssetType.SnapshotFolder ||
- Type == (sbyte)AssetType.TrashFolder ||
Type == (sbyte)AssetType.ImageJPEG ||
- Type == (sbyte) AssetType.ImageTGA ||
- Type == (sbyte) AssetType.LSLBytecode);
+ Type == (sbyte)AssetType.ImageTGA ||
+ Type == (sbyte)AssetType.LSLBytecode);
}
}
diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs
index b3457a6..fb66056 100644
--- a/OpenSim/Framework/InventoryFolderBase.cs
+++ b/OpenSim/Framework/InventoryFolderBase.cs
@@ -34,6 +34,9 @@ namespace OpenSim.Framework
///
public class InventoryFolderBase : InventoryNodeBase
{
+ public static readonly string ROOT_FOLDER_NAME = "My Inventory";
+ public static readonly string SUITCASE_FOLDER_NAME = "My Suitcase";
+
///
/// The folder this folder is contained in
///
diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs
index ce63ee0..f9fd752 100644
--- a/OpenSim/Framework/InventoryItemBase.cs
+++ b/OpenSim/Framework/InventoryItemBase.cs
@@ -34,11 +34,7 @@ namespace OpenSim.Framework
/// Inventory Item - contains all the properties associated with an individual inventory piece.
///
public class InventoryItemBase : InventoryNodeBase, ICloneable
- {
- public static readonly string SUITCASE_FOLDER_NAME = "My Suitcase";
- public static readonly sbyte SUITCASE_FOLDER_TYPE = 100;
- public static readonly sbyte SUITCASE_FOLDER_FAKE_TYPE = 8;
-
+ {
///
/// The inventory type of the item. This is slightly different from the asset type in some situations.
///
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs
index 027fc0e..e66d5be 100644
--- a/OpenSim/Framework/SLUtil.cs
+++ b/OpenSim/Framework/SLUtil.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Framework
private class TypeMapping
{
private sbyte assetType;
- private InventoryType inventoryType;
+ private sbyte inventoryType;
private string contentType;
private string contentType2;
private string extension;
@@ -79,7 +79,7 @@ namespace OpenSim.Framework
get { return AssetTypeFromCode(assetType); }
}
- public InventoryType InventoryType
+ public sbyte InventoryType
{
get { return inventoryType; }
}
@@ -99,7 +99,7 @@ namespace OpenSim.Framework
get { return extension; }
}
- private TypeMapping(sbyte assetType, InventoryType inventoryType, string contentType, string contentType2, string extension)
+ private TypeMapping(sbyte assetType, sbyte inventoryType, string contentType, string contentType2, string extension)
{
this.assetType = assetType;
this.inventoryType = inventoryType;
@@ -108,18 +108,28 @@ namespace OpenSim.Framework
this.extension = extension;
}
- public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension)
+ public TypeMapping(AssetType assetType, sbyte inventoryType, string contentType, string contentType2, string extension)
: this((sbyte)assetType, inventoryType, contentType, contentType2, extension)
{
}
+ public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension)
+ : this((sbyte)assetType, (sbyte)inventoryType, contentType, contentType2, extension)
+ {
+ }
+
public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension)
- : this((sbyte)assetType, inventoryType, contentType, null, extension)
+ : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
+ {
+ }
+
+ public TypeMapping(AssetType assetType, FolderType inventoryType, string contentType, string extension)
+ : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
{
}
public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, string contentType, string extension)
- : this((sbyte)assetType, inventoryType, contentType, null, extension)
+ : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
{
}
}
@@ -145,53 +155,65 @@ namespace OpenSim.Framework
new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"),
new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"),
new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"),
- new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"),
- new TypeMapping(AssetType.RootFolder, InventoryType.RootCategory, "application/vnd.ll.rootfolder", "rootfolder"),
new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"),
new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"),
new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"),
- new TypeMapping(AssetType.TrashFolder, InventoryType.Folder, "application/vnd.ll.trashfolder", "trashfolder"),
- new TypeMapping(AssetType.SnapshotFolder, InventoryType.Folder, "application/vnd.ll.snapshotfolder", "snapshotfolder"),
- new TypeMapping(AssetType.LostAndFoundFolder, InventoryType.Folder, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"),
new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"),
new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"),
new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"),
- new TypeMapping(AssetType.FavoriteFolder, InventoryType.Unknown, "application/vnd.ll.favoritefolder", "favoritefolder"),
new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"),
new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"),
- new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"),
- new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"),
- new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"),
new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm"),
+
+ // The next few items are about inventory folders
+ new TypeMapping(AssetType.Folder, FolderType.None, "application/vnd.ll.folder", "folder"),
+ new TypeMapping(AssetType.Folder, FolderType.Root, "application/vnd.ll.rootfolder", "rootfolder"),
+ new TypeMapping(AssetType.Folder, FolderType.Trash, "application/vnd.ll.trashfolder", "trashfolder"),
+ new TypeMapping(AssetType.Folder, FolderType.Snapshot, "application/vnd.ll.snapshotfolder", "snapshotfolder"),
+ new TypeMapping(AssetType.Folder, FolderType.LostAndFound, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"),
+ new TypeMapping(AssetType.Folder, FolderType.Favorites, "application/vnd.ll.favoritefolder", "favoritefolder"),
+ new TypeMapping(AssetType.Folder, FolderType.CurrentOutfit, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"),
+ new TypeMapping(AssetType.Folder, FolderType.Outfit, "application/vnd.ll.outfitfolder", "outfitfolder"),
+ new TypeMapping(AssetType.Folder, FolderType.MyOutfits, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"),
+ // This next mappping is an asset to inventory item mapping.
+ // Note: LL stores folders as assets of type Folder = 8, and it has a corresponding InventoryType = 8
+ // OpenSim doesn't store folders as assets, so this mapping should only be used when parsing things from the viewer to the server
+ new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"),
+
+ // OpenSim specific
new TypeMapping(OpenSimAssetType.Material, InventoryType.Unknown, "application/llsd+xml", "material")
};
private static Dictionary asset2Content;
private static Dictionary asset2Extension;
- private static Dictionary inventory2Content;
+ private static Dictionary inventory2Content;
private static Dictionary content2Asset;
- private static Dictionary content2Inventory;
+ private static Dictionary content2Inventory;
static SLUtil()
{
asset2Content = new Dictionary();
asset2Extension = new Dictionary();
- inventory2Content = new Dictionary();
+ inventory2Content = new Dictionary();
content2Asset = new Dictionary();
- content2Inventory = new Dictionary();
+ content2Inventory = new Dictionary();
foreach (TypeMapping mapping in MAPPINGS)
{
sbyte assetType = mapping.AssetTypeCode;
if (!asset2Content.ContainsKey(assetType))
asset2Content.Add(assetType, mapping.ContentType);
+
if (!asset2Extension.ContainsKey(assetType))
asset2Extension.Add(assetType, mapping.Extension);
+
if (!inventory2Content.ContainsKey(mapping.InventoryType))
inventory2Content.Add(mapping.InventoryType, mapping.ContentType);
+
if (!content2Asset.ContainsKey(mapping.ContentType))
content2Asset.Add(mapping.ContentType, assetType);
+
if (!content2Inventory.ContainsKey(mapping.ContentType))
content2Inventory.Add(mapping.ContentType, mapping.InventoryType);
@@ -216,8 +238,8 @@ namespace OpenSim.Framework
public static string SLInvTypeToContentType(int invType)
{
string contentType;
- if (!inventory2Content.TryGetValue((InventoryType)invType, out contentType))
- contentType = inventory2Content[InventoryType.Unknown];
+ if (!inventory2Content.TryGetValue((sbyte)invType, out contentType))
+ contentType = inventory2Content[(sbyte)InventoryType.Unknown];
return contentType;
}
@@ -231,9 +253,9 @@ namespace OpenSim.Framework
public static sbyte ContentTypeToSLInvType(string contentType)
{
- InventoryType invType;
+ sbyte invType;
if (!content2Inventory.TryGetValue(contentType, out invType))
- invType = InventoryType.Unknown;
+ invType = (sbyte)InventoryType.Unknown;
return (sbyte)invType;
}
diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs
index 73ebfae..ab3c285 100644
--- a/OpenSim/Framework/Serialization/ArchiveConstants.cs
+++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs
@@ -115,20 +115,16 @@ namespace OpenSim.Framework.Serialization
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageJPEG] = ASSET_EXTENSION_SEPARATOR + "image.jpg";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageTGA] = ASSET_EXTENSION_SEPARATOR + "image.tga";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Landmark] = ASSET_EXTENSION_SEPARATOR + "landmark.txt";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = ASSET_EXTENSION_SEPARATOR + "lostandfoundfolder.txt"; // Not sure if we'll ever see this
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLBytecode] = ASSET_EXTENSION_SEPARATOR + "bytecode.lso";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLText] = ASSET_EXTENSION_SEPARATOR + "script.lsl";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Mesh] = ASSET_EXTENSION_SEPARATOR + "mesh.llmesh";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = ASSET_EXTENSION_SEPARATOR + "notecard.txt";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = ASSET_EXTENSION_SEPARATOR + "object.xml";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = ASSET_EXTENSION_SEPARATOR + "rootfolder.txt"; // Not sure if we'll ever see this
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Simstate] = ASSET_EXTENSION_SEPARATOR + "simstate.bin"; // Not sure if we'll ever see this
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SnapshotFolder] = ASSET_EXTENSION_SEPARATOR + "snapshotfolder.txt"; // Not sure if we'll ever see this
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Sound] = ASSET_EXTENSION_SEPARATOR + "sound.ogg";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = ASSET_EXTENSION_SEPARATOR + "sound.wav";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2";
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"; // Not sure if we'll ever see this
ASSET_TYPE_TO_EXTENSION[(sbyte)OpenSimAssetType.Material] = ASSET_EXTENSION_SEPARATOR + "material.xml"; // Not sure if we'll ever see this
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation;
@@ -140,21 +136,17 @@ namespace OpenSim.Framework.Serialization
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "image.jpg"] = (sbyte)AssetType.ImageJPEG;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "image.tga"] = (sbyte)AssetType.ImageTGA;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "landmark.txt"] = (sbyte)AssetType.Landmark;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "lostandfoundfolder.txt"] = (sbyte)AssetType.LostAndFoundFolder;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bytecode.lso"] = (sbyte)AssetType.LSLBytecode;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "script.lsl"] = (sbyte)AssetType.LSLText;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "mesh.llmesh"] = (sbyte)AssetType.Mesh;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "notecard.txt"] = (sbyte)AssetType.Notecard;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "object.xml"] = (sbyte)AssetType.Object;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "rootfolder.txt"] = (sbyte)AssetType.RootFolder;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "simstate.bin"] = (sbyte)AssetType.Simstate;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "snapshotfolder.txt"] = (sbyte)AssetType.SnapshotFolder;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.ogg"] = (sbyte)AssetType.Sound;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.wav"] = (sbyte)AssetType.SoundWAV;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture;
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)OpenSimAssetType.Material;
+ EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)OpenSimAssetType.Material;
}
public static string CreateOarLandDataPath(LandData ld)
diff --git a/OpenSim/Framework/Tests/AssetBaseTest.cs b/OpenSim/Framework/Tests/AssetBaseTest.cs
index 25d2393..1975a4d 100644
--- a/OpenSim/Framework/Tests/AssetBaseTest.cs
+++ b/OpenSim/Framework/Tests/AssetBaseTest.cs
@@ -50,19 +50,15 @@ namespace OpenSim.Framework.Tests
CheckContainsReferences(AssetType.ImageJPEG , false);
CheckContainsReferences(AssetType.ImageTGA , false);
CheckContainsReferences(AssetType.Landmark , false);
- CheckContainsReferences(AssetType.LostAndFoundFolder, false);
CheckContainsReferences(AssetType.LSLBytecode, false);
CheckContainsReferences(AssetType.LSLText, false);
CheckContainsReferences(AssetType.Notecard, false);
CheckContainsReferences(AssetType.Object, false);
- CheckContainsReferences(AssetType.RootFolder, false);
CheckContainsReferences(AssetType.Simstate, false);
- CheckContainsReferences(AssetType.SnapshotFolder, false);
CheckContainsReferences(AssetType.Sound, false);
CheckContainsReferences(AssetType.SoundWAV, false);
CheckContainsReferences(AssetType.Texture, false);
CheckContainsReferences(AssetType.TextureTGA, false);
- CheckContainsReferences(AssetType.TrashFolder, false);
CheckContainsReferences(AssetType.Unknown, false);
}
--
cgit v1.1