diff options
Diffstat (limited to 'indra/newview/llfloaterbuycurrency.cpp')
| -rw-r--r-- | indra/newview/llfloaterbuycurrency.cpp | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/indra/newview/llfloaterbuycurrency.cpp b/indra/newview/llfloaterbuycurrency.cpp index e41f893c43..7533145625 100644 --- a/indra/newview/llfloaterbuycurrency.cpp +++ b/indra/newview/llfloaterbuycurrency.cpp @@ -40,6 +40,8 @@ #include "llviewchildren.h" #include "llviewerwindow.h" #include "lluictrlfactory.h" +#include "llviewercontrol.h" +#include "llviewernetwork.h" #include "llweb.h" #include "llwindow.h" #include "llappviewer.h" @@ -316,29 +318,59 @@ void LLFloaterBuyCurrency::handleBuyCurrency(bool has_piof, bool has_target, con if (has_piof) { LLFloaterBuyCurrencyUI* ui = LLFloaterReg::showTypedInstance<LLFloaterBuyCurrencyUI>("buy_currency"); - if (has_target) + if (ui) { - ui->target(name, price); + if (has_target) + { + ui->target(name, price); + } + else + { + ui->noTarget(); + } + ui->updateUI(); + ui->collapsePanels(!has_target); } else { - ui->noTarget(); + LL_WARNS() << "Cannot instantiate buy_currency floater" << LL_ENDL; } - ui->updateUI(); - ui->collapsePanels(!has_target); } else { - LLFloaterReg::showInstance("add_payment_method"); + openPaymentMethodPage(); } } +// static +void LLFloaterBuyCurrency::openPaymentMethodPage() +{ + const std::string& grid_id = LLGridManager::getInstance()->getGridId(); + const std::string& grid_id_lower = utf8str_tolower(grid_id); + const std::string url = gSavedSettings.getString(grid_id_lower == "damballah" ? "PaymentMethodStagingURL" : "PaymentMethodURL"); + LLWeb::loadURL(url); +} + LLFetchAvatarPaymentInfo::LLFetchAvatarPaymentInfo(bool has_target, const std::string& name, S32 price) : mAvatarID(gAgent.getID()), mHasTarget(has_target), mPrice(price), mName(name) { + sendRequest(); +} + +LLFetchAvatarPaymentInfo::LLFetchAvatarPaymentInfo(const callback_t& cb) +: mAvatarID(gAgent.getID()), + mHasTarget(false), + mPrice(0), + mCallback(cb) +{ + sendRequest(); +} + +void LLFetchAvatarPaymentInfo::sendRequest() +{ LLAvatarPropertiesProcessor* processor = LLAvatarPropertiesProcessor::getInstance(); // register ourselves as an observer processor->addObserver(mAvatarID, this); @@ -357,6 +389,16 @@ void LLFetchAvatarPaymentInfo::processProperties(void* data, EAvatarProcessorTyp if (data && type == APT_PROPERTIES) { LLAvatarData* avatar_data = static_cast<LLAvatarData*>(data); - LLFloaterBuyCurrency::handleBuyCurrency(LLAvatarPropertiesProcessor::hasPaymentInfoOnFile(avatar_data), mHasTarget, mName, mPrice); + bool has_piof = LLAvatarPropertiesProcessor::hasPaymentInfoOnFile(avatar_data); + if (mCallback) + { + // call a local copy, since the callback may delete this observer + callback_t cb = mCallback; + cb(has_piof); + } + else + { + LLFloaterBuyCurrency::handleBuyCurrency(has_piof, mHasTarget, mName, mPrice); + } } } |
