summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2014-05-05 15:13:48 -0700
committerMerov Linden <merov@lindenlab.com>2014-05-05 15:13:48 -0700
commit1a837c5719fa8dded91561a97839d2ed28e87553 (patch)
tree5f805b02e95e4a4b24c0711257afc9136a2a01a0 /indra
parent9c5d3de013921999b2dfb4994de91ab10308fd6a (diff)
DD-22 : WIP : Completed GET and POST listings routes. Refactored the marketplace data code a bit as a result
Diffstat (limited to 'indra')
-rwxr-xr-xindra/newview/llinventorybridge.cpp2
-rwxr-xr-xindra/newview/llmarketplacefunctions.cpp97
-rwxr-xr-xindra/newview/llmarketplacefunctions.h5
3 files changed, 54 insertions, 50 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 97646dc949..e9abe6a466 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3210,7 +3210,7 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
}
else if ("marketplace_create_listing" == action)
{
- LLMarketplaceData::instance().addListing(mUUID);
+ LLMarketplaceData::instance().createListing(mUUID);
return;
}
else if ("marketplace_disassociate_listing" == action)
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index d71f328a28..64df5a8396 100755
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -170,13 +170,24 @@ public:
return;
}
- // Extract the info from the Json string : just get the id for the first element in the list
- const int id = root["listings"][0u]["id"].asInt();
- //Json::Value listings = root["listings"];
- llinfos << "Merov : Parsed the json, string = " << body << llendl;
- llinfos << "Merov : Parsed the json, id = " << id << 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 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);
+ LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed);
+ it++;
+ }
}
-
};
class LLSLMCreateListingsResponder : public LLHTTPClient::Responder
@@ -211,35 +222,23 @@ public:
return;
}
- // Extract the info from the Json string : just get the id for the first element in the list
- const int id = root["listings"][0u]["id"].asInt();
- //Json::Value listings = root["listings"];
- llinfos << "Merov : Parsed the json, string = " << body << llendl;
- llinfos << "Merov : Parsed the json, id = " << id << llendl;
- }
-
- virtual void completed(U32 status, const std::string& reason, const LLSD& content)
- {
- if (isGoodStatus(status))
- {
- llinfos << "Merov : completed successful, status = " << status << ", reason = " << reason << ", content = " << content << llendl;
- }
- else
- {
- llinfos << "Merov : completed with error, status = " << status << ", reason = " << reason << ", content = " << content << llendl;
- }
- }
-
- void completedHeader(U32 status, const std::string& reason, const LLSD& content)
- {
- if (isGoodStatus(status))
- {
- llinfos << "Merov : completed header successful, status = " << status << ", reason = " << reason << ", content = " << content << llendl;
- }
- else
- {
- llinfos << "Merov : completed header with error, status = " << status << ", reason = " << reason << ", content = " << content << 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 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);
+ LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed);
+ it++;
+ }
}
};
// SLM Responders End
@@ -795,7 +794,7 @@ void LLMarketplaceData::getSLMListings()
LLHTTPClient::get(getSLMConnectURL("/listings"), new LLSLMListingsResponder(), LLSD());
}
-void LLMarketplaceData::postSLMListing(const LLUUID& folder_id)
+void LLMarketplaceData::createSLMListing(const LLUUID& folder_id)
{
LLSD headers = LLSD::emptyMap();
headers["Accept"] = "application/json";
@@ -811,8 +810,6 @@ void LLMarketplaceData::postSLMListing(const LLUUID& folder_id)
std::string json_str = writer.write(root);
- llinfos << "Merov : postSLMListing, json body = " << json_str << ", size = " << json_str.size() << llendl;
-
// postRaw() takes ownership of the buffer and releases it later.
size_t size = json_str.size();
U8 *data = new U8[size];
@@ -851,23 +848,29 @@ void LLMarketplaceData::setSLMStatus(U32 status)
}
// Creation / Deletion
-bool LLMarketplaceData::addListing(const LLUUID& folder_id)
+bool LLMarketplaceData::createListing(const LLUUID& folder_id)
{
if (isListed(folder_id))
{
// Listing already exists -> exit with error
return false;
}
- mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id);
-
- // Post the listing to SLM
- postSLMListing(folder_id);
- // *TODO : Get the listing id from SLM
- // For the moment, we use that wonky test ID generator...
- S32 listing_id = LLMarketplaceData::instance().getTestMarketplaceID();
+ // Post the listing creation request to SLM
+ createSLMListing(folder_id);
- setListingID(folder_id,listing_id);
+ return true;
+}
+
+bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed)
+{
+ if (isListed(folder_id))
+ {
+ // Listing already exists -> exit with error
+ return false;
+ }
+ mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id, listing_id, version_id, is_listed);
+
update_marketplace_category(folder_id);
gInventory.notifyObservers();
return true;
diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h
index 7f1b6350e8..aa286adcc8 100755
--- a/indra/newview/llmarketplacefunctions.h
+++ b/indra/newview/llmarketplacefunctions.h
@@ -163,7 +163,7 @@ public:
void initializeSLM(const status_updated_signal_t::slot_type& cb);
void getSLMListings();
//void getSLMListing();
- void postSLMListing(const LLUUID& folder_id);
+ void createSLMListing(const LLUUID& folder_id);
//void modifySLMListing();
//void associateSLMListing();
@@ -174,7 +174,8 @@ public:
bool isVersionFolder(const LLUUID& folder_id); // returns true if folder_id is a Version folder
// Create/Delete Marketplace data set : each method returns true if the function succeeds, false if error
- bool addListing(const LLUUID& folder_id);
+ bool createListing(const LLUUID& folder_id);
+ bool addListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed);
bool associateListing(const LLUUID& folder_id, S32 listing_id);
bool deleteListing(const LLUUID& folder_id);