From 104b117154022da6ec8e54bea04ff76e5692f93a Mon Sep 17 00:00:00 2001
From: Aura Linden <aura@lindenlab.com>
Date: Thu, 31 Mar 2016 15:26:53 -0700
Subject: Faster to copy changes than merge branches.

---
 indra/newview/llinventorymodel.cpp    | 153 -----------------
 indra/newview/llinventorymodel.h      |   2 -
 indra/newview/llinventoryobserver.cpp |  30 +---
 indra/newview/lltooldraganddrop.cpp   |  60 -------
 indra/newview/llviewerinventory.cpp   | 314 ++++++----------------------------
 indra/newview/llviewerinventory.h     |   6 +-
 6 files changed, 64 insertions(+), 501 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index bdbe253723..ea57067f93 100755
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -2693,24 +2693,13 @@ void LLInventoryModel::registerCallbacks(LLMessageSystem* msg)
 	msg->setHandlerFuncFast(_PREHASH_RemoveInventoryObjects,
 							processRemoveInventoryObjects,
 							NULL);	
-	//msg->setHandlerFuncFast(_PREHASH_ExchangeCallingCard,
-	//						processExchangeCallingcard,
-	//						NULL);
-	//msg->setHandlerFuncFast(_PREHASH_AddCallingCard,
-	//					processAddCallingcard,
-	//					NULL);
-	//msg->setHandlerFuncFast(_PREHASH_DeclineCallingCard,
-	//					processDeclineCallingcard,
-	//					NULL);
 	msg->setHandlerFuncFast(_PREHASH_SaveAssetIntoInventory,
 						processSaveAssetIntoInventory,
 						NULL);
 	msg->setHandlerFuncFast(_PREHASH_BulkUpdateInventory,
 							processBulkUpdateInventory,
 							NULL);
-	msg->setHandlerFunc("InventoryDescendents", processInventoryDescendents);
 	msg->setHandlerFunc("MoveInventoryItem", processMoveInventoryItem);
-	msg->setHandlerFunc("FetchInventoryReply", processFetchInventoryReply);
 }
 
 
@@ -2730,14 +2719,6 @@ void LLInventoryModel::processUpdateCreateInventoryItem(LLMessageSystem* msg, vo
 
 }
 
-// static
-void LLInventoryModel::processFetchInventoryReply(LLMessageSystem* msg, void**)
-{
-	// no accounting
-	gInventory.messageUpdateCore(msg, false);
-}
-
-
 bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account, U32 mask)
 {
 	//make sure our added inventory observer is active
@@ -3180,85 +3161,6 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**)
 		InventoryCallbackInfo cbinfo = (*inv_it);
 		gInventoryCallbacks.fire(cbinfo.mCallback, cbinfo.mInvID);
 	}
