* Re-Fixed caps

* This fixes chi11ken's/OpenViewer's libsl cap issue.
0.6.0-stable
Teravus Ovares 2008-04-17 19:42:54 +00:00
parent 4ee368785d
commit dd4deebbcb
11 changed files with 195 additions and 283 deletions

View File

@ -251,11 +251,6 @@ namespace OpenSim.Framework.Communications.Cache
ItemReceive(userID, itemInfo); ItemReceive(userID, itemInfo);
m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
} }
else
{
m_log.Error("[UNABLE TO UPLOAD]: ");
}
} }
/// <summary> /// <summary>
@ -269,10 +264,6 @@ namespace OpenSim.Framework.Communications.Cache
{ {
m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
} }
else
{
m_log.Error("[UNABLE TO UPDATE]: ");
}
} }
/// <summary> /// <summary>
@ -292,10 +283,6 @@ namespace OpenSim.Framework.Communications.Cache
m_commsManager.InventoryService.DeleteInventoryItem(userID, item); m_commsManager.InventoryService.DeleteInventoryItem(userID, item);
} }
} }
else
{
m_log.Error("[UNABLE TO DELETE]: ");
}
return result; return result;
} }

View File

@ -100,6 +100,7 @@ namespace OpenSim.Region.Capabilities
private int m_eventQueueCount = 1; private int m_eventQueueCount = 1;
private Queue<string> m_capsEventQueue = new Queue<string>(); private Queue<string> m_capsEventQueue = new Queue<string>();
private bool m_dumpAssetsToFile; private bool m_dumpAssetsToFile;
private string m_regionName;
// These are callbacks which will be setup by the scene so that we can update scene data when we // These are callbacks which will be setup by the scene so that we can update scene data when we
// receive capability calls // receive capability calls
@ -110,7 +111,7 @@ namespace OpenSim.Region.Capabilities
public GetClientDelegate GetClient = null; public GetClientDelegate GetClient = null;
public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath,
LLUUID agent, bool dumpAssetsToFile) LLUUID agent, bool dumpAssetsToFile, string regionName)
{ {
m_assetCache = assetCache; m_assetCache = assetCache;
m_capsObjectPath = capsPath; m_capsObjectPath = capsPath;
@ -120,6 +121,7 @@ namespace OpenSim.Region.Capabilities
m_agentID = agent; m_agentID = agent;
m_dumpAssetsToFile = dumpAssetsToFile; m_dumpAssetsToFile = dumpAssetsToFile;
m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort); m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort);
m_regionName = regionName;
} }
/// <summary> /// <summary>
@ -199,6 +201,7 @@ namespace OpenSim.Region.Capabilities
/// <returns></returns> /// <returns></returns>
public string CapsRequest(string request, string path, string param) public string CapsRequest(string request, string path, string param)
{ {
m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName);
//Console.WriteLine("caps request " + request); //Console.WriteLine("caps request " + request);
string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails); string result = LLSDHelpers.SerialiseLLSDReply(m_capsHandlers.CapsDetails);
//m_log.DebugFormat("[CAPS] CapsRequest {0}", result); //m_log.DebugFormat("[CAPS] CapsRequest {0}", result);
@ -225,6 +228,7 @@ namespace OpenSim.Region.Capabilities
string unmodifiedRequest = request.ToString(); string unmodifiedRequest = request.ToString();
//m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest); //m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS fetch inventory request {0}", unmodifiedRequest);
m_log.Debug("[CAPS]: Inventory Request in region: " + m_regionName);
Hashtable hash = new Hashtable(); Hashtable hash = new Hashtable();
try try
@ -366,6 +370,7 @@ namespace OpenSim.Region.Capabilities
/// <returns></returns> /// <returns></returns>
public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
{ {
m_log.Debug("[CAPS]: MapLayer Request in region: " + m_regionName);
LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse());
return mapResponse; return mapResponse;
@ -472,6 +477,7 @@ namespace OpenSim.Region.Capabilities
{ {
try try
{ {
m_log.Debug("[CAPS]: ScriptTaskInventory Request in region: " + m_regionName);
//m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param); //m_log.DebugFormat("[CAPS]: request: {0}, path: {1}, param: {2}", request, path, param);
Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request));
@ -523,6 +529,7 @@ namespace OpenSim.Region.Capabilities
/// <returns></returns> /// <returns></returns>
public string NoteCardAgentInventory(string request, string path, string param) public string NoteCardAgentInventory(string request, string path, string param)
{ {
m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName);
//libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); //libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request));
Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request));
LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); LLSDItemUpdate llsdRequest = new LLSDItemUpdate();

View File

@ -68,6 +68,8 @@ namespace OpenSim.Region.Capabilities
/// handler to be removed</param> /// handler to be removed</param>
public void Remove(string capsName) public void Remove(string capsName)
{ {
// This line must be here, or caps will break!
m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path);
m_capsHandlers.Remove(capsName); m_capsHandlers.Remove(capsName);
} }

