From 51e4ad0ed0ba07328ec8415742a3f5c60afc7244 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sat, 26 Jul 2014 14:44:04 -0700 Subject: DD-101 : Do not list or associate listings that do not validate. Present user with relevant error when that happens. --- indra/newview/llfloatermarketplacelistings.cpp | 4 +- indra/newview/llfloatermarketplacelistings.h | 2 +- indra/newview/llinventorybridge.cpp | 35 ++++++++++++- indra/newview/llinventorybridge.h | 2 + indra/newview/llinventoryfunctions.cpp | 60 +++++++++++++--------- indra/newview/llinventoryfunctions.h | 4 +- .../newview/skins/default/xui/en/notifications.xml | 13 +++++ 7 files changed, 89 insertions(+), 31 deletions(-) diff --git a/indra/newview/llfloatermarketplacelistings.cpp b/indra/newview/llfloatermarketplacelistings.cpp index 8778839fea..ec551aca06 100755 --- a/indra/newview/llfloatermarketplacelistings.cpp +++ b/indra/newview/llfloatermarketplacelistings.cpp @@ -593,7 +593,7 @@ void LLFloaterMarketplaceValidation::onOpen(const LLSD& key) if (marketplacelistings_id.notNull()) { LLViewerInventoryCategory* cat = gInventory.getCategory(marketplacelistings_id); - validate_marketplacelistings(cat,boost::bind(&LLFloaterMarketplaceValidation::appendMessage, this, _1)); + validate_marketplacelistings(cat,boost::bind(&LLFloaterMarketplaceValidation::appendMessage, this, _1, _2)); } } @@ -605,7 +605,7 @@ void LLFloaterMarketplaceValidation::onOK( void* userdata ) self->closeFloater(); } -void LLFloaterMarketplaceValidation::appendMessage(std::string& message) +void LLFloaterMarketplaceValidation::appendMessage(std::string& message, LLError::ELevel log_level) { if (mEditor) { diff --git a/indra/newview/llfloatermarketplacelistings.h b/indra/newview/llfloatermarketplacelistings.h index f68097f156..b1de8d09d9 100755 --- a/indra/newview/llfloatermarketplacelistings.h +++ b/indra/newview/llfloatermarketplacelistings.h @@ -161,7 +161,7 @@ public: virtual void draw(); virtual void onOpen(const LLSD& key); - void appendMessage(std::string& message); + void appendMessage(std::string& message, LLError::ELevel log_level); static void onOK( void* userdata ); private: diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index ba5374e437..5c5ad1fa30 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2975,7 +2975,15 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) } else if ("marketplace_list" == action) { - if (depth_nesting_in_marketplace(mUUID) == 1) + LLViewerInventoryCategory* cat = gInventory.getCategory(mUUID); + mMessage = ""; + if (!validate_marketplacelistings(cat,boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2))) + { + LLSD subs; + subs["[ERROR_CODE]"] = mMessage; + LLNotificationsUtil::add("MerchantListingFailed", subs); + } + else if (depth_nesting_in_marketplace(mUUID) == 1) { LLMarketplaceData::instance().activateListing(mUUID,true); } @@ -3025,7 +3033,18 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) } else if ("marketplace_associate_listing" == action) { - LLFloaterAssociateListing::show(mUUID); + LLViewerInventoryCategory* cat = gInventory.getCategory(mUUID); + mMessage = ""; + if (!validate_marketplacelistings(cat,boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2))) + { + LLSD subs; + subs["[ERROR_CODE]"] = mMessage; + LLNotificationsUtil::add("MerchantListingFailed", subs); + } + else + { + LLFloaterAssociateListing::show(mUUID); + } return; } else if ("marketplace_edit_listing" == action) @@ -3055,6 +3074,18 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) } } +void LLFolderBridge::gatherMessage(std::string& message, LLError::ELevel log_level) +{ + if (log_level >= LLError::LEVEL_ERROR) + { + if (!mMessage.empty()) + { + mMessage += "\n"; + } + mMessage += message; + } +} + void LLFolderBridge::openItem() { LL_DEBUGS() << "LLFolderBridge::openItem()" << LL_ENDL; diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 029a5395ca..4a3f2ebf12 100755 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -361,11 +361,13 @@ public: private: void callback_pasteFromClipboard(const LLSD& notification, const LLSD& response); void perform_pasteFromClipboard(); + void gatherMessage(std::string& message, LLError::ELevel log_level); bool mCallingCards; bool mWearables; bool mIsLoading; LLTimer mTimeSinceRequestStart; + std::string mMessage; LLRootHandle mHandle; }; diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 0fd7eb067c..bdd129d54c 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -1340,13 +1340,16 @@ bool move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUU return true; } -// Make all relevant business logic checks on the marketplace listings starting with the folder as argument -// This function does no deletion of listings but a mere audit and raises issues to the user -// The only thing that's done is to move and sort folders containing no-copy items to stock folders -// *TODO : Add the rest of the SLM/AIS business logic (limit of nesting depth, stock folder consistency, overall limit on listings, etc...) -void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_t cb) -{ - // Special case a stock folder depth issue +// Make all relevant business logic checks on the marketplace listings starting with the folder as argument. +// This function does no deletion of listings but a mere audit and raises issues to the user (through the +// optional callback cb). It also returns a boolean, true if things validate, false if issues are raised. +// The only inventory changes that are done is to move and sort folders containing no-copy items to stock folders. +bool validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_t cb) +{ + // Folder is valid unless issue is raised + bool result = true; + + // Special case a stock folder depth issue LLViewerInventoryCategory * viewer_cat = (LLViewerInventoryCategory *) (cat); const LLFolderType::EType folder_type = cat->getPreferredType(); S32 depth = depth_nesting_in_marketplace(cat->getUUID()); @@ -1354,28 +1357,34 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ { // If the folder is not under the marketplace listings root, validation should not be applied // *TODO: Should we call update_marketplace_category(cat->getUUID()) ? - return; + return result; } + if (depth == 1) { if (cb) { std::string message = LLTrans::getString("Marketplace Validation Intro") + cat->getName(); - cb(message); + cb(message,LLError::LEVEL_INFO); } std::string message; - bool is_ok = can_move_folder_to_marketplace(cat, cat, cat, message, 0); - if (cb && !is_ok) + if (!can_move_folder_to_marketplace(cat, cat, cat, message, 0)) { - message = LLTrans::getString("Marketplace Validation Error") + message; - cb(message); + result = false; + if (cb) + { + message = LLTrans::getString("Marketplace Validation Error") + message; + cb(message,LLError::LEVEL_ERROR); + } } } + std::string indent; for (int i = 1; i < depth; i++) { indent += " "; } + if ((folder_type == LLFolderType::FT_MARKETPLACE_STOCK) && (depth <= 2)) { // Nest the stock folder one level deeper in a normal folder and restart from there @@ -1385,12 +1394,12 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ if (cb) { std::string message = indent + LLTrans::getString("Marketplace Validation Warning Stock") + cat->getName(); - cb(message); + cb(message,LLError::LEVEL_WARN); } LLInventoryCategory* new_cat = gInventory.getCategory(folder_uuid); gInventory.changeCategoryParent(viewer_cat, folder_uuid, false); - validate_marketplacelistings(new_cat, cb); - return; + result &= validate_marketplacelistings(new_cat, cb); + return result; } LLInventoryModel::cat_array_t* cat_array; @@ -1417,10 +1426,11 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ std::string error_msg; if (!can_move_to_marketplace(item, error_msg, false)) { + result = false; if (cb) { std::string message = indent + LLTrans::getString("Marketplace Validation Error") + error_msg + " : " + viewer_inv_item->getName(); - cb(message); + cb(message,LLError::LEVEL_ERROR); } continue; } @@ -1451,7 +1461,7 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ if ((cat_array->size() == 0) && cb) { std::string message = indent + LLTrans::getString("Marketplace Validation Warning Empty") + cat->getName(); - cb(message); + cb(message,LLError::LEVEL_WARN); } } // If we have one kind only, in the correct folder type at the right depth -> all OK @@ -1461,7 +1471,7 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ if (cb) { std::string message = indent + LLTrans::getString("Marketplace Validation Log") + cat->getName(); - cb(message); + cb(message,LLError::LEVEL_INFO); } } else @@ -1485,7 +1495,7 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ { message = indent + LLTrans::getString("Marketplace Validation Warning Create Version") + viewer_cat->getName(); } - cb(message); + cb(message,LLError::LEVEL_WARN); } LLUUID folder_uuid = gInventory.createNewCategory(parent_uuid, new_folder_type, viewer_cat->getName()); // Move each item to the new folder @@ -1495,7 +1505,7 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ if (cb) { std::string message = indent + LLTrans::getString("Marketplace Validation Warning Move") + viewer_inv_item->getName(); - cb(message); + cb(message,LLError::LEVEL_WARN); } gInventory.changeItemParent(viewer_inv_item, folder_uuid, true); items_vector[i].pop_back(); @@ -1511,11 +1521,11 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ if (cb) { std::string message = indent + LLTrans::getString("Marketplace Validation Warning Delete") + viewer_cat->getName(); - cb(message); + cb(message,LLError::LEVEL_WARN); } gInventory.removeCategory(cat->getUUID()); gInventory.notifyObservers(); - return; + return result; } else { @@ -1531,8 +1541,10 @@ void validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_ for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++) { LLInventoryCategory* category = *iter; - validate_marketplacelistings(category, cb); + result &= validate_marketplacelistings(category, cb); } + + return result; } ///---------------------------------------------------------------------------- diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 2d9c6fe38e..76f2120415 100755 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -74,13 +74,13 @@ void copy_item_to_outbox(LLInventoryItem* inv_item, LLUUID dest_folder, const LL void move_item_within_outbox(LLInventoryItem* inv_item, LLUUID dest_folder, S32 operation_id); void copy_folder_to_outbox(LLInventoryCategory* inv_cat, const LLUUID& dest_folder, const LLUUID& top_level_folder, S32 operation_id); -typedef boost::function validation_callback_t; +typedef boost::function validation_callback_t; bool can_move_item_to_marketplace(const LLInventoryCategory* root_folder, LLInventoryCategory* dest_folder, LLInventoryItem* inv_item, std::string& tooltip_msg, S32 bundle_size = 1); bool can_move_folder_to_marketplace(const LLInventoryCategory* root_folder, LLInventoryCategory* dest_folder, LLInventoryCategory* inv_cat, std::string& tooltip_msg, S32 bundle_size = 1); bool move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_folder, bool copy = false); bool move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUUID& dest_folder, bool copy = false); -void validate_marketplacelistings(LLInventoryCategory* inv_cat, validation_callback_t cb = NULL); +bool validate_marketplacelistings(LLInventoryCategory* inv_cat, validation_callback_t cb = NULL); S32 depth_nesting_in_marketplace(LLUUID cur_uuid); LLUUID nested_parent_id(LLUUID cur_uuid, S32 depth); S32 compute_stock_count(LLUUID cat_uuid); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 8166ba67a3..062a93f3cf 100755 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -306,6 +306,19 @@ Initialization with the Marketplace failed because of a system or network error. yestext="OK"/> + + Listing to Marketplace failed with error : + + '[ERROR_CODE]' + + + +