summaryrefslogtreecommitdiff
path: root/indra/newview/llagentwearablesfetch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llagentwearablesfetch.cpp')
-rw-r--r--indra/newview/llagentwearablesfetch.cpp166
1 files changed, 124 insertions, 42 deletions
diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp
index 45274a8e2c..f6bb1b9bc9 100644
--- a/indra/newview/llagentwearablesfetch.cpp
+++ b/indra/newview/llagentwearablesfetch.cpp
@@ -37,9 +37,61 @@
#include "llagentwearables.h"
#include "llappearancemgr.h"
#include "llinventoryfunctions.h"
+#include "llstartup.h"
#include "llvoavatarself.h"
-LLInitialWearablesFetch::LLInitialWearablesFetch()
+
+class LLOrderMyOutfitsOnDestroy: public LLInventoryCallback
+{
+public:
+ LLOrderMyOutfitsOnDestroy() {};
+
+ virtual ~LLOrderMyOutfitsOnDestroy()
+ {
+ if (!LLApp::isRunning())
+ {
+ llwarns << "called during shutdown, skipping" << llendl;
+ return;
+ }
+
+ const LLUUID& my_outfits_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS);
+ if (my_outfits_id.isNull()) return;
+
+ LLInventoryModel::cat_array_t* cats;
+ LLInventoryModel::item_array_t* items;
+ gInventory.getDirectDescendentsOf(my_outfits_id, cats, items);
+ if (!cats) return;
+
+ //My Outfits should at least contain saved initial outfit and one another outfit
+ if (cats->size() < 2)
+ {
+ llwarning("My Outfits category was not populated properly", 0);
+ return;
+ }
+
+ llinfos << "Starting updating My Outfits with wearables ordering information" << llendl;
+
+ for (LLInventoryModel::cat_array_t::iterator outfit_iter = cats->begin();
+ outfit_iter != cats->end(); ++outfit_iter)
+ {
+ const LLUUID& cat_id = (*outfit_iter)->getUUID();
+ if (cat_id.isNull()) continue;
+
+ // saved initial outfit already contains wearables ordering information
+ if (cat_id == LLAppearanceMgr::getInstance()->getBaseOutfitUUID()) continue;
+
+ LLAppearanceMgr::getInstance()->updateClothingOrderingInfo(cat_id);
+ }
+
+ llinfos << "Finished updating My Outfits with wearables ordering information" << llendl;
+ }
+
+ /* virtual */ void fire(const LLUUID& inv_item) {};
+};
+
+
+LLInitialWearablesFetch::LLInitialWearablesFetch(const LLUUID& cof_id) :
+ LLInventoryFetchDescendentsObserver(cof_id)
{
}
@@ -54,7 +106,7 @@ void LLInitialWearablesFetch::done()
// gInventory.notifyObservers. The results will be handled in the next
// idle tick instead.
gInventory.removeObserver(this);
- doOnIdle(boost::bind(&LLInitialWearablesFetch::processContents,this));
+ doOnIdleOneTime(boost::bind(&LLInitialWearablesFetch::processContents,this));
}
void LLInitialWearablesFetch::add(InitialWearableData &data)
@@ -69,12 +121,13 @@ void LLInitialWearablesFetch::processContents()
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t wearable_array;
LLFindWearables is_wearable;
- gInventory.collectDescendentsIf(mCompleteFolders.front(), cat_array, wearable_array,
+ gInventory.collectDescendentsIf(mComplete.front(), cat_array, wearable_array,
LLInventoryModel::EXCLUDE_TRASH, is_wearable);
LLAppearanceMgr::instance().setAttachmentInvLinkEnable(true);
if (wearable_array.count() > 0)
{
+ gAgentWearables.notifyLoadingStarted();
LLAppearanceMgr::instance().updateAppearanceFromCOF();
}
else
@@ -86,12 +139,11 @@ void LLInitialWearablesFetch::processContents()
delete this;
}
-class LLFetchAndLinkObserver: public LLInventoryFetchObserver
+class LLFetchAndLinkObserver: public LLInventoryFetchItemsObserver
{
public:
- LLFetchAndLinkObserver(LLInventoryFetchObserver::item_ref_t& ids):
- m_ids(ids),
- LLInventoryFetchObserver(true) // retry for missing items
+ LLFetchAndLinkObserver(uuid_vec_t& ids):
+ LLInventoryFetchItemsObserver(ids)
{
}
~LLFetchAndLinkObserver()
@@ -103,8 +155,8 @@ public:
// Link to all fetched items in COF.
LLPointer<LLInventoryCallback> link_waiter = new LLUpdateAppearanceOnDestroy;
- for (LLInventoryFetchObserver::item_ref_t::iterator it = m_ids.begin();
- it != m_ids.end();
+ for (uuid_vec_t::iterator it = mIDs.begin();
+ it != mIDs.end();
++it)
{
LLUUID id = *it;
@@ -119,12 +171,11 @@ public:
item->getLinkedUUID(),
LLAppearanceMgr::instance().getCOF(),
item->getName(),
+ item->getDescription(),
LLAssetType::AT_LINK,
link_waiter);
}
}
-private:
- LLInventoryFetchObserver::item_ref_t m_ids;
};
void LLInitialWearablesFetch::processWearablesMessage()
@@ -132,7 +183,7 @@ void LLInitialWearablesFetch::processWearablesMessage()
if (!mAgentInitialWearables.empty()) // We have an empty current outfit folder, use the message data instead.
{
const LLUUID current_outfit_id = LLAppearanceMgr::instance().getCOF();
- LLInventoryFetchObserver::item_ref_t ids;
+ uuid_vec_t ids;
for (U8 i = 0; i < mAgentInitialWearables.size(); ++i)
{
// Populate the current outfit folder with links to the wearables passed in the message
@@ -164,7 +215,7 @@ void LLInitialWearablesFetch::processWearablesMessage()
{
LLViewerObject* attached_object = (*attachment_iter);
if (!attached_object) continue;
- const LLUUID& item_id = attached_object->getItemID();
+ const LLUUID& item_id = attached_object->getAttachmentItemID();
if (item_id.isNull()) continue;
ids.push_back(item_id);
}
@@ -173,10 +224,10 @@ void LLInitialWearablesFetch::processWearablesMessage()
// Need to fetch the inventory items for ids, then create links to them after they arrive.
LLFetchAndLinkObserver *fetcher = new LLFetchAndLinkObserver(ids);
- fetcher->fetchItems(ids);
+ fetcher->startFetch();
// If no items to be fetched, done will never be triggered.
- // TODO: Change LLInventoryFetchObserver::fetchItems to trigger done() on this condition.
- if (fetcher->isEverythingComplete())
+ // TODO: Change LLInventoryFetchItemsObserver::fetchItems to trigger done() on this condition.
+ if (fetcher->isFinished())
{
fetcher->done();
}
@@ -191,10 +242,13 @@ void LLInitialWearablesFetch::processWearablesMessage()
}
}
-LLLibraryOutfitsFetch::LLLibraryOutfitsFetch() :
+LLLibraryOutfitsFetch::LLLibraryOutfitsFetch(const LLUUID& my_outfits_id) :
+ LLInventoryFetchDescendentsObserver(my_outfits_id),
mCurrFetchStep(LOFS_FOLDER),
mOutfitsPopulated(false)
{
+ llinfos << "created" << llendl;
+
mMyOutfitsID = LLUUID::null;
mClothingID = LLUUID::null;
mLibraryClothingID = LLUUID::null;
@@ -204,18 +258,23 @@ LLLibraryOutfitsFetch::LLLibraryOutfitsFetch() :
LLLibraryOutfitsFetch::~LLLibraryOutfitsFetch()
{
+ llinfos << "destroyed" << llendl;
}
void LLLibraryOutfitsFetch::done()
{
+ llinfos << "start" << llendl;
+
// Delay this until idle() routine, since it's a heavy operation and
// we also can't have it run within notifyObservers.
- doOnIdle(boost::bind(&LLLibraryOutfitsFetch::doneIdle,this));
- gInventory.removeObserver(this); // Prevent doOnIdle from being added twice.
+ doOnIdleOneTime(boost::bind(&LLLibraryOutfitsFetch::doneIdle,this));
+ gInventory.removeObserver(this); // Prevent doOnIdleOneTime from being added twice.
}
void LLLibraryOutfitsFetch::doneIdle()
{
+ llinfos << "start" << llendl;
+
gInventory.addObserver(this); // Add this back in since it was taken out during ::done()
switch (mCurrFetchStep)
@@ -254,14 +313,18 @@ void LLLibraryOutfitsFetch::doneIdle()
}
}
-void LLLibraryOutfitsFetch::folderDone(void)
+void LLLibraryOutfitsFetch::folderDone()
{
+ llinfos << "start" << llendl;
+
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t wearable_array;
gInventory.collectDescendents(mMyOutfitsID, cat_array, wearable_array,
LLInventoryModel::EXCLUDE_TRASH);
- // Early out if we already have items in My Outfits.
- if (cat_array.count() > 0 || wearable_array.count() > 0)
+
+ // Early out if we already have items in My Outfits
+ // except the case when My Outfits contains just initial outfit
+ if (cat_array.count() > 1)
{
mOutfitsPopulated = true;
return;
@@ -272,6 +335,7 @@ void LLLibraryOutfitsFetch::folderDone(void)
// If Library->Clothing->Initial Outfits exists, use that.
LLNameCategoryCollector matchFolderFunctor("Initial Outfits");
+ cat_array.clear();
gInventory.collectDescendentsIf(mLibraryClothingID,
cat_array, wearable_array,
LLInventoryModel::EXCLUDE_TRASH,
@@ -282,21 +346,24 @@ void LLLibraryOutfitsFetch::folderDone(void)
mLibraryClothingID = cat->getUUID();
}
- mCompleteFolders.clear();
+ mComplete.clear();
// Get the complete information on the items in the inventory.
uuid_vec_t folders;
folders.push_back(mClothingID);
folders.push_back(mLibraryClothingID);
- fetchDescendents(folders);
- if (isEverythingComplete())
+ setFetchIDs(folders);
+ startFetch();
+ if (isFinished())
{
done();
}
}
-void LLLibraryOutfitsFetch::outfitsDone(void)
+void LLLibraryOutfitsFetch::outfitsDone()
{
+ llinfos << "start" << llendl;
+
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t wearable_array;
uuid_vec_t folders;
@@ -336,10 +403,10 @@ void LLLibraryOutfitsFetch::outfitsDone(void)
mImportedClothingID = cat->getUUID();
}
- mCompleteFolders.clear();
-
- fetchDescendents(folders);
- if (isEverythingComplete())
+ mComplete.clear();
+ setFetchIDs(folders);
+ startFetch();
+ if (isFinished())
{
done();
}
@@ -372,8 +439,10 @@ private:
};
// Copy the clothing folders from the library into the imported clothing folder
-void LLLibraryOutfitsFetch::libraryDone(void)
+void LLLibraryOutfitsFetch::libraryDone()
{
+ llinfos << "start" << llendl;
+
if (mImportedClothingID != LLUUID::null)
{
// Skip straight to fetching the contents of the imported folder
@@ -427,23 +496,27 @@ void LLLibraryOutfitsFetch::libraryDone(void)
}
}
-void LLLibraryOutfitsFetch::importedFolderFetch(void)
+void LLLibraryOutfitsFetch::importedFolderFetch()
{
+ llinfos << "start" << llendl;
+
// Fetch the contents of the Imported Clothing Folder
uuid_vec_t folders;
folders.push_back(mImportedClothingID);
- mCompleteFolders.clear();
-
- fetchDescendents(folders);
- if (isEverythingComplete())
+ mComplete.clear();
+ setFetchIDs(folders);
+ startFetch();
+ if (isFinished())
{
done();
}
}
-void LLLibraryOutfitsFetch::importedFolderDone(void)
+void LLLibraryOutfitsFetch::importedFolderDone()
{
+ llinfos << "start" << llendl;
+
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t wearable_array;
uuid_vec_t folders;
@@ -463,19 +536,24 @@ void LLLibraryOutfitsFetch::importedFolderDone(void)
mImportedClothingFolders.push_back(cat->getUUID());
}
- mCompleteFolders.clear();
- fetchDescendents(folders);
- if (isEverythingComplete())
+ mComplete.clear();
+ setFetchIDs(folders);
+ startFetch();
+ if (isFinished())
{
done();
}
}
-void LLLibraryOutfitsFetch::contentsDone(void)
+void LLLibraryOutfitsFetch::contentsDone()
{
+ llinfos << "start" << llendl;
+
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t wearable_array;
+ LLPointer<LLOrderMyOutfitsOnDestroy> order_myoutfits_on_destroy = new LLOrderMyOutfitsOnDestroy;
+
for (uuid_vec_t::const_iterator folder_iter = mImportedClothingFolders.begin();
folder_iter != mImportedClothingFolders.end();
++folder_iter)
@@ -487,6 +565,9 @@ void LLLibraryOutfitsFetch::contentsDone(void)
llwarns << "Library folder import for uuid:" << folder_id << " failed to find folder." << llendl;
continue;
}
+
+ //initial outfit should be already in My Outfits
+ if (cat->getName() == LLStartUp::getInitialOutfitName()) continue;
// First, make a folder in the My Outfits directory.
LLUUID new_outfit_folder_id = gInventory.createNewCategory(mMyOutfitsID, LLFolderType::FT_OUTFIT, cat->getName());
@@ -506,8 +587,9 @@ void LLLibraryOutfitsFetch::contentsDone(void)
item->getLinkedUUID(),
new_outfit_folder_id,
item->getName(),
+ item->getDescription(),
LLAssetType::AT_LINK,
- NULL);
+ order_myoutfits_on_destroy);
}
}