summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2014-05-12 13:41:38 -0700
committerMerov Linden <merov@lindenlab.com>2014-05-12 13:41:38 -0700
commit03679c227e0715d51229250c006f9c407bd9d923 (patch)
tree23a92066768cec485d413f1d06487c68379cf9bc /indra
parent4ffa30b533979a2214eb3996c19435f1cd16bc2a (diff)
DD-22 : WIP : Implement the GET /listing/:listing route to complete the SLM API coverage. Will be used only in test.
Diffstat (limited to 'indra')
-rwxr-xr-xindra/newview/llinventorybridge.cpp8
-rwxr-xr-xindra/newview/llmarketplacefunctions.cpp99
-rwxr-xr-xindra/newview/llmarketplacefunctions.h4
-rwxr-xr-xindra/newview/skins/default/xui/en/menu_inventory.xml8
4 files changed, 119 insertions, 0 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 6bb93633d4..05e6427dc1 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -866,6 +866,7 @@ void LLInvFVBridge::addMarketplaceContextMenuOptions(U32 flags,
items.push_back(std::string("Marketplace Create Listing"));
items.push_back(std::string("Marketplace Associate Listing"));
items.push_back(std::string("Marketplace Disassociate Listing"));
+ items.push_back(std::string("Marketplace Get Listing"));
items.push_back(std::string("Marketplace List"));
items.push_back(std::string("Marketplace Unlist"));
if (LLMarketplaceData::instance().isListed(mUUID))
@@ -892,6 +893,7 @@ void LLInvFVBridge::addMarketplaceContextMenuOptions(U32 flags,
else
{
disabled_items.push_back(std::string("Marketplace Disassociate Listing"));
+ disabled_items.push_back(std::string("Marketplace Get Listing"));
disabled_items.push_back(std::string("Marketplace List"));
disabled_items.push_back(std::string("Marketplace Unlist"));
}
@@ -3218,6 +3220,12 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
LLMarketplaceData::instance().clearListing(mUUID);
return;
}
+ else if ("marketplace_get_listing" == action)
+ {
+ // This is used only to exercise the SLM API but won't be shown to end users
+ LLMarketplaceData::instance().getListing(mUUID);
+ return;
+ }
else if ("marketplace_associate_listing" == action)
{
LLFloaterAssociateListing::show(mUUID);
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index 5aab7aa6d3..ff43d82f03 100755
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -252,6 +252,66 @@ public:
}
};
+class LLSLMGetListingResponder : public LLHTTPClient::Responder
+{
+ LOG_CLASS(LLSLMGetListingResponder);
+public:
+
+ LLSLMGetListingResponder() {}
+
+ virtual void completedRaw(U32 status,
+ const std::string& reason,
+ const LLChannelDescriptors& channels,
+ const LLIOPipe::buffer_ptr_t& buffer)
+ {
+ LLBufferStream istr(channels, buffer.get());
+ std::stringstream strstrm;
+ strstrm << istr.rdbuf();
+ const std::string body = strstrm.str();
+
+ if (!isGoodStatus(status))
+ {
+ log_SLM_error("Get listing", status, reason, "", body);
+ return;
+ }
+
+ Json::Value root;
+ Json::Reader reader;
+ if (!reader.parse(body,root))
+ {
+ log_SLM_error("Get listing", status, "Json parsing failed", reader.getFormatedErrorMessages(), body);
+ return;
+ }
+
+ llinfos << "Merov : Get listing completedRaw : status = " << status << ", reason = " << reason << ", body = " << body << llendl;
+
+ // 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();
+
+ LLUUID folder_id(folder_uuid_string);
+ LLUUID version_id(version_uuid_string);
+
+ // Update that listing
+ LLMarketplaceData::instance().setListingID(folder_id, listing_id);
+ LLMarketplaceData::instance().setVersionFolderID(folder_id, version_id);
+ LLMarketplaceData::instance().setActivationState(folder_id, is_listed);
+ LLMarketplaceData::instance().setListingURL(folder_id, edit_url);
+
+ it++;
+ }
+ }
+};
+
class LLSLMUpdateListingsResponder : public LLHTTPClient::Responder
{
LOG_CLASS(LLSLMUpdateListingsResponder);
@@ -989,6 +1049,18 @@ void LLMarketplaceData::getSLMListings()
LLHTTPClient::get(getSLMConnectURL("/listings"), new LLSLMGetListingsResponder(), LLSD());
}
+void LLMarketplaceData::getSLMListing(S32 listing_id)
+{
+ LLSD headers = LLSD::emptyMap();
+ headers["Accept"] = "application/json";
+ headers["Content-Type"] = "application/json";
+
+ // Send request
+ std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id);
+ llinfos << "Merov : get listing : " << url << llendl;
+ LLHTTPClient::get(url, new LLSLMGetListingResponder(), headers);
+}
+
void LLMarketplaceData::createSLMListing(const LLUUID& folder_id)
{
LLSD headers = LLSD::emptyMap();
@@ -1151,6 +1223,33 @@ bool LLMarketplaceData::clearListing(const LLUUID& folder_id)
return true;
}
+bool LLMarketplaceData::getListing(const LLUUID& folder_id)
+{
+ if (folder_id.isNull())
+ {
+ // Folder doesn't exists -> exit with error
+ return false;
+ }
+
+ // Folder id can be the root of the listing or not so we need to retrieve the root first
+ S32 depth = depth_nesting_in_marketplace(folder_id);
+ LLUUID listing_uuid = (isListed(folder_id) ? folder_id : nested_parent_id(folder_id, depth));
+ S32 listing_id = getListingID(listing_uuid);
+
+ if (listing_id == 0)
+ {
+ // Listing doesn't exists -> exit with error
+ return false;
+ }
+
+ llinfos << "Merov : getListing, listing uuid = " << listing_uuid << ", listing id = " << listing_id << ", depth = " << depth << llendl;
+
+ // Get listing data from SLM
+ getSLMListing(listing_id);
+
+ return true;
+}
+
bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate)
{
// Folder id can be the root of the listing or not so we need to retrieve the root first
diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h
index de860bf9ca..8151d3aa40 100755
--- a/indra/newview/llmarketplacefunctions.h
+++ b/indra/newview/llmarketplacefunctions.h
@@ -160,6 +160,7 @@ typedef std::map<LLUUID, LLMarketplaceTuple> marketplace_items_list_t;
class LLSLMGetMerchantResponder;
class LLSLMGetListingsResponder;
class LLSLMCreateListingsResponder;
+class LLSLMGetListingResponder;
class LLSLMUpdateListingsResponder;
class LLSLMAssociateListingsResponder;
class LLSLMDeleteListingsResponder;
@@ -171,6 +172,7 @@ public:
friend class LLSLMGetMerchantResponder;
friend class LLSLMGetListingsResponder;
friend class LLSLMCreateListingsResponder;
+ friend class LLSLMGetListingResponder;
friend class LLSLMUpdateListingsResponder;
friend class LLSLMAssociateListingsResponder;
friend class LLSLMDeleteListingsResponder;
@@ -191,6 +193,7 @@ public:
bool clearListing(const LLUUID& folder_id);
bool setVersionFolder(const LLUUID& folder_id, const LLUUID& version_id);
bool associateListing(const LLUUID& folder_id, S32 listing_id);
+ bool getListing(const LLUUID& folder_id);
// Probe the Marketplace data set to identify folders
bool isListed(const LLUUID& folder_id); // returns true if folder_id is a Listing folder
@@ -220,6 +223,7 @@ private:
// Private SLM API : package data and get/post/put requests to the SLM Server through the SLM API
void setSLMStatus(U32 status);
void createSLMListing(const LLUUID& folder_id);
+ void getSLMListing(S32 listing_id);
void updateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed);
void associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id);
void deleteSLMListing(S32 listing_id);
diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml
index b621d53a6c..231e03b1bb 100755
--- a/indra/newview/skins/default/xui/en/menu_inventory.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory.xml
@@ -29,6 +29,14 @@
parameter="marketplace_disassociate_listing" />
</menu_item_call>
<menu_item_call
+ label="Get (Refresh) Listing"
+ layout="topleft"
+ name="Marketplace Get Listing">
+ <menu_item_call.on_click
+ function="Inventory.DoToSelected"
+ parameter="marketplace_get_listing" />
+ </menu_item_call>
+ <menu_item_call
label="Edit Listing"
layout="topleft"
name="Marketplace Edit Listing">