View File

@ -64,7 +64,6 @@ namespace OpenSim.Framework
ClientManager ClientManager { get; } ClientManager ClientManager { get; }
string GetCapsPath(LLUUID agentId); string GetCapsPath(LLUUID agentId);
string GetNewCapsPath(LLUUID agentId);
} }
} }

View File

@ -143,8 +143,8 @@ namespace OpenSim.Region.Environment.Modules
{ {
// Centralized grid structure using OpenSimWi Redux revision 9+ // Centralized grid structure using OpenSimWi Redux revision 9+
// https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux // https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux
scene.AddXmlRPCHandler("dynamic_balance_update_request", GridMoneyUpdate); scene.AddXmlRPCHandler("balanceUpdateRequest", GridMoneyUpdate);
scene.AddXmlRPCHandler("user_alert", UserAlert); scene.AddXmlRPCHandler("userAlert", UserAlert);
} }
else else
{ {
@ -171,12 +171,11 @@ namespace OpenSim.Region.Environment.Modules
scene.EventManager.OnNewClient += OnNewClient; scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnMoneyTransfer += MoneyTransferAction; scene.EventManager.OnMoneyTransfer += MoneyTransferAction;
scene.EventManager.OnClientClosed += ClientClosed; scene.EventManager.OnClientClosed += ClientClosed;
scene.EventManager.OnNewInventoryItemUploadComplete += NewInventoryItemEconomyHandler;
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
scene.EventManager.OnMakeChildAgent += MakeChildAgent; scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnClientClosed += ClientLoggedOut; scene.EventManager.OnClientClosed += ClientLoggedOut;
scene.EventManager.OnLandBuy += ValidateLandBuy; scene.EventManager.OnValidateLandBuy += ValidateLandBuy;
scene.EventManager.OnValidatedLandBuy += processLandBuy; scene.EventManager.OnLandBuy += processLandBuy;
} }
} }
@ -214,6 +213,7 @@ namespace OpenSim.Region.Environment.Modules
PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1); PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1);
string EBA = startupConfig.GetString("EconomyBaseAccount", LLUUID.Zero.ToString()); string EBA = startupConfig.GetString("EconomyBaseAccount", LLUUID.Zero.ToString());
Helpers.TryParse(EBA,out EconomyBaseAccount); Helpers.TryParse(EBA,out EconomyBaseAccount);
UserLevelPaysFees = startupConfig.GetInt("UserLevelPaysFees", -1); UserLevelPaysFees = startupConfig.GetInt("UserLevelPaysFees", -1);
m_stipend = startupConfig.GetInt("UserStipend", 500); m_stipend = startupConfig.GetInt("UserStipend", 500);
m_minFundsBeforeRefresh = startupConfig.GetInt("IssueStipendWhenClientIsBelowAmount", 10); m_minFundsBeforeRefresh = startupConfig.GetInt("IssueStipendWhenClientIsBelowAmount", 10);
@ -343,99 +343,54 @@ namespace OpenSim.Region.Environment.Modules
private void ValidateLandBuy (Object osender, LandBuyArgs e) private void ValidateLandBuy (Object osender, LandBuyArgs e)
{ {
LLUUID agentId = e.agentId; if (m_MoneyAddress.Length == 0)
int price = e.parcelPrice; {
bool final = e.final; lock (m_KnownClientFunds)
{
int funds = 0; if (m_KnownClientFunds.ContainsKey(e.agentId))
{
if (m_MoneyAddress.Length > 0) // Does the sender have enough funds to give?
{ if (m_KnownClientFunds[e.agentId] >= e.parcelPrice)
IClientAPI aClient = LocateClientObject(agentId); {
if (aClient != null) lock(e)
{ {
Scene s = LocateSceneClientIn(agentId); e.economyValidated=true;
if (s != null) }
{ }
Hashtable hbinfo = GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(), s.RegionInfo.regionSecret); }
if ((bool)hbinfo["success"] == true) }
{ }
else
Helpers.TryParse((string)hbinfo["agentId"], out agentId); {
try if(GetRemoteBalance(e.agentId) >= e.parcelPrice)
{ {
funds = (Int32)hbinfo["funds"]; lock(e)
} {
catch (ArgumentException) e.economyValidated=true;
{ }
} }
catch (FormatException) }
{
}
catch (OverflowException)
{
m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentId);
aClient.SendAlertMessage("Unable to get your money balance, money operations will be unavailable");
}
catch (InvalidCastException)
{
funds = 0;
}
SetLocalFundsForAgentID(agentId, funds);
}
else
{
m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId, (string)hbinfo["errorMessage"]);
aClient.SendAlertMessage((string)hbinfo["errorMessage"]);
}
}
}
}
else
{
funds = GetFundsForAgentID(agentId);
}
if (funds >= e.parcelPrice)
{
lock (e)
{
e.economyValidated = true;
}
XMLRPCHandler.EventManager.TriggerValidatedLandBuy(this, e);
}
} }
private void processLandBuy(Object osender, LandBuyArgs e) private void processLandBuy(Object osender, LandBuyArgs e)
{ {
LLUUID agentId = e.agentId; lock(e)
int price = e.parcelPrice; {
bool final = e.final; if(e.economyValidated == true && e.transactionID == 0)
{
int funds = 0; e.transactionID=Util.UnixTimeSinceEpoch();
// Only do this if we have not already transacted against this.
if (e.transactionID == 0)
{
funds = GetFundsForAgentID(e.agentId);
if (e.landValidated)
{
if (e.parcelPrice >= 0)
{
doMoneyTransfer(agentId, e.parcelOwnerID, e.parcelPrice);
lock (e)
{
e.transactionID = Util.UnixTimeSinceEpoch();
e.amountDebited = e.parcelPrice;
}
}
// This tells the land module that we've transacted.
XMLRPCHandler.EventManager.TriggerValidatedLandBuy(this, e);
}
}
if(doMoneyTransfer(e.agentId, e.parcelOwnerID, e.parcelPrice, 0, "Land purchase"))
{
lock (e)
{
e.amountDebited = e.parcelPrice;
}
}
}
}
} }
/// <summary> /// <summary>
/// THis method gets called when someone pays someone else as a gift. /// THis method gets called when someone pays someone else as a gift.
/// </summary> /// </summary>
@ -445,14 +400,13 @@ namespace OpenSim.Region.Environment.Modules
{ {
IClientAPI sender = null; IClientAPI sender = null;
IClientAPI receiver = null; IClientAPI receiver = null;
//m_log.WarnFormat("[MONEY] Explicit transfer of {0} from {1} to {2}", e.amount, e.sender.ToString(), e.receiver.ToString());
sender = LocateClientObject(e.sender); sender = LocateClientObject(e.sender);
if (sender != null) if (sender != null)
{ {
receiver = LocateClientObject(e.receiver); receiver = LocateClientObject(e.receiver);
bool transactionresult = doMoneyTransfer(e.sender, e.receiver, e.amount);
bool transactionresult = doMoneyTransfer(e.sender, e.receiver, e.amount, e.transactiontype, e.description);
if (e.sender != e.receiver) if (e.sender != e.receiver)
{ {
@ -466,45 +420,19 @@ namespace OpenSim.Region.Environment.Modules
{ {
receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.receiver)); receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.receiver));
} }
} }
else else
{ {
m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" + e.sender.ToString() + " Reciver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString()); m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" + e.sender.ToString() + " Receiver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString());
} }
} }
/// <summary>
/// A new inventory item came in, so we must charge if we're configured to do so!
/// </summary>
/// <param name="Uploader"></param>
/// <param name="AssetID"></param>
/// <param name="AssetName"></param>
/// <param name="userlevel"></param>
private void NewInventoryItemEconomyHandler(LLUUID Uploader, LLUUID AssetID, String AssetName, int userlevel)
{
// Presumably a normal grid would actually send this information to a server somewhere.
// We're going to apply the UploadCost here.
if (m_enabled)
{
// Only make users that are below the UserLevelPaysFees value pay.
// Use this to exclude Region Owners (2), Estate Managers(1), Users (0), Disabled(-1)
if (PriceUpload > 0 && userlevel <= UserLevelPaysFees)
{
doMoneyTransfer(Uploader, EconomyBaseAccount, PriceUpload);
}
}
}
/// <summary> /// <summary>
/// Event Handler for when a root agent becomes a child agent /// Event Handler for when a root agent becomes a child agent
/// </summary> /// </summary>
/// <param name="avatar"></param> /// <param name="avatar"></param>
private void MakeChildAgent(ScenePresence avatar) private void MakeChildAgent(ScenePresence avatar)
{ {
lock (m_rootAgents) lock (m_rootAgents)
{ {
if (m_rootAgents.ContainsKey(avatar.UUID)) if (m_rootAgents.ContainsKey(avatar.UUID))
@ -630,16 +558,14 @@ namespace OpenSim.Region.Environment.Modules
#endregion #endregion
/// <summary> /// <summary>
/// Transfer money This currently does Gifts only. /// Transfer money
/// </summary> /// </summary>
/// <param name="Sender"></param> /// <param name="Sender"></param>
/// <param name="Receiver"></param> /// <param name="Receiver"></param>
/// <param name="amount"></param> /// <param name="amount"></param>
/// <returns></returns> /// <returns></returns>
private bool doMoneyTransfer(LLUUID Sender, LLUUID Receiver, int amount) private bool doMoneyTransfer(LLUUID Sender, LLUUID Receiver, int amount, int transactiontype, string description)
{ {
//m_log.WarnFormat("[MONEY] Transfer {0} from {1} to {2}", amount, Sender.ToString(), Receiver.ToString());
bool result = false; bool result = false;
if (amount >= 0) if (amount >= 0)
{ {
@ -647,49 +573,49 @@ namespace OpenSim.Region.Environment.Modules
{ {
// If we don't know about the sender, then the sender can't // If we don't know about the sender, then the sender can't
// actually be here and therefore this is likely fraud or outdated. // actually be here and therefore this is likely fraud or outdated.
if (m_KnownClientFunds.ContainsKey(Sender)) if (m_MoneyAddress.Length == 0)
{ {
// Does the sender have enough funds to give? if (m_KnownClientFunds.ContainsKey(Sender))
if (m_KnownClientFunds[Sender] >= amount) {
{ // Does the sender have enough funds to give?
// Subtract the funds from the senders account if (m_KnownClientFunds[Sender] >= amount)
m_KnownClientFunds[Sender] -= amount; {
// Subtract the funds from the senders account
m_KnownClientFunds[Sender] -= amount;
// do we know about the receiver? // do we know about the receiver?
if (!m_KnownClientFunds.ContainsKey(Receiver)) if (!m_KnownClientFunds.ContainsKey(Receiver))
{ {
// Make a record for them so they get the updated balance when they login // Make a record for them so they get the updated balance when they login
CheckExistAndRefreshFunds(Receiver); CheckExistAndRefreshFunds(Receiver);
} }
if (m_enabled) if (m_enabled)
{ {
if (m_MoneyAddress.Length == 0) //Add the amount to the Receiver's funds
{ m_KnownClientFunds[Receiver] += amount;
//Add the amount to the Receiver's funds result = true;
m_KnownClientFunds[Receiver] += amount; }
result = true; }
} else
else {
{ // These below are redundant to make this clearer to read
result = false;
result = TransferMoneyonMoneyServer(Sender, Receiver, amount); }
} }
} else
} {
else result = false;
{ }
// These below are redundant to make this clearer to read }
result = false; else
} {
} result = TransferMoneyonMoneyServer(Sender, Receiver, amount, transactiontype, description);
else }
{ }
result = false;
}
}
} }
return result; return result;
} }
#region Utility Helpers #region Utility Helpers
/// <summary> /// <summary>
/// Locates a IClientAPI for the client specified /// Locates a IClientAPI for the client specified
@ -890,7 +816,7 @@ namespace OpenSim.Region.Environment.Modules
MoneyBalanceRequestParams["secret"] = regionSecret; MoneyBalanceRequestParams["secret"] = regionSecret;
MoneyBalanceRequestParams["currencySecret"] = ""; // per - region/user currency secret gotten from the money system MoneyBalanceRequestParams["currencySecret"] = ""; // per - region/user currency secret gotten from the money system
Hashtable MoneyRespData = genericCurrencyXMLRPCRequest(MoneyBalanceRequestParams, "simulator_user_balance_request"); Hashtable MoneyRespData = genericCurrencyXMLRPCRequest(MoneyBalanceRequestParams, "simulatorUserBalanceRequest");
return MoneyRespData; return MoneyRespData;
} }
@ -989,7 +915,7 @@ namespace OpenSim.Region.Environment.Modules
MoneyBalanceRequestParams["regionId"] = regionId.ToString(); MoneyBalanceRequestParams["regionId"] = regionId.ToString();
MoneyBalanceRequestParams["secret"] = regionSecret; MoneyBalanceRequestParams["secret"] = regionSecret;
Hashtable MoneyRespData = genericCurrencyXMLRPCRequest(MoneyBalanceRequestParams, "simulator_claim_user_request"); Hashtable MoneyRespData = genericCurrencyXMLRPCRequest(MoneyBalanceRequestParams, "simulatorClaimUserRequest");
IClientAPI sendMoneyBal = LocateClientObject(agentId); IClientAPI sendMoneyBal = LocateClientObject(agentId);
if (sendMoneyBal != null) if (sendMoneyBal != null)
{ {
@ -1005,13 +931,11 @@ namespace OpenSim.Region.Environment.Modules
/// <param name="destId"></param> /// <param name="destId"></param>
/// <param name="amount"></param> /// <param name="amount"></param>
/// <returns></returns> /// <returns></returns>
public bool TransferMoneyonMoneyServer(LLUUID sourceId, LLUUID destId, int amount) public bool TransferMoneyonMoneyServer(LLUUID sourceId, LLUUID destId, int amount, int transactiontype, string description)
{ {
string description = "Gift";
int aggregatePermInventory = 0; int aggregatePermInventory = 0;
int aggregatePermNextOwner = 0; int aggregatePermNextOwner = 0;
int flags = 0; int flags = 0;
int transactiontype = 0;
bool rvalue = false; bool rvalue = false;
IClientAPI cli = LocateClientObject(sourceId); IClientAPI cli = LocateClientObject(sourceId);
@ -1039,7 +963,7 @@ namespace OpenSim.Region.Environment.Modules
ht["transactionType"] = transactiontype; ht["transactionType"] = transactiontype;
ht["description"] = description; ht["description"] = description;
Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "region_move_money"); Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "regionMoveMoney");
if ((bool)hresult["success"] == true) if ((bool)hresult["success"] == true)
{ {
@ -1086,6 +1010,63 @@ namespace OpenSim.Region.Environment.Modules
} }
public int GetRemoteBalance(LLUUID agentId)
{
int funds = 0;
IClientAPI aClient = LocateClientObject(agentId);
if (aClient != null)
{
Scene s = LocateSceneClientIn(agentId);
if (s != null)
{
if (m_MoneyAddress.Length > 0)
{
Hashtable hbinfo = GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(), s.RegionInfo.regionSecret);
if ((bool)hbinfo["success"] == true)
{
try
{
funds = (Int32)hbinfo["funds"];
}
catch (ArgumentException)
{
}
catch (FormatException)
{
}
catch (OverflowException)
{
m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentId);
aClient.SendAlertMessage("Unable to get your money balance, money operations will be unavailable");
}
catch (InvalidCastException)
{
funds = 0;
}
}
else
{
m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId, (string)hbinfo["errorMessage"]);
aClient.SendAlertMessage((string)hbinfo["errorMessage"]);
}
}
SetLocalFundsForAgentID(agentId, funds);
SendMoneyBalance(aClient, agentId, aClient.SessionId, LLUUID.Zero);
}
else
{
m_log.Debug("[MONEY]: Got balance request update for agent that is here, but couldn't find which scene.");
}
}
else
{
m_log.Debug("[MONEY]: Got balance request update for agent that isn't here.");
}
return funds;
}
public XmlRpcResponse GridMoneyUpdate(XmlRpcRequest request) public XmlRpcResponse GridMoneyUpdate(XmlRpcRequest request)
{ {
@ -1099,58 +1080,7 @@ namespace OpenSim.Region.Environment.Modules
Helpers.TryParse((string)requestData["agentId"], out agentId); Helpers.TryParse((string)requestData["agentId"], out agentId);
if (agentId != LLUUID.Zero) if (agentId != LLUUID.Zero)
{ {
IClientAPI aClient = LocateClientObject(agentId); GetRemoteBalance(agentId);
if (aClient != null)
{
Scene s = LocateSceneClientIn(agentId);
if (s != null)
{
if (m_MoneyAddress.Length > 0)
{
Hashtable hbinfo = GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(), s.RegionInfo.regionSecret);
if ((bool)hbinfo["success"] == true)
{
int funds = 0;
Helpers.TryParse((string)hbinfo["agentId"], out agentId);
try
{
funds = (Int32)hbinfo["funds"];
}
catch (ArgumentException)
{
}
catch (FormatException)
{
}
catch (OverflowException)
{
m_log.ErrorFormat("[MONEY]: While getting the Currency for user {0}, the return funds overflowed.", agentId);
aClient.SendAlertMessage("Unable to get your money balance, money operations will be unavailable");
}
catch (InvalidCastException)
{
funds = 0;
}
SetLocalFundsForAgentID(agentId, funds);
}
else
{
m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId, (string)hbinfo["errorMessage"]);
aClient.SendAlertMessage((string)hbinfo["errorMessage"]);
}
}
SendMoneyBalance(aClient, agentId, aClient.SessionId, LLUUID.Zero);
}
else
{
m_log.Debug("[MONEY]: Got balance request update for agent that is here, but couldn't find which scene.");
}
}
else
{
m_log.Debug("[MONEY]: Got balance request update for agent that isn't here.");
}
} }
else else
@ -1169,6 +1099,7 @@ namespace OpenSim.Region.Environment.Modules
r.Value = rparms; r.Value = rparms;
return r; return r;
} }
/// <summary> /// <summary>
/// XMLRPC handler to send alert message and sound to client /// XMLRPC handler to send alert message and sound to client
/// </summary> /// </summary>

