From 96e343b49b0b5a0951ffab0beb2e1d09c37bbdc5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 1 Sep 2015 16:13:52 -0700 Subject: MAINT-5575: Convert the Experience cache into a coro based singleton. --HG-- branch : MAINT-5575 --- indra/newview/llfloaterexperienceprofile.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfloaterexperienceprofile.cpp') diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp index 197162487d..8a04f9e4cc 100644 --- a/indra/newview/llfloaterexperienceprofile.cpp +++ b/indra/newview/llfloaterexperienceprofile.cpp @@ -99,7 +99,7 @@ public: if(params.size() != 2 || params[1].asString() != "profile") return false; - LLExperienceCache::get(params[0].asUUID(), boost::bind(&LLExperienceHandler::experienceCallback, this, _1)); + LLExperienceCache::getInstance()->get(params[0].asUUID(), boost::bind(&LLExperienceHandler::experienceCallback, this, _1)); return true; } @@ -288,8 +288,8 @@ BOOL LLFloaterExperienceProfile::postBuild() if (mExperienceId.notNull()) { - LLExperienceCache::fetch(mExperienceId, true); - LLExperienceCache::get(mExperienceId, boost::bind(&LLFloaterExperienceProfile::experienceCallback, + LLExperienceCache::getInstance()->fetch(mExperienceId, true); + LLExperienceCache::getInstance()->get(mExperienceId, boost::bind(&LLFloaterExperienceProfile::experienceCallback, getDerivedHandle(), _1)); LLViewerRegion* region = gAgent.getRegion(); @@ -799,8 +799,8 @@ void LLFloaterExperienceProfile::onSaveComplete( const LLSD& content ) } refreshExperience(*it); - LLExperienceCache::insert(*it); - LLExperienceCache::fetch(id, true); + LLExperienceCache::getInstance()->insert(*it); + LLExperienceCache::getInstance()->fetch(id, true); if(mSaveCompleteAction==VIEW) { -- cgit v1.2.3 From 8913ed6692fddc5d72ee01ecb92a21093c5d22ad Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 3 Sep 2015 16:59:00 -0700 Subject: Changes from code review with Nat --- indra/newview/llfloaterexperienceprofile.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfloaterexperienceprofile.cpp') diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp index 8a04f9e4cc..e850be99ab 100644 --- a/indra/newview/llfloaterexperienceprofile.cpp +++ b/indra/newview/llfloaterexperienceprofile.cpp @@ -99,7 +99,7 @@ public: if(params.size() != 2 || params[1].asString() != "profile") return false; - LLExperienceCache::getInstance()->get(params[0].asUUID(), boost::bind(&LLExperienceHandler::experienceCallback, this, _1)); + LLExperienceCache::instance().get(params[0].asUUID(), boost::bind(&LLExperienceHandler::experienceCallback, this, _1)); return true; } @@ -288,8 +288,8 @@ BOOL LLFloaterExperienceProfile::postBuild() if (mExperienceId.notNull()) { - LLExperienceCache::getInstance()->fetch(mExperienceId, true); - LLExperienceCache::getInstance()->get(mExperienceId, boost::bind(&LLFloaterExperienceProfile::experienceCallback, + LLExperienceCache::instance().fetch(mExperienceId, true); + LLExperienceCache::instance().get(mExperienceId, boost::bind(&LLFloaterExperienceProfile::experienceCallback, getDerivedHandle(), _1)); LLViewerRegion* region = gAgent.getRegion(); @@ -799,8 +799,8 @@ void LLFloaterExperienceProfile::onSaveComplete( const LLSD& content ) } refreshExperience(*it); - LLExperienceCache::getInstance()->insert(*it); - LLExperienceCache::getInstance()->fetch(id, true); + LLExperienceCache::instance().insert(*it); + LLExperienceCache::instance().fetch(id, true); if(mSaveCompleteAction==VIEW) { -- cgit v1.2.3 From a471ae72e4b48a12cfeeba544afde9d078428f0d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 4 Sep 2015 13:13:16 -0700 Subject: Experience Profile to coroutines and Experience cache. --- indra/newview/llfloaterexperienceprofile.cpp | 259 +++++++++------------------ 1 file changed, 84 insertions(+), 175 deletions(-) (limited to 'indra/newview/llfloaterexperienceprofile.cpp') diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp index e850be99ab..fdf15d2513 100644 --- a/indra/newview/llfloaterexperienceprofile.cpp +++ b/indra/newview/llfloaterexperienceprofile.cpp @@ -144,145 +144,6 @@ public: } }; -class ExperienceUpdateResponder : public HandleResponder -{ -public: - ExperienceUpdateResponder(const LLHandle& parent):HandleResponder(parent) - { - } - - virtual void httpSuccess() - { - LLFloaterExperienceProfile* parent=mParent.get(); - if(parent) - { - parent->onSaveComplete(getContent()); - } - } -}; - - - -class ExperiencePreferencesResponder : public LLHTTPClient::Responder -{ -public: - ExperiencePreferencesResponder(const LLUUID& single = LLUUID::null):mId(single) - { - } - - bool sendSingle(const LLSD& content, const LLSD& permission, const char* name) - { - if(!content.has(name)) - return false; - - LLEventPump& pump = LLEventPumps::instance().obtain("experience_permission"); - const LLSD& list = content[name]; - LLSD::array_const_iterator it = list.beginArray(); - while(it != list.endArray()) - { - if(it->asUUID() == mId) - { - LLSD message; - message[it->asString()] = permission; - message["experience"] = mId; - pump.post(message); - return true; - } - ++it; - } - return false; - } - - bool hasPermission(const LLSD& content, const char* name) - { - if(!content.has(name)) - return false; - - const LLSD& list = content[name]; - LLSD::array_const_iterator it = list.beginArray(); - while(it != list.endArray()) - { - if(it->asUUID() == mId) - { - return true; - } - ++it; - } - return false; - } - - const char* getPermission(const LLSD& content) - { - if(hasPermission(content, "experiences")) - { - return "Allow"; - } - else if(hasPermission(content, "blocked")) - { - return "Block"; - } - return "Forget"; - } - - - virtual void httpSuccess() - { - if(mId.notNull()) - { - post(getPermission(getContent())); - return; - } - LLEventPumps::instance().obtain("experience_permission").post(getContent()); - } - - void post( const char* perm ) - { - LLSD experience; - LLSD message; - experience["permission"]=perm; - message["experience"] = mId; - message[mId.asString()] = experience; - LLEventPumps::instance().obtain("experience_permission").post(message); - } - -private: - LLUUID mId; -}; - - -class IsAdminResponder : public HandleResponder -{ -public: - IsAdminResponder(const LLHandle& parent):HandleResponder(parent) - { - } - - virtual void httpSuccess() - { - LLFloaterExperienceProfile* parent = mParent.get(); - if(!parent) - return; - - bool enabled = true; - LLViewerRegion* region = gAgent.getRegion(); - if (!region) - { - enabled = false; - } - else - { - std::string url=region->getCapability("UpdateExperience"); - if(url.empty()) - enabled = false; - } - if(enabled && getContent()["status"].asBoolean()) - { - parent->getChild(PNL_TOP)->setVisible(TRUE); - parent->getChild(BTN_EDIT)->setVisible(TRUE); - } - } -}; - BOOL LLFloaterExperienceProfile::postBuild() { @@ -295,11 +156,8 @@ BOOL LLFloaterExperienceProfile::postBuild() LLViewerRegion* region = gAgent.getRegion(); if (region) { - std::string lookup_url=region->getCapability("IsExperienceAdmin"); - if(!lookup_url.empty()) - { - LLHTTPClient::get(lookup_url+"?experience_id="+mExperienceId.asString(), new IsAdminResponder(getDerivedHandle())); - } + LLExperienceCache::instance().getExperienceAdmin(mExperienceId, boost::bind( + &LLFloaterExperienceProfile::experienceIsAdmin, getDerivedHandle(), _1)); } } @@ -372,23 +230,13 @@ void LLFloaterExperienceProfile::onClickSave() doSave(NOTHING); } - void LLFloaterExperienceProfile::onClickPermission(const char* perm) { LLViewerRegion* region = gAgent.getRegion(); if (!region) return; - - std::string lookup_url=region->getCapability("ExperiencePreferences"); - if(lookup_url.empty()) - return; - LLSD permission; - LLSD data; - permission["permission"]=perm; - - data[mExperienceId.asString()]=permission; - LLHTTPClient::put(lookup_url, data, new ExperiencePreferencesResponder(mExperienceId)); - + LLExperienceCache::instance().setExperiencePermission(mExperienceId, perm, boost::bind( + &LLFloaterExperienceProfile::experiencePermissionResults, mExperienceId, _1)); } @@ -398,11 +246,8 @@ void LLFloaterExperienceProfile::onClickForget() if (!region) return; - std::string lookup_url=region->getCapability("ExperiencePreferences"); - if(lookup_url.empty()) - return; - - LLHTTPClient::del(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder(mExperienceId)); + LLExperienceCache::instance().forgetExperiencePermission(mExperienceId, boost::bind( + &LLFloaterExperienceProfile::experiencePermissionResults, mExperienceId, _1)); } bool LLFloaterExperienceProfile::setMaturityString( U8 maturity, LLTextBox* child, LLComboBox* combo ) @@ -549,11 +394,8 @@ void LLFloaterExperienceProfile::refreshExperience( const LLSD& experience ) LLViewerRegion* region = gAgent.getRegion(); if (region) { - std::string lookup_url=region->getCapability("ExperiencePreferences"); - if(!lookup_url.empty()) - { - LLHTTPClient::get(lookup_url+"?"+mExperienceId.asString(), new ExperiencePreferencesResponder(mExperienceId)); - } + LLExperienceCache::instance().getExperiencePermission(mExperienceId, boost::bind( + &LLFloaterExperienceProfile::experiencePermissionResults, mExperienceId, _1)); } } @@ -733,15 +575,9 @@ void LLFloaterExperienceProfile::doSave( int success_action ) if (!region) return; - std::string url=region->getCapability("UpdateExperience"); - if(url.empty()) - return; - - mPackage.erase(LLExperienceCache::QUOTA); - mPackage.erase(LLExperienceCache::EXPIRES); - mPackage.erase(LLExperienceCache::AGENT_ID); - - LLHTTPClient::post(url, mPackage, new ExperienceUpdateResponder(getDerivedHandle())); + LLExperienceCache::instance().updateExperience(mPackage, boost::bind( + &LLFloaterExperienceProfile::experienceUpdateResult, + getDerivedHandle(), _1)); } void LLFloaterExperienceProfile::onSaveComplete( const LLSD& content ) @@ -1002,3 +838,76 @@ void LLFloaterExperienceProfile::onReportExperience() { LLFloaterReporter::showFromExperience(mExperienceId); } + +/*static*/ +bool LLFloaterExperienceProfile::hasPermission(const LLSD& content, const std::string &name, const LLUUID &test) +{ + if (!content.has(name)) + return false; + + const LLSD& list = content[name]; + LLSD::array_const_iterator it = list.beginArray(); + while (it != list.endArray()) + { + if (it->asUUID() == test) + { + return true; + } + ++it; + } + return false; +} + +/*static*/ +void LLFloaterExperienceProfile::experiencePermissionResults(LLUUID exprienceId, LLSD result) +{ + std::string permission("Forget"); + if (hasPermission(result, "experiences", exprienceId)) + permission = "Allow"; + else if (hasPermission(result, "blocked", exprienceId)) + permission = "Block"; + + LLSD experience; + LLSD message; + experience["permission"] = permission; + message["experience"] = exprienceId; + message[exprienceId.asString()] = experience; + + LLEventPumps::instance().obtain("experience_permission").post(message); +} + +/*static*/ +void LLFloaterExperienceProfile::experienceIsAdmin(LLHandle handle, const LLSD &result) +{ + LLFloaterExperienceProfile* parent = handle.get(); + if (!parent) + return; + + bool enabled = true; + LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + enabled = false; + } + else + { + std::string url = region->getCapability("UpdateExperience"); + if (url.empty()) + enabled = false; + } + if (enabled && result["status"].asBoolean()) + { + parent->getChild(PNL_TOP)->setVisible(TRUE); + parent->getChild(BTN_EDIT)->setVisible(TRUE); + } +} + +/*static*/ +void LLFloaterExperienceProfile::experienceUpdateResult(LLHandle handle, const LLSD &result) +{ + LLFloaterExperienceProfile* parent = handle.get(); + if (parent) + { + parent->onSaveComplete(result); + } +} -- cgit v1.2.3 From 6a204b1bddc711b768d598c6ac0a16413f48d3c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 10 Sep 2015 16:48:01 -0700 Subject: MAINT-5575: Finished converting experience cache to singleton MAINT-4952: Coverted VMM to coroutines --- indra/newview/llfloaterexperienceprofile.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'indra/newview/llfloaterexperienceprofile.cpp') diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp index fdf15d2513..dd1c6dce0a 100644 --- a/indra/newview/llfloaterexperienceprofile.cpp +++ b/indra/newview/llfloaterexperienceprofile.cpp @@ -131,19 +131,6 @@ LLFloaterExperienceProfile::~LLFloaterExperienceProfile() } -template -class HandleResponder : public LLHTTPClient::Responder -{ -public: - HandleResponder(const LLHandle& parent):mParent(parent){} - LLHandle mParent; - - virtual void httpFailure() - { - LL_WARNS() << "HandleResponder failed with code: " << getStatus() << ", reason: " << getReason() << LL_ENDL; - } -}; - BOOL LLFloaterExperienceProfile::postBuild() { -- cgit v1.2.3 From 97236a42ca08979897d5c7b0826312345754cd67 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 14 Sep 2015 11:15:23 -0700 Subject: MAINT-5507: Remove HTTPClient and related cruft. --- indra/newview/llfloaterexperienceprofile.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llfloaterexperienceprofile.cpp') diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp index dd1c6dce0a..d44eb4310d 100644 --- a/indra/newview/llfloaterexperienceprofile.cpp +++ b/indra/newview/llfloaterexperienceprofile.cpp @@ -36,7 +36,6 @@ #include "llexpandabletextbox.h" #include "llexperiencecache.h" #include "llfloaterreg.h" -#include "llhttpclient.h" #include "lllayoutstack.h" #include "lllineeditor.h" #include "llnotificationsutil.h" -- cgit v1.2.3