diff options
author | Melanie | 2012-09-23 19:18:49 +0200 |
---|---|---|
committer | Melanie | 2012-09-23 19:18:49 +0200 |
commit | 291e57afb4bb4fb30230c76b28434da79e337e3f (patch) | |
tree | ff8b8b3e06131ef0d89bdc5b0ae33da4563f2d61 | |
parent | refix prior commit (diff) | |
parent | try to allow free uploads for testing, if users prefix names with "TEST-". Let (diff) | |
download | opensim-SC-291e57afb4bb4fb30230c76b28434da79e337e3f.zip opensim-SC-291e57afb4bb4fb30230c76b28434da79e337e3f.tar.gz opensim-SC-291e57afb4bb4fb30230c76b28434da79e337e3f.tar.bz2 opensim-SC-291e57afb4bb4fb30230c76b28434da79e337e3f.tar.xz |
Merge branch 'ubitwork' into avination
Conflicts:
OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs
6 files changed, 390 insertions, 203 deletions
diff --git a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs index ab6cee5..ae8eb09 100644 --- a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs | |||
@@ -30,12 +30,15 @@ using OpenMetaverse; | |||
30 | 30 | ||
31 | namespace OpenSim.Framework.Capabilities | 31 | namespace OpenSim.Framework.Capabilities |
32 | { | 32 | { |
33 | |||
33 | [LLSDType("MAP")] | 34 | [LLSDType("MAP")] |
34 | public class LLSDAssetUploadComplete | 35 | public class LLSDAssetUploadComplete |
35 | { | 36 | { |
36 | public string new_asset = String.Empty; | 37 | public string new_asset = String.Empty; |
37 | public UUID new_inventory_item = UUID.Zero; | 38 | public UUID new_inventory_item = UUID.Zero; |
39 | // public UUID new_texture_folder_id = UUID.Zero; | ||
38 | public string state = String.Empty; | 40 | public string state = String.Empty; |
41 | public LLSDAssetUploadError error = null; | ||
39 | //public bool success = false; | 42 | //public bool success = false; |
40 | 43 | ||
41 | public LLSDAssetUploadComplete() | 44 | public LLSDAssetUploadComplete() |
diff --git a/OpenSim/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs index f981bf0..6779cc1 100644 --- a/OpenSim/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs | |||
@@ -45,6 +45,10 @@ namespace OpenSim.Framework.Capabilities | |||
45 | public string asset_type = String.Empty; | 45 | public string asset_type = String.Empty; |
46 | public string description = String.Empty; | 46 | public string description = String.Empty; |
47 | public UUID folder_id = UUID.Zero; | 47 | public UUID folder_id = UUID.Zero; |
48 | public UUID texture_folder_id = UUID.Zero; | ||
49 | public int next_owner_mask = 0; | ||
50 | public int group_mask = 0; | ||
51 | public int everyone_mask = 0; | ||
48 | public string inventory_type = String.Empty; | 52 | public string inventory_type = String.Empty; |
49 | public string name = String.Empty; | 53 | public string name = String.Empty; |
50 | public LLSDAssetResource asset_resources = new LLSDAssetResource(); | 54 | public LLSDAssetResource asset_resources = new LLSDAssetResource(); |
diff --git a/OpenSim/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs index 18285b5..7c4bc97 100644 --- a/OpenSim/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs | |||
@@ -26,10 +26,18 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenMetaverse; | ||
29 | 30 | ||
30 | namespace OpenSim.Framework.Capabilities | 31 | namespace OpenSim.Framework.Capabilities |
31 | { | 32 | { |
32 | [OSDMap] | 33 | [OSDMap] |
34 | public class LLSDAssetUploadError | ||
35 | { | ||
36 | public string message = String.Empty; | ||
37 | public UUID identifier = UUID.Zero; | ||
38 | } | ||
39 | |||
40 | [OSDMap] | ||
33 | public class LLSDAssetUploadResponsePricebrkDown | 41 | public class LLSDAssetUploadResponsePricebrkDown |
34 | { | 42 | { |
35 | public int mesh_streaming; | 43 | public int mesh_streaming; |
@@ -56,11 +64,13 @@ namespace OpenSim.Framework.Capabilities | |||
56 | public string state = String.Empty; | 64 | public string state = String.Empty; |
57 | public int upload_price = 0; | 65 | public int upload_price = 0; |
58 | public LLSDAssetUploadResponseData data = null; | 66 | public LLSDAssetUploadResponseData data = null; |
67 | public LLSDAssetUploadError error = null; | ||
59 | public LLSDAssetUploadResponse() | 68 | public LLSDAssetUploadResponse() |
60 | { | 69 | { |
61 | } | 70 | } |
62 | } | 71 | } |
63 | 72 | ||
73 | |||
64 | [OSDMap] | 74 | [OSDMap] |
65 | public class LLSDNewFileAngentInventoryVariablePriceReplyResponse | 75 | public class LLSDNewFileAngentInventoryVariablePriceReplyResponse |
66 | { | 76 | { |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index d66076d..21a1005 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -54,8 +54,10 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap; | |||
54 | namespace OpenSim.Region.ClientStack.Linden | 54 | namespace OpenSim.Region.ClientStack.Linden |
55 | { | 55 | { |
56 | public delegate void UpLoadedAsset( | 56 | public delegate void UpLoadedAsset( |
57 | string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, | 57 | string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, |
58 | byte[] data, string inventoryType, string assetType); | 58 | byte[] data, string inventoryType, string assetType, |
59 | int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, | ||
60 | bool IsAtestUpload, ref string error); | ||
59 | 61 | ||
60 | public delegate UUID UpdateItem(UUID itemID, byte[] data); | 62 | public delegate UUID UpdateItem(UUID itemID, byte[] data); |
61 | 63 | ||
@@ -118,6 +120,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
118 | private string m_regionName; | 120 | private string m_regionName; |
119 | private int m_levelUpload = 0; | 121 | private int m_levelUpload = 0; |
120 | private float m_PrimScaleMin = 0.001f; | 122 | private float m_PrimScaleMin = 0.001f; |
123 | private bool m_enableFreeTestUpload = false; | ||
124 | private bool m_enableModelUploadTextureToInventory = false; | ||
125 | private UUID m_testAssetsCreatorID = UUID.Zero; | ||
121 | 126 | ||
122 | private enum FileAgentInventoryState : int | 127 | private enum FileAgentInventoryState : int |
123 | { | 128 | { |
@@ -128,9 +133,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
128 | } | 133 | } |
129 | private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; | 134 | private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; |
130 | 135 | ||
131 | // private bool m_addNewTextures = false; | ||
132 | // private bool m_addNewMeshes = false; | ||
133 | |||
134 | public BunchOfCaps(Scene scene, Caps caps) | 136 | public BunchOfCaps(Scene scene, Caps caps) |
135 | { | 137 | { |
136 | m_Scene = scene; | 138 | m_Scene = scene; |
@@ -145,6 +147,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
145 | // m_ModelCost.ObjectLinkedPartsMax = ?? | 147 | // m_ModelCost.ObjectLinkedPartsMax = ?? |
146 | // m_PrimScaleMin = ?? | 148 | // m_PrimScaleMin = ?? |
147 | 149 | ||
150 | float modelTextureUploadFactor = m_ModelCost.ModelTextureCostFactor; | ||
151 | float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; | ||
152 | float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; | ||
153 | |||
154 | // can be UUID.zero. This is me at OSG, should be a valid grid ID, is case a bad config | ||
155 | UUID.TryParse("58e06f33-ea8c-4ff6-9af5-420606926118", out m_testAssetsCreatorID); | ||
156 | |||
148 | IConfigSource config = m_Scene.Config; | 157 | IConfigSource config = m_Scene.Config; |
149 | if (config != null) | 158 | if (config != null) |
150 | { | 159 | { |
@@ -159,6 +168,29 @@ namespace OpenSim.Region.ClientStack.Linden | |||
159 | { | 168 | { |
160 | m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); | 169 | m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); |
161 | } | 170 | } |
171 | // economy for model upload | ||
172 | IConfig EconomyConfig = config.Configs["Economy"]; | ||
173 | if (EconomyConfig != null) | ||
174 | { | ||
175 | modelUploadFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", modelUploadFactor); | ||
176 | modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); | ||
177 | modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); | ||
178 | m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", false); | ||
179 | |||
180 | m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", false); | ||
181 | string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", m_testAssetsCreatorID.ToString()); | ||
182 | if (testcreator != "") | ||
183 | { | ||
184 | UUID id; | ||
185 | UUID.TryParse(testcreator, out id); | ||
186 | if (id != null) | ||
187 | m_testAssetsCreatorID = id; | ||
188 | } | ||
189 | |||
190 | m_ModelCost.ModelMeshCostFactor = modelUploadFactor; | ||
191 | m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; | ||
192 | m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; | ||
193 | } | ||
162 | } | 194 | } |
163 | 195 | ||
164 | m_assetService = m_Scene.AssetService; | 196 | m_assetService = m_Scene.AssetService; |
@@ -410,37 +442,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
410 | return UUID.Zero; | 442 | return UUID.Zero; |
411 | } | 443 | } |
412 | 444 | ||
413 | private delegate void UploadWithCostCompleteDelegate(string assetName, | ||
414 | string assetDescription, UUID assetID, UUID inventoryItem, | ||
415 | UUID parentFolder, byte[] data, string inventoryType, | ||
416 | string assetType, uint cost); | ||
417 | |||
418 | private class AssetUploaderWithCost : AssetUploader | ||
419 | { | ||
420 | private uint m_cost; | ||
421 | |||
422 | public event UploadWithCostCompleteDelegate OnUpLoad; | ||
423 | |||
424 | public AssetUploaderWithCost(string assetName, string description, UUID assetID, | ||
425 | UUID inventoryItem, UUID parentFolderID, string invType, string assetType, | ||
426 | string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : | ||
427 | base(assetName, description, assetID, inventoryItem, parentFolderID, | ||
428 | invType, assetType, path, httpServer, dumpAssetsToFile) | ||
429 | { | ||
430 | m_cost = cost; | ||
431 | |||
432 | base.OnUpLoad += UploadCompleteHandler; | ||
433 | } | ||
434 | |||
435 | private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, | ||
436 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | ||
437 | string assetType) | ||
438 | { | ||
439 | OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, | ||
440 | data, inventoryType, assetType, m_cost); | ||
441 | } | ||
442 | } | ||
443 | |||
444 | /// <summary> | 445 | /// <summary> |
445 | /// | 446 | /// |
446 | /// </summary> | 447 | /// </summary> |
@@ -462,11 +463,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
462 | { | 463 | { |
463 | case FileAgentInventoryState.processRequest: | 464 | case FileAgentInventoryState.processRequest: |
464 | case FileAgentInventoryState.processUpload: | 465 | case FileAgentInventoryState.processUpload: |
465 | if (client != null) | 466 | LLSDAssetUploadError resperror = new LLSDAssetUploadError(); |
466 | client.SendAgentAlertMessage("Unable to upload asset. Processing previus request", false); | 467 | resperror.message = "Uploader busy processing previus request"; |
468 | resperror.identifier = UUID.Zero; | ||
469 | |||
467 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | 470 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); |
468 | errorResponse.uploader = ""; | 471 | errorResponse.uploader = ""; |
469 | errorResponse.state = "error"; | 472 | errorResponse.state = "error"; |
473 | errorResponse.error = resperror; | ||
470 | return errorResponse; | 474 | return errorResponse; |
471 | break; | 475 | break; |
472 | case FileAgentInventoryState.waitUpload: | 476 | case FileAgentInventoryState.waitUpload: |
@@ -480,7 +484,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
480 | m_FileAgentInventoryState = FileAgentInventoryState.processRequest; | 484 | m_FileAgentInventoryState = FileAgentInventoryState.processRequest; |
481 | } | 485 | } |
482 | 486 | ||
483 | uint cost = 0; | 487 | int cost = 0; |
488 | int nreqtextures = 0; | ||
489 | int nreqmeshs= 0; | ||
490 | int nreqinstances = 0; | ||
491 | bool IsAtestUpload = false; | ||
492 | |||
484 | LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); | 493 | LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); |
485 | 494 | ||
486 | if (llsdRequest.asset_type == "texture" || | 495 | if (llsdRequest.asset_type == "texture" || |
@@ -496,12 +505,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
496 | { | 505 | { |
497 | if (avatar.UserLevel < m_levelUpload) | 506 | if (avatar.UserLevel < m_levelUpload) |
498 | { | 507 | { |
499 | if (client != null) | 508 | LLSDAssetUploadError resperror = new LLSDAssetUploadError(); |
500 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); | 509 | resperror.message = "Insufficient permissions to upload"; |
510 | resperror.identifier = UUID.Zero; | ||
501 | 511 | ||
502 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | 512 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); |
503 | errorResponse.uploader = ""; | 513 | errorResponse.uploader = ""; |
504 | errorResponse.state = "error"; | 514 | errorResponse.state = "error"; |
515 | errorResponse.error = resperror; | ||
505 | lock (m_ModelCost) | 516 | lock (m_ModelCost) |
506 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | 517 | m_FileAgentInventoryState = FileAgentInventoryState.idle; |
507 | return errorResponse; | 518 | return errorResponse; |
@@ -517,40 +528,62 @@ namespace OpenSim.Region.ClientStack.Linden | |||
517 | if (mm != null) | 528 | if (mm != null) |
518 | baseCost = mm.UploadCharge; | 529 | baseCost = mm.UploadCharge; |
519 | 530 | ||
531 | string warning = String.Empty; | ||
532 | |||
520 | if (llsdRequest.asset_type == "mesh") | 533 | if (llsdRequest.asset_type == "mesh") |
521 | { | 534 | { |
522 | string error; | 535 | string error; |
523 | int modelcost; | 536 | int modelcost; |
524 | 537 | ||
525 | if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, | 538 | if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, |
526 | meshcostdata, out error)) | 539 | meshcostdata, out error, ref warning)) |
527 | { | 540 | { |
528 | client.SendAgentAlertMessage(error, false); | 541 | LLSDAssetUploadError resperror = new LLSDAssetUploadError(); |
542 | resperror.message = error; | ||
543 | resperror.identifier = UUID.Zero; | ||
529 | 544 | ||
530 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | 545 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); |
531 | errorResponse.uploader = ""; | 546 | errorResponse.uploader = ""; |
532 | errorResponse.state = "error"; | 547 | errorResponse.state = "error"; |
548 | errorResponse.error = resperror; | ||
549 | |||
533 | lock (m_ModelCost) | 550 | lock (m_ModelCost) |
534 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | 551 | m_FileAgentInventoryState = FileAgentInventoryState.idle; |
535 | return errorResponse; | 552 | return errorResponse; |
536 | } | 553 | } |
537 | cost = (uint)modelcost; | 554 | cost = modelcost; |
538 | } | 555 | } |
539 | else | 556 | else |
540 | { | 557 | { |
541 | cost = (uint)baseCost; | 558 | cost = baseCost; |
559 | } | ||
560 | |||
561 | if (m_enableFreeTestUpload && cost > 0 && mm != null) | ||
562 | { | ||
563 | string str = llsdRequest.name; | ||
564 | if (str.Length > 5 && str.StartsWith("TEST-")) | ||
565 | { | ||
566 | warning += "Upload will have no cost, but for personal test purposes only. Other uses are forbiden"; | ||
567 | IsAtestUpload = true; | ||
568 | } | ||
542 | } | 569 | } |
543 | 570 | ||
571 | if (client != null && warning != String.Empty) | ||
572 | client.SendAgentAlertMessage(warning, true); | ||
573 | |||
544 | // check funds | 574 | // check funds |
545 | if (mm != null) | 575 | if (!IsAtestUpload && mm != null && cost >0) |
546 | { | 576 | { |
547 | if (!mm.UploadCovered(client.AgentId, (int)cost)) | 577 | if (!mm.UploadCovered(client.AgentId, (int)cost)) |
548 | { | 578 | { |
549 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | 579 | LLSDAssetUploadError resperror = new LLSDAssetUploadError(); |
580 | resperror.message = "Insuficient funds"; | ||
581 | resperror.identifier = UUID.Zero; | ||
550 | 582 | ||
551 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | 583 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); |
552 | errorResponse.uploader = ""; | 584 | errorResponse.uploader = ""; |
553 | errorResponse.state = "error"; | 585 | errorResponse.state = "error"; |
586 | errorResponse.error = resperror; | ||
554 | lock (m_ModelCost) | 587 | lock (m_ModelCost) |
555 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | 588 | m_FileAgentInventoryState = FileAgentInventoryState.idle; |
556 | return errorResponse; | 589 | return errorResponse; |
@@ -566,10 +599,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
566 | UUID newInvItem = UUID.Random(); | 599 | UUID newInvItem = UUID.Random(); |
567 | UUID parentFolder = llsdRequest.folder_id; | 600 | UUID parentFolder = llsdRequest.folder_id; |
568 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | 601 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); |
602 | UUID texturesFolder = UUID.Zero; | ||
569 | 603 | ||
570 | AssetUploaderWithCost uploader = | 604 | if(!IsAtestUpload && m_enableModelUploadTextureToInventory) |
571 | new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | 605 | texturesFolder = llsdRequest.texture_folder_id; |
572 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); | 606 | |
607 | AssetUploader uploader = | ||
608 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | ||
609 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, | ||
610 | texturesFolder, nreqtextures, nreqmeshs, nreqinstances,IsAtestUpload); | ||
573 | 611 | ||
574 | m_HostCapsObj.HttpListener.AddStreamHandler( | 612 | m_HostCapsObj.HttpListener.AddStreamHandler( |
575 | new BinaryStreamHandler( | 613 | new BinaryStreamHandler( |
@@ -614,8 +652,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
614 | /// <param name="data"></param> | 652 | /// <param name="data"></param> |
615 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, | 653 | public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, |
616 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | 654 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, |
617 | string assetType, uint cost) | 655 | string assetType, int cost, |
656 | UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, | ||
657 | bool IsAtestUpload, ref string error) | ||
618 | { | 658 | { |
659 | |||
619 | lock (m_ModelCost) | 660 | lock (m_ModelCost) |
620 | m_FileAgentInventoryState = FileAgentInventoryState.processUpload; | 661 | m_FileAgentInventoryState = FileAgentInventoryState.processUpload; |
621 | 662 | ||
@@ -626,7 +667,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
626 | sbyte assType = 0; | 667 | sbyte assType = 0; |
627 | sbyte inType = 0; | 668 | sbyte inType = 0; |
628 | 669 | ||
629 | IClientAPI client = null; | 670 | UUID owner_id = m_HostCapsObj.AgentID; |
671 | UUID creatorID; | ||
672 | |||
673 | bool istest = IsAtestUpload && m_enableFreeTestUpload && (cost > 0); | ||
674 | |||
675 | if (istest) | ||
676 | creatorID = m_testAssetsCreatorID; | ||
677 | else | ||
678 | creatorID = owner_id; | ||
679 | |||
680 | string creatorIDstr = creatorID.ToString(); | ||
630 | 681 | ||
631 | IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>(); | 682 | IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>(); |
632 | if (mm != null) | 683 | if (mm != null) |
@@ -634,13 +685,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
634 | // make sure client still has enougth credit | 685 | // make sure client still has enougth credit |
635 | if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost)) | 686 | if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost)) |
636 | { | 687 | { |
637 | m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); | 688 | error = "Insufficient funds."; |
638 | if (client != null) | ||
639 | client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); | ||
640 | return; | 689 | return; |
641 | } | 690 | } |
642 | } | 691 | } |
643 | 692 | ||
693 | // strings to types | ||
644 | if (inventoryType == "sound") | 694 | if (inventoryType == "sound") |
645 | { | 695 | { |
646 | inType = (sbyte)InventoryType.Sound; | 696 | inType = (sbyte)InventoryType.Sound; |
@@ -674,109 +724,87 @@ namespace OpenSim.Region.ClientStack.Linden | |||
674 | List<Vector3> positions = new List<Vector3>(); | 724 | List<Vector3> positions = new List<Vector3>(); |
675 | List<Quaternion> rotations = new List<Quaternion>(); | 725 | List<Quaternion> rotations = new List<Quaternion>(); |
676 | OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); | 726 | OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); |
727 | |||
728 | // compare and get updated information | ||
729 | |||
730 | bool mismatchError = true; | ||
731 | |||
732 | while (mismatchError) | ||
733 | { | ||
734 | mismatchError = false; | ||
735 | } | ||
736 | |||
737 | if (mismatchError) | ||
738 | { | ||
739 | error = "Upload and fee estimation information don't match"; | ||
740 | lock (m_ModelCost) | ||
741 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | ||
742 | |||
743 | return; | ||
744 | } | ||
745 | |||
677 | OSDArray instance_list = (OSDArray)request["instance_list"]; | 746 | OSDArray instance_list = (OSDArray)request["instance_list"]; |
678 | OSDArray mesh_list = (OSDArray)request["mesh_list"]; | 747 | OSDArray mesh_list = (OSDArray)request["mesh_list"]; |
679 | OSDArray texture_list = (OSDArray)request["texture_list"]; | 748 | OSDArray texture_list = (OSDArray)request["texture_list"]; |
680 | SceneObjectGroup grp = null; | 749 | SceneObjectGroup grp = null; |
681 | 750 | ||
682 | // create and store texture assets | 751 | // create and store texture assets |
752 | bool doTextInv = (!istest && m_enableModelUploadTextureToInventory && | ||
753 | texturesFolder != UUID.Zero); | ||
754 | |||
755 | |||
683 | List<UUID> textures = new List<UUID>(); | 756 | List<UUID> textures = new List<UUID>(); |
757 | |||
684 | for (int i = 0; i < texture_list.Count; i++) | 758 | for (int i = 0; i < texture_list.Count; i++) |
685 | { | 759 | { |
686 | AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, ""); | 760 | AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, creatorIDstr); |
687 | textureAsset.Data = texture_list[i].AsBinary(); | 761 | textureAsset.Data = texture_list[i].AsBinary(); |
688 | m_assetService.Store(textureAsset); | 762 | m_assetService.Store(textureAsset); |
689 | textures.Add(textureAsset.FullID); | 763 | textures.Add(textureAsset.FullID); |
690 | /* | 764 | |
691 | don't do this | 765 | if (doTextInv) |
692 | replace it by optionaly making model textures cost less than if individually uploaded | 766 | { |
693 | since they can't be used for other purpuses | 767 | string name = assetName; |
694 | 768 | if (name.Length > 25) | |
695 | // save it to inventory | 769 | name = name.Substring(0, 24); |
696 | if (m_addNewTextures && AddNewInventoryItem != null) | 770 | name += "_Texture#" + i.ToString(); |
697 | { | 771 | InventoryItemBase texitem = new InventoryItemBase(); |
698 | string name = assetName; | 772 | texitem.Owner = m_HostCapsObj.AgentID; |
699 | if (name.Length > 25) | 773 | texitem.CreatorId = creatorIDstr; |
700 | name = name.Substring(0, 24); | 774 | texitem.CreatorData = String.Empty; |
701 | name += "_Texture#" + i.ToString(); | 775 | texitem.ID = UUID.Random(); |
702 | InventoryItemBase texitem = new InventoryItemBase(); | 776 | texitem.AssetID = textureAsset.FullID; |
703 | texitem.Owner = m_HostCapsObj.AgentID; | 777 | texitem.Description = "mesh model texture"; |
704 | texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); | 778 | texitem.Name = name; |
705 | texitem.CreatorData = String.Empty; | 779 | texitem.AssetType = (int)AssetType.Texture; |
706 | texitem.ID = UUID.Random(); | 780 | texitem.InvType = (int)InventoryType.Texture; |
707 | texitem.AssetID = textureAsset.FullID; | 781 | texitem.Folder = texturesFolder; |
708 | texitem.Description = "mesh model texture"; | 782 | |
709 | texitem.Name = name; | 783 | texitem.CurrentPermissions |
710 | texitem.AssetType = (int)AssetType.Texture; | 784 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); |
711 | texitem.InvType = (int)InventoryType.Texture; | 785 | |
712 | texitem.Folder = UUID.Zero; // send to default | 786 | texitem.BasePermissions = (uint)PermissionMask.All; |
713 | 787 | texitem.EveryOnePermissions = 0; | |
714 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current | 788 | texitem.NextPermissions = (uint)PermissionMask.All; |
715 | // (owner) permissions. This becomes a problem if next permissions are changed. | 789 | texitem.CreationDate = Util.UnixTimeSinceEpoch(); |
716 | texitem.CurrentPermissions | 790 | |
717 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); | 791 | AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); |
718 | 792 | texitem = null; | |
719 | texitem.BasePermissions = (uint)PermissionMask.All; | 793 | // this aren't showing up in viewer until relog :( |
720 | texitem.EveryOnePermissions = 0; | 794 | } |
721 | texitem.NextPermissions = (uint)PermissionMask.All; | ||
722 | texitem.CreationDate = Util.UnixTimeSinceEpoch(); | ||
723 | |||
724 | AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); | ||
725 | texitem = null; | ||
726 | } | ||
727 | */ | ||
728 | textureAsset = null; | ||
729 | } | 795 | } |
730 | 796 | ||
731 | // create and store meshs assets | 797 | // create and store meshs assets |
732 | List<UUID> meshAssets = new List<UUID>(); | 798 | List<UUID> meshAssets = new List<UUID>(); |
733 | for (int i = 0; i < mesh_list.Count; i++) | 799 | for (int i = 0; i < mesh_list.Count; i++) |
734 | { | 800 | { |
735 | AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); | 801 | AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); |
736 | meshAsset.Data = mesh_list[i].AsBinary(); | 802 | meshAsset.Data = mesh_list[i].AsBinary(); |
737 | m_assetService.Store(meshAsset); | 803 | m_assetService.Store(meshAsset); |
738 | meshAssets.Add(meshAsset.FullID); | 804 | meshAssets.Add(meshAsset.FullID); |
739 | |||
740 | /* this was a test, funny and showed viewers deal with mesh inventory itens | ||
741 | * nut also same reason as for textures | ||
742 | * let integrated in a model cost eventually less than hipotetical independent meshs assets | ||
743 | * that will be in inventory | ||
744 | // save it to inventory | ||
745 | if (m_addNewMeshes && AddNewInventoryItem != null) | ||
746 | { | ||
747 | string name = assetName; | ||
748 | if (name.Length > 25) | ||
749 | name = name.Substring(0, 24); | ||
750 | name += "_Mesh#" + i.ToString(); | ||
751 | InventoryItemBase meshitem = new InventoryItemBase(); | ||
752 | meshitem.Owner = m_HostCapsObj.AgentID; | ||
753 | meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); | ||
754 | meshitem.CreatorData = String.Empty; | ||
755 | meshitem.ID = UUID.Random(); | ||
756 | meshitem.AssetID = meshAsset.FullID; | ||
757 | meshitem.Description = "mesh "; | ||
758 | meshitem.Name = name; | ||
759 | meshitem.AssetType = (int)AssetType.Mesh; | ||
760 | meshitem.InvType = (int)InventoryType.Mesh; | ||
761 | meshitem.Folder = UUID.Zero; // send to default | ||
762 | |||
763 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current | ||
764 | // (owner) permissions. This becomes a problem if next permissions are changed. | ||
765 | meshitem.CurrentPermissions | ||
766 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); | ||
767 | |||
768 | meshitem.BasePermissions = (uint)PermissionMask.All; | ||
769 | meshitem.EveryOnePermissions = 0; | ||
770 | meshitem.NextPermissions = (uint)PermissionMask.All; | ||
771 | meshitem.CreationDate = Util.UnixTimeSinceEpoch(); | ||
772 | |||
773 | AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); | ||
774 | meshitem = null; | ||
775 | } | ||
776 | */ | ||
777 | meshAsset = null; | ||
778 | } | 805 | } |
779 | 806 | ||
807 | int skipedMeshs = 0; | ||
780 | // build prims from instances | 808 | // build prims from instances |
781 | for (int i = 0; i < instance_list.Count; i++) | 809 | for (int i = 0; i < instance_list.Count; i++) |
782 | { | 810 | { |
@@ -784,9 +812,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
784 | 812 | ||
785 | // skip prims that are 2 small | 813 | // skip prims that are 2 small |
786 | Vector3 scale = inner_instance_list["scale"].AsVector3(); | 814 | Vector3 scale = inner_instance_list["scale"].AsVector3(); |
787 | 815 | ||
788 | if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) | 816 | if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) |
817 | { | ||
818 | skipedMeshs++; | ||
789 | continue; | 819 | continue; |
820 | } | ||
790 | 821 | ||
791 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); | 822 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); |
792 | 823 | ||
@@ -836,21 +867,33 @@ namespace OpenSim.Region.ClientStack.Linden | |||
836 | 867 | ||
837 | pbs.TextureEntry = textureEntry.GetBytes(); | 868 | pbs.TextureEntry = textureEntry.GetBytes(); |
838 | 869 | ||
839 | int meshindx = inner_instance_list["mesh"].AsInteger(); | 870 | bool hasmesh = false; |
840 | if (meshAssets.Count > meshindx) | 871 | if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ... |
841 | { | 872 | { |
842 | pbs.SculptEntry = true; | 873 | int meshindx = inner_instance_list["mesh"].AsInteger(); |
843 | pbs.SculptType = (byte)SculptType.Mesh; | 874 | if (meshAssets.Count > meshindx) |
844 | pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction | 875 | { |
845 | // data will be requested from asset on rez (i hope) | 876 | pbs.SculptEntry = true; |
877 | pbs.SculptType = (byte)SculptType.Mesh; | ||
878 | pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction | ||
879 | // data will be requested from asset on rez (i hope) | ||
880 | hasmesh = true; | ||
881 | } | ||
846 | } | 882 | } |
847 | 883 | ||
848 | Vector3 position = inner_instance_list["position"].AsVector3(); | 884 | Vector3 position = inner_instance_list["position"].AsVector3(); |
849 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); | 885 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); |
850 | 886 | ||
887 | // for now viwers do send fixed defaults | ||
888 | // but this may change | ||
889 | // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); | ||
890 | byte physicsShapeType = (byte)PhysShapeType.prim; // default for mesh is simple convex | ||
891 | if(hasmesh) | ||
892 | physicsShapeType = (byte) PhysShapeType.convex; // default for mesh is simple convex | ||
893 | // int material = inner_instance_list["material"].AsInteger(); | ||
894 | byte material = (byte)Material.Wood; | ||
895 | |||
851 | // no longer used - begin ------------------------ | 896 | // no longer used - begin ------------------------ |
852 | // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); | ||
853 | // int material = inner_instance_list["material"].AsInteger(); | ||
854 | // int mesh = inner_instance_list["mesh"].AsInteger(); | 897 | // int mesh = inner_instance_list["mesh"].AsInteger(); |
855 | 898 | ||
856 | // OSDMap permissions = (OSDMap)inner_instance_list["permissions"]; | 899 | // OSDMap permissions = (OSDMap)inner_instance_list["permissions"]; |
@@ -866,23 +909,41 @@ namespace OpenSim.Region.ClientStack.Linden | |||
866 | // int owner_mask = permissions["owner_mask"].AsInteger(); | 909 | // int owner_mask = permissions["owner_mask"].AsInteger(); |
867 | // no longer used - end ------------------------ | 910 | // no longer used - end ------------------------ |
868 | 911 | ||
869 | UUID owner_id = m_HostCapsObj.AgentID; | 912 | |
870 | 913 | ||
871 | SceneObjectPart prim | 914 | SceneObjectPart prim |
872 | = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); | 915 | = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); |
873 | 916 | ||
874 | prim.Scale = scale; | 917 | prim.Scale = scale; |
875 | prim.OffsetPosition = position; | 918 | // prim.OffsetPosition = position; |
876 | rotations.Add(rotation); | 919 | rotations.Add(rotation); |
877 | positions.Add(position); | 920 | positions.Add(position); |
878 | prim.UUID = UUID.Random(); | 921 | prim.UUID = UUID.Random(); |
879 | prim.CreatorID = owner_id; | 922 | prim.CreatorID = creatorID; |
880 | prim.OwnerID = owner_id; | 923 | prim.OwnerID = owner_id; |
881 | prim.GroupID = UUID.Zero; | 924 | prim.GroupID = UUID.Zero; |
882 | prim.LastOwnerID = prim.OwnerID; | 925 | prim.LastOwnerID = creatorID; |
883 | prim.CreationDate = Util.UnixTimeSinceEpoch(); | 926 | prim.CreationDate = Util.UnixTimeSinceEpoch(); |
884 | prim.Name = assetName; | 927 | |
885 | prim.Description = ""; | 928 | if (grp == null) |
929 | prim.Name = assetName; | ||
930 | else | ||
931 | prim.Name = assetName + "#" + i.ToString(); | ||
932 | |||
933 | if (istest) | ||
934 | { | ||
935 | prim.BaseMask = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
936 | prim.EveryoneMask = 0; | ||
937 | prim.GroupMask = 0; | ||
938 | prim.NextOwnerMask = 0; | ||
939 | prim.OwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
940 | |||
941 | prim.Description = "For personal testing only. Other uses are forbiden"; | ||
942 | } | ||
943 | else | ||
944 | prim.Description = ""; | ||
945 | prim.Material = material; | ||
946 | prim.PhysicsShapeType = physicsShapeType; | ||
886 | 947 | ||
887 | // prim.BaseMask = (uint)base_mask; | 948 | // prim.BaseMask = (uint)base_mask; |
888 | // prim.EveryoneMask = (uint)everyone_mask; | 949 | // prim.EveryoneMask = (uint)everyone_mask; |
@@ -891,30 +952,48 @@ namespace OpenSim.Region.ClientStack.Linden | |||
891 | // prim.OwnerMask = (uint)owner_mask; | 952 | // prim.OwnerMask = (uint)owner_mask; |
892 | 953 | ||
893 | if (grp == null) | 954 | if (grp == null) |
955 | { | ||
894 | grp = new SceneObjectGroup(prim); | 956 | grp = new SceneObjectGroup(prim); |
957 | grp.LastOwnerID = creatorID; | ||
958 | } | ||
895 | else | 959 | else |
896 | grp.AddPart(prim); | 960 | grp.AddPart(prim); |
897 | } | 961 | } |
898 | 962 | ||
899 | // Fix first link number | 963 | Vector3 rootPos = positions[0]; |
964 | |||
900 | if (grp.Parts.Length > 1) | 965 | if (grp.Parts.Length > 1) |
966 | { | ||
967 | // Fix first link number | ||
901 | grp.RootPart.LinkNum++; | 968 | grp.RootPart.LinkNum++; |
902 | 969 | ||
903 | Vector3 rootPos = positions[0]; | 970 | Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]); |
904 | grp.AbsolutePosition = rootPos; | 971 | Quaternion tmprot; |
905 | for (int i = 0; i < positions.Count; i++) | 972 | Vector3 offset; |
906 | { | 973 | |
907 | Vector3 offset = positions[i] - rootPos; | 974 | // fix children rotations and positions |
908 | grp.Parts[i].OffsetPosition = offset; | 975 | for (int i = 1; i < rotations.Count; i++) |
909 | } | 976 | { |
977 | tmprot = rotations[i]; | ||
978 | tmprot = rootRotConj * tmprot; | ||
979 | |||
980 | grp.Parts[i].RotationOffset = tmprot; | ||
910 | 981 | ||
911 | for (int i = 0; i < rotations.Count; i++) | 982 | offset = positions[i] - rootPos; |
983 | |||
984 | offset *= rootRotConj; | ||
985 | grp.Parts[i].OffsetPosition = offset; | ||
986 | } | ||
987 | |||
988 | grp.AbsolutePosition = rootPos; | ||
989 | grp.UpdateGroupRotationR(rotations[0]); | ||
990 | } | ||
991 | else | ||
912 | { | 992 | { |
913 | if (i != 0) | 993 | grp.AbsolutePosition = rootPos; |
914 | grp.Parts[i].RotationOffset = rotations[i]; | 994 | grp.UpdateGroupRotationR(rotations[0]); |
915 | } | 995 | } |
916 | 996 | ||
917 | grp.UpdateGroupRotationR(rotations[0]); | ||
918 | data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); | 997 | data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); |
919 | } | 998 | } |
920 | 999 | ||
@@ -926,7 +1005,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
926 | } | 1005 | } |
927 | 1006 | ||
928 | AssetBase asset; | 1007 | AssetBase asset; |
929 | asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString()); | 1008 | asset = new AssetBase(assetID, assetName, assType, creatorIDstr); |
930 | asset.Data = data; | 1009 | asset.Data = data; |
931 | if (AddNewAsset != null) | 1010 | if (AddNewAsset != null) |
932 | AddNewAsset(asset); | 1011 | AddNewAsset(asset); |
@@ -935,11 +1014,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
935 | 1014 | ||
936 | InventoryItemBase item = new InventoryItemBase(); | 1015 | InventoryItemBase item = new InventoryItemBase(); |
937 | item.Owner = m_HostCapsObj.AgentID; | 1016 | item.Owner = m_HostCapsObj.AgentID; |
938 | item.CreatorId = m_HostCapsObj.AgentID.ToString(); | 1017 | item.CreatorId = creatorIDstr; |
939 | item.CreatorData = String.Empty; | 1018 | item.CreatorData = String.Empty; |
940 | item.ID = inventoryItem; | 1019 | item.ID = inventoryItem; |
941 | item.AssetID = asset.FullID; | 1020 | item.AssetID = asset.FullID; |
942 | item.Description = assetDescription; | 1021 | if (istest) |
1022 | item.Description = "For personal testing only. Other uses are forbiden"; | ||
1023 | else | ||
1024 | item.Description = assetDescription; | ||
943 | item.Name = assetName; | 1025 | item.Name = assetName; |
944 | item.AssetType = assType; | 1026 | item.AssetType = assType; |
945 | item.InvType = inType; | 1027 | item.InvType = inType; |
@@ -947,18 +1029,56 @@ namespace OpenSim.Region.ClientStack.Linden | |||
947 | 1029 | ||
948 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current | 1030 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current |
949 | // (owner) permissions. This becomes a problem if next permissions are changed. | 1031 | // (owner) permissions. This becomes a problem if next permissions are changed. |
950 | item.CurrentPermissions | ||
951 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); | ||
952 | 1032 | ||
953 | item.BasePermissions = (uint)PermissionMask.All; | 1033 | if (istest) |
954 | item.EveryOnePermissions = 0; | 1034 | { |
955 | item.NextPermissions = (uint)PermissionMask.All; | 1035 | item.CurrentPermissions |
1036 | = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
1037 | |||
1038 | item.BasePermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); | ||
1039 | item.EveryOnePermissions = 0; | ||
1040 | item.NextPermissions = 0; | ||
1041 | } | ||
1042 | else | ||
1043 | { | ||
1044 | item.CurrentPermissions | ||
1045 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); | ||
1046 | |||
1047 | item.BasePermissions = (uint)PermissionMask.All; | ||
1048 | item.EveryOnePermissions = 0; | ||
1049 | item.NextPermissions = (uint)PermissionMask.All; | ||
1050 | } | ||
1051 | |||
956 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 1052 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
957 | 1053 | ||
1054 | IClientAPI client = null; | ||
1055 | m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); | ||
1056 | |||
958 | if (AddNewInventoryItem != null) | 1057 | if (AddNewInventoryItem != null) |
959 | { | 1058 | { |
960 | AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); | 1059 | if (istest) |
1060 | { | ||
1061 | AddNewInventoryItem(m_HostCapsObj.AgentID, item, 0); | ||
1062 | if (client != null) | ||
1063 | client.SendAgentAlertMessage("Upload complete with no cost for personal testing purposes only. Other uses are forbiden", true); | ||
1064 | } | ||
1065 | else | ||
1066 | { | ||
1067 | AddNewInventoryItem(m_HostCapsObj.AgentID, item, (uint)cost); | ||
1068 | if (client != null) | ||
1069 | { | ||
1070 | // let users see anything.. i don't so far | ||
1071 | string str; | ||
1072 | if (cost > 0) | ||
1073 | // dont remember where is money unit name to put here | ||
1074 | str = "Upload complete. charged " + cost.ToString() + "$"; | ||
1075 | else | ||
1076 | str = "Upload complete"; | ||
1077 | client.SendAgentAlertMessage(str, true); | ||
1078 | } | ||
1079 | } | ||
961 | } | 1080 | } |
1081 | |||
962 | lock (m_ModelCost) | 1082 | lock (m_ModelCost) |
963 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | 1083 | m_FileAgentInventoryState = FileAgentInventoryState.idle; |
964 | } | 1084 | } |
@@ -1273,6 +1393,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1273 | private static readonly ILog m_log = | 1393 | private static readonly ILog m_log = |
1274 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 1394 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
1275 | 1395 | ||
1396 | |||
1276 | public event UpLoadedAsset OnUpLoad; | 1397 | public event UpLoadedAsset OnUpLoad; |
1277 | private UpLoadedAsset handlerUpLoad = null; | 1398 | private UpLoadedAsset handlerUpLoad = null; |
1278 | 1399 | ||
@@ -1287,11 +1408,21 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1287 | 1408 | ||
1288 | private string m_invType = String.Empty; | 1409 | private string m_invType = String.Empty; |
1289 | private string m_assetType = String.Empty; | 1410 | private string m_assetType = String.Empty; |
1411 | private int m_cost; | ||
1412 | private string m_error = String.Empty; | ||
1413 | |||
1290 | private Timer m_timeoutTimer = new Timer(); | 1414 | private Timer m_timeoutTimer = new Timer(); |
1415 | private UUID m_texturesFolder; | ||
1416 | private int m_nreqtextures; | ||
1417 | private int m_nreqmeshs; | ||
1418 | private int m_nreqinstances; | ||
1419 | private bool m_IsAtestUpload; | ||
1291 | 1420 | ||
1292 | public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, | 1421 | public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, |
1293 | UUID parentFolderID, string invType, string assetType, string path, | 1422 | UUID parentFolderID, string invType, string assetType, string path, |
1294 | IHttpServer httpServer, bool dumpAssetsToFile) | 1423 | IHttpServer httpServer, bool dumpAssetsToFile, |
1424 | int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, | ||
1425 | bool IsAtestUpload) | ||
1295 | { | 1426 | { |
1296 | m_assetName = assetName; | 1427 | m_assetName = assetName; |
1297 | m_assetDes = description; | 1428 | m_assetDes = description; |
@@ -1303,6 +1434,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1303 | m_assetType = assetType; | 1434 | m_assetType = assetType; |
1304 | m_invType = invType; | 1435 | m_invType = invType; |
1305 | m_dumpAssetsToFile = dumpAssetsToFile; | 1436 | m_dumpAssetsToFile = dumpAssetsToFile; |
1437 | m_cost = totalCost; | ||
1438 | |||
1439 | m_texturesFolder = texturesFolder; | ||
1440 | m_nreqtextures = nreqtextures; | ||
1441 | m_nreqmeshs = nreqmeshs; | ||
1442 | m_nreqinstances = nreqinstances; | ||
1443 | m_IsAtestUpload = IsAtestUpload; | ||
1306 | 1444 | ||
1307 | m_timeoutTimer.Elapsed += TimedOut; | 1445 | m_timeoutTimer.Elapsed += TimedOut; |
1308 | m_timeoutTimer.Interval = 120000; | 1446 | m_timeoutTimer.Interval = 120000; |
@@ -1322,12 +1460,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1322 | UUID inv = inventoryItemID; | 1460 | UUID inv = inventoryItemID; |
1323 | string res = String.Empty; | 1461 | string res = String.Empty; |
1324 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); | 1462 | LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); |
1463 | /* | ||
1325 | uploadComplete.new_asset = newAssetID.ToString(); | 1464 | uploadComplete.new_asset = newAssetID.ToString(); |
1326 | uploadComplete.new_inventory_item = inv; | 1465 | uploadComplete.new_inventory_item = inv; |
1327 | uploadComplete.state = "complete"; | 1466 | uploadComplete.state = "complete"; |
1328 | 1467 | ||
1329 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | 1468 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); |
1330 | 1469 | */ | |
1331 | m_timeoutTimer.Stop(); | 1470 | m_timeoutTimer.Stop(); |
1332 | httpListener.RemoveStreamHandler("POST", uploaderPath); | 1471 | httpListener.RemoveStreamHandler("POST", uploaderPath); |
1333 | 1472 | ||
@@ -1345,8 +1484,28 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1345 | handlerUpLoad = OnUpLoad; | 1484 | handlerUpLoad = OnUpLoad; |
1346 | if (handlerUpLoad != null) | 1485 | if (handlerUpLoad != null) |
1347 | { | 1486 | { |
1348 | handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); | 1487 | handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, |
1488 | m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, ref m_error); | ||
1349 | } | 1489 | } |
1490 | if(m_error == String.Empty) | ||
1491 | { | ||
1492 | uploadComplete.new_asset = newAssetID.ToString(); | ||
1493 | uploadComplete.new_inventory_item = inv; | ||
1494 | // if (m_texturesFolder != UUID.Zero) | ||
1495 | // uploadComplete.new_texture_folder_id = m_texturesFolder; | ||
1496 | uploadComplete.state = "complete"; | ||
1497 | } | ||
1498 | else | ||
1499 | { | ||
1500 | LLSDAssetUploadError resperror = new LLSDAssetUploadError(); | ||
1501 | resperror.message = m_error; | ||
1502 | resperror.identifier = inv; | ||
1503 | |||
1504 | uploadComplete.error = resperror; | ||
1505 | uploadComplete.state = "failed"; | ||
1506 | } | ||
1507 | |||
1508 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | ||
1350 | return res; | 1509 | return res; |
1351 | } | 1510 | } |
1352 | 1511 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index da701ba..66bb429 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | |||
@@ -31,7 +31,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
31 | public class ModelCost | 31 | public class ModelCost |
32 | { | 32 | { |
33 | 33 | ||
34 | // upload fee tunning paramenters | 34 | // upload fee defaults |
35 | // fees are normalized to 1.0 | 35 | // fees are normalized to 1.0 |
36 | // this parameters scale them to basic cost ( so 1.0 translates to 10 ) | 36 | // this parameters scale them to basic cost ( so 1.0 translates to 10 ) |
37 | 37 | ||
@@ -42,7 +42,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
42 | 42 | ||
43 | public float ModelTextureCostFactor = 1.00f; // keep full price because texture price | 43 | public float ModelTextureCostFactor = 1.00f; // keep full price because texture price |
44 | // is based on it's storage needs not on usability | 44 | // is based on it's storage needs not on usability |
45 | |||
46 | // itens costs in normalized values | 45 | // itens costs in normalized values |
47 | // ie will be multiplied by basicCost and factors above | 46 | // ie will be multiplied by basicCost and factors above |
48 | const float primCreationCost = 0.002f; // extra cost for each prim creation overhead | 47 | const float primCreationCost = 0.002f; // extra cost for each prim creation overhead |
@@ -100,7 +99,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
100 | // basicCost input region assets upload cost | 99 | // basicCost input region assets upload cost |
101 | // totalcost returns model total upload fee | 100 | // totalcost returns model total upload fee |
102 | // meshcostdata returns detailed costs for viewer | 101 | // meshcostdata returns detailed costs for viewer |
103 | public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, LLSDAssetUploadResponseData meshcostdata, out string error) | 102 | public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, |
103 | LLSDAssetUploadResponseData meshcostdata, out string error, ref string warning) | ||
104 | { | 104 | { |
105 | totalcost = 0; | 105 | totalcost = 0; |
106 | error = string.Empty; | 106 | error = string.Empty; |
@@ -109,7 +109,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
109 | resources.instance_list == null || | 109 | resources.instance_list == null || |
110 | resources.instance_list.Array.Count == 0) | 110 | resources.instance_list.Array.Count == 0) |
111 | { | 111 | { |
112 | error = "Unable to upload mesh model. missing information."; | 112 | error = "missing model information."; |
113 | return false; | 113 | return false; |
114 | } | 114 | } |
115 | 115 | ||
@@ -117,7 +117,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
117 | 117 | ||
118 | if( numberInstances > ObjectLinkedPartsMax ) | 118 | if( numberInstances > ObjectLinkedPartsMax ) |
119 | { | 119 | { |
120 | error = "upload failed: Model whould have two many linked prims"; | 120 | error = "Model whould have more than " + ObjectLinkedPartsMax.ToString() + " linked prims"; |
121 | return false; | 121 | return false; |
122 | } | 122 | } |
123 | 123 | ||
@@ -190,15 +190,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
190 | 190 | ||
191 | if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) | 191 | if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) |
192 | { | 192 | { |
193 | // error = " upload fail: Model contains parts with a dimension lower than 0.001. Please adjust scaling"; | ||
194 | // return false; | ||
195 | skipedSmall++; | 193 | skipedSmall++; |
196 | continue; | 194 | continue; |
197 | } | 195 | } |
198 | 196 | ||
199 | if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) | 197 | if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) |
200 | { | 198 | { |
201 | error = "upload fail: Model contains parts larger than maximum allowed. Please adjust scaling"; | 199 | error = "Model contains parts with sides larger than " + NonPhysicalPrimScaleMax.ToString() + "m. Please ajust scale"; |
202 | return false; | 200 | return false; |
203 | } | 201 | } |
204 | 202 | ||
@@ -208,7 +206,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
208 | 206 | ||
209 | if (mesh >= numberMeshs) | 207 | if (mesh >= numberMeshs) |
210 | { | 208 | { |
211 | error = "Unable to upload mesh model. incoerent information."; | 209 | error = "Incoerent model information."; |
212 | return false; | 210 | return false; |
213 | } | 211 | } |
214 | 212 | ||
@@ -235,10 +233,18 @@ namespace OpenSim.Region.ClientStack.Linden | |||
235 | meshsfee += primCreationCost; | 233 | meshsfee += primCreationCost; |
236 | } | 234 | } |
237 | 235 | ||
238 | if (skipedSmall >0 && skipedSmall > numberInstances / 2) | 236 | if (skipedSmall > 0) |
239 | { | 237 | { |
240 | error = "Upload failed: Model contains too much prims smaller than minimum size to ignore"; | 238 | if (skipedSmall > numberInstances / 2) |
241 | return false; | 239 | { |
240 | error = "Model contains too many prims smaller than " + PrimScaleMin.ToString() + | ||
241 | "m minimum allowed size. Please check scalling"; | ||
242 | return false; | ||
243 | } | ||
244 | else | ||
245 | warning += skipedSmall.ToString() + " of the requested " +numberInstances.ToString() + | ||
246 | " model prims will not upload because they are smaller than " + PrimScaleMin.ToString() + | ||
247 | "m minimum allowed size. Please check scalling "; | ||
242 | } | 248 | } |
243 | 249 | ||
244 | if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) | 250 | if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) |
@@ -283,14 +289,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
283 | 289 | ||
284 | if (data == null || data.Length == 0) | 290 | if (data == null || data.Length == 0) |
285 | { | 291 | { |
286 | error = "Unable to upload mesh model. missing information."; | 292 | error = "Missing model information."; |
287 | return false; | 293 | return false; |
288 | } | 294 | } |
289 | 295 | ||
290 | OSD meshOsd = null; | 296 | OSD meshOsd = null; |
291 | int start = 0; | 297 | int start = 0; |
292 | 298 | ||
293 | error = "Unable to upload mesh model. Invalid data"; | 299 | error = "Invalid model data"; |
294 | 300 | ||
295 | using (MemoryStream ms = new MemoryStream(data)) | 301 | using (MemoryStream ms = new MemoryStream(data)) |
296 | { | 302 | { |
@@ -338,13 +344,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
338 | 344 | ||
339 | if (submesh_offset < 0 || hulls_size == 0) | 345 | if (submesh_offset < 0 || hulls_size == 0) |
340 | { | 346 | { |
341 | error = "Unable to upload mesh model. missing physics_convex block"; | 347 | error = "Missing physics_convex block"; |
342 | return false; | 348 | return false; |
343 | } | 349 | } |
344 | 350 | ||
345 | if (!hulls(data, submesh_offset, hulls_size, out phys_hullsvertices, out phys_nhulls)) | 351 | if (!hulls(data, submesh_offset, hulls_size, out phys_hullsvertices, out phys_nhulls)) |
346 | { | 352 | { |
347 | error = "Unable to upload mesh model. bad physics_convex block"; | 353 | error = "Bad physics_convex block"; |
348 | return false; | 354 | return false; |
349 | } | 355 | } |
350 | 356 | ||
@@ -364,7 +370,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
364 | 370 | ||
365 | if (submesh_offset < 0 || highlod_size <= 0) | 371 | if (submesh_offset < 0 || highlod_size <= 0) |
366 | { | 372 | { |
367 | error = "Unable to upload mesh model. missing high_lod"; | 373 | error = "Missing high_lod block"; |
368 | return false; | 374 | return false; |
369 | } | 375 | } |
370 | 376 | ||
@@ -409,9 +415,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
409 | 415 | ||
410 | submesh_offset = -1; | 416 | submesh_offset = -1; |
411 | 417 | ||
412 | if (map.ContainsKey("physics_mesh")) | 418 | tmpmap = null; |
413 | { | 419 | if(map.ContainsKey("physics_mesh")) |
414 | tmpmap = (OSDMap)map["physics_mesh"]; | 420 | tmpmap = (OSDMap)map["physics_mesh"]; |
421 | else if (map.ContainsKey("physics_shape")) // old naming | ||
422 | tmpmap = (OSDMap)map["physics_shape"]; | ||
423 | |||
424 | if(tmpmap != null) | ||
425 | { | ||
415 | if (tmpmap.ContainsKey("offset")) | 426 | if (tmpmap.ContainsKey("offset")) |
416 | submesh_offset = tmpmap["offset"].AsInteger() + start; | 427 | submesh_offset = tmpmap["offset"].AsInteger() + start; |
417 | if (tmpmap.ContainsKey("size")) | 428 | if (tmpmap.ContainsKey("size")) |
@@ -422,7 +433,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
422 | 433 | ||
423 | if (!submesh(data, submesh_offset, physmesh_size, out phys_ntriangles)) | 434 | if (!submesh(data, submesh_offset, physmesh_size, out phys_ntriangles)) |
424 | { | 435 | { |
425 | error = "Unable to upload mesh model. parsing error"; | 436 | error = "Model data parsing error"; |
426 | return false; | 437 | return false; |
427 | } | 438 | } |
428 | } | 439 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs index 44a6883..0251ac4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs | |||
@@ -129,15 +129,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
129 | // m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request"); | 129 | // m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request"); |
130 | 130 | ||
131 | OSDMap data = new OSDMap(); | 131 | OSDMap data = new OSDMap(); |
132 | ScenePresence sp = m_scene.GetScenePresence(m_agentID); | 132 | // ScenePresence sp = m_scene.GetScenePresence(m_agentID); |
133 | data["username"] = sp.Firstname + "." + sp.Lastname; | 133 | // data["username"] = sp.Firstname + "." + sp.Lastname; |
134 | data["display_name_next_update"] = new OSDDate(DateTime.Now); | 134 | // data["display_name_next_update"] = new OSDDate(DateTime.Now); |
135 | data["legacy_first_name"] = sp.Firstname; | 135 | // data["legacy_first_name"] = sp.Firstname; |
136 | data["mesh_upload_status"] = "valid"; | 136 | data["mesh_upload_status"] = "valid"; |
137 | data["display_name"] = sp.Firstname + " " + sp.Lastname; | 137 | // data["display_name"] = sp.Firstname + " " + sp.Lastname; |
138 | data["legacy_last_name"] = sp.Lastname; | 138 | // data["legacy_last_name"] = sp.Lastname; |
139 | data["id"] = m_agentID; | 139 | // data["id"] = m_agentID; |
140 | data["is_display_name_default"] = true; | 140 | // data["is_display_name_default"] = true; |
141 | 141 | ||
142 | //Send back data | 142 | //Send back data |
143 | Hashtable responsedata = new Hashtable(); | 143 | Hashtable responsedata = new Hashtable(); |