diff -Nur aurora-/Aurora/AuroraDotNetEngine/EventManager.cs aurora/Aurora/AuroraDotNetEngine/EventManager.cs --- aurora-/Aurora/AuroraDotNetEngine/EventManager.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/Aurora/AuroraDotNetEngine/EventManager.cs 2011-08-27 16:36:32.000000000 +0900 @@ -118,53 +118,22 @@ if (money != null) { money.OnObjectPaid += HandleObjectPaid; - money.OnPostObjectPaid += HandlePostObjectPaid; } } - //private void HandleObjectPaid(UUID objectID, UUID agentID, int amount) - private bool HandleObjectPaid(UUID objectID, UUID agentID, int amount) + private void HandleObjectPaid(UUID objectID, UUID agentID, int amount) { - bool ret = false; ISceneChildEntity part = m_scriptEngine.findPrim(objectID); - //if (part == null) - // return; + if (part == null) return; - //m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount); - //if (part.ParentGroup != null) - // part = part.ParentGroup.RootPart; + m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount); + if (part.ParentEntity != null) part = part.ParentEntity.RootChild; - //if (part != null) - //{ - // money(part.LocalId, agentID, amount); - //} - if (part != null) + if (part != null) { - m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount); - if (part.ParentEntity != null) part = part.ParentEntity.RootChild; - if (part != null) - { - ret = money(part.LocalId, agentID, amount); - } + money(part.LocalId, agentID, amount); } - return ret; - } - - private bool HandlePostObjectPaid(uint localID, ulong regionHandle, UUID agentID, int amount) - { - bool ret = true; - - foreach (IScene scene in m_scriptEngine.Worlds) - { - if (scene.RegionInfo.RegionHandle == regionHandle) - { - ret = money(localID, agentID, amount); - break; - } - } - - return ret; } public void changed (ISceneChildEntity part, uint change) @@ -311,19 +280,18 @@ CoalescedTouchEvents[part.LocalId] = det; } - //public void money(uint localID, UUID agentID, int amount) - public bool money(uint localID, UUID agentID, int amount) + public void money(uint localID, UUID agentID, int amount) { - bool ret = false; ISceneChildEntity part = m_scriptEngine.findPrim(localID); - if (part == null) return ret; + if (part == null) return; ScriptData[] datas = ScriptEngine.ScriptProtection.GetScripts(part.UUID); if (datas == null || datas.Length == 0) { - datas = ScriptEngine.ScriptProtection.GetScripts(part.ParentEntity.UUID); - if (datas == null || datas.Length == 0) return ret; + //datas = ScriptEngine.ScriptProtection.GetScripts(part.ParentEntity.UUID); + //if (datas == null || datas.Length == 0) + return; } string functionName = "money"; object[] param = new object[] { @@ -334,10 +302,8 @@ { if (CheckIfEventShouldFire(ID, functionName, param)) { m_scriptEngine.AddToScriptQueue(ID, functionName, new DetectParams[0], EventPriority.FirstStart, param); - ret = true; } } - return ret; } public void collision_start (ISceneChildEntity part, ColliderArgs col) diff -Nur aurora-/Aurora/AuroraDotNetEngine4/EventManager.cs aurora/Aurora/AuroraDotNetEngine4/EventManager.cs --- aurora-/Aurora/AuroraDotNetEngine4/EventManager.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/Aurora/AuroraDotNetEngine4/EventManager.cs 2011-08-27 16:36:32.000000000 +0900 @@ -122,53 +122,22 @@ if (money != null) { money.OnObjectPaid += HandleObjectPaid; - money.OnPostObjectPaid += HandlePostObjectPaid; } } - //private void HandleObjectPaid(UUID objectID, UUID agentID, int amount) - private bool HandleObjectPaid(UUID objectID, UUID agentID, int amount) + private void HandleObjectPaid(UUID objectID, UUID agentID, int amount) { - bool ret = false; ISceneChildEntity part = m_scriptEngine.findPrim(objectID); - //if (part == null) - // return; + if (part == null) return; - //m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount); - //if (part.ParentGroup != null) - // part = part.ParentGroup.RootPart; + m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount); + if (part.ParentEntity != null) part = part.ParentEntity.RootChild; - //if (part != null) - //{ - // money(part.LocalId, agentID, amount); - //} - if (part != null) + if (part != null) { - m_log.Debug("Paid: " + objectID + " from " + agentID + ", amount " + amount); - if (part.ParentEntity != null) part = part.ParentEntity.RootChild; - if (part != null) - { - ret = money(part.LocalId, agentID, amount); - } + money(part.LocalId, agentID, amount); } - return ret; - } - - private bool HandlePostObjectPaid(uint localID, ulong regionHandle, UUID agentID, int amount) - { - bool ret = true; - - foreach (Scene scene in m_Scenes) - { - if (scene.RegionInfo.RegionHandle == regionHandle) - { - ret = money(localID, agentID, amount); - break; - } - } - - return ret; } public void changed (ISceneChildEntity part, uint change) @@ -315,19 +284,18 @@ CoalescedTouchEvents[part.LocalId] = det; } - //public void money(uint localID, UUID agentID, int amount) - public bool money(uint localID, UUID agentID, int amount) + public void money(uint localID, UUID agentID, int amount) { - bool ret = false; ISceneChildEntity part = m_scriptEngine.findPrim(localID); - if (part == null) return ret; + if (part == null) return; ScriptData[] datas = ScriptEngine.ScriptProtection.GetScripts(part.UUID); if (datas == null || datas.Length == 0) { - datas = ScriptEngine.ScriptProtection.GetScripts(part.ParentEntity.UUID); - if (datas == null || datas.Length == 0) return ret; + //datas = ScriptEngine.ScriptProtection.GetScripts(part.ParentEntity.UUID); + //if (datas == null || datas.Length == 0) + return; } string functionName = "money"; object[] param = new object[] { @@ -338,10 +306,8 @@ { if (CheckIfEventShouldFire(ID, functionName, param)) { m_scriptEngine.AddToScriptQueue(ID, functionName, new DetectParams[0], ID.VersionID, param); - ret = true; } } - return ret; } public void collision_start (ISceneChildEntity part, ColliderArgs col) diff -Nur aurora-/Aurora/Modules/Avatar/AuroraProfile/AvatarProfileModule.cs aurora/Aurora/Modules/Avatar/AuroraProfile/AvatarProfileModule.cs --- aurora-/Aurora/Modules/Avatar/AuroraProfile/AvatarProfileModule.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/Aurora/Modules/Avatar/AuroraProfile/AvatarProfileModule.cs 2011-08-27 16:36:32.000000000 +0900 @@ -242,7 +242,8 @@ IMoneyModule money = p.Scene.RequestModuleInterface(); if (money != null) { - if (!money.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified")) + //if (!money.Charge(remoteClient.AgentId, queryclassifiedPrice, "Add Classified")) + if (!money.AmountCovered(remoteClient, queryclassifiedPrice)) { remoteClient.SendAlertMessage("You do not have enough money to complete this upload."); return; diff -Nur aurora-/Aurora/Modules/World/SampleCurrencyModule/SampleCurrencyModule.cs aurora/Aurora/Modules/World/SampleCurrencyModule/SampleCurrencyModule.cs --- aurora-/Aurora/Modules/World/SampleCurrencyModule/SampleCurrencyModule.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/Aurora/Modules/World/SampleCurrencyModule/SampleCurrencyModule.cs 2011-08-27 16:36:32.000000000 +0900 @@ -59,6 +59,35 @@ #region IMoneyModule Members + + public bool UploadCovered(IClientAPI client, int amount) + { + return true; + } + + public bool AmountCovered(IClientAPI clientx , int amount) + { + return true; + } + + public bool GroupCreationCovered(IClientAPI client, int amount) + { + return true; + } + + public void ApplyUploadCharge(UUID agnetID, int amount, string text) + { + } + + public void ApplyCharge(UUID agnetID, int amount, string text) + { + } + + public void ApplyGroupCreationCharge(UUID agnetID, int amount, string text) + { + } + + public int UploadCharge { get { return 0; } @@ -71,7 +100,6 @@ #pragma warning disable 67 public event ObjectPaid OnObjectPaid; - public event PostObjectPaid OnPostObjectPaid; public bool Transfer(UUID toID, UUID fromID, int amount, string description) { return true; @@ -84,7 +112,7 @@ public bool Transfer(UUID toID, UUID fromID, UUID toObjectID, UUID fromObjectID, int amount, string description, TransactionType type) { - if ((type == TransactionType.ObjectPay) && (OnObjectPaid != null)) + if ((type == TransactionType.PayObject) && (OnObjectPaid != null)) OnObjectPaid((fromObjectID == UUID.Zero) ? toObjectID : fromObjectID, fromID, amount); return true; } @@ -161,6 +189,11 @@ #endregion + public int GetBalance(UUID agentID) + { + return 0; + } + public int Balance(IClientAPI client) { return 0; diff -Nur aurora-/OpenSim/Framework/IMoneyModule.cs aurora/OpenSim/Framework/IMoneyModule.cs --- aurora-/OpenSim/Framework/IMoneyModule.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/OpenSim/Framework/IMoneyModule.cs 2011-08-27 16:36:32.000000000 +0900 @@ -29,39 +29,48 @@ namespace OpenSim.Framework { - //public delegate void ObjectPaid(UUID objectID, UUID agentID, int amount); - // For legacy money module. Fumi.Iseki - public delegate bool ObjectPaid(UUID objectID, UUID agentID, int amount); - // For DTL money module. - public delegate bool PostObjectPaid(uint localID, ulong regionHandle, UUID agentID, int amount); + public delegate void ObjectPaid(UUID objectID, UUID agentID, int amount); - public enum TransactionType + public enum TransactionType : int { - SystemGenerated = 0, - RegionMoneyRequest = 1, - Gift = 2, - Purchase = 3, - Upload = 4, - ObjectPay = 5008 + GroupCreate = 1002, + GroupJoin = 1004, + UploadCharge = 1101, + LandAuction = 1102, + ObjectSale = 5000, + Gift = 5001, + LandSale = 5002, + ReferBonus = 5003, + InvntorySale = 5004, + DwellBonus = 5007, + PayObject = 5008, + ObjectPays = 5009, + BuyMoney = 5010, + MoveMoney = 5011 } public interface IMoneyModule { - bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, - int amount); + bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount); - int Balance(IClientAPI client); - bool Charge(IClientAPI client, int amount); - bool Charge(UUID agentID, int amount, string text); + int GetBalance(UUID agentID); + bool UploadCovered(IClientAPI client, int amount); + bool AmountCovered(IClientAPI client, int amount); + + void ApplyCharge(UUID agentID, int amount, string text); + void ApplyUploadCharge(UUID agentID, int amount, string text); int UploadCharge { get; } int GroupCreationCharge { get; } event ObjectPaid OnObjectPaid; - event PostObjectPaid OnPostObjectPaid; - bool Transfer(UUID toID, UUID fromID, int amount, string description); - bool Transfer(UUID toID, UUID fromID, int amount, string description, TransactionType type); - bool Transfer(UUID toID, UUID fromID, UUID toObjectID, UUID fromObjectID, int amount, string description, TransactionType type); + bool GroupCreationCovered(IClientAPI client, int amount); + void ApplyGroupCreationCharge(UUID agentID, int amount, string text); + + + //bool Transfer(UUID toID, UUID fromID, int amount, string description); + //bool Transfer(UUID toID, UUID fromID, int amount, string description, TransactionType type); + //bool Transfer(UUID toID, UUID fromID, UUID toObjectID, UUID fromObjectID, int amount, string description, TransactionType type); } } diff -Nur aurora-/OpenSim/Framework/ISceneEntity.cs aurora/OpenSim/Framework/ISceneEntity.cs --- aurora-/OpenSim/Framework/ISceneEntity.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/OpenSim/Framework/ISceneEntity.cs 2011-08-27 16:36:32.000000000 +0900 @@ -2997,5 +2997,54 @@ } } } + + + // + public class MoneyTransferArgs : EventArgs + { + public UUID sender; + public UUID receiver; + // Always false. The SL protocol sucks. + public bool authenticated = false; + public int amount; + public int transactiontype; + public string description; + + public MoneyTransferArgs(UUID asender, UUID areceiver, int aamount, int atransactiontype, string adescription) + { + sender = asender; + receiver = areceiver; + amount = aamount; + transactiontype = atransactiontype; + description = adescription; + } + } + + + public delegate void MoneyTransferEvent(Object sender, MoneyTransferArgs e); + public event MoneyTransferEvent OnMoneyTransfer; + + + public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs args) + { + MoneyTransferEvent handlerMoneyTransfer = OnMoneyTransfer; + if (handlerMoneyTransfer != null) + { + foreach (MoneyTransferEvent d in handlerMoneyTransfer.GetInvocationList()) + { + try + { + d(sender, args); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerMoneyTransfer failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + } } diff -Nur aurora-/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs aurora/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs --- aurora-/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs 2011-08-27 16:36:32.000000000 +0900 @@ -32,6 +32,7 @@ using System.IO; using System.Net; using System.Net.Sockets; +using System.Security.Cryptography.X509Certificates; using System.Reflection; using System.Globalization; using System.Text; @@ -41,6 +42,7 @@ using log4net; using Nwc.XmlRpc; using OpenMetaverse.StructuredData; +using CoolHTTPListener = HttpServer.HttpListener; using HttpListener = HttpServer.HttpListener; using LogPrio = HttpServer.LogPrio; @@ -54,7 +56,8 @@ private volatile int NotSocketErrors = 0; public volatile bool HTTPDRunning = false; - protected HttpListener m_httpListener; + // protected HttpListener m_httpListener; + protected HttpListener m_httpListener2; protected Dictionary m_rpcHandlers = new Dictionary(); protected Dictionary m_rpcHandlersKeepAlive = new Dictionary(); protected DefaultLLSDMethod m_defaultLlsdHandler = null; // <-- Moving away from the monolithic.. and going to /registered/ @@ -68,6 +71,7 @@ protected uint m_port; protected uint m_sslport; protected bool m_ssl; + private X509Certificate2 m_cert; protected bool m_firstcaps = true; protected string m_SSLCommonName = ""; protected string m_hostName; @@ -129,6 +133,14 @@ m_hostName = hostName; } + public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) : this (port, ssl) + { + if (m_ssl) + { + m_cert = new X509Certificate2(CPath, CPass); + } + } + /// /// Add a stream handler to the http server. If the handler already exists, then nothing happens. /// @@ -1560,14 +1572,15 @@ try { //m_httpListener = new HttpListener(); + NotSocketErrors = 0; if (!m_ssl) { //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); //m_httpListener.Prefixes.Add("http://10.1.1.5:" + m_port + "/"); - m_httpListener = HttpListener.Create (m_listenIPAddress, (int)m_port/*, httpserverlog*/); - m_httpListener.ExceptionThrown += httpServerException; - m_httpListener.LogWriter = httpserverlog; + m_httpListener2 = CoolHTTPListener.Create (m_listenIPAddress, (int)m_port/*, httpserverlog*/); + m_httpListener2.ExceptionThrown += httpServerException; + m_httpListener2.LogWriter = httpserverlog; // Uncomment this line in addition to those in HttpServerLogWriter // if you want more detailed trace information from the HttpServer @@ -1579,15 +1592,13 @@ { //m_httpListener.Prefixes.Add("https://+:" + (m_sslport) + "/"); //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); - System.Security.Cryptography.X509Certificates.X509Certificate2 cert = - new System.Security.Cryptography.X509Certificates.X509Certificate2("SineWaveCert.pfx", "123"); - m_httpListener = HttpListener.Create (IPAddress.Any, (int)m_port, cert/*, httpserverlog*/); - m_httpListener.ExceptionThrown += httpServerException; - m_httpListener.LogWriter = httpserverlog; + m_httpListener2 = CoolHTTPListener.Create(IPAddress.Any, (int)m_port, m_cert); + m_httpListener2.ExceptionThrown += httpServerException; + m_httpListener2.LogWriter = httpserverlog; } - m_httpListener.RequestReceived += OnRequest; - m_httpListener.Start(64); + m_httpListener2.RequestReceived += OnRequest; + m_httpListener2.Start(64); // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events m_PollServiceManager = new PollServiceRequestManager(this, 3, 25000); @@ -1634,12 +1645,12 @@ HTTPDRunning = false; try { - m_httpListener.ExceptionThrown -= httpServerException; + m_httpListener2.ExceptionThrown -= httpServerException; //m_httpListener2.DisconnectHandler = null; - m_httpListener.LogWriter = null; - m_httpListener.RequestReceived -= OnRequest; - m_httpListener.Stop(); + m_httpListener2.LogWriter = null; + m_httpListener2.RequestReceived -= OnRequest; + m_httpListener2.Stop(); } catch (NullReferenceException) { diff -Nur aurora-/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs aurora/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs --- aurora-/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs 2011-08-27 16:36:32.000000000 +0900 @@ -306,7 +306,7 @@ if (mm != null) { - if (!mm.Charge(remoteClient, mm.UploadCharge)) + if (!mm.UploadCovered(remoteClient, mm.UploadCharge)) { remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); return; diff -Nur aurora-/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs aurora/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs --- aurora-/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs 2011-08-27 16:36:32.000000000 +0900 @@ -956,7 +956,8 @@ try { // do the transaction, that is if the agent has got sufficient funds - if (!money.Charge (GetRequestingAgentID (remoteClient), money.GroupCreationCharge, "Group Creation")) + //if (!money.Charge (GetRequestingAgentID (remoteClient), money.GroupCreationCharge, "Group Creation")) + if (!money.GroupCreationCovered(remoteClient, money.GroupCreationCharge)) { remoteClient.SendCreateGroupReply (UUID.Zero, false, "You have got issuficient funds to create a group."); return UUID.Zero; diff -Nur aurora-/OpenSim/Region/CoreModules/World/Land/ParcelManagementModule.cs aurora/OpenSim/Region/CoreModules/World/Land/ParcelManagementModule.cs --- aurora-/OpenSim/Region/CoreModules/World/Land/ParcelManagementModule.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/OpenSim/Region/CoreModules/World/Land/ParcelManagementModule.cs 2011-08-27 16:36:32.000000000 +0900 @@ -1202,7 +1202,8 @@ IMoneyModule module = m_scene.RequestModuleInterface(); if (module != null) - if (!module.Transfer(landObject.LandData.OwnerID, client.AgentId, landObject.LandData.PassPrice, "Parcel Pass")) + //if (!module.Transfer(landObject.LandData.OwnerID, client.AgentId, landObject.LandData.PassPrice, "Parcel Pass")) + if (!module.AmountCovered(client, landObject.LandData.PassPrice)) { client.SendAlertMessage("You do not have enough funds to complete this transaction."); return; diff -Nur aurora-/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs aurora/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs --- aurora-/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs 2011-08-27 16:37:28.000000000 +0900 +++ aurora/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs 2011-08-27 16:36:32.000000000 +0900 @@ -157,7 +157,8 @@ IMoneyModule moneyMod = remoteClient.Scene.RequestModuleInterface(); if (moneyMod != null) { - if (!moneyMod.Transfer(part.OwnerID, remoteClient.AgentId, part.ParentUUID, UUID.Zero, part.SalePrice, "Object Purchase", TransactionType.ObjectPay)) + //if (!moneyMod.Transfer(part.OwnerID, remoteClient.AgentId, part.ParentUUID, UUID.Zero, part.SalePrice, "Object Purchase", TransactionType.ObjectPay)) + if (!moneyMod.AmountCovered(remoteClient, part.SalePrice)) { remoteClient.SendAgentAlertMessage("You do not have enough money to buy this object.", false); return;