-
-	//gInventory.validate();
-
-	// Don't show the inventory.  We used to call showAgentInventory here.
-	//LLFloaterInventory* view = LLFloaterInventory::getActiveInventory();
-	//if(view)
-	//{
-	//	const BOOL take_keyboard_focus = FALSE;
-	//	view->setSelection(category.getUUID(), take_keyboard_focus );
-	//	LLView* focus_view = gFocusMgr.getKeyboardFocus();
-	//	LLFocusMgr::FocusLostCallback callback = gFocusMgr.getFocusCallback();
-	//	// HACK to open inventory offers that are accepted.  This information
-	//	// really needs to flow through the instant messages and inventory
-	//	// transfer/update messages.
-	//	if (LLFloaterInventory::sOpenNextNewItem)
-	//	{
-	//		view->openSelected();
-	//		LLFloaterInventory::sOpenNextNewItem = FALSE;
-	//	}
-	//
-	//	// restore keyboard focus
-	//	gFocusMgr.setKeyboardFocus(focus_view);
-	//}
-}
-
-// static
-void LLInventoryModel::processInventoryDescendents(LLMessageSystem* msg,void**)
-{
-	LLUUID agent_id;
-	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
-	if(agent_id != gAgent.getID())
-	{
-		LL_WARNS() << "Got a UpdateInventoryItem for the wrong agent." << LL_ENDL;
-		return;
-	}
-	LLUUID parent_id;
-	msg->getUUID("AgentData", "FolderID", parent_id);
-	LLUUID owner_id;
-	msg->getUUID("AgentData", "OwnerID", owner_id);
-	S32 version;
-	msg->getS32("AgentData", "Version", version);
-	S32 descendents;
-	msg->getS32("AgentData", "Descendents", descendents);
-
-	S32 i;
-	S32 count = msg->getNumberOfBlocksFast(_PREHASH_FolderData);
-	LLPointer<LLViewerInventoryCategory> tcategory = new LLViewerInventoryCategory(owner_id);
-	for(i = 0; i < count; ++i)
-	{
-		tcategory->unpackMessage(msg, _PREHASH_FolderData, i);
-		gInventory.updateCategory(tcategory);
-	}
-
-	count = msg->getNumberOfBlocksFast(_PREHASH_ItemData);
-	LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
-	for(i = 0; i < count; ++i)
-	{
-		titem->unpackMessage(msg, _PREHASH_ItemData, i);
-		// If the item has already been added (e.g. from link prefetch), then it doesn't need to be re-added.
-		if (gInventory.getItem(titem->getUUID()))
-		{
-			LL_DEBUGS("Inventory") << "Skipping prefetched item [ Name: " << titem->getName()
-								   << " | Type: " << titem->getActualType() << " | ItemUUID: " << titem->getUUID() << " ] " << LL_ENDL;
-			continue;
-		}
-		gInventory.updateItem(titem);
-	}
-
-	// set version and descendentcount according to message.
-	LLViewerInventoryCategory* cat = gInventory.getCategory(parent_id);
-	if(cat)
-	{
-		cat->setVersion(version);
-		cat->setDescendentCount(descendents);
-		// Get this UUID on the changed list so that whatever's listening for it
-		// will get triggered.
-		gInventory.addChangedMask(LLInventoryObserver::INTERNAL, cat->getUUID());
-	}
-	gInventory.notifyObservers();
 }
 
 // static
@@ -3527,30 +3429,6 @@ void LLInventoryModel::updateItemsOrder(LLInventoryModel::item_array_t& items, c
 	}
 }
 
-//* @param[in] items vector of items in order to be saved.
-/*
-void LLInventoryModel::saveItemsOrder(const LLInventoryModel::item_array_t& items)
-{
-	int sortField = 0;
-
-	// current order is saved by setting incremental values (1, 2, 3, ...) for the sort field
-	for (item_array_t::const_iterator i = items.begin(); i != items.end(); ++i)
-	{
-		LLViewerInventoryItem* item = *i;
-
-		item->setSortField(++sortField);
-		item->setComplete(TRUE);
-		item->updateServer(FALSE);
-
-		updateItem(item);
-
-		// Tell the parent folder to refresh its sort order.
-		addChangedMask(LLInventoryObserver::SORT, item->getParentUUID());
-	}
-
-	notifyObservers();
-}
-*/
 // See also LLInventorySort where landmarks in the Favorites folder are sorted.
 class LLViewerInventoryItemSort
 {
@@ -3561,37 +3439,6 @@ public:
 	}
 };
 
-/**
- * Sorts passed items by LLViewerInventoryItem sort field.
- *
- * @param[in, out] items - array of items, not sorted.
- */
-//static void rearrange_item_order_by_sort_field(LLInventoryModel::item_array_t& items)
-//{
-//	static LLViewerInventoryItemSort sort_functor;
-//	std::sort(items.begin(), items.end(), sort_functor);
-//}
-
-// * @param source_item_id - LLUUID of the source item to be moved into new position
-// * @param target_item_id - LLUUID of the target item before which source item should be placed.
-/*
-void LLInventoryModel::rearrangeFavoriteLandmarks(const LLUUID& source_item_id, const LLUUID& target_item_id)
-{
-	LLInventoryModel::cat_array_t cats;
-	LLInventoryModel::item_array_t items;
-	LLIsType is_type(LLAssetType::AT_LANDMARK);
-	LLUUID favorites_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
-	gInventory.collectDescendentsIf(favorites_id, cats, items, LLInventoryModel::EXCLUDE_TRASH, is_type);
-
-	// ensure items are sorted properly before changing order. EXT-3498
-	rearrange_item_order_by_sort_field(items);
-
-	// update order
-	updateItemsOrder(items, source_item_id, target_item_id);
-
-	saveItemsOrder(items);
-}
-*/
 //----------------------------------------------------------------------------
 
 // *NOTE: DEBUG functionality
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h
index e1e6db19eb..bfa56bcec0 100755
--- a/indra/newview/llinventorymodel.h
+++ b/indra/newview/llinventorymodel.h
@@ -623,9 +623,7 @@ public:
 	static void processRemoveInventoryObjects(LLMessageSystem* msg, void**);
 	static void processSaveAssetIntoInventory(LLMessageSystem* msg, void**);
 	static void processBulkUpdateInventory(LLMessageSystem* msg, void**);
