aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/SLUtil.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/SLUtil.cs')
-rw-r--r--OpenSim/Framework/SLUtil.cs68
1 files changed, 45 insertions, 23 deletions
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
64 private class TypeMapping 64 private class TypeMapping
65 { 65 {
66 private sbyte assetType; 66 private sbyte assetType;
67 private InventoryType inventoryType; 67 private sbyte inventoryType;
68 private string contentType; 68 private string contentType;
69 private string contentType2; 69 private string contentType2;
70 private string extension; 70 private string extension;
@@ -79,7 +79,7 @@ namespace OpenSim.Framework
79 get { return AssetTypeFromCode(assetType); } 79 get { return AssetTypeFromCode(assetType); }
80 } 80 }
81 81
82 public InventoryType InventoryType 82 public sbyte InventoryType
83 { 83 {
84 get { return inventoryType; } 84 get { return inventoryType; }
85 } 85 }
@@ -99,7 +99,7 @@ namespace OpenSim.Framework
99 get { return extension; } 99 get { return extension; }
100 } 100 }
101 101
102 private TypeMapping(sbyte assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) 102 private TypeMapping(sbyte assetType, sbyte inventoryType, string contentType, string contentType2, string extension)
103 { 103 {
104 this.assetType = assetType; 104 this.assetType = assetType;
105 this.inventoryType = inventoryType; 105 this.inventoryType = inventoryType;
@@ -108,18 +108,28 @@ namespace OpenSim.Framework
108 this.extension = extension; 108 this.extension = extension;
109 } 109 }
110 110
111 public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) 111 public TypeMapping(AssetType assetType, sbyte inventoryType, string contentType, string contentType2, string extension)
112 : this((sbyte)assetType, inventoryType, contentType, contentType2, extension) 112 : this((sbyte)assetType, inventoryType, contentType, contentType2, extension)
113 { 113 {
114 } 114 }
115 115
116 public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension)
117 : this((sbyte)assetType, (sbyte)inventoryType, contentType, contentType2, extension)
118 {
119 }
120
116 public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension) 121 public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension)
117 : this((sbyte)assetType, inventoryType, contentType, null, extension) 122 : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
123 {
124 }
125
126 public TypeMapping(AssetType assetType, FolderType inventoryType, string contentType, string extension)
127 : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
118 { 128 {
119 } 129 }
120 130
121 public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, string contentType, string extension) 131 public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, string contentType, string extension)
122 : this((sbyte)assetType, inventoryType, contentType, null, extension) 132 : this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
123 { 133 {
124 } 134 }
125 } 135 }
@@ -145,53 +155,65 @@ namespace OpenSim.Framework
145 new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), 155 new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"),
146 new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), 156 new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"),
147 new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"), 157 new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"),
148 new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"),
149 new TypeMapping(AssetType.RootFolder, InventoryType.RootCategory, "application/vnd.ll.rootfolder", "rootfolder"),
150 new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"), 158 new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"),
151 new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"), 159 new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"),
152 new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"), 160 new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"),
153 new TypeMapping(AssetType.TrashFolder, InventoryType.Folder, "application/vnd.ll.trashfolder", "trashfolder"),
154 new TypeMapping(AssetType.SnapshotFolder, InventoryType.Folder, "application/vnd.ll.snapshotfolder", "snapshotfolder"),
155 new TypeMapping(AssetType.LostAndFoundFolder, InventoryType.Folder, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"),
156 new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"), 161 new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"),
157 new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"), 162 new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"),
158 new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"), 163 new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"),
159 new TypeMapping(AssetType.FavoriteFolder, InventoryType.Unknown, "application/vnd.ll.favoritefolder", "favoritefolder"),
160 new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"), 164 new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"),
161 new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"), 165 new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"),
162 new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"),
163 new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"),
164 new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"),
165 new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm"), 166 new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm"),
167
168 // The next few items are about inventory folders
169 new TypeMapping(AssetType.Folder, FolderType.None, "application/vnd.ll.folder", "folder"),
170 new TypeMapping(AssetType.Folder, FolderType.Root, "application/vnd.ll.rootfolder", "rootfolder"),
171 new TypeMapping(AssetType.Folder, FolderType.Trash, "application/vnd.ll.trashfolder", "trashfolder"),
172 new TypeMapping(AssetType.Folder, FolderType.Snapshot, "application/vnd.ll.snapshotfolder", "snapshotfolder"),
173 new TypeMapping(AssetType.Folder, FolderType.LostAndFound, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"),
174 new TypeMapping(AssetType.Folder, FolderType.Favorites, "application/vnd.ll.favoritefolder", "favoritefolder"),
175 new TypeMapping(AssetType.Folder, FolderType.CurrentOutfit, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"),
176 new TypeMapping(AssetType.Folder, FolderType.Outfit, "application/vnd.ll.outfitfolder", "outfitfolder"),
177 new TypeMapping(AssetType.Folder, FolderType.MyOutfits, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"),
166 178
179 // This next mappping is an asset to inventory item mapping.
180 // Note: LL stores folders as assets of type Folder = 8, and it has a corresponding InventoryType = 8
181 // OpenSim doesn't store folders as assets, so this mapping should only be used when parsing things from the viewer to the server
182 new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"),
183
184 // OpenSim specific
167 new TypeMapping(OpenSimAssetType.Material, InventoryType.Unknown, "application/llsd+xml", "material") 185 new TypeMapping(OpenSimAssetType.Material, InventoryType.Unknown, "application/llsd+xml", "material")
168 }; 186 };
169 187
170 private static Dictionary<sbyte, string> asset2Content; 188 private static Dictionary<sbyte, string> asset2Content;
171 private static Dictionary<sbyte, string> asset2Extension; 189 private static Dictionary<sbyte, string> asset2Extension;
172 private static Dictionary<InventoryType, string> inventory2Content; 190 private static Dictionary<sbyte, string> inventory2Content;
173 private static Dictionary<string, sbyte> content2Asset; 191 private static Dictionary<string, sbyte> content2Asset;
174 private static Dictionary<string, InventoryType> content2Inventory; 192 private static Dictionary<string, sbyte> content2Inventory;
175 193
176 static SLUtil() 194 static SLUtil()
177 { 195 {
178 asset2Content = new Dictionary<sbyte, string>(); 196 asset2Content = new Dictionary<sbyte, string>();
179 asset2Extension = new Dictionary<sbyte, string>(); 197 asset2Extension = new Dictionary<sbyte, string>();
180 inventory2Content = new Dictionary<InventoryType, string>(); 198 inventory2Content = new Dictionary<sbyte, string>();
181 content2Asset = new Dictionary<string, sbyte>(); 199 content2Asset = new Dictionary<string, sbyte>();
182 content2Inventory = new Dictionary<string, InventoryType>(); 200 content2Inventory = new Dictionary<string, sbyte>();
183 201
184 foreach (TypeMapping mapping in MAPPINGS) 202 foreach (TypeMapping mapping in MAPPINGS)
185 { 203 {
186 sbyte assetType = mapping.AssetTypeCode; 204 sbyte assetType = mapping.AssetTypeCode;
187 if (!asset2Content.ContainsKey(assetType)) 205 if (!asset2Content.ContainsKey(assetType))
188 asset2Content.Add(assetType, mapping.ContentType); 206 asset2Content.Add(assetType, mapping.ContentType);
207
189 if (!asset2Extension.ContainsKey(assetType)) 208 if (!asset2Extension.ContainsKey(assetType))
190 asset2Extension.Add(assetType, mapping.Extension); 209 asset2Extension.Add(assetType, mapping.Extension);
210
191 if (!inventory2Content.ContainsKey(mapping.InventoryType)) 211 if (!inventory2Content.ContainsKey(mapping.InventoryType))
192 inventory2Content.Add(mapping.InventoryType, mapping.ContentType); 212 inventory2Content.Add(mapping.InventoryType, mapping.ContentType);
213
193 if (!content2Asset.ContainsKey(mapping.ContentType)) 214 if (!content2Asset.ContainsKey(mapping.ContentType))
194 content2Asset.Add(mapping.ContentType, assetType); 215 content2Asset.Add(mapping.ContentType, assetType);
216
195 if (!content2Inventory.ContainsKey(mapping.ContentType)) 217 if (!content2Inventory.ContainsKey(mapping.ContentType))
196 content2Inventory.Add(mapping.ContentType, mapping.InventoryType); 218 content2Inventory.Add(mapping.ContentType, mapping.InventoryType);
197 219
@@ -216,8 +238,8 @@ namespace OpenSim.Framework
216 public static string SLInvTypeToContentType(int invType) 238 public static string SLInvTypeToContentType(int invType)
217 { 239 {
218 string contentType; 240 string contentType;
219 if (!inventory2Content.TryGetValue((InventoryType)invType, out contentType)) 241 if (!inventory2Content.TryGetValue((sbyte)invType, out contentType))
220 contentType = inventory2Content[InventoryType.Unknown]; 242 contentType = inventory2Content[(sbyte)InventoryType.Unknown];
221 return contentType; 243 return contentType;
222 } 244 }
223 245
@@ -231,9 +253,9 @@ namespace OpenSim.Framework
231 253
232 public static sbyte ContentTypeToSLInvType(string contentType) 254 public static sbyte ContentTypeToSLInvType(string contentType)
233 { 255 {
234 InventoryType invType; 256 sbyte invType;
235 if (!content2Inventory.TryGetValue(contentType, out invType)) 257 if (!content2Inventory.TryGetValue(contentType, out invType))
236 invType = InventoryType.Unknown; 258 invType = (sbyte)InventoryType.Unknown;
237 return (sbyte)invType; 259 return (sbyte)invType;
238 } 260 }
239 261