summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2015-05-29 13:17:03 -0700
committerRider Linden <rider@lindenlab.com>2015-05-29 13:17:03 -0700
commitd41ad508bf10643c3bfeb70dd8f39e187d618a02 (patch)
treecf8816d6d78ad1405246c7a998b8c4cf13147eca /indra
parent4fb588187106b18724d730e6235fc57454744341 (diff)
Land SKU descriptions by coro
Diffstat (limited to 'indra')
-rwxr-xr-xindra/newview/llproductinforequest.cpp63
-rwxr-xr-xindra/newview/llproductinforequest.h21
2 files changed, 45 insertions, 39 deletions
diff --git a/indra/newview/llproductinforequest.cpp b/indra/newview/llproductinforequest.cpp
index e92bf4590d..fd948765b3 100755
--- a/indra/newview/llproductinforequest.cpp
+++ b/indra/newview/llproductinforequest.cpp
@@ -32,31 +32,10 @@
#include "llagent.h" // for gAgent
#include "lltrans.h"
#include "llviewerregion.h"
+#include "llcorehttputil.h"
-class LLProductInfoRequestResponder : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLProductInfoRequestResponder);
-private:
- //If we get back a normal response, handle it here
- /* virtual */ void httpSuccess()
- {
- const LLSD& content = getContent();
- if (!content.isArray())
- {
- failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content);
- return;
- }
- LLProductInfoRequestManager::instance().setSkuDescriptions(getContent());
- }
-
- //If we get back an error (not found, etc...), handle it here
- /* virtual */ void httpFailure()
- {
- LL_WARNS() << dumpResponse() << LL_ENDL;
- }
-};
-
-LLProductInfoRequestManager::LLProductInfoRequestManager() : mSkuDescriptions()
+LLProductInfoRequestManager::LLProductInfoRequestManager():
+ mSkuDescriptions()
{
}
@@ -65,15 +44,11 @@ void LLProductInfoRequestManager::initSingleton()
std::string url = gAgent.getRegion()->getCapability("ProductInfoRequest");
if (!url.empty())
{
- LLHTTPClient::get(url, new LLProductInfoRequestResponder());
+ LLCoros::instance().launch("LLProductInfoRequestManager::getLandDescriptionsCoro",
+ boost::bind(&LLProductInfoRequestManager::getLandDescriptionsCoro, this, _1, url));
}
}
-void LLProductInfoRequestManager::setSkuDescriptions(const LLSD& content)
-{
- mSkuDescriptions = content;
-}
-
std::string LLProductInfoRequestManager::getDescriptionForSku(const std::string& sku)
{
// The description LLSD is an array of maps; each array entry
@@ -90,3 +65,31 @@ std::string LLProductInfoRequestManager::getDescriptionForSku(const std::string&
}
return LLTrans::getString("land_type_unknown");
}
+
+void LLProductInfoRequestManager::getLandDescriptionsCoro(LLCoros::self& self, std::string url)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+
+ LLSD result = httpAdapter->getAndYield(self, httpRequest, url);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ return;
+ }
+
+ if (result.has(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT) &&
+ result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT].isArray())
+ {
+ mSkuDescriptions = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_CONTENT];
+ }
+ else
+ {
+ LL_WARNS() << "Land SKU description response is malformed" << LL_ENDL;
+ }
+}
diff --git a/indra/newview/llproductinforequest.h b/indra/newview/llproductinforequest.h
index fe8f7093b0..44aaa9d6e4 100755
--- a/indra/newview/llproductinforequest.h
+++ b/indra/newview/llproductinforequest.h
@@ -30,25 +30,28 @@
#include "llhttpclient.h"
#include "llmemory.h"
+#include "lleventcoro.h"
+#include "llcoros.h"
-/*
- This is a singleton to manage a cache of information about land types.
- The land system provides a capability to get information about the
- set of possible land sku, name, and description information.
- We use description in the UI, but the sku is provided in the various
- messages; this tool provides translation between the systems.
+/**
+ * This is a singleton to manage a cache of information about land types.
+ * The land system provides a capability to get information about the
+ * set of possible land sku, name, and description information.
+ * We use description in the UI, but the sku is provided in the various
+ * messages; this tool provides translation between the systems.
*/
-
class LLProductInfoRequestManager : public LLSingleton<LLProductInfoRequestManager>
{
public:
LLProductInfoRequestManager();
- void setSkuDescriptions(const LLSD& content);
std::string getDescriptionForSku(const std::string& sku);
+
private:
friend class LLSingleton<LLProductInfoRequestManager>;
/* virtual */ void initSingleton();
- LLSD mSkuDescriptions;
+
+ void getLandDescriptionsCoro(LLCoros::self& self, std::string url);
+ LLSD mSkuDescriptions;
};
#endif // LL_LLPRODUCTINFOREQUEST_H