diff options
-rw-r--r-- | indra/newview/llfloateroutbox.cpp | 135 | ||||
-rw-r--r-- | indra/newview/llfloateroutbox.h | 10 | ||||
-rw-r--r-- | indra/newview/llmarketplacefunctions.cpp | 101 | ||||
-rw-r--r-- | indra/newview/llmarketplacefunctions.h | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/strings.xml | 24 |
5 files changed, 162 insertions, 112 deletions
diff --git a/indra/newview/llfloateroutbox.cpp b/indra/newview/llfloateroutbox.cpp index 8d64214e8c..b10ef0ba64 100644 --- a/indra/newview/llfloateroutbox.cpp +++ b/indra/newview/llfloateroutbox.cpp @@ -30,6 +30,7 @@ #include "llfloaterreg.h" #include "llfolderview.h" +#include "llinventorymodelbackgroundfetch.h" #include "llinventoryobserver.h" #include "llinventorypanel.h" #include "llmarketplacefunctions.h" @@ -139,6 +140,8 @@ BOOL LLFloaterOutbox::postBuild() mImportButton = getChild<LLButton>("outbox_import_btn"); mImportButton->setCommitCallback(boost::bind(&LLFloaterOutbox::onImportButtonClicked, this)); + + LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLFloaterOutbox::onFocusReceived, this)); return TRUE; } @@ -187,10 +190,30 @@ void LLFloaterOutbox::onOpen(const LLSD& key) } updateView(); + + // + // Trigger fetch of outbox contents + // + + fetchOutboxContents(); +} + +void LLFloaterOutbox::onFocusReceived() +{ + fetchOutboxContents(); +} + +void LLFloaterOutbox::fetchOutboxContents() +{ + if (mOutboxId.notNull()) + { + LLInventoryModelBackgroundFetch::instance().start(mOutboxId); + } } void LLFloaterOutbox::setupOutbox(const LLUUID& outboxId) -{ +{ + llassert(outboxId.notNull()); llassert(mOutboxId.isNull()); llassert(mCategoriesObserver == NULL); @@ -228,15 +251,47 @@ void LLFloaterOutbox::setupOutbox(const LLUUID& outboxId) mOutboxInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); mOutboxInventoryPanel->getFilter()->markDefault(); - // Set selection callback for proper update of inventory status buttons - //mOutboxInventoryPanel->setSelectCallback(boost::bind(&LLPanelMarketplaceOutbox::onSelectionChange, this)); + fetchOutboxContents(); +} + +void LLFloaterOutbox::updateItemCount() +{ + S32 item_count = 0; + + if (mOutboxId.notNull()) + { + LLInventoryModel::cat_array_t * cats; + LLInventoryModel::item_array_t * items; + gInventory.getDirectDescendentsOf(mOutboxId, cats, items); + + item_count = cats->count() + items->count(); + } + + mOutboxItemCount = item_count; + + switch (mOutboxItemCount) + { + case 0: mInventoryFolderCountText->setText(getString("OutboxFolderCount0")); break; + case 1: mInventoryFolderCountText->setText(getString("OutboxFolderCount1")); break; + default: + { + std::string item_count_str = llformat("%d", mOutboxItemCount); + + LLStringUtil::format_map_t args; + args["[NUM]"] = item_count_str; + + mInventoryFolderCountText->setText(getString("OutboxFolderCountN", args)); + break; + } + } - // Set up the note to display when the outbox is empty - mOutboxInventoryPanel->getFilter()->setEmptyLookupMessage("InventoryOutboxNoItems"); + mImportButton->setEnabled(mOutboxItemCount > 0); } void LLFloaterOutbox::updateView() { + updateItemCount(); + if (mOutboxItemCount > 0) { mOutboxInventoryPanel->setVisible(TRUE); @@ -251,44 +306,17 @@ void LLFloaterOutbox::updateView() std::string outbox_title; std::string outbox_tooltip; + LLStringUtil::format_map_t subs = getMarketplaceStringSubstitutions(); + if (mOutboxId.notNull()) { - outbox_text = LLTrans::getString("InventoryOutboxNoItems"); + outbox_text = LLTrans::getString("InventoryOutboxNoItems", subs); outbox_title = LLTrans::getString("InventoryOutboxNoItemsTitle"); outbox_tooltip = LLTrans::getString("InventoryOutboxNoItemsTooltip"); } else { - // - // The string to become a merchant contains 3 URL's which need the domain name patched in. - // - - std::string domain = "secondlife.com"; - - if (!LLGridManager::getInstance()->isInProductionGrid()) - { - std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); - domain = llformat("%s.lindenlab.com", utf8str_tolower(gridLabel).c_str()); - } - - LLStringUtil::format_map_t domain_arg; - domain_arg["[DOMAIN_NAME]"] = domain; - - std::string marketplace_url = LLTrans::getString("MarketplaceURL", domain_arg); - std::string marketplace_url_create = LLTrans::getString("MarketplaceURL_CreateStore", domain_arg); - std::string marketplace_url_info = LLTrans::getString("MarketplaceURL_LearnMore", domain_arg); - - LLStringUtil::format_map_t args1, args2, args3; - args1["[MARKETPLACE_URL]"] = marketplace_url; - args2["[LEARN_MORE_URL]"] = marketplace_url_info; - args3["[CREATE_STORE_URL]"] = marketplace_url_create; - - // NOTE: This is dumb, ridiculous and very finicky. The order of these is very important - // to have these three string substitutions work properly. - outbox_text = LLTrans::getString("InventoryOutboxNotMerchant", args1); - LLStringUtil::format(outbox_text, args2); - LLStringUtil::format(outbox_text, args3); - + outbox_text = LLTrans::getString("InventoryOutboxNotMerchant", subs); outbox_title = LLTrans::getString("InventoryOutboxNotMerchantTitle"); outbox_tooltip = LLTrans::getString("InventoryOutboxNotMerchantTooltip"); } @@ -306,7 +334,7 @@ BOOL LLFloaterOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, std::string& tooltip_msg) { // Pass drag and drop to this floater to the outbox inventory control - + if (LLMarketplaceInventoryImporter::getInstance()->isImportInProgress() || (mWindowShade && mWindowShade->isShown())) { @@ -329,37 +357,8 @@ void LLFloaterOutbox::onImportButtonClicked() void LLFloaterOutbox::onOutboxChanged() { llassert(!mOutboxId.isNull()); - - U32 item_count = 0; - - const LLFolderViewFolder * outbox_folder = mOutboxInventoryPanel->getRootFolder(); - - if (outbox_folder) - { - item_count += outbox_folder->getFoldersCount(); - item_count += outbox_folder->getItemsCount(); - } - - mOutboxItemCount = item_count; - - switch (mOutboxItemCount) - { - case 0: mInventoryFolderCountText->setText(getString("OutboxFolderCount0")); break; - case 1: mInventoryFolderCountText->setText(getString("OutboxFolderCount1")); break; - default: - { - std::string item_count_str = llformat("%d", mOutboxItemCount); - - LLStringUtil::format_map_t args; - args["[NUM]"] = item_count_str; - - mInventoryFolderCountText->setText(getString("OutboxFolderCountN", args)); - break; - } - } - - mImportButton->setEnabled(mOutboxItemCount > 0); + fetchOutboxContents(); updateView(); } @@ -384,6 +383,8 @@ void LLFloaterOutbox::importReportResults(U32 status, const LLSD& content) //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); LLNotificationsUtil::add("OutboxImportFailed", subs); } + + updateView(); } void LLFloaterOutbox::importStatusChanged(bool inProgress) diff --git a/indra/newview/llfloateroutbox.h b/indra/newview/llfloateroutbox.h index 8023434675..5222db1142 100644 --- a/indra/newview/llfloateroutbox.h +++ b/indra/newview/llfloateroutbox.h @@ -58,8 +58,6 @@ public: // virtuals BOOL postBuild(); - void onClose(bool app_quitting); - void onOpen(const LLSD& key); BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, @@ -69,12 +67,20 @@ public: void showNotification(LLNotificationPtr notify); protected: + void fetchOutboxContents(); + void importReportResults(U32 status, const LLSD& content); void importStatusChanged(bool inProgress); + void onClose(bool app_quitting); + void onOpen(const LLSD& key); + + void onFocusReceived(); + void onImportButtonClicked(); void onOutboxChanged(); + void updateItemCount(); void updateView(); private: diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 9c67c589b8..225bb059c9 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -30,6 +30,7 @@ #include "llagent.h" #include "llhttpclient.h" +#include "lltrans.h" #include "llviewermedia.h" #include "llviewernetwork.h" @@ -38,6 +39,59 @@ // Helpers // +static std::string getMarketplaceDomain() +{ + std::string domain = "secondlife.com"; + + if (!LLGridManager::getInstance()->isInProductionGrid()) + { + const std::string& grid_label = LLGridManager::getInstance()->getGridLabel(); + const std::string& grid_label_lower = utf8str_tolower(grid_label); + + if (grid_label_lower == "damballah") + { + domain = "secondlife-staging.com"; + } + else + { + domain = llformat("%s.lindenlab.com", grid_label_lower.c_str()); + } + } + + return domain; +} + +static std::string getMarketplaceURL(const std::string& urlStringName) +{ + LLStringUtil::format_map_t domain_arg; + domain_arg["[MARKETPLACE_DOMAIN_NAME]"] = getMarketplaceDomain(); + + std::string marketplace_url = LLTrans::getString(urlStringName, domain_arg); + + return marketplace_url; +} + +LLStringUtil::format_map_t getMarketplaceStringSubstitutions() +{ + std::string marketplace_url = getMarketplaceURL("MarketplaceURL"); + std::string marketplace_url_create = getMarketplaceURL("MarketplaceURL_CreateStore"); + std::string marketplace_url_dashboard = getMarketplaceURL("MarketplaceURL_Dashboard"); + std::string marketplace_url_info = getMarketplaceURL("MarketplaceURL_LearnMore"); + + LLStringUtil::format_map_t agent_map; + agent_map["[AGENT_ID]"] = gAgent.getID().getString(); + + LLStringUtil::format(marketplace_url_dashboard, agent_map); + + LLStringUtil::format_map_t marketplace_sub_map; + marketplace_sub_map["[MARKETPLACE_URL]"] = marketplace_url; + marketplace_sub_map["[MARKETPLACE_CREATE_STORE_URL]"] = marketplace_url_create; + marketplace_sub_map["[MARKETPLACE_LEARN_MORE_URL]"] = marketplace_url_info; + marketplace_sub_map["[MARKETPLACE_DASHBOARD_URL]"] = marketplace_url_dashboard; + + return marketplace_sub_map; +} + namespace LLMarketplaceImport { // Basic interface for this namespace @@ -61,42 +115,6 @@ namespace LLMarketplaceImport static LLSD sImportResults = LLSD::emptyMap(); - // Internal helper functions - - std::string getBaseURL() - { - std::string url = "https://marketplace.secondlife.com/"; - - if (!LLGridManager::getInstance()->isInProductionGrid()) - { - std::string gridLabel = utf8str_tolower(LLGridManager::getInstance()->getGridLabel()); - - if (gridLabel == "damballah") - { - url = "https://marketplace.secondlife-staging.com/"; - } - else - { - url = llformat("https://marketplace.%s.lindenlab.com/", gridLabel.c_str()); - } - } - - url += "api/1/"; - url += gAgent.getID().getString(); - url += "/inventory/"; - - return url; - } - - std::string getInventoryImportURL() - { - std::string url = getBaseURL(); - - url += "import/"; - - return url; - } - // Responders class LLImportPostResponder : public LLHTTPClient::Responder @@ -200,6 +218,17 @@ namespace LLMarketplaceImport return sImportResults; } + static std::string getInventoryImportURL() + { + std::string url = getMarketplaceURL("MarketplaceURL"); + + url += "api/1/"; + url += gAgent.getID().getString(); + url += "/inventory/import/"; + + return url; + } + void establishMarketplaceSessionCookie() { sImportInProgress = true; diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index 5ca0bdfe77..f501f1ee8b 100644 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -34,6 +34,10 @@ #include <boost/signals2.hpp> #include "llsingleton.h" +#include "llstring.h" + + +LLStringUtil::format_map_t getMarketplaceStringSubstitutions(); namespace MarketplaceErrorCodes diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index b8d5f93320..7dd965de84 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -2029,18 +2029,28 @@ Returns a string with the requested data about the region <string name="FavoritesNoMatchingItems">Drag a landmark here to add it to your favorites.</string> <string name="InventoryNoTexture">You do not have a copy of this texture in your inventory</string> <string name="InventoryInboxNoItems">When you purchase or otherwise receive an item, it will appear here so you can drag it to a folder in your inventory, or delete it if you do not wish to keep it.</string> - <string name="MarketplaceURL">http://marketplace.[DOMAIN_NAME]</string> - <string name="MarketplaceURL_CreateStore">http://marketplace.[DOMAIN_NAME]/create_store</string> - <string name="MarketplaceURL_LearnMore">http://marketplace.[DOMAIN_NAME]/learn_more</string> + <string name="MarketplaceURL">https://marketplace.[MARKETPLACE_DOMAIN_NAME]</string> + <string name="MarketplaceURL_CreateStore">https://marketplace.[MARKETPLACE_DOMAIN_NAME]/create_store</string> + <string name="MarketplaceURL_Dashboard">https://marketplace.[MARKETPLACE_DOMAIN_NAME]/merchants/[AGENT_ID]/store/dashboard</string> + <string name="MarketplaceURL_LearnMore">https://marketplace.[MARKETPLACE_DOMAIN_NAME]/learn_more</string> <string name="InventoryOutboxCreationErrorTitle">Your Merchant Outbox is not properly configured</string> <string name="InventoryOutboxCreationErrorTooltip">Merchant Outbox configuration error</string> <string name="InventoryOutboxCreationError">Please contact Customer Service to correct the problem.</string> - <string name="InventoryOutboxNotMerchantTitle">Anyone can sell items on the Marketplace</string> + <string name="InventoryOutboxNotMerchantTitle">Anyone can sell items on the Marketplace.</string> <string name="InventoryOutboxNotMerchantTooltip">Become a merchant!</string> - <string name="InventoryOutboxNotMerchant">[[MARKETPLACE_URL] The Second Life Marketplace] offers more than one million virtual products for sale, all of them created by Residents. You, too, can sell items you create, as well as some of the items you have purchased. It’s easy and setup is free. [[LEARN_MORE_URL] Learn more] or [[CREATE_STORE_URL] create a store] on the Marketplace to get started.</string> - <string name="InventoryOutboxNoItemsTitle">A new way to send items to the Marketplace</string> + <string name="InventoryOutboxNotMerchant"> + The Second Life Marketplace offers more than one million virtual products for sale, all of them created by Residents like you. You too can create items and sell them on the Marketplace. Creating a store is easy and free of charge. + + [[MARKETPLACE_URL] Visit the Marketplace] + [[MARKETPLACE_LEARN_MORE_URL] Learn more about creating a store] + </string> + <string name="InventoryOutboxNoItemsTitle">Your outbox is empty.</string> <string name="InventoryOutboxNoItemsTooltip">Drag and drop items here to prepare them for sale on the Marketplace</string> - <string name="InventoryOutboxNoItems">Drag items or folders that you wish to sell into this area. A copy of the item will appear, leaving your inventory unchanged, unless you have dragged a no-copy item. When you are ready to send the items to the Marketplace, click the Upload button. Once your items have been moved to your Marketplace Inventory, they will disappear from this folder.</string> + <string name="InventoryOutboxNoItems"> + Drag folders to this area. When you are ready to send them to the Marketplace for sale, click the "Send to Marketplace" button below. + + [[MARKETPLACE_DASHBOARD_URL] Go to your Merchant Dashboard] + </string> <string name="Marketplace Error None">No errors</string> <string name="Marketplace Error Not Merchant">Error: Before sending items to the Marketplace you will need to set yourself up as a merchant (free of charge).</string> |