diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/Communications/Capabilities/Caps.cs | |
parent | * Deleted .user file (diff) | |
download | opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/Capabilities/Caps.cs | 136 |
1 files changed, 79 insertions, 57 deletions
diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a114b64..23dfcc6 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs | |||
@@ -28,18 +28,23 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | ||
32 | using System.IO; | 31 | using System.IO; |
33 | using libsecondlife; | 32 | using libsecondlife; |
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications.Cache; | 34 | using OpenSim.Framework.Communications.Cache; |
35 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Framework.Servers; | 36 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Framework; | ||
37 | 37 | ||
38 | namespace OpenSim.Region.Capabilities | 38 | namespace OpenSim.Region.Capabilities |
39 | { | 39 | { |
40 | public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType); | 40 | public delegate void UpLoadedAsset( |
41 | string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, | ||
42 | string inventoryType, string assetType); | ||
43 | |||
41 | public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); | 44 | public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); |
45 | |||
42 | public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); | 46 | public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); |
47 | |||
43 | public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); | 48 | public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); |
44 | 49 | ||
45 | public class Caps | 50 | public class Caps |
@@ -62,7 +67,8 @@ namespace OpenSim.Region.Capabilities | |||
62 | public ItemUpdatedCallback ItemUpdatedCall = null; | 67 | public ItemUpdatedCallback ItemUpdatedCall = null; |
63 | private bool m_dumpAssetsToFile; | 68 | private bool m_dumpAssetsToFile; |
64 | 69 | ||
65 | public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) | 70 | public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, |
71 | LLUUID agent, bool dumpAssetsToFile) | ||
66 | { | 72 | { |
67 | assetCache = assetCach; | 73 | assetCache = assetCach; |
68 | m_capsObjectPath = capsPath; | 74 | m_capsObjectPath = capsPath; |
@@ -78,12 +84,17 @@ namespace OpenSim.Region.Capabilities | |||
78 | /// </summary> | 84 | /// </summary> |
79 | public void RegisterHandlers() | 85 | public void RegisterHandlers() |
80 | { | 86 | { |
81 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CAPS","Registering CAPS handlers"); | 87 | MainLog.Instance.Verbose("CAPS", "Registering CAPS handlers"); |
82 | string capsBase = "/CAPS/" + m_capsObjectPath; | 88 | string capsBase = "/CAPS/" + m_capsObjectPath; |
83 | try | 89 | try |
84 | { | 90 | { |
85 | httpListener.AddStreamHandler(new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, this.GetMapLayer)); | 91 | httpListener.AddStreamHandler( |
86 | httpListener.AddStreamHandler(new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); | 92 | new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, |
93 | GetMapLayer)); | ||
94 | httpListener.AddStreamHandler( | ||
95 | new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", | ||
96 | capsBase + m_newInventory, | ||
97 | NewAgentInventoryRequest)); | ||
87 | 98 | ||
88 | AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); | 99 | AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); |
89 | //AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture); | 100 | //AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture); |
@@ -103,7 +114,7 @@ namespace OpenSim.Region.Capabilities | |||
103 | string capsBase = "/CAPS/" + m_capsObjectPath; | 114 | string capsBase = "/CAPS/" + m_capsObjectPath; |
104 | httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); | 115 | httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); |
105 | } | 116 | } |
106 | 117 | ||
107 | /// <summary> | 118 | /// <summary> |
108 | /// | 119 | /// |
109 | /// </summary> | 120 | /// </summary> |
@@ -113,8 +124,8 @@ namespace OpenSim.Region.Capabilities | |||
113 | /// <returns></returns> | 124 | /// <returns></returns> |
114 | public string CapsRequest(string request, string path, string param) | 125 | public string CapsRequest(string request, string path, string param) |
115 | { | 126 | { |
116 | // Console.WriteLine("caps request " + request); | 127 | // Console.WriteLine("caps request " + request); |
117 | string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); | 128 | string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); |
118 | return result; | 129 | return result; |
119 | } | 130 | } |
120 | 131 | ||
@@ -125,9 +136,10 @@ namespace OpenSim.Region.Capabilities | |||
125 | protected LLSDCapsDetails GetCapabilities() | 136 | protected LLSDCapsDetails GetCapabilities() |
126 | { | 137 | { |
127 | LLSDCapsDetails caps = new LLSDCapsDetails(); | 138 | LLSDCapsDetails caps = new LLSDCapsDetails(); |
128 | string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; | 139 | string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + |
140 | m_capsObjectPath; | ||
129 | caps.MapLayer = capsBaseUrl + m_mapLayerPath; | 141 | caps.MapLayer = capsBaseUrl + m_mapLayerPath; |
130 | // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; | 142 | // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; |
131 | caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; | 143 | caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; |
132 | caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; | 144 | caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; |
133 | caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; | 145 | caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; |
@@ -142,7 +154,7 @@ namespace OpenSim.Region.Capabilities | |||
142 | public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) | 154 | public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) |
143 | { | 155 | { |
144 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); | 156 | LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); |
145 | mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse()); | 157 | mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); |
146 | return mapResponse; | 158 | return mapResponse; |
147 | } | 159 | } |
148 | 160 | ||
@@ -174,6 +186,7 @@ namespace OpenSim.Region.Capabilities | |||
174 | } | 186 | } |
175 | 187 | ||
176 | #region EventQueue (Currently not enabled) | 188 | #region EventQueue (Currently not enabled) |
189 | |||
177 | /// <summary> | 190 | /// <summary> |
178 | /// | 191 | /// |
179 | /// </summary> | 192 | /// </summary> |
@@ -184,10 +197,10 @@ namespace OpenSim.Region.Capabilities | |||
184 | public string ProcessEventQueue(string request, string path, string param) | 197 | public string ProcessEventQueue(string request, string path, string param) |
185 | { | 198 | { |
186 | string res = ""; | 199 | string res = ""; |
187 | 200 | ||
188 | if (this.CapsEventQueue.Count > 0) | 201 | if (CapsEventQueue.Count > 0) |
189 | { | 202 | { |
190 | lock (this.CapsEventQueue) | 203 | lock (CapsEventQueue) |
191 | { | 204 | { |
192 | string item = CapsEventQueue.Dequeue(); | 205 | string item = CapsEventQueue.Dequeue(); |
193 | res = item; | 206 | res = item; |
@@ -195,7 +208,7 @@ namespace OpenSim.Region.Capabilities | |||
195 | } | 208 | } |
196 | else | 209 | else |
197 | { | 210 | { |
198 | res = this.CreateEmptyEventResponse(); | 211 | res = CreateEmptyEventResponse(); |
199 | } | 212 | } |
200 | return res; | 213 | return res; |
201 | } | 214 | } |
@@ -214,8 +227,8 @@ namespace OpenSim.Region.Capabilities | |||
214 | eventItem.events.Array.Add(new LLSDEmpty()); | 227 | eventItem.events.Array.Add(new LLSDEmpty()); |
215 | string res = LLSDHelpers.SerialiseLLSDReply(eventItem); | 228 | string res = LLSDHelpers.SerialiseLLSDReply(eventItem); |
216 | eventQueueCount++; | 229 | eventQueueCount++; |
217 | 230 | ||
218 | this.CapsEventQueue.Enqueue(res); | 231 | CapsEventQueue.Enqueue(res); |
219 | return res; | 232 | return res; |
220 | } | 233 | } |
221 | 234 | ||
@@ -232,6 +245,7 @@ namespace OpenSim.Region.Capabilities | |||
232 | eventQueueCount++; | 245 | eventQueueCount++; |
233 | return res; | 246 | return res; |
234 | } | 247 | } |
248 | |||
235 | #endregion | 249 | #endregion |
236 | 250 | ||
237 | /// <summary> | 251 | /// <summary> |
@@ -243,24 +257,27 @@ namespace OpenSim.Region.Capabilities | |||
243 | /// <returns></returns> | 257 | /// <returns></returns> |
244 | public string NoteCardAgentInventory(string request, string path, string param) | 258 | public string NoteCardAgentInventory(string request, string path, string param) |
245 | { | 259 | { |
246 | Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); | 260 | Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); |
247 | LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); | 261 | LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); |
248 | LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); | 262 | LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); |
249 | 263 | ||
250 | string capsBase = "/CAPS/" + m_capsObjectPath; | 264 | string capsBase = "/CAPS/" + m_capsObjectPath; |
251 | LLUUID newInvItem = llsdRequest.item_id; | 265 | LLUUID newInvItem = llsdRequest.item_id; |
252 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | 266 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); |
253 | 267 | ||
254 | ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener, m_dumpAssetsToFile ); | 268 | ItemUpdater uploader = |
255 | uploader.OnUpLoad += this.ItemUpdated; | 269 | new ItemUpdater(newInvItem, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile); |
270 | uploader.OnUpLoad += ItemUpdated; | ||
256 | 271 | ||
257 | httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | 272 | httpListener.AddStreamHandler( |
258 | string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; | 273 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); |
274 | string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + | ||
275 | uploaderPath; | ||
259 | 276 | ||
260 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); | 277 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); |
261 | uploadResponse.uploader = uploaderURL; | 278 | uploadResponse.uploader = uploaderURL; |
262 | uploadResponse.state = "upload"; | 279 | uploadResponse.state = "upload"; |
263 | 280 | ||
264 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); | 281 | return LLSDHelpers.SerialiseLLSDReply(uploadResponse); |
265 | } | 282 | } |
266 | 283 | ||
@@ -272,7 +289,7 @@ namespace OpenSim.Region.Capabilities | |||
272 | public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) | 289 | public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) |
273 | { | 290 | { |
274 | //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); | 291 | //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); |
275 | 292 | ||
276 | string assetName = llsdRequest.name; | 293 | string assetName = llsdRequest.name; |
277 | string assetDes = llsdRequest.description; | 294 | string assetDes = llsdRequest.description; |
278 | string capsBase = "/CAPS/" + m_capsObjectPath; | 295 | string capsBase = "/CAPS/" + m_capsObjectPath; |
@@ -281,14 +298,18 @@ namespace OpenSim.Region.Capabilities | |||
281 | LLUUID parentFolder = llsdRequest.folder_id; | 298 | LLUUID parentFolder = llsdRequest.folder_id; |
282 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | 299 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); |
283 | 300 | ||
284 | AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, this.httpListener, m_dumpAssetsToFile); | 301 | AssetUploader uploader = |
285 | httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | 302 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, |
286 | string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; | 303 | llsdRequest.asset_type, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile); |
304 | httpListener.AddStreamHandler( | ||
305 | new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); | ||
306 | string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + | ||
307 | uploaderPath; | ||
287 | 308 | ||
288 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); | 309 | LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); |
289 | uploadResponse.uploader = uploaderURL; | 310 | uploadResponse.uploader = uploaderURL; |
290 | uploadResponse.state = "upload"; | 311 | uploadResponse.state = "upload"; |
291 | uploader.OnUpLoad += this.UploadCompleteHandler; | 312 | uploader.OnUpLoad += UploadCompleteHandler; |
292 | return uploadResponse; | 313 | return uploadResponse; |
293 | } | 314 | } |
294 | 315 | ||
@@ -298,7 +319,9 @@ namespace OpenSim.Region.Capabilities | |||
298 | /// <param name="assetID"></param> | 319 | /// <param name="assetID"></param> |
299 | /// <param name="inventoryItem"></param> | 320 | /// <param name="inventoryItem"></param> |
300 | /// <param name="data"></param> | 321 | /// <param name="data"></param> |
301 | public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType) | 322 | public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, |
323 | LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, | ||
324 | string assetType) | ||
302 | { | 325 | { |
303 | sbyte assType = 0; | 326 | sbyte assType = 0; |
304 | sbyte inType = 0; | 327 | sbyte inType = 0; |
@@ -319,14 +342,14 @@ namespace OpenSim.Region.Capabilities | |||
319 | asset.FullID = assetID; | 342 | asset.FullID = assetID; |
320 | asset.Type = assType; | 343 | asset.Type = assType; |
321 | asset.InvType = inType; | 344 | asset.InvType = inType; |
322 | asset.Name = assetName; | 345 | asset.Name = assetName; |
323 | asset.Data = data; | 346 | asset.Data = data; |
324 | this.assetCache.AddAsset(asset); | 347 | assetCache.AddAsset(asset); |
325 | 348 | ||
326 | InventoryItemBase item = new InventoryItemBase(); | 349 | InventoryItemBase item = new InventoryItemBase(); |
327 | item.avatarID = agentID; | 350 | item.avatarID = agentID; |
328 | item.creatorsID = agentID; | 351 | item.creatorsID = agentID; |
329 | item.inventoryID = inventoryItem; | 352 | item.inventoryID = inventoryItem; |
330 | item.assetID = asset.FullID; | 353 | item.assetID = asset.FullID; |
331 | item.inventoryDescription = assetDescription; | 354 | item.inventoryDescription = assetDescription; |
332 | item.inventoryName = assetName; | 355 | item.inventoryName = assetName; |
@@ -340,14 +363,13 @@ namespace OpenSim.Region.Capabilities | |||
340 | { | 363 | { |
341 | AddNewInventoryItem(agentID, item); | 364 | AddNewInventoryItem(agentID, item); |
342 | } | 365 | } |
343 | |||
344 | } | 366 | } |
345 | 367 | ||
346 | public LLUUID ItemUpdated(LLUUID itemID, byte[] data) | 368 | public LLUUID ItemUpdated(LLUUID itemID, byte[] data) |
347 | { | 369 | { |
348 | if (ItemUpdatedCall != null) | 370 | if (ItemUpdatedCall != null) |
349 | { | 371 | { |
350 | return ItemUpdatedCall(this.agentID, itemID, data); | 372 | return ItemUpdatedCall(agentID, itemID, data); |
351 | } | 373 | } |
352 | return LLUUID.Zero; | 374 | return LLUUID.Zero; |
353 | } | 375 | } |
@@ -359,7 +381,7 @@ namespace OpenSim.Region.Capabilities | |||
359 | private string uploaderPath = ""; | 381 | private string uploaderPath = ""; |
360 | private LLUUID newAssetID; | 382 | private LLUUID newAssetID; |
361 | private LLUUID inventoryItemID; | 383 | private LLUUID inventoryItemID; |
362 | private LLUUID parentFolder; | 384 | private LLUUID parentFolder; |
363 | private BaseHttpServer httpListener; | 385 | private BaseHttpServer httpListener; |
364 | private bool m_dumpAssetsToFile; | 386 | private bool m_dumpAssetsToFile; |
365 | private string m_assetName = ""; | 387 | private string m_assetName = ""; |
@@ -368,7 +390,9 @@ namespace OpenSim.Region.Capabilities | |||
368 | private string m_invType = ""; | 390 | private string m_invType = ""; |
369 | private string m_assetType = ""; | 391 | private string m_assetType = ""; |
370 | 392 | ||
371 | public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer, bool dumpAssetsToFile) | 393 | public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, |
394 | LLUUID parentFolderID, string invType, string assetType, string path, | ||
395 | BaseHttpServer httpServer, bool dumpAssetsToFile) | ||
372 | { | 396 | { |
373 | m_assetName = assetName; | 397 | m_assetName = assetName; |
374 | m_assetDes = description; | 398 | m_assetDes = description; |
@@ -391,7 +415,7 @@ namespace OpenSim.Region.Capabilities | |||
391 | /// <returns></returns> | 415 | /// <returns></returns> |
392 | public string uploaderCaps(byte[] data, string path, string param) | 416 | public string uploaderCaps(byte[] data, string path, string param) |
393 | { | 417 | { |
394 | LLUUID inv = this.inventoryItemID; | 418 | LLUUID inv = inventoryItemID; |
395 | string res = ""; | 419 | string res = ""; |
396 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | 420 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); |
397 | uploadComplete.new_asset = newAssetID.ToStringHyphenated(); | 421 | uploadComplete.new_asset = newAssetID.ToStringHyphenated(); |
@@ -399,29 +423,29 @@ namespace OpenSim.Region.Capabilities | |||
399 | uploadComplete.state = "complete"; | 423 | uploadComplete.state = "complete"; |
400 | 424 | ||
401 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | 425 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); |
402 | 426 | ||
403 | httpListener.RemoveStreamHandler("POST", uploaderPath); | 427 | httpListener.RemoveStreamHandler("POST", uploaderPath); |
404 | 428 | ||
405 | if (this.m_dumpAssetsToFile) | 429 | if (m_dumpAssetsToFile) |
406 | { | 430 | { |
407 | this.SaveAssetToFile(m_assetName + ".jp2", data); | 431 | SaveAssetToFile(m_assetName + ".jp2", data); |
408 | } | 432 | } |
409 | 433 | ||
410 | if (OnUpLoad != null) | 434 | if (OnUpLoad != null) |
411 | { | 435 | { |
412 | OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); | 436 | OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); |
413 | } | 437 | } |
414 | 438 | ||
415 | return res; | 439 | return res; |
416 | } | 440 | } |
417 | 441 | ||
418 | private void SaveAssetToFile(string filename, byte[] data) | 442 | private void SaveAssetToFile(string filename, byte[] data) |
419 | { | 443 | { |
420 | FileStream fs = File.Create(filename); | 444 | FileStream fs = File.Create(filename); |
421 | BinaryWriter bw = new BinaryWriter(fs); | 445 | BinaryWriter bw = new BinaryWriter(fs); |
422 | bw.Write(data); | 446 | bw.Write(data); |
423 | bw.Close(); | 447 | bw.Close(); |
424 | fs.Close(); | 448 | fs.Close(); |
425 | } | 449 | } |
426 | } | 450 | } |
427 | 451 | ||
@@ -434,7 +458,7 @@ namespace OpenSim.Region.Capabilities | |||
434 | private BaseHttpServer httpListener; | 458 | private BaseHttpServer httpListener; |
435 | private bool m_dumpAssetToFile; | 459 | private bool m_dumpAssetToFile; |
436 | 460 | ||
437 | public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) | 461 | public ItemUpdater(LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) |
438 | { | 462 | { |
439 | m_dumpAssetToFile = dumpAssetToFile; | 463 | m_dumpAssetToFile = dumpAssetToFile; |
440 | 464 | ||
@@ -452,7 +476,7 @@ namespace OpenSim.Region.Capabilities | |||
452 | /// <returns></returns> | 476 | /// <returns></returns> |
453 | public string uploaderCaps(byte[] data, string path, string param) | 477 | public string uploaderCaps(byte[] data, string path, string param) |
454 | { | 478 | { |
455 | LLUUID inv = this.inventoryItemID; | 479 | LLUUID inv = inventoryItemID; |
456 | string res = ""; | 480 | string res = ""; |
457 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | 481 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); |
458 | LLUUID assetID = LLUUID.Zero; | 482 | LLUUID assetID = LLUUID.Zero; |
@@ -461,7 +485,7 @@ namespace OpenSim.Region.Capabilities | |||
461 | { | 485 | { |
462 | assetID = OnUpLoad(inv, data); | 486 | assetID = OnUpLoad(inv, data); |
463 | } | 487 | } |
464 | 488 | ||
465 | uploadComplete.new_asset = assetID.ToStringHyphenated(); | 489 | uploadComplete.new_asset = assetID.ToStringHyphenated(); |
466 | uploadComplete.new_inventory_item = inv; | 490 | uploadComplete.new_inventory_item = inv; |
467 | uploadComplete.state = "complete"; | 491 | uploadComplete.state = "complete"; |
@@ -470,9 +494,9 @@ namespace OpenSim.Region.Capabilities | |||
470 | 494 | ||
471 | httpListener.RemoveStreamHandler("POST", uploaderPath); | 495 | httpListener.RemoveStreamHandler("POST", uploaderPath); |
472 | 496 | ||
473 | if (this.m_dumpAssetToFile) | 497 | if (m_dumpAssetToFile) |
474 | { | 498 | { |
475 | this.SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); | 499 | SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); |
476 | } | 500 | } |
477 | 501 | ||
478 | return res; | 502 | return res; |
@@ -488,6 +512,4 @@ namespace OpenSim.Region.Capabilities | |||
488 | } | 512 | } |
489 | } | 513 | } |
490 | } | 514 | } |
491 | } | 515 | } \ No newline at end of file |
492 | |||
493 | |||