aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Capabilities
diff options
context:
space:
mode:
authorMW2007-07-19 20:21:02 +0000
committerMW2007-07-19 20:21:02 +0000
commitb2c6f316e16e9bb33f81997319a4130fa683bc48 (patch)
tree632f901a43267c2f3a7c0de8feff2e4ddc845275 /OpenSim/Region/Capabilities
parent*Handler Functions can now refuse an object as invalid by returning false, th... (diff)
downloadopensim-SC_OLD-b2c6f316e16e9bb33f81997319a4130fa683bc48.zip
opensim-SC_OLD-b2c6f316e16e9bb33f81997319a4130fa683bc48.tar.gz
opensim-SC_OLD-b2c6f316e16e9bb33f81997319a4130fa683bc48.tar.bz2
opensim-SC_OLD-b2c6f316e16e9bb33f81997319a4130fa683bc48.tar.xz
Some work on Inventory (not yet finished or enabled)
Diffstat (limited to 'OpenSim/Region/Capabilities')
-rw-r--r--OpenSim/Region/Capabilities/Caps.cs33
1 files changed, 26 insertions, 7 deletions
diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs
index 110ba6f..ab2b3a6 100644
--- a/OpenSim/Region/Capabilities/Caps.cs
+++ b/OpenSim/Region/Capabilities/Caps.cs
@@ -38,7 +38,7 @@ using OpenSim.Region.Caches;
38 38
39namespace OpenSim.Region.Capabilities 39namespace OpenSim.Region.Capabilities
40{ 40{
41 public delegate void UpLoadedTexture(LLUUID assetID, LLUUID inventoryItem, byte[] data); 41 public delegate void UpLoadedTexture(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data);
42 42
43 public class Caps 43 public class Caps
44 { 44 {
@@ -223,12 +223,14 @@ namespace OpenSim.Region.Capabilities
223 /// <returns></returns> 223 /// <returns></returns>
224 public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) 224 public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
225 { 225 {
226 // Console.WriteLine("asset upload request via CAPS");
227 string assetName = llsdRequest.name;
226 string capsBase = "/CAPS/" + m_capsObjectPath; 228 string capsBase = "/CAPS/" + m_capsObjectPath;
227 LLUUID newAsset = LLUUID.Random(); 229 LLUUID newAsset = LLUUID.Random();
228 LLUUID newInvItem = LLUUID.Random(); 230 LLUUID newInvItem = LLUUID.Random();
229 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 231 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
230 232
231 AssetUploader uploader = new AssetUploader(newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); 233 AssetUploader uploader = new AssetUploader(assetName, newAsset, newInvItem, capsBase + uploaderPath, this.httpListener);
232 httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); 234 httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
233 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; 235 string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
234 236
@@ -245,14 +247,14 @@ namespace OpenSim.Region.Capabilities
245 /// <param name="assetID"></param> 247 /// <param name="assetID"></param>
246 /// <param name="inventoryItem"></param> 248 /// <param name="inventoryItem"></param>
247 /// <param name="data"></param> 249 /// <param name="data"></param>
248 public void UploadCompleteHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) 250 public void UploadCompleteHandler(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data)
249 { 251 {
250 AssetBase asset; 252 AssetBase asset;
251 asset = new AssetBase(); 253 asset = new AssetBase();
252 asset.FullID = assetID; 254 asset.FullID = assetID;
253 asset.Type = 0; 255 asset.Type = 0;
254 asset.InvType = 0; 256 asset.InvType = 0;
255 asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); 257 asset.Name = assetName; //"UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000");
256 asset.Data = data; 258 asset.Data = data;
257 this.assetCache.AddAsset(asset); 259 this.assetCache.AddAsset(asset);
258 } 260 }
@@ -265,6 +267,8 @@ namespace OpenSim.Region.Capabilities
265 private LLUUID newAssetID; 267 private LLUUID newAssetID;
266 private LLUUID inventoryItemID; 268 private LLUUID inventoryItemID;
267 private BaseHttpServer httpListener; 269 private BaseHttpServer httpListener;
270 private bool SaveImages = true;
271 private string m_assetName = "";
268 272
269 /// <summary> 273 /// <summary>
270 /// 274 ///
@@ -273,8 +277,9 @@ namespace OpenSim.Region.Capabilities
273 /// <param name="inventoryItem"></param> 277 /// <param name="inventoryItem"></param>
274 /// <param name="path"></param> 278 /// <param name="path"></param>
275 /// <param name="httpServer"></param> 279 /// <param name="httpServer"></param>
276 public AssetUploader(LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) 280 public AssetUploader(string assetName, LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer)
277 { 281 {
282 m_assetName = assetName;
278 newAssetID = assetID; 283 newAssetID = assetID;
279 inventoryItemID = inventoryItem; 284 inventoryItemID = inventoryItem;
280 uploaderPath = path; 285 uploaderPath = path;
@@ -299,13 +304,27 @@ namespace OpenSim.Region.Capabilities
299 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); 304 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
300 305
301 httpListener.RemoveStreamHandler("POST", uploaderPath); 306 httpListener.RemoveStreamHandler("POST", uploaderPath);
302 307
308 if(this.SaveImages)
309 this.SaveImageToFile(m_assetName + ".jp2", data);
310
303 if (OnUpLoad != null) 311 if (OnUpLoad != null)
304 { 312 {
305 OnUpLoad(newAssetID, inv, data); 313 OnUpLoad(m_assetName, newAssetID, inv, data);
306 } 314 }
315
307 return res; 316 return res;
308 } 317 }
318
319 private void SaveImageToFile(string filename, byte[] data)
320 {
321
322 FileStream fs = File.Create(filename);
323 BinaryWriter bw = new BinaryWriter(fs);
324 bw.Write(data);
325 bw.Close();
326 fs.Close();
327 }
309 } 328 }
310 } 329 }
311} 330}