View File

@ -953,8 +953,12 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
} }
} }
// If the economy has been validated by the economy module,
// and land has been validated as well, this method transfers
// the land ownership
public void handleLandBuyRequest(Object o, LandBuyArgs e) public void handleLandBuyRequest(Object o, LandBuyArgs e)
{ {
if (e.economyValidated && e.landValidated) if (e.economyValidated && e.landValidated)
{ {
lock (landList) lock (landList)
@ -966,7 +970,15 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
} }
} }
} }
else if (e.landValidated == false) }
// After receiving a land buy packet, first the data needs to
// be validated. This method validates the right to buy the
// parcel
public void handleLandValidationRequest(Object o, LandBuyArgs e)
{
if (e.landValidated == false)
{ {
ILandObject lob = null; ILandObject lob = null;
lock (landList) lock (landList)
@ -994,7 +1006,6 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
} }
} }
m_scene.EventManager.TriggerValidatedLandBuy(this, e);
} }
} }
} }

View File

@ -55,8 +55,8 @@ namespace OpenSim.Region.Environment.Modules.LandManagement
m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts;
m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement); m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement);
m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest;
m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest; m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest;
m_scene.EventManager.OnValidatedLandBuy += landChannel.handleLandBuyRequest;
lock (m_scene) lock (m_scene)
{ {

View File

@ -136,6 +136,10 @@ namespace OpenSim.Region.Environment.Scenes
EventManager.LandBuyArgs args = new EventManager.LandBuyArgs( EventManager.LandBuyArgs args = new EventManager.LandBuyArgs(
agentId, groupId, final, groupOwned, removeContribution, parcelLocalID, parcelArea, parcelPrice, authenticated); agentId, groupId, final, groupOwned, removeContribution, parcelLocalID, parcelArea, parcelPrice, authenticated);
// First, allow all validators a stab at it
m_eventManager.TriggerValidateLandBuy(this, args);
// Then, check validation and transfer
m_eventManager.TriggerLandBuy(this, args); m_eventManager.TriggerLandBuy(this, args);
} }

