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.cs185
1 files changed, 185 insertions, 0 deletions
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs
new file mode 100644
index 0000000..9d5c30a
--- /dev/null
+++ b/OpenSim/Framework/SLUtil.cs
@@ -0,0 +1,185 @@
1using System;
2using OpenMetaverse;
3
4namespace OpenSim.Framework
5{
6 public static class SLUtil
7 {
8 #region SL / file extension / content-type conversions
9
10 public static string SLAssetTypeToContentType(int assetType)
11 {
12 switch ((AssetType)assetType)
13 {
14 case AssetType.Texture:
15 return "image/x-j2c";
16 case AssetType.Sound:
17 return "application/ogg";
18 case AssetType.CallingCard:
19 return "application/vnd.ll.callingcard";
20 case AssetType.Landmark:
21 return "application/vnd.ll.landmark";
22 case AssetType.Clothing:
23 return "application/vnd.ll.clothing";
24 case AssetType.Object:
25 return "application/vnd.ll.primitive";
26 case AssetType.Notecard:
27 return "application/vnd.ll.notecard";
28 case AssetType.Folder:
29 return "application/vnd.ll.folder";
30 case AssetType.RootFolder:
31 return "application/vnd.ll.rootfolder";
32 case AssetType.LSLText:
33 return "application/vnd.ll.lsltext";
34 case AssetType.LSLBytecode:
35 return "application/vnd.ll.lslbyte";
36 case AssetType.TextureTGA:
37 case AssetType.ImageTGA:
38 return "image/tga";
39 case AssetType.Bodypart:
40 return "application/vnd.ll.bodypart";
41 case AssetType.TrashFolder:
42 return "application/vnd.ll.trashfolder";
43 case AssetType.SnapshotFolder:
44 return "application/vnd.ll.snapshotfolder";
45 case AssetType.LostAndFoundFolder:
46 return "application/vnd.ll.lostandfoundfolder";
47 case AssetType.SoundWAV:
48 return "audio/x-wav";
49 case AssetType.ImageJPEG:
50 return "image/jpeg";
51 case AssetType.Animation:
52 return "application/vnd.ll.animation";
53 case AssetType.Gesture:
54 return "application/vnd.ll.gesture";
55 case AssetType.Simstate:
56 return "application/x-metaverse-simstate";
57 case AssetType.Unknown:
58 default:
59 return "application/octet-stream";
60 }
61 }
62
63 public static sbyte ContentTypeToSLAssetType(string contentType)
64 {
65 switch (contentType)
66 {
67 case "image/x-j2c":
68 case "image/jp2":
69 return (sbyte)AssetType.Texture;
70 case "application/ogg":
71 return (sbyte)AssetType.Sound;
72 case "application/vnd.ll.callingcard":
73 case "application/x-metaverse-callingcard":
74 return (sbyte)AssetType.CallingCard;
75 case "application/vnd.ll.landmark":
76 case "application/x-metaverse-landmark":
77 return (sbyte)AssetType.Landmark;
78 case "application/vnd.ll.clothing":
79 case "application/x-metaverse-clothing":
80 return (sbyte)AssetType.Clothing;
81 case "application/vnd.ll.primitive":
82 case "application/x-metaverse-primitive":
83 return (sbyte)AssetType.Object;
84 case "application/vnd.ll.notecard":
85 case "application/x-metaverse-notecard":
86 return (sbyte)AssetType.Notecard;
87 case "application/vnd.ll.folder":
88 return (sbyte)AssetType.Folder;
89 case "application/vnd.ll.rootfolder":
90 return (sbyte)AssetType.RootFolder;
91 case "application/vnd.ll.lsltext":
92 case "application/x-metaverse-lsl":
93 return (sbyte)AssetType.LSLText;
94 case "application/vnd.ll.lslbyte":
95 case "application/x-metaverse-lso":
96 return (sbyte)AssetType.LSLBytecode;
97 case "image/tga":
98 // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA
99 return (sbyte)AssetType.ImageTGA;
100 case "application/vnd.ll.bodypart":
101 case "application/x-metaverse-bodypart":
102 return (sbyte)AssetType.Bodypart;
103 case "application/vnd.ll.trashfolder":
104 return (sbyte)AssetType.TrashFolder;
105 case "application/vnd.ll.snapshotfolder":
106 return (sbyte)AssetType.SnapshotFolder;
107 case "application/vnd.ll.lostandfoundfolder":
108 return (sbyte)AssetType.LostAndFoundFolder;
109 case "audio/x-wav":
110 return (sbyte)AssetType.SoundWAV;
111 case "image/jpeg":
112 return (sbyte)AssetType.ImageJPEG;
113 case "application/vnd.ll.animation":
114 case "application/x-metaverse-animation":
115 return (sbyte)AssetType.Animation;
116 case "application/vnd.ll.gesture":
117 case "application/x-metaverse-gesture":
118 return (sbyte)AssetType.Gesture;
119 case "application/x-metaverse-simstate":
120 return (sbyte)AssetType.Simstate;
121 case "application/octet-stream":
122 default:
123 return (sbyte)AssetType.Unknown;
124 }
125 }
126
127 public static sbyte ContentTypeToSLInvType(string contentType)
128 {
129 switch (contentType)
130 {
131 case "image/x-j2c":
132 case "image/jp2":
133 case "image/tga":
134 case "image/jpeg":
135 return (sbyte)InventoryType.Texture;
136 case "application/ogg":
137 case "audio/x-wav":
138 return (sbyte)InventoryType.Sound;
139 case "application/vnd.ll.callingcard":
140 case "application/x-metaverse-callingcard":
141 return (sbyte)InventoryType.CallingCard;
142 case "application/vnd.ll.landmark":
143 case "application/x-metaverse-landmark":
144 return (sbyte)InventoryType.Landmark;
145 case "application/vnd.ll.clothing":
146 case "application/x-metaverse-clothing":
147 case "application/vnd.ll.bodypart":
148 case "application/x-metaverse-bodypart":
149 return (sbyte)InventoryType.Wearable;
150 case "application/vnd.ll.primitive":
151 case "application/x-metaverse-primitive":
152 return (sbyte)InventoryType.Object;
153 case "application/vnd.ll.notecard":
154 case "application/x-metaverse-notecard":
155 return (sbyte)InventoryType.Notecard;
156 case "application/vnd.ll.folder":
157 return (sbyte)InventoryType.Folder;
158 case "application/vnd.ll.rootfolder":
159 return (sbyte)InventoryType.RootCategory;
160 case "application/vnd.ll.lsltext":
161 case "application/x-metaverse-lsl":
162 case "application/vnd.ll.lslbyte":
163 case "application/x-metaverse-lso":
164 return (sbyte)InventoryType.LSL;
165 case "application/vnd.ll.trashfolder":
166 case "application/vnd.ll.snapshotfolder":
167 case "application/vnd.ll.lostandfoundfolder":
168 return (sbyte)InventoryType.Folder;
169 case "application/vnd.ll.animation":
170 case "application/x-metaverse-animation":
171 return (sbyte)InventoryType.Animation;
172 case "application/vnd.ll.gesture":
173 case "application/x-metaverse-gesture":
174 return (sbyte)InventoryType.Gesture;
175 case "application/x-metaverse-simstate":
176 return (sbyte)InventoryType.Snapshot;
177 case "application/octet-stream":
178 default:
179 return (sbyte)InventoryType.Unknown;
180 }
181 }
182
183 #endregion SL / file extension / content-type conversions
184 }
185}