-	static void processInventoryDescendents(LLMessageSystem* msg, void**);
 	static void processMoveInventoryItem(LLMessageSystem* msg, void**);
-	static void processFetchInventoryReply(LLMessageSystem* msg, void**);
 protected:
 	bool messageUpdateCore(LLMessageSystem* msg, bool do_accounting, U32 mask = 0x0);
 
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 6c81378622..776bb1c601 100755
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -241,33 +241,11 @@ void fetch_items_from_llsd(const LLSD& items_llsd)
 			gInventory.requestPost(true, url, body[i], handler, (i ? "Library Item" : "Inventory Item"));
 			continue;
 		}
+        else
+        {
+            LL_WARNS("INVENTORY") << "Failed to get capability." << LL_ENDL;
+        }
 
-		LLMessageSystem* msg = gMessageSystem;
-		BOOL start_new_message = TRUE;
-		for (S32 j=0; j<body[i]["items"].size(); j++)
-		{
-			LLSD item_entry = body[i]["items"][j];
-			if (start_new_message)
-			{
-				start_new_message = FALSE;
-				msg->newMessageFast(_PREHASH_FetchInventory);
-				msg->nextBlockFast(_PREHASH_AgentData);
-				msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-				msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			}
-			msg->nextBlockFast(_PREHASH_InventoryData);
-			msg->addUUIDFast(_PREHASH_OwnerID, item_entry["owner_id"].asUUID());
-			msg->addUUIDFast(_PREHASH_ItemID, item_entry["item_id"].asUUID());
-			if (msg->isSendFull(NULL))
-			{
-				start_new_message = TRUE;
-				gAgent.sendReliableMessage();
-			}
-		}
-		if (!start_new_message)
-		{
-			gAgent.sendReliableMessage();
-		}
 	}
 }
 
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 98586e3b3d..27c4c90857 100755
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -223,66 +223,6 @@ void LLCategoryDropObserver::done()
 	}
 	delete this;
 }
-/* Doesn't seem to be used anymore.
-class LLCategoryDropDescendentsObserver : public LLInventoryFetchDescendentsObserver
-{
-public:
-	LLCategoryDropDescendentsObserver(
-		const LLUUID& obj_id, LLToolDragAndDrop::ESource src) :
-		mObjectID(obj_id),
-		mSource(src)
-	{}
-	~LLCategoryDropDescendentsObserver() {}
-	virtual void done();
-
-protected:
-	LLUUID mObjectID;
-	LLToolDragAndDrop::ESource mSource;
-};
-
-void LLCategoryDropDescendentsObserver::done()
-{
-
-	gInventory.removeObserver(this);
-	uuid_vec_t::iterator it = mComplete.begin();
-	uuid_vec_t::iterator end = mComplete.end();
-	LLViewerInventoryCategory::cat_array_t cats;
-	LLViewerInventoryItem::item_array_t items;
-	for(; it != end; ++it)
-	{
-		gInventory.collectDescendents(
-			(*it),
-			cats,
-			items,
-			LLInventoryModel::EXCLUDE_TRASH);
-	}
-
-	S32 count = items.size();
-	if (count)
-	{
-		std::set<LLUUID> unique_ids;
-		for(S32 i = 0; i < count; ++i)
-		{
-			unique_ids.insert(items.get(i)->getUUID());
-		}
-		uuid_vec_t ids;
-		std::back_insert_iterator<uuid_vec_t> copier(ids);
-		std::copy(unique_ids.begin(), unique_ids.end(), copier);
-		LLCategoryDropObserver* dropper;
-		dropper = new LLCategoryDropObserver(ids, mObjectID, mSource);
-		dropper->startFetch();
-		if (dropper->isDone())
-		{
-			dropper->done();
-		}
-		else
-		{
-			gInventory.addObserver(dropper);
-		}
-	}
-	delete this;
-}
-*/
 
 S32 LLToolDragAndDrop::sOperationId = 0;
 
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 0ee873d7a1..10de787a3a 100755
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -384,16 +384,20 @@ void LLViewerInventoryItem::updateServer(BOOL is_new) const
 	LLInventoryModel::LLCategoryUpdate up(mParentUUID, is_new ? 1 : 0);
 	gInventory.accountForUpdate(up);
 