View File

@ -1916,25 +1916,8 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="agentId"></param> /// <param name="agentId"></param>
/// <param name="capsObjectPath"></param> /// <param name="capsObjectPath"></param>
public void AddCapsHandler(LLUUID agentId) public void AddCapsHandler(LLUUID agentId)
{ {
// Here we clear out old Caps handlers for the agent String capsObjectPath = GetCapsPath(agentId);
// this is required because we potentially have multiple simulators in an instance nearby.
Caps oldcap = null;
lock (m_capsHandlers)
{
if (m_capsHandlers.ContainsKey(agentId))
oldcap = m_capsHandlers[agentId];
}
if (oldcap != null)
{
oldcap.DeregisterHandlers();
}
// Generate a new base caps path LLUUID.Random().ToString() instead of agentId.ToString()
// If the caps paths are not different for each region, the client and sim will do weird
// things like send the request to a region the agent is no longer in.
String capsObjectPath = GetNewCapsPath(agentId);
m_log.DebugFormat( m_log.DebugFormat(
"[CAPS]: Setting up CAPS handler for root agent {0} in {1}", "[CAPS]: Setting up CAPS handler for root agent {0} in {1}",
@ -1942,7 +1925,7 @@ namespace OpenSim.Region.Environment.Scenes
Caps cap = Caps cap =
new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port, new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port,
capsObjectPath, agentId, m_dumpAssetsToFile); capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName);
cap.RegisterHandlers(); cap.RegisterHandlers();
EventManager.TriggerOnRegisterCaps(agentId, cap); EventManager.TriggerOnRegisterCaps(agentId, cap);

View File

@ -214,17 +214,5 @@ namespace OpenSim.Region.Environment.Scenes
return null; return null;
} }
public string GetNewCapsPath(LLUUID agentID)
{
if (capsPaths.ContainsKey(agentID))
{
capsPaths[agentID] = LLUUID.Random().ToString();
}
else
{
capsPaths.Add(agentID, LLUUID.Random().ToString());
}
return GetCapsPath(agentID);
}
} }
} }

