From c3d9316dff568d5265d856a708e3909deae09f18 Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Tue, 6 Apr 2010 17:30:23 -0400
Subject: [PATCH] EXT-6727 : Allow LLInventoryObservers to target a single item
 (instead of a vector of items)

Added new constructors to LLInventoryFetch types to allow passing in a single item.
---
 indra/newview/llagentwearables.cpp      |  8 ++------
 indra/newview/llagentwearablesfetch.cpp |  8 ++++----
 indra/newview/llagentwearablesfetch.h   |  4 ++--
 indra/newview/llappearancemgr.cpp       |  2 +-
 indra/newview/llappearancemgr.h         |  8 +++-----
 indra/newview/llfriendcard.cpp          |  8 +++-----
 indra/newview/llinventoryobserver.cpp   | 22 ++++++++++++++++++----
 indra/newview/llinventoryobserver.h     | 11 +++++++----
 indra/newview/llpaneloutfitedit.cpp     |  6 ++----
 indra/newview/llviewermenu.cpp          |  9 +++------
 indra/newview/llviewermessage.cpp       | 16 +++++-----------
 11 files changed, 50 insertions(+), 52 deletions(-)

diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index bc8931827e..aedea5660f 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -905,9 +905,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
 
 		// Get the UUID of the current outfit folder (will be created if it doesn't exist)
 		const LLUUID current_outfit_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT);
-		uuid_vec_t folders;
-		folders.push_back(current_outfit_id);
-		LLInitialWearablesFetch* outfit = new LLInitialWearablesFetch(folders);
+		LLInitialWearablesFetch* outfit = new LLInitialWearablesFetch(current_outfit_id);
 		
 		//lldebugs << "processAgentInitialWearablesUpdate()" << llendl;
 		// Add wearables
@@ -2061,9 +2059,7 @@ void LLAgentWearables::populateMyOutfitsFolder(void)
 	llinfos << "starting outfit population" << llendl;
 
 	const LLUUID& my_outfits_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS);
-	uuid_vec_t folders;
-	folders.push_back(my_outfits_id);
-	LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch(folders);
+	LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch(my_outfits_id);
 	outfits->mMyOutfitsID = my_outfits_id;
 	
 	// Get the complete information on the items in the inventory and 
diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp
index 6b7edaa302..04a970b683 100644
--- a/indra/newview/llagentwearablesfetch.cpp
+++ b/indra/newview/llagentwearablesfetch.cpp
@@ -39,8 +39,8 @@
 #include "llinventoryfunctions.h"
 #include "llvoavatarself.h"
 
-LLInitialWearablesFetch::LLInitialWearablesFetch(const uuid_vec_t& ids) :
-	LLInventoryFetchDescendentsObserver(ids)
+LLInitialWearablesFetch::LLInitialWearablesFetch(const LLUUID& cof_id) :
+	LLInventoryFetchDescendentsObserver(cof_id)
 {
 }
 
@@ -189,8 +189,8 @@ void LLInitialWearablesFetch::processWearablesMessage()
 	}
 }
 
