aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/Communications/Capabilities/Caps.cs26
-rw-r--r--OpenSim/Region/Environment/Interfaces/IMoneyModule.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs19
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs37
-rw-r--r--prebuild.xml1
5 files changed, 80 insertions, 6 deletions
diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs
index 24fe0f4..338604d 100644
--- a/OpenSim/Framework/Communications/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs
@@ -34,6 +34,9 @@ using libsecondlife;
34using log4net; 34using log4net;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37using OpenSim.Framework;
38using OpenSim.Region.Environment.Interfaces;
39using OpenSim.Region.Environment.Scenes;
37 40
38namespace OpenSim.Framework.Communications.Capabilities 41namespace OpenSim.Framework.Communications.Capabilities
39{ 42{
@@ -606,6 +609,29 @@ namespace OpenSim.Framework.Communications.Capabilities
606 /// <returns></returns> 609 /// <returns></returns>
607 public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) 610 public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
608 { 611 {
612 if (llsdRequest.asset_type == "texture" ||
613 llsdRequest.asset_type == "animation" ||
614 llsdRequest.asset_type == "sound")
615 {
616 IClientAPI client = GetClient(m_agentID);
617 Scene scene = (Scene)client.Scene;
618
619 IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
620
621 if(mm != null)
622 {
623 if(!mm.UploadCovered(client))
624 {
625 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
626
627 LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
628 errorResponse.uploader = "";
629 errorResponse.state = "error";
630 return errorResponse;
631 }
632 }
633 }
634
609 //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); 635 //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type);
610 636
611 string assetName = llsdRequest.name; 637 string assetName = llsdRequest.name;
diff --git a/OpenSim/Region/Environment/Interfaces/IMoneyModule.cs b/OpenSim/Region/Environment/Interfaces/IMoneyModule.cs
index eae6702..49d096b 100644
--- a/OpenSim/Region/Environment/Interfaces/IMoneyModule.cs
+++ b/OpenSim/Region/Environment/Interfaces/IMoneyModule.cs
@@ -36,7 +36,10 @@ namespace OpenSim.Region.Environment.Interfaces
36 { 36 {
37 bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID, 37 bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID,
38 int amount); 38 int amount);
39
40 int GetBalance(IClientAPI client);
39 void ApplyUploadCharge(LLUUID agentID); 41 void ApplyUploadCharge(LLUUID agentID);
42 bool UploadCovered(IClientAPI client);
40 43
41 event ObjectPaid OnObjectPaid; 44 event ObjectPaid OnObjectPaid;
42 } 45 }
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
index fd407d9..d8720db 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
261 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, 261 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
262 byte[] data, bool storeLocal, bool tempFile) 262 byte[] data, bool storeLocal, bool tempFile)
263 { 263 {
264 if ((AssetType)type == AssetType.Texture ||
265 (AssetType)type == AssetType.Sound ||
266 (AssetType)type == AssetType.TextureTGA ||
267 (AssetType)type == AssetType.Animation)
268 {
269 Scene scene = (Scene)remoteClient.Scene;
270 IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
271 if (mm != null)
272 {
273 if (!mm.UploadCovered(remoteClient))
274 {
275 remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
276 return;
277 }
278 }
279 }
280
264 // Console.WriteLine("asset upload of " + assetID); 281 // Console.WriteLine("asset upload of " + assetID);
265 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 282 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
266 283
@@ -288,4 +305,4 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
288 transactions.HandleXfer(xferID, packetID, data); 305 transactions.HandleXfer(xferID, packetID, data);
289 } 306 }
290 } 307 }
291} \ No newline at end of file 308}
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
index f038975..e31770f 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
266 scene.SetObjectCapacity(ObjectCapacity); 266 scene.SetObjectCapacity(ObjectCapacity);
267 } 267 }
268 268
269 /// <summary> 269 private void GetClientFunds(IClientAPI client)
270 /// New Client Event Handler
271 /// </summary>
272 /// <param name="client"></param>
273 private void OnNewClient(IClientAPI client)
274 { 270 {
275 // Here we check if we're in grid mode 271 // Here we check if we're in grid mode
276 // I imagine that the 'check balance' 272 // I imagine that the 'check balance'
@@ -343,6 +339,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
343 CheckExistAndRefreshFunds(client.AgentId); 339 CheckExistAndRefreshFunds(client.AgentId);
344 } 340 }
345 341
342 }
343
344 /// <summary>
345 /// New Client Event Handler
346 /// </summary>
347 /// <param name="client"></param>
348 private void OnNewClient(IClientAPI client)
349 {
350 GetClientFunds(client);
351
346 // Subscribe to Money messages 352 // Subscribe to Money messages
347 client.OnEconomyDataRequest += EconomyDataRequestHandler; 353 client.OnEconomyDataRequest += EconomyDataRequestHandler;
348 client.OnMoneyBalanceRequest += SendMoneyBalance; 354 client.OnMoneyBalanceRequest += SendMoneyBalance;
@@ -1525,6 +1531,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1525 DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient); 1531 DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient);
1526 } 1532 }
1527 1533
1534 public int GetBalance(IClientAPI client)
1535 {
1536 GetClientFunds(client);
1537
1538 lock(m_KnownClientFunds)
1539 {
1540 if (!m_KnownClientFunds.ContainsKey(client.AgentId))
1541 return 0;
1542
1543 return m_KnownClientFunds[client.AgentId];
1544 }
1545 }
1546
1547 public bool UploadCovered(IClientAPI client)
1548 {
1549 if (GetBalance(client) < PriceUpload)
1550 return false;
1551
1552 return true;
1553 }
1554
1528 #endregion 1555 #endregion
1529 } 1556 }
1530 1557
diff --git a/prebuild.xml b/prebuild.xml
index c91044a..2f67c60 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -668,6 +668,7 @@
668 <Reference name="System.Xml"/> 668 <Reference name="System.Xml"/>
669 <Reference name="System.Web"/> 669 <Reference name="System.Web"/>
670 <Reference name="OpenSim.Framework"/> 670 <Reference name="OpenSim.Framework"/>
671 <Reference name="OpenSim.Region.Environment"/>
671 <Reference name="OpenSim.Framework.AssetLoader.Filesystem"/> 672 <Reference name="OpenSim.Framework.AssetLoader.Filesystem"/>
672 <Reference name="OpenSim.Data" /> 673 <Reference name="OpenSim.Data" />
673 <Reference name="OpenSim.Framework.Servers"/> 674 <Reference name="OpenSim.Framework.Servers"/>