Use proper json for Marketplace functions
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
#include "llinventoryfunctions.h"
|
#include "llinventoryfunctions.h"
|
||||||
#include "llinventoryobserver.h"
|
#include "llinventoryobserver.h"
|
||||||
#include "llnotificationsutil.h"
|
#include "llnotificationsutil.h"
|
||||||
#include "llsdserialize.h"
|
#include "llsdjson.h"
|
||||||
#include "lltimer.h"
|
#include "lltimer.h"
|
||||||
#include "lltrans.h"
|
#include "lltrans.h"
|
||||||
#include "llviewercontrol.h"
|
#include "llviewercontrol.h"
|
||||||
@@ -264,19 +264,11 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istringstream strstrm(body);
|
|
||||||
LLSD result;
|
|
||||||
if (LLSDSerialize::fromNotation(result, strstrm, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
|
|
||||||
{
|
|
||||||
log_SLM_warning("Get /listings", getStatus(), "Json parsing failed", LLStringUtil::null, body);
|
|
||||||
LLMarketplaceData::instance().setSLMDataFetched(MarketplaceFetchCodes::MARKET_FETCH_FAILED);
|
|
||||||
update_marketplace_category(folderId, false);
|
|
||||||
gInventory.notifyObservers();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_SLM_infos("Get /listings", getStatus(), body);
|
log_SLM_infos("Get /listings", getStatus(), body);
|
||||||
|
|
||||||
|
auto json = nlohmann::json::parse(body);
|
||||||
|
LLSD result = LlsdFromJson(json);;
|
||||||
|
|
||||||
// Extract the info from the results
|
// Extract the info from the results
|
||||||
for (LLSD::array_iterator it = result["listings"].beginArray();
|
for (LLSD::array_iterator it = result["listings"].beginArray();
|
||||||
it != result["listings"].endArray(); ++it)
|
it != result["listings"].endArray(); ++it)
|
||||||
@@ -336,17 +328,11 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLSD result;
|
|
||||||
if (LLSDSerialize::fromNotation(result, strstrm, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
|
|
||||||
{
|
|
||||||
log_SLM_warning("Post /listings", getStatus(), "Json parsing failed", LLStringUtil::null, body);
|
|
||||||
update_marketplace_category(folderId, false);
|
|
||||||
gInventory.notifyObservers();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_SLM_infos("Post /listings", getStatus(), body);
|
log_SLM_infos("Post /listings", getStatus(), body);
|
||||||
|
|
||||||
|
auto json = nlohmann::json::parse(body);
|
||||||
|
LLSD result = LlsdFromJson(json);;
|
||||||
|
|
||||||
// Extract the info from the Json string
|
// Extract the info from the Json string
|
||||||
auto it = result["listings"].beginArray();
|
auto it = result["listings"].beginArray();
|
||||||
|
|
||||||
@@ -410,18 +396,10 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istringstream strstrm(body);
|
|
||||||
LLSD result;
|
|
||||||
if (LLSDSerialize::fromNotation(result, strstrm, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
|
|
||||||
{
|
|
||||||
log_SLM_warning("Get /listing", getStatus(), "Json parsing failed", LLStringUtil::null, body);
|
|
||||||
update_marketplace_category(folderId, false);
|
|
||||||
gInventory.notifyObservers();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_SLM_infos("Get /listing", getStatus(), body);
|
log_SLM_infos("Get /listing", getStatus(), body);
|
||||||
|
|
||||||
|
auto json = nlohmann::json::parse(body);
|
||||||
|
LLSD result = LlsdFromJson(json);;
|
||||||
|
|
||||||
// Extract the info from the results
|
// Extract the info from the results
|
||||||
for (LLSD::array_iterator it = result["listings"].beginArray();
|
for (LLSD::array_iterator it = result["listings"].beginArray();
|
||||||
@@ -444,7 +422,7 @@ public:
|
|||||||
LLMarketplaceData::instance().
|
LLMarketplaceData::instance().
|
||||||
setActivationState(folderUuid, isListed, false);
|
setActivationState(folderUuid, isListed, false);
|
||||||
LLMarketplaceData::instance().
|
LLMarketplaceData::instance().
|
||||||
setListingURL(folderUuid, editUrl, false);
|
setListingURL(folderUuid, editUrl, false);
|
||||||
LLMarketplaceData::instance().
|
LLMarketplaceData::instance().
|
||||||
setCountOnHand(folderUuid, count, false);
|
setCountOnHand(folderUuid, count, false);
|
||||||
update_marketplace_category(folderUuid, false);
|
update_marketplace_category(folderUuid, false);
|
||||||
@@ -485,18 +463,11 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istringstream strstrm(body);
|
|
||||||
LLSD result;
|
|
||||||
if (LLSDSerialize::fromNotation(result, strstrm, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
|
|
||||||
{
|
|
||||||
log_SLM_warning("Put /listing", getStatus(), "Json parsing failed", LLStringUtil::null, body);
|
|
||||||
update_marketplace_category(folderId, false);
|
|
||||||
gInventory.notifyObservers();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_SLM_infos("Put /listing", getStatus(), body);
|
log_SLM_infos("Put /listing", getStatus(), body);
|
||||||
|
|
||||||
|
auto json = nlohmann::json::parse(body);
|
||||||
|
LLSD result = LlsdFromJson(json);;
|
||||||
|
|
||||||
// Extract the info from the Json string
|
// Extract the info from the Json string
|
||||||
for (LLSD::array_iterator it = result["listings"].beginArray();
|
for (LLSD::array_iterator it = result["listings"].beginArray();
|
||||||
it != result["listings"].endArray(); ++it)
|
it != result["listings"].endArray(); ++it)
|
||||||
@@ -570,19 +541,11 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istringstream strstrm(body);
|
|
||||||
LLSD result;
|
|
||||||
if (LLSDSerialize::fromNotation(result, strstrm, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
|
|
||||||
{
|
|
||||||
log_SLM_warning("Put /associate_inventory", getStatus(), "Json parsing failed", LLStringUtil::null, body);
|
|
||||||
update_marketplace_category(folderId, false);
|
|
||||||
update_marketplace_category(sourceFolderId, false);
|
|
||||||
gInventory.notifyObservers();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_SLM_infos("Put /associate_inventory", getStatus(), body);
|
log_SLM_infos("Put /associate_inventory", getStatus(), body);
|
||||||
|
|
||||||
|
auto json = nlohmann::json::parse(body);
|
||||||
|
LLSD result = LlsdFromJson(json);;
|
||||||
|
|
||||||
for (LLSD::array_iterator it = result["listings"].beginArray();
|
for (LLSD::array_iterator it = result["listings"].beginArray();
|
||||||
it != result["listings"].endArray(); ++it)
|
it != result["listings"].endArray(); ++it)
|
||||||
{
|
{
|
||||||
@@ -650,18 +613,11 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istringstream strstrm(body);
|
|
||||||
LLSD result;
|
|
||||||
if (LLSDSerialize::fromNotation(result, strstrm, LLSDSerialize::SIZE_UNLIMITED) == LLSDParser::PARSE_FAILURE)
|
|
||||||
{
|
|
||||||
log_SLM_warning("Delete /listing", getStatus(), "Json parsing failed", LLStringUtil::null, body);
|
|
||||||
update_marketplace_category(folderId, false);
|
|
||||||
gInventory.notifyObservers();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_SLM_infos("Delete /listing", getStatus(), body);
|
log_SLM_infos("Delete /listing", getStatus(), body);
|
||||||
|
|
||||||
|
auto json = nlohmann::json::parse(body);
|
||||||
|
LLSD result = LlsdFromJson(json);;
|
||||||
|
|
||||||
for (LLSD::array_iterator it = result["listings"].beginArray();
|
for (LLSD::array_iterator it = result["listings"].beginArray();
|
||||||
it != result["listings"].endArray(); ++it)
|
it != result["listings"].endArray(); ++it)
|
||||||
{
|
{
|
||||||
@@ -1344,9 +1300,8 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folderId, const LLUUID& v
|
|||||||
LLSD postData;
|
LLSD postData;
|
||||||
postData["listing"] = listing;
|
postData["listing"] = listing;
|
||||||
|
|
||||||
std::stringstream json;
|
auto json = LlsdToJson(postData);
|
||||||
LLSDSerialize::toPrettyNotation(postData, json);
|
auto json_str = json.dump();
|
||||||
auto json_str = json.str();
|
|
||||||
|
|
||||||
// postRaw() takes ownership of the buffer and releases it later.
|
// postRaw() takes ownership of the buffer and releases it later.
|
||||||
size_t size = json_str.length();
|
size_t size = json_str.length();
|
||||||
@@ -1384,9 +1339,8 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folderId, S32 listingId,
|
|||||||
LLSD postData;
|
LLSD postData;
|
||||||
postData["listing"] = listing;
|
postData["listing"] = listing;
|
||||||
|
|
||||||
std::stringstream json;
|
auto json = LlsdToJson(postData);
|
||||||
LLSDSerialize::toPrettyNotation(postData, json);
|
auto json_str = json.dump();
|
||||||
auto json_str = json.str();
|
|
||||||
|
|
||||||
// postRaw() takes ownership of the buffer and releases it later.
|
// postRaw() takes ownership of the buffer and releases it later.
|
||||||
size_t size = json_str.size();
|
size_t size = json_str.size();
|
||||||
@@ -1414,9 +1368,8 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folderId, S32 listingI
|
|||||||
LLSD postData;
|
LLSD postData;
|
||||||
postData["listing"] = listing;
|
postData["listing"] = listing;
|
||||||
|
|
||||||
std::stringstream json;
|
auto json = LlsdToJson(postData);
|
||||||
LLSDSerialize::toPrettyNotation(postData, json);
|
auto json_str = json.dump();
|
||||||
auto json_str = json.str();
|
|
||||||
|
|
||||||
// postRaw() takes ownership of the buffer and releases it later.
|
// postRaw() takes ownership of the buffer and releases it later.
|
||||||
size_t size = json_str.size();
|
size_t size = json_str.size();
|
||||||
|
|||||||
Reference in New Issue
Block a user