-	LLMessageSystem* msg = gMessageSystem;
-	msg->newMessageFast(_PREHASH_UpdateInventoryItem);
-	msg->nextBlockFast(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	msg->addUUIDFast(_PREHASH_TransactionID, mTransactionID);
-	msg->nextBlockFast(_PREHASH_InventoryData);
-	msg->addU32Fast(_PREHASH_CallbackID, 0);
-	packMessage(msg);
-	gAgent.sendReliableMessage();
+    LLSD updates = asLLSD();
+    // Replace asset_id and/or shadow_id with transaction_id (hash_id)
+    if (updates.has("asset_id"))
+    {
+        updates.erase("asset_id");
+        updates["hash_id"] = getTransactionID();
+    }
+    if (updates.has("shadow_id"))
+    {
+        updates.erase("shadow_id");
+        updates["hash_id"] = getTransactionID();
+    }
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, NULL, _1);
+    AISAPI::UpdateItem(getUUID(), updates, cr);
 }
 
 void LLViewerInventoryItem::fetchFromServer(void) const
@@ -636,17 +640,9 @@ void LLViewerInventoryCategory::updateServer(BOOL is_new) const
 		return;
 	}
 
-	LLInventoryModel::LLCategoryUpdate up(mParentUUID, is_new ? 1 : 0);
-	gInventory.accountForUpdate(up);
-
-	LLMessageSystem* msg = gMessageSystem;
-	msg->newMessageFast(_PREHASH_UpdateInventoryFolder);
-	msg->nextBlockFast(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	msg->nextBlockFast(_PREHASH_FolderData);
-	packMessage(msg);
-	gAgent.sendReliableMessage();
+    LLSD new_llsd = asLLSD();
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, NULL, _1);
+    AISAPI::UpdateCategory(getUUID(), new_llsd, cr);
 }
 
 S32 LLViewerInventoryCategory::getVersion() const
@@ -669,18 +665,6 @@ bool LLViewerInventoryCategory::fetch()
 		mDescendentsRequested.reset();
 		mDescendentsRequested.setTimerExpirySec(FETCH_TIMER_EXPIRY);
 
-		// bitfield
-		// 1 = by date
-		// 2 = folders by date
-		// Need to mask off anything but the first bit.
-		// This comes from LLInventoryFilter from llfolderview.h
-		U32 sort_order = gSavedSettings.getU32(LLInventoryPanel::DEFAULT_SORT_ORDER) & 0x1;
-
-		// *NOTE: For bug EXT-2879, originally commented out
-		// gAgent.getRegion()->getCapability in order to use the old
-		// message-based system.  This has been uncommented now that
-		// AIS folks are aware of the issue and have a fix in process.
-		// see ticket for details.
 
 		std::string url;
 		if (gAgent.getRegion())
@@ -695,24 +679,6 @@ bool LLViewerInventoryCategory::fetch()
 		{
 			LLInventoryModelBackgroundFetch::instance().start(mUUID, false);			
 		}
-		else
-		{	//Deprecated, but if we don't have a capability, use the old system.
-			LL_INFOS(LOG_INV) << "FetchInventoryDescendents2 capability not found.  Using deprecated UDP message." << LL_ENDL;
-			
-			LLMessageSystem* msg = gMessageSystem;
-			msg->newMessage("FetchInventoryDescendents");
-			msg->nextBlock("AgentData");
-			msg->addUUID("AgentID", gAgent.getID());
-			msg->addUUID("SessionID", gAgent.getSessionID());
-			msg->nextBlock("InventoryData");
-			msg->addUUID("FolderID", mUUID);
-			msg->addUUID("OwnerID", mOwnerID);
-
-			msg->addS32("SortOrder", sort_order);
-			msg->addBOOL("FetchFolders", FALSE);
-			msg->addBOOL("FetchItems", TRUE);
-			gAgent.sendReliableMessage();
-		}
 		return true;
 	}
 	return false;
@@ -905,17 +871,16 @@ void LLViewerInventoryCategory::changeType(LLFolderType::EType new_folder_type)
 	const LLUUID &parent_id = getParentUUID();
 	const std::string &name = getName();
 		
