Skip to content
Snippets Groups Projects
Commit 7cabb9de authored by Lynx Linden's avatar Lynx Linden
Browse files

EXT-332: Added support for local currency estimates to the Buy L$

and Buy Land floaters.

We now check for a new estimatedLocalCost key from the XML-RPC server,
which provides the estimated cost in the user's local currency, e.g.,
"US$ 10.00" or "10.00 Euros". Note: the server is not currently
sending this information.

The previous codepath still exists and should be unaffected. That is,
we will continue to check for an estimatedCost key from the server with
a value specified in US cents. We give precedence to estimatedLocalCost
though and may want to remove this code once the international billing
server changes go live.

<lynx@lindenlab.com> HG: branch 'default' HG: changed
indra/newview/llcurrencyuimanager.cpp HG: changed
indra/newview/llcurrencyuimanager.h HG: changed
indra/newview/llfloaterbuyland.cpp HG: changed
indra/newview/skins/default/xui/en/floater_buy_land.xml
parent 12f038b5
No related branches found
No related tags found
No related merge requests found
...@@ -76,8 +76,15 @@ class LLCurrencyUIManager::Impl ...@@ -76,8 +76,15 @@ class LLCurrencyUIManager::Impl
bool mUserEnteredCurrencyBuy; bool mUserEnteredCurrencyBuy;
// from website // from website
bool mSiteCurrencyEstimated;
S32 mSiteCurrencyEstimatedCost; // pre-viewer 2.0, the server returned estimates as an
// integer US cents value, e.g., "1000" for $10.00
// post-viewer 2.0, the server may also return estimates
// as a string with currency embedded, e.g., "10.00 Euros"
bool mUSDCurrencyEstimated;
S32 mUSDCurrencyEstimatedCost;
bool mLocalCurrencyEstimated;
std::string mLocalCurrencyEstimatedCost;
std::string mSiteConfirm; std::string mSiteConfirm;
bool mBought; bool mBought;
...@@ -101,6 +108,10 @@ class LLCurrencyUIManager::Impl ...@@ -101,6 +108,10 @@ class LLCurrencyUIManager::Impl
void startCurrencyBuy(const std::string& password); void startCurrencyBuy(const std::string& password);
void finishCurrencyBuy(); void finishCurrencyBuy();
void clearEstimate();
bool hasEstimate() const;
std::string getLocalEstimate() const;
void startTransaction(TransactionType type, void startTransaction(TransactionType type,
const char* method, LLXMLRPCValue params); const char* method, LLXMLRPCValue params);
...@@ -126,12 +137,11 @@ LLCurrencyUIManager::Impl::Impl(LLPanel& dialog) ...@@ -126,12 +137,11 @@ LLCurrencyUIManager::Impl::Impl(LLPanel& dialog)
mError(false), mError(false),
mUserCurrencyBuy(2000), // note, this is a default, real value set in llfloaterbuycurrency.cpp mUserCurrencyBuy(2000), // note, this is a default, real value set in llfloaterbuycurrency.cpp
mUserEnteredCurrencyBuy(false), mUserEnteredCurrencyBuy(false),
mSiteCurrencyEstimated(false),
mSiteCurrencyEstimatedCost(0),
mBought(false), mBought(false),
mTransactionType(TransactionNone), mTransaction(0), mTransactionType(TransactionNone), mTransaction(0),
mCurrencyChanged(false) mCurrencyChanged(false)
{ {
clearEstimate();
} }
LLCurrencyUIManager::Impl::~Impl() LLCurrencyUIManager::Impl::~Impl()
...@@ -141,14 +151,13 @@ LLCurrencyUIManager::Impl::~Impl() ...@@ -141,14 +151,13 @@ LLCurrencyUIManager::Impl::~Impl()
void LLCurrencyUIManager::Impl::updateCurrencyInfo() void LLCurrencyUIManager::Impl::updateCurrencyInfo()
{ {
mSiteCurrencyEstimated = false; clearEstimate();
mSiteCurrencyEstimatedCost = 0;
mBought = false; mBought = false;
mCurrencyChanged = false; mCurrencyChanged = false;
if (mUserCurrencyBuy == 0) if (mUserCurrencyBuy == 0)
{ {
mSiteCurrencyEstimated = true; mLocalCurrencyEstimated = true;
return; return;
} }
...@@ -185,9 +194,21 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo() ...@@ -185,9 +194,21 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo()
} }
LLXMLRPCValue currency = result["currency"]; LLXMLRPCValue currency = result["currency"];
mSiteCurrencyEstimated = true;
mSiteCurrencyEstimatedCost = currency["estimatedCost"].asInt(); // old XML-RPC server: estimatedCost = value in US cents
mUSDCurrencyEstimated = currency["estimatedCost"].isValid();
if (mUSDCurrencyEstimated)
{
mUSDCurrencyEstimatedCost = currency["estimatedCost"].asInt();
}
// newer XML-RPC server: estimatedLocalCost = local currency string
mLocalCurrencyEstimated = currency["estimatedLocalCost"].isValid();
if (mLocalCurrencyEstimated)
{
mLocalCurrencyEstimatedCost = currency["estimatedLocalCost"].asString();
}
S32 newCurrencyBuy = currency["currencyBuy"].asInt(); S32 newCurrencyBuy = currency["currencyBuy"].asInt();
if (newCurrencyBuy != mUserCurrencyBuy) if (newCurrencyBuy != mUserCurrencyBuy)
{ {
...@@ -200,17 +221,20 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo() ...@@ -200,17 +221,20 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo()
void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password) void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password)
{ {
mSiteCurrencyEstimated = false;
mSiteCurrencyEstimatedCost = 0;
mCurrencyChanged = false;
LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct();
keywordArgs.appendString("agentId", gAgent.getID().asString()); keywordArgs.appendString("agentId", gAgent.getID().asString());
keywordArgs.appendString( keywordArgs.appendString(
"secureSessionId", "secureSessionId",
gAgent.getSecureSessionID().asString()); gAgent.getSecureSessionID().asString());
keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy); keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy);
keywordArgs.appendInt("estimatedCost", mSiteCurrencyEstimatedCost); if (mUSDCurrencyEstimated)
{
keywordArgs.appendInt("estimatedCost", mUSDCurrencyEstimatedCost);
}
if (mLocalCurrencyEstimated)
{
keywordArgs.appendString("estimatedLocalCost", mLocalCurrencyEstimatedCost);
}
keywordArgs.appendString("confirm", mSiteConfirm); keywordArgs.appendString("confirm", mSiteConfirm);
if (!password.empty()) if (!password.empty())
{ {
...@@ -226,6 +250,9 @@ void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password) ...@@ -226,6 +250,9 @@ void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password)
params.append(keywordArgs); params.append(keywordArgs);
startTransaction(TransactionBuy, "buyCurrency", params); startTransaction(TransactionBuy, "buyCurrency", params);
clearEstimate();
mCurrencyChanged = false;
} }
void LLCurrencyUIManager::Impl::finishCurrencyBuy() void LLCurrencyUIManager::Impl::finishCurrencyBuy()
...@@ -270,6 +297,34 @@ void LLCurrencyUIManager::Impl::startTransaction(TransactionType type, ...@@ -270,6 +297,34 @@ void LLCurrencyUIManager::Impl::startTransaction(TransactionType type,
clearError(); clearError();
} }
void LLCurrencyUIManager::Impl::clearEstimate()
{
mUSDCurrencyEstimated = false;
mUSDCurrencyEstimatedCost = 0;
mLocalCurrencyEstimated = false;
mLocalCurrencyEstimatedCost = "0";
}
bool LLCurrencyUIManager::Impl::hasEstimate() const
{
return (mUSDCurrencyEstimated || mLocalCurrencyEstimated);
}
std::string LLCurrencyUIManager::Impl::getLocalEstimate() const
{
if (mLocalCurrencyEstimated)
{
// we have the new-style local currency string
return mLocalCurrencyEstimatedCost;
}
if (mUSDCurrencyEstimated)
{
// we have the old-style USD-specific value
return "US$ " + llformat("%#.2f", mUSDCurrencyEstimatedCost / 100.0);
}
return "";
}
bool LLCurrencyUIManager::Impl::checkTransaction() bool LLCurrencyUIManager::Impl::checkTransaction()
{ {
if (!mTransaction) if (!mTransaction)
...@@ -342,8 +397,8 @@ void LLCurrencyUIManager::Impl::currencyKey(S32 value) ...@@ -342,8 +397,8 @@ void LLCurrencyUIManager::Impl::currencyKey(S32 value)
mUserCurrencyBuy = value; mUserCurrencyBuy = value;
if (mSiteCurrencyEstimated) { if (hasEstimate()) {
mSiteCurrencyEstimated = false; clearEstimate();
//cannot just simply refresh the whole UI, as the edit field will //cannot just simply refresh the whole UI, as the edit field will
// get reset and the cursor will change... // get reset and the cursor will change...
...@@ -406,8 +461,8 @@ void LLCurrencyUIManager::Impl::updateUI() ...@@ -406,8 +461,8 @@ void LLCurrencyUIManager::Impl::updateUI()
} }
} }
mPanel.childSetTextArg("currency_est", "[LOCALAMOUNT]", "US$ " + llformat("%#.2f", mSiteCurrencyEstimatedCost / 100.0)); mPanel.childSetTextArg("currency_est", "[LOCALAMOUNT]", getLocalEstimate());
mPanel.childSetVisible("currency_est", mSiteCurrencyEstimated && mUserCurrencyBuy > 0); mPanel.childSetVisible("currency_est", hasEstimate() && mUserCurrencyBuy > 0);
if (mPanel.childIsEnabled("buy_btn") if (mPanel.childIsEnabled("buy_btn")
||mPanel.childIsVisible("currency_est") ||mPanel.childIsVisible("currency_est")
...@@ -448,18 +503,32 @@ void LLCurrencyUIManager::setZeroMessage(const std::string& message) ...@@ -448,18 +503,32 @@ void LLCurrencyUIManager::setZeroMessage(const std::string& message)
impl.mZeroMessage = message; impl.mZeroMessage = message;
} }
void LLCurrencyUIManager::setEstimate(int amount) void LLCurrencyUIManager::setUSDEstimate(int amount)
{
impl.mUSDCurrencyEstimatedCost = amount;
impl.mUSDCurrencyEstimated = true;
impl.updateUI();
impl.mCurrencyChanged = false;
}
int LLCurrencyUIManager::getUSDEstimate()
{
return impl.mUSDCurrencyEstimated ? impl.mUSDCurrencyEstimatedCost : 0;
}
void LLCurrencyUIManager::setLocalEstimate(const std::string &amount)
{ {
impl.mSiteCurrencyEstimatedCost = amount; impl.mLocalCurrencyEstimatedCost = amount;
impl.mSiteCurrencyEstimated = true; impl.mLocalCurrencyEstimated = true;
impl.updateUI(); impl.updateUI();
impl.mCurrencyChanged = false; impl.mCurrencyChanged = false;
} }
int LLCurrencyUIManager::getEstimate() std::string LLCurrencyUIManager::getLocalEstimate() const
{ {
return impl.mSiteCurrencyEstimated ? impl.mSiteCurrencyEstimatedCost : 0; return impl.getLocalEstimate();
} }
void LLCurrencyUIManager::prepare() void LLCurrencyUIManager::prepare()
...@@ -490,7 +559,7 @@ void LLCurrencyUIManager::buy(const std::string& buy_msg) ...@@ -490,7 +559,7 @@ void LLCurrencyUIManager::buy(const std::string& buy_msg)
LLUIString msg = buy_msg; LLUIString msg = buy_msg;
msg.setArg("[LINDENS]", llformat("%d", impl.mUserCurrencyBuy)); msg.setArg("[LINDENS]", llformat("%d", impl.mUserCurrencyBuy));
msg.setArg("[LOCALAMOUNT]", "US$ " + llformat("%#.2f", impl.mSiteCurrencyEstimatedCost / 100.0)); msg.setArg("[LOCALAMOUNT]", getLocalEstimate());
LLConfirmationManager::confirm(impl.mSiteConfirm, LLConfirmationManager::confirm(impl.mSiteConfirm,
msg, msg,
impl, impl,
...@@ -511,7 +580,7 @@ bool LLCurrencyUIManager::canCancel() ...@@ -511,7 +580,7 @@ bool LLCurrencyUIManager::canCancel()
bool LLCurrencyUIManager::canBuy() bool LLCurrencyUIManager::canBuy()
{ {
return impl.mTransactionType == Impl::TransactionNone return impl.mTransactionType == Impl::TransactionNone
&& impl.mSiteCurrencyEstimated && impl.hasEstimate()
&& impl.mUserCurrencyBuy > 0; && impl.mUserCurrencyBuy > 0;
} }
......
...@@ -57,11 +57,16 @@ class LLCurrencyUIManager ...@@ -57,11 +57,16 @@ class LLCurrencyUIManager
void setZeroMessage(const std::string& message); void setZeroMessage(const std::string& message);
// sets the gray message to show when zero // sets the gray message to show when zero
void setEstimate(int); void setUSDEstimate(int); // deprecated in 2.0
int getEstimate(); int getUSDEstimate(); // deprecated in 2.0
// the amount in US$ * 100 (in otherwords, in cents) // the amount in US$ * 100 (in otherwords, in cents)
// use set when you get this information from elsewhere // use set when you get this information from elsewhere
void setLocalEstimate(const std::string &local_est);
std::string getLocalEstimate() const;
// the estimated cost in the user's local currency
// for example, "US$ 10.00" or "10.00 Euros"
void prepare(); void prepare();
// call once after dialog is built, from postBuild() // call once after dialog is built, from postBuild()
void updateUI(bool show = true); void updateUI(bool show = true);
......
...@@ -685,7 +685,14 @@ void LLFloaterBuyLandUI::finishWebSiteInfo() ...@@ -685,7 +685,14 @@ void LLFloaterBuyLandUI::finishWebSiteInfo()
mSiteLandUseAction = landUse["action"].asString(); mSiteLandUseAction = landUse["action"].asString();
LLXMLRPCValue currency = result["currency"]; LLXMLRPCValue currency = result["currency"];
mCurrency.setEstimate(currency["estimatedCost"].asInt()); if (currency["estimatedCost"].isValid())
{
mCurrency.setUSDEstimate(currency["estimatedCost"].asInt());
}
if (currency["estimatedLocalCost"].isValid())
{
mCurrency.setLocalEstimate(currency["estimatedLocalCost"].asString());
}
mSiteConfirm = result["confirm"].asString(); mSiteConfirm = result["confirm"].asString();
} }
...@@ -733,7 +740,8 @@ void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password) ...@@ -733,7 +740,8 @@ void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password)
keywordArgs.appendInt("billableArea", keywordArgs.appendInt("billableArea",
mIsForGroup ? 0 : mParcelBillableArea); mIsForGroup ? 0 : mParcelBillableArea);
keywordArgs.appendInt("currencyBuy", mCurrency.getAmount()); keywordArgs.appendInt("currencyBuy", mCurrency.getAmount());
keywordArgs.appendInt("estimatedCost", mCurrency.getEstimate()); keywordArgs.appendInt("estimatedCost", mCurrency.getUSDEstimate());
keywordArgs.appendString("estimatedLocalCost", mCurrency.getLocalEstimate());
keywordArgs.appendString("confirm", mSiteConfirm); keywordArgs.appendString("confirm", mSiteConfirm);
if (!password.empty()) if (!password.empty())
{ {
...@@ -1217,7 +1225,7 @@ void LLFloaterBuyLandUI::refreshUI() ...@@ -1217,7 +1225,7 @@ void LLFloaterBuyLandUI::refreshUI()
childSetText("currency_reason", getString("not_enough_lindens", string_args)); childSetText("currency_reason", getString("not_enough_lindens", string_args));
childSetTextArg("currency_est", "[AMOUNT2]", llformat("%#.2f", mCurrency.getEstimate() / 100.0)); childSetTextArg("currency_est", "[LOCAL_AMOUNT]", mCurrency.getLocalEstimate());
} }
if (willHaveEnough) if (willHaveEnough)
...@@ -1297,7 +1305,7 @@ void LLFloaterBuyLandUI::startBuyPreConfirm() ...@@ -1297,7 +1305,7 @@ void LLFloaterBuyLandUI::startBuyPreConfirm()
{ {
LLStringUtil::format_map_t string_args; LLStringUtil::format_map_t string_args;
string_args["[AMOUNT]"] = llformat("%d", mCurrency.getAmount()); string_args["[AMOUNT]"] = llformat("%d", mCurrency.getAmount());
string_args["[AMOUNT2]"] = llformat("%#.2f", mCurrency.getEstimate() / 100.0); string_args["[LOCAL_AMOUNT]"] = mCurrency.getLocalEstimate();
action += getString("buy_for_US", string_args); action += getString("buy_for_US", string_args);
} }
......
...@@ -115,7 +115,7 @@ Try selecting a smaller area. ...@@ -115,7 +115,7 @@ Try selecting a smaller area.
</floater.string> </floater.string>
<floater.string <floater.string
name="buy_for_US"> name="buy_for_US">
Buy L$ [AMOUNT] for approx. US$ [AMOUNT2], Buy L$ [AMOUNT] for approx. [LOCAL_AMOUNT],
</floater.string> </floater.string>
<floater.string <floater.string
name="parcel_meters"> name="parcel_meters">
...@@ -172,10 +172,6 @@ supports [AMOUNT2] objects ...@@ -172,10 +172,6 @@ supports [AMOUNT2] objects
name="no_parcel_selected"> name="no_parcel_selected">
(no parcel selected) (no parcel selected)
</floater.string> </floater.string>
<floater.string
name="buy_currency">
Buy L$ [LINDENS] for approx. US$ [USD]
</floater.string>
<text <text
type="string" type="string"
length="1" length="1"
...@@ -667,7 +663,7 @@ This parcel is 512 m² of land. ...@@ -667,7 +663,7 @@ This parcel is 512 m² of land.
name="currency_est" name="currency_est"
top="409" top="409"
width="178"> width="178">
for approx. US$ [AMOUNT2] for approx. [LOCAL_AMOUNT]
</text> </text>
<text <text
type="string" type="string"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment