diff options
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/newview/llinventorybridge.cpp | 2 | ||||
-rwxr-xr-x | indra/newview/llinventoryfunctions.cpp | 4 | ||||
-rwxr-xr-x | indra/newview/llmarketplacefunctions.cpp | 116 | ||||
-rwxr-xr-x | indra/newview/llmarketplacefunctions.h | 26 |
4 files changed, 68 insertions, 80 deletions
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 759716f024..6bb93633d4 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -872,7 +872,7 @@ void LLInvFVBridge::addMarketplaceContextMenuOptions(U32 flags, { disabled_items.push_back(std::string("Marketplace Create Listing")); disabled_items.push_back(std::string("Marketplace Associate Listing")); - if (LLMarketplaceData::instance().getVersionFolderID(mUUID).isNull()) + if (LLMarketplaceData::instance().getVersionFolder(mUUID).isNull()) { disabled_items.push_back(std::string("Marketplace List")); disabled_items.push_back(std::string("Marketplace Unlist")); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index f92831ccc5..283736f607 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -162,7 +162,7 @@ void update_marketplace_category(const LLUUID& cur_uuid) // Verify marketplace data consistency for this listing if (LLMarketplaceData::instance().isListed(listing_uuid)) { - LLUUID version_folder_uuid = LLMarketplaceData::instance().getVersionFolderID(listing_uuid); + LLUUID version_folder_uuid = LLMarketplaceData::instance().getVersionFolder(listing_uuid); if (version_folder_uuid.notNull() && !gInventory.isObjectDescendentOf(version_folder_uuid, listing_uuid)) { // *TODO : Confirm with Producer that this is what we want to happen in that case! @@ -867,7 +867,7 @@ S32 compute_stock_count(LLUUID cat_uuid) return -1; } - LLUUID version_folder_uuid = LLMarketplaceData::instance().getVersionFolderID(listing_uuid); + LLUUID version_folder_uuid = LLMarketplaceData::instance().getVersionFolder(listing_uuid); // Handle the case of the first 2 levels : listing and version folders if (depth == 1) { 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; } diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index 2aee41d3d8..c3f7693a67 100755 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -109,8 +109,8 @@ private: }; -// Classes handling the data coming from and going to the Marketplace DB: -// * implement the Marketplace API (TBD) +// Classes handling the data coming from and going to the Marketplace SLM Server DB: +// * implement the Marketplace API // * cache the current Marketplace data (tuples) // * provide methods to get Marketplace data on any inventory item // * set Marketplace data @@ -119,7 +119,9 @@ namespace SLMErrorCodes { enum eCode { - SLM_DONE = 200, + SLM_SUCCESS = 200, + SLM_RECORD_CREATED = 201, + SLM_MALFORMED_PAYLOAD = 400, SLM_NOT_FOUND = 404, }; } @@ -176,12 +178,12 @@ public: // Public SLM API : Initialization and status typedef boost::signals2::signal<void ()> status_updated_signal_t; - U32 getSLMStatus() const { return mMarketPlaceStatus; } void initializeSLM(const status_updated_signal_t::slot_type& cb); + U32 getSLMStatus() const { return mMarketPlaceStatus; } void getSLMListings(); bool isEmpty() { return (mMarketplaceItems.size() == 0); } - // Create/Delete Marketplace data set : each method returns true if the function succeeds, false if error + // High level create/delete/set Marketplace data: each method returns true if the function succeeds, false if error bool createListing(const LLUUID& folder_id); bool activateListing(const LLUUID& folder_id, bool activate); bool clearListing(const LLUUID& folder_id); @@ -192,14 +194,14 @@ public: bool isListed(const LLUUID& folder_id); // returns true if folder_id is a Listing folder bool isVersionFolder(const LLUUID& folder_id); // returns true if folder_id is a Version folder - // Access Marketplace data set : each method returns a default value if the folder_id can't be found + // Access Marketplace data set : each method returns a default value if the argument can't be found bool getActivationState(const LLUUID& folder_id); S32 getListingID(const LLUUID& folder_id); - LLUUID getVersionFolderID(const LLUUID& folder_id); + LLUUID getVersionFolder(const LLUUID& folder_id); std::string getListingURL(const LLUUID& folder_id); LLUUID getListingFolder(S32 listing_id); - // Used to flag if count values for Marketplace are likely to have to be updated + // Used to flag if stock count values for Marketplace have to be updated bool checkDirtyCount() { if (mDirtyCount) { mDirtyCount = false; return true; } else { return false; } } void setDirtyCount() { mDirtyCount = true; } @@ -210,8 +212,8 @@ private: bool deleteListing(const LLUUID& folder_id); bool setListingID(const LLUUID& folder_id, S32 listing_id); bool setVersionFolderID(const LLUUID& folder_id, const LLUUID& version_id); - bool setActivation(const LLUUID& folder_id, bool activate); - bool setEditURL(const LLUUID& folder_id, const std::string& edit_url); + bool setActivationState(const LLUUID& folder_id, bool activate); + bool setListingURL(const LLUUID& folder_id, const std::string& edit_url); // Private SLM API : package data and get/post/put requests to the SLM Server through the SLM API void setSLMStatus(U32 status); @@ -222,9 +224,9 @@ private: // Handling Marketplace connection and inventory connection U32 mMarketPlaceStatus; - status_updated_signal_t * mStatusUpdatedSignal; + status_updated_signal_t* mStatusUpdatedSignal; LLInventoryObserver* mInventoryObserver; - bool mDirtyCount; // If true, stock count value will be updating at the next check + bool mDirtyCount; // If true, stock count value need to be updated at the next check // The cache of SLM data (at last...) marketplace_items_list_t mMarketplaceItems; |