aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJohn Hurliman2010-02-20 16:21:13 -0800
committerJohn Hurliman2010-02-20 16:21:13 -0800
commit845a390e9308f6b6823c85ac319ecb211f968d4b (patch)
tree7cc28abeb9396c845db7c3a8f4f04a4eb17af685 /OpenSim
parent* Fixed SL asset type enum to mime type conversion and added more helper func... (diff)
downloadopensim-SC-845a390e9308f6b6823c85ac319ecb211f968d4b.zip
opensim-SC-845a390e9308f6b6823c85ac319ecb211f968d4b.tar.gz
opensim-SC-845a390e9308f6b6823c85ac319ecb211f968d4b.tar.bz2
opensim-SC-845a390e9308f6b6823c85ac319ecb211f968d4b.tar.xz
* Added a sanity check for missing asset data in LLClientView
* Moved the SL asset type to content type conversion methods from ServerUtils to OpenSim.Framework.SLUtil * Linked content type to asset type in AssetMetadata
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/AssetBase.cs17
-rw-r--r--OpenSim/Framework/SLUtil.cs185
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs10
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs177
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs4
5 files changed, 212 insertions, 181 deletions
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs
index 212f41d..3e64e47 100644
--- a/OpenSim/Framework/AssetBase.cs
+++ b/OpenSim/Framework/AssetBase.cs
@@ -289,8 +289,21 @@ namespace OpenSim.Framework
289 289
290 public string ContentType 290 public string ContentType
291 { 291 {
292 get { return m_content_type; } 292 get
293 set { m_content_type = value; } 293 {
294 if (!String.IsNullOrEmpty(m_content_type))
295 return m_content_type;
296 else
297 return SLUtil.SLAssetTypeToContentType(m_type);
298 }
299 set
300 {
301 m_content_type = value;
302
303 sbyte type = (sbyte)SLUtil.ContentTypeToSLAssetType(value);
304 if (type != -1)
305 m_type = type;
306 }
294 } 307 }
295 308
296 public byte[] SHA1 309 public byte[] SHA1
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}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 0df1748..1f5946b 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -2533,6 +2533,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2533 2533
2534 public void SendAsset(AssetRequestToClient req) 2534 public void SendAsset(AssetRequestToClient req)
2535 { 2535 {
2536 if (req.AssetInf.Data == null)
2537 {
2538 m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
2539 req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
2540 return;
2541 }
2542
2536 //m_log.Debug("sending asset " + req.RequestAssetID); 2543 //m_log.Debug("sending asset " + req.RequestAssetID);
2537 TransferInfoPacket Transfer = new TransferInfoPacket(); 2544 TransferInfoPacket Transfer = new TransferInfoPacket();
2538 Transfer.TransferInfo.ChannelType = 2; 2545 Transfer.TransferInfo.ChannelType = 2;
@@ -16193,6 +16200,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
16193 const uint m_maxPacketSize = 600; 16200 const uint m_maxPacketSize = 600;
16194 int numPackets = 1; 16201 int numPackets = 1;
16195 16202
16203 if (data == null)
16204 return 0;
16205
16196 if (data.LongLength > m_maxPacketSize) 16206 if (data.LongLength > m_maxPacketSize)
16197 { 16207 {
16198 // over max number of bytes so split up file 16208 // over max number of bytes so split up file
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index c79785f..2fbcea4 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -42,183 +42,6 @@ namespace OpenSim.Server.Base
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 #region SL / file extension / content-type conversions
46
47 public static string SLAssetTypeToContentType(int assetType)
48 {
49 switch ((AssetType)assetType)
50 {
51 case AssetType.Texture:
52 return "image/x-j2c";
53 case AssetType.Sound:
54 return "application/ogg";
55 case AssetType.CallingCard:
56 return "application/vnd.ll.callingcard";
57 case AssetType.Landmark:
58 return "application/vnd.ll.landmark";
59 case AssetType.Clothing:
60 return "application/vnd.ll.clothing";
61 case AssetType.Object:
62 return "application/vnd.ll.primitive";
63 case AssetType.Notecard:
64 return "application/vnd.ll.notecard";
65 case AssetType.Folder:
66 return "application/vnd.ll.folder";
67 case AssetType.RootFolder:
68 return "application/vnd.ll.rootfolder";
69 case AssetType.LSLText:
70 return "application/vnd.ll.lsltext";
71 case AssetType.LSLBytecode:
72 return "application/vnd.ll.lslbyte";
73 case AssetType.TextureTGA:
74 case AssetType.ImageTGA:
75 return "image/tga";
76 case AssetType.Bodypart:
77 return "application/vnd.ll.bodypart";
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:
85 return "audio/x-wav";
86 case AssetType.ImageJPEG:
87 return "image/jpeg";
88 case AssetType.Animation:
89 return "application/vnd.ll.animation";
90 case AssetType.Gesture:
91 return "application/vnd.ll.gesture";
92 case AssetType.Simstate:
93 return "application/x-metaverse-simstate";
94 case AssetType.Unknown:
95 default:
96 return "application/octet-stream";
97 }
98 }
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
222 public static byte[] SerializeResult(XmlSerializer xs, object data) 45 public static byte[] SerializeResult(XmlSerializer xs, object data)
223 { 46 {
224 MemoryStream ms = new MemoryStream(); 47 MemoryStream ms = new MemoryStream();
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
index fe0da0b..43c1693 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
@@ -91,7 +91,7 @@ namespace OpenSim.Server.Handlers.Asset
91 91
92 httpResponse.StatusCode = (int)HttpStatusCode.OK; 92 httpResponse.StatusCode = (int)HttpStatusCode.OK;
93 httpResponse.ContentType = 93 httpResponse.ContentType =
94 ServerUtils.SLAssetTypeToContentType(metadata.Type); 94 SLUtil.SLAssetTypeToContentType(metadata.Type);
95 } 95 }
96 else 96 else
97 { 97 {
@@ -111,7 +111,7 @@ namespace OpenSim.Server.Handlers.Asset
111 111
112 httpResponse.StatusCode = (int)HttpStatusCode.OK; 112 httpResponse.StatusCode = (int)HttpStatusCode.OK;
113 httpResponse.ContentType = 113 httpResponse.ContentType =
114 ServerUtils.SLAssetTypeToContentType(asset.Type); 114 SLUtil.SLAssetTypeToContentType(asset.Type);
115 } 115 }
116 else 116 else
117 { 117 {