From c08072a0508cefc6bfc8c05937e984a095f323ce Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 3 Sep 2015 11:10:32 -0700 Subject: Moved group experiences into experience cache. Use coros and new HTTP libs. --- indra/llmessage/llexperiencecache.cpp | 41 ++++++++++++++++++++++ indra/llmessage/llexperiencecache.h | 2 ++ indra/newview/llcompilequeue.cpp | 2 +- indra/newview/llpanelgroupexperiences.cpp | 56 +++++++++++-------------------- indra/newview/llpanelgroupexperiences.h | 3 ++ 5 files changed, 66 insertions(+), 38 deletions(-) (limited to 'indra') diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp index 29ca0b2820..233b15dcdd 100644 --- a/indra/llmessage/llexperiencecache.cpp +++ b/indra/llmessage/llexperiencecache.cpp @@ -635,6 +635,47 @@ void LLExperienceCache::findExperienceByNameCoro(LLCoreHttpUtil::HttpCoroutineAd fn(result); } +//------------------------------------------------------------------------- +void LLExperienceCache::getGroupExperiences(const LLUUID &groupId, ExperienceGetFn_t fn) +{ + if (mCapability.empty()) + { + LL_WARNS("ExperienceCache") << "Capability query method not set." << LL_ENDL; + return; + } + + LLCoprocedureManager::getInstance()->enqueueCoprocedure("ExpCache", "Group Experiences", + boost::bind(&LLExperienceCache::getGroupExperiencesCoro, this, _1, groupId, fn)); +} + +void LLExperienceCache::getGroupExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, LLUUID groupId, ExperienceGetFn_t fn) +{ + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); + + // search for experiences owned by the current group + std::string url = mCapability("GroupExperiences"); + if (url.empty()) + { + LL_WARNS("ExperienceCache") << "No Group Experiences capability" << LL_ENDL; + } + + url += "?" + groupId.asString(); + + LLSD result = httpAdapter->getAndYield(httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + fn(LLSD()); + return; + } + + const LLSD& experienceIds = result["experience_ids"]; + fn(experienceIds); +} + //========================================================================= void LLExperienceCacheImpl::mapKeys(const LLSD& legacyKeys) { diff --git a/indra/llmessage/llexperiencecache.h b/indra/llmessage/llexperiencecache.h index f6f69d92ba..76cbbb6ed6 100644 --- a/indra/llmessage/llexperiencecache.h +++ b/indra/llmessage/llexperiencecache.h @@ -65,6 +65,7 @@ public: //------------------------------------------- void fetchAssociatedExperience(const LLUUID& objectId, const LLUUID& itemId, ExperienceGetFn_t fn); void findExperienceByName(const std::string text, int page, ExperienceGetFn_t fn); + void getGroupExperiences(const LLUUID &groupId, ExperienceGetFn_t fn); //------------------------------------------- static const std::string NAME; // "name" @@ -137,6 +138,7 @@ private: void fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, LLUUID, LLUUID, ExperienceGetFn_t); void findExperienceByNameCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, std::string, int, ExperienceGetFn_t); + void getGroupExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, LLUUID , ExperienceGetFn_t); void bootstrap(const LLSD& legacyKeys, int initialExpiration); void exportFile(std::ostream& ostr) const; diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index f763a59c94..b52ccffed9 100755 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -358,7 +358,7 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object, viewer_object->getID(), itemp); LLExperienceCache::getInstance()->fetchAssociatedExperience(itemp->getParentUUID(), itemp->getUUID(), - boost::bind(LLFloaterCompileQueue::requestAsset, datap, _1)); + boost::bind(&LLFloaterCompileQueue::requestAsset, datap, _1)); } } } diff --git a/indra/newview/llpanelgroupexperiences.cpp b/indra/newview/llpanelgroupexperiences.cpp index 76b68122fb..067f9eb426 100644 --- a/indra/newview/llpanelgroupexperiences.cpp +++ b/indra/newview/llpanelgroupexperiences.cpp @@ -37,39 +37,11 @@ #include "llflatlistview.h" #include "llpanelexperiences.h" #include "llsd.h" - +#include "llexperiencecache.h" static LLPanelInjector t_panel_group_experiences("panel_group_experiences"); -class LLGroupExperienceResponder : public LLHTTPClient::Responder -{ -public: - LLHandle mHandle; - - LLGroupExperienceResponder(LLHandle handle) : mHandle(handle) { } - -protected: - /*virtual*/ void httpSuccess() - { - if (mHandle.isDead()) - { - return; - } - - LLPanelGroupExperiences* panel = mHandle.get(); - if (panel) - { - panel->setExperienceList(getContent().get("experience_ids")); - } - } - - /*virtual*/ void httpFailure() - { - LL_WARNS() << "experience responder failed [status:" << getStatus() << "]: " << getContent() << LL_ENDL; - } -}; - LLPanelGroupExperiences::LLPanelGroupExperiences() : LLPanelGroupTab(), mExperiencesList(NULL) { @@ -101,14 +73,8 @@ void LLPanelGroupExperiences::activate() return; } - // search for experiences owned by the current group - std::string url = gAgent.getRegion()->getCapability("GroupExperiences"); - if (!url.empty()) - { - url += "?" + getGroupID().asString(); - - LLHTTPClient::get(url, new LLGroupExperienceResponder(getDerivedHandle())); - } + LLExperienceCache::getInstance()->getGroupExperiences(getGroupID(), + boost::bind(&LLPanelGroupExperiences::groupExperiencesResults, getDerivedHandle(), _1)); } void LLPanelGroupExperiences::setGroupID(const LLUUID& id) @@ -141,3 +107,19 @@ void LLPanelGroupExperiences::setExperienceList(const LLSD& experiences) mExperiencesList->addItem(item, public_key); } } + +/*static*/ +void LLPanelGroupExperiences::groupExperiencesResults(LLHandle handle, const LLSD &experiences) +{ + if (handle.isDead()) + { + return; + } + + LLPanelGroupExperiences* panel = handle.get(); + if (panel) + { + panel->setExperienceList(experiences); + } + +} diff --git a/indra/newview/llpanelgroupexperiences.h b/indra/newview/llpanelgroupexperiences.h index ae1ecc1ac5..7c79f77332 100644 --- a/indra/newview/llpanelgroupexperiences.h +++ b/indra/newview/llpanelgroupexperiences.h @@ -48,6 +48,9 @@ public: protected: LLFlatListView* mExperiencesList; + +private: + static void groupExperiencesResults(LLHandle, const LLSD &); }; #endif -- cgit v1.2.3