-	LLMessageSystem* msg = gMessageSystem;
-	msg->newMessageFast(_PREHASH_UpdateInventoryFolder);
-	msg->nextBlockFast(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	msg->nextBlockFast(_PREHASH_FolderData);
-	msg->addUUIDFast(_PREHASH_FolderID, folder_id);
-	msg->addUUIDFast(_PREHASH_ParentID, parent_id);
-	msg->addS8Fast(_PREHASH_Type, new_folder_type);
-	msg->addStringFast(_PREHASH_Name, name);
-	gAgent.sendReliableMessage();
+    LLPointer<LLViewerInventoryCategory> new_cat = new LLViewerInventoryCategory(folder_id,
+                                                                                 parent_id,
+                                                                                 new_folder_type,
+                                                                                 name,
+                                                                                 gAgent.getID());
+        
+        
+    LLSD new_llsd = new_cat->asLLSD();
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, NULL, _1);
+    AISAPI::UpdateCategory(folder_id, new_llsd, cr);
 
 	setPreferredType(new_folder_type);
 	gInventory.addChangedMask(LLInventoryObserver::LABEL, folder_id);
@@ -1289,40 +1254,10 @@ void link_inventory_array(const LLUUID& category,
 						   << " UUID:" << category << " ] " << LL_ENDL;
 #endif
 	}
-
-    if (AISAPI::isAvailable())
-	{
-		LLSD new_inventory = LLSD::emptyMap();
-		new_inventory["links"] = links;
-        AISAPI::completion_t cr = (cb) ? boost::bind(&doInventoryCb, cb, _1) : AISAPI::completion_t();
-        AISAPI::CreateInventory(category, new_inventory, cr);
-	}
-    else
-	{
-		LLMessageSystem* msg = gMessageSystem;
-		for (LLSD::array_iterator iter = links.beginArray(); iter != links.endArray(); ++iter )
-		{
-			msg->newMessageFast(_PREHASH_LinkInventoryItem);
-			msg->nextBlock(_PREHASH_AgentData);
-			{
-				msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-				msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			}
-			msg->nextBlock(_PREHASH_InventoryBlock);
-			{
-				LLSD link = (*iter);
-				msg->addU32Fast(_PREHASH_CallbackID, gInventoryCallbacks.registerCB(cb));
-				msg->addUUIDFast(_PREHASH_FolderID, category);
-				msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null);
-				msg->addUUIDFast(_PREHASH_OldItemID, link["linked_id"].asUUID());
-				msg->addS8Fast(_PREHASH_Type, link["type"].asInteger());
-				msg->addS8Fast(_PREHASH_InvType, link["inv_type"].asInteger());
-				msg->addStringFast(_PREHASH_Name, link["name"].asString());
-				msg->addStringFast(_PREHASH_Description, link["desc"].asString());
-			}
-			gAgent.sendReliableMessage();
-		}
-	}
+    LLSD new_inventory = LLSD::emptyMap();
+    new_inventory["links"] = links;
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1);
+    AISAPI::CreateInventory(category, new_inventory, cr);
 }
 
 void move_inventory_item(
@@ -1354,49 +1289,21 @@ void update_inventory_item(
 	LLPointer<LLInventoryCallback> cb)
 {
 	const LLUUID& item_id = update_item->getUUID();
-    if (AISAPI::isAvailable())
-	{
-		LLSD updates = update_item->asLLSD();
-		// Replace asset_id and/or shadow_id with transaction_id (hash_id)
-		if (updates.has("asset_id"))
-		{
-			updates.erase("asset_id");
-			updates["hash_id"] = update_item->getTransactionID();
-		}
-		if (updates.has("shadow_id"))
-		{
-			updates.erase("shadow_id");
-			updates["hash_id"] = update_item->getTransactionID();
-		}
-        AISAPI::completion_t cr = (cb) ? boost::bind(&doInventoryCb, cb, _1) : AISAPI::completion_t();
-        AISAPI::UpdateItem(item_id, updates, cr);
-	}
-    else
-	{
-		LLPointer<LLViewerInventoryItem> obj = gInventory.getItem(item_id);
-		LL_DEBUGS(LOG_INV) << "item_id: [" << item_id << "] name " << (update_item ? update_item->getName() : "(NOT FOUND)") << LL_ENDL;
-		if(obj)
-		{
-			LLMessageSystem* msg = gMessageSystem;
-			msg->newMessageFast(_PREHASH_UpdateInventoryItem);
-			msg->nextBlockFast(_PREHASH_AgentData);
-			msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			msg->addUUIDFast(_PREHASH_TransactionID, update_item->getTransactionID());
-			msg->nextBlockFast(_PREHASH_InventoryData);
-			msg->addU32Fast(_PREHASH_CallbackID, 0);
-			update_item->packMessage(msg);
-			gAgent.sendReliableMessage();
-
-			LLInventoryModel::LLCategoryUpdate up(update_item->getParentUUID(), 0);
-			gInventory.accountForUpdate(up);
-			gInventory.updateItem(update_item);
-			if (cb)
-			{
-				cb->fire(item_id);
-			}
-		}
-	}
+  
+    LLSD updates = update_item->asLLSD();
+    // Replace asset_id and/or shadow_id with transaction_id (hash_id)
+    if (updates.has("asset_id"))
+    {
+        updates.erase("asset_id");
+        updates["hash_id"] = update_item->getTransactionID();
+    }
+    if (updates.has("shadow_id"))
+    {
+        updates.erase("shadow_id");
+        updates["hash_id"] = update_item->getTransactionID();
+    }
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1);
+    AISAPI::UpdateItem(item_id, updates, cr);
 }
 
 // Note this only supports updating an existing item. Goes through AISv3
