summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llcompilequeue.cpp49
-rwxr-xr-xindra/newview/llcompilequeue.h2
-rw-r--r--indra/newview/llfloaterexperiences.cpp224
-rw-r--r--indra/newview/llfloaterexperiences.h17
4 files changed, 169 insertions, 123 deletions
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index 24e662ee50..9545771c8d 100755
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -61,6 +61,7 @@
#include "llexperiencecache.h"
#include "llviewerassetupload.h"
+#include "llcorehttputil.h"
// *NOTE$: A minor specialization of LLScriptAssetUpload, it does not require a buffer
// (and does not save a buffer to the vFS) and it finds the compile queue window and
@@ -283,35 +284,6 @@ BOOL LLFloaterScriptQueue::startQueue()
return nextObject();
}
-class CompileQueueExperienceResponder : public LLHTTPClient::Responder
-{
-public:
- CompileQueueExperienceResponder(const LLUUID& parent):mParent(parent)
- {
- }
-
- LLUUID mParent;
-
- /*virtual*/ void httpSuccess()
- {
- sendResult(getContent());
- }
- /*virtual*/ void httpFailure()
- {
- sendResult(LLSD());
- }
- void sendResult(const LLSD& content)
- {
- LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", mParent);
- if(!queue)
- return;
-
- queue->experienceIdsReceived(content["experience_ids"]);
- }
-};
-
-
-
///----------------------------------------------------------------------------
/// Class LLFloaterCompileQueue
@@ -675,14 +647,29 @@ BOOL LLFloaterCompileQueue::startQueue()
std::string lookup_url=region->getCapability("GetCreatorExperiences");
if(!lookup_url.empty())
{
- LLHTTPClient::get(lookup_url, new CompileQueueExperienceResponder(getKey().asUUID()));
- return TRUE;
+ LLCoreHttpUtil::HttpCoroutineAdapter::completionCallback_t success =
+ boost::bind(&LLFloaterCompileQueue::processExperienceIdResults, _1, getKey().asUUID());
+
+ LLCoreHttpUtil::HttpCoroutineAdapter::completionCallback_t failure =
+ boost::bind(&LLFloaterCompileQueue::processExperienceIdResults, LLSD(), getKey().asUUID());
+
+ LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpGet(lookup_url,
+ success, failure);
+ return TRUE;
}
}
return nextObject();
}
+/*static*/
+void LLFloaterCompileQueue::processExperienceIdResults(LLSD result, LLUUID parent)
+{
+ LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", parent);
+ if (!queue)
+ return;
+ queue->experienceIdsReceived(result["experience_ids"]);
+}
void LLFloaterNotRunQueue::handleInventory(LLViewerObject* viewer_obj,
LLInventoryObject::object_list_t* inv)
diff --git a/indra/newview/llcompilequeue.h b/indra/newview/llcompilequeue.h
index c7be4fbe3b..cee8efe9b0 100755
--- a/indra/newview/llcompilequeue.h
+++ b/indra/newview/llcompilequeue.h
@@ -155,6 +155,8 @@ protected:
LLViewerInventoryItem::item_array_t mCurrentScripts;
private:
+ static void processExperienceIdResults(LLSD result, LLUUID parent);
+
uuid_list_t mExperienceIds;
};
diff --git a/indra/newview/llfloaterexperiences.cpp b/indra/newview/llfloaterexperiences.cpp
index 777dc382cd..14fbdb3a8f 100644
--- a/indra/newview/llfloaterexperiences.cpp
+++ b/indra/newview/llfloaterexperiences.cpp
@@ -43,59 +43,6 @@
#define SHOW_RECENT_TAB (0)
-
-class LLExperienceListResponder : public LLHTTPClient::Responder
-{
-public:
- typedef std::map<std::string, std::string> NameMap;
- typedef boost::function<void(LLPanelExperiences*, const LLSD&)> Callback;
- LLExperienceListResponder(const LLHandle<LLFloaterExperiences>& parent, NameMap& nameMap, const std::string& errorMessage="ErrorMessage"):mParent(parent),mErrorMessage(errorMessage)
- {
- mNameMap.swap(nameMap);
- }
-
- Callback mCallback;
- LLHandle<LLFloaterExperiences> mParent;
- NameMap mNameMap;
- const std::string mErrorMessage;
- /*virtual*/ void httpSuccess()
- {
- if(mParent.isDead())
- return;
-
- LLFloaterExperiences* parent=mParent.get();
- LLTabContainer* tabs = parent->getChild<LLTabContainer>("xp_tabs");
-
- NameMap::iterator it = mNameMap.begin();
- while(it != mNameMap.end())
- {
- if(getContent().has(it->first))
- {
- LLPanelExperiences* tab = (LLPanelExperiences*)tabs->getPanelByName(it->second);
- if(tab)
- {
- const LLSD& ids = getContent()[it->first];
- tab->setExperienceList(ids);
- if(!mCallback.empty())
- {
- mCallback(tab, getContent());
- }
- }
- }
- ++it;
- }
- }
-
- /*virtual*/ void httpFailure()
- {
- LLSD subs;
- subs["ERROR_MESSAGE"] = getReason();
- LLNotificationsUtil::add(mErrorMessage, subs);
- }
-};
-
-
-
LLFloaterExperiences::LLFloaterExperiences(const LLSD& data)
:LLFloater(data)
{
@@ -198,26 +145,20 @@ void LLFloaterExperiences::refreshContents()
if (region)
{
- LLExperienceListResponder::NameMap nameMap;
- std::string lookup_url=region->getCapability("GetExperiences");
- if(!lookup_url.empty())
- {
- nameMap["experiences"]="Allowed_Experiences_Tab";
- nameMap["blocked"]="Blocked_Experiences_Tab";
- LLHTTPClient::get(lookup_url, new LLExperienceListResponder(getDerivedHandle<LLFloaterExperiences>(), nameMap));
- }
+ NameMap_t tabMap;
+ LLHandle<LLFloaterExperiences> handle = getDerivedHandle<LLFloaterExperiences>();
+
+ tabMap["experiences"]="Allowed_Experiences_Tab";
+ tabMap["blocked"]="Blocked_Experiences_Tab";
+ tabMap["experience_ids"]="Owned_Experiences_Tab";
+
+ retrieveExperienceList(region->getCapability("GetExperiences"), handle, tabMap);
updateInfo("GetAdminExperiences","Admin_Experiences_Tab");
updateInfo("GetCreatorExperiences","Contrib_Experiences_Tab");
- lookup_url = region->getCapability("AgentExperiences");
- if(!lookup_url.empty())
- {
- nameMap["experience_ids"]="Owned_Experiences_Tab";
- LLExperienceListResponder* responder = new LLExperienceListResponder(getDerivedHandle<LLFloaterExperiences>(), nameMap, "ExperienceAcquireFailed");
- responder->mCallback = boost::bind(&LLFloaterExperiences::checkPurchaseInfo, this, _1, _2);
- LLHTTPClient::get(lookup_url, responder);
- }
+ retrieveExperienceList(region->getCapability("AgentExperiences"), handle, tabMap,
+ "ExperienceAcquireFailed", boost::bind(&LLFloaterExperiences::checkPurchaseInfo, this, _1, _2));
}
}
@@ -303,38 +244,139 @@ void LLFloaterExperiences::checkPurchaseInfo(LLPanelExperiences* panel, const LL
LLFloaterExperiences::findInstance()->updateInfo("GetCreatorExperiences","Contrib_Experiences_Tab");
}
-void LLFloaterExperiences::updateInfo(std::string experiences, std::string tab)
+void LLFloaterExperiences::updateInfo(std::string experienceCap, std::string tab)
{
LLViewerRegion* region = gAgent.getRegion();
if (region)
{
- LLExperienceListResponder::NameMap nameMap;
- std::string lookup_url = region->getCapability(experiences);
- if(!lookup_url.empty())
- {
- nameMap["experience_ids"]=tab;
- LLHTTPClient::get(lookup_url, new LLExperienceListResponder(getDerivedHandle<LLFloaterExperiences>(), nameMap));
- }
- }
+ NameMap_t tabMap;
+ LLHandle<LLFloaterExperiences> handle = getDerivedHandle<LLFloaterExperiences>();
+
+ tabMap["experience_ids"] = tab;
+
+ retrieveExperienceList(region->getCapability(experienceCap), handle, tabMap);
+ }
}
-void LLFloaterExperiences::sendPurchaseRequest() const
+void LLFloaterExperiences::sendPurchaseRequest()
{
- LLViewerRegion* region = gAgent.getRegion();
- std::string url = region->getCapability("AgentExperiences");
- if(!url.empty())
- {
- LLSD content;
-
- LLExperienceListResponder::NameMap nameMap;
- nameMap["experience_ids"]="Owned_Experiences_Tab";
- LLExperienceListResponder* responder = new LLExperienceListResponder(getDerivedHandle<LLFloaterExperiences>(), nameMap, "ExperienceAcquireFailed");
- responder->mCallback = boost::bind(&LLFloaterExperiences::checkPurchaseInfo, this, _1, _2);
- LLHTTPClient::post(url, content, responder);
- }
+ LLViewerRegion* region = gAgent.getRegion();
+
+ if (region)
+ {
+ NameMap_t tabMap;
+ LLHandle<LLFloaterExperiences> handle = getDerivedHandle<LLFloaterExperiences>();
+
+ tabMap["experience_ids"] = "Owned_Experiences_Tab";
+
+ requestNewExperience(region->getCapability("AgentExperiences"), handle, tabMap, "ExperienceAcquireFailed",
+ boost::bind(&LLFloaterExperiences::checkPurchaseInfo, this, _1, _2));
+ }
}
LLFloaterExperiences* LLFloaterExperiences::findInstance()
{
return LLFloaterReg::findTypedInstance<LLFloaterExperiences>("experiences");
}
+
+
+void LLFloaterExperiences::retrieveExperienceList(const std::string &url,
+ const LLHandle<LLFloaterExperiences> &hparent, const NameMap_t &tabMapping,
+ const std::string &errorNotify, Callback_t cback)
+
+{
+ invokationFn_t getFn = boost::bind(
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
+ static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
+ //----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> httpOptions
+ // _5 -> httpHeaders
+ (&LLCoreHttpUtil::HttpCoroutineAdapter::getAndYield), _1, _2, _3, _4, _5);
+
+ LLCoros::instance().launch("LLFloaterExperiences::retrieveExperienceList",
+ boost::bind(&LLFloaterExperiences::retrieveExperienceListCoro,
+ url, hparent, tabMapping, errorNotify, cback, getFn));
+
+}
+
+void LLFloaterExperiences::requestNewExperience(const std::string &url,
+ const LLHandle<LLFloaterExperiences> &hparent, const NameMap_t &tabMapping,
+ const std::string &errorNotify, Callback_t cback)
+{
+ invokationFn_t postFn = boost::bind(
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
+ static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t, const std::string &, const LLSD &, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t)>
+ //----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> httpOptions
+ // _5 -> httpHeaders
+ (&LLCoreHttpUtil::HttpCoroutineAdapter::postAndYield), _1, _2, _3, LLSD(), _4, _5);
+
+ LLCoros::instance().launch("LLFloaterExperiences::requestNewExperience",
+ boost::bind(&LLFloaterExperiences::retrieveExperienceListCoro,
+ url, hparent, tabMapping, errorNotify, cback, postFn));
+
+}
+
+
+void LLFloaterExperiences::retrieveExperienceListCoro(std::string url,
+ LLHandle<LLFloaterExperiences> hparent, NameMap_t tabMapping,
+ std::string errorNotify, Callback_t cback, invokationFn_t invoker)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("retrieveExperienceListCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions);
+ LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
+
+
+ if (url.empty())
+ {
+ LL_WARNS() << "retrieveExperienceListCoro called with empty capability!" << LL_ENDL;
+ return;
+ }
+
+ LLSD result = invoker(httpAdapter, httpRequest, url, httpOptions, httpHeaders);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ LLSD subs;
+ subs["ERROR_MESSAGE"] = status.getType();
+ LLNotificationsUtil::add(errorNotify, subs);
+
+ return;
+ }
+
+ if (hparent.isDead())
+ return;
+
+ LLFloaterExperiences* parent = hparent.get();
+ LLTabContainer* tabs = parent->getChild<LLTabContainer>("xp_tabs");
+
+ for (NameMap_t::iterator it = tabMapping.begin(); it != tabMapping.end(); ++it)
+ {
+ if (result.has(it->first))
+ {
+ LLPanelExperiences* tab = (LLPanelExperiences*)tabs->getPanelByName(it->second);
+ if (tab)
+ {
+ const LLSD& ids = result[it->first];
+ tab->setExperienceList(ids);
+ if (!cback.empty())
+ {
+ cback(tab, result);
+ }
+ }
+ }
+ }
+
+}
diff --git a/indra/newview/llfloaterexperiences.h b/indra/newview/llfloaterexperiences.h
index 769283ff07..c038aa6375 100644
--- a/indra/newview/llfloaterexperiences.h
+++ b/indra/newview/llfloaterexperiences.h
@@ -28,6 +28,7 @@
#define LL_LLFLOATEREXPERIENCES_H
#include "llfloater.h"
+#include "llcorehttputil.h"
class LLPanelExperiences;
@@ -41,6 +42,9 @@ public:
virtual void onOpen(const LLSD& key);
static LLFloaterExperiences* findInstance();
protected:
+ typedef std::map<std::string, std::string> NameMap_t;
+ typedef boost::function<void(LLPanelExperiences*, const LLSD&)> Callback_t;
+
void clearFromRecent(const LLSD& ids);
void resizeToTabs();
/*virtual*/ BOOL postBuild();
@@ -49,11 +53,22 @@ protected:
LLPanelExperiences* addTab(const std::string& name, bool select);
bool updatePermissions(const LLSD& permission);
- void sendPurchaseRequest() const;
+ void sendPurchaseRequest();
void checkPurchaseInfo(LLPanelExperiences* panel, const LLSD& content)const;
void updateInfo(std::string experiences, std::string tab);
+ void retrieveExperienceList(const std::string &url, const LLHandle<LLFloaterExperiences> &hparent, const NameMap_t &tabMapping,
+ const std::string &errorNotify = std::string("ErrorMessage"), Callback_t cback = Callback_t());
+
+ void requestNewExperience(const std::string &url, const LLHandle<LLFloaterExperiences> &hparent, const NameMap_t &tabMapping,
+ const std::string &errorNotify, Callback_t cback);
+
private:
+ typedef boost::function < LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t, LLCore::HttpRequest::ptr_t,
+ const std::string, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t) > invokationFn_t;
+
+ static void retrieveExperienceListCoro(std::string url, LLHandle<LLFloaterExperiences> hparent,
+ NameMap_t tabMapping, std::string errorNotify, Callback_t cback, invokationFn_t invoker);
};