aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
diff options
context:
space:
mode:
authorubit2012-09-17 14:34:12 +0200
committerubit2012-09-17 14:34:12 +0200
commit6e115798b7dd7396d493b2fa03fe767e588735eb (patch)
treec0285b996fdccdf1329ac98a3cd48a1c9be69d8d /OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
parentMerge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork (diff)
parentAdd a missing brace, remove a useless temp variable, enable charging. (diff)
downloadopensim-SC-6e115798b7dd7396d493b2fa03fe767e588735eb.zip
opensim-SC-6e115798b7dd7396d493b2fa03fe767e588735eb.tar.gz
opensim-SC-6e115798b7dd7396d493b2fa03fe767e588735eb.tar.bz2
opensim-SC-6e115798b7dd7396d493b2fa03fe767e588735eb.tar.xz
Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs92
1 files changed, 85 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..9982556 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,8 +427,11 @@ 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" ||
434 llsdRequest.asset_type == "mesh" ||
401 llsdRequest.asset_type == "sound") 435 llsdRequest.asset_type == "sound")
402 { 436 {
403 ScenePresence avatar = null; 437 ScenePresence avatar = null;
@@ -428,7 +462,31 @@ 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
467 if (llsdRequest.asset_type == "mesh")
468 {
469 if (llsdRequest.asset_resources == null)
470 {
471 client.SendAgentAlertMessage("Unable to upload asset. missing information.", false);
472
473 LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
474 errorResponse.uploader = "";
475 errorResponse.state = "error";
476 return errorResponse;
477 }
478
479 uint textures_cost = (uint)llsdRequest.asset_resources.texture_list.Array.Count;
480 textures_cost *= (uint)mm.UploadCharge;
481
482 cost = textures_cost;
483 }
484 else
485 {
486 cost = (uint)mm.UploadCharge;
487 }
488
489 if (!mm.UploadCovered(client.AgentId, (int)cost))
432 { 490 {
433 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); 491 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
434 492
@@ -449,9 +507,9 @@ namespace OpenSim.Region.ClientStack.Linden
449 UUID parentFolder = llsdRequest.folder_id; 507 UUID parentFolder = llsdRequest.folder_id;
450 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); 508 string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
451 509
452 AssetUploader uploader = 510 AssetUploaderWithCost uploader =
453 new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, 511 new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
454 llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile); 512 llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost);
455 513
456 m_HostCapsObj.HttpListener.AddStreamHandler( 514 m_HostCapsObj.HttpListener.AddStreamHandler(
457 new BinaryStreamHandler( 515 new BinaryStreamHandler(
@@ -469,11 +527,31 @@ namespace OpenSim.Region.ClientStack.Linden
469 string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase + 527 string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase +
470 uploaderPath; 528 uploaderPath;
471 529
530
472 LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); 531 LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
473 uploadResponse.uploader = uploaderURL; 532 uploadResponse.uploader = uploaderURL;
474 uploadResponse.state = "upload"; 533 uploadResponse.state = "upload";
534 uploadResponse.upload_price = (int)cost;
535
536 // use fake values for now
537 if (llsdRequest.asset_type == "mesh")
538 {
539 uploadResponse.data = new LLSDAssetUploadResponseData();
540 uploadResponse.data.model_streaming_cost = 1.0;
541 uploadResponse.data.simulation_cost = 1.5;
542
543 uploadResponse.data.physics_cost = 2.0;
544 uploadResponse.data.resource_cost = 3.0;
545 uploadResponse.data.upload_price_breakdown.mesh_instance = 1;
546 uploadResponse.data.upload_price_breakdown.mesh_physics = 2;
547 uploadResponse.data.upload_price_breakdown.mesh_streaming = 3;
548 uploadResponse.data.upload_price_breakdown.texture = 5;
549 uploadResponse.data.upload_price_breakdown.model = 4;
550 }
551
475 uploader.OnUpLoad += UploadCompleteHandler; 552 uploader.OnUpLoad += UploadCompleteHandler;
476 return uploadResponse; 553 return uploadResponse;
554
477 } 555 }
478 556
479 /// <summary> 557 /// <summary>
@@ -484,7 +562,7 @@ namespace OpenSim.Region.ClientStack.Linden
484 /// <param name="data"></param> 562 /// <param name="data"></param>
485 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, 563 public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
486 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, 564 UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
487 string assetType) 565 string assetType, uint cost)
488 { 566 {
489 m_log.DebugFormat( 567 m_log.DebugFormat(
490 "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", 568 "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
@@ -703,7 +781,7 @@ namespace OpenSim.Region.ClientStack.Linden
703 781
704 if (AddNewInventoryItem != null) 782 if (AddNewInventoryItem != null)
705 { 783 {
706 AddNewInventoryItem(m_HostCapsObj.AgentID, item); 784 AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost);
707 } 785 }
708 } 786 }
709 787