@@ -1407,41 +1314,8 @@ void update_inventory_item(
 	const LLSD& updates,
 	LLPointer<LLInventoryCallback> cb)
 {
-    if (AISAPI::isAvailable())
-	{
-        AISAPI::completion_t cr = (cb) ? boost::bind(&doInventoryCb, cb, _1) : AISAPI::completion_t();
-        AISAPI::UpdateItem(item_id, updates, cr);
-	}
-    else
-	{
-		LLPointer<LLViewerInventoryItem> obj = gInventory.getItem(item_id);
-		LL_DEBUGS(LOG_INV) << "item_id: [" << item_id << "] name " << (obj ? obj->getName() : "(NOT FOUND)") << LL_ENDL;
-		if(obj)
-		{
-			LLPointer<LLViewerInventoryItem> new_item(new LLViewerInventoryItem);
-			new_item->copyViewerItem(obj);
-			new_item->fromLLSD(updates,false);
-
-			LLMessageSystem* msg = gMessageSystem;
-			msg->newMessageFast(_PREHASH_UpdateInventoryItem);
-			msg->nextBlockFast(_PREHASH_AgentData);
-			msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			msg->addUUIDFast(_PREHASH_TransactionID, new_item->getTransactionID());
-			msg->nextBlockFast(_PREHASH_InventoryData);
-			msg->addU32Fast(_PREHASH_CallbackID, 0);
-			new_item->packMessage(msg);
-			gAgent.sendReliableMessage();
-
-			LLInventoryModel::LLCategoryUpdate up(new_item->getParentUUID(), 0);
-			gInventory.accountForUpdate(up);
-			gInventory.updateItem(new_item);
-			if (cb)
-			{
-				cb->fire(item_id);
-			}
-		}
-	}
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1);
+    AISAPI::UpdateItem(item_id, updates, cr);
 }
 
 void update_inventory_category(
@@ -1461,32 +1335,9 @@ void update_inventory_category(
 
 		LLPointer<LLViewerInventoryCategory> new_cat = new LLViewerInventoryCategory(obj);
 		new_cat->fromLLSD(updates);
-		// FIXME - restore this once the back-end work has been done.
-        if (AISAPI::isAvailable())
-		{
-			LLSD new_llsd = new_cat->asLLSD();
-            AISAPI::completion_t cr = (cb) ? boost::bind(&doInventoryCb, cb, _1) : AISAPI::completion_t();
-            AISAPI::UpdateCategory(cat_id, new_llsd, cr);
-		}
-		else // no cap
-		{
-			LLMessageSystem* msg = gMessageSystem;
-			msg->newMessageFast(_PREHASH_UpdateInventoryFolder);
-			msg->nextBlockFast(_PREHASH_AgentData);
-			msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			msg->nextBlockFast(_PREHASH_FolderData);
-			new_cat->packMessage(msg);
-			gAgent.sendReliableMessage();
-
-			LLInventoryModel::LLCategoryUpdate up(new_cat->getParentUUID(), 0);
-			gInventory.accountForUpdate(up);
-			gInventory.updateCategory(new_cat);
-			if (cb)
-			{
-				cb->fire(cat_id);
-			}
-		}
+        LLSD new_llsd = new_cat->asLLSD();
+        AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1);
+        AISAPI::UpdateCategory(cat_id, new_llsd, cr);
 	}
 }
 
