diff options
author | Melanie | 2012-09-11 17:28:13 +0200 |
---|---|---|
committer | Melanie | 2012-09-11 17:28:13 +0200 |
commit | bd1d9a214b7f8750427d670566c8f99ff62f33c4 (patch) | |
tree | f379f826369488f768fc718d45b99b62c23e3bec /OpenSim/Region/ClientStack | |
parent | Remove the unused NewFileAgentInventoryVariablePrice module. (diff) | |
download | opensim-SC_OLD-bd1d9a214b7f8750427d670566c8f99ff62f33c4.zip opensim-SC_OLD-bd1d9a214b7f8750427d670566c8f99ff62f33c4.tar.gz opensim-SC_OLD-bd1d9a214b7f8750427d670566c8f99ff62f33c4.tar.bz2 opensim-SC_OLD-bd1d9a214b7f8750427d670566c8f99ff62f33c4.tar.xz |
Add the option to have variable costing for uploads
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 51 |
1 files changed, 44 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..097e224 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,38 @@ 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 | |||
420 | |||
389 | /// <summary> | 421 | /// <summary> |
390 | /// | 422 | /// |
391 | /// </summary> | 423 | /// </summary> |
@@ -396,6 +428,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
396 | //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); | 428 | //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); |
397 | //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); | 429 | //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); |
398 | 430 | ||
431 | uint cost = 0; | ||
432 | |||
399 | if (llsdRequest.asset_type == "texture" || | 433 | if (llsdRequest.asset_type == "texture" || |
400 | llsdRequest.asset_type == "animation" || | 434 | llsdRequest.asset_type == "animation" || |
401 | llsdRequest.asset_type == "sound") | 435 | llsdRequest.asset_type == "sound") |
@@ -428,7 +462,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
428 | 462 | ||
429 | if (mm != null) | 463 | if (mm != null) |
430 | { | 464 | { |
431 | if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) | 465 | // XPTO: The cost should be calculated about here |
466 | cost = (uint)mm.UploadCharge; | ||
467 | |||
468 | if (!mm.UploadCovered(client.AgentId, (int)cost)) | ||
432 | { | 469 | { |
433 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | 470 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); |
434 | 471 | ||
@@ -449,9 +486,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
449 | UUID parentFolder = llsdRequest.folder_id; | 486 | UUID parentFolder = llsdRequest.folder_id; |
450 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | 487 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); |
451 | 488 | ||
452 | AssetUploader uploader = | 489 | AssetUploaderWithCost uploader = |
453 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | 490 | new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, |
454 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile); | 491 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); |
455 | 492 | ||
456 | m_HostCapsObj.HttpListener.AddStreamHandler( | 493 | m_HostCapsObj.HttpListener.AddStreamHandler( |
457 | new BinaryStreamHandler( | 494 | new BinaryStreamHandler( |
@@ -484,7 +521,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
484 | /// <param name="data"></param> | 521 | /// <param name="data"></param> |
485 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, | 522 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, |
486 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | 523 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, |
487 | string assetType) | 524 | string assetType, uint cost) |
488 | { | 525 | { |
489 | m_log.DebugFormat( | 526 | m_log.DebugFormat( |
490 | "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", | 527 | "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", |
@@ -703,7 +740,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
703 | 740 | ||
704 | if (AddNewInventoryItem != null) | 741 | if (AddNewInventoryItem != null) |
705 | { | 742 | { |
706 | AddNewInventoryItem(m_HostCapsObj.AgentID, item); | 743 | AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); |
707 | } | 744 | } |
708 | } | 745 | } |
709 | 746 | ||