aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Base
diff options
context:
space:
mode:
authorJohn Hurliman2010-02-19 15:28:35 -0800
committerJohn Hurliman2010-02-19 15:28:35 -0800
commiteb22fde96c53ee61f7173b94ce50b0faac14b235 (patch)
tree3184fe74931426ffd5351b6634a533559804d45b /OpenSim/Server/Base
parentMerge branch 'master' into presence-refactor (diff)
downloadopensim-SC_OLD-eb22fde96c53ee61f7173b94ce50b0faac14b235.zip
opensim-SC_OLD-eb22fde96c53ee61f7173b94ce50b0faac14b235.tar.gz
opensim-SC_OLD-eb22fde96c53ee61f7173b94ce50b0faac14b235.tar.bz2
opensim-SC_OLD-eb22fde96c53ee61f7173b94ce50b0faac14b235.tar.xz
* Fixed SL asset type enum to mime type conversion and added more helper functions for going back and forth between enums and mime types
Diffstat (limited to 'OpenSim/Server/Base')
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs197
1 files changed, 166 insertions, 31 deletions
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index e00eb2a..c79785f 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -34,56 +34,191 @@ using System.Text;
34using System.Collections.Generic; 34using System.Collections.Generic;
35using log4net; 35using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenMetaverse;
37 38
38namespace OpenSim.Server.Base 39namespace OpenSim.Server.Base
39{ 40{
40 public static class ServerUtils 41 public static class ServerUtils
41 { 42 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 44
45 #region SL / file extension / content-type conversions
46
44 public static string SLAssetTypeToContentType(int assetType) 47 public static string SLAssetTypeToContentType(int assetType)
45 { 48 {
46 switch (assetType) 49 switch ((AssetType)assetType)
47 { 50 {
48 case 0: 51 case AssetType.Texture:
49 return "image/jp2"; 52 return "image/x-j2c";
50 case 1: 53 case AssetType.Sound:
51 return "application/ogg"; 54 return "application/ogg";
52 case 2: 55 case AssetType.CallingCard:
53 return "application/x-metaverse-callingcard"; 56 return "application/vnd.ll.callingcard";
54 case 3: 57 case AssetType.Landmark:
55 return "application/x-metaverse-landmark"; 58 return "application/vnd.ll.landmark";
56 case 5: 59 case AssetType.Clothing:
57 return "application/x-metaverse-clothing"; 60 return "application/vnd.ll.clothing";
58 case 6: 61 case AssetType.Object:
59 return "application/x-metaverse-primitive"; 62 return "application/vnd.ll.primitive";
60 case 7: 63 case AssetType.Notecard:
61 return "application/x-metaverse-notecard"; 64 return "application/vnd.ll.notecard";
62 case 8: 65 case AssetType.Folder:
63 return "application/x-metaverse-folder"; 66 return "application/vnd.ll.folder";
64 case 10: 67 case AssetType.RootFolder:
65 return "application/x-metaverse-lsl"; 68 return "application/vnd.ll.rootfolder";
66 case 11: 69 case AssetType.LSLText:
67 return "application/x-metaverse-lso"; 70 return "application/vnd.ll.lsltext";
68 case 12: 71 case AssetType.LSLBytecode:
72 return "application/vnd.ll.lslbyte";
73 case AssetType.TextureTGA:
74 case AssetType.ImageTGA:
69 return "image/tga"; 75 return "image/tga";
70 case 13: 76 case AssetType.Bodypart:
71 return "application/x-metaverse-bodypart"; 77 return "application/vnd.ll.bodypart";
72 case 17: 78 case AssetType.TrashFolder:
79 return "application/vnd.ll.trashfolder";
80 case AssetType.SnapshotFolder:
81 return "application/vnd.ll.snapshotfolder";
82 case AssetType.LostAndFoundFolder:
83 return "application/vnd.ll.lostandfoundfolder";
84 case AssetType.SoundWAV:
73 return "audio/x-wav"; 85 return "audio/x-wav";
74 case 19: 86 case AssetType.ImageJPEG:
75 return "image/jpeg"; 87 return "image/jpeg";
76 case 20: 88 case AssetType.Animation:
77 return "application/x-metaverse-animation"; 89 return "application/vnd.ll.animation";
78 case 21: 90 case AssetType.Gesture:
79 return "application/x-metaverse-gesture"; 91 return "application/vnd.ll.gesture";
80 case 22: 92 case AssetType.Simstate:
81 return "application/x-metaverse-simstate"; 93 return "application/x-metaverse-simstate";
94 case AssetType.Unknown:
82 default: 95 default:
83 return "application/octet-stream"; 96 return "application/octet-stream";
84 } 97 }
85 } 98 }
86 99
100 public static sbyte ContentTypeToSLAssetType(string contentType)
101 {
102 switch (contentType)
103 {
104 case "image/x-j2c":
105 case "image/jp2":
106 return (sbyte)AssetType.Texture;
107 case "application/ogg":
108 return (sbyte)AssetType.Sound;
109 case "application/vnd.ll.callingcard":
110 case "application/x-metaverse-callingcard":
111 return (sbyte)AssetType.CallingCard;
112 case "application/vnd.ll.landmark":
113 case "application/x-metaverse-landmark":
114 return (sbyte)AssetType.Landmark;
115 case "application/vnd.ll.clothing":
116 case "application/x-metaverse-clothing":
117 return (sbyte)AssetType.Clothing;
118 case "application/vnd.ll.primitive":
119 case "application/x-metaverse-primitive":
120 return (sbyte)AssetType.Object;
121 case "application/vnd.ll.notecard":
122 case "application/x-metaverse-notecard":
123 return (sbyte)AssetType.Notecard;
124 case "application/vnd.ll.folder":
125 return (sbyte)AssetType.Folder;
126 case "application/vnd.ll.rootfolder":
127 return (sbyte)AssetType.RootFolder;
128 case "application/vnd.ll.lsltext":
129 case "application/x-metaverse-lsl":
130 return (sbyte)AssetType.LSLText;
131 case "application/vnd.ll.lslbyte":
132 case "application/x-metaverse-lso":
133 return (sbyte)AssetType.LSLBytecode;
134 case "image/tga":
135 // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA
136 return (sbyte)AssetType.ImageTGA;
137 case "application/vnd.ll.bodypart":
138 case "application/x-metaverse-bodypart":
139 return (sbyte)AssetType.Bodypart;
140 case "application/vnd.ll.trashfolder":
141 return (sbyte)AssetType.TrashFolder;
142 case "application/vnd.ll.snapshotfolder":
143 return (sbyte)AssetType.SnapshotFolder;
144 case "application/vnd.ll.lostandfoundfolder":
145 return (sbyte)AssetType.LostAndFoundFolder;
146 case "audio/x-wav":
147 return (sbyte)AssetType.SoundWAV;
148 case "image/jpeg":
149 return (sbyte)AssetType.ImageJPEG;
150 case "application/vnd.ll.animation":
151 case "application/x-metaverse-animation":
152 return (sbyte)AssetType.Animation;
153 case "application/vnd.ll.gesture":
154 case "application/x-metaverse-gesture":
155 return (sbyte)AssetType.Gesture;
156 case "application/x-metaverse-simstate":
157 return (sbyte)AssetType.Simstate;
158 case "application/octet-stream":
159 default:
160 return (sbyte)AssetType.Unknown;
161 }
162 }
163
164 public static sbyte ContentTypeToSLInvType(string contentType)
165 {
166 switch (contentType)
167 {
168 case "image/x-j2c":
169 case "image/jp2":
170 case "image/tga":
171 case "image/jpeg":
172 return (sbyte)InventoryType.Texture;
173 case "application/ogg":
174 case "audio/x-wav":
175 return (sbyte)InventoryType.Sound;
176 case "application/vnd.ll.callingcard":
177 case "application/x-metaverse-callingcard":
178 return (sbyte)InventoryType.CallingCard;
179 case "application/vnd.ll.landmark":
180 case "application/x-metaverse-landmark":
181 return (sbyte)InventoryType.Landmark;
182 case "application/vnd.ll.clothing":
183 case "application/x-metaverse-clothing":
184 case "application/vnd.ll.bodypart":
185 case "application/x-metaverse-bodypart":
186 return (sbyte)InventoryType.Wearable;
187 case "application/vnd.ll.primitive":
188 case "application/x-metaverse-primitive":
189 return (sbyte)InventoryType.Object;
190 case "application/vnd.ll.notecard":
191 case "application/x-metaverse-notecard":
192 return (sbyte)InventoryType.Notecard;
193 case "application/vnd.ll.folder":
194 return (sbyte)InventoryType.Folder;
195 case "application/vnd.ll.rootfolder":
196 return (sbyte)InventoryType.RootCategory;
197 case "application/vnd.ll.lsltext":
198 case "application/x-metaverse-lsl":
199 case "application/vnd.ll.lslbyte":
200 case "application/x-metaverse-lso":
201 return (sbyte)InventoryType.LSL;
202 case "application/vnd.ll.trashfolder":
203 case "application/vnd.ll.snapshotfolder":
204 case "application/vnd.ll.lostandfoundfolder":
205 return (sbyte)InventoryType.Folder;
206 case "application/vnd.ll.animation":
207 case "application/x-metaverse-animation":
208 return (sbyte)InventoryType.Animation;
209 case "application/vnd.ll.gesture":
210 case "application/x-metaverse-gesture":
211 return (sbyte)InventoryType.Gesture;
212 case "application/x-metaverse-simstate":
213 return (sbyte)InventoryType.Snapshot;
214 case "application/octet-stream":
215 default:
216 return (sbyte)InventoryType.Unknown;
217 }
218 }
219
220 #endregion SL / file extension / content-type conversions
221
87 public static byte[] SerializeResult(XmlSerializer xs, object data) 222 public static byte[] SerializeResult(XmlSerializer xs, object data)
88 { 223 {
89 MemoryStream ms = new MemoryStream(); 224 MemoryStream ms = new MemoryStream();