diff options
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/llinventoryfunctions.cpp | 5 | ||||
-rwxr-xr-x | indra/newview/llmarketplacefunctions.cpp | 64 | ||||
-rwxr-xr-x | indra/newview/llmarketplacefunctions.h | 6 |
3 files changed, 71 insertions, 4 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 1ca658ebd2..ac1efa5471 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -177,6 +177,11 @@ void update_marketplace_category(const LLUUID& cur_uuid, bool perform_consistenc } } + // Check if the count on hand needs to be updated on SLM + if (compute_stock_count(listing_uuid) != LLMarketplaceData::instance().getCountOnHand(listing_uuid)) + { + LLMarketplaceData::instance().updateCountOnHand(listing_uuid); + } // Update all descendents starting from the listing root update_marketplace_folder_hierarchy(listing_uuid); } diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index ea2364ef86..d7a85de062 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1221,7 +1221,7 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) LLHTTPClient::postRaw(url, data, size, new LLSLMCreateListingsResponder(folder_id), headers); } -void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed) +void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed, S32 count) { LLSD headers = LLSD::emptyMap(); headers["Accept"] = "application/json"; @@ -1235,6 +1235,7 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 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); @@ -1264,6 +1265,7 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing root["listing"]["is_listed"] = false; root["listing"]["inventory_info"]["listing_folder_id"] = folder_id.asString(); root["listing"]["inventory_info"]["version_folder_id"] = LLUUID::null.asString(); + root["listing"]["inventory_info"]["count_on_hand"] = -1; std::string json_str = writer.write(root); @@ -1416,9 +1418,13 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) } LLUUID version_uuid = getVersionFolder(listing_uuid); + + // Keep track of the count on hand + S32 count = compute_stock_count(folder_id); + setCountOnHand(folder_id, count); // Post the listing update request to SLM - updateSLMListing(listing_uuid, listing_id, version_uuid, activate); + updateSLMListing(listing_uuid, listing_id, version_uuid, activate, count); return true; } @@ -1438,8 +1444,38 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& // Note: if the version_id is cleared, we need to unlist the listing, otherwise, state unchanged bool is_listed = (version_id.isNull() ? false : getActivationState(listing_uuid)); + // Keep track of the count on hand + S32 count = compute_stock_count(version_id); + setCountOnHand(folder_id, count); + // Post the listing update request to SLM - updateSLMListing(listing_uuid, listing_id, version_id, is_listed); + updateSLMListing(listing_uuid, listing_id, version_id, is_listed, count); + + return true; +} + +bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id) +{ + // 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 = 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; + } + + // Get the unchanged values + bool is_listed = getActivationState(listing_uuid); + LLUUID version_uuid = getVersionFolder(listing_uuid); + + // Update the count on hand + S32 count = compute_stock_count(folder_id); + setCountOnHand(folder_id, count); + + // Post the listing update request to SLM + updateSLMListing(listing_uuid, listing_id, version_uuid, is_listed, count); return true; } @@ -1452,6 +1488,9 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& return false; } + // Clear the count on hand in that case (we don't have a version folder anymore) + setCountOnHand(folder_id, -1); + // Post the listing update request to SLM associateSLMListing(folder_id, listing_id, source_folder_id); @@ -1529,6 +1568,12 @@ S32 LLMarketplaceData::getListingID(const LLUUID& folder_id) return (it == mMarketplaceItems.end() ? 0 : (it->second).mListingId); } +S32 LLMarketplaceData::getCountOnHand(const LLUUID& folder_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + return (it == mMarketplaceItems.end() ? -1 : (it->second).mCountOnHand); +} + LLUUID LLMarketplaceData::getVersionFolder(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); @@ -1656,6 +1701,19 @@ bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) return true; } +bool LLMarketplaceData::setCountOnHand(const LLUUID& folder_id, S32 count) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + if (it == mMarketplaceItems.end()) + { + return false; + } + + (it->second).mCountOnHand = count; + + return true; +} + bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID& version_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index c2b287eea9..2b578c4c37 100755 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -147,6 +147,7 @@ private: S32 mListingId; LLUUID mVersionFolderId; bool mIsActive; + S32 mCountOnHand; std::string mEditURL; }; // Notes: @@ -195,6 +196,7 @@ public: bool clearListing(const LLUUID& folder_id); bool setVersionFolder(const LLUUID& folder_id, const LLUUID& version_id); bool associateListing(const LLUUID& folder_id, const LLUUID& source_folder_id, S32 listing_id); + bool updateCountOnHand(const LLUUID& folder_id); bool getListing(const LLUUID& folder_id); bool getListing(S32 listing_id); bool deleteListing(S32 listing_id); @@ -213,6 +215,7 @@ public: LLUUID getVersionFolder(const LLUUID& folder_id); std::string getListingURL(const LLUUID& folder_id); LLUUID getListingFolder(S32 listing_id); + S32 getCountOnHand(const LLUUID& folder_id); // Used to flag if stock count values for Marketplace have to be updated bool checkDirtyCount() { if (mDirtyCount) { mDirtyCount = false; return true; } else { return false; } } @@ -228,12 +231,13 @@ private: bool setVersionFolderID(const LLUUID& folder_id, const LLUUID& version_id); bool setActivationState(const LLUUID& folder_id, bool activate); bool setListingURL(const LLUUID& folder_id, const std::string& edit_url); + bool setCountOnHand(const LLUUID& folder_id, S32 count); // 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 updateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed, S32 count); void associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id); void deleteSLMListing(S32 listing_id); std::string getSLMConnectURL(const std::string& route); |