aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie Thielker2010-09-02 16:10:44 +0200
committerMelanie2010-09-02 16:20:44 +0100
commit7128e1a4bacf811df0268695eaf4c747fd53955b (patch)
tree6e9197b7e3dd045f0b442f8320c7a860cbe3295d /OpenSim
parentFix cast issue (diff)
downloadopensim-SC-7128e1a4bacf811df0268695eaf4c747fd53955b.zip
opensim-SC-7128e1a4bacf811df0268695eaf4c747fd53955b.tar.gz
opensim-SC-7128e1a4bacf811df0268695eaf4c747fd53955b.tar.bz2
opensim-SC-7128e1a4bacf811df0268695eaf4c747fd53955b.tar.xz
Implement UploadBakedTexture cap
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Capabilities/Caps.cs105
1 files changed, 105 insertions, 0 deletions
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index 0db7bb9..8a339fe 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -44,6 +44,8 @@ namespace OpenSim.Framework.Capabilities
44 string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, 44 string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder,
45 byte[] data, string inventoryType, string assetType); 45 byte[] data, string inventoryType, string assetType);
46 46
47 public delegate void UploadedBakedTexture(UUID assetID, byte[] data);
48
47 public delegate UUID UpdateItem(UUID itemID, byte[] data); 49 public delegate UUID UpdateItem(UUID itemID, byte[] data);
48 50
49 public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors); 51 public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors);
@@ -97,6 +99,7 @@ namespace OpenSim.Framework.Capabilities
97 // private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module. 99 // private static readonly string m_provisionVoiceAccountRequestPath = "0008/";// This is in a module.
98 100
99 // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. 101 // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule.
102 private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule.
100 103
101 //private string eventQueue = "0100/"; 104 //private string eventQueue = "0100/";
102 private IScene m_Scene; 105 private IScene m_Scene;
@@ -185,6 +188,8 @@ namespace OpenSim.Framework.Capabilities
185 m_capsHandlers["UpdateScriptTaskInventory"] = 188 m_capsHandlers["UpdateScriptTaskInventory"] =
186 new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); 189 new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory);
187 m_capsHandlers["UpdateScriptTask"] = m_capsHandlers["UpdateScriptTaskInventory"]; 190 m_capsHandlers["UpdateScriptTask"] = m_capsHandlers["UpdateScriptTaskInventory"];
191 m_capsHandlers["UploadBakedTexture"] =
192 new RestStreamHandler("POST", capsBase + m_uploadBakedTexturePath, UploadBakedTexture);
188 193
189 } 194 }
190 catch (Exception e) 195 catch (Exception e)
@@ -742,6 +747,50 @@ namespace OpenSim.Framework.Capabilities
742 return null; 747 return null;
743 } 748 }
744 749
750 public string UploadBakedTexture(string request, string path,
751 string param, OSHttpRequest httpRequest,
752 OSHttpResponse httpResponse)
753 {
754 try
755 {
756 m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " +
757 m_regionName);
758
759 string capsBase = "/CAPS/" + m_capsObjectPath;
760 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
761
762 BakedTextureUploader uploader =
763 new BakedTextureUploader( capsBase + uploaderPath,
764 m_httpListener);
765 uploader.OnUpLoad += BakedTextureUploaded;
766
767 m_httpListener.AddStreamHandler(
768 new BinaryStreamHandler("POST", capsBase + uploaderPath,
769 uploader.uploaderCaps));
770
771 string protocol = "http://";
772
773 if (m_httpListener.UseSSL)
774 protocol = "https://";
775
776 string uploaderURL = protocol + m_httpListenerHostName + ":" +
777 m_httpListenPort.ToString() + capsBase + uploaderPath;
778
779 LLSDAssetUploadResponse uploadResponse =
780 new LLSDAssetUploadResponse();
781 uploadResponse.uploader = uploaderURL;
782 uploadResponse.state = "upload";
783
784 return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
785 }
786 catch (Exception e)
787 {
788 m_log.Error("[CAPS]: " + e.ToString());
789 }
790
791 return null;
792 }
793
745 /// <summary> 794 /// <summary>
746 /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset. 795 /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset.
747 /// </summary> 796 /// </summary>
@@ -925,6 +974,17 @@ namespace OpenSim.Framework.Capabilities
925 } 974 }
926 } 975 }
927 976
977 public void BakedTextureUploaded(UUID assetID, byte[] data)
978 {
979 m_log.DebugFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
980 AssetBase asset;
981 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString());
982 asset.Data = data;
983 asset.Temporary = true;
984 asset.Local = true;
985 m_assetCache.Store(asset);
986 }
987
928 /// <summary> 988 /// <summary>
929 /// Called when new asset data for an agent inventory item update has been uploaded. 989 /// Called when new asset data for an agent inventory item update has been uploaded.
930 /// </summary> 990 /// </summary>
@@ -1243,5 +1303,50 @@ namespace OpenSim.Framework.Capabilities
1243 fs.Close(); 1303 fs.Close();
1244 } 1304 }
1245 } 1305 }
1306
1307 public class BakedTextureUploader
1308 {
1309 public event UploadedBakedTexture OnUpLoad;
1310 private UploadedBakedTexture handlerUpLoad = null;
1311
1312 private string uploaderPath = String.Empty;
1313 private UUID newAssetID;
1314 private IHttpServer httpListener;
1315
1316 public BakedTextureUploader(string path, IHttpServer httpServer)
1317 {
1318 newAssetID = UUID.Random();
1319 uploaderPath = path;
1320 httpListener = httpServer;
1321 }
1322
1323 /// <summary>
1324 ///
1325 /// </summary>
1326 /// <param name="data"></param>
1327 /// <param name="path"></param>
1328 /// <param name="param"></param>
1329 /// <returns></returns>
1330 public string uploaderCaps(byte[] data, string path, string param)
1331 {
1332 string res = String.Empty;
1333 LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
1334 uploadComplete.new_asset = newAssetID.ToString();
1335 uploadComplete.new_inventory_item = UUID.Zero;
1336 uploadComplete.state = "complete";
1337
1338 res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
1339
1340 httpListener.RemoveStreamHandler("POST", uploaderPath);
1341
1342 handlerUpLoad = OnUpLoad;
1343 if (handlerUpLoad != null)
1344 {
1345 handlerUpLoad(newAssetID, data);
1346 }
1347
1348 return res;
1349 }
1350 }
1246 } 1351 }
1247} 1352}