summaryrefslogtreecommitdiff
path: root/indra/newview/llinventoryobserver.cpp
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2010-04-07 13:30:21 -0400
committerLoren Shih <seraph@lindenlab.com>2010-04-07 13:30:21 -0400
commit5d3de2ea03ff500690acec13fd4b403dc8a72088 (patch)
treec16bcbe34d65de983e58f94a5837f603e616d17e /indra/newview/llinventoryobserver.cpp
parente9f06764412af37023f45c4d83b2b97c48d2a13e (diff)
EXT-6745 : Refactor LLFetchComboObserver to use LLFetchItems and LLFetchDescedents instead of code duplication
Took out a bunch of code duplication from the FetchComboObserver and am using the LLFetchItems/DescendentsObservers instead. Also added some comments and made some minor superficial cleanup to LLInventoryObserver done().
Diffstat (limited to 'indra/newview/llinventoryobserver.cpp')
-rw-r--r--indra/newview/llinventoryobserver.cpp135
1 files changed, 31 insertions, 104 deletions
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 35bd06125f..26fe1904fb 100644
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -205,10 +205,6 @@ void LLInventoryFetchItemsObserver::changed(U32 mask)
//llinfos << "LLInventoryFetchItemsObserver::changed() mIncomplete size " << mIncomplete.size() << llendl;
}
-void LLInventoryFetchItemsObserver::done()
-{
-}
-
void fetch_items_from_llsd(const LLSD& items_llsd)
{
if (!items_llsd.size()) return;
@@ -406,119 +402,50 @@ BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInven
}
LLInventoryFetchComboObserver::LLInventoryFetchComboObserver(const uuid_vec_t& folder_ids,
- const uuid_vec_t& item_ids) :
- mFolderIDs(folder_ids),
- mItemIDs(item_ids),
- mDone(FALSE)
+ const uuid_vec_t& item_ids)
{
-}
+ mFetchDescendents = new LLInventoryFetchDescendentsObserver(folder_ids);
-void LLInventoryFetchComboObserver::changed(U32 mask)
-{
- if (!mIncompleteItems.empty())
- {
- for (uuid_vec_t::iterator it = mIncompleteItems.begin(); it < mIncompleteItems.end(); )
- {
- LLViewerInventoryItem* item = gInventory.getItem(*it);
- if (!item)
- {
- it = mIncompleteItems.erase(it);
- continue;
- }
- if (item->isFinished())
- {
- mCompleteItems.push_back(*it);
- it = mIncompleteItems.erase(it);
- continue;
- }
- ++it;
- }
- }
- if (!mIncompleteFolders.empty())
+ uuid_vec_t pruned_item_ids;
+ for (uuid_vec_t::const_iterator item_iter = item_ids.begin();
+ item_iter != item_ids.end();
+ ++item_iter)
{
- for (uuid_vec_t::iterator it = mIncompleteFolders.begin(); it < mIncompleteFolders.end();)
+ const LLUUID& item_id = (*item_iter);
+ const LLViewerInventoryItem* item = gInventory.getItem(item_id);
+ if (item && std::find(folder_ids.begin(), folder_ids.end(), item->getParentUUID()) == folder_ids.end())
{
- LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
- if (!cat)
- {
- it = mIncompleteFolders.erase(it);
- continue;
- }
- if (gInventory.isCategoryComplete(*it))
- {
- mCompleteFolders.push_back(*it);
- it = mIncompleteFolders.erase(it);
- continue;
- }
- ++it;
+ continue;
}
+ pruned_item_ids.push_back(item_id);
}
- if (!mDone && mIncompleteItems.empty() && mIncompleteFolders.empty())
+
+ mFetchItems = new LLInventoryFetchItemsObserver(pruned_item_ids);
+ mFetchDescendents = new LLInventoryFetchDescendentsObserver(folder_ids);
+}
+
+LLInventoryFetchComboObserver::~LLInventoryFetchComboObserver()
+{
+ mFetchItems->done();
+ mFetchDescendents->done();
+ delete mFetchItems;
+ delete mFetchDescendents;
+}
+
+void LLInventoryFetchComboObserver::changed(U32 mask)
+{
+ mFetchItems->changed(mask);
+ mFetchDescendents->changed(mask);
+ if (mFetchItems->isFinished() && mFetchDescendents->isFinished())
{
- mDone = TRUE;
done();
}
}
void LLInventoryFetchComboObserver::startFetch()
{
- lldebugs << "LLInventoryFetchComboObserver::startFetch()" << llendl;
- for (uuid_vec_t::const_iterator fit = mFolderIDs.begin(); fit != mFolderIDs.end(); ++fit)
- {
- LLViewerInventoryCategory* cat = gInventory.getCategory(*fit);
- if (!cat) continue;
- if (!gInventory.isCategoryComplete(*fit))
- {
- cat->fetch();
- lldebugs << "fetching folder " << *fit <<llendl;
- mIncompleteFolders.push_back(*fit);
- }
- else
- {
- mCompleteFolders.push_back(*fit);
- lldebugs << "completing folder " << *fit <<llendl;
- }
- }
-
- // Now for the items - we fetch everything which is not a direct
- // descendent of an incomplete folder because the item will show
- // up in an inventory descendents message soon enough so we do not
- // have to fetch it individually.
- LLSD items_llsd;
- LLUUID owner_id;
- for (uuid_vec_t::const_iterator iit = mItemIDs.begin(); iit != mItemIDs.end(); ++iit)
- {
- const LLViewerInventoryItem* item = gInventory.getItem(*iit);
- if (!item)
- {
- lldebugs << "uanble to find item " << *iit << llendl;
- continue;
- }
- if (item->isFinished())
- {
- // It's complete, so put it on the complete container.
- mCompleteItems.push_back(*iit);
- lldebugs << "completing item " << *iit << llendl;
- continue;
- }
- else
- {
- mIncompleteItems.push_back(*iit);
- owner_id = item->getPermissions().getOwner();
- }
- if (std::find(mIncompleteFolders.begin(), mIncompleteFolders.end(), item->getParentUUID()) == mIncompleteFolders.end())
- {
- LLSD item_entry;
- item_entry["owner_id"] = owner_id;
- item_entry["item_id"] = (*iit);
- items_llsd.append(item_entry);
- }
- else
- {
- lldebugs << "not worrying about " << *iit << llendl;
- }
- }
- fetch_items_from_llsd(items_llsd);
+ mFetchItems->startFetch();
+ mFetchDescendents->startFetch();
}
void LLInventoryExistenceObserver::watchItem(const LLUUID& id)