summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llcommon/llsdjson.cpp48
-rw-r--r--indra/llcommon/llsdjson.h18
-rw-r--r--indra/llmessage/llcorehttputil.cpp106
-rw-r--r--indra/llmessage/llcorehttputil.h69
-rwxr-xr-xindra/newview/CMakeLists.txt3
-rw-r--r--indra/newview/llfloaterexperienceprofile.cpp13
-rwxr-xr-xindra/newview/llmarketplacefunctions.cpp1361
-rwxr-xr-xindra/newview/llmarketplacefunctions.h8
-rwxr-xr-xindra/newview/lltexturestats.cpp14
-rwxr-xr-xindra/newview/lltexturestatsuploader.cpp49
-rwxr-xr-xindra/newview/lltexturestatsuploader.h40
-rwxr-xr-xindra/newview/llviewermessage.cpp21
12 files changed, 779 insertions, 971 deletions
diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp
index 2afdba388a..8caaaee534 100644
--- a/indra/llcommon/llsdjson.cpp
+++ b/indra/llcommon/llsdjson.cpp
@@ -76,3 +76,51 @@ LLSD LlsdFromJson(const Json::Value &val)
}
return result;
}
+
+//=========================================================================
+Json::Value LlsdToJson(const LLSD &val)
+{
+ Json::Value result;
+
+ switch (val.type())
+ {
+ case LLSD::TypeUndefined:
+ result = Json::Value::null;
+ break;
+ case LLSD::TypeBoolean:
+ result = Json::Value(static_cast<bool>(val.asBoolean()));
+ break;
+ case LLSD::TypeInteger:
+ result = Json::Value(static_cast<int>(val.asInteger()));
+ break;
+ case LLSD::TypeReal:
+ result = Json::Value(static_cast<double>(val.asReal()));
+ break;
+ case LLSD::TypeURI:
+ case LLSD::TypeDate:
+ case LLSD::TypeUUID:
+ case LLSD::TypeString:
+ result = Json::Value(val.asString());
+ break;
+ case LLSD::TypeMap:
+ result = Json::Value(Json::objectValue);
+ for (LLSD::map_const_iterator it = val.beginMap(); it != val.endMap(); ++it)
+ {
+ result[it->first] = LlsdToJson(it->second);
+ }
+ break;
+ case LLSD::TypeArray:
+ result = Json::Value(Json::arrayValue);
+ for (LLSD::array_const_iterator it = val.beginArray(); it != val.endArray(); ++it)
+ {
+ result.append(LlsdToJson(*it));
+ }
+ break;
+ case LLSD::TypeBinary:
+ default:
+ LL_ERRS("LlsdToJson") << "Unsupported conversion to JSON from LLSD type (" << val.type() << ")." << LL_ENDL;
+ break;
+ }
+
+ return result;
+}
diff --git a/indra/llcommon/llsdjson.h b/indra/llcommon/llsdjson.h
index cdf9fed500..2be7112404 100644
--- a/indra/llcommon/llsdjson.h
+++ b/indra/llcommon/llsdjson.h
@@ -55,5 +55,23 @@
/// Order is preserved for an array but not for objects.
LLSD LlsdFromJson(const Json::Value &val);
+/// Convert an LLSD object into Parsed JSON object maintaining member names and
+/// array indexs.
+///
+/// Types are converted as follows:
+/// LLSD Type | JSON Type
+/// --------------+----------------
+/// TypeUndefined | null
+/// TypeBoolean | boolean
+/// TypeInteger | integer
+/// TypeReal | real/numeric
+/// TypeString | string
+/// TypeURI | string
+/// TypeDate | string
+/// TypeUUID | string
+/// TypeMap | object
+/// TypeArray | array
+/// TypeBinary | unsupported
+Json::Value LlsdToJson(const LLSD &val);
#endif // LL_LLSDJSON_H
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp
index d342888255..4c2e2c5ee7 100644
--- a/indra/llmessage/llcorehttputil.cpp
+++ b/indra/llmessage/llcorehttputil.cpp
@@ -35,7 +35,8 @@
#include "llsd.h"
#include "llsdjson.h"
#include "llsdserialize.h"
-#include "reader.h"
+#include "reader.h" // JSON
+#include "writer.h" // JSON
#include "llvfile.h"
#include "message.h" // for getting the port
@@ -570,7 +571,7 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName, true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump));
return postAndYield_(request, url, body, options, headers, httpHandler);
}
@@ -607,7 +608,7 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName, true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump));
return postAndYield_(request, url, rawbody, options, headers, httpHandler);
}
@@ -617,7 +618,7 @@ LLSD HttpCoroutineAdapter::postRawAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName, true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroRawHandler(replyPump));
return postAndYield_(request, url, rawbody, options, headers, httpHandler);
}
@@ -676,6 +677,28 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request,
return postAndYield(request, url, fileData, options, headers);
}
+LLSD HttpCoroutineAdapter::postJsonAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url, const LLSD & body,
+ LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
+{
+ LLEventStream replyPump(mAdapterName, true);
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroJSONHandler(replyPump));
+
+ LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray);
+
+ {
+ LLCore::BufferArrayStream outs(rawbody.get());
+ Json::Value root = LlsdToJson(body);
+ Json::FastWriter writer;
+
+ LL_WARNS("Http::post") << "JSON Generates: \"" << writer.write(root) << "\"" << LL_ENDL;
+
+ outs << writer.write(root);
+ }
+
+ return postAndYield_(request, url, rawbody, options, headers, httpHandler);
+}
+
LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request,
const std::string & url, LLCore::BufferArray::ptr_t &rawbody,
@@ -708,11 +731,32 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump));
return putAndYield_(request, url, body, options, headers, httpHandler);
}
+LLSD HttpCoroutineAdapter::putJsonAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url, const LLSD & body,
+ LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
+{
+ LLEventStream replyPump(mAdapterName, true);
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroJSONHandler(replyPump));
+
+ LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray);
+
+ {
+ LLCore::BufferArrayStream outs(rawbody.get());
+ Json::Value root = LlsdToJson(body);
+ Json::FastWriter writer;
+
+ LL_WARNS("Http::put") << "JSON Generates: \"" << writer.write(root) << "\"" << LL_ENDL;
+ outs << writer.write(root);
+ }
+
+ return putAndYield_(request, url, rawbody, options, headers, httpHandler);
+}
+
LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request,
const std::string & url, const LLSD & body,
LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
@@ -740,12 +784,39 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request,
return results;
}
+LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request,
+ const std::string & url, const LLCore::BufferArray::ptr_t & rawbody,
+ LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
+ HttpCoroHandler::ptr_t &handler)
+{
+ HttpRequestPumper pumper(request);
+
+ checkDefaultHeaders(headers);
+
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // pointer from the smart pointer is safe in this case.
+ LLCore::HttpHandle hhandle = request->requestPut(mPolicyId, mPriority,
+ url, rawbody.get(), options, headers, handler.get());
+
+ if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
+ {
+ return HttpCoroutineAdapter::buildImmediateErrorResult(request, url);
+ }
+
+ saveState(hhandle, request, handler);
+ LLSD results = llcoro::waitForEventOn(handler->getReplyPump());
+ cleanState();
+
+ return results;
+}
+
+
LLSD HttpCoroutineAdapter::getAndYield(LLCore::HttpRequest::ptr_t request,
const std::string & url,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump));
return getAndYield_(request, url, options, headers, httpHandler);
}
@@ -755,7 +826,7 @@ LLSD HttpCoroutineAdapter::getRawAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroRawHandler(replyPump));
return getAndYield_(request, url, options, headers, httpHandler);
}
@@ -764,7 +835,7 @@ LLSD HttpCoroutineAdapter::getJsonAndYield(LLCore::HttpRequest::ptr_t request,
const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroJSONHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroJSONHandler(replyPump));
return getAndYield_(request, url, options, headers, httpHandler);
}
@@ -801,11 +872,22 @@ LLSD HttpCoroutineAdapter::deleteAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump));
+
+ return deleteAndYield_(request, url, options, headers, httpHandler);
+}
+
+LLSD HttpCoroutineAdapter::deleteJsonAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url,
+ LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
+{
+ LLEventStream replyPump(mAdapterName + "Reply", true);
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroJSONHandler(replyPump));
return deleteAndYield_(request, url, options, headers, httpHandler);
}
+
LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request,
const std::string & url, LLCore::HttpOptions::ptr_t &options,
LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler)
@@ -835,7 +917,7 @@ LLSD HttpCoroutineAdapter::patchAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump));
return patchAndYield_(request, url, body, options, headers, httpHandler);
}
@@ -873,7 +955,7 @@ LLSD HttpCoroutineAdapter::copyAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump));
if (!headers)
headers.reset(new LLCore::HttpHeaders);
@@ -915,7 +997,7 @@ LLSD HttpCoroutineAdapter::moveAndYield(LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
- HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump));
+ HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump));
if (!headers)
headers.reset(new LLCore::HttpHeaders);
diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h
index 31a73bb900..6599a4f01a 100644
--- a/indra/llmessage/llcorehttputil.h
+++ b/indra/llmessage/llcorehttputil.h
@@ -337,6 +337,7 @@ public:
const std::string & url, LLCore::BufferArray::ptr_t rawbody,
LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()));
+
LLSD postAndYield(LLCore::HttpRequest::ptr_t &request,
const std::string & url, const LLSD & body,
LLCore::HttpHeaders::ptr_t &headers)
@@ -393,6 +394,19 @@ public:
LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers);
}
+ LLSD postJsonAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url, const LLSD & body,
+ LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
+ LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()));
+ LLSD postJsonAndYield(LLCore::HttpRequest::ptr_t &request,
+ const std::string & url, const LLSD & body,
+ LLCore::HttpHeaders::ptr_t &headers)
+ {
+ return postJsonAndYield(request, url, body,
+ LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers);
+ }
+
+
/// Execute a Put transaction on the supplied URL and yield execution of
/// the coroutine until a result is available.
@@ -404,11 +418,32 @@ public:
LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()));
+ LLSD putAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url, const LLSD & body,
+ LLCore::HttpHeaders::ptr_t headers)
+ {
+ return putAndYield(request, url, body,
+ LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers);
+ }
+
+ LLSD putJsonAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url, const LLSD & body,
+ LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
+ LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()));
+ LLSD putJsonAndYield(LLCore::HttpRequest::ptr_t &request,
+ const std::string & url, const LLSD & body,
+ LLCore::HttpHeaders::ptr_t &headers)
+ {
+ return putJsonAndYield(request, url, body,
+ LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers);
+ }
+
/// Execute a Get transaction on the supplied URL and yield execution of
/// the coroutine until a result is available.
///
/// @Note: the request's smart pointer is passed by value so that it will
/// not be deallocated during the yield.
+ ///
LLSD getAndYield(LLCore::HttpRequest::ptr_t request,
const std::string & url,
LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
@@ -433,11 +468,15 @@ public:
headers);
}
+ /// These methods have the same behavior as @getAndYield() however they are
+ /// expecting the server to return the results formatted in a JSON string.
+ /// On a successful GET call the JSON results will be converted into LLSD
+ /// before being returned to the caller.
LLSD getJsonAndYield(LLCore::HttpRequest::ptr_t request,
const std::string & url,
LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()));
- LLSD getJsonndYield(LLCore::HttpRequest::ptr_t &request,
+ LLSD getJsonAndYield(LLCore::HttpRequest::ptr_t &request,
const std::string & url, LLCore::HttpHeaders::ptr_t &headers)
{
return getJsonAndYield(request, url,
@@ -455,6 +494,29 @@ public:
const std::string & url,
LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()));
+ LLSD deleteAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url, LLCore::HttpHeaders::ptr_t headers)
+ {
+ return deleteAndYield(request, url,
+ LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
+ headers);
+ }
+
+ /// These methods have the same behavior as @deleteAndYield() however they are
+ /// expecting the server to return any results formatted in a JSON string.
+ /// On a successful DELETE call the JSON results will be converted into LLSD
+ /// before being returned to the caller.
+ LLSD deleteJsonAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url,
+ LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
+ LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()));
+ LLSD deleteJsonAndYield(LLCore::HttpRequest::ptr_t request,
+ const std::string & url, LLCore::HttpHeaders::ptr_t headers)
+ {
+ return deleteJsonAndYield(request, url,
+ LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()),
+ headers);
+ }
/// Execute a PATCH transaction on the supplied URL and yield execution of
@@ -568,6 +630,11 @@ private:
LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
HttpCoroHandler::ptr_t &handler);
+ LLSD putAndYield_(LLCore::HttpRequest::ptr_t &request,
+ const std::string & url, const LLCore::BufferArray::ptr_t & rawbody,
+ LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
+ HttpCoroHandler::ptr_t &handler);
+
LLSD getAndYield_(LLCore::HttpRequest::ptr_t &request,
const std::string & url, LLCore::HttpOptions::ptr_t &options,
LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler);
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 67af240f8d..979b182662 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -561,7 +561,6 @@ set(viewer_SOURCE_FILES
lltextureinfo.cpp
lltextureinfodetails.cpp
lltexturestats.cpp
- lltexturestatsuploader.cpp
lltextureview.cpp
lltoast.cpp
lltoastalertpanel.cpp
@@ -1160,7 +1159,6 @@ set(viewer_HEADER_FILES
lltextureinfo.h
lltextureinfodetails.h
lltexturestats.h
- lltexturestatsuploader.h
lltextureview.h
lltoast.h
lltoastalertpanel.h
@@ -2386,7 +2384,6 @@ if (LL_TESTS)
#ADD_VIEWER_BUILD_TEST(llagentaccess viewer)
#ADD_VIEWER_BUILD_TEST(lltextureinfo viewer)
#ADD_VIEWER_BUILD_TEST(lltextureinfodetails viewer)
- #ADD_VIEWER_BUILD_TEST(lltexturestatsuploader viewer)
include(LLAddBuildTest)
SET(viewer_TEST_SOURCE_FILES
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 T>
-class HandleResponder : public LLHTTPClient::Responder
-{
-public:
- HandleResponder(const LLHandle<T>& parent):mParent(parent){}
- LLHandle<T> mParent;
-
- virtual void httpFailure()
- {
- LL_WARNS() << "HandleResponder failed with code: " << getStatus() << ", reason: " << getReason() << LL_ENDL;
- }
-};
-
BOOL LLFloaterExperienceProfile::postBuild()
{
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index f11d0f16da..8eace7d2be 100755
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -48,605 +48,125 @@
#include "llcoros.h"
#include "llcorehttputil.h"
+#include "llsdutil.h"
//
// Helpers
//
-static std::string getMarketplaceDomain()
-{
- std::string domain = "secondlife.com";
-
- if (!LLGridManager::getInstance()->isInProductionGrid())
- {
- const std::string& grid_id = LLGridManager::getInstance()->getGridId();
- const std::string& grid_id_lower = utf8str_tolower(grid_id);
-
- if (grid_id_lower == "damballah")
- {
- domain = "secondlife-staging.com";
- }
- else
- {
- domain = llformat("%s.lindenlab.com", grid_id_lower.c_str());
- }
- }
-
- return domain;
-}
-
-static std::string getMarketplaceURL(const std::string& urlStringName)
-{
- LLStringUtil::format_map_t domain_arg;
- domain_arg["[MARKETPLACE_DOMAIN_NAME]"] = getMarketplaceDomain();
-
- std::string marketplace_url = LLTrans::getString(urlStringName, domain_arg);
-
- return marketplace_url;
-}
+namespace {
-LLSD getMarketplaceStringSubstitutions()
-{
- std::string marketplace_url = getMarketplaceURL("MarketplaceURL");
- std::string marketplace_url_create = getMarketplaceURL("MarketplaceURL_CreateStore");
- std::string marketplace_url_dashboard = getMarketplaceURL("MarketplaceURL_Dashboard");
- std::string marketplace_url_imports = getMarketplaceURL("MarketplaceURL_Imports");
- std::string marketplace_url_info = getMarketplaceURL("MarketplaceURL_LearnMore");
+ static std::string getMarketplaceDomain()
+ {
+ std::string domain = "secondlife.com";
- LLSD marketplace_sub_map;
-
- marketplace_sub_map["[MARKETPLACE_URL]"] = marketplace_url;
- marketplace_sub_map["[MARKETPLACE_CREATE_STORE_URL]"] = marketplace_url_create;
- marketplace_sub_map["[MARKETPLACE_LEARN_MORE_URL]"] = marketplace_url_info;
- marketplace_sub_map["[MARKETPLACE_DASHBOARD_URL]"] = marketplace_url_dashboard;
- marketplace_sub_map["[MARKETPLACE_IMPORTS_URL]"] = marketplace_url_imports;
+ if (!LLGridManager::getInstance()->isInProductionGrid())
+ {
+ const std::string& grid_id = LLGridManager::getInstance()->getGridId();
+ const std::string& grid_id_lower = utf8str_tolower(grid_id);
+
+ if (grid_id_lower == "damballah")
+ {
+ domain = "secondlife-staging.com";
+ }
+ else
+ {
+ domain = llformat("%s.lindenlab.com", grid_id_lower.c_str());
+ }
+ }
- return marketplace_sub_map;
-}
-
-// Get the version folder: if there is only one subfolder, we will use it as a version folder
-LLUUID getVersionFolderIfUnique(const LLUUID& folder_id)
-{
- LLUUID version_id = LLUUID::null;
- LLInventoryModel::cat_array_t* categories;
- LLInventoryModel::item_array_t* items;
- gInventory.getDirectDescendentsOf(folder_id, categories, items);
- if (categories->size() == 1)
- {
- version_id = categories->begin()->get()->getUUID();
- }
- else
- {
- LLNotificationsUtil::add("AlertMerchantListingActivateRequired");
+ return domain;
}
- return version_id;
-}
-///////////////////////////////////////////////////////////////////////////////
-// SLM Responders
-void log_SLM_warning(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description)
-{
- LL_WARNS("SLM") << "SLM API : Responder to " << request << ". status : " << status << ", reason : " << reason << ", code : " << code << ", description : " << description << LL_ENDL;
- if ((status == 422) && (description == "[\"You must have an English description to list the product\", \"You must choose a category for your product before it can be listed\", \"Listing could not change state.\", \"Price can't be blank\"]"))
- {
- // Unprocessable Entity : Special case that error as it is a frequent answer when trying to list an incomplete listing
- LLNotificationsUtil::add("MerchantUnprocessableEntity");
- }
- else
- {
- // Prompt the user with the warning (so they know why things are failing)
- LLSD subs;
- subs["[ERROR_REASON]"] = reason;
- // We do show long descriptions in the alert (unlikely to be readable). The description string will be in the log though.
- subs["[ERROR_DESCRIPTION]"] = (description.length() <= 512 ? description : "");
- LLNotificationsUtil::add("MerchantTransactionFailed", subs);
- }
-}
-void log_SLM_infos(const std::string& request, U32 status, const std::string& body)
-{
- if (gSavedSettings.getBOOL("MarketplaceListingsLogging"))
- {
- LL_INFOS("SLM") << "SLM API : Responder to " << request << ". status : " << status << ", body or description : " << body << LL_ENDL;
- }
-}
-void log_SLM_infos(const std::string& request, const std::string& url, const std::string& body)
-{
- if (gSavedSettings.getBOOL("MarketplaceListingsLogging"))
+ static std::string getMarketplaceURL(const std::string& urlStringName)
{
- LL_INFOS("SLM") << "SLM API : Sending " << request << ". url : " << url << ", body : " << body << LL_ENDL;
- }
-}
-
-class LLSLMGetMerchantResponder : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLSLMGetMerchantResponder);
-public:
+ LLStringUtil::format_map_t domain_arg;
+ domain_arg["[MARKETPLACE_DOMAIN_NAME]"] = getMarketplaceDomain();
+
+ std::string marketplace_url = LLTrans::getString(urlStringName, domain_arg);
- LLSLMGetMerchantResponder() {}
+ return marketplace_url;
+ }
-protected:
- virtual void httpFailure()
+ // Get the version folder: if there is only one subfolder, we will use it as a version folder
+ LLUUID getVersionFolderIfUnique(const LLUUID& folder_id)
{
- if (HTTP_NOT_FOUND == getStatus())
+ LLUUID version_id = LLUUID::null;
+ LLInventoryModel::cat_array_t* categories;
+ LLInventoryModel::item_array_t* items;
+ gInventory.getDirectDescendentsOf(folder_id, categories, items);
+ if (categories->size() == 1)
{
- log_SLM_infos("Get /merchant", getStatus(), "User is not a merchant");
- LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT);
+ version_id = categories->begin()->get()->getUUID();
}
- else if (HTTP_SERVICE_UNAVAILABLE == getStatus())
+ else
{
- log_SLM_infos("Get /merchant", getStatus(), "Merchant is not migrated");
- LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MIGRATED_MERCHANT);
+ LLNotificationsUtil::add("AlertMerchantListingActivateRequired");
}
- else
- {
- log_SLM_warning("Get /merchant", getStatus(), getReason(), getContent().get("error_code"), getContent().get("error_description"));
- LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_CONNECTION_FAILURE);
- }
- }
-
- virtual void httpSuccess()
- {
- log_SLM_infos("Get /merchant", getStatus(), "User is a merchant");
- LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT);
+ return version_id;
}
-
-};
-class LLSLMGetListingsResponder : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLSLMGetListingsResponder);
-public:
-
- LLSLMGetListingsResponder(const LLUUID& folder_id)
- {
- mExpectedFolderId = folder_id;
- }
-
- virtual void completedRaw(const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer)
+ ///////////////////////////////////////////////////////////////////////////////
+ // SLM Responders
+ void log_SLM_warning(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description)
{
- LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false);
-
- LLBufferStream istr(channels, buffer.get());
- std::stringstream strstrm;
- strstrm << istr.rdbuf();
- const std::string body = strstrm.str();
-
- if (!isGoodStatus())
- {
- log_SLM_warning("Get /listings", getStatus(), getReason(), "", body);
- LLMarketplaceData::instance().setSLMDataFetched(MarketplaceFetchCodes::MARKET_FETCH_FAILED);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- Json::Value root;
- Json::Reader reader;
- if (!reader.parse(body,root))
+ LL_WARNS("SLM") << "SLM API : Responder to " << request << ". status : " << status << ", reason : " << reason << ", code : " << code << ", description : " << description << LL_ENDL;
+ if ((status == 422) && (description == "[\"You must have an English description to list the product\", \"You must choose a category for your product before it can be listed\", \"Listing could not change state.\", \"Price can't be blank\"]"))
{
- log_SLM_warning("Get /listings", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body);
- LLMarketplaceData::instance().setSLMDataFetched(MarketplaceFetchCodes::MARKET_FETCH_FAILED);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
+ // Unprocessable Entity : Special case that error as it is a frequent answer when trying to list an incomplete listing
+ LLNotificationsUtil::add("MerchantUnprocessableEntity");
}
-
- log_SLM_infos("Get /listings", getStatus(), body);
-
- // Extract the info from the Json string
- Json::ValueIterator it = root["listings"].begin();
-
- while (it != root["listings"].end())
+ else
{
- Json::Value listing = *it;
-
- int listing_id = listing["id"].asInt();
- bool is_listed = listing["is_listed"].asBool();
- std::string edit_url = listing["edit_url"].asString();
- std::string folder_uuid_string = listing["inventory_info"]["listing_folder_id"].asString();
- std::string version_uuid_string = listing["inventory_info"]["version_folder_id"].asString();
- int count = listing["inventory_info"]["count_on_hand"].asInt();
-
- LLUUID folder_id(folder_uuid_string);
- LLUUID version_id(version_uuid_string);
- if (folder_id.notNull())
- {
- LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed,edit_url,count);
- }
- it++;
+ // Prompt the user with the warning (so they know why things are failing)
+ LLSD subs;
+ subs["[ERROR_REASON]"] = reason;
+ // We do show long descriptions in the alert (unlikely to be readable). The description string will be in the log though.
+ subs["[ERROR_DESCRIPTION]"] = (description.length() <= 512 ? description : "");
+ LLNotificationsUtil::add("MerchantTransactionFailed", subs);
}
-
- // Update all folders under the root
- LLMarketplaceData::instance().setSLMDataFetched(MarketplaceFetchCodes::MARKET_FETCH_DONE);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
}
-private:
- LLUUID mExpectedFolderId;
-};
-class LLSLMCreateListingsResponder : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLSLMCreateListingsResponder);
-public:
-
- LLSLMCreateListingsResponder(const LLUUID& folder_id)
+ void log_SLM_infos(const std::string& request, U32 status, const std::string& body)
{
- mExpectedFolderId = folder_id;
- }
-
- virtual void completedRaw(const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer)
- {
- LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false);
-
- LLBufferStream istr(channels, buffer.get());
- std::stringstream strstrm;
- strstrm << istr.rdbuf();
- const std::string body = strstrm.str();
-
- if (!isGoodStatus())
- {
- log_SLM_warning("Post /listings", getStatus(), getReason(), "", body);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- Json::Value root;
- Json::Reader reader;
- if (!reader.parse(body,root))
+ if (gSavedSettings.getBOOL("MarketplaceListingsLogging"))
{
- log_SLM_warning("Post /listings", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- log_SLM_infos("Post /listings", getStatus(), body);
-
- // Extract the info from the Json string
- Json::ValueIterator it = root["listings"].begin();
-
- while (it != root["listings"].end())
- {
- Json::Value listing = *it;
-
- int listing_id = listing["id"].asInt();
- bool is_listed = listing["is_listed"].asBool();
- std::string edit_url = listing["edit_url"].asString();
- std::string folder_uuid_string = listing["inventory_info"]["listing_folder_id"].asString();
- std::string version_uuid_string = listing["inventory_info"]["version_folder_id"].asString();
- int count = listing["inventory_info"]["count_on_hand"].asInt();
-
- LLUUID folder_id(folder_uuid_string);
- LLUUID version_id(version_uuid_string);
- LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed,edit_url,count);
- update_marketplace_category(folder_id, false);
- gInventory.notifyObservers();
- it++;
+ LL_INFOS("SLM") << "SLM API : Responder to " << request << ". status : " << status << ", body or description : " << body << LL_ENDL;
}
}
-private:
- LLUUID mExpectedFolderId;
-};
-class LLSLMGetListingResponder : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLSLMGetListingResponder);
-public:
-
- LLSLMGetListingResponder(const LLUUID& folder_id)
- {
- mExpectedFolderId = folder_id;
- }
-
- virtual void completedRaw(const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer)
+ void log_SLM_infos(const std::string& request, const std::string& url, const std::string& body)
{
- LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false);
-
- LLBufferStream istr(channels, buffer.get());
- std::stringstream strstrm;
- strstrm << istr.rdbuf();
- const std::string body = strstrm.str();
-
- if (!isGoodStatus())
- {
- if (getStatus() == 404)
- {
- // That listing does not exist -> delete its record from the local SLM data store
- LLMarketplaceData::instance().deleteListing(mExpectedFolderId, false);
- }
- else
- {
- log_SLM_warning("Get /listing", getStatus(), getReason(), "", body);
- }
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- Json::Value root;
- Json::Reader reader;
- if (!reader.parse(body,root))
- {
- log_SLM_warning("Get /listing", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- log_SLM_infos("Get /listing", getStatus(), body);
-
- // Extract the info from the Json string
- Json::ValueIterator it = root["listings"].begin();
-
- while (it != root["listings"].end())
+ if (gSavedSettings.getBOOL("MarketplaceListingsLogging"))
{
- Json::Value listing = *it;
-
- int listing_id = listing["id"].asInt();
- bool is_listed = listing["is_listed"].asBool();
- std::string edit_url = listing["edit_url"].asString();
- std::string folder_uuid_string = listing["inventory_info"]["listing_folder_id"].asString();
- std::string version_uuid_string = listing["inventory_info"]["version_folder_id"].asString();
- int count = listing["inventory_info"]["count_on_hand"].asInt();
-
- LLUUID folder_id(folder_uuid_string);
- LLUUID version_id(version_uuid_string);
-
- // Update that listing
- LLMarketplaceData::instance().setListingID(folder_id, listing_id, false);
- LLMarketplaceData::instance().setVersionFolderID(folder_id, version_id, false);
- LLMarketplaceData::instance().setActivationState(folder_id, is_listed, false);
- LLMarketplaceData::instance().setListingURL(folder_id, edit_url, false);
- LLMarketplaceData::instance().setCountOnHand(folder_id,count,false);
- update_marketplace_category(folder_id, false);
- gInventory.notifyObservers();
-
- it++;
+ LL_INFOS("SLM") << "SLM API : Sending " << request << ". url : " << url << ", body : " << body << LL_ENDL;
}
}
-private:
- LLUUID mExpectedFolderId;
-};
+}
-class LLSLMUpdateListingsResponder : public LLHTTPClient::Responder
+LLSD getMarketplaceStringSubstitutions()
{
- LOG_CLASS(LLSLMUpdateListingsResponder);
-public:
-
- LLSLMUpdateListingsResponder(const LLUUID& folder_id, bool expected_listed_state, const LLUUID& expected_version_id)
- {
- mExpectedFolderId = folder_id;
- mExpectedListedState = expected_listed_state;
- mExpectedVersionUUID = expected_version_id;
- }
-
- virtual void completedRaw(const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer)
- {
- LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false);
+ std::string marketplace_url = getMarketplaceURL("MarketplaceURL");
+ std::string marketplace_url_create = getMarketplaceURL("MarketplaceURL_CreateStore");
+ std::string marketplace_url_dashboard = getMarketplaceURL("MarketplaceURL_Dashboard");
+ std::string marketplace_url_imports = getMarketplaceURL("MarketplaceURL_Imports");
+ std::string marketplace_url_info = getMarketplaceURL("MarketplaceURL_LearnMore");
- LLBufferStream istr(channels, buffer.get());
- std::stringstream strstrm;
- strstrm << istr.rdbuf();
- const std::string body = strstrm.str();
-
- if (!isGoodStatus())
- {
- log_SLM_warning("Put /listing", getStatus(), getReason(), "", body);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- Json::Value root;
- Json::Reader reader;
- if (!reader.parse(body,root))
- {
- log_SLM_warning("Put /listing", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- log_SLM_infos("Put /listing", getStatus(), body);
+ LLSD marketplace_sub_map;
- // Extract the info from the Json string
- Json::ValueIterator it = root["listings"].begin();
-
- while (it != root["listings"].end())
- {
- Json::Value listing = *it;
-
- int listing_id = listing["id"].asInt();
- bool is_listed = listing["is_listed"].asBool();
- std::string edit_url = listing["edit_url"].asString();
- std::string folder_uuid_string = listing["inventory_info"]["listing_folder_id"].asString();
- std::string version_uuid_string = listing["inventory_info"]["version_folder_id"].asString();
- int count = listing["inventory_info"]["count_on_hand"].asInt();
-
- LLUUID folder_id(folder_uuid_string);
- LLUUID version_id(version_uuid_string);
-
- // Update that listing
- LLMarketplaceData::instance().setListingID(folder_id, listing_id, false);
- LLMarketplaceData::instance().setVersionFolderID(folder_id, version_id, false);
- LLMarketplaceData::instance().setActivationState(folder_id, is_listed, false);
- LLMarketplaceData::instance().setListingURL(folder_id, edit_url, false);
- LLMarketplaceData::instance().setCountOnHand(folder_id,count,false);
- update_marketplace_category(folder_id, false);
- gInventory.notifyObservers();
-
- // Show a notification alert if what we got is not what we expected
- // (this actually doesn't result in an error status from the SLM API protocol)
- if ((mExpectedListedState != is_listed) || (mExpectedVersionUUID != version_id))
- {
- LLSD subs;
- subs["[URL]"] = edit_url;
- LLNotificationsUtil::add("AlertMerchantListingNotUpdated", subs);
- }
-
- it++;
- }
- }
-private:
- LLUUID mExpectedFolderId;
- bool mExpectedListedState;
- LLUUID mExpectedVersionUUID;
-};
+ marketplace_sub_map["[MARKETPLACE_URL]"] = marketplace_url;
+ marketplace_sub_map["[MARKETPLACE_CREATE_STORE_URL]"] = marketplace_url_create;
+ marketplace_sub_map["[MARKETPLACE_LEARN_MORE_URL]"] = marketplace_url_info;
+ marketplace_sub_map["[MARKETPLACE_DASHBOARD_URL]"] = marketplace_url_dashboard;
+ marketplace_sub_map["[MARKETPLACE_IMPORTS_URL]"] = marketplace_url_imports;
-class LLSLMAssociateListingsResponder : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLSLMAssociateListingsResponder);
-public:
-
- LLSLMAssociateListingsResponder(const LLUUID& folder_id, const LLUUID& source_folder_id)
- {
- mExpectedFolderId = folder_id;
- mSourceFolderId = source_folder_id;
- }
-
- virtual void completedRaw(const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer)
- {
- LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false);
- LLMarketplaceData::instance().setUpdating(mSourceFolderId,false);
-
- LLBufferStream istr(channels, buffer.get());
- std::stringstream strstrm;
- strstrm << istr.rdbuf();
- const std::string body = strstrm.str();
-
- if (!isGoodStatus())
- {
- log_SLM_warning("Put /associate_inventory", getStatus(), getReason(), "", body);
- update_marketplace_category(mExpectedFolderId, false);
- update_marketplace_category(mSourceFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- Json::Value root;
- Json::Reader reader;
- if (!reader.parse(body,root))
- {
- log_SLM_warning("Put /associate_inventory", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body);
- update_marketplace_category(mExpectedFolderId, false);
- update_marketplace_category(mSourceFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- log_SLM_infos("Put /associate_inventory", getStatus(), body);
-
- // Extract the info from the Json string
- Json::ValueIterator it = root["listings"].begin();
-
- while (it != root["listings"].end())
- {
- Json::Value listing = *it;
-
- int listing_id = listing["id"].asInt();
- bool is_listed = listing["is_listed"].asBool();
- std::string edit_url = listing["edit_url"].asString();
- std::string folder_uuid_string = listing["inventory_info"]["listing_folder_id"].asString();
- std::string version_uuid_string = listing["inventory_info"]["version_folder_id"].asString();
- int count = listing["inventory_info"]["count_on_hand"].asInt();
-
- LLUUID folder_id(folder_uuid_string);
- LLUUID version_id(version_uuid_string);
-
- // Check that the listing ID is not already associated to some other record
- LLUUID old_listing = LLMarketplaceData::instance().getListingFolder(listing_id);
- if (old_listing.notNull())
- {
- // If it is already used, unlist the old record (we can't have 2 listings with the same listing ID)
- LLMarketplaceData::instance().deleteListing(old_listing);
- }
-
- // Add the new association
- LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed,edit_url,count);
- update_marketplace_category(folder_id, false);
- gInventory.notifyObservers();
-
- // The stock count needs to be updated with the new local count now
- LLMarketplaceData::instance().updateCountOnHand(folder_id,1);
-
- it++;
- }
-
- // Always update the source folder so its widget updates
- update_marketplace_category(mSourceFolderId, false);
- }
-private:
- LLUUID mExpectedFolderId; // This is the folder now associated with the id.
- LLUUID mSourceFolderId; // This is the folder initially associated with the id. Can be LLUUI::null
-};
+ return marketplace_sub_map;
+}
-class LLSLMDeleteListingsResponder : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLSLMDeleteListingsResponder);
-public:
-
- LLSLMDeleteListingsResponder(const LLUUID& folder_id)
- {
- mExpectedFolderId = folder_id;
- }
-
- virtual void completedRaw(const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer)
- {
- LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false);
-
- LLBufferStream istr(channels, buffer.get());
- std::stringstream strstrm;
- strstrm << istr.rdbuf();
- const std::string body = strstrm.str();
-
- if (!isGoodStatus())
- {
- log_SLM_warning("Delete /listing", getStatus(), getReason(), "", body);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- Json::Value root;
- Json::Reader reader;
- if (!reader.parse(body,root))
- {
- log_SLM_warning("Delete /listing", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body);
- update_marketplace_category(mExpectedFolderId, false);
- gInventory.notifyObservers();
- return;
- }
-
- log_SLM_infos("Delete /listing", getStatus(), body);
-
- // Extract the info from the Json string
- Json::ValueIterator it = root["listings"].begin();
-
- while (it != root["listings"].end())
- {
- Json::Value listing = *it;
-
- int listing_id = listing["id"].asInt();
- LLUUID folder_id = LLMarketplaceData::instance().getListingFolder(listing_id);
- LLMarketplaceData::instance().deleteListing(folder_id);
-
- it++;
- }
- }
-private:
- LLUUID mExpectedFolderId;
-};
// SLM Responders End
///////////////////////////////////////////////////////////////////////////////
+#if 1
namespace LLMarketplaceImport
{
// Basic interface for this namespace
@@ -671,13 +191,8 @@ namespace LLMarketplaceImport
static S32 sImportResultStatus = 0;
static LLSD sImportResults = LLSD::emptyMap();
-#if 0
- static LLTimer slmGetTimer;
- static LLTimer slmPostTimer;
-#endif
// Responders
-#if 1
void marketplacePostCoro(std::string url)
{
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
@@ -739,56 +254,6 @@ namespace LLMarketplaceImport
}
-
-#else
- class LLImportPostResponder : public LLHTTPClient::Responder
- {
- LOG_CLASS(LLImportPostResponder);
- public:
- LLImportPostResponder() : LLCurl::Responder() {}
-
- protected:
- /* virtual */ void httpCompleted()
- {
- slmPostTimer.stop();
-
- if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
- {
- LL_INFOS() << " SLM [timer:" << slmPostTimer.getElapsedTimeF32() << "] "
- << dumpResponse() << LL_ENDL;
- }
-
- S32 status = getStatus();
- if ((status == MarketplaceErrorCodes::IMPORT_REDIRECT) ||
- (status == MarketplaceErrorCodes::IMPORT_AUTHENTICATION_ERROR) ||
- // MAINT-2301 : we determined we can safely ignore that error in that context
- (status == MarketplaceErrorCodes::IMPORT_JOB_TIMEOUT))
- {
- if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
- {
- LL_INFOS() << " SLM POST : Ignoring time out status and treating it as success" << LL_ENDL;
- }
- status = MarketplaceErrorCodes::IMPORT_DONE;
- }
-
- if (status >= MarketplaceErrorCodes::IMPORT_BAD_REQUEST)
- {
- if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
- {
- LL_INFOS() << " SLM POST : Clearing marketplace cookie due to client or server error" << LL_ENDL;
- }
- sMarketplaceCookie.clear();
- }
-
- sImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE);
- sImportPostPending = false;
- sImportResultStatus = status;
- sImportId = getContent();
- }
- };
-#endif
-
-#if 1
void marketplaceGetCoro(std::string url, bool buildHeaders)
{
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
@@ -854,57 +319,6 @@ namespace LLMarketplaceImport
}
-#else
- class LLImportGetResponder : public LLHTTPClient::Responder
- {
- LOG_CLASS(LLImportGetResponder);
- public:
- LLImportGetResponder() : LLCurl::Responder() {}
-
- protected:
- /* virtual */ void httpCompleted()
- {
- const std::string& set_cookie_string = getResponseHeader(HTTP_IN_HEADER_SET_COOKIE);
-
- if (!set_cookie_string.empty())
- {
- sMarketplaceCookie = set_cookie_string;
- }
-
- slmGetTimer.stop();
-
- if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
- {
- LL_INFOS() << " SLM [timer:" << slmGetTimer.getElapsedTimeF32() << "] "
- << dumpResponse() << LL_ENDL;
- }
-
- // MAINT-2452 : Do not clear the cookie on IMPORT_DONE_WITH_ERRORS : Happens when trying to import objects with wrong permissions
- // ACME-1221 : Do not clear the cookie on IMPORT_NOT_FOUND : Happens for newly created Merchant accounts that are initially empty
- S32 status = getStatus();
- if ((status >= MarketplaceErrorCodes::IMPORT_BAD_REQUEST) &&
- (status != MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) &&
- (status != MarketplaceErrorCodes::IMPORT_NOT_FOUND))
- {
- if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
- {
- LL_INFOS() << " SLM GET clearing marketplace cookie due to client or server error" << LL_ENDL;
- }
- sMarketplaceCookie.clear();
- }
- else if (gSavedSettings.getBOOL("InventoryOutboxLogging") && (status >= MarketplaceErrorCodes::IMPORT_BAD_REQUEST))
- {
- LL_INFOS() << " SLM GET : Got error status = " << status << ", but marketplace cookie not cleared." << LL_ENDL;
- }
-
- sImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING);
- sImportGetPending = false;
- sImportResultStatus = status;
- sImportResults = getContent();
- }
- };
-#endif
-
// Basic API
bool hasSessionCookie()
@@ -955,24 +369,9 @@ namespace LLMarketplaceImport
std::string url = getInventoryImportURL();
-#if 1
LLCoros::instance().launch("marketplaceGetCoro",
boost::bind(&marketplaceGetCoro, url, false));
-#else
- if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
- {
- LL_INFOS() << " SLM GET: establishMarketplaceSessionCookie, LLHTTPClient::get, url = " << url << LL_ENDL;
- LLSD headers = LLViewerMedia::getHeaders();
- std::stringstream str;
- LLSDSerialize::toPrettyXML(headers, str);
- LL_INFOS() << " SLM GET: headers " << LL_ENDL;
- LL_INFOS() << str.str() << LL_ENDL;
- }
-
- slmGetTimer.start();
- LLHTTPClient::get(url, new LLImportGetResponder(), LLViewerMedia::getHeaders());
-#endif
return true;
}
@@ -989,31 +388,9 @@ namespace LLMarketplaceImport
url += sImportId.asString();
-#if 1
LLCoros::instance().launch("marketplaceGetCoro",
boost::bind(&marketplaceGetCoro, url, true));
-#else
- // Make the headers for the post
- LLSD headers = LLSD::emptyMap();
- headers[HTTP_OUT_HEADER_ACCEPT] = "*/*";
- headers[HTTP_OUT_HEADER_COOKIE] = sMarketplaceCookie;
- // *TODO: Why are we setting Content-Type for a GET request?
- headers[HTTP_OUT_HEADER_CONTENT_TYPE] = HTTP_CONTENT_LLSD_XML;
- headers[HTTP_OUT_HEADER_USER_AGENT] = LLViewerMedia::getCurrentUserAgent();
-
- if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
- {
- LL_INFOS() << " SLM GET: pollStatus, LLHTTPClient::get, url = " << url << LL_ENDL;
- std::stringstream str;
- LLSDSerialize::toPrettyXML(headers, str);
- LL_INFOS() << " SLM GET: headers " << LL_ENDL;
- LL_INFOS() << str.str() << LL_ENDL;
- }
-
- slmGetTimer.start();
- LLHTTPClient::get(url, new LLImportGetResponder(), headers);
-#endif
return true;
}
@@ -1032,35 +409,13 @@ namespace LLMarketplaceImport
std::string url = getInventoryImportURL();
-#if 1
LLCoros::instance().launch("marketplacePostCoro",
boost::bind(&marketplacePostCoro, url));
-#else
- // Make the headers for the post
- LLSD headers = LLSD::emptyMap();
- headers[HTTP_OUT_HEADER_ACCEPT] = "*/*";
- headers[HTTP_OUT_HEADER_CONNECTION] = "Keep-Alive";
- headers[HTTP_OUT_HEADER_COOKIE] = sMarketplaceCookie;
- headers[HTTP_OUT_HEADER_CONTENT_TYPE] = HTTP_CONTENT_XML;
- headers[HTTP_OUT_HEADER_USER_AGENT] = LLViewerMedia::getCurrentUserAgent();
-
- if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
- {
- LL_INFOS() << " SLM POST: triggerImport, LLHTTPClient::post, url = " << url << LL_ENDL;
- std::stringstream str;
- LLSDSerialize::toPrettyXML(headers, str);
- LL_INFOS() << " SLM POST: headers " << LL_ENDL;
- LL_INFOS() << str.str() << LL_ENDL;
- }
-
- slmPostTimer.start();
- LLHTTPClient::post(url, LLSD(), new LLImportPostResponder(), headers);
-#endif
return true;
}
}
-
+#endif
//
// Interface class
@@ -1377,15 +732,60 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type&
}
else
{
- // Initiate SLM connection and set responder
- std::string url = getSLMConnectURL("/merchant");
- if (url != "")
+ mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING;
+
+ LLCoros::instance().launch("getMerchantStatus",
+ boost::bind(&LLMarketplaceData::getMerchantStatusCoro, this));
+ }
+}
+
+void LLMarketplaceData::getMerchantStatusCoro()
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getMerchantStatusCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
+
+ httpOpts->setFollowRedirects(true);
+
+ std::string url = getSLMConnectURL("/merchant");
+ if (url.empty())
+ {
+ LL_INFOS("Marketplace") << "No marketplace capability on Sim" << LL_ENDL;
+ }
+
+ LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ S32 httpCode = status.getType();
+
+ if (httpCode == HTTP_NOT_FOUND)
{
- mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING;
- log_SLM_infos("LLHTTPClient::get", url, "");
- LLHTTPClient::get(url, new LLSLMGetMerchantResponder(), LLSD());
+ log_SLM_infos("Get /merchant", httpCode, "User is not a merchant");
+ setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT);
}
+ else if (httpCode == HTTP_SERVICE_UNAVAILABLE)
+ {
+ log_SLM_infos("Get /merchant", httpCode, "Merchant is not migrated");
+ setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MIGRATED_MERCHANT);
+ }
+ else
+ {
+ std::string err_code = result["error_code"].asString();
+ std::string err_description = result["error_description"].asString();
+ log_SLM_warning("Get /merchant", httpCode, status.toString(), err_code, err_description);
+ setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_CONNECTION_FAILURE);
+ }
+ return;
}
+
+ log_SLM_infos("Get /merchant", status.getType(), "User is a merchant");
+ setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT);
}
void LLMarketplaceData::setDataFetchedSignal(const status_updated_signal_t::slot_type& cb)
@@ -1400,151 +800,434 @@ void LLMarketplaceData::setDataFetchedSignal(const status_updated_signal_t::slot
// Get/Post/Put requests to the SLM Server using the SLM API
void LLMarketplaceData::getSLMListings()
{
- LLSD headers = LLSD::emptyMap();
- headers["Accept"] = "application/json";
- headers["Content-Type"] = "application/json";
-
- // Send request
+ const LLUUID marketplaceFolderId = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
+ setUpdating(marketplaceFolderId, true);
+
+ LLCoros::instance().launch("getSLMListings",
+ boost::bind(&LLMarketplaceData::getSLMListingsCoro, this, marketplaceFolderId));
+}
+
+void LLMarketplaceData::getSLMListingsCoro(LLUUID folderId)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getMerchantStatusCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
+
+ httpHeaders->append("Accept", "application/json");
+ httpHeaders->append("Content-Type", "application/json");
+
std::string url = getSLMConnectURL("/listings");
- log_SLM_infos("LLHTTPClient::get", url, "");
- const LLUUID marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false);
- setUpdating(marketplacelistings_id,true);
- LLHTTPClient::get(url, new LLSLMGetListingsResponder(marketplacelistings_id), headers);
+
+ LLSD result = httpAdapter->getJsonAndYield(httpRequest, url, httpHeaders);
+
+ setUpdating(folderId, false);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ log_SLM_warning("Get /listings", status.getType(), status.toString(), "", ll_pretty_print_sd(result));
+ setSLMDataFetched(MarketplaceFetchCodes::MARKET_FETCH_FAILED);
+ update_marketplace_category(folderId, false);
+ gInventory.notifyObservers();
+ return;
+ }
+
+ log_SLM_infos("Get /listings", static_cast<U32>(status.getType()), ll_pretty_print_sd(result));
+
+ // Extract the info from the results
+ for (LLSD::array_iterator it = result["listings"].beginArray();
+ it != result["listings"].endArray(); ++it)
+ {
+ LLSD listing = *it;
+
+ int listingId = listing["id"].asInteger();
+ bool isListed = listing["is_listed"].asBoolean();
+ std::string editUrl = listing["edit_url"].asString();
+ LLUUID folderUuid = listing["inventory_info"]["listing_folder_id"].asUUID();
+ LLUUID versionUuid = listing["inventory_info"]["version_folder_id"].asUUID();
+ int count = listing["inventory_info"]["count_on_hand"].asInteger();
+
+ if (folderUuid.notNull())
+ {
+ addListing(folderUuid, listingId, versionUuid, isListed, editUrl, count);
+ }
+ }
+
+ // Update all folders under the root
+ setSLMDataFetched(MarketplaceFetchCodes::MARKET_FETCH_DONE);
+ update_marketplace_category(folderId, false);
+ gInventory.notifyObservers();
}
-void LLMarketplaceData::getSLMListing(S32 listing_id)
+void LLMarketplaceData::getSLMListing(S32 listingId)
{
- LLSD headers = LLSD::emptyMap();
- headers["Accept"] = "application/json";
- headers["Content-Type"] = "application/json";
-
- // Send request
- std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id);
- log_SLM_infos("LLHTTPClient::get", url, "");
- LLUUID folder_id = LLMarketplaceData::instance().getListingFolder(listing_id);
- setUpdating(folder_id,true);
- LLHTTPClient::get(url, new LLSLMGetListingResponder(folder_id), headers);
+ LLUUID folderId = getListingFolder(listingId);
+ setUpdating(folderId, true);
+
+ LLCoros::instance().launch("getSingleListingCoro",
+ boost::bind(&LLMarketplaceData::getSingleListingCoro, this, listingId, folderId));
+}
+
+void LLMarketplaceData::getSingleListingCoro(S32 listingId, LLUUID folderId)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getMerchantStatusCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
+
+ httpHeaders->append("Accept", "application/json");
+ httpHeaders->append("Content-Type", "application/json");
+
+ std::string url = getSLMConnectURL("/listing/") + llformat("%d", listingId);
+
+ LLSD result = httpAdapter->getJsonAndYield(httpRequest, url, httpHeaders);
+
+ setUpdating(folderId, false);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ if (status.getType() == HTTP_NOT_FOUND)
+ {
+ // That listing does not exist -> delete its record from the local SLM data store
+ deleteListing(folderId, false);
+ }
+ else
+ {
+ log_SLM_warning("Get /listing", status.getType(), status.toString(), "", ll_pretty_print_sd(result));
+ }
+
+ update_marketplace_category(folderId, false);
+ gInventory.notifyObservers();
+ return;
+ }
+
+ log_SLM_infos("Get /listings", static_cast<U32>(status.getType()), ll_pretty_print_sd(result));
+
+
+ // Extract the info from the results
+ for (LLSD::array_iterator it = result["listings"].beginArray();
+ it != result["listings"].endArray(); ++it)
+ {
+ LLSD listing = *it;
+
+ int resListingId = listing["id"].asInteger();
+ bool isListed = listing["is_listed"].asBoolean();
+ std::string editUrl = listing["edit_url"].asString();
+ LLUUID folderUuid = listing["inventory_info"]["listing_folder_id"].asUUID();
+ LLUUID versionUuid = listing["inventory_info"]["version_folder_id"].asUUID();
+ int count = listing["inventory_info"]["count_on_hand"].asInteger();
+
+ // Update that listing
+ setListingID(folderUuid, resListingId, false);
+ setVersionFolderID(folderUuid, versionUuid, false);
+ setActivationState(folderUuid, isListed, false);
+ setListingURL(folderUuid, editUrl, false);
+ setCountOnHand(folderUuid, count, false);
+ update_marketplace_category(folderUuid, false);
+ gInventory.notifyObservers();
+ }
}
void LLMarketplaceData::createSLMListing(const LLUUID& folder_id, const LLUUID& version_id, S32 count)
{
- LLSD headers = LLSD::emptyMap();
- headers["Accept"] = "application/json";
- headers["Content-Type"] = "application/json";
-
- // Build the json message
- Json::Value root;
- Json::FastWriter writer;
-
- LLViewerInventoryCategory* category = gInventory.getCategory(folder_id);
- root["listing"]["name"] = category->getName();
- root["listing"]["inventory_info"]["listing_folder_id"] = folder_id.asString();
- root["listing"]["inventory_info"]["version_folder_id"] = version_id.asString();
- root["listing"]["inventory_info"]["count_on_hand"] = count;
-
- std::string json_str = writer.write(root);
-
- // postRaw() takes ownership of the buffer and releases it later.
- size_t size = json_str.size();
- U8 *data = new U8[size];
- memcpy(data, (U8*)(json_str.c_str()), size);
-
- // Send request
- std::string url = getSLMConnectURL("/listings");
- log_SLM_infos("LLHTTPClient::postRaw", url, json_str);
- setUpdating(folder_id,true);
- LLHTTPClient::postRaw(url, data, size, new LLSLMCreateListingsResponder(folder_id), headers);
+ setUpdating(folder_id, true);
+ LLCoros::instance().launch("createSLMListingCoro",
+ boost::bind(&LLMarketplaceData::createSLMListingCoro, this, folder_id, version_id, count));
}
-void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed, S32 count)
+void LLMarketplaceData::createSLMListingCoro(LLUUID folderId, LLUUID versionId, S32 count)
{
- LLSD headers = LLSD::emptyMap();
- headers["Accept"] = "application/json";
- headers["Content-Type"] = "application/json";
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getMerchantStatusCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
+
+ httpHeaders->append("Accept", "application/json");
+ httpHeaders->append("Content-Type", "application/json");
+
+ LLViewerInventoryCategory* category = gInventory.getCategory(folderId);
+ LLSD invInfo;
+ invInfo["listing_folder_id"] = folderId;
+ invInfo["version_folder_id"] = versionId;
+ invInfo["count_on_hand"] = count;
+ LLSD listing;
+ listing["name"] = category->getName();
+ listing["inventory_info"] = invInfo;
+ LLSD postData;
+ postData["listing"] = listing;
+
+ std::string url = getSLMConnectURL("/listings");
+
+ LLSD result = httpAdapter->postJsonAndYield(httpRequest, url, postData, httpHeaders);
- Json::Value root;
- Json::FastWriter writer;
+ setUpdating(folderId, false);
- // Note : auto unlist if the count is 0 (out of stock)
- if (is_listed && (count == 0))
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
{
- is_listed = false;
- LLNotificationsUtil::add("AlertMerchantStockFolderEmpty");
+ log_SLM_warning("Post /listings", status.getType(), status.toString(), "", ll_pretty_print_sd(result));
+ update_marketplace_category(folderId, false);
+ gInventory.notifyObservers();
+ return;
}
- // Note : we're assuming that sending unchanged info won't break anything server side...
- root["listing"]["id"] = listing_id;
- root["listing"]["is_listed"] = is_listed;
- root["listing"]["inventory_info"]["listing_folder_id"] = folder_id.asString();
- root["listing"]["inventory_info"]["version_folder_id"] = version_id.asString();
- root["listing"]["inventory_info"]["count_on_hand"] = count;
-
- std::string json_str = writer.write(root);
-
- // postRaw() takes ownership of the buffer and releases it later.
- size_t size = json_str.size();
- U8 *data = new U8[size];
- memcpy(data, (U8*)(json_str.c_str()), size);
+ log_SLM_infos("Post /listings", status.getType(), ll_pretty_print_sd(result));
+
+ // Extract the info from the results
+ for (LLSD::array_iterator it = result["listings"].beginArray();
+ it != result["listings"].endArray(); ++it)
+ {
+ LLSD listing = *it;
+
+ int listingId = listing["id"].asInteger();
+ bool isListed = listing["is_listed"].asBoolean();
+ std::string editUrl = listing["edit_url"].asString();
+ LLUUID folderUuid = listing["inventory_info"]["listing_folder_id"].asUUID();
+ LLUUID versionUuid = listing["inventory_info"]["version_folder_id"].asUUID();
+ int count = listing["inventory_info"]["count_on_hand"].asInteger();
+
+ addListing(folderUuid, listingId, versionUuid, isListed, editUrl, count);
+ update_marketplace_category(folderUuid, false);
+ gInventory.notifyObservers();
+ }
+
+}
+
+void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed, S32 count)
+{
+ setUpdating(folder_id, true);
+ LLCoros::instance().launch("updateSLMListingCoro",
+ boost::bind(&LLMarketplaceData::updateSLMListingCoro, this, folder_id, listing_id, version_id, is_listed, count));
+}
+
+void LLMarketplaceData::updateSLMListingCoro(LLUUID folderId, S32 listingId, LLUUID versionId, bool isListed, S32 count)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getMerchantStatusCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
+
+ httpHeaders->append("Accept", "application/json");
+ httpHeaders->append("Content-Type", "application/json");
- // Send request
- std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id);
- log_SLM_infos("LLHTTPClient::putRaw", url, json_str);
- setUpdating(folder_id,true);
- LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(folder_id, is_listed, version_id), headers);
+ LLSD invInfo;
+ invInfo["listing_folder_id"] = folderId;
+ invInfo["version_folder_id"] = versionId;
+ invInfo["count_on_hand"] = count;
+ LLSD listing;
+ listing["inventory_info"] = invInfo;
+ listing["id"] = listingId;
+ listing["is_listed"] = isListed;
+ LLSD postData;
+ postData["listing"] = listing;
+
+ std::string url = getSLMConnectURL("/listing/") + llformat("%d", listingId);
+ LLSD result = httpAdapter->putJsonAndYield(httpRequest, url, postData, httpHeaders);
+
+ setUpdating(folderId, false);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ log_SLM_warning("Put /listing", status.getType(), status.toString(), "", ll_pretty_print_sd(result));
+ update_marketplace_category(folderId, false);
+ gInventory.notifyObservers();
+ return;
+ }
+
+ log_SLM_infos("Put /listing", status.getType(), ll_pretty_print_sd(result));
+
+ // Extract the info from the Json string
+ for (LLSD::array_iterator it = result["listings"].beginArray();
+ it != result["listings"].endArray(); ++it)
+ {
+ LLSD listing = *it;
+
+ int listing_id = listing["id"].asInteger();
+ bool is_listed = listing["is_listed"].asBoolean();
+ std::string edit_url = listing["edit_url"].asString();
+ LLUUID folderUuid = listing["inventory_info"]["listing_folder_id"].asUUID();
+ LLUUID versionUuid = listing["inventory_info"]["version_folder_id"].asUUID();
+ int onHand = listing["inventory_info"]["count_on_hand"].asInteger();
+
+ // Update that listing
+ setListingID(folderUuid, listing_id, false);
+ setVersionFolderID(folderUuid, versionUuid, false);
+ setActivationState(folderUuid, is_listed, false);
+ setListingURL(folderUuid, edit_url, false);
+ setCountOnHand(folderUuid, onHand, false);
+ update_marketplace_category(folderUuid, false);
+ gInventory.notifyObservers();
+
+ // Show a notification alert if what we got is not what we expected
+ // (this actually doesn't result in an error status from the SLM API protocol)
+ if ((isListed != is_listed) || (versionId != versionUuid))
+ {
+ LLSD subs;
+ subs["[URL]"] = edit_url;
+ LLNotificationsUtil::add("AlertMerchantListingNotUpdated", subs);
+ }
+ }
+
}
void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, const LLUUID& source_folder_id)
{
- LLSD headers = LLSD::emptyMap();
- headers["Accept"] = "application/json";
- headers["Content-Type"] = "application/json";
-
- Json::Value root;
- Json::FastWriter writer;
-
- // Note : we're assuming that sending unchanged info won't break anything server side...
- root["listing"]["id"] = listing_id;
- root["listing"]["inventory_info"]["listing_folder_id"] = folder_id.asString();
- root["listing"]["inventory_info"]["version_folder_id"] = version_id.asString();
-
- std::string json_str = writer.write(root);
-
- // postRaw() takes ownership of the buffer and releases it later.
- size_t size = json_str.size();
- U8 *data = new U8[size];
- memcpy(data, (U8*)(json_str.c_str()), size);
-
- // Send request
- std::string url = getSLMConnectURL("/associate_inventory/") + llformat("%d",listing_id);
- log_SLM_infos("LLHTTPClient::putRaw", url, json_str);
- setUpdating(folder_id,true);
- setUpdating(source_folder_id,true);
- LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(folder_id,source_folder_id), headers);
+ setUpdating(folder_id, true);
+ setUpdating(source_folder_id, true);
+ LLCoros::instance().launch("associateSLMListingCoro",
+ boost::bind(&LLMarketplaceData::associateSLMListingCoro, this, folder_id, listing_id, version_id, source_folder_id));
}
-void LLMarketplaceData::deleteSLMListing(S32 listing_id)
+void LLMarketplaceData::associateSLMListingCoro(LLUUID folderId, S32 listingId, LLUUID versionId, LLUUID sourceFolderId)
{
- LLSD headers = LLSD::emptyMap();
- headers["Accept"] = "application/json";
- headers["Content-Type"] = "application/json";
-
- // Send request
- std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id);
- log_SLM_infos("LLHTTPClient::del", url, "");
- LLUUID folder_id = LLMarketplaceData::instance().getListingFolder(listing_id);
- setUpdating(folder_id,true);
- LLHTTPClient::del(url, new LLSLMDeleteListingsResponder(folder_id), headers);
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getMerchantStatusCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
+
+ httpHeaders->append("Accept", "application/json");
+ httpHeaders->append("Content-Type", "application/json");
+
+ LLSD invInfo;
+ invInfo["listing_folder_id"] = folderId;
+ invInfo["version_folder_id"] = versionId;
+ LLSD listing;
+ listing["id"] = listingId;
+ listing["inventory_info"] = invInfo;
+ LLSD postData;
+ postData["listing"] = listing;
+
+ // Send request
+ std::string url = getSLMConnectURL("/associate_inventory/") + llformat("%d", listingId);
+
+ LLSD result = httpAdapter->putJsonAndYield(httpRequest, url, postData, httpHeaders);
+
+ setUpdating(folderId, false);
+ setUpdating(sourceFolderId, false);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ log_SLM_warning("Put /associate_inventory", status.getType(), status.toString(), "", ll_pretty_print_sd(result));
+ update_marketplace_category(folderId, false);
+ update_marketplace_category(sourceFolderId, false);
+ gInventory.notifyObservers();
+ return;
+ }
+
+ log_SLM_infos("Put /associate_inventory", status.getType(), ll_pretty_print_sd(result));
+
+ for (LLSD::array_iterator it = result["listings"].beginArray();
+ it != result["listings"].endArray(); ++it)
+ {
+ LLSD listing = *it;
+
+ int listing_id = listing["id"].asInteger();
+ bool is_listed = listing["is_listed"].asBoolean();
+ std::string edit_url = listing["edit_url"].asString();
+ LLUUID folder_uuid = listing["inventory_info"]["listing_folder_id"].asUUID();
+ LLUUID version_uuid = listing["inventory_info"]["version_folder_id"].asUUID();
+ int count = listing["inventory_info"]["count_on_hand"].asInteger();
+
+ // Check that the listing ID is not already associated to some other record
+ LLUUID old_listing = LLMarketplaceData::instance().getListingFolder(listing_id);
+ if (old_listing.notNull())
+ {
+ // If it is already used, unlist the old record (we can't have 2 listings with the same listing ID)
+ deleteListing(old_listing);
+ }
+
+ // Add the new association
+ addListing(folder_uuid, listing_id, version_uuid, is_listed, edit_url, count);
+ update_marketplace_category(folder_uuid, false);
+ gInventory.notifyObservers();
+
+ // The stock count needs to be updated with the new local count now
+ updateCountOnHand(folder_uuid, 1);
+ }
+
+ // Always update the source folder so its widget updates
+ update_marketplace_category(sourceFolderId, false);
+}
+
+void LLMarketplaceData::deleteSLMListing(S32 listingId)
+{
+ LLCoros::instance().launch("deleteSLMListingCoro",
+ boost::bind(&LLMarketplaceData::deleteSLMListingCoro, this, listingId));
+}
+
+void LLMarketplaceData::deleteSLMListingCoro(S32 listingId)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getMerchantStatusCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
+
+ httpHeaders->append("Accept", "application/json");
+ httpHeaders->append("Content-Type", "application/json");
+
+ std::string url = getSLMConnectURL("/listing/") + llformat("%d", listingId);
+ LLUUID folderId = getListingFolder(listingId);
+
+ setUpdating(folderId, true);
+
+ LLSD result = httpAdapter->deleteJsonAndYield(httpRequest, url, httpHeaders);
+
+ setUpdating(folderId, false);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ log_SLM_warning("Delete /listing", status.getType(), status.toString(), "", ll_pretty_print_sd(result));
+ update_marketplace_category(folderId, false);
+ gInventory.notifyObservers();
+ return;
+ }
+
+ log_SLM_infos("Delete /listing", status.getType(), ll_pretty_print_sd(result));
+
+ for (LLSD::array_iterator it = result["listings"].beginArray();
+ it != result["listings"].endArray(); ++it)
+ {
+ LLSD listing = *it;
+
+ int listing_id = listing["id"].asInteger();
+ LLUUID folder_id = LLMarketplaceData::instance().getListingFolder(listing_id);
+ deleteListing(folder_id);
+ }
+
}
std::string LLMarketplaceData::getSLMConnectURL(const std::string& route)
{
- std::string url("");
+ std::string url;
LLViewerRegion *regionp = gAgent.getRegion();
if (regionp)
{
// Get DirectDelivery cap
url = regionp->getCapability("DirectDelivery");
- if (url != "")
+ if (!url.empty())
{
url += route;
}
@@ -2133,5 +1816,3 @@ bool LLMarketplaceData::setListingURL(const LLUUID& folder_id, const std::string
return true;
}
-
-
diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h
index f8e7ed4364..f9e2ac98d0 100755
--- a/indra/newview/llmarketplacefunctions.h
+++ b/indra/newview/llmarketplacefunctions.h
@@ -261,6 +261,14 @@ private:
void deleteSLMListing(S32 listing_id);
std::string getSLMConnectURL(const std::string& route);
+ void getMerchantStatusCoro();
+ void getSLMListingsCoro(LLUUID folderId);
+ void getSingleListingCoro(S32 listingId, LLUUID folderId);
+ void createSLMListingCoro(LLUUID folderId, LLUUID versionId, S32 count);
+ void updateSLMListingCoro(LLUUID folderId, S32 listingId, LLUUID versionId, bool isListed, S32 count);
+ void associateSLMListingCoro(LLUUID folderId, S32 listingId, LLUUID versionId, LLUUID sourceFolderId);
+ void deleteSLMListingCoro(S32 listingId);
+
// Handling Marketplace connection and inventory connection
U32 mMarketPlaceStatus;
status_updated_signal_t* mStatusUpdatedSignal;
diff --git a/indra/newview/lltexturestats.cpp b/indra/newview/lltexturestats.cpp
index ca42d710f8..8ded148e17 100755
--- a/indra/newview/lltexturestats.cpp
+++ b/indra/newview/lltexturestats.cpp
@@ -30,8 +30,8 @@
#include "llagent.h"
#include "lltexturefetch.h"
#include "lltexturestats.h"
-#include "lltexturestatsuploader.h"
#include "llviewerregion.h"
+#include "llcorehttputil.h"
void send_texture_stats_to_sim(const LLSD &texture_stats)
{
@@ -49,6 +49,16 @@ void send_texture_stats_to_sim(const LLSD &texture_stats)
std::string texture_cap_url = gAgent.getRegion()->getCapability("TextureStats");
LL_INFOS() << "uploading texture stats data to simulator" << LL_ENDL;
- LLTextureStatsUploader::uploadStatsToSimulator(texture_cap_url, texture_stats);
+
+ if (texture_cap_url != "")
+ {
+ LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(texture_cap_url, texture_stats,
+ "Texture statistics posted to sim.", "Error posting texture statistics to sim");
+ }
+ else
+ {
+ LL_INFOS() << "Not sending texture stats: " << texture_stats
+ << " as there is no cap url." << LL_ENDL;
+ }
}
diff --git a/indra/newview/lltexturestatsuploader.cpp b/indra/newview/lltexturestatsuploader.cpp
deleted file mode 100755
index c4809bc8e7..0000000000
--- a/indra/newview/lltexturestatsuploader.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * @file lltexturerstats.cpp
- * @brief texture stats upload class
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "lltexturestatsuploader.h"
-
-#include "llhttpclient.h"
-
-
-// static
-void LLTextureStatsUploader::uploadStatsToSimulator(const std::string texture_cap_url, const LLSD &texture_stats)
-{
- if ( texture_cap_url != "" )
- {
- LLHTTPClient::post(texture_cap_url, texture_stats, NULL);
- }
- else
- {
- LL_INFOS() << "Not sending texture stats: "
- << texture_stats
- << " as there is no cap url."
- << LL_ENDL;
- }
-}
-
diff --git a/indra/newview/lltexturestatsuploader.h b/indra/newview/lltexturestatsuploader.h
deleted file mode 100755
index ac268c2516..0000000000
--- a/indra/newview/lltexturestatsuploader.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * @file lltexturestatsuploader.h
- * @brief Class to send the texture stats to the simulatore
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLTEXTURESTATSUPLOADER_H
-#define LL_LLTEXTURESTATSUPLOADER_H
-
-#include "llappviewer.h"
-
-// utility functions to capture data on texture download speeds and send to simulator periodically
-
-class LLTextureStatsUploader
-{
-public:
- static void uploadStatsToSimulator(const std::string texture_cap_url, const LLSD &texture_stats);
-};
-
-#endif // LL_LLTEXTURESTATSUPLOADER_H
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index ea8fc07e8a..0643f7b1e3 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -120,6 +120,8 @@
#include "llnotificationmanager.h" //
#include "llexperiencecache.h"
+#include "llexperiencecache.h"
+
#if LL_MSVC
// disable boost::lexical_cast warning
#pragma warning (disable:4702)
@@ -6468,17 +6470,14 @@ bool script_question_cb(const LLSD& notification, const LLSD& response)
if (!region)
return false;
- std::string lookup_url=region->getCapability("ExperiencePreferences");
- if(lookup_url.empty())
- return false;
- LLSD permission;
- LLSD data;
- permission["permission"]="Block";
-
- data[experience.asString()]=permission;
- LLHTTPClient::put(lookup_url, data, NULL);
- data["experience"]=experience;
- LLEventPumps::instance().obtain("experience_permission").post(data);
+ LLExperienceCache::instance().setExperiencePermission(experience, std::string("Block"), LLExperienceCache::ExperienceGetFn_t());
+
+ LLSD permission;
+ LLSD data;
+ permission["permission"] = "Block";
+ data[experience.asString()] = permission;
+ data["experience"] = experience;
+ LLEventPumps::instance().obtain("experience_permission").post(data);
}
}
return false;