BunchOfCaps.cs 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.IO;
  31. using System.Reflection;
  32. using System.Text;
  33. using OpenMetaverse;
  34. using OpenMetaverse.StructuredData;
  35. using Nini.Config;
  36. using log4net;
  37. using OpenSim.Framework;
  38. using OpenSim.Framework.Capabilities;
  39. using OpenSim.Region.Framework;
  40. using OpenSim.Region.Framework.Scenes;
  41. using OpenSim.Region.Framework.Scenes.Serialization;
  42. using OpenSim.Framework.Servers;
  43. using OpenSim.Framework.Servers.HttpServer;
  44. using OpenSim.Services.Interfaces;
  45. using Caps = OpenSim.Framework.Capabilities.Caps;
  46. using OSDArray = OpenMetaverse.StructuredData.OSDArray;
  47. using OSDMap = OpenMetaverse.StructuredData.OSDMap;
  48. namespace OpenSim.Region.ClientStack.Linden
  49. {
  50. public delegate void UpLoadedAsset(
  51. string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder,
  52. byte[] data, string inventoryType, string assetType);
  53. public delegate void UploadedBakedTexture(UUID assetID, byte[] data);
  54. public delegate UUID UpdateItem(UUID itemID, byte[] data);
  55. public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors);
  56. public delegate void NewInventoryItem(UUID userID, InventoryItemBase item);
  57. public delegate void NewAsset(AssetBase asset);
  58. public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data);
  59. public delegate ArrayList TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID,
  60. bool isScriptRunning, byte[] data);
  61. public delegate InventoryCollection FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID,
  62. bool fetchFolders, bool fetchItems, int sortOrder, out int version);
  63. /// <summary>
  64. /// XXX Probably not a particularly nice way of allow us to get the scene presence from the scene (chiefly so that
  65. /// we can popup a message on the user's client if the inventory service has permanently failed). But I didn't want
  66. /// to just pass the whole Scene into CAPS.
  67. /// </summary>
  68. public delegate IClientAPI GetClientDelegate(UUID agentID);
  69. public class BunchOfCaps
  70. {
  71. private static readonly ILog m_log =
  72. LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  73. private Scene m_Scene;
  74. private Caps m_HostCapsObj;
  75. private static readonly string m_requestPath = "0000/";
  76. // private static readonly string m_mapLayerPath = "0001/";
  77. private static readonly string m_newInventory = "0002/";
  78. //private static readonly string m_requestTexture = "0003/";
  79. private static readonly string m_notecardUpdatePath = "0004/";
  80. private static readonly string m_notecardTaskUpdatePath = "0005/";
  81. // private static readonly string m_fetchInventoryPath = "0006/";
  82. // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule.
  83. private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule.
  84. // These are callbacks which will be setup by the scene so that we can update scene data when we
  85. // receive capability calls
  86. public NewInventoryItem AddNewInventoryItem = null;
  87. public NewAsset AddNewAsset = null;
  88. public ItemUpdatedCallback ItemUpdatedCall = null;
  89. public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null;
  90. public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null;
  91. public GetClientDelegate GetClient = null;
  92. private bool m_persistBakedTextures = false;
  93. private IAssetService m_assetService;
  94. private bool m_dumpAssetsToFile = false;
  95. private string m_regionName;
  96. public BunchOfCaps(Scene scene, Caps caps)
  97. {
  98. m_Scene = scene;
  99. m_HostCapsObj = caps;
  100. IConfigSource config = m_Scene.Config;
  101. if (config != null)
  102. {
  103. IConfig sconfig = config.Configs["Startup"];
  104. if (sconfig != null)
  105. m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
  106. }
  107. m_assetService = m_Scene.AssetService;
  108. m_regionName = m_Scene.RegionInfo.RegionName;
  109. RegisterHandlers();
  110. AddNewInventoryItem = m_Scene.AddUploadedInventoryItem;
  111. ItemUpdatedCall = m_Scene.CapsUpdateInventoryItemAsset;
  112. TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset;
  113. CAPSFetchInventoryDescendents = m_Scene.HandleFetchInventoryDescendentsCAPS;
  114. GetClient = m_Scene.SceneContents.GetControllingClient;
  115. }
  116. /// <summary>
  117. /// Register a bunch of CAPS http service handlers
  118. /// </summary>
  119. public void RegisterHandlers()
  120. {
  121. string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
  122. RegisterRegionServiceHandlers(capsBase);
  123. RegisterInventoryServiceHandlers(capsBase);
  124. }
  125. public void RegisterRegionServiceHandlers(string capsBase)
  126. {
  127. try
  128. {
  129. // the root of all evil
  130. m_HostCapsObj.RegisterHandler("SEED", new RestStreamHandler("POST", capsBase + m_requestPath, SeedCapRequest));
  131. m_log.DebugFormat(
  132. "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_HostCapsObj.AgentID);
  133. //m_capsHandlers["MapLayer"] =
  134. // new LLSDStreamhandler<OSDMapRequest, OSDMapLayerResponse>("POST",
  135. // capsBase + m_mapLayerPath,
  136. // GetMapLayer);
  137. IRequestHandler req = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory);
  138. m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req);
  139. m_HostCapsObj.RegisterHandler("UpdateScriptTask", req);
  140. m_HostCapsObj.RegisterHandler("UploadBakedTexture", new RestStreamHandler("POST", capsBase + m_uploadBakedTexturePath, UploadBakedTexture));
  141. }
  142. catch (Exception e)
  143. {
  144. m_log.Error("[CAPS]: " + e.ToString());
  145. }
  146. }
  147. public void RegisterInventoryServiceHandlers(string capsBase)
  148. {
  149. try
  150. {
  151. // I don't think this one works...
  152. m_HostCapsObj.RegisterHandler("NewFileAgentInventory", new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST",
  153. capsBase + m_newInventory,
  154. NewAgentInventoryRequest));
  155. IRequestHandler req = new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory);
  156. m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req);
  157. m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req);
  158. m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req);
  159. // As of RC 1.22.9 of the Linden client this is
  160. // supported
  161. //m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest);
  162. // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and
  163. // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires
  164. // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service,
  165. // but when I went on the Linden grid, the
  166. // simulators I visited (version 1.21) were, surprisingly, no longer supplying this capability. Instead,
  167. // the 1.19.1.4 client appeared to be happily flowing inventory data over UDP
  168. //
  169. // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid
  170. // we will be
  171. // able to get the data we need to implement the necessary part of the protocol to fix the issue above.
  172. // m_capsHandlers["FetchInventoryDescendents"] =
  173. // new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest);
  174. // m_capsHandlers["FetchInventoryDescendents"] =
  175. // new LLSDStreamhandler<LLSDFetchInventoryDescendents, LLSDInventoryDescendents>("POST",
  176. // capsBase + m_fetchInventory,
  177. // FetchInventory));
  178. // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST",
  179. // capsBase + m_requestTexture,
  180. // RequestTexture);
  181. }
  182. catch (Exception e)
  183. {
  184. m_log.Error("[CAPS]: " + e.ToString());
  185. }
  186. }
  187. /// <summary>
  188. /// Construct a client response detailing all the capabilities this server can provide.
  189. /// </summary>
  190. /// <param name="request"></param>
  191. /// <param name="path"></param>
  192. /// <param name="param"></param>
  193. /// <param name="httpRequest">HTTP request header object</param>
  194. /// <param name="httpResponse">HTTP response header object</param>
  195. /// <returns></returns>
  196. public string SeedCapRequest(string request, string path, string param,
  197. OSHttpRequest httpRequest, OSHttpResponse httpResponse)
  198. {
  199. // m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName);
  200. if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint))
  201. {
  202. m_log.DebugFormat("[CAPS]: Unauthorized CAPS client");
  203. return string.Empty;
  204. }
  205. Hashtable caps = m_HostCapsObj.CapsHandlers.CapsDetails;
  206. // Add the external too
  207. foreach (KeyValuePair<string, string> kvp in m_HostCapsObj.ExternalCapsHandlers)
  208. caps[kvp.Key] = kvp.Value;
  209. string result = LLSDHelpers.SerialiseLLSDReply(caps);
  210. //m_log.DebugFormat("[CAPS] CapsRequest {0}", result);
  211. return result;
  212. }
  213. /// <summary>
  214. /// Called by the script task update handler. Provides a URL to which the client can upload a new asset.
  215. /// </summary>
  216. /// <param name="request"></param>
  217. /// <param name="path"></param>
  218. /// <param name="param"></param>
  219. /// <param name="httpRequest">HTTP request header object</param>
  220. /// <param name="httpResponse">HTTP response header object</param>
  221. /// <returns></returns>
  222. public string ScriptTaskInventory(string request, string path, string param,
  223. OSHttpRequest httpRequest, OSHttpResponse httpResponse)
  224. {
  225. try
  226. {
  227. m_log.Debug("[CAPS]: ScriptTaskInventory Request in region: " + m_regionName);
  228. //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param);
  229. Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
  230. LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate();
  231. LLSDHelpers.DeserialiseOSDMap(hash, llsdUpdateRequest);
  232. string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
  233. string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
  234. TaskInventoryScriptUpdater uploader =
  235. new TaskInventoryScriptUpdater(
  236. llsdUpdateRequest.item_id,
  237. llsdUpdateRequest.task_id,
  238. llsdUpdateRequest.is_script_running,
  239. capsBase + uploaderPath,
  240. m_HostCapsObj.HttpListener,
  241. m_dumpAssetsToFile);
  242. uploader.OnUpLoad += TaskScriptUpdated;
  243. m_HostCapsObj.HttpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
  244. string protocol = "http://";
  245. if (m_HostCapsObj.SSLCaps)
  246. protocol = "https://";
  247. string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase +
  248. uploaderPath;
  249. LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
  250. uploadResponse.uploader = uploaderURL;
  251. uploadResponse.state = "upload";
  252. // m_log.InfoFormat("[CAPS]: " +
  253. // "ScriptTaskInventory response: {0}",
  254. // LLSDHelpers.SerialiseLLSDReply(uploadResponse)));
  255. return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
  256. }
  257. catch (Exception e)
  258. {
  259. m_log.Error("[CAPS]: " + e.ToString());
  260. }
  261. return null;
  262. }
  263. /// <summary>
  264. /// Called when new asset data for an agent inventory item update has been uploaded.
  265. /// </summary>
  266. /// <param name="itemID">Item to update</param>
  267. /// <param name="primID">Prim containing item to update</param>
  268. /// <param name="isScriptRunning">Signals whether the script to update is currently running</param>
  269. /// <param name="data">New asset data</param>
  270. public void TaskScriptUpdated(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors)
  271. {
  272. if (TaskScriptUpdatedCall != null)
  273. {
  274. ArrayList e = TaskScriptUpdatedCall(m_HostCapsObj.AgentID, itemID, primID, isScriptRunning, data);
  275. foreach (Object item in e)
  276. errors.Add(item);
  277. }
  278. }
  279. /// <summary>
  280. /// Handle a request from the client for a Uri to upload a baked texture.
  281. /// </summary>
  282. /// <param name="request"></param>
  283. /// <param name="path"></param>
  284. /// <param name="param"></param>
  285. /// <param name="httpRequest"></param>
  286. /// <param name="httpResponse"></param>
  287. /// <returns>The upload response if the request is successful, null otherwise.</returns>
  288. public string UploadBakedTexture(string request, string path,
  289. string param, OSHttpRequest httpRequest,
  290. OSHttpResponse httpResponse)
  291. {
  292. try
  293. {
  294. // m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + m_regionName);
  295. string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
  296. string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
  297. BakedTextureUploader uploader =
  298. new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener);
  299. uploader.OnUpLoad += BakedTextureUploaded;
  300. m_HostCapsObj.HttpListener.AddStreamHandler(
  301. new BinaryStreamHandler("POST", capsBase + uploaderPath,
  302. uploader.uploaderCaps));
  303. string protocol = "http://";
  304. if (m_HostCapsObj.SSLCaps)
  305. protocol = "https://";
  306. string uploaderURL = protocol + m_HostCapsObj.HostName + ":" +
  307. m_HostCapsObj.Port.ToString() + capsBase + uploaderPath;
  308. LLSDAssetUploadResponse uploadResponse =
  309. new LLSDAssetUploadResponse();
  310. uploadResponse.uploader = uploaderURL;
  311. uploadResponse.state = "upload";
  312. return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
  313. }
  314. catch (Exception e)
  315. {
  316. m_log.Error("[CAPS]: " + e.ToString());
  317. }
  318. return null;
  319. }
  320. /// <summary>
  321. /// Called when a baked texture has been successfully uploaded by a client.
  322. /// </summary>
  323. /// <param name="assetID"></param>
  324. /// <param name="data"></param>
  325. public void BakedTextureUploaded(UUID assetID, byte[] data)
  326. {
  327. // m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
  328. AssetBase asset;
  329. asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
  330. asset.Data = data;
  331. asset.Temporary = true;
  332. asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are
  333. m_assetService.Store(asset);
  334. }
  335. /// <summary>
  336. /// Called when new asset data for an agent inventory item update has been uploaded.
  337. /// </summary>
  338. /// <param name="itemID">Item to update</param>
  339. /// <param name="data">New asset data</param>
  340. /// <returns></returns>
  341. public UUID ItemUpdated(UUID itemID, byte[] data)
  342. {
  343. if (ItemUpdatedCall != null)
  344. {
  345. return ItemUpdatedCall(m_HostCapsObj.AgentID, itemID, data);
  346. }
  347. return UUID.Zero;
  348. }
  349. /// <summary>
  350. ///
  351. /// </summary>
  352. /// <param name="llsdRequest"></param>
  353. /// <returns></returns>
  354. public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
  355. {
  356. //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString());
  357. //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type);
  358. if (llsdRequest.asset_type == "texture" ||
  359. llsdRequest.asset_type == "animation" ||
  360. llsdRequest.asset_type == "sound")
  361. {
  362. IClientAPI client = null;
  363. IScene scene = null;
  364. if (GetClient != null)
  365. {
  366. client = GetClient(m_HostCapsObj.AgentID);
  367. scene = client.Scene;
  368. IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
  369. if (mm != null)
  370. {
  371. if (!mm.UploadCovered(client, mm.UploadCharge))
  372. {
  373. if (client != null)
  374. client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
  375. LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
  376. errorResponse.uploader = "";
  377. errorResponse.state = "error";
  378. return errorResponse;
  379. }
  380. }
  381. }
  382. }
  383. string assetName = llsdRequest.name;
  384. string assetDes = llsdRequest.description;
  385. string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
  386. UUID newAsset = UUID.Random();
  387. UUID newInvItem = UUID.Random();
  388. UUID parentFolder = llsdRequest.folder_id;
  389. string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
  390. AssetUploader uploader =
  391. new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
  392. llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile);
  393. m_HostCapsObj.HttpListener.AddStreamHandler(
  394. new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
  395. string protocol = "http://";
  396. if (m_HostCapsObj.SSLCaps)
  397. protocol = "https://";
  398. string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase +
  399. uploaderPath;
  400. LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
  401. uploadResponse.uploader = uploaderURL;
  402. uploadResponse.state = "upload";
  403. uploader.OnUpLoad += UploadCompleteHandler;
  404. return uploadResponse;
  405. }
  406. /// <summary>
  407. /// Convert raw uploaded data into the appropriate asset and item.
  408. /// </summary>
  409. /// <param name="assetID"></param>
  410. /// <param name="inventoryItem"></param>
  411. /// <param name="data"></param>
  412. public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
  413. UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
  414. string assetType)
  415. {
  416. m_log.DebugFormat(
  417. "Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
  418. assetID, inventoryItem, inventoryType, assetType);
  419. sbyte assType = 0;
  420. sbyte inType = 0;
  421. if (inventoryType == "sound")
  422. {
  423. inType = 1;
  424. assType = 1;
  425. }
  426. else if (inventoryType == "animation")
  427. {
  428. inType = 19;
  429. assType = 20;
  430. }
  431. else if (inventoryType == "wearable")
  432. {
  433. inType = 18;
  434. switch (assetType)
  435. {
  436. case "bodypart":
  437. assType = 13;
  438. break;
  439. case "clothing":
  440. assType = 5;
  441. break;
  442. }
  443. }
  444. else if (inventoryType == "object")
  445. {
  446. inType = (sbyte)InventoryType.Object;
  447. assType = (sbyte)AssetType.Object;
  448. List<Vector3> positions = new List<Vector3>();
  449. List<Quaternion> rotations = new List<Quaternion>();
  450. OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data);
  451. OSDArray instance_list = (OSDArray)request["instance_list"];
  452. OSDArray mesh_list = (OSDArray)request["mesh_list"];
  453. OSDArray texture_list = (OSDArray)request["texture_list"];
  454. SceneObjectGroup grp = null;
  455. List<UUID> textures = new List<UUID>();
  456. for (int i = 0; i < texture_list.Count; i++)
  457. {
  458. AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, "");
  459. textureAsset.Data = texture_list[i].AsBinary();
  460. m_assetService.Store(textureAsset);
  461. textures.Add(textureAsset.FullID);
  462. }
  463. for (int i = 0; i < mesh_list.Count; i++)
  464. {
  465. PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
  466. Primitive.TextureEntry textureEntry
  467. = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
  468. OSDMap inner_instance_list = (OSDMap)instance_list[i];
  469. OSDArray face_list = (OSDArray)inner_instance_list["face_list"];
  470. for (uint face = 0; face < face_list.Count; face++)
  471. {
  472. OSDMap faceMap = (OSDMap)face_list[(int)face];
  473. Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face);
  474. if(faceMap.ContainsKey("fullbright"))
  475. f.Fullbright = faceMap["fullbright"].AsBoolean();
  476. if (faceMap.ContainsKey ("diffuse_color"))
  477. f.RGBA = faceMap["diffuse_color"].AsColor4();
  478. int textureNum = faceMap["image"].AsInteger();
  479. float imagerot = faceMap["imagerot"].AsInteger();
  480. float offsets = (float)faceMap["offsets"].AsReal();
  481. float offsett = (float)faceMap["offsett"].AsReal();
  482. float scales = (float)faceMap["scales"].AsReal();
  483. float scalet = (float)faceMap["scalet"].AsReal();
  484. if(imagerot != 0)
  485. f.Rotation = imagerot;
  486. if(offsets != 0)
  487. f.OffsetU = offsets;
  488. if (offsett != 0)
  489. f.OffsetV = offsett;
  490. if (scales != 0)
  491. f.RepeatU = scales;
  492. if (scalet != 0)
  493. f.RepeatV = scalet;
  494. if (textures.Count > textureNum)
  495. f.TextureID = textures[textureNum];
  496. else
  497. f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE;
  498. textureEntry.FaceTextures[face] = f;
  499. }
  500. pbs.TextureEntry = textureEntry.GetBytes();
  501. AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, "");
  502. meshAsset.Data = mesh_list[i].AsBinary();
  503. m_assetService.Store(meshAsset);
  504. pbs.SculptEntry = true;
  505. pbs.SculptTexture = meshAsset.FullID;
  506. pbs.SculptType = (byte)SculptType.Mesh;
  507. pbs.SculptData = meshAsset.Data;
  508. Vector3 position = inner_instance_list["position"].AsVector3();
  509. Vector3 scale = inner_instance_list["scale"].AsVector3();
  510. Quaternion rotation = inner_instance_list["rotation"].AsQuaternion();
  511. // no longer used - begin ------------------------
  512. // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger();
  513. // int material = inner_instance_list["material"].AsInteger();
  514. // int mesh = inner_instance_list["mesh"].AsInteger();
  515. // OSDMap permissions = (OSDMap)inner_instance_list["permissions"];
  516. // int base_mask = permissions["base_mask"].AsInteger();
  517. // int everyone_mask = permissions["everyone_mask"].AsInteger();
  518. // UUID creator_id = permissions["creator_id"].AsUUID();
  519. // UUID group_id = permissions["group_id"].AsUUID();
  520. // int group_mask = permissions["group_mask"].AsInteger();
  521. // bool is_owner_group = permissions["is_owner_group"].AsBoolean();
  522. // UUID last_owner_id = permissions["last_owner_id"].AsUUID();
  523. // int next_owner_mask = permissions["next_owner_mask"].AsInteger();
  524. // UUID owner_id = permissions["owner_id"].AsUUID();
  525. // int owner_mask = permissions["owner_mask"].AsInteger();
  526. // no longer used - end ------------------------
  527. UUID owner_id = m_HostCapsObj.AgentID;
  528. SceneObjectPart prim
  529. = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero);
  530. prim.Scale = scale;
  531. prim.OffsetPosition = position;
  532. rotations.Add(rotation);
  533. positions.Add(position);
  534. prim.UUID = UUID.Random();
  535. prim.CreatorID = owner_id;
  536. prim.OwnerID = owner_id;
  537. prim.GroupID = UUID.Zero;
  538. prim.LastOwnerID = prim.OwnerID;
  539. prim.CreationDate = Util.UnixTimeSinceEpoch();
  540. prim.Name = assetName;
  541. prim.Description = "";
  542. // prim.BaseMask = (uint)base_mask;
  543. // prim.EveryoneMask = (uint)everyone_mask;
  544. // prim.GroupMask = (uint)group_mask;
  545. // prim.NextOwnerMask = (uint)next_owner_mask;
  546. // prim.OwnerMask = (uint)owner_mask;
  547. if (grp == null)
  548. grp = new SceneObjectGroup(prim);
  549. else
  550. grp.AddPart(prim);
  551. }
  552. // Fix first link number
  553. if (grp.Parts.Length > 1)
  554. grp.RootPart.LinkNum++;
  555. Vector3 rootPos = positions[0];
  556. grp.AbsolutePosition = rootPos;
  557. for (int i = 0; i < positions.Count; i++)
  558. {
  559. Vector3 offset = positions[i] - rootPos;
  560. grp.Parts[i].OffsetPosition = offset;
  561. }
  562. for (int i = 0; i < rotations.Count; i++)
  563. {
  564. if (i != 0)
  565. grp.Parts[i].RotationOffset = rotations[i];
  566. }
  567. grp.UpdateGroupRotationR(rotations[0]);
  568. data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp));
  569. }
  570. AssetBase asset;
  571. asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString());
  572. asset.Data = data;
  573. if (AddNewAsset != null)
  574. AddNewAsset(asset);
  575. else if (m_assetService != null)
  576. m_assetService.Store(asset);
  577. InventoryItemBase item = new InventoryItemBase();
  578. item.Owner = m_HostCapsObj.AgentID;
  579. item.CreatorId = m_HostCapsObj.AgentID.ToString();
  580. item.CreatorData = String.Empty;
  581. item.ID = inventoryItem;
  582. item.AssetID = asset.FullID;
  583. item.Description = assetDescription;
  584. item.Name = assetName;
  585. item.AssetType = assType;
  586. item.InvType = inType;
  587. item.Folder = parentFolder;
  588. item.CurrentPermissions = (uint)PermissionMask.All;
  589. item.BasePermissions = (uint)PermissionMask.All;
  590. item.EveryOnePermissions = 0;
  591. item.NextPermissions = (uint)PermissionMask.All;
  592. item.CreationDate = Util.UnixTimeSinceEpoch();
  593. if (AddNewInventoryItem != null)
  594. {
  595. AddNewInventoryItem(m_HostCapsObj.AgentID, item);
  596. }
  597. }
  598. /// <summary>
  599. ///
  600. /// </summary>
  601. /// <param name="mapReq"></param>
  602. /// <returns></returns>
  603. public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
  604. {
  605. m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName);
  606. LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
  607. mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
  608. return mapResponse;
  609. }
  610. /// <summary>
  611. ///
  612. /// </summary>
  613. /// <returns></returns>
  614. protected static OSDMapLayer GetOSDMapLayerResponse()
  615. {
  616. OSDMapLayer mapLayer = new OSDMapLayer();
  617. mapLayer.Right = 5000;
  618. mapLayer.Top = 5000;
  619. mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  620. return mapLayer;
  621. }
  622. /// <summary>
  623. ///
  624. /// </summary>
  625. /// <param name="request"></param>
  626. /// <param name="path"></param>
  627. /// <param name="param"></param>
  628. /// <returns></returns>
  629. public string RequestTexture(string request, string path, string param)
  630. {
  631. m_log.Debug("texture request " + request);
  632. // Needs implementing (added to remove compiler warning)
  633. return String.Empty;
  634. }
  635. /// <summary>
  636. /// Called by the notecard update handler. Provides a URL to which the client can upload a new asset.
  637. /// </summary>
  638. /// <param name="request"></param>
  639. /// <param name="path"></param>
  640. /// <param name="param"></param>
  641. /// <returns></returns>
  642. public string NoteCardAgentInventory(string request, string path, string param,
  643. OSHttpRequest httpRequest, OSHttpResponse httpResponse)
  644. {
  645. //m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request);
  646. //m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request);
  647. //OpenMetaverse.StructuredData.OSDMap hash = (OpenMetaverse.StructuredData.OSDMap)OpenMetaverse.StructuredData.LLSDParser.DeserializeBinary(Utils.StringToBytes(request));
  648. Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
  649. LLSDItemUpdate llsdRequest = new LLSDItemUpdate();
  650. LLSDHelpers.DeserialiseOSDMap(hash, llsdRequest);
  651. string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
  652. string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
  653. ItemUpdater uploader =
  654. new ItemUpdater(llsdRequest.item_id, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile);
  655. uploader.OnUpLoad += ItemUpdated;
  656. m_HostCapsObj.HttpListener.AddStreamHandler(
  657. new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
  658. string protocol = "http://";
  659. if (m_HostCapsObj.SSLCaps)
  660. protocol = "https://";
  661. string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase +
  662. uploaderPath;
  663. LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
  664. uploadResponse.uploader = uploaderURL;
  665. uploadResponse.state = "upload";
  666. // m_log.InfoFormat("[CAPS]: " +
  667. // "NoteCardAgentInventory response: {0}",
  668. // LLSDHelpers.SerialiseLLSDReply(uploadResponse)));
  669. return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
  670. }
  671. }
  672. public class AssetUploader
  673. {
  674. public event UpLoadedAsset OnUpLoad;
  675. private UpLoadedAsset handlerUpLoad = null;
  676. private string uploaderPath = String.Empty;
  677. private UUID newAssetID;
  678. private UUID inventoryItemID;
  679. private UUID parentFolder;
  680. private IHttpServer httpListener;
  681. private bool m_dumpAssetsToFile;
  682. private string m_assetName = String.Empty;
  683. private string m_assetDes = String.Empty;
  684. private string m_invType = String.Empty;
  685. private string m_assetType = String.Empty;
  686. public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem,
  687. UUID parentFolderID, string invType, string assetType, string path,
  688. IHttpServer httpServer, bool dumpAssetsToFile)
  689. {
  690. m_assetName = assetName;
  691. m_assetDes = description;
  692. newAssetID = assetID;
  693. inventoryItemID = inventoryItem;
  694. uploaderPath = path;
  695. httpListener = httpServer;
  696. parentFolder = parentFolderID;
  697. m_assetType = assetType;
  698. m_invType = invType;
  699. m_dumpAssetsToFile = dumpAssetsToFile;
  700. }
  701. /// <summary>
  702. /// Handle raw asset upload data via the capability.
  703. /// </summary>
  704. /// <param name="data"></param>
  705. /// <param name="path"></param>
  706. /// <param name="param"></param>
  707. /// <returns></returns>
  708. public string uploaderCaps(byte[] data, string path, string param)
  709. {
  710. UUID inv = inventoryItemID;
  711. string res = String.Empty;
  712. LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
  713. uploadComplete.new_asset = newAssetID.ToString();
  714. uploadComplete.new_inventory_item = inv;
  715. uploadComplete.state = "complete";
  716. res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
  717. httpListener.RemoveStreamHandler("POST", uploaderPath);
  718. // TODO: probably make this a better set of extensions here
  719. string extension = ".jp2";
  720. if (m_invType != "image")
  721. {
  722. extension = ".dat";
  723. }
  724. if (m_dumpAssetsToFile)
  725. {
  726. SaveAssetToFile(m_assetName + extension, data);
  727. }
  728. handlerUpLoad = OnUpLoad;
  729. if (handlerUpLoad != null)
  730. {
  731. handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType);
  732. }
  733. return res;
  734. }
  735. ///Left this in and commented in case there are unforseen issues
  736. //private void SaveAssetToFile(string filename, byte[] data)
  737. //{
  738. // FileStream fs = File.Create(filename);
  739. // BinaryWriter bw = new BinaryWriter(fs);
  740. // bw.Write(data);
  741. // bw.Close();
  742. // fs.Close();
  743. //}
  744. private static void SaveAssetToFile(string filename, byte[] data)
  745. {
  746. string assetPath = "UserAssets";
  747. if (!Directory.Exists(assetPath))
  748. {
  749. Directory.CreateDirectory(assetPath);
  750. }
  751. FileStream fs = File.Create(Path.Combine(assetPath, Util.safeFileName(filename)));
  752. BinaryWriter bw = new BinaryWriter(fs);
  753. bw.Write(data);
  754. bw.Close();
  755. fs.Close();
  756. }
  757. }
  758. /// <summary>
  759. /// This class is a callback invoked when a client sends asset data to
  760. /// an agent inventory notecard update url
  761. /// </summary>
  762. public class ItemUpdater
  763. {
  764. public event UpdateItem OnUpLoad;
  765. private UpdateItem handlerUpdateItem = null;
  766. private string uploaderPath = String.Empty;
  767. private UUID inventoryItemID;
  768. private IHttpServer httpListener;
  769. private bool m_dumpAssetToFile;
  770. public ItemUpdater(UUID inventoryItem, string path, IHttpServer httpServer, bool dumpAssetToFile)
  771. {
  772. m_dumpAssetToFile = dumpAssetToFile;
  773. inventoryItemID = inventoryItem;
  774. uploaderPath = path;
  775. httpListener = httpServer;
  776. }
  777. /// <summary>
  778. /// Handle raw uploaded asset data.
  779. /// </summary>
  780. /// <param name="data"></param>
  781. /// <param name="path"></param>
  782. /// <param name="param"></param>
  783. /// <returns></returns>
  784. public string uploaderCaps(byte[] data, string path, string param)
  785. {
  786. UUID inv = inventoryItemID;
  787. string res = String.Empty;
  788. LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
  789. UUID assetID = UUID.Zero;
  790. handlerUpdateItem = OnUpLoad;
  791. if (handlerUpdateItem != null)
  792. {
  793. assetID = handlerUpdateItem(inv, data);
  794. }
  795. uploadComplete.new_asset = assetID.ToString();
  796. uploadComplete.new_inventory_item = inv;
  797. uploadComplete.state = "complete";
  798. res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
  799. httpListener.RemoveStreamHandler("POST", uploaderPath);
  800. if (m_dumpAssetToFile)
  801. {
  802. SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data);
  803. }
  804. return res;
  805. }
  806. ///Left this in and commented in case there are unforseen issues
  807. //private void SaveAssetToFile(string filename, byte[] data)
  808. //{
  809. // FileStream fs = File.Create(filename);
  810. // BinaryWriter bw = new BinaryWriter(fs);
  811. // bw.Write(data);
  812. // bw.Close();
  813. // fs.Close();
  814. //}
  815. private static void SaveAssetToFile(string filename, byte[] data)
  816. {
  817. string assetPath = "UserAssets";
  818. if (!Directory.Exists(assetPath))
  819. {
  820. Directory.CreateDirectory(assetPath);
  821. }
  822. FileStream fs = File.Create(Path.Combine(assetPath, filename));
  823. BinaryWriter bw = new BinaryWriter(fs);
  824. bw.Write(data);
  825. bw.Close();
  826. fs.Close();
  827. }
  828. }
  829. /// <summary>
  830. /// This class is a callback invoked when a client sends asset data to
  831. /// a task inventory script update url
  832. /// </summary>
  833. public class TaskInventoryScriptUpdater
  834. {
  835. private static readonly ILog m_log =
  836. LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  837. public event UpdateTaskScript OnUpLoad;
  838. private UpdateTaskScript handlerUpdateTaskScript = null;
  839. private string uploaderPath = String.Empty;
  840. private UUID inventoryItemID;
  841. private UUID primID;
  842. private bool isScriptRunning;
  843. private IHttpServer httpListener;
  844. private bool m_dumpAssetToFile;
  845. public TaskInventoryScriptUpdater(UUID inventoryItemID, UUID primID, int isScriptRunning,
  846. string path, IHttpServer httpServer, bool dumpAssetToFile)
  847. {
  848. m_dumpAssetToFile = dumpAssetToFile;
  849. this.inventoryItemID = inventoryItemID;
  850. this.primID = primID;
  851. // This comes in over the packet as an integer, but actually appears to be treated as a bool
  852. this.isScriptRunning = (0 == isScriptRunning ? false : true);
  853. uploaderPath = path;
  854. httpListener = httpServer;
  855. }
  856. /// <summary>
  857. ///
  858. /// </summary>
  859. /// <param name="data"></param>
  860. /// <param name="path"></param>
  861. /// <param name="param"></param>
  862. /// <returns></returns>
  863. public string uploaderCaps(byte[] data, string path, string param)
  864. {
  865. try
  866. {
  867. // m_log.InfoFormat("[CAPS]: " +
  868. // "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}",
  869. // data, path, param));
  870. string res = String.Empty;
  871. LLSDTaskScriptUploadComplete uploadComplete = new LLSDTaskScriptUploadComplete();
  872. ArrayList errors = new ArrayList();
  873. handlerUpdateTaskScript = OnUpLoad;
  874. if (handlerUpdateTaskScript != null)
  875. {
  876. handlerUpdateTaskScript(inventoryItemID, primID, isScriptRunning, data, ref errors);
  877. }
  878. uploadComplete.new_asset = inventoryItemID;
  879. uploadComplete.compiled = errors.Count > 0 ? false : true;
  880. uploadComplete.state = "complete";
  881. uploadComplete.errors = new OpenSim.Framework.Capabilities.OSDArray();
  882. uploadComplete.errors.Array = errors;
  883. res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
  884. httpListener.RemoveStreamHandler("POST", uploaderPath);
  885. if (m_dumpAssetToFile)
  886. {
  887. SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data);
  888. }
  889. // m_log.InfoFormat("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res);
  890. return res;
  891. }
  892. catch (Exception e)
  893. {
  894. m_log.Error("[CAPS]: " + e.ToString());
  895. }
  896. // XXX Maybe this should be some meaningful error packet
  897. return null;
  898. }
  899. ///Left this in and commented in case there are unforseen issues
  900. //private void SaveAssetToFile(string filename, byte[] data)
  901. //{
  902. // FileStream fs = File.Create(filename);
  903. // BinaryWriter bw = new BinaryWriter(fs);
  904. // bw.Write(data);
  905. // bw.Close();
  906. // fs.Close();
  907. //}
  908. private static void SaveAssetToFile(string filename, byte[] data)
  909. {
  910. string assetPath = "UserAssets";
  911. if (!Directory.Exists(assetPath))
  912. {
  913. Directory.CreateDirectory(assetPath);
  914. }
  915. FileStream fs = File.Create(Path.Combine(assetPath, filename));
  916. BinaryWriter bw = new BinaryWriter(fs);
  917. bw.Write(data);
  918. bw.Close();
  919. fs.Close();
  920. }
  921. }
  922. public class BakedTextureUploader
  923. {
  924. public event UploadedBakedTexture OnUpLoad;
  925. private UploadedBakedTexture handlerUpLoad = null;
  926. private string uploaderPath = String.Empty;
  927. private UUID newAssetID;
  928. private IHttpServer httpListener;
  929. public BakedTextureUploader(string path, IHttpServer httpServer)
  930. {
  931. newAssetID = UUID.Random();
  932. uploaderPath = path;
  933. httpListener = httpServer;
  934. // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
  935. }
  936. /// <summary>
  937. /// Handle raw uploaded baked texture data.
  938. /// </summary>
  939. /// <param name="data"></param>
  940. /// <param name="path"></param>
  941. /// <param name="param"></param>
  942. /// <returns></returns>
  943. public string uploaderCaps(byte[] data, string path, string param)
  944. {
  945. handlerUpLoad = OnUpLoad;
  946. if (handlerUpLoad != null)
  947. {
  948. Util.FireAndForget(delegate(object o) { handlerUpLoad(newAssetID, data); });
  949. }
  950. string res = String.Empty;
  951. LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
  952. uploadComplete.new_asset = newAssetID.ToString();
  953. uploadComplete.new_inventory_item = UUID.Zero;
  954. uploadComplete.state = "complete";
  955. res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
  956. httpListener.RemoveStreamHandler("POST", uploaderPath);
  957. // m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID);
  958. return res;
  959. }
  960. }
  961. }