add money helper
parent
185da85155
commit
c2a0343854
|
@ -357,7 +357,12 @@ namespace OpenSim.Modules.Currency
|
|||
HttpServer.AddXmlRPCHandler("GetBalance", GetBalanceHandler); // added
|
||||
HttpServer.AddXmlRPCHandler("AddBankerMoney", AddBankerMoneyHandler); // added
|
||||
HttpServer.AddXmlRPCHandler("SendMoney", SendMoneyHandler); // added
|
||||
HttpServer.AddXmlRPCHandler("MoveMoney", MoveMoneyHandler); // added
|
||||
HttpServer.AddXmlRPCHandler("MoveMoney", MoveMoneyHandler); // added
|
||||
|
||||
HttpServer.AddXmlRPCHandler("getCurrencyQuote", quote_func);
|
||||
HttpServer.AddXmlRPCHandler("buyCurrency", buy_func);
|
||||
HttpServer.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func);
|
||||
HttpServer.AddXmlRPCHandler("buyLandPrep", landBuy_func);
|
||||
|
||||
MainServer.Instance.AddXmlRPCHandler("OnMoneyTransfered", OnMoneyTransferedHandler);
|
||||
MainServer.Instance.AddXmlRPCHandler("UpdateBalance", BalanceUpdateHandler);
|
||||
|
@ -1895,6 +1900,132 @@ namespace OpenSim.Modules.Currency
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region moneyhelper
|
||||
private XmlRpcResponse quote_func(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
|
||||
string agentIdStr = requestData["agentId"] as string;
|
||||
UUID agentId = UUID.Parse(agentIdStr);
|
||||
UUID sessionId = UUID.Parse(requestData["secureSessionId"] as string);
|
||||
int amount = (int)requestData["currencyBuy"];
|
||||
|
||||
XmlRpcResponse returnval = new XmlRpcResponse();
|
||||
Hashtable quoteResponse = new Hashtable();
|
||||
Hashtable currencyResponse = new Hashtable();
|
||||
|
||||
currencyResponse.Add("estimatedCost", amount / 2);
|
||||
currencyResponse.Add("currencyBuy", amount);
|
||||
|
||||
quoteResponse.Add("success", true);
|
||||
quoteResponse.Add("currency", currencyResponse);
|
||||
|
||||
// TODO - generate a unique confirmation token
|
||||
quoteResponse.Add("confirm", "asdfad9fj39ma9fj");
|
||||
|
||||
returnval.Value = quoteResponse;
|
||||
return returnval;
|
||||
}
|
||||
|
||||
private XmlRpcResponse buy_func(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
UUID agentId = UUID.Parse(requestData["agentId"] as string);
|
||||
string confirm = requestData["confirm"] as string;
|
||||
int currencyBuy = (int)requestData["currencyBuy"];
|
||||
int estimatedCost = (int)requestData["estimatedCost"];
|
||||
string secureSessionId = requestData["secureSessionId"] as string;
|
||||
|
||||
// Fill parameters for money transfer XML-RPC.
|
||||
Hashtable paramTable = new Hashtable();
|
||||
paramTable["agentId"] = agentId.ToString();
|
||||
paramTable["amount"] = currencyBuy;
|
||||
|
||||
XmlRpcResponse returnval = new XmlRpcResponse();
|
||||
Hashtable returnresp = new Hashtable();
|
||||
|
||||
// Generate the request for transfer.
|
||||
Hashtable resultTable = genericCurrencyXMLRPCRequest(paramTable, "GetFreeMoney");
|
||||
|
||||
if (resultTable != null && resultTable.Contains("success"))
|
||||
{
|
||||
if ((bool)resultTable["success"] == true)
|
||||
{
|
||||
returnresp.Add("success", true);
|
||||
returnresp.Add("errorMessage", "");
|
||||
returnresp.Add("errorUrl", "http://invaliddomaininvalid.com/");
|
||||
}
|
||||
else
|
||||
{
|
||||
returnresp.Add("success", false);
|
||||
returnresp.Add("errorMessage", m_config.Configs["Economy"].GetString("Message_FreePayoutDenied", "Sorry. You cant get money from the system right now!"));
|
||||
returnresp.Add("errorUrl", m_config.Configs["Economy"].GetString("ErrorURL", "http://127.0.0.1"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnresp.Add("success", false);
|
||||
returnresp.Add("errorMessage", "FATAL ERROR. An unexpected fault is happend. Please try again or contact the region owner.");
|
||||
returnresp.Add("errorUrl", m_config.Configs["Economy"].GetString("ErrorURL", "http://127.0.0.1"));
|
||||
}
|
||||
|
||||
|
||||
returnval.Value = returnresp;
|
||||
return returnval;
|
||||
}
|
||||
|
||||
private XmlRpcResponse preflightBuyLandPrep_func(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
XmlRpcResponse ret = new XmlRpcResponse();
|
||||
Hashtable retparam = new Hashtable();
|
||||
Hashtable membershiplevels = new Hashtable();
|
||||
ArrayList levels = new ArrayList();
|
||||
Hashtable level = new Hashtable();
|
||||
level.Add("id", "00000000-0000-0000-0000-000000000000");
|
||||
level.Add("description", "some level");
|
||||
levels.Add(level);
|
||||
//membershiplevels.Add("levels",levels);
|
||||
|
||||
Hashtable landuse = new Hashtable();
|
||||
landuse.Add("upgrade", false);
|
||||
landuse.Add("action", "http://invaliddomaininvalid.com/");
|
||||
|
||||
Hashtable currency = new Hashtable();
|
||||
currency.Add("estimatedCost", 0);
|
||||
|
||||
Hashtable membership = new Hashtable();
|
||||
membershiplevels.Add("upgrade", false);
|
||||
membershiplevels.Add("action", "http://invaliddomaininvalid.com/");
|
||||
membershiplevels.Add("levels", membershiplevels);
|
||||
|
||||
retparam.Add("success", true);
|
||||
retparam.Add("currency", currency);
|
||||
retparam.Add("membership", membership);
|
||||
retparam.Add("landuse", landuse);
|
||||
retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
|
||||
|
||||
ret.Value = retparam;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private XmlRpcResponse landBuy_func(XmlRpcRequest request, IPEndPoint remoteClient)
|
||||
{
|
||||
XmlRpcResponse ret = new XmlRpcResponse();
|
||||
Hashtable retparam = new Hashtable();
|
||||
// Hashtable requestData = (Hashtable) request.Params[0];
|
||||
|
||||
// UUID agentId = UUID.Zero;
|
||||
// int amount = 0;
|
||||
|
||||
retparam.Add("success", true);
|
||||
ret.Value = retparam;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue