diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-04-28 12:41:34 +0100 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-04-28 12:41:34 +0100 |
commit | 47fa4bc01478d5ef0311aa491321bfb397777302 (patch) | |
tree | 7d9ab0c14c56ece7b178dc9d8ab67633cd476af0 /indra/newview/llinventoryobserver.cpp | |
parent | b740924c9dbb6a5697254ca238e099a62e7054a9 (diff) | |
parent | 96df3f3eb1351973d140ba73b507de44b1052c89 (diff) |
merge from viewer-trunk
Diffstat (limited to 'indra/newview/llinventoryobserver.cpp')
-rw-r--r-- | indra/newview/llinventoryobserver.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index 29d99d328a..214b5d317a 100644 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -650,3 +650,53 @@ void LLInventoryTransactionObserver::changed(U32 mask) } } } + +void LLInventoryCategoriesObserver::changed(U32 mask) +{ + if (!mCategoryMap.size()) + return; + + for (category_map_t::iterator iter = mCategoryMap.begin(); + iter != mCategoryMap.end(); + ++iter) + { + LLViewerInventoryCategory* category = gInventory.getCategory((*iter).first); + if (!category) + continue; + + S32 version = category->getVersion(); + if (version != (*iter).second.mVersion) + { + // Update category version in map. + (*iter).second.mVersion = version; + (*iter).second.mCallback(); + } + } +} + +void LLInventoryCategoriesObserver::addCategory(const LLUUID& cat_id, callback_t cb) +{ + S32 version; + LLViewerInventoryCategory* category = gInventory.getCategory(cat_id); + if (category) + { + // Inventory category version is used to find out if some changes + // to a category have been made. + version = category->getVersion(); + } + else + { + // If category could not be retrieved it might mean that + // inventory is unusable at the moment so the category is + // stored with VERSION_UNKNOWN and it may be updated later. + version = LLViewerInventoryCategory::VERSION_UNKNOWN; + } + + version = category->getVersion(); + mCategoryMap.insert(category_map_value_t(cat_id, LLCategoryData(cb, version))); +} + +void LLInventoryCategoriesObserver::removeCategory(const LLUUID& cat_id) +{ + mCategoryMap.erase(cat_id); +} |