From 0006840325fd88aea3c7514ca5d93f42659e4037 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 7 Mar 2014 13:56:21 -0800 Subject: DD-2 : Implement LLMarketplaceTuple and LLMarketplaceData --- indra/newview/llmarketplacefunctions.cpp | 110 +++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 05c9d76810..d231202f40 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -528,3 +528,113 @@ void LLMarketplaceInventoryImporter::updateImport() } } +// +// Direct Delivery : Marketplace tuples and data +// + +// Tuple == Item +LLMarketplaceTuple::LLMarketplaceTuple() : + mFolderListingId(), + mListingId(""), + mActiveVersionFolderId(), + mIsActive(false) +{ +} + +LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id) : + mFolderListingId(folder_id), + mListingId(""), + mActiveVersionFolderId(), + mIsActive(false) +{ +} + +LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, std::string listing_id, const LLUUID& version_id, bool is_listed) : + mFolderListingId(folder_id), + mListingId(listing_id), + mActiveVersionFolderId(version_id), + mIsActive(is_listed) +{ +} + + +// Data map +LLMarketplaceData::LLMarketplaceData() +{ +} + +// Accessors +bool LLMarketplaceData::getActivationState(const LLUUID& folder_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + return (it == mMarketplaceItems.end() ? false : (it->second).mIsActive); +} +std::string LLMarketplaceData::getListingID(const LLUUID& folder_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + return (it == mMarketplaceItems.end() ? "" : (it->second).mListingId); +} +LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + return (it == mMarketplaceItems.end() ? LLUUID::null : (it->second).mActiveVersionFolderId); +} +bool LLMarketplaceData::isListed(const LLUUID& folder_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + return (it != mMarketplaceItems.end()); +} + +// Modifiers +bool LLMarketplaceData::setListingID(const LLUUID& folder_id, std::string listing_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + if (it == mMarketplaceItems.end()) + { + return false; + } + else + { + (it->second).mListingId = listing_id; + return true; + } +} +bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID& version_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + if (it == mMarketplaceItems.end()) + { + return false; + } + else + { + (it->second).mActiveVersionFolderId = version_id; + return true; + } +} +bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + if (it == mMarketplaceItems.end()) + { + return false; + } + else + { + (it->second).mIsActive = activate; + return true; + } +} + +// Test methods +void LLMarketplaceData::addTestItem(const LLUUID& folder_id) +{ + mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); +} +void LLMarketplaceData::addTestItem(const LLUUID& folder_id, const LLUUID& version_id) +{ + mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); + setVersionFolderID(folder_id, version_id); +} + + -- cgit v1.2.3 From 00fe1b7fbe605ddcb6fb56e0a3d20b1208fbd5fd Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 10 Mar 2014 11:44:40 -0700 Subject: DD-3 : WIP : Add test data to LLMarketplaceData when opening the floater for the first time --- indra/newview/llmarketplacefunctions.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d231202f40..b39889c721 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -629,10 +629,12 @@ bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) // Test methods void LLMarketplaceData::addTestItem(const LLUUID& folder_id) { + llinfos << "Merov : addTestItem, id = " << folder_id << llendl; mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); } void LLMarketplaceData::addTestItem(const LLUUID& folder_id, const LLUUID& version_id) { + llinfos << "Merov : addTestItem, id = " << folder_id << ", version = " << version_id << llendl; mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); setVersionFolderID(folder_id, version_id); } -- cgit v1.2.3 From f93f860e9b565213089f945ee0d88dedf3dcd9c0 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 14 Mar 2014 13:52:42 -0700 Subject: DD-43, DD-44 : implement update_marketplace_category() and get it called swhen appropriate --- indra/newview/llmarketplacefunctions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index b39889c721..6f35cc217d 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -30,6 +30,7 @@ #include "llagent.h" #include "llhttpclient.h" +#include "llinventoryfunctions.h" #include "llsdserialize.h" #include "lltimer.h" #include "lltrans.h" @@ -596,6 +597,7 @@ bool LLMarketplaceData::setListingID(const LLUUID& folder_id, std::string listin else { (it->second).mListingId = listing_id; + update_marketplace_category(folder_id); return true; } } @@ -609,6 +611,7 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID else { (it->second).mActiveVersionFolderId = version_id; + update_marketplace_category(folder_id); return true; } } @@ -622,6 +625,7 @@ bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) else { (it->second).mIsActive = activate; + update_marketplace_category(folder_id); return true; } } @@ -631,12 +635,15 @@ void LLMarketplaceData::addTestItem(const LLUUID& folder_id) { llinfos << "Merov : addTestItem, id = " << folder_id << llendl; mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); + update_marketplace_category(folder_id); } void LLMarketplaceData::addTestItem(const LLUUID& folder_id, const LLUUID& version_id) { llinfos << "Merov : addTestItem, id = " << folder_id << ", version = " << version_id << llendl; mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); setVersionFolderID(folder_id, version_id); + update_marketplace_category(folder_id); + update_marketplace_category(version_id); } -- cgit v1.2.3 From a38bc63da24994b51cfd3487d4011c8e608cd41d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sun, 6 Apr 2014 22:03:58 -0700 Subject: DD-15 : Allow version folder to be made active/inactive, add new methods to marketplace to make all that a bit more clear and clean --- indra/newview/llmarketplacefunctions.cpp | 112 ++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 18 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 6f35cc217d..29ce5361f0 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -535,25 +535,25 @@ void LLMarketplaceInventoryImporter::updateImport() // Tuple == Item LLMarketplaceTuple::LLMarketplaceTuple() : - mFolderListingId(), + mListingFolderId(), mListingId(""), - mActiveVersionFolderId(), + mVersionFolderId(), mIsActive(false) { } LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id) : - mFolderListingId(folder_id), + mListingFolderId(folder_id), mListingId(""), - mActiveVersionFolderId(), + mVersionFolderId(), mIsActive(false) { } LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, std::string listing_id, const LLUUID& version_id, bool is_listed) : - mFolderListingId(folder_id), + mListingFolderId(folder_id), mListingId(listing_id), - mActiveVersionFolderId(version_id), + mVersionFolderId(version_id), mIsActive(is_listed) { } @@ -564,28 +564,85 @@ LLMarketplaceData::LLMarketplaceData() { } +// Creation / Deletion +bool LLMarketplaceData::addListing(const LLUUID& folder_id) +{ + if (isListed(folder_id)) + { + // Listing already exists -> exit with error + return false; + } + mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); + update_marketplace_category(folder_id); + return true; +} + +bool LLMarketplaceData::deleteListing(const LLUUID& folder_id) +{ + if (!isListed(folder_id)) + { + // Listing doesn't exist -> exit with error + return false; + } + mMarketplaceItems.erase(folder_id); + update_marketplace_category(folder_id); + return true; +} + // Accessors bool LLMarketplaceData::getActivationState(const LLUUID& folder_id) { - marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); - return (it == mMarketplaceItems.end() ? false : (it->second).mIsActive); + // Listing folder case + if (isListed(folder_id)) + { + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + return (it->second).mIsActive; + } + // We need to iterate through the list to check it's not a version folder + marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); + while (it != mMarketplaceItems.end()) + { + if ((it->second).mVersionFolderId == folder_id) + { + return (it->second).mIsActive; + } + it++; + } + return false; } + std::string LLMarketplaceData::getListingID(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); return (it == mMarketplaceItems.end() ? "" : (it->second).mListingId); } + LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); - return (it == mMarketplaceItems.end() ? LLUUID::null : (it->second).mActiveVersionFolderId); + return (it == mMarketplaceItems.end() ? LLUUID::null : (it->second).mVersionFolderId); } + bool LLMarketplaceData::isListed(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); return (it != mMarketplaceItems.end()); } +bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); + while (it != mMarketplaceItems.end()) + { + if ((it->second).mVersionFolderId == folder_id) + { + return true; + } + it++; + } + return false; +} + // Modifiers bool LLMarketplaceData::setListingID(const LLUUID& folder_id, std::string listing_id) { @@ -601,6 +658,7 @@ bool LLMarketplaceData::setListingID(const LLUUID& folder_id, std::string listin return true; } } + bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID& version_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); @@ -610,24 +668,42 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID } else { - (it->second).mActiveVersionFolderId = version_id; - update_marketplace_category(folder_id); + LLUUID old_version_id = (it->second).mVersionFolderId; + if (old_version_id != version_id) + { + (it->second).mVersionFolderId = version_id; + update_marketplace_category(old_version_id); + update_marketplace_category(version_id); + } return true; } } + bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) { - marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); - if (it == mMarketplaceItems.end()) - { - return false; - } - else + // Listing folder case + if (isListed(folder_id)) { + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); (it->second).mIsActive = activate; - update_marketplace_category(folder_id); + update_marketplace_category((it->second).mListingFolderId); + update_marketplace_category((it->second).mVersionFolderId); return true; } + // We need to iterate through the list to check it's not a version folder + marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); + while (it != mMarketplaceItems.end()) + { + if ((it->second).mVersionFolderId == folder_id) + { + (it->second).mIsActive = activate; + update_marketplace_category((it->second).mListingFolderId); + update_marketplace_category((it->second).mVersionFolderId); + return true; + } + it++; + } + return false; } // Test methods -- cgit v1.2.3 From 748bbeaf982c456b120d4b3f4d33aa6dce576908 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 9 Apr 2014 14:19:38 -0700 Subject: DD-13 : Clean up Associate/Disassociate listing. Also clarify the update folder code in marketplace --- indra/newview/llmarketplacefunctions.cpp | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 29ce5361f0..b7c84dc714 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -687,7 +687,6 @@ bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); (it->second).mIsActive = activate; update_marketplace_category((it->second).mListingFolderId); - update_marketplace_category((it->second).mVersionFolderId); return true; } // We need to iterate through the list to check it's not a version folder @@ -698,7 +697,6 @@ bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) { (it->second).mIsActive = activate; update_marketplace_category((it->second).mListingFolderId); - update_marketplace_category((it->second).mVersionFolderId); return true; } it++; @@ -706,20 +704,4 @@ bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) return false; } -// Test methods -void LLMarketplaceData::addTestItem(const LLUUID& folder_id) -{ - llinfos << "Merov : addTestItem, id = " << folder_id << llendl; - mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); - update_marketplace_category(folder_id); -} -void LLMarketplaceData::addTestItem(const LLUUID& folder_id, const LLUUID& version_id) -{ - llinfos << "Merov : addTestItem, id = " << folder_id << ", version = " << version_id << llendl; - mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); - setVersionFolderID(folder_id, version_id); - update_marketplace_category(folder_id); - update_marketplace_category(version_id); -} - -- cgit v1.2.3 From a4f6fc8ee1a4231d2b81d28035b21b8f8b3fd8fd Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 16 Apr 2014 16:56:01 -0700 Subject: DD-11 : Implement getListingURL() and parametrize it correctly. Change Show Listing to Edit Listing. --- indra/newview/llmarketplacefunctions.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index b7c84dc714..4a3abe5f22 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -617,6 +617,18 @@ std::string LLMarketplaceData::getListingID(const LLUUID& folder_id) return (it == mMarketplaceItems.end() ? "" : (it->second).mListingId); } +std::string LLMarketplaceData::getListingName(const LLUUID& folder_id) +{ + std::string listing_name = ""; + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + if (it != mMarketplaceItems.end()) + { + // *TODO : Call the MKT API to get the name of a listing + llinfos << "Merov : Marketplace warning : No API to get Listing name for : " << folder_id << llendl; + } + return listing_name; +} + LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); @@ -643,6 +655,24 @@ bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) return false; } +std::string LLMarketplaceData::getListingURL(const LLUUID& folder_id) +{ + // Get the listing id (i.e. go up the hierarchy to find the listing folder + // URL format will be something like : https://marketplace.secondlife.com/p// + std::string marketplace_url = getMarketplaceURL("MarketplaceURL"); + + S32 depth = depth_nesting_in_marketplace(folder_id); + LLUUID listing_uuid = nested_parent_id(folder_id, depth); + std::string listing_name = getListingName(listing_uuid); + std::string listing_id = getListingID(listing_uuid); + + if (!listing_name.empty() && !listing_id.empty()) + { + marketplace_url += "p/" + listing_name + "/" + listing_id; + } + return marketplace_url; +} + // Modifiers bool LLMarketplaceData::setListingID(const LLUUID& folder_id, std::string listing_id) { -- cgit v1.2.3 From ccdffd9794229b59b7d022760540ce5f8d8ea133 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 17 Apr 2014 11:44:04 -0700 Subject: DD-70 : Use List/Delist for listing folders and Activate/Deactivate for version folders. Also create test SLM ID when creating listing. --- indra/newview/llmarketplacefunctions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 4a3abe5f22..4a6914ee9c 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -562,6 +562,7 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, std::string list // Data map LLMarketplaceData::LLMarketplaceData() { + mTestCurrentMarketplaceID = 1234567; } // Creation / Deletion @@ -573,6 +574,12 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id) return false; } mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); + + // *TODO : Create the listing on SLM and get the ID (blocking?) + // For the moment, we use that wonky test ID generator... + std::string listing_id = llformat ("%d", LLMarketplaceData::instance().getTestMarketplaceID()); + + setListingID(folder_id,listing_id); update_marketplace_category(folder_id); return true; } -- cgit v1.2.3 From c52b4e27f2fbeb558eec3ea587fe88f8e5b947dd Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 18 Apr 2014 11:23:06 -0700 Subject: DD-11 : Suppress getListingName() method since we actually do not need that to get a listing URL --- indra/newview/llmarketplacefunctions.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 4a6914ee9c..9465401d88 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -624,18 +624,6 @@ std::string LLMarketplaceData::getListingID(const LLUUID& folder_id) return (it == mMarketplaceItems.end() ? "" : (it->second).mListingId); } -std::string LLMarketplaceData::getListingName(const LLUUID& folder_id) -{ - std::string listing_name = ""; - marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); - if (it != mMarketplaceItems.end()) - { - // *TODO : Call the MKT API to get the name of a listing - llinfos << "Merov : Marketplace warning : No API to get Listing name for : " << folder_id << llendl; - } - return listing_name; -} - LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); @@ -665,17 +653,16 @@ bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) std::string LLMarketplaceData::getListingURL(const LLUUID& folder_id) { // Get the listing id (i.e. go up the hierarchy to find the listing folder - // URL format will be something like : https://marketplace.secondlife.com/p// + // URL format will be something like : https://marketplace.secondlife.com/p/listing/ std::string marketplace_url = getMarketplaceURL("MarketplaceURL"); S32 depth = depth_nesting_in_marketplace(folder_id); LLUUID listing_uuid = nested_parent_id(folder_id, depth); - std::string listing_name = getListingName(listing_uuid); std::string listing_id = getListingID(listing_uuid); - if (!listing_name.empty() && !listing_id.empty()) + if (!listing_id.empty()) { - marketplace_url += "p/" + listing_name + "/" + listing_id; + marketplace_url += "p/listing/" + listing_id; } return marketplace_url; } -- cgit v1.2.3 From a99e2475443bebb6b9c9d2c8998300ce50f254a8 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 18 Apr 2014 14:41:32 -0700 Subject: DD-58 : Implement associate listing UI and primitive --- indra/newview/llmarketplacefunctions.cpp | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 9465401d88..6ff6ba6714 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -584,6 +584,28 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id) return true; } +bool LLMarketplaceData::associateListing(const LLUUID& folder_id, std::string listing_id) +{ + if (isListed(folder_id)) + { + // Listing already exists -> exit with error + return false; + } + mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); + + // Check that the listing ID is not already associated to some other record + LLUUID old_listing = 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); + } + + setListingID(folder_id,listing_id); + update_marketplace_category(folder_id); + return true; +} + bool LLMarketplaceData::deleteListing(const LLUUID& folder_id) { if (!isListed(folder_id)) @@ -630,6 +652,21 @@ LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) return (it == mMarketplaceItems.end() ? LLUUID::null : (it->second).mVersionFolderId); } +// Reverse lookup : find the listing folder id from the listing id +LLUUID LLMarketplaceData::getListingFolder(std::string listing_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); + while (it != mMarketplaceItems.end()) + { + if ((it->second).mListingId == listing_id) + { + return (it->second).mListingFolderId; + } + it++; + } + return LLUUID::null; +} + bool LLMarketplaceData::isListed(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); -- cgit v1.2.3 From 4ec13dcf8c331bc39a00aa6fec8397b6714172ba Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 21 Apr 2014 18:42:56 -0700 Subject: DD-21 : WIP : Call DirectDelivery cap, nothing done but print out the url in the log --- indra/newview/llmarketplacefunctions.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 6ff6ba6714..3fa2c58cba 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -37,6 +37,7 @@ #include "llviewercontrol.h" #include "llviewermedia.h" #include "llviewernetwork.h" +#include "llviewerregion.h" // @@ -426,6 +427,18 @@ void LLMarketplaceInventoryImporter::initialize() return; } + // Test DirectDelivery cap + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + std::string url = region->getCapability("DirectDelivery"); + llinfos << "Merov : Test DirectDelivery cap : url = " << url << llendl; + } + else + { + llinfos << "Merov : Test DirectDelivery cap : no region accessible" << llendl; + } + if (!LLMarketplaceImport::hasSessionCookie()) { mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; -- cgit v1.2.3 From d22944da00a5ade5eb97aa109bac624967ead94c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 22 Apr 2014 20:57:49 -0700 Subject: DD-58 : Forced listing ID to be an integer throughout. Verify we get an integer when using the associate UI. --- indra/newview/llmarketplacefunctions.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 3fa2c58cba..40417bf77b 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -549,7 +549,7 @@ void LLMarketplaceInventoryImporter::updateImport() // Tuple == Item LLMarketplaceTuple::LLMarketplaceTuple() : mListingFolderId(), - mListingId(""), + mListingId(0), mVersionFolderId(), mIsActive(false) { @@ -557,13 +557,13 @@ LLMarketplaceTuple::LLMarketplaceTuple() : LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id) : mListingFolderId(folder_id), - mListingId(""), + mListingId(0), mVersionFolderId(), mIsActive(false) { } -LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, std::string listing_id, const LLUUID& version_id, bool is_listed) : +LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed) : mListingFolderId(folder_id), mListingId(listing_id), mVersionFolderId(version_id), @@ -590,14 +590,14 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id) // *TODO : Create the listing on SLM and get the ID (blocking?) // For the moment, we use that wonky test ID generator... - std::string listing_id = llformat ("%d", LLMarketplaceData::instance().getTestMarketplaceID()); + S32 listing_id = LLMarketplaceData::instance().getTestMarketplaceID(); setListingID(folder_id,listing_id); update_marketplace_category(folder_id); return true; } -bool LLMarketplaceData::associateListing(const LLUUID& folder_id, std::string listing_id) +bool LLMarketplaceData::associateListing(const LLUUID& folder_id, S32 listing_id) { if (isListed(folder_id)) { @@ -653,10 +653,10 @@ bool LLMarketplaceData::getActivationState(const LLUUID& folder_id) return false; } -std::string LLMarketplaceData::getListingID(const LLUUID& folder_id) +S32 LLMarketplaceData::getListingID(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); - return (it == mMarketplaceItems.end() ? "" : (it->second).mListingId); + return (it == mMarketplaceItems.end() ? 0 : (it->second).mListingId); } LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) @@ -666,7 +666,7 @@ LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) } // Reverse lookup : find the listing folder id from the listing id -LLUUID LLMarketplaceData::getListingFolder(std::string listing_id) +LLUUID LLMarketplaceData::getListingFolder(S32 listing_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); while (it != mMarketplaceItems.end()) @@ -708,17 +708,17 @@ std::string LLMarketplaceData::getListingURL(const LLUUID& folder_id) S32 depth = depth_nesting_in_marketplace(folder_id); LLUUID listing_uuid = nested_parent_id(folder_id, depth); - std::string listing_id = getListingID(listing_uuid); + S32 listing_id = getListingID(listing_uuid); - if (!listing_id.empty()) + if (listing_id != 0) { - marketplace_url += "p/listing/" + listing_id; + marketplace_url += llformat("p/listing/%d",listing_id); } return marketplace_url; } // Modifiers -bool LLMarketplaceData::setListingID(const LLUUID& folder_id, std::string listing_id) +bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); if (it == mMarketplaceItems.end()) -- cgit v1.2.3 From 6d7b33f77e6d6facd585faf8c5d355f68942fcef Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 25 Apr 2014 17:12:49 -0700 Subject: DD-22 : WIP : Implemented SLM API GET merchant, use it in initialization but glitch in UI (needs to reopen the floater to see content) --- indra/newview/llmarketplacefunctions.cpp | 94 ++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 17 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 40417bf77b..607f907ed1 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -95,6 +95,46 @@ LLSD getMarketplaceStringSubstitutions() return marketplace_sub_map; } +/////////////////////////////////////////////////////////////////////////////// +// SLM Responder +class LLSLMMerchantResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLSLMMerchantResponder); +public: + + LLSLMMerchantResponder() {} + + 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; + LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); + } + else + { + llinfos << "Merov : completed with error, status = " << status << ", reason = " << reason << ", content = " << content << llendl; + LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); + } + } + + 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; + LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); + } + else + { + llinfos << "Merov : completed header with error, status = " << status << ", reason = " << reason << ", content = " << content << llendl; + LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); + } + } +}; +// SLM Responder End +/////////////////////////////////////////////////////////////////////////////// + namespace LLMarketplaceImport { // Basic interface for this namespace @@ -427,27 +467,15 @@ void LLMarketplaceInventoryImporter::initialize() return; } - // Test DirectDelivery cap - LLViewerRegion* region = gAgent.getRegion(); - if (region) + if (!LLMarketplaceImport::hasSessionCookie()) { - std::string url = region->getCapability("DirectDelivery"); - llinfos << "Merov : Test DirectDelivery cap : url = " << url << llendl; + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; + LLMarketplaceImport::establishMarketplaceSessionCookie(); } else { - llinfos << "Merov : Test DirectDelivery cap : no region accessible" << llendl; + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_MERCHANT; } - - if (!LLMarketplaceImport::hasSessionCookie()) - { - mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; - LLMarketplaceImport::establishMarketplaceSessionCookie(); - } - else - { - mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_MERCHANT; - } } void LLMarketplaceInventoryImporter::reinitializeAndTriggerImport() @@ -573,11 +601,43 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id, // Data map -LLMarketplaceData::LLMarketplaceData() +LLMarketplaceData::LLMarketplaceData() : + mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED) { mTestCurrentMarketplaceID = 1234567; } +S32 LLMarketplaceData::getTestMarketplaceID() +{ + return mTestCurrentMarketplaceID++; +} + +void LLMarketplaceData::initializeSLM() +{ + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; + + // Get DirectDelivery cap + std::string url = ""; + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + url = region->getCapability("DirectDelivery"); + llinfos << "Merov : Test DirectDelivery cap : url = " << url << llendl; + } + else + { + llinfos << "Merov : Test DirectDelivery cap : no region accessible" << llendl; + } + // *TODO : Take this DirectDelivery cap coping hack out + if (url == "") + { + url = "https://marketplace.secondlife-staging.com/api/1/viewer/" + gAgentID.asString() + "/merchant"; + } + llinfos << "Merov : Testing get : " << url << llendl; + + LLHTTPClient::get(url, new LLSLMMerchantResponder(), LLSD()); +} + // Creation / Deletion bool LLMarketplaceData::addListing(const LLUUID& folder_id) { -- cgit v1.2.3 From fc4939033e089354bc05fd0ca7fe402a4a1198bd Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 28 Apr 2014 14:11:17 -0700 Subject: DD-22 : WIP : Fix initialization glitch and got rid of old Merchant Outbox remnants in Marketplace --- indra/newview/llmarketplacefunctions.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 607f907ed1..c3aaf66071 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -602,7 +602,8 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id, // Data map LLMarketplaceData::LLMarketplaceData() : - mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED) + mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED), + mStatusUpdatedSignal(NULL) { mTestCurrentMarketplaceID = 1234567; } @@ -612,9 +613,14 @@ S32 LLMarketplaceData::getTestMarketplaceID() return mTestCurrentMarketplaceID++; } -void LLMarketplaceData::initializeSLM() +void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& cb) { mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; + if (mStatusUpdatedSignal == NULL) + { + mStatusUpdatedSignal = new status_updated_signal_t(); + } + mStatusUpdatedSignal->connect(cb); // Get DirectDelivery cap std::string url = ""; @@ -638,6 +644,17 @@ void LLMarketplaceData::initializeSLM() LLHTTPClient::get(url, new LLSLMMerchantResponder(), LLSD()); } +void LLMarketplaceData::setSLMStatus(U32 status) +{ + mMarketPlaceStatus = status; /* call cb if status is "done" */ + + // Make sure we trigger the status change with the current state + if (mStatusUpdatedSignal) + { + (*mStatusUpdatedSignal)(); + } +} + // Creation / Deletion bool LLMarketplaceData::addListing(const LLUUID& folder_id) { -- cgit v1.2.3 From f15442a82a2bfee00694b0097abdf6aeae083e14 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 28 Apr 2014 15:53:54 -0700 Subject: DD-22 : WIP : Implements getSLMListings(). Does no parsing for the moment --- indra/newview/llmarketplacefunctions.cpp | 84 +++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 24 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index c3aaf66071..b85828ddfd 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -96,7 +96,7 @@ LLSD getMarketplaceStringSubstitutions() } /////////////////////////////////////////////////////////////////////////////// -// SLM Responder +// SLM Responders class LLSLMMerchantResponder : public LLHTTPClient::Responder { LOG_CLASS(LLSLMMerchantResponder); @@ -132,7 +132,41 @@ public: } } }; -// SLM Responder End + +class LLSLMListingsResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLSLMListingsResponder); +public: + + LLSLMListingsResponder() {} + + 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; + // *TODO : Parse the Json body + //LLMarketplaceData::instance().parseListings(content); + } + 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; + } + } +}; +// SLM Responders End /////////////////////////////////////////////////////////////////////////////// namespace LLMarketplaceImport @@ -621,34 +655,36 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& mStatusUpdatedSignal = new status_updated_signal_t(); } mStatusUpdatedSignal->connect(cb); - - // Get DirectDelivery cap - std::string url = ""; - LLViewerRegion* region = gAgent.getRegion(); - if (region) - { - url = region->getCapability("DirectDelivery"); - llinfos << "Merov : Test DirectDelivery cap : url = " << url << llendl; - } - else - { - llinfos << "Merov : Test DirectDelivery cap : no region accessible" << llendl; - } - // *TODO : Take this DirectDelivery cap coping hack out - if (url == "") + LLHTTPClient::get(getSLMConnectURL("/merchant"), new LLSLMMerchantResponder(), LLSD()); +} + +void LLMarketplaceData::getSLMListings() +{ + LLHTTPClient::get(getSLMConnectURL("/listings"), new LLSLMListingsResponder(), LLSD()); +} + +std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) +{ + std::string url(""); + LLViewerRegion *regionp = gAgent.getRegion(); + if (regionp) { - url = "https://marketplace.secondlife-staging.com/api/1/viewer/" + gAgentID.asString() + "/merchant"; + // Get DirectDelivery cap + url = regionp->getCapability("DirectDelivery"); + // *TODO : Take this DirectDelivery cap coping mechanism hack out + if (url == "") + { + url = "https://marketplace.secondlife-staging.com/api/1/viewer/" + gAgentID.asString(); + } + url += route; } - llinfos << "Merov : Testing get : " << url << llendl; - - LLHTTPClient::get(url, new LLSLMMerchantResponder(), LLSD()); + llinfos << "Merov : Testing getSLMConnectURL : " << url << llendl; + return url; } void LLMarketplaceData::setSLMStatus(U32 status) { - mMarketPlaceStatus = status; /* call cb if status is "done" */ - - // Make sure we trigger the status change with the current state + mMarketPlaceStatus = status; if (mStatusUpdatedSignal) { (*mStatusUpdatedSignal)(); -- cgit v1.2.3 From eeccd4c381243eb8dbbafdbaf43f30eb74b96048 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 28 Apr 2014 21:01:57 -0700 Subject: DD-22 : WIP : Cleaned up error handling in GET merchant --- indra/newview/llmarketplacefunctions.cpp | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index b85828ddfd..5804bce819 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -97,6 +97,15 @@ LLSD getMarketplaceStringSubstitutions() /////////////////////////////////////////////////////////////////////////////// // SLM Responders +void log_SLM_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description) +{ + LL_WARNS("SLM") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << " (" << description << ")" << LL_ENDL; +} + +// Merov: This is a temporary hack used by dev while secondlife-staging is down... +// *TODO : Suppress that before shipping! +static bool sBypassMerchant = false; + class LLSLMMerchantResponder : public LLHTTPClient::Responder { LOG_CLASS(LLSLMMerchantResponder); @@ -104,32 +113,23 @@ public: LLSLMMerchantResponder() {} - 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; - LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); - } - else - { - llinfos << "Merov : completed with error, status = " << status << ", reason = " << reason << ", content = " << content << llendl; - LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); - } - } + virtual void completed(U32 status, const std::string& reason, const LLSD& content) { } void completedHeader(U32 status, const std::string& reason, const LLSD& content) { - if (isGoodStatus(status)) + if (isGoodStatus(status) || sBypassMerchant) { - llinfos << "Merov : completed header successful, status = " << status << ", reason = " << reason << ", content = " << content << llendl; LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); } - else + else if (status == SLMErrorCodes::SLM_NOT_FOUND) { - llinfos << "Merov : completed header with error, status = " << status << ", reason = " << reason << ", content = " << content << llendl; LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); } + else + { + log_SLM_error("Get merchant", status, reason, content.get("error_code"), content.get("error_description")); + LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_CONNECTION_FAILURE); + } } }; -- cgit v1.2.3 From 87192990592f9abda8314393bdcac3627c15d5ac Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 1 May 2014 17:36:17 -0700 Subject: DD-81 : Fixed the stock folder count update using an inventory observer. This observe other changes as well of interest to marketplace and should improve consistency in general --- indra/newview/llmarketplacefunctions.cpp | 66 +++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 5804bce819..c9e6623b72 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -31,6 +31,7 @@ #include "llagent.h" #include "llhttpclient.h" #include "llinventoryfunctions.h" +#include "llinventoryobserver.h" #include "llsdserialize.h" #include "lltimer.h" #include "lltrans.h" @@ -607,6 +608,54 @@ void LLMarketplaceInventoryImporter::updateImport() // // Direct Delivery : Marketplace tuples and data // +class LLMarketplaceInventoryObserver : public LLInventoryObserver +{ +public: + LLMarketplaceInventoryObserver() {} + virtual ~LLMarketplaceInventoryObserver() {} + virtual void changed(U32 mask); +}; + +void LLMarketplaceInventoryObserver::changed(U32 mask) +{ + // When things are changed in the inventory, this can trigger a host of changes in the marketplace listings folder: + // * stock counts changing : no copy items coming in and out will change the stock count on folders + // * version and listing folders : moving those might invalidate the marketplace data itself + // Since we should cannot raise inventory change while in the observer is called (the list will be cleared once observers are called) + // we need to raise a flag in the inventory to signal that things have been dirtied. + + // That's the only changes that really do make sense for marketplace to worry about + if ((mask & (LLInventoryObserver::INTERNAL | LLInventoryObserver::STRUCTURE)) != 0) + { + const std::set& changed_items = gInventory.getChangedIDs(); + + std::set::const_iterator id_it = changed_items.begin(); + std::set::const_iterator id_end = changed_items.end(); + for (;id_it != id_end; ++id_it) + { + LLInventoryObject* obj = gInventory.getObject(*id_it); + if (LLAssetType::AT_CATEGORY == obj->getType()) + { + // If it's a folder known to the marketplace, let's check it's in proper shape + if (LLMarketplaceData::instance().isListed(*id_it) || LLMarketplaceData::instance().isVersionFolder(*id_it)) + { + LLInventoryCategory* cat = (LLInventoryCategory*)(obj); + validate_marketplacelistings(cat); + } + } + else + { + // If it's not a category, it's an item... + LLInventoryItem* item = (LLInventoryItem*)(obj); + // If it's a no copy item, we may need to update the label count of marketplace listings + if (!item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID())) + { + LLMarketplaceData::instance().setDirtyCount(); + } + } + } + } +} // Tuple == Item LLMarketplaceTuple::LLMarketplaceTuple() : @@ -637,9 +686,17 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id, // Data map LLMarketplaceData::LLMarketplaceData() : mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED), - mStatusUpdatedSignal(NULL) + mStatusUpdatedSignal(NULL), + mDirtyCount(false) { mTestCurrentMarketplaceID = 1234567; + mInventoryObserver = new LLMarketplaceInventoryObserver; + gInventory.addObserver(mInventoryObserver); +} + +LLMarketplaceData::~LLMarketplaceData() +{ + gInventory.removeObserver(mInventoryObserver); } S32 LLMarketplaceData::getTestMarketplaceID() @@ -707,6 +764,7 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id) setListingID(folder_id,listing_id); update_marketplace_category(folder_id); + gInventory.notifyObservers(); return true; } @@ -729,6 +787,7 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, S32 listing_id setListingID(folder_id,listing_id); update_marketplace_category(folder_id); + gInventory.notifyObservers(); return true; } @@ -741,6 +800,7 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id) } mMarketplaceItems.erase(folder_id); update_marketplace_category(folder_id); + gInventory.notifyObservers(); return true; } @@ -842,6 +902,7 @@ bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) { (it->second).mListingId = listing_id; update_marketplace_category(folder_id); + gInventory.notifyObservers(); return true; } } @@ -861,6 +922,7 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID (it->second).mVersionFolderId = version_id; update_marketplace_category(old_version_id); update_marketplace_category(version_id); + gInventory.notifyObservers(); } return true; } @@ -874,6 +936,7 @@ bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); (it->second).mIsActive = activate; update_marketplace_category((it->second).mListingFolderId); + gInventory.notifyObservers(); return true; } // We need to iterate through the list to check it's not a version folder @@ -884,6 +947,7 @@ bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) { (it->second).mIsActive = activate; update_marketplace_category((it->second).mListingFolderId); + gInventory.notifyObservers(); return true; } it++; -- cgit v1.2.3 From eeeacd3c5f5ae29c5d13cd8cfd983e4308882b41 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 2 May 2014 17:09:49 -0700 Subject: DD-22 : WIP : Post listing using json, get listings using json (parsing commented out though as too risky and ugly) --- indra/newview/llmarketplacefunctions.cpp | 112 ++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index c9e6623b72..0db114b999 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -29,6 +29,7 @@ #include "llmarketplacefunctions.h" #include "llagent.h" +#include "llbufferstream.h" #include "llhttpclient.h" #include "llinventoryfunctions.h" #include "llinventoryobserver.h" @@ -36,10 +37,13 @@ #include "lltimer.h" #include "lltrans.h" #include "llviewercontrol.h" +#include "llviewerinventory.h" #include "llviewermedia.h" #include "llviewernetwork.h" #include "llviewerregion.h" +#include "reader.h" // JSON +#include "writer.h" // JSON // // Helpers @@ -154,6 +158,84 @@ public: llinfos << "Merov : completed with error, status = " << status << ", reason = " << reason << ", content = " << content << llendl; } } + + virtual void completedRaw(U32 status, + const std::string& reason, + const LLChannelDescriptors& channels, + const LLIOPipe::buffer_ptr_t& buffer) + { + LLBufferStream istr(channels, buffer.get()); + LLSD content; + // Merov : Absolutely godamn aweful parsing : this is to learn the rope + /* + std::ostringstream ostr; + while (istr.good()) + { + char buf[1024]; + istr.read(buf, sizeof(buf)); + ostr.write(buf, istr.gcount()); + } + std::string local_string = ostr.str(); + + Json::Value root; + Json::Reader reader; + if (!reader.parse(local_string,root)) + { + // The message is not a Json string so it's a regular load url request + llinfos << "Merov : Failed to parse the json string = " << local_string << llendl; + } + else + { + // 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 = " << local_string << llendl; + llinfos << "Merov : Parsed the json, id = " << id << llendl; + } + */ + // Merov : end parsing test + + // This will fail as json is not LLSD... To be deleted once we get the parsing right... + const bool emit_errors = false; + if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(content, istr, emit_errors)) + { + content["reason"] = reason; + } + + completed(status, reason, content); + } + + 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; + } + } +}; + +class LLSLMCreateListingsResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLSLMCreateListingsResponder); +public: + + LLSLMCreateListingsResponder() {} + + 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) { @@ -720,6 +802,31 @@ void LLMarketplaceData::getSLMListings() LLHTTPClient::get(getSLMConnectURL("/listings"), new LLSLMListingsResponder(), LLSD()); } +void LLMarketplaceData::postSLMListing(const LLUUID& folder_id) +{ + LLSD headers = LLSD::emptyMap(); + headers["Accept"] = "application/json"; + headers["Content-Type"] = "application/json"; + + LLViewerInventoryCategory* category = gInventory.getCategory(folder_id); + + std::ostringstream body; + body << "{ \"listing\": { \"name\":\"" << category->getName() << "\"," + << "\"inventory_info\":{\"listing_folder_id\":\"" << category->getUUID().asString() << "\"" + << "} } }"; + + // postRaw() takes ownership of the buffer and releases it later. + size_t size = body.str().size(); + U8 *data = new U8[size]; + memcpy(data, body.str().data(), size); + + std::string data_str = body.str(); + llinfos << "Merov : postSLMListing, body = " << data_str << ", header = " << headers << llendl; + + // Send request + LLHTTPClient::postRaw(getSLMConnectURL("/listings"), data, size, new LLSLMCreateListingsResponder(), headers); +} + std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) { std::string url(""); @@ -758,7 +865,10 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id) } mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); - // *TODO : Create the listing on SLM and get the ID (blocking?) + // 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(); -- cgit v1.2.3 From 5000749f6ba13448f13927dc778bef3f54260f31 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 5 May 2014 09:03:53 -0700 Subject: DD-22 : WIP : Clean up json code and test Json::Writer --- indra/newview/llmarketplacefunctions.cpp | 87 +++++++++++--------------------- 1 file changed, 29 insertions(+), 58 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 0db114b999..7dbd825d20 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -145,77 +145,38 @@ public: LLSLMListingsResponder() {} - 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; - // *TODO : Parse the Json body - //LLMarketplaceData::instance().parseListings(content); - } - else - { - llinfos << "Merov : completed with error, status = " << status << ", reason = " << reason << ", content = " << content << llendl; - } - } - virtual void completedRaw(U32 status, const std::string& reason, const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { LLBufferStream istr(channels, buffer.get()); - LLSD content; - // Merov : Absolutely godamn aweful parsing : this is to learn the rope - /* - std::ostringstream ostr; - while (istr.good()) - { - char buf[1024]; - istr.read(buf, sizeof(buf)); - ostr.write(buf, istr.gcount()); - } - std::string local_string = ostr.str(); + std::stringstream strstrm; + strstrm << istr.rdbuf(); + const std::string body = strstrm.str(); + + if (!isGoodStatus(status)) + { + std::string error_code = llformat("%d",status); + log_SLM_error("Get listings", status, reason, error_code, body); + return; + } Json::Value root; Json::Reader reader; - if (!reader.parse(local_string,root)) - { - // The message is not a Json string so it's a regular load url request - llinfos << "Merov : Failed to parse the json string = " << local_string << llendl; - } - else + if (!reader.parse(body,root)) { - // 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 = " << local_string << llendl; - llinfos << "Merov : Parsed the json, id = " << id << llendl; + log_SLM_error("Get listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + return; } - */ - // Merov : end parsing test - // This will fail as json is not LLSD... To be deleted once we get the parsing right... - const bool emit_errors = false; - if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(content, istr, emit_errors)) - { - content["reason"] = reason; - } - - completed(status, reason, content); + // 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; } - 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; - } - } }; class LLSLMCreateListingsResponder : public LLHTTPClient::Responder @@ -821,7 +782,17 @@ void LLMarketplaceData::postSLMListing(const LLUUID& folder_id) memcpy(data, body.str().data(), size); std::string data_str = body.str(); - llinfos << "Merov : postSLMListing, body = " << data_str << ", header = " << headers << llendl; + + Json::Value root; + Json::StyledWriter writer; + + root["listing"]["name"] = category->getName(); + root["listing"]["inventory_info"]["listing_folder_id"] = category->getUUID().asString(); + + std::string json_str = writer.write(root); + + llinfos << "Merov : postSLMListing, test body = " << data_str << ", size = " << size << llendl; + llinfos << "Merov : postSLMListing, json body = " << json_str << ", size = " << json_str.size() << llendl; // Send request LLHTTPClient::postRaw(getSLMConnectURL("/listings"), data, size, new LLSLMCreateListingsResponder(), headers); -- cgit v1.2.3 From 9c5d3de013921999b2dfb4994de91ab10308fd6a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 5 May 2014 13:24:48 -0700 Subject: DD-22 : WIP : Clean up use of Json::FastWriter, clean up logging function as well --- indra/newview/llmarketplacefunctions.cpp | 66 ++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 21 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 7dbd825d20..d71f328a28 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -104,7 +104,7 @@ LLSD getMarketplaceStringSubstitutions() // SLM Responders void log_SLM_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description) { - LL_WARNS("SLM") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << " (" << description << ")" << LL_ENDL; + LL_WARNS("SLM") << request << " request failed. status : " << status << ". reason : " << reason << ". code : " << code << ". description : " << description << LL_ENDL; } // Merov: This is a temporary hack used by dev while secondlife-staging is down... @@ -150,18 +150,18 @@ public: 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)) { std::string error_code = llformat("%d",status); - log_SLM_error("Get listings", status, reason, error_code, body); + log_SLM_error("Get listings", status, reason, error_code, ""); return; } + LLBufferStream istr(channels, buffer.get()); + std::stringstream strstrm; + strstrm << istr.rdbuf(); + const std::string body = strstrm.str(); + Json::Value root; Json::Reader reader; if (!reader.parse(body,root)) @@ -186,6 +186,38 @@ public: LLSLMCreateListingsResponder() {} + virtual void completedRaw(U32 status, + const std::string& reason, + const LLChannelDescriptors& channels, + const LLIOPipe::buffer_ptr_t& buffer) + { + if (!isGoodStatus(status)) + { + std::string error_code = llformat("%d",status); + log_SLM_error("Post listings", status, reason, error_code, ""); + return; + } + + LLBufferStream istr(channels, buffer.get()); + std::stringstream strstrm; + strstrm << istr.rdbuf(); + const std::string body = strstrm.str(); + + Json::Value root; + Json::Reader reader; + if (!reader.parse(body,root)) + { + log_SLM_error("Post listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + 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)) @@ -771,29 +803,21 @@ void LLMarketplaceData::postSLMListing(const LLUUID& folder_id) LLViewerInventoryCategory* category = gInventory.getCategory(folder_id); - std::ostringstream body; - body << "{ \"listing\": { \"name\":\"" << category->getName() << "\"," - << "\"inventory_info\":{\"listing_folder_id\":\"" << category->getUUID().asString() << "\"" - << "} } }"; - - // postRaw() takes ownership of the buffer and releases it later. - size_t size = body.str().size(); - U8 *data = new U8[size]; - memcpy(data, body.str().data(), size); - - std::string data_str = body.str(); - Json::Value root; - Json::StyledWriter writer; + Json::FastWriter writer; root["listing"]["name"] = category->getName(); root["listing"]["inventory_info"]["listing_folder_id"] = category->getUUID().asString(); std::string json_str = writer.write(root); - llinfos << "Merov : postSLMListing, test body = " << data_str << ", size = " << size << llendl; 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]; + memcpy(data, (U8*)(json_str.c_str()), size); + // Send request LLHTTPClient::postRaw(getSLMConnectURL("/listings"), data, size, new LLSLMCreateListingsResponder(), headers); } -- cgit v1.2.3 From 1a837c5719fa8dded91561a97839d2ed28e87553 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 5 May 2014 15:13:48 -0700 Subject: DD-22 : WIP : Completed GET and POST listings routes. Refactored the marketplace data code a bit as a result --- indra/newview/llmarketplacefunctions.cpp | 97 ++++++++++++++++---------------- 1 file changed, 50 insertions(+), 47 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') 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; -- cgit v1.2.3 From d24ff0bf0adeae1ce000551e3b9bdac528f5c162 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 5 May 2014 15:58:15 -0700 Subject: DD-22 : WIP : Implement putRaw() on LLHTTPClient --- indra/newview/llmarketplacefunctions.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 64df5a8396..2178ecaaa2 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -906,6 +906,7 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id) // Listing doesn't exist -> exit with error return false; } + // *TODO : Implement SLM API for deleting SLM records once it exists there... mMarketplaceItems.erase(folder_id); update_marketplace_category(folder_id); gInventory.notifyObservers(); -- cgit v1.2.3 From e916b47f12ba0e84ee6b1faed687b920e49633f8 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 6 May 2014 21:24:06 -0700 Subject: DD-22 : WIP : Implement the modify listing route. Made the code more readable and cleared old debug code --- indra/newview/llmarketplacefunctions.cpp | 172 ++++++++++++++++++++++++++----- 1 file changed, 149 insertions(+), 23 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 2178ecaaa2..15c1630a2a 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -104,19 +104,19 @@ LLSD getMarketplaceStringSubstitutions() // SLM Responders void log_SLM_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description) { - LL_WARNS("SLM") << request << " request failed. status : " << status << ". reason : " << reason << ". code : " << code << ". description : " << description << LL_ENDL; + LL_WARNS("SLM") << "Merov : " << request << " request failed. status : " << status << ", reason : " << reason << ", code : " << code << ", description : " << description << LL_ENDL; } // Merov: This is a temporary hack used by dev while secondlife-staging is down... // *TODO : Suppress that before shipping! -static bool sBypassMerchant = false; +static bool sBypassMerchant = true; -class LLSLMMerchantResponder : public LLHTTPClient::Responder +class LLSLMGetMerchantResponder : public LLHTTPClient::Responder { - LOG_CLASS(LLSLMMerchantResponder); + LOG_CLASS(LLSLMGetMerchantResponder); public: - LLSLMMerchantResponder() {} + LLSLMGetMerchantResponder() {} virtual void completed(U32 status, const std::string& reason, const LLSD& content) { } @@ -138,12 +138,12 @@ public: } }; -class LLSLMListingsResponder : public LLHTTPClient::Responder +class LLSLMGetListingsResponder : public LLHTTPClient::Responder { - LOG_CLASS(LLSLMListingsResponder); + LOG_CLASS(LLSLMGetListingsResponder); public: - LLSLMListingsResponder() {} + LLSLMGetListingsResponder() {} virtual void completedRaw(U32 status, const std::string& reason, @@ -152,8 +152,7 @@ public: { if (!isGoodStatus(status)) { - std::string error_code = llformat("%d",status); - log_SLM_error("Get listings", status, reason, error_code, ""); + log_SLM_error("Get listings", status, reason, "", ""); return; } @@ -169,7 +168,9 @@ public: log_SLM_error("Get listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - + + llinfos << "Merov : Get listings completedRaw : data = " << body << llendl; + // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -204,8 +205,7 @@ public: { if (!isGoodStatus(status)) { - std::string error_code = llformat("%d",status); - log_SLM_error("Post listings", status, reason, error_code, ""); + log_SLM_error("Post listings", status, reason, "", ""); return; } @@ -221,7 +221,9 @@ public: log_SLM_error("Post listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - + + llinfos << "Merov : Create listing completedRaw : data = " << body << llendl; + // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -241,6 +243,64 @@ public: } } }; + +class LLSLMUpdateListingsResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLSLMUpdateListingsResponder); +public: + + LLSLMUpdateListingsResponder() {} + + virtual void completedRaw(U32 status, + const std::string& reason, + const LLChannelDescriptors& channels, + const LLIOPipe::buffer_ptr_t& buffer) + { + if (!isGoodStatus(status)) + { + log_SLM_error("Put listings", status, reason, "", ""); + return; + } + + LLBufferStream istr(channels, buffer.get()); + std::stringstream strstrm; + strstrm << istr.rdbuf(); + const std::string body = strstrm.str(); + + Json::Value root; + Json::Reader reader; + if (!reader.parse(body,root)) + { + log_SLM_error("Put listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + return; + } + + llinfos << "Merov : Update listing completedRaw : data = " << 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 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().setActivation(folder_id, is_listed); + + it++; + } + } +}; // SLM Responders End /////////////////////////////////////////////////////////////////////////////// @@ -763,7 +823,6 @@ LLMarketplaceData::LLMarketplaceData() : mStatusUpdatedSignal(NULL), mDirtyCount(false) { - mTestCurrentMarketplaceID = 1234567; mInventoryObserver = new LLMarketplaceInventoryObserver; gInventory.addObserver(mInventoryObserver); } @@ -773,11 +832,6 @@ LLMarketplaceData::~LLMarketplaceData() gInventory.removeObserver(mInventoryObserver); } -S32 LLMarketplaceData::getTestMarketplaceID() -{ - return mTestCurrentMarketplaceID++; -} - void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& cb) { mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; @@ -786,12 +840,12 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& mStatusUpdatedSignal = new status_updated_signal_t(); } mStatusUpdatedSignal->connect(cb); - LLHTTPClient::get(getSLMConnectURL("/merchant"), new LLSLMMerchantResponder(), LLSD()); + LLHTTPClient::get(getSLMConnectURL("/merchant"), new LLSLMGetMerchantResponder(), LLSD()); } void LLMarketplaceData::getSLMListings() { - LLHTTPClient::get(getSLMConnectURL("/listings"), new LLSLMListingsResponder(), LLSD()); + LLHTTPClient::get(getSLMConnectURL("/listings"), new LLSLMGetListingsResponder(), LLSD()); } void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) @@ -819,6 +873,36 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) LLHTTPClient::postRaw(getSLMConnectURL("/listings"), data, size, new LLSLMCreateListingsResponder(), headers); } +void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed) +{ + 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"]["is_listed"] = is_listed; + 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("/listing/") + llformat("%d",listing_id); + llinfos << "Merov : updating listing : " << url << ", data = " << json_str << llendl; + LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(), headers); +} + +// PUT /associate_inventory/:listing_folder_id/:version_folder_id/:listing_id + std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) { std::string url(""); @@ -847,7 +931,8 @@ void LLMarketplaceData::setSLMStatus(U32 status) } } -// Creation / Deletion +// Creation / Deletion / Update +// Methods publicly called bool LLMarketplaceData::createListing(const LLUUID& folder_id) { if (isListed(folder_id)) @@ -862,6 +947,47 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_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 + 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; + } + + LLUUID version_uuid = getVersionFolderID(listing_uuid); + + // Post the listing update request to SLM + updateSLMListing(listing_uuid, listing_id, version_uuid, activate); + + return true; +} + +bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& version_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; + } + + bool is_listed = getActivationState(listing_uuid); + + // Post the listing update request to SLM + updateSLMListing(listing_uuid, listing_id, version_id, is_listed); + + return true; +} + +// Methods privately called or called by SLM responders to perform changes bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed) { if (isListed(folder_id)) -- cgit v1.2.3 From bd0d62c339d197ec2fa50cc642a864071677dc3a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 7 May 2014 14:51:36 -0700 Subject: DD-22 : WIP : Partial implementation of PUT associate_listing --- indra/newview/llmarketplacefunctions.cpp | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 15c1630a2a..701d341753 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -301,6 +301,29 @@ public: } } }; + +class LLSLMAssociateListingsResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLSLMAssociateListingsResponder); +public: + + LLSLMAssociateListingsResponder() {} + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) { } + + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); + } + else + { + log_SLM_error("Get merchant", status, reason, content.get("error_code"), content.get("error_description")); + } + } +}; + // SLM Responders End /////////////////////////////////////////////////////////////////////////////// @@ -902,6 +925,23 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id } // PUT /associate_inventory/:listing_folder_id/:version_folder_id/:listing_id +void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id) +{ + LLSD headers = LLSD::emptyMap(); + headers["Accept"] = "application/json"; + headers["Content-Type"] = "application/json"; + + LLSD data = LLSD::emptyMap(); + + // Send request + std::string url = getSLMConnectURL("/associate_inventory/") + + folder_id.asString() + "/" + + version_id.asString() + "/" + + llformat("%d",listing_id); + + llinfos << "Merov : associate listing : " << url << llendl; + LLHTTPClient::put(url, data, new LLSLMAssociateListingsResponder(), headers); +} std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) { -- cgit v1.2.3 From 00c1094c7d230fdf0670a7e8c2218bb6b1a677ca Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 7 May 2014 16:44:14 -0700 Subject: DD-22 : WIP : Completed the associate_listing route, take edit_url into account and rewrite getListingURL() --- indra/newview/llmarketplacefunctions.cpp | 157 +++++++++++++++++++++---------- 1 file changed, 109 insertions(+), 48 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 701d341753..74ea453c50 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -109,7 +109,7 @@ void log_SLM_error(const std::string& request, U32 status, const std::string& re // Merov: This is a temporary hack used by dev while secondlife-staging is down... // *TODO : Suppress that before shipping! -static bool sBypassMerchant = true; +static bool sBypassMerchant = false; class LLSLMGetMerchantResponder : public LLHTTPClient::Responder { @@ -180,12 +180,14 @@ public: 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); LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); + LLMarketplaceData::instance().setEditURL(folder_id, edit_url); it++; } } @@ -233,12 +235,14 @@ public: 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); LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); + LLMarketplaceData::instance().setEditURL(folder_id, edit_url); it++; } } @@ -286,6 +290,7 @@ public: 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(); @@ -296,6 +301,7 @@ public: LLMarketplaceData::instance().setListingID(folder_id, listing_id); LLMarketplaceData::instance().setVersionFolderID(folder_id, version_id); LLMarketplaceData::instance().setActivation(folder_id, is_listed); + LLMarketplaceData::instance().setEditURL(folder_id, edit_url); it++; } @@ -311,16 +317,61 @@ public: virtual void completed(U32 status, const std::string& reason, const LLSD& content) { } - void completedHeader(U32 status, const std::string& reason, const LLSD& content) + virtual void completedRaw(U32 status, + const std::string& reason, + const LLChannelDescriptors& channels, + const LLIOPipe::buffer_ptr_t& buffer) { - if (isGoodStatus(status)) - { - LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); - } - else + if (!isGoodStatus(status)) { - log_SLM_error("Get merchant", status, reason, content.get("error_code"), content.get("error_description")); + log_SLM_error("Associate listings", status, reason, "", ""); + return; } + + LLBufferStream istr(channels, buffer.get()); + std::stringstream strstrm; + strstrm << istr.rdbuf(); + const std::string body = strstrm.str(); + + Json::Value root; + Json::Reader reader; + if (!reader.parse(body,root)) + { + log_SLM_error("Associate listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + return; + } + + llinfos << "Merov : Update listing completedRaw : data = " << 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); + + // 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); + LLMarketplaceData::instance().setEditURL(folder_id, edit_url); + it++; + } } }; @@ -819,7 +870,8 @@ LLMarketplaceTuple::LLMarketplaceTuple() : mListingFolderId(), mListingId(0), mVersionFolderId(), - mIsActive(false) + mIsActive(false), + mEditURL("") { } @@ -827,7 +879,8 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id) : mListingFolderId(folder_id), mListingId(0), mVersionFolderId(), - mIsActive(false) + mIsActive(false), + mEditURL("") { } @@ -835,7 +888,8 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id, mListingFolderId(folder_id), mListingId(listing_id), mVersionFolderId(version_id), - mIsActive(is_listed) + mIsActive(is_listed), + mEditURL("") { } @@ -924,23 +978,31 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(), headers); } -// PUT /associate_inventory/:listing_folder_id/:version_folder_id/:listing_id void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id) { LLSD headers = LLSD::emptyMap(); headers["Accept"] = "application/json"; headers["Content-Type"] = "application/json"; - LLSD data = LLSD::emptyMap(); + 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(); - // Send request - std::string url = getSLMConnectURL("/associate_inventory/") - + folder_id.asString() + "/" - + version_id.asString() + "/" - + llformat("%d",listing_id); + std::string json_str = writer.write(root); - llinfos << "Merov : associate listing : " << url << llendl; - LLHTTPClient::put(url, data, new LLSLMAssociateListingsResponder(), headers); + // 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); + llinfos << "Merov : associate listing : " << url << ", data = " << json_str << llendl; + LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(), headers); } std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) @@ -1027,39 +1089,31 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& return true; } -// Methods privately called or called by SLM responders to perform changes -bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed) +bool LLMarketplaceData::associateListing(const LLUUID& folder_id, S32 listing_id) { 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(); + + // Post the listing update request to SLM + LLUUID version_id; + associateSLMListing(folder_id, listing_id, version_id); + return true; } -bool LLMarketplaceData::associateListing(const LLUUID& folder_id, S32 listing_id) +// Methods privately called or called by SLM responders to perform changes +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); - - // Check that the listing ID is not already associated to some other record - LLUUID old_listing = 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); - } - - setListingID(folder_id,listing_id); + mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id, listing_id, version_id, is_listed); + update_marketplace_category(folder_id); gInventory.notifyObservers(); return true; @@ -1150,19 +1204,11 @@ bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) std::string LLMarketplaceData::getListingURL(const LLUUID& folder_id) { - // Get the listing id (i.e. go up the hierarchy to find the listing folder - // URL format will be something like : https://marketplace.secondlife.com/p/listing/ - std::string marketplace_url = getMarketplaceURL("MarketplaceURL"); - 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) - { - marketplace_url += llformat("p/listing/%d",listing_id); - } - return marketplace_url; + marketplace_items_list_t::iterator it = mMarketplaceItems.find(listing_uuid); + return (it == mMarketplaceItems.end() ? "" : (it->second).mEditURL); } // Modifiers @@ -1230,4 +1276,19 @@ bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) return false; } +bool LLMarketplaceData::setEditURL(const LLUUID& folder_id, const std::string& edit_url) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + if (it == mMarketplaceItems.end()) + { + return false; + } + else + { + (it->second).mEditURL = edit_url; + return true; + } +} + + -- cgit v1.2.3 From 4d14e1ca9600d7ca7023edbd3827fbff994c8110 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 8 May 2014 15:56:38 -0700 Subject: DD-22 : WIP : Cleanep up the class definition, seting methods private and better isolate calls leading to HTTP requests --- indra/newview/llmarketplacefunctions.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 74ea453c50..f4b4d8aa27 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1049,6 +1049,26 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_id) return true; } +bool LLMarketplaceData::clearListing(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; + } + + // Update the SLM Server so that this listing is not active anymore + // *TODO : use deleteSLMListing() + deleteListing(listing_uuid); + updateSLMListing(listing_uuid, listing_id, LLUUID::null, false); + + 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 @@ -1126,8 +1146,8 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id) // Listing doesn't exist -> exit with error return false; } - // *TODO : Implement SLM API for deleting SLM records once it exists there... mMarketplaceItems.erase(folder_id); + update_marketplace_category(folder_id); gInventory.notifyObservers(); return true; -- cgit v1.2.3 From b4ddacaa5a3a6a46c38e13a52254c16956e9ed5a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 8 May 2014 21:26:07 -0700 Subject: DD-22 : WIP : More clean up of marketplace classes, rationalize methods naming --- indra/newview/llmarketplacefunctions.cpp | 116 ++++++++++++++----------------- 1 file changed, 51 insertions(+), 65 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index f4b4d8aa27..a3cc3cd0b4 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -187,7 +187,7 @@ public: LLUUID folder_id(folder_uuid_string); LLUUID version_id(version_uuid_string); LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); - LLMarketplaceData::instance().setEditURL(folder_id, edit_url); + LLMarketplaceData::instance().setListingURL(folder_id, edit_url); it++; } } @@ -242,7 +242,7 @@ public: LLUUID folder_id(folder_uuid_string); LLUUID version_id(version_uuid_string); LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); - LLMarketplaceData::instance().setEditURL(folder_id, edit_url); + LLMarketplaceData::instance().setListingURL(folder_id, edit_url); it++; } } @@ -300,8 +300,8 @@ public: // Update that listing LLMarketplaceData::instance().setListingID(folder_id, listing_id); LLMarketplaceData::instance().setVersionFolderID(folder_id, version_id); - LLMarketplaceData::instance().setActivation(folder_id, is_listed); - LLMarketplaceData::instance().setEditURL(folder_id, edit_url); + LLMarketplaceData::instance().setActivationState(folder_id, is_listed); + LLMarketplaceData::instance().setListingURL(folder_id, edit_url); it++; } @@ -369,7 +369,7 @@ public: // Add the new association LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); - LLMarketplaceData::instance().setEditURL(folder_id, edit_url); + LLMarketplaceData::instance().setListingURL(folder_id, edit_url); it++; } } @@ -829,8 +829,8 @@ void LLMarketplaceInventoryObserver::changed(U32 mask) // When things are changed in the inventory, this can trigger a host of changes in the marketplace listings folder: // * stock counts changing : no copy items coming in and out will change the stock count on folders // * version and listing folders : moving those might invalidate the marketplace data itself - // Since we should cannot raise inventory change while in the observer is called (the list will be cleared once observers are called) - // we need to raise a flag in the inventory to signal that things have been dirtied. + // Since we should cannot raise inventory change while the observer is called (the list will be cleared + // once observers are called) we need to raise a flag in the inventory to signal that things have been dirtied. // That's the only changes that really do make sense for marketplace to worry about if ((mask & (LLInventoryObserver::INTERNAL | LLInventoryObserver::STRUCTURE)) != 0) @@ -920,6 +920,7 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& LLHTTPClient::get(getSLMConnectURL("/merchant"), new LLSLMGetMerchantResponder(), LLSD()); } +// Get/Post/Put requests to the SLM Server using the SLM API void LLMarketplaceData::getSLMListings() { LLHTTPClient::get(getSLMConnectURL("/listings"), new LLSLMGetListingsResponder(), LLSD()); @@ -1020,7 +1021,6 @@ std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) } url += route; } - llinfos << "Merov : Testing getSLMConnectURL : " << url << llendl; return url; } @@ -1081,7 +1081,7 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) return false; } - LLUUID version_uuid = getVersionFolderID(listing_uuid); + LLUUID version_uuid = getVersionFolder(listing_uuid); // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_uuid, activate); @@ -1181,7 +1181,7 @@ S32 LLMarketplaceData::getListingID(const LLUUID& folder_id) return (it == mMarketplaceItems.end() ? 0 : (it->second).mListingId); } -LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) +LLUUID LLMarketplaceData::getVersionFolder(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); return (it == mMarketplaceItems.end() ? LLUUID::null : (it->second).mVersionFolderId); @@ -1202,6 +1202,15 @@ LLUUID LLMarketplaceData::getListingFolder(S32 listing_id) return LLUUID::null; } +std::string LLMarketplaceData::getListingURL(const LLUUID& folder_id) +{ + S32 depth = depth_nesting_in_marketplace(folder_id); + LLUUID listing_uuid = nested_parent_id(folder_id, depth); + + marketplace_items_list_t::iterator it = mMarketplaceItems.find(listing_uuid); + return (it == mMarketplaceItems.end() ? "" : (it->second).mEditURL); +} + bool LLMarketplaceData::isListed(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); @@ -1222,16 +1231,7 @@ bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) return false; } -std::string LLMarketplaceData::getListingURL(const LLUUID& folder_id) -{ - S32 depth = depth_nesting_in_marketplace(folder_id); - LLUUID listing_uuid = nested_parent_id(folder_id, depth); - - marketplace_items_list_t::iterator it = mMarketplaceItems.find(listing_uuid); - return (it == mMarketplaceItems.end() ? "" : (it->second).mEditURL); -} - -// Modifiers +// Private Modifiers bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); @@ -1239,13 +1239,12 @@ bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) { return false; } - else - { - (it->second).mListingId = listing_id; - update_marketplace_category(folder_id); - gInventory.notifyObservers(); - return true; - } + + (it->second).mListingId = listing_id; + + update_marketplace_category(folder_id); + gInventory.notifyObservers(); + return true; } bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID& version_id) @@ -1255,59 +1254,46 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID { return false; } - else + + LLUUID old_version_id = (it->second).mVersionFolderId; + if (old_version_id == version_id) { - LLUUID old_version_id = (it->second).mVersionFolderId; - if (old_version_id != version_id) - { - (it->second).mVersionFolderId = version_id; - update_marketplace_category(old_version_id); - update_marketplace_category(version_id); - gInventory.notifyObservers(); - } - return true; + return false; } + + (it->second).mVersionFolderId = version_id; + + update_marketplace_category(old_version_id); + update_marketplace_category(version_id); + gInventory.notifyObservers(); + return true; } -bool LLMarketplaceData::setActivation(const LLUUID& folder_id, bool activate) +bool LLMarketplaceData::setActivationState(const LLUUID& folder_id, bool activate) { - // Listing folder case - if (isListed(folder_id)) - { - marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); - (it->second).mIsActive = activate; - update_marketplace_category((it->second).mListingFolderId); - gInventory.notifyObservers(); - return true; - } - // We need to iterate through the list to check it's not a version folder - marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); - while (it != mMarketplaceItems.end()) + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + if (it == mMarketplaceItems.end()) { - if ((it->second).mVersionFolderId == folder_id) - { - (it->second).mIsActive = activate; - update_marketplace_category((it->second).mListingFolderId); - gInventory.notifyObservers(); - return true; - } - it++; + return false; } - return false; + + (it->second).mIsActive = activate; + + update_marketplace_category((it->second).mListingFolderId); + gInventory.notifyObservers(); + return true; } -bool LLMarketplaceData::setEditURL(const LLUUID& folder_id, const std::string& edit_url) +bool LLMarketplaceData::setListingURL(const LLUUID& folder_id, const std::string& edit_url) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); if (it == mMarketplaceItems.end()) { return false; } - else - { - (it->second).mEditURL = edit_url; - return true; - } + + (it->second).mEditURL = edit_url; + return true; } -- cgit v1.2.3 From 4ffa30b533979a2214eb3996c19435f1cd16bc2a Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 9 May 2014 16:48:51 -0700 Subject: DD-22 : WIP : Implement deleteSLMListing() to cover the Delete /listing/:listing_id route. Avoid recursive calls in deleteListing() --- indra/newview/llmarketplacefunctions.cpp | 121 ++++++++++++++++++++++++++----- 1 file changed, 103 insertions(+), 18 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index a3cc3cd0b4..5aab7aa6d3 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -186,8 +186,12 @@ public: LLUUID folder_id(folder_uuid_string); LLUUID version_id(version_uuid_string); - LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); - LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + if (folder_id.notNull()) + { + LLMarketplaceData::instance().deleteListing(folder_id,false); + LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); + LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + } it++; } } @@ -260,17 +264,17 @@ public: const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { - if (!isGoodStatus(status)) - { - log_SLM_error("Put listings", status, reason, "", ""); - return; - } - LLBufferStream istr(channels, buffer.get()); std::stringstream strstrm; strstrm << istr.rdbuf(); const std::string body = strstrm.str(); + if (!isGoodStatus(status)) + { + log_SLM_error("Put listings", status, reason, "", body); + return; + } + Json::Value root; Json::Reader reader; if (!reader.parse(body,root)) @@ -279,7 +283,7 @@ public: return; } - llinfos << "Merov : Update listing completedRaw : data = " << body << llendl; + llinfos << "Merov : Update listing completedRaw : status = " << status << ", reason = " << reason << ", body = " << body << llendl; // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -341,7 +345,7 @@ public: return; } - llinfos << "Merov : Update listing completedRaw : data = " << body << llendl; + llinfos << "Merov : Associate listing completedRaw : data = " << body << llendl; // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -375,6 +379,65 @@ public: } }; +class LLSLMDeleteListingsResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLSLMDeleteListingsResponder); +public: + + LLSLMDeleteListingsResponder() {} + + virtual void completed(U32 status, const std::string& reason, const LLSD& content) { } + + 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("Delete listings", status, reason, "", body); + return; + } + + Json::Value root; + Json::Reader reader; + if (!reader.parse(body,root)) + { + log_SLM_error("Delete listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + return; + } + + llinfos << "Merov : Delete listing completedRaw : data = " << 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(); + std::string folder_uuid_string = listing["inventory_info"]["listing_folder_id"].asString(); + + LLUUID folder_id(folder_uuid_string); + + // Check that the listing ID is associated to the correct folder + LLUUID old_listing = LLMarketplaceData::instance().getListingFolder(listing_id); + if (old_listing == folder_id) + { + LLMarketplaceData::instance().deleteListing(folder_id); + } + + it++; + } + } +}; + // SLM Responders End /////////////////////////////////////////////////////////////////////////////// @@ -1006,6 +1069,18 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(), headers); } +void LLMarketplaceData::deleteSLMListing(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 : delete listing : " << url << llendl; + LLHTTPClient::del(url, new LLSLMDeleteListingsResponder(), headers); +} + std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) { std::string url(""); @@ -1051,20 +1126,27 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_id) bool LLMarketplaceData::clearListing(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 = nested_parent_id(folder_id, depth); + 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; } - // Update the SLM Server so that this listing is not active anymore - // *TODO : use deleteSLMListing() - deleteListing(listing_uuid); - updateSLMListing(listing_uuid, listing_id, LLUUID::null, false); + llinfos << "Merov : clearListing, folder id = " << folder_id << ", listing uuid = " << listing_uuid << ", listing id = " << listing_id << ", depth = " << depth << llendl; + + // Update the SLM Server so that this listing is deleted (actually, archived...) + deleteSLMListing(listing_id); return true; } @@ -1139,7 +1221,7 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, cons return true; } -bool LLMarketplaceData::deleteListing(const LLUUID& folder_id) +bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update_slm) { if (!isListed(folder_id)) { @@ -1148,8 +1230,11 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id) } mMarketplaceItems.erase(folder_id); - update_marketplace_category(folder_id); - gInventory.notifyObservers(); + if (update_slm) + { + update_marketplace_category(folder_id); + gInventory.notifyObservers(); + } return true; } -- cgit v1.2.3 From 03679c227e0715d51229250c006f9c407bd9d923 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 12 May 2014 13:41:38 -0700 Subject: DD-22 : WIP : Implement the GET /listing/:listing route to complete the SLM API coverage. Will be used only in test. --- indra/newview/llmarketplacefunctions.cpp | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') 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 -- cgit v1.2.3 From acdd70688bf2c53f50cb39781179bbffcb2a400d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 12 May 2014 14:58:17 -0700 Subject: DD-89 : Add a MarketplaceListingsLogging setting to get SLM API logs. DD-22 : Fixed the delete /listing route --- indra/newview/llmarketplacefunctions.cpp | 91 +++++++++++++++++--------------- 1 file changed, 49 insertions(+), 42 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index ff43d82f03..d8c25f1c02 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -102,9 +102,19 @@ LLSD getMarketplaceStringSubstitutions() /////////////////////////////////////////////////////////////////////////////// // SLM Responders -void log_SLM_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description) +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") << "Merov : " << request << " request failed. status : " << status << ", reason : " << reason << ", code : " << code << ", description : " << description << LL_ENDL; + if (gSavedSettings.getBOOL("MarketplaceListingsLogging")) + { + LL_WARNS("SLM") << "SLM API : Responder to " << request << ". status : " << status << ", reason : " << reason << ", code : " << code << ", description : " << description << LL_ENDL; + } +} +void log_SLM_warning(const std::string& request, const std::string& url, const std::string& data) +{ + if (gSavedSettings.getBOOL("MarketplaceListingsLogging")) + { + LL_WARNS("SLM") << "SLM API : Sending " << request << ". url : " << url << ", data : " << data << LL_ENDL; + } } // Merov: This is a temporary hack used by dev while secondlife-staging is down... @@ -124,15 +134,17 @@ public: { if (isGoodStatus(status) || sBypassMerchant) { + log_SLM_warning("Get /merchant", status, reason, "", "User is a merchant"); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); } else if (status == SLMErrorCodes::SLM_NOT_FOUND) { + log_SLM_warning("Get /merchant", status, reason, "", "User is not a merchant"); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); } else { - log_SLM_error("Get merchant", status, reason, content.get("error_code"), content.get("error_description")); + log_SLM_warning("Get /merchant", status, reason, content.get("error_code"), content.get("error_description")); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_CONNECTION_FAILURE); } } @@ -152,7 +164,7 @@ public: { if (!isGoodStatus(status)) { - log_SLM_error("Get listings", status, reason, "", ""); + log_SLM_warning("Get /listings", status, reason, "", ""); return; } @@ -165,11 +177,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_error("Get listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Get /listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - llinfos << "Merov : Get listings completedRaw : data = " << body << llendl; + log_SLM_warning("Get /listings", status, reason, "", body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -211,7 +223,7 @@ public: { if (!isGoodStatus(status)) { - log_SLM_error("Post listings", status, reason, "", ""); + log_SLM_warning("Post /listings", status, reason, "", ""); return; } @@ -224,11 +236,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_error("Post listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Post /listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - llinfos << "Merov : Create listing completedRaw : data = " << body << llendl; + log_SLM_warning("Post /listings", status, reason, "", body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -271,7 +283,7 @@ public: if (!isGoodStatus(status)) { - log_SLM_error("Get listing", status, reason, "", body); + log_SLM_warning("Get /listing", status, reason, "", body); return; } @@ -279,11 +291,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_error("Get listing", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Get /listing", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - llinfos << "Merov : Get listing completedRaw : status = " << status << ", reason = " << reason << ", body = " << body << llendl; + log_SLM_warning("Get /listing", status, reason, "", body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -331,7 +343,7 @@ public: if (!isGoodStatus(status)) { - log_SLM_error("Put listings", status, reason, "", body); + log_SLM_warning("Put /listing", status, reason, "", body); return; } @@ -339,11 +351,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_error("Put listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Put /listing", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - llinfos << "Merov : Update listing completedRaw : status = " << status << ", reason = " << reason << ", body = " << body << llendl; + log_SLM_warning("Put /listing", status, reason, "", body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -388,7 +400,7 @@ public: { if (!isGoodStatus(status)) { - log_SLM_error("Associate listings", status, reason, "", ""); + log_SLM_warning("Put /associate_inventory", status, reason, "", ""); return; } @@ -401,11 +413,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_error("Associate listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Put /associate_inventory", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - llinfos << "Merov : Associate listing completedRaw : data = " << body << llendl; + log_SLM_warning("Put /associate_inventory", status, reason, "", body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -460,7 +472,7 @@ public: if (!isGoodStatus(status)) { - log_SLM_error("Delete listings", status, reason, "", body); + log_SLM_warning("Delete /listing", status, reason, "", body); return; } @@ -468,11 +480,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_error("Delete listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Delete /listing", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - llinfos << "Merov : Delete listing completedRaw : data = " << body << llendl; + log_SLM_warning("Delete /listing", status, reason, "", body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -482,16 +494,8 @@ public: Json::Value listing = *it; int listing_id = listing["id"].asInt(); - std::string folder_uuid_string = listing["inventory_info"]["listing_folder_id"].asString(); - - LLUUID folder_id(folder_uuid_string); - - // Check that the listing ID is associated to the correct folder - LLUUID old_listing = LLMarketplaceData::instance().getListingFolder(listing_id); - if (old_listing == folder_id) - { - LLMarketplaceData::instance().deleteListing(folder_id); - } + LLUUID folder_id = LLMarketplaceData::instance().getListingFolder(listing_id); + LLMarketplaceData::instance().deleteListing(folder_id); it++; } @@ -1040,13 +1044,18 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& mStatusUpdatedSignal = new status_updated_signal_t(); } mStatusUpdatedSignal->connect(cb); - LLHTTPClient::get(getSLMConnectURL("/merchant"), new LLSLMGetMerchantResponder(), LLSD()); + + std::string url = getSLMConnectURL("/merchant"); + log_SLM_warning("LLHTTPClient::get", url, ""); + LLHTTPClient::get(url, new LLSLMGetMerchantResponder(), LLSD()); } // Get/Post/Put requests to the SLM Server using the SLM API void LLMarketplaceData::getSLMListings() { - LLHTTPClient::get(getSLMConnectURL("/listings"), new LLSLMGetListingsResponder(), LLSD()); + std::string url = getSLMConnectURL("/listings"); + log_SLM_warning("LLHTTPClient::get", url, ""); + LLHTTPClient::get(url, new LLSLMGetListingsResponder(), LLSD()); } void LLMarketplaceData::getSLMListing(S32 listing_id) @@ -1057,7 +1066,7 @@ void LLMarketplaceData::getSLMListing(S32 listing_id) // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); - llinfos << "Merov : get listing : " << url << llendl; + log_SLM_warning("LLHTTPClient::get", url, ""); LLHTTPClient::get(url, new LLSLMGetListingResponder(), headers); } @@ -1083,7 +1092,9 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) memcpy(data, (U8*)(json_str.c_str()), size); // Send request - LLHTTPClient::postRaw(getSLMConnectURL("/listings"), data, size, new LLSLMCreateListingsResponder(), headers); + std::string url = getSLMConnectURL("/listings"); + log_SLM_warning("LLHTTPClient::postRaw", url, json_str); + LLHTTPClient::postRaw(url, data, size, new LLSLMCreateListingsResponder(), headers); } void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed) @@ -1110,7 +1121,7 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); - llinfos << "Merov : updating listing : " << url << ", data = " << json_str << llendl; + log_SLM_warning("LLHTTPClient::putRaw", url, json_str); LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(), headers); } @@ -1137,7 +1148,7 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing // Send request std::string url = getSLMConnectURL("/associate_inventory/") + llformat("%d",listing_id); - llinfos << "Merov : associate listing : " << url << ", data = " << json_str << llendl; + log_SLM_warning("LLHTTPClient::putRaw", url, json_str); LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(), headers); } @@ -1149,7 +1160,7 @@ void LLMarketplaceData::deleteSLMListing(S32 listing_id) // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); - llinfos << "Merov : delete listing : " << url << llendl; + log_SLM_warning("LLHTTPClient::del", url, ""); LLHTTPClient::del(url, new LLSLMDeleteListingsResponder(), headers); } @@ -1215,8 +1226,6 @@ bool LLMarketplaceData::clearListing(const LLUUID& folder_id) return false; } - llinfos << "Merov : clearListing, folder id = " << folder_id << ", listing uuid = " << listing_uuid << ", listing id = " << listing_id << ", depth = " << depth << llendl; - // Update the SLM Server so that this listing is deleted (actually, archived...) deleteSLMListing(listing_id); @@ -1242,8 +1251,6 @@ bool LLMarketplaceData::getListing(const LLUUID& folder_id) return false; } - llinfos << "Merov : getListing, listing uuid = " << listing_uuid << ", listing id = " << listing_id << ", depth = " << depth << llendl; - // Get listing data from SLM getSLMListing(listing_id); -- cgit v1.2.3 From 659be5d3e7ece89a1a1eb0fb8ea9d3666300ea80 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 13 May 2014 14:34:26 -0700 Subject: DD-89 : Separate warnings from infos in the SLM API log. Infos are controled by a setting. Warning are always logged. --- indra/newview/llmarketplacefunctions.cpp | 40 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d8c25f1c02..957e96e866 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -103,17 +103,21 @@ LLSD getMarketplaceStringSubstitutions() /////////////////////////////////////////////////////////////////////////////// // 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; +} +void log_SLM_infos(const std::string& request, U32 status, const std::string& body) { if (gSavedSettings.getBOOL("MarketplaceListingsLogging")) { - LL_WARNS("SLM") << "SLM API : Responder to " << request << ". status : " << status << ", reason : " << reason << ", code : " << code << ", description : " << description << LL_ENDL; + LL_INFOS("SLM") << "SLM API : Responder to " << request << ". status : " << status << ", body or description : " << body << LL_ENDL; } } -void log_SLM_warning(const std::string& request, const std::string& url, const std::string& data) +void log_SLM_infos(const std::string& request, const std::string& url, const std::string& body) { if (gSavedSettings.getBOOL("MarketplaceListingsLogging")) { - LL_WARNS("SLM") << "SLM API : Sending " << request << ". url : " << url << ", data : " << data << LL_ENDL; + LL_INFOS("SLM") << "SLM API : Sending " << request << ". url : " << url << ", body : " << body << LL_ENDL; } } @@ -134,12 +138,12 @@ public: { if (isGoodStatus(status) || sBypassMerchant) { - log_SLM_warning("Get /merchant", status, reason, "", "User is a merchant"); + log_SLM_infos("Get /merchant", status, "User is a merchant"); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); } else if (status == SLMErrorCodes::SLM_NOT_FOUND) { - log_SLM_warning("Get /merchant", status, reason, "", "User is not a merchant"); + log_SLM_infos("Get /merchant", status, "User is not a merchant"); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); } else @@ -181,7 +185,7 @@ public: return; } - log_SLM_warning("Get /listings", status, reason, "", body); + log_SLM_infos("Get /listings", status, body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -240,7 +244,7 @@ public: return; } - log_SLM_warning("Post /listings", status, reason, "", body); + log_SLM_infos("Post /listings", status, body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -295,7 +299,7 @@ public: return; } - log_SLM_warning("Get /listing", status, reason, "", body); + log_SLM_infos("Get /listing", status, body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -355,7 +359,7 @@ public: return; } - log_SLM_warning("Put /listing", status, reason, "", body); + log_SLM_infos("Put /listing", status, body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -417,7 +421,7 @@ public: return; } - log_SLM_warning("Put /associate_inventory", status, reason, "", body); + log_SLM_infos("Put /associate_inventory", status, body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -484,7 +488,7 @@ public: return; } - log_SLM_warning("Delete /listing", status, reason, "", body); + log_SLM_infos("Delete /listing", status, body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -1046,7 +1050,7 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& mStatusUpdatedSignal->connect(cb); std::string url = getSLMConnectURL("/merchant"); - log_SLM_warning("LLHTTPClient::get", url, ""); + log_SLM_infos("LLHTTPClient::get", url, ""); LLHTTPClient::get(url, new LLSLMGetMerchantResponder(), LLSD()); } @@ -1054,7 +1058,7 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& void LLMarketplaceData::getSLMListings() { std::string url = getSLMConnectURL("/listings"); - log_SLM_warning("LLHTTPClient::get", url, ""); + log_SLM_infos("LLHTTPClient::get", url, ""); LLHTTPClient::get(url, new LLSLMGetListingsResponder(), LLSD()); } @@ -1066,7 +1070,7 @@ void LLMarketplaceData::getSLMListing(S32 listing_id) // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); - log_SLM_warning("LLHTTPClient::get", url, ""); + log_SLM_infos("LLHTTPClient::get", url, ""); LLHTTPClient::get(url, new LLSLMGetListingResponder(), headers); } @@ -1093,7 +1097,7 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) // Send request std::string url = getSLMConnectURL("/listings"); - log_SLM_warning("LLHTTPClient::postRaw", url, json_str); + log_SLM_infos("LLHTTPClient::postRaw", url, json_str); LLHTTPClient::postRaw(url, data, size, new LLSLMCreateListingsResponder(), headers); } @@ -1121,7 +1125,7 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); - log_SLM_warning("LLHTTPClient::putRaw", url, json_str); + log_SLM_infos("LLHTTPClient::putRaw", url, json_str); LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(), headers); } @@ -1148,7 +1152,7 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing // Send request std::string url = getSLMConnectURL("/associate_inventory/") + llformat("%d",listing_id); - log_SLM_warning("LLHTTPClient::putRaw", url, json_str); + log_SLM_infos("LLHTTPClient::putRaw", url, json_str); LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(), headers); } @@ -1160,7 +1164,7 @@ void LLMarketplaceData::deleteSLMListing(S32 listing_id) // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); - log_SLM_warning("LLHTTPClient::del", url, ""); + log_SLM_infos("LLHTTPClient::del", url, ""); LLHTTPClient::del(url, new LLSLMDeleteListingsResponder(), headers); } -- cgit v1.2.3 From b9407199462c0b56a7d49c2e19657e87ec149d8c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 29 May 2014 16:56:15 -0700 Subject: DD-84 : WIP : Get DAMA to display for drag and drop. Note that, because of current SLM issues, it works on version folders, active or not. --- indra/newview/llmarketplacefunctions.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 957e96e866..75853b2cc0 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1426,6 +1426,17 @@ bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) return false; } +bool LLMarketplaceData::isInActiveFolder(const LLUUID& obj_id) +{ + S32 depth = depth_nesting_in_marketplace(obj_id); + LLUUID listing_uuid = nested_parent_id(obj_id, depth); + // *TODO: use true activation status once SLM is in decent shape again + //bool active = getActivationState(listing_uuid); Hack waiting for SLM to allow activation again... + bool active = true; + LLUUID version_uuid = getVersionFolder(listing_uuid); + return (active && gInventory.isObjectDescendentOf(obj_id, version_uuid)); +} + // Private Modifiers bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) { -- cgit v1.2.3 From d5cd32a2a82473d504c04b00eb105290e5d61d08 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 2 Jun 2014 11:57:25 -0700 Subject: DD-92 : WIP : Use the new LLCurl::Responder interface. Marketplace Listings functional again. --- indra/newview/llmarketplacefunctions.cpp | 116 ++++++++++++++----------------- 1 file changed, 53 insertions(+), 63 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 7925662663..f6a0a28735 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -131,27 +131,34 @@ class LLSLMGetMerchantResponder : public LLHTTPClient::Responder public: LLSLMGetMerchantResponder() {} - - virtual void completed(U32 status, const std::string& reason, const LLSD& content) { } - - void completedHeader(U32 status, const std::string& reason, const LLSD& content) + +protected: + virtual void httpFailure() { - if (((200 <= status ) && (status < 300)) || sBypassMerchant) - { - log_SLM_infos("Get /merchant", status, "User is a merchant"); + if (sBypassMerchant) + { + // *TODO : Suppress that before shipping! + log_SLM_infos("Get /merchant", getStatus(), "SLM Connection error bypassed (debug only)"); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); - } - else if (status == SLMErrorCodes::SLM_NOT_FOUND) - { - log_SLM_infos("Get /merchant", status, "User is not a merchant"); + } + else if (HTTP_NOT_FOUND == getStatus()) + { + log_SLM_infos("Get /merchant", getStatus(), "User is not a merchant"); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); - } + } else { - log_SLM_warning("Get /merchant", status, reason, content.get("error_code"), content.get("error_description")); + 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); + } + }; class LLSLMGetListingsResponder : public LLHTTPClient::Responder @@ -161,32 +168,29 @@ public: LLSLMGetListingsResponder() {} - virtual void completedRaw(U32 status, - const std::string& reason, - const LLChannelDescriptors& channels, + virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { - if (!(200 <= status ) && (status < 300)) + if (!isGoodStatus()) { - log_SLM_warning("Get /listings", status, reason, "", ""); + log_SLM_warning("Get /listings", getStatus(), getReason(), "", ""); return; } - LLBufferStream istr(channels, buffer.get()); std::stringstream strstrm; strstrm << istr.rdbuf(); const std::string body = strstrm.str(); - + Json::Value root; Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_warning("Get /listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Get /listings", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - - log_SLM_infos("Get /listings", status, body); - + + log_SLM_infos("Get /listings", getStatus(), body); + // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -220,14 +224,12 @@ public: LLSLMCreateListingsResponder() {} - virtual void completedRaw(U32 status, - const std::string& reason, - const LLChannelDescriptors& channels, + virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { - if (!(200 <= status ) && (status < 300)) + if (!isGoodStatus()) { - log_SLM_warning("Post /listings", status, reason, "", ""); + log_SLM_warning("Post /listings", getStatus(), getReason(), "", ""); return; } @@ -240,11 +242,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_warning("Post /listings", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Post /listings", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - log_SLM_infos("Post /listings", status, body); + log_SLM_infos("Post /listings", getStatus(), body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -275,9 +277,7 @@ public: LLSLMGetListingResponder() {} - virtual void completedRaw(U32 status, - const std::string& reason, - const LLChannelDescriptors& channels, + virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { LLBufferStream istr(channels, buffer.get()); @@ -285,9 +285,9 @@ public: strstrm << istr.rdbuf(); const std::string body = strstrm.str(); - if (!(200 <= status ) && (status < 300)) + if (!isGoodStatus()) { - log_SLM_warning("Get /listing", status, reason, "", body); + log_SLM_warning("Get /listing", getStatus(), getReason(), "", body); return; } @@ -295,11 +295,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_warning("Get /listing", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Get /listing", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - log_SLM_infos("Get /listing", status, body); + log_SLM_infos("Get /listing", getStatus(), body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -335,9 +335,7 @@ public: LLSLMUpdateListingsResponder() {} - virtual void completedRaw(U32 status, - const std::string& reason, - const LLChannelDescriptors& channels, + virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { LLBufferStream istr(channels, buffer.get()); @@ -345,9 +343,9 @@ public: strstrm << istr.rdbuf(); const std::string body = strstrm.str(); - if (!(200 <= status ) && (status < 300)) + if (!isGoodStatus()) { - log_SLM_warning("Put /listing", status, reason, "", body); + log_SLM_warning("Put /listing", getStatus(), getReason(), "", body); return; } @@ -355,11 +353,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_warning("Put /listing", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Put /listing", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - log_SLM_infos("Put /listing", status, body); + log_SLM_infos("Put /listing", getStatus(), body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -395,16 +393,12 @@ public: LLSLMAssociateListingsResponder() {} - virtual void completed(U32 status, const std::string& reason, const LLSD& content) { } - - virtual void completedRaw(U32 status, - const std::string& reason, - const LLChannelDescriptors& channels, + virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { - if (!(200 <= status ) && (status < 300)) + if (!isGoodStatus()) { - log_SLM_warning("Put /associate_inventory", status, reason, "", ""); + log_SLM_warning("Put /associate_inventory", getStatus(), getReason(), "", ""); return; } @@ -417,11 +411,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_warning("Put /associate_inventory", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Put /associate_inventory", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - log_SLM_infos("Put /associate_inventory", status, body); + log_SLM_infos("Put /associate_inventory", getStatus(), body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); @@ -462,11 +456,7 @@ public: LLSLMDeleteListingsResponder() {} - virtual void completed(U32 status, const std::string& reason, const LLSD& content) { } - - virtual void completedRaw(U32 status, - const std::string& reason, - const LLChannelDescriptors& channels, + virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { LLBufferStream istr(channels, buffer.get()); @@ -474,9 +464,9 @@ public: strstrm << istr.rdbuf(); const std::string body = strstrm.str(); - if (!(200 <= status ) && (status < 300)) + if (!isGoodStatus()) { - log_SLM_warning("Delete /listing", status, reason, "", body); + log_SLM_warning("Delete /listing", getStatus(), getReason(), "", body); return; } @@ -484,11 +474,11 @@ public: Json::Reader reader; if (!reader.parse(body,root)) { - log_SLM_warning("Delete /listing", status, "Json parsing failed", reader.getFormatedErrorMessages(), body); + log_SLM_warning("Delete /listing", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); return; } - log_SLM_infos("Delete /listing", status, body); + log_SLM_infos("Delete /listing", getStatus(), body); // Extract the info from the Json string Json::ValueIterator it = root["listings"].begin(); -- cgit v1.2.3 From 86d75052f65149da6bbe1ade5ea28b6f01aaba17 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 3 Jun 2014 19:46:33 -0700 Subject: DD-84 : Fix all active listing modification actions. Add specific message when listing will unlist. Make update skip consistency check when called from internal level (not public API). --- indra/newview/llmarketplacefunctions.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index f6a0a28735..d3d529cedb 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1318,7 +1318,7 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, cons } mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id, listing_id, version_id, is_listed); - update_marketplace_category(folder_id); + update_marketplace_category(folder_id, true); gInventory.notifyObservers(); return true; } @@ -1334,7 +1334,7 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update_slm) if (update_slm) { - update_marketplace_category(folder_id); + update_marketplace_category(folder_id, true); gInventory.notifyObservers(); } return true; @@ -1422,11 +1422,9 @@ bool LLMarketplaceData::isInActiveFolder(const LLUUID& obj_id) { S32 depth = depth_nesting_in_marketplace(obj_id); LLUUID listing_uuid = nested_parent_id(obj_id, depth); - // *TODO: use true activation status once SLM is in decent shape again - //bool active = getActivationState(listing_uuid); Hack waiting for SLM to allow activation again... - bool active = true; + bool active = getActivationState(listing_uuid); LLUUID version_uuid = getVersionFolder(listing_uuid); - return (active && gInventory.isObjectDescendentOf(obj_id, version_uuid)); + return (active && ((obj_id == listing_uuid) || (obj_id == version_uuid) || gInventory.isObjectDescendentOf(obj_id, version_uuid))); } // Private Modifiers @@ -1440,7 +1438,7 @@ bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) (it->second).mListingId = listing_id; - update_marketplace_category(folder_id); + update_marketplace_category(folder_id, true); gInventory.notifyObservers(); return true; } @@ -1461,8 +1459,8 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID (it->second).mVersionFolderId = version_id; - update_marketplace_category(old_version_id); - update_marketplace_category(version_id); + update_marketplace_category(old_version_id, true); + update_marketplace_category(version_id, true); gInventory.notifyObservers(); return true; } @@ -1477,7 +1475,7 @@ bool LLMarketplaceData::setActivationState(const LLUUID& folder_id, bool activat (it->second).mIsActive = activate; - update_marketplace_category((it->second).mListingFolderId); + update_marketplace_category((it->second).mListingFolderId, true); gInventory.notifyObservers(); return true; } -- cgit v1.2.3 From 252ad06b7bcc33a48b6c23917f6156a436df4b00 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 4 Jun 2014 09:58:11 -0700 Subject: DD-84 : Final clean up for this fix --- indra/newview/llmarketplacefunctions.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d3d529cedb..d8f78ce81a 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1318,7 +1318,7 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, cons } mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id, listing_id, version_id, is_listed); - update_marketplace_category(folder_id, true); + update_marketplace_category(folder_id, false); gInventory.notifyObservers(); return true; } @@ -1334,7 +1334,7 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update_slm) if (update_slm) { - update_marketplace_category(folder_id, true); + update_marketplace_category(folder_id, false); gInventory.notifyObservers(); } return true; @@ -1438,7 +1438,7 @@ bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) (it->second).mListingId = listing_id; - update_marketplace_category(folder_id, true); + update_marketplace_category(folder_id, false); gInventory.notifyObservers(); return true; } @@ -1459,8 +1459,8 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID (it->second).mVersionFolderId = version_id; - update_marketplace_category(old_version_id, true); - update_marketplace_category(version_id, true); + update_marketplace_category(old_version_id, false); + update_marketplace_category(version_id, false); gInventory.notifyObservers(); return true; } @@ -1475,7 +1475,7 @@ bool LLMarketplaceData::setActivationState(const LLUUID& folder_id, bool activat (it->second).mIsActive = activate; - update_marketplace_category((it->second).mListingFolderId, true); + update_marketplace_category((it->second).mListingFolderId, false); gInventory.notifyObservers(); return true; } -- cgit v1.2.3 From 4083e972ccf238cd02d60da2af88855f25ed7b1f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 9 Jun 2014 15:20:07 -0700 Subject: DD-97 : When clearing the version folder of a record, force activation (listed) status to false at the same time, avoiding confusing (and eventually wrong) double call to updateSLMListing --- indra/newview/llmarketplacefunctions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d8f78ce81a..3b68c12d11 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1285,7 +1285,8 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& return false; } - bool is_listed = getActivationState(listing_uuid); + // 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)); // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_id, is_listed); -- cgit v1.2.3 From ae2f24d0c10a9a91090aa040f8367e8691fcbbd1 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 10 Jun 2014 14:04:53 -0700 Subject: DD : Clean up marketplace listings folder creation so we create it in only one place --- indra/newview/llmarketplacefunctions.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 3b68c12d11..fe67683de5 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1173,6 +1173,10 @@ std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) { url = "https://marketplace.secondlife-staging.com/api/1/viewer/" + gAgentID.asString(); } + else + { + llinfos << "Merov : DD cap = " << url << ", agent = " << gAgentID.asString() << llendl; + } url += route; } return url; -- cgit v1.2.3 From 140d5f0a22ab531f92b4a3a66c8229f550e1ff5c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 11 Jun 2014 21:25:32 -0700 Subject: DD-98 : Add message with link to marketplace if listing cannot be edited --- indra/newview/llmarketplacefunctions.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index fe67683de5..d6a4d4062f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -33,6 +33,7 @@ #include "llhttpclient.h" #include "llinventoryfunctions.h" #include "llinventoryobserver.h" +#include "llnotificationsutil.h" #include "llsdserialize.h" #include "lltimer.h" #include "lltrans.h" @@ -333,7 +334,11 @@ class LLSLMUpdateListingsResponder : public LLHTTPClient::Responder LOG_CLASS(LLSLMUpdateListingsResponder); public: - LLSLMUpdateListingsResponder() {} + LLSLMUpdateListingsResponder(bool expected_listed_state, const LLUUID& expected_version_id) + { + mExpectedListedState = expected_listed_state; + mExpectedVersionUUID = expected_version_id; + } virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) @@ -381,9 +386,21 @@ public: LLMarketplaceData::instance().setActivationState(folder_id, is_listed); LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + // 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: + bool mExpectedListedState; + LLUUID mExpectedVersionUUID; }; class LLSLMAssociateListingsResponder : public LLHTTPClient::Responder @@ -1118,7 +1135,7 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); log_SLM_infos("LLHTTPClient::putRaw", url, json_str); - LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(), headers); + LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(is_listed, version_id), headers); } void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id) -- cgit v1.2.3 From a00861b1691c37ed30ec16dd1bc84045f8d87dda Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 2 Jul 2014 13:13:52 -0700 Subject: DD-21 : Fix the header on the SLM GET /listings route when using cap --- indra/newview/llmarketplacefunctions.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d6a4d4062f..b37ae30021 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1066,9 +1066,14 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& // 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 std::string url = getSLMConnectURL("/listings"); log_SLM_infos("LLHTTPClient::get", url, ""); - LLHTTPClient::get(url, new LLSLMGetListingsResponder(), LLSD()); + LLHTTPClient::get(url, new LLSLMGetListingsResponder(), headers); } void LLMarketplaceData::getSLMListing(S32 listing_id) -- cgit v1.2.3 From d37c294bd38bf4cae251c33f863e4e6e66ef44db Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 30 Jul 2014 20:51:18 -0700 Subject: DD-75 : Prevent dropping on filtered tabs root. Adding an allow_drop option to inventory tab and folder view folders so that case can be taken into account. --- indra/newview/llmarketplacefunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index b37ae30021..c2b4f34ac2 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -124,7 +124,7 @@ void log_SLM_infos(const std::string& request, const std::string& url, const std // Merov: This is a temporary hack used by dev while secondlife-staging is down... // *TODO : Suppress that before shipping! -static bool sBypassMerchant = false; +static bool sBypassMerchant = true; class LLSLMGetMerchantResponder : public LLHTTPClient::Responder { -- cgit v1.2.3 From f02ac3b7dc8c0496a639e881f6a5f8c62bbdd7c0 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 13 Aug 2014 17:21:13 -0700 Subject: Switch the merchant bypass off (that's debug only, for dev only...) --- indra/newview/llmarketplacefunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index c2b4f34ac2..b37ae30021 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -124,7 +124,7 @@ void log_SLM_infos(const std::string& request, const std::string& url, const std // Merov: This is a temporary hack used by dev while secondlife-staging is down... // *TODO : Suppress that before shipping! -static bool sBypassMerchant = true; +static bool sBypassMerchant = false; class LLSLMGetMerchantResponder : public LLHTTPClient::Responder { -- cgit v1.2.3 From 51e8b7fae6ff14c58bf32ef740a60386bc15baee Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 19 Aug 2014 22:34:06 -0700 Subject: DD-129 : Prevent DAMA when dropping under the root of a listing, even active. Finer granularity of DAMA for all drop and cut and paste cases. --- indra/newview/llmarketplacefunctions.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index b37ae30021..a23295ec20 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1431,6 +1431,11 @@ bool LLMarketplaceData::isListed(const LLUUID& folder_id) return (it != mMarketplaceItems.end()); } +bool LLMarketplaceData::isListedAndActive(const LLUUID& folder_id) +{ + return (isListed(folder_id) && getActivationState(folder_id)); +} + bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); @@ -1451,7 +1456,7 @@ bool LLMarketplaceData::isInActiveFolder(const LLUUID& obj_id) LLUUID listing_uuid = nested_parent_id(obj_id, depth); bool active = getActivationState(listing_uuid); LLUUID version_uuid = getVersionFolder(listing_uuid); - return (active && ((obj_id == listing_uuid) || (obj_id == version_uuid) || gInventory.isObjectDescendentOf(obj_id, version_uuid))); + return (active && ((obj_id == version_uuid) || gInventory.isObjectDescendentOf(obj_id, version_uuid))); } // Private Modifiers -- cgit v1.2.3 From c77575df2f91452ad1a527f2f46ba1191459b259 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sat, 23 Aug 2014 17:31:33 -0700 Subject: DD-122 : Fixed. Unlist if listing doesn't validate after move --- indra/newview/llmarketplacefunctions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index a23295ec20..669c49ea4f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1459,6 +1459,13 @@ bool LLMarketplaceData::isInActiveFolder(const LLUUID& obj_id) return (active && ((obj_id == version_uuid) || gInventory.isObjectDescendentOf(obj_id, version_uuid))); } +LLUUID LLMarketplaceData::getActiveFolder(const LLUUID& obj_id) +{ + S32 depth = depth_nesting_in_marketplace(obj_id); + LLUUID listing_uuid = nested_parent_id(obj_id, depth); + return (getActivationState(listing_uuid) ? getVersionFolder(listing_uuid) : LLUUID::null); +} + // Private Modifiers bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) { -- cgit v1.2.3 From 85ec32c05e3474e55db142489f91e978df319951 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 25 Aug 2014 10:02:13 -0700 Subject: DD-105 : WIP : Adding (updating...) suffix when SLM transaction in progress --- indra/newview/llmarketplacefunctions.cpp | 92 ++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 11 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 669c49ea4f..17b8ec746f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -172,6 +172,8 @@ public: virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { + LLMarketplaceData::instance().setUpdating(false); + if (!isGoodStatus()) { log_SLM_warning("Get /listings", getStatus(), getReason(), "", ""); @@ -223,11 +225,16 @@ class LLSLMCreateListingsResponder : public LLHTTPClient::Responder LOG_CLASS(LLSLMCreateListingsResponder); public: - LLSLMCreateListingsResponder() {} + LLSLMCreateListingsResponder(const LLUUID& folder_id) + { + mExpectedFolderId = folder_id; + } virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { + LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false); + if (!isGoodStatus()) { log_SLM_warning("Post /listings", getStatus(), getReason(), "", ""); @@ -269,6 +276,8 @@ public: it++; } } +private: + LLUUID mExpectedFolderId; }; class LLSLMGetListingResponder : public LLHTTPClient::Responder @@ -276,11 +285,16 @@ class LLSLMGetListingResponder : public LLHTTPClient::Responder LOG_CLASS(LLSLMGetListingResponder); public: - LLSLMGetListingResponder() {} + LLSLMGetListingResponder(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(); @@ -327,6 +341,8 @@ public: it++; } } +private: + LLUUID mExpectedFolderId; }; class LLSLMUpdateListingsResponder : public LLHTTPClient::Responder @@ -334,8 +350,9 @@ class LLSLMUpdateListingsResponder : public LLHTTPClient::Responder LOG_CLASS(LLSLMUpdateListingsResponder); public: - LLSLMUpdateListingsResponder(bool expected_listed_state, const LLUUID& expected_version_id) + 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; } @@ -343,6 +360,8 @@ public: 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(); @@ -399,6 +418,7 @@ public: } } private: + LLUUID mExpectedFolderId; bool mExpectedListedState; LLUUID mExpectedVersionUUID; }; @@ -408,11 +428,16 @@ class LLSLMAssociateListingsResponder : public LLHTTPClient::Responder LOG_CLASS(LLSLMAssociateListingsResponder); public: - LLSLMAssociateListingsResponder() {} + LLSLMAssociateListingsResponder(const LLUUID& folder_id) + { + mExpectedFolderId = folder_id; + } virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { + LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false); + if (!isGoodStatus()) { log_SLM_warning("Put /associate_inventory", getStatus(), getReason(), "", ""); @@ -464,6 +489,8 @@ public: it++; } } +private: + LLUUID mExpectedFolderId; }; class LLSLMDeleteListingsResponder : public LLHTTPClient::Responder @@ -471,11 +498,16 @@ class LLSLMDeleteListingsResponder : public LLHTTPClient::Responder LOG_CLASS(LLSLMDeleteListingsResponder); public: - LLSLMDeleteListingsResponder() {} + 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(); @@ -511,6 +543,8 @@ public: it++; } } +private: + LLUUID mExpectedFolderId; }; // SLM Responders End @@ -1038,7 +1072,8 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id, LLMarketplaceData::LLMarketplaceData() : mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED), mStatusUpdatedSignal(NULL), - mDirtyCount(false) + mDirtyCount(false), + mIsUpdating(false) { mInventoryObserver = new LLMarketplaceInventoryObserver; gInventory.addObserver(mInventoryObserver); @@ -1073,6 +1108,7 @@ void LLMarketplaceData::getSLMListings() // Send request std::string url = getSLMConnectURL("/listings"); log_SLM_infos("LLHTTPClient::get", url, ""); + setUpdating(true); LLHTTPClient::get(url, new LLSLMGetListingsResponder(), headers); } @@ -1085,7 +1121,9 @@ void LLMarketplaceData::getSLMListing(S32 listing_id) // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); log_SLM_infos("LLHTTPClient::get", url, ""); - LLHTTPClient::get(url, new LLSLMGetListingResponder(), headers); + LLUUID folder_id = LLMarketplaceData::instance().getListingFolder(listing_id); + setUpdating(folder_id,true); + LLHTTPClient::get(url, new LLSLMGetListingResponder(folder_id), headers); } void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) @@ -1112,7 +1150,8 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) // Send request std::string url = getSLMConnectURL("/listings"); log_SLM_infos("LLHTTPClient::postRaw", url, json_str); - LLHTTPClient::postRaw(url, data, size, new LLSLMCreateListingsResponder(), headers); + setUpdating(folder_id,true); + 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) @@ -1140,7 +1179,8 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); log_SLM_infos("LLHTTPClient::putRaw", url, json_str); - LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(is_listed, version_id), headers); + setUpdating(folder_id,true); + LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(folder_id, is_listed, version_id), headers); } void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id) @@ -1167,7 +1207,8 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing // Send request std::string url = getSLMConnectURL("/associate_inventory/") + llformat("%d",listing_id); log_SLM_infos("LLHTTPClient::putRaw", url, json_str); - LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(), headers); + setUpdating(folder_id,true); + LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(folder_id), headers); } void LLMarketplaceData::deleteSLMListing(S32 listing_id) @@ -1179,7 +1220,9 @@ void LLMarketplaceData::deleteSLMListing(S32 listing_id) // Send request std::string url = getSLMConnectURL("/listing/") + llformat("%d",listing_id); log_SLM_infos("LLHTTPClient::del", url, ""); - LLHTTPClient::del(url, new LLSLMDeleteListingsResponder(), headers); + LLUUID folder_id = LLMarketplaceData::instance().getListingFolder(listing_id); + setUpdating(folder_id,true); + LLHTTPClient::del(url, new LLSLMDeleteListingsResponder(folder_id), headers); } std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) @@ -1466,6 +1509,33 @@ LLUUID LLMarketplaceData::getActiveFolder(const LLUUID& obj_id) return (getActivationState(listing_uuid) ? getVersionFolder(listing_uuid) : LLUUID::null); } +bool LLMarketplaceData::isUpdating(const LLUUID& folder_id) +{ + if (mIsUpdating) + { + // If we're waiting for data for all listings, we are in the updating process + return true; + } + else + { + std::set::iterator it = mPendingUpdateSet.find(folder_id); + return (it != mPendingUpdateSet.end()); + } +} + +void LLMarketplaceData::setUpdating(const LLUUID& folder_id, bool isUpdating) +{ + std::set::iterator it = mPendingUpdateSet.find(folder_id); + if (it != mPendingUpdateSet.end()) + { + mPendingUpdateSet.erase(it); + } + if (isUpdating) + { + mPendingUpdateSet.insert(folder_id); + } +} + // Private Modifiers bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) { -- cgit v1.2.3 From 2631d6f81717a0f6be0e5adba58ddddcd826b721 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 25 Aug 2014 11:30:46 -0700 Subject: DD-105 : WIP : Use one single mechanism for marking folders being updated by SLM --- indra/newview/llmarketplacefunctions.cpp | 44 ++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 17b8ec746f..9457884cf4 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -167,12 +167,15 @@ class LLSLMGetListingsResponder : public LLHTTPClient::Responder LOG_CLASS(LLSLMGetListingsResponder); public: - LLSLMGetListingsResponder() {} + LLSLMGetListingsResponder(const LLUUID& folder_id) + { + mExpectedFolderId = folder_id; + } virtual void completedRaw(const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer) { - LLMarketplaceData::instance().setUpdating(false); + LLMarketplaceData::instance().setUpdating(mExpectedFolderId,false); if (!isGoodStatus()) { @@ -217,7 +220,13 @@ public: } it++; } + + // Update all folders under the root + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); } +private: + LLUUID mExpectedFolderId; }; class LLSLMCreateListingsResponder : public LLHTTPClient::Responder @@ -1072,8 +1081,7 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id, LLMarketplaceData::LLMarketplaceData() : mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED), mStatusUpdatedSignal(NULL), - mDirtyCount(false), - mIsUpdating(false) + mDirtyCount(false) { mInventoryObserver = new LLMarketplaceInventoryObserver; gInventory.addObserver(mInventoryObserver); @@ -1108,8 +1116,9 @@ void LLMarketplaceData::getSLMListings() // Send request std::string url = getSLMConnectURL("/listings"); log_SLM_infos("LLHTTPClient::get", url, ""); - setUpdating(true); - LLHTTPClient::get(url, new LLSLMGetListingsResponder(), headers); + const LLUUID marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false); + setUpdating(marketplacelistings_id,true); + LLHTTPClient::get(url, new LLSLMGetListingsResponder(marketplacelistings_id), headers); } void LLMarketplaceData::getSLMListing(S32 listing_id) @@ -1511,15 +1520,28 @@ LLUUID LLMarketplaceData::getActiveFolder(const LLUUID& obj_id) bool LLMarketplaceData::isUpdating(const LLUUID& folder_id) { - if (mIsUpdating) + S32 depth = depth_nesting_in_marketplace(folder_id); + if ((depth <= 0) || (depth > 2)) { - // If we're waiting for data for all listings, we are in the updating process - return true; + // Only listing and version folders though are concerned by that status + return false; } else { - std::set::iterator it = mPendingUpdateSet.find(folder_id); - return (it != mPendingUpdateSet.end()); + const LLUUID marketplace_listings_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS, false); + std::set::iterator it = mPendingUpdateSet.find(marketplace_listings_uuid); + if (it != mPendingUpdateSet.end()) + { + // If we're waiting for data for the marketplace listings root, we are in the updating process for all + return true; + } + else + { + // Check if the listing folder is waiting or data + LLUUID listing_uuid = nested_parent_id(folder_id, depth); + it = mPendingUpdateSet.find(listing_uuid); + return (it != mPendingUpdateSet.end()); + } } } -- cgit v1.2.3 From 4d752d31aa7c86631bd12e9fdd5d37c541d78929 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 25 Aug 2014 22:03:49 -0700 Subject: DD-105 : Refresh listing even when SLM returns with errors --- indra/newview/llmarketplacefunctions.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 9457884cf4..090b78a6bb 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -180,6 +180,8 @@ public: if (!isGoodStatus()) { log_SLM_warning("Get /listings", getStatus(), getReason(), "", ""); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } LLBufferStream istr(channels, buffer.get()); @@ -192,6 +194,8 @@ public: if (!reader.parse(body,root)) { log_SLM_warning("Get /listings", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } @@ -247,6 +251,8 @@ public: if (!isGoodStatus()) { log_SLM_warning("Post /listings", getStatus(), getReason(), "", ""); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } @@ -260,6 +266,8 @@ public: if (!reader.parse(body,root)) { log_SLM_warning("Post /listings", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } @@ -312,6 +320,8 @@ public: if (!isGoodStatus()) { log_SLM_warning("Get /listing", getStatus(), getReason(), "", body); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } @@ -320,6 +330,8 @@ public: 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; } @@ -379,6 +391,8 @@ public: if (!isGoodStatus()) { log_SLM_warning("Put /listing", getStatus(), getReason(), "", body); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } @@ -387,6 +401,8 @@ public: 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; } @@ -450,6 +466,8 @@ public: if (!isGoodStatus()) { log_SLM_warning("Put /associate_inventory", getStatus(), getReason(), "", ""); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } @@ -463,6 +481,8 @@ public: if (!reader.parse(body,root)) { log_SLM_warning("Put /associate_inventory", getStatus(), "Json parsing failed", reader.getFormatedErrorMessages(), body); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } @@ -525,6 +545,8 @@ public: if (!isGoodStatus()) { log_SLM_warning("Delete /listing", getStatus(), getReason(), "", body); + update_marketplace_category(mExpectedFolderId, false); + gInventory.notifyObservers(); return; } @@ -533,6 +555,8 @@ public: 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; } -- cgit v1.2.3 From 7643a0571ebd92a31ac293cea18d21a160e3d46f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 1 Sep 2014 16:49:35 -0700 Subject: DD-168 : Display an error message when SLM transactions fail --- indra/newview/llmarketplacefunctions.cpp | 41 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 090b78a6bb..c453b236cd 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -106,6 +106,12 @@ LLSD getMarketplaceStringSubstitutions() 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; + // Prompt the user with the warning (so they know why things are failing) + LLSD subs; + subs["[ERROR_REASON]"] = reason; + subs["[ERROR_DESCRIPTION]"] = description; + LLNotificationsUtil::add("MerchantTransactionFailed", subs); + } void log_SLM_infos(const std::string& request, U32 status, const std::string& body) { @@ -177,17 +183,18 @@ public: { 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(), "", ""); + log_SLM_warning("Get /listings", getStatus(), getReason(), "", body); update_marketplace_category(mExpectedFolderId, false); gInventory.notifyObservers(); return; } - LLBufferStream istr(channels, buffer.get()); - std::stringstream strstrm; - strstrm << istr.rdbuf(); - const std::string body = strstrm.str(); Json::Value root; Json::Reader reader; @@ -248,19 +255,19 @@ public: { 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(), "", ""); + log_SLM_warning("Post /listings", getStatus(), getReason(), "", body); update_marketplace_category(mExpectedFolderId, false); gInventory.notifyObservers(); return; } - LLBufferStream istr(channels, buffer.get()); - std::stringstream strstrm; - strstrm << istr.rdbuf(); - const std::string body = strstrm.str(); - Json::Value root; Json::Reader reader; if (!reader.parse(body,root)) @@ -463,19 +470,19 @@ public: { 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("Put /associate_inventory", getStatus(), getReason(), "", ""); + log_SLM_warning("Put /associate_inventory", getStatus(), getReason(), "", body); update_marketplace_category(mExpectedFolderId, false); gInventory.notifyObservers(); return; } - LLBufferStream istr(channels, buffer.get()); - std::stringstream strstrm; - strstrm << istr.rdbuf(); - const std::string body = strstrm.str(); - Json::Value root; Json::Reader reader; if (!reader.parse(body,root)) -- cgit v1.2.3 From 5b1f6d23be13d5a0879b06d5c11f333c68bc132b Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 2 Sep 2014 21:52:31 -0700 Subject: DD-106 : WIP : Use a single atomic SLM call for association and unlisting. Updating status on source and destination working. --- indra/newview/llmarketplacefunctions.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index c453b236cd..650b587091 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -460,15 +460,17 @@ class LLSLMAssociateListingsResponder : public LLHTTPClient::Responder LOG_CLASS(LLSLMAssociateListingsResponder); public: - LLSLMAssociateListingsResponder(const LLUUID& folder_id) + 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; @@ -479,6 +481,7 @@ public: { log_SLM_warning("Put /associate_inventory", getStatus(), getReason(), "", body); update_marketplace_category(mExpectedFolderId, false); + update_marketplace_category(mSourceFolderId, false); gInventory.notifyObservers(); return; } @@ -489,6 +492,7 @@ public: { 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; } @@ -524,9 +528,13 @@ public: LLMarketplaceData::instance().setListingURL(folder_id, edit_url); it++; } + + // Always update the source folder so its widget updates + update_marketplace_category(mSourceFolderId, false); } private: - LLUUID mExpectedFolderId; + 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 }; class LLSLMDeleteListingsResponder : public LLHTTPClient::Responder @@ -1223,7 +1231,7 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(folder_id, is_listed, version_id), headers); } -void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id) +void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& source_folder_id) { LLSD headers = LLSD::emptyMap(); headers["Accept"] = "application/json"; @@ -1234,8 +1242,9 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing // Note : we're assuming that sending unchanged info won't break anything server side... root["listing"]["id"] = listing_id; + root["listing"]["is_listed"] = false; root["listing"]["inventory_info"]["listing_folder_id"] = folder_id.asString(); - root["listing"]["inventory_info"]["version_folder_id"] = version_id.asString(); + root["listing"]["inventory_info"]["version_folder_id"] = LLUUID::null.asString(); std::string json_str = writer.write(root); @@ -1248,7 +1257,8 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing std::string url = getSLMConnectURL("/associate_inventory/") + llformat("%d",listing_id); log_SLM_infos("LLHTTPClient::putRaw", url, json_str); setUpdating(folder_id,true); - LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(folder_id), headers); + setUpdating(source_folder_id,true); + LLHTTPClient::putRaw(url, data, size, new LLSLMAssociateListingsResponder(folder_id,source_folder_id), headers); } void LLMarketplaceData::deleteSLMListing(S32 listing_id) @@ -1403,7 +1413,7 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& return true; } -bool LLMarketplaceData::associateListing(const LLUUID& folder_id, S32 listing_id) +bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& source_folder_id, S32 listing_id) { if (isListed(folder_id)) { @@ -1412,8 +1422,7 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, S32 listing_id } // Post the listing update request to SLM - LLUUID version_id; - associateSLMListing(folder_id, listing_id, version_id); + associateSLMListing(folder_id, listing_id, source_folder_id); return true; } -- cgit v1.2.3 From 1a334a1005d116b99eca45c1e4a1a475c9dba68d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 16 Sep 2014 10:39:23 -0700 Subject: DD-23 : WIP : Catch the SLM_UPDATE_FOLDER notification and trigger the GET /listing route so to get the updated SLM status for the listing --- indra/newview/llmarketplacefunctions.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 650b587091..794bb62834 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1372,6 +1372,18 @@ bool LLMarketplaceData::getListing(const LLUUID& folder_id) return true; } +bool LLMarketplaceData::getListing(S32 listing_id) +{ + if (listing_id == 0) + { + return false; + } + + // 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 -- cgit v1.2.3 From 6b8916e7604d47f37d30ae0c1a6ab2465da1f39d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sun, 5 Oct 2014 20:17:29 -0700 Subject: DD-170 : Handle 503 answer from SLM and added a MARKET_MERCHANT_NOT_MIGRATED state to the UI, showing only the relevant UI to the user (i.e. Merchant Outbox or Marketplace Listings). --- indra/newview/llmarketplacefunctions.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 794bb62834..58a946e4e4 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -152,6 +152,11 @@ protected: { log_SLM_infos("Get /merchant", getStatus(), "User is not a merchant"); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); + } + else if (HTTP_SERVICE_UNAVAILABLE == getStatus()) + { + log_SLM_infos("Get /merchant", getStatus(), "Merchant is not migrated"); + LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_MERCHANT_NOT_MIGRATED); } else { @@ -1133,16 +1138,25 @@ LLMarketplaceData::~LLMarketplaceData() void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& cb) { - mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; if (mStatusUpdatedSignal == NULL) { mStatusUpdatedSignal = new status_updated_signal_t(); } mStatusUpdatedSignal->connect(cb); - std::string url = getSLMConnectURL("/merchant"); - log_SLM_infos("LLHTTPClient::get", url, ""); - LLHTTPClient::get(url, new LLSLMGetMerchantResponder(), LLSD()); + if (mMarketPlaceStatus != MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED) + { + // If already initialized, just confirm the status so the callback gets called + setSLMStatus(mMarketPlaceStatus); + } + else + { + // Initiate SLM connection and set responder + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; + std::string url = getSLMConnectURL("/merchant"); + log_SLM_infos("LLHTTPClient::get", url, ""); + LLHTTPClient::get(url, new LLSLMGetMerchantResponder(), LLSD()); + } } // Get/Post/Put requests to the SLM Server using the SLM API -- cgit v1.2.3 From 5ded6ef85b971a2be9287f11be5acca2b343f364 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 6 Oct 2014 21:09:01 -0700 Subject: DD-170 : Rename enum for consistency --- indra/newview/llmarketplacefunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 58a946e4e4..8988b80a4f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -156,7 +156,7 @@ protected: else if (HTTP_SERVICE_UNAVAILABLE == getStatus()) { log_SLM_infos("Get /merchant", getStatus(), "Merchant is not migrated"); - LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_MERCHANT_NOT_MIGRATED); + LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MIGRATED_MERCHANT); } else { -- cgit v1.2.3 From 8ca0ebbb8b3592f146f77e95a8b93ef4d37cf988 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 14 Oct 2014 21:32:00 -0700 Subject: DD-170 : Check the Merchant Outbox API and hide the menu item if getting 503. Show SLM always. --- indra/newview/llmarketplacefunctions.cpp | 85 ++++++++++++++++---------------- 1 file changed, 42 insertions(+), 43 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 8988b80a4f..fbfddd09a5 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -666,7 +666,7 @@ namespace LLMarketplaceImport { if (gSavedSettings.getBOOL("InventoryOutboxLogging")) { - LL_INFOS() << " SLM POST clearing marketplace cookie due to client or server error" << LL_ENDL; + LL_INFOS() << " SLM POST : Clearing marketplace cookie due to client or server error" << LL_ENDL; } sMarketplaceCookie.clear(); } @@ -746,7 +746,7 @@ namespace LLMarketplaceImport S32 getResultStatus() { - return sImportResultStatus; + return sImportResultStatus; } const LLSD& getResults() @@ -989,47 +989,46 @@ void LLMarketplaceInventoryImporter::updateImport() // If we are no longer in progress if (!mImportInProgress) { - if (mInitialized) - { - // Report results - if (mStatusReportSignal) - { - (*mStatusReportSignal)(LLMarketplaceImport::getResultStatus(), LLMarketplaceImport::getResults()); - } - } - else - { - // Look for results success - mInitialized = LLMarketplaceImport::hasSessionCookie(); - - if (mInitialized) - { - mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_MERCHANT; - // Follow up with auto trigger of import - if (mAutoTriggerImport) - { - mAutoTriggerImport = false; - mImportInProgress = triggerImport(); - } - } - else - { - U32 status = LLMarketplaceImport::getResultStatus(); - if ((status == MarketplaceErrorCodes::IMPORT_FORBIDDEN) || - (status == MarketplaceErrorCodes::IMPORT_AUTHENTICATION_ERROR)) - { - mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT; - } - else - { - mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_CONNECTION_FAILURE; - } - if (mErrorInitSignal && (mMarketPlaceStatus == MarketplaceStatusCodes::MARKET_PLACE_CONNECTION_FAILURE)) - { - (*mErrorInitSignal)(LLMarketplaceImport::getResultStatus(), LLMarketplaceImport::getResults()); - } - } - } + // Look for results success + mInitialized = LLMarketplaceImport::hasSessionCookie(); + + // Report results + if (mStatusReportSignal) + { + (*mStatusReportSignal)(LLMarketplaceImport::getResultStatus(), LLMarketplaceImport::getResults()); + } + + if (mInitialized) + { + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_MERCHANT; + // Follow up with auto trigger of import + if (mAutoTriggerImport) + { + mAutoTriggerImport = false; + mImportInProgress = triggerImport(); + } + } + else + { + U32 status = LLMarketplaceImport::getResultStatus(); + if ((status == MarketplaceErrorCodes::IMPORT_FORBIDDEN) || + (status == MarketplaceErrorCodes::IMPORT_AUTHENTICATION_ERROR)) + { + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT; + } + else if (status == MarketplaceErrorCodes::IMPORT_SERVER_API_DISABLED) + { + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_MIGRATED_MERCHANT; + } + else + { + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_CONNECTION_FAILURE; + } + if (mErrorInitSignal && (mMarketPlaceStatus == MarketplaceStatusCodes::MARKET_PLACE_CONNECTION_FAILURE)) + { + (*mErrorInitSignal)(LLMarketplaceImport::getResultStatus(), LLMarketplaceImport::getResults()); + } + } } // Make sure we trigger the status change with the final state (in case of auto trigger after initialize) -- cgit v1.2.3 From c58af954101ea23f38f7fca6a1d5fd4ed4139e31 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sun, 19 Oct 2014 21:53:07 -0700 Subject: DD-170 : Set the import callback for Merchant Outbox only when clicking the import button --- indra/newview/llmarketplacefunctions.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index fbfddd09a5..b4a2921f8c 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1030,13 +1030,13 @@ void LLMarketplaceInventoryImporter::updateImport() } } } - - // Make sure we trigger the status change with the final state (in case of auto trigger after initialize) - if (mStatusChangedSignal) - { - (*mStatusChangedSignal)(mImportInProgress); - } } + + // Make sure we trigger the status change with the final state (in case of auto trigger after initialize) + if (mStatusChangedSignal) + { + (*mStatusChangedSignal)(mImportInProgress); + } } // -- cgit v1.2.3 From eeb5fb382bdb45c4c886a113506b777e85cbf4e2 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 21 Oct 2014 19:34:54 -0700 Subject: DD-221 : Pointer testing to avoid potential crash --- indra/newview/llmarketplacefunctions.cpp | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index b4a2921f8c..4bf0eac03b 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1059,7 +1059,7 @@ void LLMarketplaceInventoryObserver::changed(U32 mask) // once observers are called) we need to raise a flag in the inventory to signal that things have been dirtied. // That's the only changes that really do make sense for marketplace to worry about - if ((mask & (LLInventoryObserver::INTERNAL | LLInventoryObserver::STRUCTURE)) != 0) + if (mask & (LLInventoryObserver::INTERNAL | LLInventoryObserver::STRUCTURE)) { const std::set& changed_items = gInventory.getChangedIDs(); @@ -1068,24 +1068,27 @@ void LLMarketplaceInventoryObserver::changed(U32 mask) for (;id_it != id_end; ++id_it) { LLInventoryObject* obj = gInventory.getObject(*id_it); - if (LLAssetType::AT_CATEGORY == obj->getType()) + if (obj) { - // If it's a folder known to the marketplace, let's check it's in proper shape - if (LLMarketplaceData::instance().isListed(*id_it) || LLMarketplaceData::instance().isVersionFolder(*id_it)) + if (LLAssetType::AT_CATEGORY == obj->getType()) { - LLInventoryCategory* cat = (LLInventoryCategory*)(obj); - validate_marketplacelistings(cat); + // If it's a folder known to the marketplace, let's check it's in proper shape + if (LLMarketplaceData::instance().isListed(*id_it) || LLMarketplaceData::instance().isVersionFolder(*id_it)) + { + LLInventoryCategory* cat = (LLInventoryCategory*)(obj); + validate_marketplacelistings(cat); + } } - } - else - { - // If it's not a category, it's an item... - LLInventoryItem* item = (LLInventoryItem*)(obj); - // If it's a no copy item, we may need to update the label count of marketplace listings - if (!item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID())) + else { - LLMarketplaceData::instance().setDirtyCount(); - } + // If it's not a category, it's an item... + LLInventoryItem* item = (LLInventoryItem*)(obj); + // If it's a no copy item, we may need to update the label count of marketplace listings + if (!item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID())) + { + LLMarketplaceData::instance().setDirtyCount(); + } + } } } } -- cgit v1.2.3 From f99dbd9be0f631ee9135ac89d8322c359711d626 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 21 Oct 2014 21:46:16 -0700 Subject: DD-224 : WIP : Add a deleteListing method, call SLM_UPDATE_FOLDER notification if state is deleted --- indra/newview/llmarketplacefunctions.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 4bf0eac03b..5e4615dbda 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1487,6 +1487,17 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update_slm) return true; } +bool LLMarketplaceData::deleteListing(S32 listing_id) +{ + if (listing_id == 0) + { + return false; + } + + LLUUID folder_id = getListingFolder(listing_id); + return deleteListing(folder_id); +} + // Accessors bool LLMarketplaceData::getActivationState(const LLUUID& folder_id) { -- cgit v1.2.3 From b2c7fb9aeead8d1c549c0bb96a9a986686a1211d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 23 Oct 2014 19:45:48 -0700 Subject: DD-224, DD-246 : Clean up code when receiving delete notification. Display DAMA alert when associating listing --- indra/newview/llmarketplacefunctions.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 5e4615dbda..ea2364ef86 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -531,6 +531,9 @@ public: // Add the new association LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + + // Alert with DAMA informing the user that a version folder must be designated + LLNotificationsUtil::add("AlertMerchantAssociateNeedsVersion"); it++; } -- cgit v1.2.3 From 828f47892151737bd5afe39b19c83d2b04fe9192 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 3 Nov 2014 13:18:06 -0800 Subject: DD-263 : Update the count on hand on SLM in various situation where stock count changes (activate, drag/drop, associate, etc...) --- indra/newview/llmarketplacefunctions.cpp | 64 ++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') 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); -- cgit v1.2.3 From 2939a542f97c5643457f0087915c733b949a0eb9 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 7 Nov 2014 16:47:19 -0800 Subject: DD-272 : Be more consistent when updating the count on hand in SLM, also prevent multiple folder update when receiving data from SLM --- indra/newview/llmarketplacefunctions.cpp | 102 ++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 35 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d7a85de062..6ee81df792 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -225,14 +225,18 @@ public: 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().deleteListing(folder_id,false); - LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); - LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + LLMarketplaceData::instance().addListing(folder_id,listing_id,version_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++; } @@ -297,11 +301,15 @@ public: 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); - LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + LLMarketplaceData::instance().addListing(folder_id,listing_id,version_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++; } } @@ -361,15 +369,19 @@ public: 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); - LLMarketplaceData::instance().setVersionFolderID(folder_id, version_id); - LLMarketplaceData::instance().setActivationState(folder_id, is_listed); - LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + 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++; } @@ -432,15 +444,19 @@ public: 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); - LLMarketplaceData::instance().setVersionFolderID(folder_id, version_id); - LLMarketplaceData::instance().setActivationState(folder_id, is_listed); - LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + 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) @@ -516,7 +532,8 @@ public: 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); @@ -529,8 +546,11 @@ public: } // Add the new association - LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed); - LLMarketplaceData::instance().setListingURL(folder_id, edit_url); + LLMarketplaceData::instance().addListing(folder_id,listing_id,version_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(); // Alert with DAMA informing the user that a version folder must be designated LLNotificationsUtil::add("AlertMerchantAssociateNeedsVersion"); @@ -1498,7 +1518,7 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& } // Methods privately called or called by SLM responders to perform changes -bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed) +bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed, bool update) { if (isListed(folder_id)) { @@ -1507,12 +1527,15 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, cons } mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id, listing_id, version_id, is_listed); - update_marketplace_category(folder_id, false); - gInventory.notifyObservers(); + if (update) + { + update_marketplace_category(folder_id, false); + gInventory.notifyObservers(); + } return true; } -bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update_slm) +bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update) { if (!isListed(folder_id)) { @@ -1521,7 +1544,7 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update_slm) } mMarketplaceItems.erase(folder_id); - if (update_slm) + if (update) { update_marketplace_category(folder_id, false); gInventory.notifyObservers(); @@ -1529,7 +1552,7 @@ bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update_slm) return true; } -bool LLMarketplaceData::deleteListing(S32 listing_id) +bool LLMarketplaceData::deleteListing(S32 listing_id, bool update) { if (listing_id == 0) { @@ -1537,7 +1560,7 @@ bool LLMarketplaceData::deleteListing(S32 listing_id) } LLUUID folder_id = getListingFolder(listing_id); - return deleteListing(folder_id); + return deleteListing(folder_id, update); } // Accessors @@ -1686,7 +1709,7 @@ void LLMarketplaceData::setUpdating(const LLUUID& folder_id, bool isUpdating) } // Private Modifiers -bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) +bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id, bool update) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); if (it == mMarketplaceItems.end()) @@ -1696,12 +1719,15 @@ bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id) (it->second).mListingId = listing_id; - update_marketplace_category(folder_id, false); - gInventory.notifyObservers(); + if (update) + { + update_marketplace_category(folder_id, false); + gInventory.notifyObservers(); + } return true; } -bool LLMarketplaceData::setCountOnHand(const LLUUID& folder_id, S32 count) +bool LLMarketplaceData::setCountOnHand(const LLUUID& folder_id, S32 count, bool update) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); if (it == mMarketplaceItems.end()) @@ -1714,7 +1740,7 @@ bool LLMarketplaceData::setCountOnHand(const LLUUID& folder_id, S32 count) return true; } -bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID& version_id) +bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID& version_id, bool update) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); if (it == mMarketplaceItems.end()) @@ -1729,14 +1755,17 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID } (it->second).mVersionFolderId = version_id; - - update_marketplace_category(old_version_id, false); - update_marketplace_category(version_id, false); - gInventory.notifyObservers(); + + if (update) + { + update_marketplace_category(old_version_id, false); + update_marketplace_category(version_id, false); + gInventory.notifyObservers(); + } return true; } -bool LLMarketplaceData::setActivationState(const LLUUID& folder_id, bool activate) +bool LLMarketplaceData::setActivationState(const LLUUID& folder_id, bool activate, bool update) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); if (it == mMarketplaceItems.end()) @@ -1746,12 +1775,15 @@ bool LLMarketplaceData::setActivationState(const LLUUID& folder_id, bool activat (it->second).mIsActive = activate; - update_marketplace_category((it->second).mListingFolderId, false); - gInventory.notifyObservers(); + if (update) + { + update_marketplace_category((it->second).mListingFolderId, false); + gInventory.notifyObservers(); + } return true; } -bool LLMarketplaceData::setListingURL(const LLUUID& folder_id, const std::string& edit_url) +bool LLMarketplaceData::setListingURL(const LLUUID& folder_id, const std::string& edit_url, bool update) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); if (it == mMarketplaceItems.end()) -- cgit v1.2.3 From 20173c9747e8205988d4f2f6f8d0b6c3d75e6e3d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sat, 8 Nov 2014 16:07:31 -0800 Subject: DD-274 : Do not display super long error description (there are in the log though) --- indra/newview/llmarketplacefunctions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 6ee81df792..c6660881f0 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -109,7 +109,8 @@ void log_SLM_warning(const std::string& request, U32 status, const std::string& // Prompt the user with the warning (so they know why things are failing) LLSD subs; subs["[ERROR_REASON]"] = reason; - subs["[ERROR_DESCRIPTION]"] = description; + // 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); } -- cgit v1.2.3 From 1461740a6818c752d3780f04431a4b3948616eb5 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 10 Nov 2014 10:30:22 -0800 Subject: DD-276 : Let the count on hand be updated locally when updateSLMListing returns with data from the server --- indra/newview/llmarketplacefunctions.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index c6660881f0..d900d29925 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1440,9 +1440,8 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) LLUUID version_uuid = getVersionFolder(listing_uuid); - // Keep track of the count on hand + // Also 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, activate, count); @@ -1465,9 +1464,8 @@ 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 + // Also update 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, count); @@ -1491,9 +1489,8 @@ bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id) bool is_listed = getActivationState(listing_uuid); LLUUID version_uuid = getVersionFolder(listing_uuid); - // Update the count on hand + // Compute the new 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); @@ -1509,9 +1506,6 @@ 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); -- cgit v1.2.3 From 00f3850fe2e2527f7f0f663f94cdabc83949b946 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sun, 14 Dec 2014 15:48:46 -0800 Subject: DD-299 : Suppress cap hardcoded fallback. Recheck cap after each teleport. --- indra/newview/llmarketplacefunctions.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d900d29925..c35b251c7e 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1178,10 +1178,13 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& else { // Initiate SLM connection and set responder - mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; std::string url = getSLMConnectURL("/merchant"); - log_SLM_infos("LLHTTPClient::get", url, ""); - LLHTTPClient::get(url, new LLSLMGetMerchantResponder(), LLSD()); + if (url != "") + { + mMarketPlaceStatus = MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING; + log_SLM_infos("LLHTTPClient::get", url, ""); + LLHTTPClient::get(url, new LLSLMGetMerchantResponder(), LLSD()); + } } } @@ -1325,16 +1328,10 @@ std::string LLMarketplaceData::getSLMConnectURL(const std::string& route) { // Get DirectDelivery cap url = regionp->getCapability("DirectDelivery"); - // *TODO : Take this DirectDelivery cap coping mechanism hack out - if (url == "") - { - url = "https://marketplace.secondlife-staging.com/api/1/viewer/" + gAgentID.asString(); - } - else + if (url != "") { - llinfos << "Merov : DD cap = " << url << ", agent = " << gAgentID.asString() << llendl; + url += route; } - url += route; } return url; } -- cgit v1.2.3 From 162d33dec4444c97837eba7e64eff964389d5987 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 15 Jan 2015 22:22:22 -0800 Subject: DD-303 : Auto activate version folder when only one present on creation or association --- indra/newview/llmarketplacefunctions.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index c35b251c7e..7d02b4e627 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -101,6 +101,24 @@ LLSD getMarketplaceStringSubstitutions() 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 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) @@ -1225,11 +1243,17 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) LLViewerInventoryCategory* category = gInventory.getCategory(folder_id); + // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately + LLUUID version_id = getVersionFolderIfUnique(folder_id); + + // Build the json message Json::Value root; Json::FastWriter writer; root["listing"]["name"] = category->getName(); - root["listing"]["inventory_info"]["listing_folder_id"] = category->getUUID().asString(); + 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"] = -1; std::string json_str = writer.write(root); @@ -1281,6 +1305,9 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing headers["Accept"] = "application/json"; headers["Content-Type"] = "application/json"; + // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately + LLUUID version_id = getVersionFolderIfUnique(folder_id); + Json::Value root; Json::FastWriter writer; @@ -1288,7 +1315,7 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing root["listing"]["id"] = listing_id; 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"]["version_folder_id"] = version_id.asString(); root["listing"]["inventory_info"]["count_on_hand"] = -1; std::string json_str = writer.write(root); -- cgit v1.2.3 From 855696c36980ded4aa93c315e1cd3d7e2b278446 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sat, 24 Jan 2015 17:30:05 -0800 Subject: DD-303 : Suppress message on activation when associating since we auto activate or have another message --- indra/newview/llmarketplacefunctions.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 7d02b4e627..d292dd25e7 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -571,8 +571,6 @@ public: update_marketplace_category(folder_id, false); gInventory.notifyObservers(); - // Alert with DAMA informing the user that a version folder must be designated - LLNotificationsUtil::add("AlertMerchantAssociateNeedsVersion"); it++; } -- cgit v1.2.3 From 03f18a55b7836c22470033267e69f267eb1a8d18 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 28 Jan 2015 22:16:47 -0800 Subject: DD-320 : Special case HTTP error 422 on the Marketplace and give it a nicer error dialog --- indra/newview/llmarketplacefunctions.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d292dd25e7..ab50506a4f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -124,13 +124,20 @@ LLUUID getVersionFolderIfUnique(const LLUUID& folder_id) 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; - // 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); - + if (status == 422) + { + // 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) { -- cgit v1.2.3 From ab91c83881ae182de2ebf8e99d31db2c5bd39f08 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 3 Feb 2015 22:04:58 -0800 Subject: DD-296 : Implement listing validation after we get all copied items confirmation from the server --- indra/newview/llmarketplacefunctions.cpp | 58 ++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index ab50506a4f..0315785960 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1099,13 +1099,43 @@ public: void LLMarketplaceInventoryObserver::changed(U32 mask) { + // When things are added to the marketplace, we might need to re-validate and fix the containing listings + if (mask & LLInventoryObserver::ADD) + { + const std::set& changed_items = gInventory.getChangedIDs(); + + std::set::const_iterator id_it = changed_items.begin(); + std::set::const_iterator id_end = changed_items.end(); + // First, count the number of items in this list... + S32 count = 0; + for (;id_it != id_end; ++id_it) + { + LLInventoryObject* obj = gInventory.getObject(*id_it); + if (obj && (LLAssetType::AT_CATEGORY != obj->getType())) + { + count++; + } + } + // Then, decrement the folders of that amount + // Note that of all of those, only one folder will be a listing folder (if at all). + // The other will be ignored by the decrement method. + id_it = changed_items.begin(); + for (;id_it != id_end; ++id_it) + { + LLInventoryObject* obj = gInventory.getObject(*id_it); + if (obj && (LLAssetType::AT_CATEGORY == obj->getType())) + { + LLMarketplaceData::instance().decrementValidationWaiting(obj->getUUID(),count); + } + } + } + // When things are changed in the inventory, this can trigger a host of changes in the marketplace listings folder: // * stock counts changing : no copy items coming in and out will change the stock count on folders // * version and listing folders : moving those might invalidate the marketplace data itself // Since we should cannot raise inventory change while the observer is called (the list will be cleared // once observers are called) we need to raise a flag in the inventory to signal that things have been dirtied. - - // That's the only changes that really do make sense for marketplace to worry about + if (mask & (LLInventoryObserver::INTERNAL | LLInventoryObserver::STRUCTURE)) { const std::set& changed_items = gInventory.getChangedIDs(); @@ -1134,7 +1164,7 @@ void LLMarketplaceInventoryObserver::changed(U32 mask) if (!item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID())) { LLMarketplaceData::instance().setDirtyCount(); - } + } } } } @@ -1732,6 +1762,28 @@ void LLMarketplaceData::setUpdating(const LLUUID& folder_id, bool isUpdating) } } +void LLMarketplaceData::setValidationWaiting(const LLUUID& folder_id, S32 count) +{ + mValidationWaitingList[folder_id] = count; +} + +void LLMarketplaceData::decrementValidationWaiting(const LLUUID& folder_id, S32 count) +{ + waiting_list_t::iterator found = mValidationWaitingList.find(folder_id); + if (found != mValidationWaitingList.end()) + { + found->second -= count; + if (found->second <= 0) + { + mValidationWaitingList.erase(found); + LLInventoryCategory *cat = gInventory.getCategory(folder_id); + validate_marketplacelistings(cat); + update_marketplace_category(folder_id); + gInventory.notifyObservers(); + } + } +} + // Private Modifiers bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id, bool update) { -- cgit v1.2.3 From fe4f5f13da50bf833254b1d168de3b60d56f2bcb Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 3 Feb 2015 23:43:15 -0800 Subject: DD-303 : do not force unlist when associating listings, let the 1 version folder policy apply, prompt user only if it doesn't --- indra/newview/llmarketplacefunctions.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 0315785960..3bedb0db44 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1348,7 +1348,6 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing // Note : we're assuming that sending unchanged info won't break anything server side... root["listing"]["id"] = listing_id; - root["listing"]["is_listed"] = false; 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"] = -1; -- cgit v1.2.3 From 0177f56fc92536b7fe0c8139ae1e081fd09eacfe Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sat, 21 Feb 2015 18:41:54 -0800 Subject: DD-335 : Improve the performance of Get listings by 400%, fix a bug when error occured on SLM --- indra/newview/llmarketplacefunctions.cpp | 34 +++++++------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 3bedb0db44..c0823cf1de 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -257,12 +257,7 @@ public: LLUUID version_id(version_uuid_string); if (folder_id.notNull()) { - LLMarketplaceData::instance().deleteListing(folder_id,false); - LLMarketplaceData::instance().addListing(folder_id,listing_id,version_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(); + LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed,edit_url,count); } it++; } @@ -331,9 +326,7 @@ public: LLUUID folder_id(folder_uuid_string); LLUUID version_id(version_uuid_string); - LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed, false); - LLMarketplaceData::instance().setListingURL(folder_id, edit_url, false); - LLMarketplaceData::instance().setCountOnHand(folder_id,count,false); + LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed,edit_url,count); update_marketplace_category(folder_id, false); gInventory.notifyObservers(); it++; @@ -572,9 +565,7 @@ public: } // Add the new association - LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed, false); - LLMarketplaceData::instance().setListingURL(folder_id, edit_url, false); - LLMarketplaceData::instance().setCountOnHand(folder_id,count,false); + LLMarketplaceData::instance().addListing(folder_id,listing_id,version_id,is_listed,edit_url,count); update_marketplace_category(folder_id, false); gInventory.notifyObservers(); @@ -1571,31 +1562,20 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& } // Methods privately called or called by SLM responders to perform changes -bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed, bool update) +bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& version_id, bool is_listed, const std::string& edit_url, S32 count) { - if (isListed(folder_id)) - { - // Listing already exists -> exit with error - return false; - } mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id, listing_id, version_id, is_listed); - - if (update) - { - update_marketplace_category(folder_id, false); - gInventory.notifyObservers(); - } + mMarketplaceItems[folder_id].mEditURL = edit_url; + mMarketplaceItems[folder_id].mCountOnHand = count; return true; } bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update) { - if (!isListed(folder_id)) + if (mMarketplaceItems.erase(folder_id) != 1) { - // Listing doesn't exist -> exit with error return false; } - mMarketplaceItems.erase(folder_id); if (update) { -- cgit v1.2.3 From df918447b7f804bb02f81ebc6f5f22babc8bb2d1 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 5 Mar 2015 21:58:57 -0800 Subject: DD-339 : Adding loading indicator to marketplace floater when the listings data and inventory data are being fetched --- indra/newview/llmarketplacefunctions.cpp | 35 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index c0823cf1de..ab3be79a2e 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -154,10 +154,6 @@ void log_SLM_infos(const std::string& request, const std::string& url, const std } } -// Merov: This is a temporary hack used by dev while secondlife-staging is down... -// *TODO : Suppress that before shipping! -static bool sBypassMerchant = false; - class LLSLMGetMerchantResponder : public LLHTTPClient::Responder { LOG_CLASS(LLSLMGetMerchantResponder); @@ -168,13 +164,7 @@ public: protected: virtual void httpFailure() { - if (sBypassMerchant) - { - // *TODO : Suppress that before shipping! - log_SLM_infos("Get /merchant", getStatus(), "SLM Connection error bypassed (debug only)"); - LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_MERCHANT); - } - else if (HTTP_NOT_FOUND == getStatus()) + if (HTTP_NOT_FOUND == getStatus()) { log_SLM_infos("Get /merchant", getStatus(), "User is not a merchant"); LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT); @@ -222,6 +212,7 @@ public: 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; @@ -232,6 +223,7 @@ public: if (!reader.parse(body,root)) { 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; @@ -263,6 +255,7 @@ public: } // Update all folders under the root + LLMarketplaceData::instance().setSLMDataFetched(MarketplaceFetchCodes::MARKET_FETCH_DONE); update_marketplace_category(mExpectedFolderId, false); gInventory.notifyObservers(); } @@ -1194,7 +1187,9 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id, // Data map LLMarketplaceData::LLMarketplaceData() : mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED), + mMarketPlaceDataFetched(MarketplaceFetchCodes::MARKET_FETCH_NOT_DONE), mStatusUpdatedSignal(NULL), + mDataFetchedSignal(NULL), mDirtyCount(false) { mInventoryObserver = new LLMarketplaceInventoryObserver; @@ -1232,6 +1227,15 @@ void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& } } +void LLMarketplaceData::setDataFetchedSignal(const status_updated_signal_t::slot_type& cb) +{ + if (mDataFetchedSignal == NULL) + { + mDataFetchedSignal = new status_updated_signal_t(); + } + mDataFetchedSignal->connect(cb); +} + // Get/Post/Put requests to the SLM Server using the SLM API void LLMarketplaceData::getSLMListings() { @@ -1397,6 +1401,15 @@ void LLMarketplaceData::setSLMStatus(U32 status) } } +void LLMarketplaceData::setSLMDataFetched(U32 status) +{ + mMarketPlaceDataFetched = status; + if (mDataFetchedSignal) + { + (*mDataFetchedSignal)(); + } +} + // Creation / Deletion / Update // Methods publicly called bool LLMarketplaceData::createListing(const LLUUID& folder_id) -- cgit v1.2.3 From 8e117983808f7b4f9d4aa288ec48cea5f0f89536 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 2 Apr 2015 14:01:03 -0700 Subject: DD-338 : Auto unlist when stock gets to 0 during stock folder manipulation --- indra/newview/llmarketplacefunctions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index ab3be79a2e..6ba98ff00e 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1307,6 +1307,13 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id Json::Value root; Json::FastWriter writer; + + // Note : auto unlist if the count is 0 (out of stock) + if (is_listed && (count == 0)) + { + is_listed = false; + LLNotificationsUtil::add("AlertMerchantStockFolderEmpty"); + } // Note : we're assuming that sending unchanged info won't break anything server side... root["listing"]["id"] = listing_id; -- cgit v1.2.3 From 79b891a688c0ebd329118a7ebc1a527c72d8f83f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Tue, 7 Apr 2015 15:22:32 -0700 Subject: DD-382 : Set count_on_hand correctly when creating or assigning a listing --- indra/newview/llmarketplacefunctions.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 6ba98ff00e..d634a252d9 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1274,8 +1274,13 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) LLViewerInventoryCategory* category = gInventory.getCategory(folder_id); // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately + S32 count = -1; LLUUID version_id = getVersionFolderIfUnique(folder_id); - + if (version_id.notNull()) + { + count = compute_stock_count(version_id, true); + } + // Build the json message Json::Value root; Json::FastWriter writer; @@ -1283,7 +1288,7 @@ void LLMarketplaceData::createSLMListing(const LLUUID& 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"] = -1; + root["listing"]["inventory_info"]["count_on_hand"] = count; std::string json_str = writer.write(root); @@ -1343,7 +1348,12 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing headers["Content-Type"] = "application/json"; // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately + S32 count = -1; LLUUID version_id = getVersionFolderIfUnique(folder_id); + if (version_id.notNull()) + { + count = compute_stock_count(version_id, true); + } Json::Value root; Json::FastWriter writer; @@ -1352,7 +1362,7 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing 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(); - root["listing"]["inventory_info"]["count_on_hand"] = -1; + root["listing"]["inventory_info"]["count_on_hand"] = count; std::string json_str = writer.write(root); -- cgit v1.2.3 From 56b1f3d88158eb86edff4ef5392f41c84f57d3fc Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 8 Apr 2015 23:14:43 -0700 Subject: DD-382 : Refactored the auto activate code in create and associate listing. Update count on hand in reassociate correctly. --- indra/newview/llmarketplacefunctions.cpp | 52 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d634a252d9..d10a1e8cd9 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1265,26 +1265,17 @@ void LLMarketplaceData::getSLMListing(S32 listing_id) LLHTTPClient::get(url, new LLSLMGetListingResponder(folder_id), headers); } -void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) +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"; - LLViewerInventoryCategory* category = gInventory.getCategory(folder_id); - - // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately - S32 count = -1; - LLUUID version_id = getVersionFolderIfUnique(folder_id); - if (version_id.notNull()) - { - count = compute_stock_count(version_id, true); - } - // 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(); @@ -1341,20 +1332,12 @@ void LLMarketplaceData::updateSLMListing(const LLUUID& folder_id, S32 listing_id LLHTTPClient::putRaw(url, data, size, new LLSLMUpdateListingsResponder(folder_id, is_listed, version_id), headers); } -void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing_id, const LLUUID& source_folder_id) +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"; - // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately - S32 count = -1; - LLUUID version_id = getVersionFolderIfUnique(folder_id); - if (version_id.notNull()) - { - count = compute_stock_count(version_id, true); - } - Json::Value root; Json::FastWriter writer; @@ -1362,7 +1345,6 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing 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(); - root["listing"]["inventory_info"]["count_on_hand"] = count; std::string json_str = writer.write(root); @@ -1437,8 +1419,16 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_id) return false; } + // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately + S32 count = -1; + LLUUID version_id = getVersionFolderIfUnique(folder_id); + if (version_id.notNull()) + { + count = compute_stock_count(version_id, true); + } + // Post the listing creation request to SLM - createSLMListing(folder_id); + createSLMListing(folder_id, version_id, count); return true; } @@ -1585,9 +1575,23 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& return false; } - // Post the listing update request to SLM - associateSLMListing(folder_id, listing_id, source_folder_id); + // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately + LLUUID version_id = getVersionFolderIfUnique(folder_id); + + // Post the listing associate request to SLM + associateSLMListing(folder_id, listing_id, version_id, source_folder_id); + // Update the other values as required + bool is_listed = false; // a listed listing cannot be reassociated + S32 count = -1; // count on hand must be set according to the new active version folder if any + if (version_id.notNull()) + { + count = compute_stock_count(version_id, true); + } + + // Post the listing update request to SLM + updateSLMListing(folder_id, listing_id, version_id, is_listed, count); + return true; } -- cgit v1.2.3 From 137185c2a9d2662a34813f83ec9971d00fa5af13 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 9 Apr 2015 14:28:58 -0700 Subject: DD-382 : Activation state should be unchanged when reassigning listing id --- indra/newview/llmarketplacefunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index d10a1e8cd9..5d8bab5833 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1582,11 +1582,11 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& associateSLMListing(folder_id, listing_id, version_id, source_folder_id); // Update the other values as required - bool is_listed = false; // a listed listing cannot be reassociated + bool is_listed = getActivationState(source_folder_id); // Use the activation state of the source listing S32 count = -1; // count on hand must be set according to the new active version folder if any if (version_id.notNull()) { - count = compute_stock_count(version_id, true); + count = compute_stock_count(version_id, true); // Use the stock count of the new listing } // Post the listing update request to SLM -- cgit v1.2.3 From a9c3681cb5eecc043dab3f5c9dc9d97bc1af1075 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 10 Apr 2015 17:37:11 -0700 Subject: DD-381 : Avoid unecessary SLM updates, suppress some update_marketplace_category() that are picked by dirty bit setup --- indra/newview/llmarketplacefunctions.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 5d8bab5833..de3bd35de0 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1507,6 +1507,12 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) return false; } + if (getActivationState(listing_uuid) == activate) + { + // If activation state is unchanged, no point spamming SLM with an update + return true; + } + LLUUID version_uuid = getVersionFolder(listing_uuid); // Also update the count on hand @@ -1530,6 +1536,12 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& return false; } + if (getVersionFolder(listing_uuid) == version_id) + { + // If version folder is unchanged, no point spamming SLM with an update + return true; + } + // 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)); @@ -1554,16 +1566,27 @@ bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id) return false; } + // Compute the new count on hand + S32 count = compute_stock_count(folder_id); + + if (getCountOnHand(listing_uuid) == count) + { + // If count on hand is unchanged, no point spamming SLM with an update + return true; + } + // Get the unchanged values bool is_listed = getActivationState(listing_uuid); LLUUID version_uuid = getVersionFolder(listing_uuid); - // Compute the new count on hand - S32 count = compute_stock_count(folder_id); // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_uuid, is_listed, count); + // Force the local value as it prevents spamming (count update may occur in burst when restocking) + // Note that if SLM has a good reason to return a different value, it'll be updated by the responder + setCountOnHand(listing_uuid, count, false); + return true; } -- cgit v1.2.3 From 637e096d5718d0a174b5383aa29e3480edd734ea Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 Apr 2015 15:29:56 -0700 Subject: DD-388 : More resilient way of reacting to not evaluated stock count throughout marketplace handling --- indra/newview/llmarketplacefunctions.cpp | 36 ++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index de3bd35de0..88a05c1e7f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1426,6 +1426,14 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_id) { count = compute_stock_count(version_id, true); } + + // Validate the count on hand + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at creation time + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing creation request to SLM createSLMListing(folder_id, version_id, count); @@ -1517,7 +1525,13 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) // Also update the count on hand S32 count = compute_stock_count(folder_id); - + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated locally, we should not change that SLM value + // We are assuming that this issue is local and should not modify server side values + count = getCountOnHand(listing_uuid); + } + // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_uuid, activate, count); @@ -1547,6 +1561,12 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& // Also update the count on hand S32 count = compute_stock_count(version_id); + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) when resetting the version folder + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_id, is_listed, count); @@ -1569,11 +1589,16 @@ bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id) // Compute the new count on hand S32 count = compute_stock_count(folder_id); - if (getCountOnHand(listing_uuid) == count) + if (count == getCountOnHand(listing_uuid)) { // If count on hand is unchanged, no point spamming SLM with an update return true; } + else if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If local count on hand is not known at that point, do *not* force an update to SLM + return false; + } // Get the unchanged values bool is_listed = getActivationState(listing_uuid); @@ -1611,6 +1636,13 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& { count = compute_stock_count(version_id, true); // Use the stock count of the new listing } + // Validate the count on hand + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at reassign time + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing update request to SLM updateSLMListing(folder_id, listing_id, version_id, is_listed, count); -- cgit v1.2.3 From 50805277b30fcbb9fcec8ed078f472d1e3ee3802 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 Apr 2015 15:58:56 -0700 Subject: DD-382 : Use default values on association when version folder is not unique --- indra/newview/llmarketplacefunctions.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 88a05c1e7f..bab655199f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1630,11 +1630,12 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& associateSLMListing(folder_id, listing_id, version_id, source_folder_id); // Update the other values as required - bool is_listed = getActivationState(source_folder_id); // Use the activation state of the source listing - S32 count = -1; // count on hand must be set according to the new active version folder if any + bool is_listed = false; + S32 count = -1; if (version_id.notNull()) { - count = compute_stock_count(version_id, true); // Use the stock count of the new listing + count = compute_stock_count(version_id, true); // Use the stock count of the new listing + is_listed = getActivationState(source_folder_id); // Use the activation state of the source listing } // Validate the count on hand if (count == COMPUTE_STOCK_NOT_EVALUATED) -- cgit v1.2.3 From 5411f349e5ed8835d5c99dbfb19a0934a6e5e28f Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 Apr 2015 17:18:01 -0700 Subject: DD-379 : a 404 on a Get /listing means that said listing is not in SLM, then delete it from the local store --- indra/newview/llmarketplacefunctions.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index bab655199f..5f5abd89e2 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -351,7 +351,15 @@ public: if (!isGoodStatus()) { - log_SLM_warning("Get /listing", getStatus(), getReason(), "", body); + 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; -- cgit v1.2.3 From e1aaebd59d7a825440cd51c7f902f0c9f30c3e88 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sat, 2 May 2015 14:46:30 -0700 Subject: DD-396 : Add decription check on the common 422 error on marketplace listing --- indra/newview/llmarketplacefunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 5f5abd89e2..e15014e6b9 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -124,7 +124,7 @@ LLUUID getVersionFolderIfUnique(const LLUUID& folder_id) 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) + 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"); -- cgit v1.2.3 From 4f9bf22d5fc473aa15dc7f298a93b89ddc30f415 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 8 Jun 2015 14:58:40 -0700 Subject: DD-336, DD-359 : WIP : Introduced a reverse lookup table for version folder to listing folder to improve performance --- indra/newview/llmarketplacefunctions.cpp | 40 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index e15014e6b9..3fec9e0da7 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1665,16 +1665,23 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, cons mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id, listing_id, version_id, is_listed); mMarketplaceItems[folder_id].mEditURL = edit_url; mMarketplaceItems[folder_id].mCountOnHand = count; + if (version_id.notNull()) + { + mVersionFolders[version_id] = folder_id; + } return true; } bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update) { + LLUUID version_folder = getVersionFolder(folder_id); + if (mMarketplaceItems.erase(folder_id) != 1) { return false; } - + mVersionFolders.erase(version_folder); + if (update) { update_marketplace_category(folder_id, false); @@ -1698,20 +1705,20 @@ bool LLMarketplaceData::deleteListing(S32 listing_id, bool update) bool LLMarketplaceData::getActivationState(const LLUUID& folder_id) { // Listing folder case - if (isListed(folder_id)) + marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); + if (it != mMarketplaceItems.end()) { - marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); return (it->second).mIsActive; } - // We need to iterate through the list to check it's not a version folder - marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); - while (it != mMarketplaceItems.end()) + // Version folder case + version_folders_list_t::iterator it_version = mVersionFolders.find(folder_id); + if (it_version != mVersionFolders.end()) { - if ((it->second).mVersionFolderId == folder_id) + marketplace_items_list_t::iterator it = mMarketplaceItems.find(it_version->second); + if (it != mMarketplaceItems.end()) { return (it->second).mIsActive; } - it++; } return false; } @@ -1771,16 +1778,8 @@ bool LLMarketplaceData::isListedAndActive(const LLUUID& folder_id) bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) { - marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); - while (it != mMarketplaceItems.end()) - { - if ((it->second).mVersionFolderId == folder_id) - { - return true; - } - it++; - } - return false; + version_folders_list_t::iterator it = mVersionFolders.find(folder_id); + return (it != mVersionFolders.end()); } bool LLMarketplaceData::isInActiveFolder(const LLUUID& obj_id) @@ -1908,6 +1907,11 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID } (it->second).mVersionFolderId = version_id; + mVersionFolders.erase(old_version_id); + if (version_id.notNull()) + { + mVersionFolders[version_id] = folder_id; + } if (update) { -- cgit v1.2.3 From ab73b1af8fad5f012f782632a08740b4a0a1c8fa Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 10 Jun 2015 14:53:12 -0700 Subject: DD-416 : Added DAMA when version folder is empty and unlisted, accelerated some functions avoiding depth computation when we could, fixed cut case --- indra/newview/llmarketplacefunctions.cpp | 83 +++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 18 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 3fec9e0da7..4a78d39be9 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1449,7 +1449,7 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_id) return true; } -bool LLMarketplaceData::clearListing(const LLUUID& folder_id) +bool LLMarketplaceData::clearListing(const LLUUID& folder_id, S32 depth) { if (folder_id.isNull()) { @@ -1457,8 +1457,13 @@ bool LLMarketplaceData::clearListing(const LLUUID& folder_id) return false; } + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(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 = (isListed(folder_id) ? folder_id : nested_parent_id(folder_id, depth)); S32 listing_id = getListingID(listing_uuid); @@ -1474,7 +1479,7 @@ bool LLMarketplaceData::clearListing(const LLUUID& folder_id) return true; } -bool LLMarketplaceData::getListing(const LLUUID& folder_id) +bool LLMarketplaceData::getListing(const LLUUID& folder_id, S32 depth) { if (folder_id.isNull()) { @@ -1482,8 +1487,13 @@ bool LLMarketplaceData::getListing(const LLUUID& folder_id) return false; } + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(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 = (isListed(folder_id) ? folder_id : nested_parent_id(folder_id, depth)); S32 listing_id = getListingID(listing_uuid); @@ -1511,10 +1521,15 @@ bool LLMarketplaceData::getListing(S32 listing_id) return true; } -bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) +bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate, S32 depth) { + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(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) @@ -1546,10 +1561,15 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) return true; } -bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& version_id) +bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& version_id, S32 depth) { + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(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) @@ -1582,10 +1602,15 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& return true; } -bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id) +bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id, S32 depth) { + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(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) @@ -1756,9 +1781,15 @@ LLUUID LLMarketplaceData::getListingFolder(S32 listing_id) return LLUUID::null; } -std::string LLMarketplaceData::getListingURL(const LLUUID& folder_id) +std::string LLMarketplaceData::getListingURL(const LLUUID& folder_id, S32 depth) { - S32 depth = depth_nesting_in_marketplace(folder_id); + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(folder_id); + + } + LLUUID listing_uuid = nested_parent_id(folder_id, depth); marketplace_items_list_t::iterator it = mMarketplaceItems.find(listing_uuid); @@ -1782,25 +1813,41 @@ bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id) return (it != mVersionFolders.end()); } -bool LLMarketplaceData::isInActiveFolder(const LLUUID& obj_id) +bool LLMarketplaceData::isInActiveFolder(const LLUUID& obj_id, S32 depth) { - S32 depth = depth_nesting_in_marketplace(obj_id); + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(obj_id); + + } + LLUUID listing_uuid = nested_parent_id(obj_id, depth); bool active = getActivationState(listing_uuid); LLUUID version_uuid = getVersionFolder(listing_uuid); return (active && ((obj_id == version_uuid) || gInventory.isObjectDescendentOf(obj_id, version_uuid))); } -LLUUID LLMarketplaceData::getActiveFolder(const LLUUID& obj_id) +LLUUID LLMarketplaceData::getActiveFolder(const LLUUID& obj_id, S32 depth) { - S32 depth = depth_nesting_in_marketplace(obj_id); + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(obj_id); + + } + LLUUID listing_uuid = nested_parent_id(obj_id, depth); return (getActivationState(listing_uuid) ? getVersionFolder(listing_uuid) : LLUUID::null); } -bool LLMarketplaceData::isUpdating(const LLUUID& folder_id) +bool LLMarketplaceData::isUpdating(const LLUUID& folder_id, S32 depth) { - S32 depth = depth_nesting_in_marketplace(folder_id); + // Evaluate the depth if it wasn't passed as a parameter + if (depth < 0) + { + depth = depth_nesting_in_marketplace(folder_id); + } if ((depth <= 0) || (depth > 2)) { // Only listing and version folders though are concerned by that status -- cgit v1.2.3 From 91c6f7a352b01cceac4bbd8cda5d2bed7435f388 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 10 Jun 2015 22:08:36 -0700 Subject: DD-393 : Rework association so that is_listed property is not overwritten before we get data from SLM --- indra/newview/llmarketplacefunctions.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'indra/newview/llmarketplacefunctions.cpp') diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 4a78d39be9..d5bfe1df4a 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -569,6 +569,9 @@ public: 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++; } @@ -1661,26 +1664,7 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& // Post the listing associate request to SLM associateSLMListing(folder_id, listing_id, version_id, source_folder_id); - - // Update the other values as required - bool is_listed = false; - S32 count = -1; - if (version_id.notNull()) - { - count = compute_stock_count(version_id, true); // Use the stock count of the new listing - is_listed = getActivationState(source_folder_id); // Use the activation state of the source listing - } - // Validate the count on hand - if (count == COMPUTE_STOCK_NOT_EVALUATED) - { - // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at reassign time - // It will get reevaluated and updated once the items are fetched - count = 0; - } - - // Post the listing update request to SLM - updateSLMListing(folder_id, listing_id, version_id, is_listed, count); - + return true; } -- cgit v1.2.3