-LLLibraryOutfitsFetch::LLLibraryOutfitsFetch(const uuid_vec_t& ids) : 
-	LLInventoryFetchDescendentsObserver(ids),
+LLLibraryOutfitsFetch::LLLibraryOutfitsFetch(const LLUUID& my_outfits_id) : 
+	LLInventoryFetchDescendentsObserver(my_outfits_id),
 	mCurrFetchStep(LOFS_FOLDER), 
 	mOutfitsPopulated(false) 
 {
diff --git a/indra/newview/llagentwearablesfetch.h b/indra/newview/llagentwearablesfetch.h
index 33368811c0..6695727d46 100644
--- a/indra/newview/llagentwearablesfetch.h
+++ b/indra/newview/llagentwearablesfetch.h
@@ -47,7 +47,7 @@
 class LLInitialWearablesFetch : public LLInventoryFetchDescendentsObserver
 {
 public:
-	LLInitialWearablesFetch(const uuid_vec_t& ids);
+	LLInitialWearablesFetch(const LLUUID& cof_id);
 	~LLInitialWearablesFetch();
 	virtual void done();
 
@@ -92,7 +92,7 @@ public:
 		LOFS_CONTENTS
 	};
 
-	LLLibraryOutfitsFetch(const uuid_vec_t& ids);
+	LLLibraryOutfitsFetch(const LLUUID& my_outfits_id);
 	~LLLibraryOutfitsFetch();
 
 	virtual void done();
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index e0f1d5348d..7700d4de7f 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -49,7 +49,7 @@
 #include "llviewerregion.h"
 #include "llwearablelist.h"
 
-LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id,const std::string& name)
+LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string& name)
 {
 	LLInventoryModel::cat_array_t cat_array;
 	LLInventoryModel::item_array_t item_array;
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index 1cf8d584db..27a4ffd8cb 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -270,8 +270,8 @@ template <class T>
 class CallAfterCategoryFetchStage1: public LLInventoryFetchDescendentsObserver
 {
 public:
-	CallAfterCategoryFetchStage1(const uuid_vec_t& ids, T callable) :
-		LLInventoryFetchDescendentsObserver(ids),
+	CallAfterCategoryFetchStage1(const LLUUID& cat_id, T callable) :
+		LLInventoryFetchDescendentsObserver(cat_id),
 		mCallable(callable)
 	{
 	}
@@ -331,9 +331,7 @@ protected:
 template <class T> 
 void callAfterCategoryFetch(const LLUUID& cat_id, T callable)
 {
-	uuid_vec_t folders;
-	folders.push_back(cat_id);
-	CallAfterCategoryFetchStage1<T> *stage1 = new CallAfterCategoryFetchStage1<T>(folders, callable);
+	CallAfterCategoryFetchStage1<T> *stage1 = new CallAfterCategoryFetchStage1<T>(cat_id, callable);
 	stage1->startFetch();
 	if (stage1->isEverythingComplete())
 	{
diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp
index aaa09ba5da..945d2d26da 100644
--- a/indra/newview/llfriendcard.cpp
+++ b/indra/newview/llfriendcard.cpp
@@ -111,9 +111,9 @@ class LLInitialFriendCardsFetch : public LLInventoryFetchDescendentsObserver
 public:
 	typedef boost::function<void()> callback_t;
 
-	LLInitialFriendCardsFetch(const uuid_vec_t& ids,
+	LLInitialFriendCardsFetch(const LLUUID& folder_id,
 							  callback_t cb) :
-		LLInventoryFetchDescendentsObserver(ids),
+		LLInventoryFetchDescendentsObserver(folder_id),
 		mCheckFolderCallback(cb)	
 	{}
 
@@ -410,10 +410,8 @@ void LLFriendCardsManager::findMatchedFriendCards(const LLUUID& avatarID, LLInve
 
 void LLFriendCardsManager::fetchAndCheckFolderDescendents(const LLUUID& folder_id,  callback_t cb)
 {
-	uuid_vec_t folders;
-	folders.push_back(folder_id);
 	// This instance will be deleted in LLInitialFriendCardsFetch::done().
-	LLInitialFriendCardsFetch* fetch = new LLInitialFriendCardsFetch(folders, cb);
+	LLInitialFriendCardsFetch* fetch = new LLInitialFriendCardsFetch(folder_id, cb);
 	fetch->startFetch();
 	if(fetch->isEverythingComplete())
 	{
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 0f8d76a4cc..fecd18b4bb 100644
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -113,9 +113,17 @@ LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(bool retry_if_missi
 {
 }
 
-LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& ids,
+LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const LLUUID& item_id,
 															 bool retry_if_missing) :
-	mIDs(ids),
+	mRetryIfMissing(retry_if_missing)
+{
+	mIDs.clear();
+	mIDs.push_back(item_id);
+}
+
+LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids,
+															 bool retry_if_missing) :
+	mIDs(item_ids),
 	mRetryIfMissing(retry_if_missing)
 {
 }
@@ -273,8 +281,14 @@ LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver()
 {
 }
 
-LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const uuid_vec_t& ids) :
-	mIDs(ids)
+LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const LLUUID& cat_id)
+{
+	mIDs.clear();
+	mIDs.push_back(cat_id);
+}
+
+LLInventoryFetchDescendentsObserver::LLInventoryFetchDescendentsObserver(const uuid_vec_t& cat_ids) :
+	mIDs(cat_ids)
 {
 }
 // virtual
diff --git a/indra/newview/llinventoryobserver.h b/indra/newview/llinventoryobserver.h
index 03f9e9c553..420afdfadc 100644
--- a/indra/newview/llinventoryobserver.h
+++ b/indra/newview/llinventoryobserver.h
@@ -81,8 +81,9 @@ public:
 class LLInventoryFetchItemsObserver : public LLInventoryObserver
 {
 public:
-	LLInventoryFetchItemsObserver(bool retry_if_missing = false);
-	LLInventoryFetchItemsObserver(const uuid_vec_t& ids, bool retry_if_missing = false);
+	LLInventoryFetchItemsObserver(bool retry_if_missing = false); // deprecated
+	LLInventoryFetchItemsObserver(const LLUUID& item_id, bool retry_if_missing = false); // single item
+	LLInventoryFetchItemsObserver(const uuid_vec_t& item_ids, bool retry_if_missing = false); // multiple items
 	virtual void changed(U32 mask);
 
 	bool isEverythingComplete() const;
@@ -108,10 +109,12 @@ class LLInventoryFetchDescendentsObserver : public LLInventoryObserver
 {
 public:
 	LLInventoryFetchDescendentsObserver();
-	LLInventoryFetchDescendentsObserver(const uuid_vec_t& ids);
+	LLInventoryFetchDescendentsObserver(const LLUUID& cat_id);
+	LLInventoryFetchDescendentsObserver(const uuid_vec_t& cat_ids);
 	virtual void changed(U32 mask);
 
-	void setFolders(const uuid_vec_t& ids) { mIDs = ids; }
+	void setFolders(const uuid_vec_t& cat_ids) { mIDs = cat_ids; }
+	void setFolders(const LLUUID& cat_id) { mIDs.clear(); mIDs.push_back(cat_id); }
 	void startFetch();
 	bool isEverythingComplete() const;
 	virtual void done() = 0;
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 5701fcb582..e93293a0f0 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -481,10 +481,8 @@ void LLPanelOutfitEdit::updateLookInfo()
 	if (getVisible())
 	{
 		mLookContents->clearRows();
-		
-		uuid_vec_t folders;
-		folders.push_back(mLookID);
-		mFetchLook->setFolders(folders);
+
+		mFetchLook->setFolders(mLookID);
 		mFetchLook->startFetch();
 		if (mFetchLook->isEverythingComplete())
 		{
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 807595960e..820db7e3ff 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -6099,8 +6099,8 @@ class LLAttachmentDetach : public view_listener_t
 class LLWornItemFetchedObserver : public LLInventoryFetchItemsObserver
 {
 public:
-	LLWornItemFetchedObserver(const uuid_vec_t& ids) :
-		LLInventoryFetchItemsObserver(ids)
+	LLWornItemFetchedObserver(const LLUUID& worn_item_id) :
+		LLInventoryFetchItemsObserver(worn_item_id)
 	{}
 	virtual ~LLWornItemFetchedObserver() {}
 
@@ -6155,10 +6155,7 @@ class LLAttachmentEnableDrop : public view_listener_t
 						// when the item finishes fetching worst case scenario 
 						// if a fetch is already out there (being sent from a slow sim)
 						// we refetch and there are 2 fetches
-
-						uuid_vec_t items; //add item to the inventory item to be fetched
-						items.push_back((*attachment_iter)->getItemID());
-						LLWornItemFetchedObserver* worn_item_fetched = new LLWornItemFetchedObserver(items);		
+						LLWornItemFetchedObserver* worn_item_fetched = new LLWornItemFetchedObserver((*attachment_iter)->getItemID());		
 						worn_item_fetched->startFetch();
 						gInventory.addObserver(worn_item_fetched);
 					}
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 6f39de996e..35eb3390a5 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -703,9 +703,9 @@ static LLNotificationFunctorRegistration jgr_3("JoinGroupCanAfford", join_group_
 class LLOpenAgentOffer : public LLInventoryFetchItemsObserver
 {
 public:
-	LLOpenAgentOffer(const uuid_vec_t& ids,
+	LLOpenAgentOffer(const LLUUID& object_id,
 					 const std::string& from_name) : 
-		LLInventoryFetchItemsObserver(ids),
+		LLInventoryFetchItemsObserver(object_id),
 		mFromName(from_name) {}
 	/*virtual*/ void done()
 	{
@@ -1207,9 +1207,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
 				// This is an offer from an agent. In this case, the back
 				// end has already copied the items into your inventory,
 				// so we can fetch it out of our inventory.
-				uuid_vec_t items;
-				items.push_back(mObjectID);
-				LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(items, from_string);
+				LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(mObjectID, from_string);
 				open_agent_offer->startFetch();
 				if(catp || (itemp && itemp->isComplete()))
 				{
@@ -1605,9 +1603,7 @@ void inventory_offer_handler(LLOfferInfo* info)
 		p.name = "UserGiveItem";
 		
 		// Prefetch the item into your local inventory.
-		uuid_vec_t items;
-		items.push_back(info->mObjectID);
-		LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(items);
+		LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(info->mObjectID);
 		fetch_item->startFetch();
 		if(fetch_item->isEverythingComplete())
 		{
@@ -2124,9 +2120,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 			if (is_muted)
 			{
 				// Prefetch the offered item so that it can be discarded by the appropriate observer. (EXT-4331)
-				uuid_vec_t items;
-				items.push_back(info->mObjectID);
-				LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(items);
+				LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(info->mObjectID);
 				fetch_item->startFetch();
 				delete fetch_item;
 
-- 
GitLab