@@ -1604,41 +1455,8 @@ void remove_inventory_category(
 			LLNotificationsUtil::add("CannotRemoveProtectedCategories");
 			return;
 		}
-        if (AISAPI::isAvailable())
-		{
-            AISAPI::completion_t cr = (cb) ? boost::bind(&doInventoryCb, cb, _1) : AISAPI::completion_t();
-            AISAPI::RemoveCategory(cat_id, cr);
-		}
-		else // no cap
-		{
-			// RemoveInventoryFolder does not remove children, so must
-			// clear descendents first.
-			LLInventoryModel::EHasChildren children = gInventory.categoryHasChildren(cat_id);
-			if(children != LLInventoryModel::CHILDREN_NO)
-			{
-				LL_DEBUGS(LOG_INV) << "Will purge descendents first before deleting category " << cat_id << LL_ENDL;
-				LLPointer<LLInventoryCallback> wrap_cb = new LLRemoveCategoryOnDestroy(cat_id, cb); 
-				purge_descendents_of(cat_id, wrap_cb);
-				return;
-			}
-
-			LLMessageSystem* msg = gMessageSystem;
-			msg->newMessageFast(_PREHASH_RemoveInventoryFolder);
-			msg->nextBlockFast(_PREHASH_AgentData);
-			msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			msg->nextBlockFast(_PREHASH_FolderData);
-			msg->addUUIDFast(_PREHASH_FolderID, cat_id);
-			gAgent.sendReliableMessage();
-
-			// Update inventory and call callback immediately since
-			// message-based system has no callback mechanism (!)
-			gInventory.onObjectDeletedFromServer(cat_id);
-			if (cb)
-			{
-				cb->fire(cat_id);
-			}
-		}
+        AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1);
+        AISAPI::RemoveCategory(cat_id, cr);
 	}
 	else
 	{
@@ -1857,29 +1675,11 @@ void slam_inventory_folder(const LLUUID& folder_id,
 						   const LLSD& contents,
 						   LLPointer<LLInventoryCallback> cb)
 {
-    if (AISAPI::isAvailable())
-	{
-		LL_DEBUGS(LOG_INV) << "using AISv3 to slam folder, id " << folder_id
-						   << " new contents: " << ll_pretty_print_sd(contents) << LL_ENDL;
+    LL_DEBUGS(LOG_INV) << "using AISv3 to slam folder, id " << folder_id
+                       << " new contents: " << ll_pretty_print_sd(contents) << LL_ENDL;
 
-        AISAPI::completion_t cr = (cb) ? boost::bind(&doInventoryCb, cb, _1) : AISAPI::completion_t();
-        AISAPI::SlamFolder(folder_id, contents, cr);
-	}
-	else // no cap
-	{
-		LL_DEBUGS(LOG_INV) << "using item-by-item calls to slam folder, id " << folder_id
-						   << " new contents: " << ll_pretty_print_sd(contents) << LL_ENDL;
-		for (LLSD::array_const_iterator it = contents.beginArray();
-			 it != contents.endArray();
-			 ++it)
-		{
-			const LLSD& item_contents = *it;
-			LLViewerInventoryItem *item = new LLViewerInventoryItem;
-			item->fromLLSD(item_contents);
-			link_inventory_object(folder_id, item, cb);
-		}
-		remove_folder_contents(folder_id,false,cb);
-	}
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1);
+    AISAPI::SlamFolder(folder_id, contents, cr);
 }
 
 void remove_folder_contents(const LLUUID& category, bool keep_outfit_links,
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index 4e91e4110a..9c2a640a1a 100755
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -387,9 +387,9 @@ void update_inventory_item(
 	LLPointer<LLInventoryCallback> cb);
 
 void update_inventory_category(
-	const LLUUID& cat_id,
-	const LLSD& updates,
-	LLPointer<LLInventoryCallback> cb);
+    const LLUUID& cat_id,
+    const LLSD& updates,
+    LLPointer<LLInventoryCallback> cb);
 
 void remove_inventory_items(
 	LLInventoryObject::object_list_t& items,
-- 
cgit v1.2.3


From 1337bff4acc8b53b29bcbe1203c620b9b0fb3b09 Mon Sep 17 00:00:00 2001
From: Aura Linden <aura@lindenlab.com>
Date: Thu, 31 Mar 2016 16:42:18 -0700
Subject: Needs prototype.

---
 indra/newview/llviewerinventory.h | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index 9c2a640a1a..5194679a0c 100755
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -38,6 +38,7 @@ class LLInventoryPanel;
 class LLFolderView;
 class LLFolderBridge;
 class LLViewerInventoryCategory;
+class LLInventoryCallback;
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // Class LLViewerInventoryItem
-- 
cgit v1.2.3


From 718b68db629c14fae6c89716ccd961a57c738bb2 Mon Sep 17 00:00:00 2001
From: Aura Linden <aura@lindenlab.com>
Date: Thu, 31 Mar 2016 17:10:10 -0700
Subject: I hate polluting the commit history.

---
 indra/newview/llviewerinventory.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 10de787a3a..5616c27370 100755
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -396,7 +396,7 @@ void LLViewerInventoryItem::updateServer(BOOL is_new) const
         updates.erase("shadow_id");
         updates["hash_id"] = getTransactionID();
     }