View File

@ -167,9 +167,9 @@ namespace OpenSim.Region.Environment.Scenes
public int transactiontype; public int transactiontype;
public string description; public string description;
public MoneyTransferArgs(LLUUID asender, LLUUID areciever, int aamount, int atransactiontype, string adescription) { public MoneyTransferArgs(LLUUID asender, LLUUID areceiver, int aamount, int atransactiontype, string adescription) {
sender = asender; sender = asender;
receiver = areciever; receiver = areceiver;
amount = aamount; amount = aamount;
transactiontype = atransactiontype; transactiontype = atransactiontype;
description = adescription; description = adescription;
@ -219,7 +219,7 @@ namespace OpenSim.Region.Environment.Scenes
public event MoneyTransferEvent OnMoneyTransfer; public event MoneyTransferEvent OnMoneyTransfer;
public event LandBuy OnLandBuy; public event LandBuy OnLandBuy;
public event LandBuy OnValidatedLandBuy; public event LandBuy OnValidateLandBuy;
/* Designated Event Deletage Instances */ /* Designated Event Deletage Instances */
@ -253,7 +253,7 @@ namespace OpenSim.Region.Environment.Scenes
private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps; private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps;
private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null; private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null;
private LandBuy handlerLandBuy = null; private LandBuy handlerLandBuy = null;
private LandBuy handlerValidatedLandBuy = null; private LandBuy handlerValidateLandBuy = null;
public void TriggerOnScriptChangedEvent(uint localID, uint change) public void TriggerOnScriptChangedEvent(uint localID, uint change)
{ {
@ -526,12 +526,12 @@ namespace OpenSim.Region.Environment.Scenes
handlerLandBuy(sender, e); handlerLandBuy(sender, e);
} }
} }
public void TriggerValidatedLandBuy(Object sender, LandBuyArgs e) public void TriggerValidateLandBuy(Object sender, LandBuyArgs e)
{ {
handlerValidatedLandBuy = OnValidatedLandBuy; handlerValidateLandBuy = OnValidateLandBuy;
if (handlerValidatedLandBuy != null) if (handlerValidateLandBuy != null)
{ {
handlerValidatedLandBuy(sender, e); handlerValidateLandBuy(sender, e);
} }
} }
} }