summaryrefslogtreecommitdiff
path: root/indra/newview/llmarketplacefunctions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llmarketplacefunctions.cpp')
-rwxr-xr-xindra/newview/llmarketplacefunctions.cpp251
1 files changed, 251 insertions, 0 deletions
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index 05c9d76810..40417bf77b 100755
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -30,12 +30,14 @@
#include "llagent.h"
#include "llhttpclient.h"
+#include "llinventoryfunctions.h"
#include "llsdserialize.h"
#include "lltimer.h"
#include "lltrans.h"
#include "llviewercontrol.h"
#include "llviewermedia.h"
#include "llviewernetwork.h"
+#include "llviewerregion.h"
//
@@ -425,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;
@@ -528,3 +542,240 @@ void LLMarketplaceInventoryImporter::updateImport()
}
}
+//
+// Direct Delivery : Marketplace tuples and data
+//
+
+// Tuple == Item
+LLMarketplaceTuple::LLMarketplaceTuple() :
+ mListingFolderId(),
+ mListingId(0),
+ mVersionFolderId(),
+ mIsActive(false)
+{
+}
+
+LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id) :
+ mListingFolderId(folder_id),
+ mListingId(0),
+ mVersionFolderId(),
+ mIsActive(false)
+{
+}
+
+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),
+ mIsActive(is_listed)
+{
+}
+
+
+// Data map
+LLMarketplaceData::LLMarketplaceData()
+{
+ mTestCurrentMarketplaceID = 1234567;
+}
+
+// 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);
+
+ // *TODO : Create the listing on SLM and get the ID (blocking?)
+ // For the moment, we use that wonky test ID generator...
+ 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, S32 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))
+ {
+ // 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)
+{
+ // 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;
+}
+
+S32 LLMarketplaceData::getListingID(const LLUUID& folder_id)
+{
+ marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id);
+ return (it == mMarketplaceItems.end() ? 0 : (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).mVersionFolderId);
+}
+
+// Reverse lookup : find the listing folder id from the listing id
+LLUUID LLMarketplaceData::getListingFolder(S32 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);
+ 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;
+}
+
+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/<listing_id>
+ 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;
+}
+
+// Modifiers
+bool LLMarketplaceData::setListingID(const LLUUID& folder_id, S32 listing_id)
+{
+ marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id);
+ if (it == mMarketplaceItems.end())
+ {
+ return false;
+ }
+ else
+ {
+ (it->second).mListingId = listing_id;
+ update_marketplace_category(folder_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
+ {
+ 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)
+{
+ // 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);
+ 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);
+ return true;
+ }
+ it++;
+ }
+ return false;
+}
+
+