aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-12-01 23:24:15 +0000
committerJustin Clark-Casey (justincc)2011-12-01 23:24:15 +0000
commit5460f2e035f50aade96b3daa0cb284bcb6faeea7 (patch)
tree623a22611e75c74f82fcb77664d971f463bcffb7 /OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
parentProvide more user feedback when "debug http" is set (diff)
downloadopensim-SC_OLD-5460f2e035f50aade96b3daa0cb284bcb6faeea7.zip
opensim-SC_OLD-5460f2e035f50aade96b3daa0cb284bcb6faeea7.tar.gz
opensim-SC_OLD-5460f2e035f50aade96b3daa0cb284bcb6faeea7.tar.bz2
opensim-SC_OLD-5460f2e035f50aade96b3daa0cb284bcb6faeea7.tar.xz
refactor: Separate the upload baked texture handler out from BunchOfCaps
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs123
1 files changed, 1 insertions, 122 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 07b4df3..98dda36 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -56,8 +56,6 @@ namespace OpenSim.Region.ClientStack.Linden
56 string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, 56 string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder,
57 byte[] data, string inventoryType, string assetType); 57 byte[] data, string inventoryType, string assetType);
58 58
59 public delegate void UploadedBakedTexture(UUID assetID, byte[] data);
60
61 public delegate UUID UpdateItem(UUID itemID, byte[] data); 59 public delegate UUID UpdateItem(UUID itemID, byte[] data);
62 60
63 public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors); 61 public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors);
@@ -97,7 +95,6 @@ namespace OpenSim.Region.ClientStack.Linden
97 private static readonly string m_notecardTaskUpdatePath = "0005/"; 95 private static readonly string m_notecardTaskUpdatePath = "0005/";
98 // private static readonly string m_fetchInventoryPath = "0006/"; 96 // private static readonly string m_fetchInventoryPath = "0006/";
99 // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. 97 // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule.
100 private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule.
101 98
102 99
103 // These are callbacks which will be setup by the scene so that we can update scene data when we 100 // These are callbacks which will be setup by the scene so that we can update scene data when we
@@ -164,8 +161,6 @@ namespace OpenSim.Region.ClientStack.Linden
164 IRequestHandler req = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); 161 IRequestHandler req = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory);
165 m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req); 162 m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req);
166 m_HostCapsObj.RegisterHandler("UpdateScriptTask", req); 163 m_HostCapsObj.RegisterHandler("UpdateScriptTask", req);
167 m_HostCapsObj.RegisterHandler("UploadBakedTexture", new RestStreamHandler("POST", capsBase + m_uploadBakedTexturePath, UploadBakedTexture));
168
169 } 164 }
170 catch (Exception e) 165 catch (Exception e)
171 { 166 {
@@ -331,74 +326,6 @@ namespace OpenSim.Region.ClientStack.Linden
331 } 326 }
332 327
333 /// <summary> 328 /// <summary>
334 /// Handle a request from the client for a Uri to upload a baked texture.
335 /// </summary>
336 /// <param name="request"></param>
337 /// <param name="path"></param>
338 /// <param name="param"></param>
339 /// <param name="httpRequest"></param>
340 /// <param name="httpResponse"></param>
341 /// <returns>The upload response if the request is successful, null otherwise.</returns>
342 public string UploadBakedTexture(string request, string path,
343 string param, OSHttpRequest httpRequest,
344 OSHttpResponse httpResponse)
345 {
346 try
347 {
348// m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + m_regionName);
349
350 string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
351 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
352
353 BakedTextureUploader uploader =
354 new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener);
355 uploader.OnUpLoad += BakedTextureUploaded;
356
357 m_HostCapsObj.HttpListener.AddStreamHandler(
358 new BinaryStreamHandler("POST", capsBase + uploaderPath,
359 uploader.uploaderCaps));
360
361 string protocol = "http://";
362
363 if (m_HostCapsObj.SSLCaps)
364 protocol = "https://";
365
366 string uploaderURL = protocol + m_HostCapsObj.HostName + ":" +
367 m_HostCapsObj.Port.ToString() + capsBase + uploaderPath;
368
369 LLSDAssetUploadResponse uploadResponse =
370 new LLSDAssetUploadResponse();
371 uploadResponse.uploader = uploaderURL;
372 uploadResponse.state = "upload";
373
374 return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
375 }
376 catch (Exception e)
377 {
378 m_log.Error("[CAPS]: " + e.ToString());
379 }
380
381 return null;
382 }
383
384 /// <summary>
385 /// Called when a baked texture has been successfully uploaded by a client.
386 /// </summary>
387 /// <param name="assetID"></param>
388 /// <param name="data"></param>
389 public void BakedTextureUploaded(UUID assetID, byte[] data)
390 {
391 // m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
392
393 AssetBase asset;
394 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
395 asset.Data = data;
396 asset.Temporary = true;
397 asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are
398 m_assetService.Store(asset);
399 }
400
401 /// <summary>
402 /// Called when new asset data for an agent inventory item update has been uploaded. 329 /// Called when new asset data for an agent inventory item update has been uploaded.
403 /// </summary> 330 /// </summary>
404 /// <param name="itemID">Item to update</param> 331 /// <param name="itemID">Item to update</param>
@@ -1067,6 +994,7 @@ namespace OpenSim.Region.ClientStack.Linden
1067 // XXX Maybe this should be some meaningful error packet 994 // XXX Maybe this should be some meaningful error packet
1068 return null; 995 return null;
1069 } 996 }
997
1070 ///Left this in and commented in case there are unforseen issues 998 ///Left this in and commented in case there are unforseen issues
1071 //private void SaveAssetToFile(string filename, byte[] data) 999 //private void SaveAssetToFile(string filename, byte[] data)
1072 //{ 1000 //{
@@ -1090,53 +1018,4 @@ namespace OpenSim.Region.ClientStack.Linden
1090 fs.Close(); 1018 fs.Close();
1091 } 1019 }
1092 } 1020 }
1093
1094 public class BakedTextureUploader
1095 {
1096 public event UploadedBakedTexture OnUpLoad;
1097 private UploadedBakedTexture handlerUpLoad = null;
1098
1099 private string uploaderPath = String.Empty;
1100 private UUID newAssetID;
1101 private IHttpServer httpListener;
1102
1103 public BakedTextureUploader(string path, IHttpServer httpServer)
1104 {
1105 newAssetID = UUID.Random();
1106 uploaderPath = path;
1107 httpListener = httpServer;
1108 // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
1109 }
1110
1111 /// <summary>
1112 /// Handle raw uploaded baked texture data.
1113 /// </summary>
1114 /// <param name="data"></param>
1115 /// <param name="path"></param>
1116 /// <param name="param"></param>
1117 /// <returns></returns>
1118 public string uploaderCaps(byte[] data, string path, string param)
1119 {
1120 handlerUpLoad = OnUpLoad;
1121 if (handlerUpLoad != null)
1122 {
1123 Util.FireAndForget(delegate(object o) { handlerUpLoad(newAssetID, data); });
1124 }
1125
1126 string res = String.Empty;
1127 LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
1128 uploadComplete.new_asset = newAssetID.ToString();
1129 uploadComplete.new_inventory_item = UUID.Zero;
1130 uploadComplete.state = "complete";
1131
1132 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1133
1134 httpListener.RemoveStreamHandler("POST", uploaderPath);
1135
1136 // m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID);
1137
1138 return res;
1139 }
1140 }
1141
1142} \ No newline at end of file 1021} \ No newline at end of file