diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 88c4d7f..328dc75 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
60 | 60 | ||
61 | 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); |
62 | 62 | ||
63 | public delegate void NewInventoryItem(UUID userID, InventoryItemBase item); | 63 | public delegate void NewInventoryItem(UUID userID, InventoryItemBase item, uint cost); |
64 | 64 | ||
65 | public delegate void NewAsset(AssetBase asset); | 65 | public delegate void NewAsset(AssetBase asset); |
66 | 66 | ||
@@ -386,6 +386,37 @@ namespace OpenSim.Region.ClientStack.Linden | |||
386 | return UUID.Zero; | 386 | return UUID.Zero; |
387 | } | 387 | } |
388 | 388 | ||
389 | private delegate void UploadWithCostCompleteDelegate(string assetName, | ||
390 | string assetDescription, UUID assetID, UUID inventoryItem, | ||
391 | UUID parentFolder, byte[] data, string inventoryType, | ||
392 | string assetType, uint cost); | ||
393 | |||
394 | private class AssetUploaderWithCost : AssetUploader | ||
395 | { | ||
396 | private uint m_cost; | ||
397 | |||
398 | public event UploadWithCostCompleteDelegate OnUpLoad; | ||
399 | |||
400 | public AssetUploaderWithCost(string assetName, string description, UUID assetID, | ||
401 | UUID inventoryItem, UUID parentFolderID, string invType, string assetType, | ||
402 | string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : | ||
403 | base(assetName, description, assetID, inventoryItem, parentFolderID, | ||
404 | invType, assetType, path, httpServer, dumpAssetsToFile) | ||
405 | { | ||
406 | m_cost = cost; | ||
407 | |||
408 | base.OnUpLoad += UploadCompleteHandler; | ||
409 | } | ||
410 | |||
411 | private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, | ||
412 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | ||
413 | string assetType) | ||
414 | { | ||
415 | OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, | ||
416 | data, inventoryType, assetType, m_cost); | ||
417 | } | ||
418 | } | ||
419 | |||
389 | /// <summary> | 420 | /// <summary> |
390 | /// | 421 | /// |
391 | /// </summary> | 422 | /// </summary> |
@@ -396,6 +427,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
396 | //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); | 427 | //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); |
397 | //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); | 428 | //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); |
398 | 429 | ||
430 | uint cost = 0; | ||
431 | |||
399 | if (llsdRequest.asset_type == "texture" || | 432 | if (llsdRequest.asset_type == "texture" || |
400 | llsdRequest.asset_type == "animation" || | 433 | llsdRequest.asset_type == "animation" || |
401 | llsdRequest.asset_type == "sound") | 434 | llsdRequest.asset_type == "sound") |
@@ -428,7 +461,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
428 | 461 | ||
429 | if (mm != null) | 462 | if (mm != null) |
430 | { | 463 | { |
431 | if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) | 464 | // XPTO: The cost should be calculated about here |
465 | cost = (uint)mm.UploadCharge; | ||
466 | |||
467 | if (!mm.UploadCovered(client.AgentId, (int)cost)) | ||
432 | { | 468 | { |
433 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | 469 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); |
434 | 470 | ||
@@ -449,9 +485,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
449 | UUID parentFolder = llsdRequest.folder_id; | 485 | UUID parentFolder = llsdRequest.folder_id; |
450 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | 486 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); |
451 | 487 | ||
452 | AssetUploader uploader = | 488 | AssetUploaderWithCost uploader = |
453 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | 489 | new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, |
454 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile); | 490 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); |
455 | 491 | ||
456 | m_HostCapsObj.HttpListener.AddStreamHandler( | 492 | m_HostCapsObj.HttpListener.AddStreamHandler( |
457 | new BinaryStreamHandler( | 493 | new BinaryStreamHandler( |
@@ -484,7 +520,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
484 | /// <param name="data"></param> | 520 | /// <param name="data"></param> |
485 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, | 521 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, |
486 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | 522 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, |
487 | string assetType) | 523 | string assetType, uint cost) |
488 | { | 524 | { |
489 | m_log.DebugFormat( | 525 | m_log.DebugFormat( |
490 | "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", | 526 | "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", |
@@ -703,7 +739,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
703 | 739 | ||
704 | if (AddNewInventoryItem != null) | 740 | if (AddNewInventoryItem != null) |
705 | { | 741 | { |
706 | AddNewInventoryItem(m_HostCapsObj.AgentID, item); | 742 | AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); |
707 | } | 743 | } |
708 | } | 744 | } |
709 | 745 | ||