/Aurora/Framework/Modules/IMoneyModule.cs

https://bitbucket.org/VirtualReality/software-testing · C# · 144 lines · 88 code · 20 blank · 36 comment · 0 complexity · 55baba7dedb5c904eb044f0ba6c7b453 MD5 · raw file

  1. /*
  2. * Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the Aurora-Sim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using Aurora.Framework.PresenceInfo;
  30. using OpenMetaverse;
  31. namespace Aurora.Framework.Modules
  32. {
  33. //public delegate void ObjectPaid(UUID objectID, UUID agentID, int amount);
  34. // For legacy money module. Fumi.Iseki
  35. public delegate bool ObjectPaid(UUID objectID, UUID agentID, int amount);
  36. // For DTL money module.
  37. public delegate bool PostObjectPaid(uint localID, ulong regionHandle, UUID agentID, int amount);
  38. public enum TransactionType
  39. {
  40. SystemGenerated = 0,
  41. GroupCreate = 1002,
  42. UploadFee = 1101,
  43. AuctionFee = 1102,
  44. ClassifiedFee = 1103,
  45. DirectoryFee = 2003,
  46. ClassifiedRenewFee = 2005,
  47. Inventory = 3000,
  48. ObjectBuy = 5000,
  49. Gift = 5001,
  50. LandSale = 5002,
  51. LandPassFee = 5006,
  52. PayIntoObject = 5008,
  53. ObjectPaysAvatar = 5009,
  54. GroupLiability = 6003,
  55. GroupDividend = 6004,
  56. StipendPayment = 10000
  57. }
  58. public class GroupBalance : IDataTransferable
  59. {
  60. public int TotalTierDebit = 0;
  61. public int TotalTierCredits = 0;
  62. public int ParcelDirectoryFee = 0;
  63. public int LandFee = 0;
  64. public int ObjectFee = 0;
  65. public int GroupFee = 0;
  66. public DateTime StartingDate;
  67. public override void FromOSD(OpenMetaverse.StructuredData.OSDMap map)
  68. {
  69. TotalTierDebit = map["TotalTierDebit"];
  70. TotalTierCredits = map["TotalTierCredits"];
  71. ParcelDirectoryFee = map["ParcelDirectoryFee"];
  72. LandFee = map["LandFee"];
  73. ObjectFee = map["ObjectFee"];
  74. GroupFee = map["GroupFee"];
  75. StartingDate = map["StartingDate"];
  76. }
  77. public override OpenMetaverse.StructuredData.OSDMap ToOSD()
  78. {
  79. OpenMetaverse.StructuredData.OSDMap map = new OpenMetaverse.StructuredData.OSDMap();
  80. map["TotalTierDebit"] = TotalTierDebit;
  81. map["TotalTierCredits"] = TotalTierCredits;
  82. map["ParcelDirectoryFee"] = ParcelDirectoryFee;
  83. map["LandFee"] = LandFee;
  84. map["ObjectFee"] = ObjectFee;
  85. map["GroupFee"] = GroupFee;
  86. map["StartingDate"] = StartingDate;
  87. return map;
  88. }
  89. }
  90. public interface IMoneyModule
  91. {
  92. int UploadCharge { get; }
  93. int GroupCreationCharge { get; }
  94. int ClientPort { get; }
  95. bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID,
  96. int amount);
  97. int Balance(UUID agentID);
  98. bool Charge(IClientAPI client, int amount);
  99. bool Charge(UUID agentID, int amount, string text);
  100. event ObjectPaid OnObjectPaid;
  101. event PostObjectPaid OnPostObjectPaid;
  102. bool Transfer(UUID toID, UUID fromID, int amount, string description);
  103. bool Transfer(UUID toID, UUID fromID, int amount, string description, TransactionType type);
  104. bool Transfer(UUID toID, UUID fromID, UUID toObjectID, UUID fromObjectID, int amount, string description,
  105. TransactionType type);
  106. /// <summary>
  107. /// Get a list of transactions that have occured over the given interval (0 is this period of interval days, positive #s go back previous sets)
  108. /// </summary>
  109. /// <param name="groupID"></param>
  110. /// <param name="agentID">Requesting agentID (must be checked whether they can call this)</param>
  111. /// <param name="currentInterval"></param>
  112. /// <param name="intervalDays"></param>
  113. List<GroupAccountHistory> GetTransactions(UUID groupID, UUID agentID, int currentInterval, int intervalDays);
  114. GroupBalance GetGroupBalance(UUID groupID);
  115. }
  116. public delegate void UserDidNotPay(UUID agentID, string paymentTextThatFailed);
  117. public delegate bool CheckWhetherUserShouldPay(UUID agentID, string paymentTextThatFailed);
  118. public interface IScheduledMoneyModule
  119. {
  120. event UserDidNotPay OnUserDidNotPay;
  121. event CheckWhetherUserShouldPay OnCheckWhetherUserShouldPay;
  122. bool Charge(UUID agentID, int amount, string text, int daysUntilNextCharge);
  123. }
  124. }