diff options
-rwxr-xr-x | indra/newview/llinventoryfunctions.cpp | 34 | ||||
-rwxr-xr-x | indra/newview/llmarketplacefunctions.cpp | 58 | ||||
-rwxr-xr-x | indra/newview/llmarketplacefunctions.h | 8 |
3 files changed, 94 insertions, 6 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 97d6bf004b..6721a9e4f4 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -130,6 +130,25 @@ S32 count_stock_folders(LLInventoryModel::cat_array_t& categories) return count; } +// Helper funtion : Count the number of items (not folders) in the descending hierarchy +S32 count_descendants_items(const LLUUID& cat_id) +{ + LLInventoryModel::cat_array_t* cat_array; + LLInventoryModel::item_array_t* item_array; + gInventory.getDirectDescendentsOf(cat_id,cat_array,item_array); + + S32 count = item_array->size(); + + LLInventoryModel::cat_array_t cat_array_copy = *cat_array; + for (LLInventoryModel::cat_array_t::iterator iter = cat_array_copy.begin(); iter != cat_array_copy.end(); iter++) + { + LLViewerInventoryCategory* category = *iter; + count += count_descendants_items(category->getUUID()); + } + + return count; +} + // Helper function : Returns true if the hierarchy contains nocopy items bool contains_nocopy_items(const LLUUID& id) { @@ -360,6 +379,12 @@ void copy_inventory_category(LLInventoryModel* model, LLInventoryModel::cat_array_t* cat_array; LLInventoryModel::item_array_t* item_array; gInventory.getDirectDescendentsOf(cat->getUUID(),cat_array,item_array); + + // If root_copy_id is null, tell the marketplace model we'll be waiting for new items to be copied over for this folder + if (root_copy_id.isNull()) + { + LLMarketplaceData::instance().setValidationWaiting(root_id,count_descendants_items(cat->getUUID())); + } // Copy all the items LLInventoryModel::item_array_t item_array_copy = *item_array; @@ -377,6 +402,8 @@ void copy_inventory_category(LLInventoryModel* model, LLViewerInventoryItem * viewer_inv_item = (LLViewerInventoryItem *) item; gInventory.changeItemParent(viewer_inv_item, new_cat_uuid, true); } + // Decrement the count in root_id since that one item won't be copied over + LLMarketplaceData::instance().decrementValidationWaiting(root_id); } else { @@ -1443,6 +1470,8 @@ bool move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol return false; } } + + open_marketplace_listings(); return true; } @@ -1477,11 +1506,10 @@ bool move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUU { // Reparent the folder gInventory.changeCategoryParent(viewer_inv_cat, dest_folder, false); + // Check the destination folder recursively for no copy items and promote the including folders if any + validate_marketplacelistings(dest_cat); } - // Check the destination folder recursively for no copy items and promote the including folders if any - validate_marketplacelistings(dest_cat); - // Update the modified folders update_marketplace_category(src_folder); update_marketplace_category(dest_folder); 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<LLUUID>& changed_items = gInventory.getChangedIDs(); + + std::set<LLUUID>::const_iterator id_it = changed_items.begin(); + std::set<LLUUID>::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<LLUUID>& 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) { diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index af274c18f2..aa78cfd2d8 100755 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -223,6 +223,10 @@ public: void setDirtyCount() { mDirtyCount = true; } void setUpdating(const LLUUID& folder_id, bool isUpdating); + // Used to decide when to run a validation on listing folders + void setValidationWaiting(const LLUUID& folder_id, S32 count); + void decrementValidationWaiting(const LLUUID& folder_id, S32 count = 1); + private: // Modify Marketplace data set : each method returns true if the function succeeds, false if error // Used internally only by SLM Responders when data are received from the SLM Server @@ -250,6 +254,10 @@ private: // Update data std::set<LLUUID> mPendingUpdateSet; + + // Listing folders waiting for validation + typedef std::map<LLUUID,S32> waiting_list_t; + waiting_list_t mValidationWaitingList; // The cache of SLM data (at last...) marketplace_items_list_t mMarketplaceItems; |