summaryrefslogtreecommitdiff
path: root/indra/newview/llagentbenefits.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2019-11-20 14:03:57 +0000
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2019-11-20 14:03:57 +0000
commit4300b204f0fc519d3e2dabc7e1296284e5908611 (patch)
tree0a5823bdee6d9379058e359c2a0fc4e21287661a /indra/newview/llagentbenefits.cpp
parenteb6e64ec401382fd2fbbbb27830e828035a6e5af (diff)
SL-10499 - handle package info from benefits service
Diffstat (limited to 'indra/newview/llagentbenefits.cpp')
-rw-r--r--indra/newview/llagentbenefits.cpp69
1 files changed, 68 insertions, 1 deletions
diff --git a/indra/newview/llagentbenefits.cpp b/indra/newview/llagentbenefits.cpp
index eef644ccc0..a7f16b03d2 100644
--- a/indra/newview/llagentbenefits.cpp
+++ b/indra/newview/llagentbenefits.cpp
@@ -130,7 +130,7 @@ S32 LLAgentBenefits::getTextureUploadCost() const
return m_texture_upload_cost;
}
-bool LLAgentBenefits::findUploadCost(LLAssetType::EType& asset_type, S32& cost)
+bool LLAgentBenefits::findUploadCost(LLAssetType::EType& asset_type, S32& cost) const
{
bool succ = false;
if (asset_type == LLAssetType::AT_TEXTURE)
@@ -150,3 +150,70 @@ bool LLAgentBenefits::findUploadCost(LLAssetType::EType& asset_type, S32& cost)
}
return succ;
}
+
+LLAgentBenefitsMgr::LLAgentBenefitsMgr()
+{
+}
+
+LLAgentBenefitsMgr::~LLAgentBenefitsMgr()
+{
+}
+
+// static
+const LLAgentBenefits& LLAgentBenefitsMgr::current()
+{
+ return instance().mCurrent;
+}
+
+// static
+const LLAgentBenefits& LLAgentBenefitsMgr::get(const std::string& package)
+{
+ if (instance().mPackageMap.find(package) != instance().mPackageMap.end())
+ {
+ return instance().mPackageMap[package];
+ }
+ else
+ {
+ return instance().mDefault;
+ }
+}
+
+// static
+bool LLAgentBenefitsMgr::init(const std::string& package, const LLSD& benefits_sd)
+{
+ LLAgentBenefits benefits;
+ if (!benefits.init(benefits_sd))
+ {
+ LL_WARNS("Benefits") << "Unable to initialize package " << package << " from sd " << benefits_sd << LL_ENDL;
+ return false;
+ }
+ else
+ {
+ instance().mPackageMap[package] = benefits;
+ }
+ return true;
+
+}
+
+// static
+bool LLAgentBenefitsMgr::initCurrent(const std::string& package, const LLSD& benefits_sd)
+{
+ LLAgentBenefits benefits;
+ if (!benefits.init(benefits_sd))
+ {
+ LL_WARNS("Benefits") << "Unable to initialize package " << package << " from sd " << benefits_sd << LL_ENDL;
+ return false;
+ }
+ else
+ {
+ instance().mCurrent = benefits;
+ }
+ return true;
+
+}
+
+// static
+bool LLAgentBenefitsMgr::has(const std::string& package)
+{
+ return instance().mPackageMap.find(package) != instance().mPackageMap.end();
+}