-    AISAPI::completion_t cr = boost::bind(&doInventoryCb, NULL, _1);
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, (LLPointer<LLInventoryCallback>)NULL, _1);
     AISAPI::UpdateItem(getUUID(), updates, cr);
 }
 
@@ -641,7 +641,7 @@ void LLViewerInventoryCategory::updateServer(BOOL is_new) const
 	}
 
     LLSD new_llsd = asLLSD();
-    AISAPI::completion_t cr = boost::bind(&doInventoryCb, NULL, _1);
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, (LLPointer<LLInventoryCallback>)NULL, _1);
     AISAPI::UpdateCategory(getUUID(), new_llsd, cr);
 }
 
@@ -879,7 +879,7 @@ void LLViewerInventoryCategory::changeType(LLFolderType::EType new_folder_type)
         
         
     LLSD new_llsd = new_cat->asLLSD();
-    AISAPI::completion_t cr = boost::bind(&doInventoryCb, NULL, _1);
+    AISAPI::completion_t cr = boost::bind(&doInventoryCb, (LLPointer<LLInventoryCallback>) NULL, _1);
     AISAPI::UpdateCategory(folder_id, new_llsd, cr);
 
 	setPreferredType(new_folder_type);
-- 
cgit v1.2.3


From 76d1551e2ce53f8c26a8f5ced6c27c9a85e8a19f Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Wed, 20 Apr 2016 17:46:59 +0300
Subject: MAINT-6341 Changing properties of the object in inventory are not
 saved after transfer it to next owner

---
 indra/newview/llviewerinventory.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 5616c27370..d0813544f8 100755
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -389,12 +389,18 @@ void LLViewerInventoryItem::updateServer(BOOL is_new) const
     if (updates.has("asset_id"))
     {
         updates.erase("asset_id");
-        updates["hash_id"] = getTransactionID();
+        if(getTransactionID().notNull())
+        {
+            updates["hash_id"] = getTransactionID();
+        }
     }
     if (updates.has("shadow_id"))
     {
         updates.erase("shadow_id");
-        updates["hash_id"] = getTransactionID();
+        if(getTransactionID().notNull())
+        {
+            updates["hash_id"] = getTransactionID();
+        }
     }
     AISAPI::completion_t cr = boost::bind(&doInventoryCb, (LLPointer<LLInventoryCallback>)NULL, _1);
     AISAPI::UpdateItem(getUUID(), updates, cr);
-- 
cgit v1.2.3


From f868e29945806fd6cefde65067ae2c870ac112a6 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 6 Jul 2016 16:52:24 -0400
Subject: increment viewer version to 4.0.7

---
 indra/newview/VIEWER_VERSION.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt
index d13e837c8e..43beb4001b 100644
--- a/indra/newview/VIEWER_VERSION.txt
+++ b/indra/newview/VIEWER_VERSION.txt
@@ -1 +1 @@
-4.0.6
+4.0.7
-- 
cgit v1.2.3