diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 24fe0f4f57..338604db82 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -34,6 +34,9 @@ using libsecondlife; using log4net; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; +using OpenSim.Framework; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Framework.Communications.Capabilities { @@ -606,6 +609,29 @@ namespace OpenSim.Framework.Communications.Capabilities /// public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { + if (llsdRequest.asset_type == "texture" || + llsdRequest.asset_type == "animation" || + llsdRequest.asset_type == "sound") + { + IClientAPI client = GetClient(m_agentID); + Scene scene = (Scene)client.Scene; + + IMoneyModule mm = scene.RequestModuleInterface(); + + if(mm != null) + { + if(!mm.UploadCovered(client)) + { + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + } + //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); string assetName = llsdRequest.name; diff --git a/OpenSim/Region/Environment/Interfaces/IMoneyModule.cs b/OpenSim/Region/Environment/Interfaces/IMoneyModule.cs index eae67020ee..49d096b378 100644 --- a/OpenSim/Region/Environment/Interfaces/IMoneyModule.cs +++ b/OpenSim/Region/Environment/Interfaces/IMoneyModule.cs @@ -36,7 +36,10 @@ namespace OpenSim.Region.Environment.Interfaces { bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID, int amount); + + int GetBalance(IClientAPI client); void ApplyUploadCharge(LLUUID agentID); + bool UploadCovered(IClientAPI client); event ObjectPaid OnObjectPaid; } diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs index fd407d9f5f..d8720dbb4c 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs @@ -261,6 +261,23 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal, bool tempFile) { + if ((AssetType)type == AssetType.Texture || + (AssetType)type == AssetType.Sound || + (AssetType)type == AssetType.TextureTGA || + (AssetType)type == AssetType.Animation) + { + Scene scene = (Scene)remoteClient.Scene; + IMoneyModule mm = scene.RequestModuleInterface(); + if (mm != null) + { + if (!mm.UploadCovered(remoteClient)) + { + remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + return; + } + } + } + // Console.WriteLine("asset upload of " + assetID); AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); @@ -288,4 +305,4 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction transactions.HandleXfer(xferID, packetID, data); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs index f038975748..e31770f3fa 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs @@ -266,11 +266,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney scene.SetObjectCapacity(ObjectCapacity); } - /// - /// New Client Event Handler - /// - /// - private void OnNewClient(IClientAPI client) + private void GetClientFunds(IClientAPI client) { // Here we check if we're in grid mode // I imagine that the 'check balance' @@ -343,6 +339,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney CheckExistAndRefreshFunds(client.AgentId); } + } + + /// + /// New Client Event Handler + /// + /// + private void OnNewClient(IClientAPI client) + { + GetClientFunds(client); + // Subscribe to Money messages client.OnEconomyDataRequest += EconomyDataRequestHandler; client.OnMoneyBalanceRequest += SendMoneyBalance; @@ -1525,6 +1531,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient); } + public int GetBalance(IClientAPI client) + { + GetClientFunds(client); + + lock(m_KnownClientFunds) + { + if (!m_KnownClientFunds.ContainsKey(client.AgentId)) + return 0; + + return m_KnownClientFunds[client.AgentId]; + } + } + + public bool UploadCovered(IClientAPI client) + { + if (GetBalance(client) < PriceUpload) + return false; + + return true; + } + #endregion } diff --git a/prebuild.xml b/prebuild.xml index c91044a86e..2f67c60e2f 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -668,6 +668,7 @@ +