Exemplo n.º 1
0
// Checked: 2011-10-06 (RLVa-1.4.2a) | Added: RLVa-1.4.2a
S32 RlvInventory::getDirectDescendentsFolderCount(const LLInventoryCategory* pFolder)
{
	LLInventoryModel::cat_array_t* pFolders = NULL; LLInventoryModel::item_array_t* pItems = NULL;
	if (pFolder)
		gInventory.getDirectDescendentsOf(pFolder->getUUID(), pFolders, pItems);
	return (pFolders) ? pFolders->size() : 0;
}
Exemplo n.º 2
0
// Checked: 2011-10-06 (RLVa-1.4.2a) | Modified: RLVa-1.4.2a
const LLUUID& RlvInventory::getSharedRootID() const
{
	if ( (m_idRlvRoot.isNull()) && (gInventory.isInventoryUsable()) )
	{
		LLInventoryModel::cat_array_t* pFolders; LLInventoryModel::item_array_t* pItems;
		gInventory.getDirectDescendentsOf(gInventory.getRootFolderID(), pFolders, pItems);
		if (pFolders)
		{
			// NOTE: we might have multiple #RLV folders (pick the first one with sub-folders; otherwise the last one with no sub-folders)
			const LLViewerInventoryCategory* pFolder;
			for (S32 idxFolder = 0, cntFolder = pFolders->count(); idxFolder < cntFolder; idxFolder++)
			{
				if ( ((pFolder = pFolders->get(idxFolder)) != NULL) && (cstrSharedRoot == pFolder->getName()) )
				{
					m_idRlvRoot = pFolder->getUUID();
					if (getDirectDescendentsFolderCount(pFolder) > 0)
						break;
				}
			}
			if ( (m_idRlvRoot.notNull()) && (!gInventory.containsObserver((RlvInventory*)this)) )
				gInventory.addObserver((RlvInventory*)this);
		}
	}
	return m_idRlvRoot;
}
Exemplo n.º 3
0
void LLFriendCardsManager::findMatchedFriendCards(const LLUUID& avatarID, LLInventoryModel::item_array_t& items) const
{
	LLInventoryModel::cat_array_t cats;
	LLUUID friendFolderUUID = findFriendFolderUUIDImpl();


	LLViewerInventoryCategory* friendFolder = gInventory.getCategory(friendFolderUUID);
	if (NULL == friendFolder)
		return;

	LLParticularBuddyCollector matchFunctor(avatarID);
	LLInventoryModel::cat_array_t subFolders;
	subFolders.push_back(friendFolder);

	while (subFolders.count() > 0)
	{
		LLViewerInventoryCategory* cat = subFolders.get(0);
		subFolders.remove(0);

		gInventory.collectDescendentsIf(cat->getUUID(), cats, items, 
			LLInventoryModel::EXCLUDE_TRASH, matchFunctor);

		move_from_to_arrays(cats, subFolders);
	}
}
Exemplo n.º 4
0
// Checked: 2010-02-28 (RLVa-1.2.0a) | Modified: RLVa-1.0.1a
LLViewerInventoryCategory* RlvInventory::getSharedFolder(const LLUUID& idParent, const std::string& strFolderName) const
{
	LLInventoryModel::cat_array_t* pFolders; LLInventoryModel::item_array_t* pItems;
	gInventory.getDirectDescendentsOf(idParent, pFolders, pItems);
	if ( (!pFolders) || (strFolderName.empty()) )
		return NULL;

	// If we can't find an exact match then we'll settle for a "contains" match
	LLViewerInventoryCategory* pPartial = NULL;

	//LLStringUtil::toLower(strFolderName); <- everything was already converted to lower case before

	std::string strName;
	for (S32 idxFolder = 0, cntFolder = pFolders->count(); idxFolder < cntFolder; idxFolder++)
	{
		LLViewerInventoryCategory* pFolder = pFolders->get(idxFolder);

		strName = pFolder->getName();
		if (strName.empty())
			continue;
		LLStringUtil::toLower(strName);

		if (strFolderName == strName)
			return pFolder;		// Found an exact match, no need to keep on going
		else if ( (!pPartial) && (RLV_FOLDER_PREFIX_HIDDEN != strName[0]) && (std::string::npos != strName.find(strFolderName)) )
			pPartial = pFolder;	// Found a partial (non-hidden) match, but we might still find an exact one (first partial match wins)
	}

	return pPartial;
}
Exemplo n.º 5
0
// Checked: 2010-02-28 (RLVa-1.1.3a) | Modified: RLVa-1.0.0h
void RlvInventory::fetchSharedInventory()
{
	// Sanity check - don't fetch if we're already fetching, or if we don't have a shared root
	const LLViewerInventoryCategory* pRlvRoot = getSharedRoot();
	if ( (m_fFetchStarted) || (!pRlvRoot) )
		return;

	// Grab all the folders under the shared root
	LLInventoryModel::cat_array_t folders; LLInventoryModel::item_array_t items;
	gInventory.collectDescendents(pRlvRoot->getUUID(), folders, items, FALSE);

	// Add them to the "to fetch" list
	uuid_vec_t fetchFolders;
	fetchFolders.push_back(pRlvRoot->getUUID());
	for (S32 idxFolder = 0, cntFolder = folders.count(); idxFolder < cntFolder; idxFolder++)
		fetchFolders.push_back(folders.get(idxFolder)->getUUID());

	// Now fetch them all in one go
	RlvSharedInventoryFetcher* pFetcher = new RlvSharedInventoryFetcher(fetchFolders);

	RLV_INFOS << "Starting fetch of " << fetchFolders.size() << " shared folders" << RLV_ENDL;
	pFetcher->startFetch();
	m_fFetchStarted = true;

	if (pFetcher->isFinished())
		pFetcher->done();
	else
		gInventory.addObserver(pFetcher);
}
// Tell if a listing has one only version folder
bool hasUniqueVersionFolder(const LLUUID& folder_id)
{
	LLInventoryModel::cat_array_t* categories;
	LLInventoryModel::item_array_t* items;
	gInventory.getDirectDescendentsOf(folder_id, categories, items);
	return (categories->size() == 1);
}
Exemplo n.º 7
0
void LLFloaterOutbox::updateFolderCount()
{
	if (mOutboxInventoryPanel.get() && mOutboxId.notNull())
	{
		S32 item_count = 0;

		if (mOutboxId.notNull())
		{
			LLInventoryModel::cat_array_t * cats;
			LLInventoryModel::item_array_t * items;
			gInventory.getDirectDescendentsOf(mOutboxId, cats, items);

			item_count = cats->count() + items->count();
		}

		mOutboxItemCount = item_count;
	}
	else
	{
		// If there's no outbox, the number of items in it should be set to 0 for consistency
		mOutboxItemCount = 0;
	}

	if (!mImportBusy)
	{
		updateFolderCountStatus();
	}
}
Exemplo n.º 8
0
//////////////////////////////////////////////////////////////////////////
// Private methods
//////////////////////////////////////////////////////////////////////////
void LLOutfitsList::computeDifference(
	const LLInventoryModel::cat_array_t& vcats, 
	uuid_vec_t& vadded, 
	uuid_vec_t& vremoved)
{
	uuid_vec_t vnew;
	// Creating a vector of newly collected sub-categories UUIDs.
	for (LLInventoryModel::cat_array_t::const_iterator iter = vcats.begin();
		iter != vcats.end();
		iter++)
	{
		vnew.push_back((*iter)->getUUID());
	}

	uuid_vec_t vcur;
	// Creating a vector of currently displayed sub-categories UUIDs.
	for (outfits_map_t::const_iterator iter = mOutfitsMap.begin();
		iter != mOutfitsMap.end();
		iter++)
	{
		vcur.push_back((*iter).first);
	}

	LLCommonUtils::computeDifference(vnew, vcur, vadded, vremoved);
}
Exemplo n.º 9
0
void move_from_to_arrays(LLInventoryModel::cat_array_t& from, LLInventoryModel::cat_array_t& to)
{
	while (from.count() > 0)
	{
		to.put(from.get(0));
		from.remove(0);
	}
}
Exemplo n.º 10
0
LLUUID FSLSLBridge::findFSBridgeContainerCategory()
{
	llinfos << "Retrieving FSBridge container category (" << FS_BRIDGE_CONTAINER_FOLDER << ")" << llendl;
	if (mBridgeContainerFolderID.notNull())
	{
		llinfos << "Returning FSBridge container category UUID from instance: " << mBridgeContainerFolderID << llendl;
		return mBridgeContainerFolderID;
	}

	LLUUID LibRootID = gInventory.getLibraryRootFolderID();
	if (LibRootID.notNull())
	{
		LLInventoryModel::item_array_t* items;
		LLInventoryModel::cat_array_t* cats;
		gInventory.getDirectDescendentsOf(LibRootID, cats, items);
		if (cats)
		{
			S32 count = cats->count();
			for (S32 i = 0; i < count; ++i)
			{
				if (cats->get(i)->getName() == "Objects")
				{
					LLUUID LibObjectsCatID = cats->get(i)->getUUID();
					if (LibObjectsCatID.notNull())
					{
						LLInventoryModel::item_array_t* objects_items;
						LLInventoryModel::cat_array_t* objects_cats;
						gInventory.getDirectDescendentsOf(LibObjectsCatID, objects_cats, objects_items);
						if (objects_cats)
						{
							S32 objects_count = objects_cats->count();
							for (S32 j = 0; j < objects_count; ++j)
							{
								if (objects_cats->get(j)->getName() == FS_BRIDGE_CONTAINER_FOLDER)
								{
									mBridgeContainerFolderID = objects_cats->get(j)->getUUID();
									llinfos << "FSBridge container category found in library. UUID: " << mBridgeContainerFolderID << llendl;
									gInventory.fetchDescendentsOf(mBridgeContainerFolderID);
									return mBridgeContainerFolderID;
								}
							}
						}
					}
				}
			}
		}
	}

	llwarns << "FSBridge container category not found in library!" << llendl;
	return LLUUID();
}
Exemplo n.º 11
0
// Checked: 2010-04-07 (RLVa-1.2.0a) | Modified: RLVa-1.0.0h
bool RlvInventory::findSharedFolders(const std::string& strCriteria, LLInventoryModel::cat_array_t& folders) const
{
	// Sanity check - can't do anything without a shared root
	const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot();
	if (!pRlvRoot)
		return false;

	folders.clear();
	LLInventoryModel::item_array_t items;
	RlvCriteriaCategoryCollector f(strCriteria);
	gInventory.collectDescendentsIf(pRlvRoot->getUUID(), folders, items, FALSE, f);

	return (folders.count() != 0);
}
S32 LLFloaterMarketplaceListings::getFolderCount()
{
	if (mPanelListings && mRootFolderId.notNull())
	{
		LLInventoryModel::cat_array_t * cats;
		LLInventoryModel::item_array_t * items;
		gInventory.getDirectDescendentsOf(mRootFolderId, cats, items);

		return (cats->size() + items->size());
	}
	else
	{
		return 0;
	}
}
static void collectLandmarkFolders(LLInventoryModel::cat_array_t& cats)
{
	LLUUID landmarks_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK);

	// Add descendent folders of the "Landmarks" category.
	LLInventoryModel::item_array_t items; // unused
	LLIsType is_category(LLAssetType::AT_CATEGORY);
	gInventory.collectDescendentsIf(
		landmarks_id,
		cats,
		items,
		LLInventoryModel::EXCLUDE_TRASH,
		is_category);

	// Add the "My Favorites" category.
	LLUUID favorites_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
	LLViewerInventoryCategory* favorites_cat = gInventory.getCategory(favorites_id);
	if (!favorites_cat)
	{
		LL_WARNS() << "Cannot find the favorites folder" << LL_ENDL;
	}
	else
	{
		cats.push_back(favorites_cat);
	}
}
Exemplo n.º 14
0
// static
void LLLocalInventory::climb(LLInventoryCategory* cat,
                             LLInventoryModel::cat_array_t& cats,
                             LLInventoryModel::item_array_t& items)
{
    LLInventoryModel* model = &gInventory;

    // Add this category
    cats.push_back(LLPointer<LLViewerInventoryCategory>((LLViewerInventoryCategory*)cat));

    LLInventoryModel::cat_array_t *direct_cats;
    LLInventoryModel::item_array_t *direct_items;
    model->getDirectDescendentsOf(cat->getUUID(), direct_cats, direct_items);

    // Add items
    LLInventoryModel::item_array_t::iterator item_iter = direct_items->begin();
    LLInventoryModel::item_array_t::iterator item_end = direct_items->end();
    for( ; item_iter != item_end; ++item_iter)
    {
        items.push_back(*item_iter);
    }

    // Do subcategories
    LLInventoryModel::cat_array_t::iterator cat_iter = direct_cats->begin();
    LLInventoryModel::cat_array_t::iterator cat_end = direct_cats->end();
    for( ; cat_iter != cat_end; ++cat_iter)
    {
        climb(*cat_iter, cats, items);
    }
}
void LLFloaterGesture::done()
{
	//this method can be called twice: for GestureFolder and once after loading all sudir of GestureFolder
	if (gInventory.isCategoryComplete(mGestureFolderID))
	{
		LL_DEBUGS("Gesture")<< "mGestureFolderID loaded" << LL_ENDL;
		// we load only gesture folder without childred.
		LLInventoryModel::cat_array_t* categories;
		LLInventoryModel::item_array_t* items;
		uuid_vec_t unloaded_folders;
		LL_DEBUGS("Gesture")<< "Get subdirs of Gesture Folder...." << LL_ENDL;
		gInventory.getDirectDescendentsOf(mGestureFolderID, categories, items);
		if (categories->empty())
		{
			gInventory.removeObserver(this);
			LL_INFOS("Gesture")<< "Gesture dos NOT contains sub-directories."<< LL_ENDL;
			return;
		}
		LL_DEBUGS("Gesture")<< "There are " << categories->size() << " Folders "<< LL_ENDL;
		for (LLInventoryModel::cat_array_t::iterator it = categories->begin(); it != categories->end(); it++)
		{
			if (!gInventory.isCategoryComplete(it->get()->getUUID()))
			{
				unloaded_folders.push_back(it->get()->getUUID());
				LL_DEBUGS("Gesture")<< it->get()->getName()<< " Folder added to fetchlist"<< LL_ENDL;
			}

		}
		if (!unloaded_folders.empty())
		{
			LL_DEBUGS("Gesture")<< "Fetching subdirectories....." << LL_ENDL;
			setFetchIDs(unloaded_folders);
			startFetch();
		}
		else
		{
			LL_DEBUGS("Gesture")<< "All Gesture subdirectories have been loaded."<< LL_ENDL;
			gInventory.removeObserver(this);
			buildGestureList();
		}
	}
	else
	{
		LL_WARNS("Gesture")<< "Gesture list was NOT loaded"<< LL_ENDL;
	}
}
Exemplo n.º 16
0
bool LLInventoryCategoriesObserver::addCategory(const LLUUID& cat_id, callback_t cb)
{
	S32 version = LLViewerInventoryCategory::VERSION_UNKNOWN;
	S32 current_num_known_descendents = LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN;
	bool can_be_added = true;

	LLViewerInventoryCategory* category = gInventory.getCategory(cat_id);
	// 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 DESCENDENT_COUNT_UNKNOWN,
	// it may be updated later.
	if (category)
	{
		// Inventory category version is used to find out if some changes
		// to a category have been made.
		version = category->getVersion();

		LLInventoryModel::cat_array_t* cats;
		LLInventoryModel::item_array_t* items;
		gInventory.getDirectDescendentsOf(cat_id, cats, items);
		if (!cats || !items)
		{
			LL_WARNS() << "Category '" << category->getName() << "' descendents corrupted, fetch failed." << LL_ENDL;
			// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
			// that the cat just doesn't have any items or subfolders).
			// Unrecoverable, so just return "false" meaning that the category can't be observed.
			can_be_added = false;

			llassert(cats != NULL && items != NULL);
		}
		else
		{
			current_num_known_descendents = cats->size() + items->size();
		}
	}

	if (can_be_added)
	{
		mCategoryMap.insert(category_map_value_t(
								cat_id,LLCategoryData(cat_id, cb, version, current_num_known_descendents)));
	}

	return can_be_added;
}
Exemplo n.º 17
0
// Checked: 2010-02-28 (RLVa-1.1.3a) | Modified: RLVa-1.0.0h
LLViewerInventoryCategory* RlvInventory::getSharedRoot() const
{
	if (gInventory.isInventoryUsable())
	{
		LLInventoryModel::cat_array_t* pFolders; LLInventoryModel::item_array_t* pItems;
		gInventory.getDirectDescendentsOf(gInventory.getRootFolderID(), pFolders, pItems);
		if (pFolders)
		{
			// NOTE: we might have multiple #RLV folders so we'll just go with the first one we come across
			LLViewerInventoryCategory* pFolder;
			for (S32 idxFolder = 0, cntFolder = pFolders->count(); idxFolder < cntFolder; idxFolder++)
			{
				if ( ((pFolder = pFolders->get(idxFolder)) != NULL) && (RlvInventory::cstrSharedRoot == pFolder->getName()) )
					return pFolder;
			}
		}
	}
	return NULL;
}
Exemplo n.º 18
0
//static
void LLLocalInventory::saveInvCache(std::string filename, LLFolderView* folder)
{
	LLInventoryModel* model = &gInventory;
	std::set<LLUUID> selected_items;
	folder->getSelectionList(selected_items);
	if(selected_items.size() < 1)
	{
		// No items selected?  Wtfboom
		return;
	}
	LLInventoryModel::cat_array_t cats;
	LLInventoryModel::item_array_t items;
	// Make complete lists of child categories and items
	std::set<LLUUID>::iterator sel_iter = selected_items.begin();
	std::set<LLUUID>::iterator sel_end = selected_items.end();
	for( ; sel_iter != sel_end; ++sel_iter)
	{
		LLInventoryCategory* cat = model->getCategory(*sel_iter);
		if(cat)
		{
			climb(cat, cats, items);
		}
	}
	// And what about items inside a folder that wasn't selected?
	// I guess I will just add selected items, so long as they aren't already added
	for(sel_iter = selected_items.begin(); sel_iter != sel_end; ++sel_iter)
	{
		LLInventoryItem* item = model->getItem(*sel_iter);
		if(item)
		{
			if(std::find(items.begin(), items.end(), item) == items.end())
			{
				items.push_back(LLPointer<LLViewerInventoryItem>((LLViewerInventoryItem*)item));
				LLInventoryCategory* parent = model->getCategory(item->getParentUUID());
				if(std::find(cats.begin(), cats.end(), parent) == cats.end())
				{
					cats.push_back(LLPointer<LLViewerInventoryCategory>((LLViewerInventoryCategory*)parent));
				}
			}
		}
	}
	LLInventoryModel::saveToFile(filename, cats, items);
}
Exemplo n.º 19
0
BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInventoryCategory* cat) const
{
	const S32 version = cat->getVersion();
	const S32 expected_num_descendents = cat->getDescendentCount();
	if ((version == LLViewerInventoryCategory::VERSION_UNKNOWN) ||
		(expected_num_descendents == LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN))
	{
		return FALSE;
	}
	// it might be complete - check known descendents against
	// currently available.
	LLInventoryModel::cat_array_t* cats;
	LLInventoryModel::item_array_t* items;
	gInventory.getDirectDescendentsOf(cat->getUUID(), cats, items);
	if (!cats || !items)
	{
		LL_WARNS() << "Category '" << cat->getName() << "' descendents corrupted, fetch failed." << LL_ENDL;
		// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
		// that the cat just doesn't have any items or subfolders).
		// Unrecoverable, so just return done so that this observer can be cleared
		// from memory.
		return TRUE;
	}
	const S32 current_num_known_descendents = cats->size() + items->size();
	
	// Got the number of descendents that we were expecting, so we're done.
	if (current_num_known_descendents == expected_num_descendents)
	{
		return TRUE;
	}

	// Error condition, but recoverable.  This happens if something was added to the
	// category before it was initialized, so accountForUpdate didn't update descendent
	// count and thus the category thinks it has fewer descendents than it actually has.
	if (current_num_known_descendents >= expected_num_descendents)
	{
		LL_WARNS() << "Category '" << cat->getName() << "' expected descendentcount:" << expected_num_descendents << " descendents but got descendentcount:" << current_num_known_descendents << LL_ENDL;
		const_cast<LLViewerInventoryCategory *>(cat)->setDescendentCount(current_num_known_descendents);
		return TRUE;
	}
	return FALSE;
}
Exemplo n.º 20
0
LLUUID FSLSLBridge::findFSCategory()
{
	if (!mBridgeFolderID.isNull())
	{
		return mBridgeFolderID;
	}

	LLUUID fsCatID;
	LLUUID bridgeCatID;

	fsCatID = gInventory.findCategoryByName(ROOT_FIRESTORM_FOLDER);
	if (!fsCatID.isNull())
	{
		LLInventoryModel::item_array_t* items;
		LLInventoryModel::cat_array_t* cats;
		gInventory.getDirectDescendentsOf(fsCatID, cats, items);
		if (cats)
		{
			S32 count = cats->count();
			for (S32 i = 0; i < count; ++i)
			{
				if (cats->get(i)->getName() == FS_BRIDGE_FOLDER)
				{
					bridgeCatID = cats->get(i)->getUUID();
				}
			}
		}
	}
	else
	{
		fsCatID = gInventory.createNewCategory(gInventory.getRootFolderID(), LLFolderType::FT_NONE, ROOT_FIRESTORM_FOLDER);
	}

	if (bridgeCatID.isNull())
	{
		bridgeCatID = gInventory.createNewCategory(fsCatID, LLFolderType::FT_NONE, FS_BRIDGE_FOLDER);
	}

	mBridgeFolderID = bridgeCatID;

	return mBridgeFolderID;
}
Exemplo n.º 21
0
const LLUUID& get_folder_uuid(const LLUUID& parentFolderUUID, LLInventoryCollectFunctor& matchFunctor)
{
	LLInventoryModel::cat_array_t cats;
	LLInventoryModel::item_array_t items;

	gInventory.collectDescendentsIf(parentFolderUUID, cats, items,
		LLInventoryModel::EXCLUDE_TRASH, matchFunctor);

	S32 cats_count = cats.count();

	if (cats_count > 1)
	{
		LL_WARNS("LLFriendCardsManager")
			<< "There is more than one Friend card folder."
			<< "The first folder will be used."
			<< LL_ENDL;
	}

	return (cats_count >= 1) ? cats.get(0)->getUUID() : LLUUID::null;
}
Exemplo n.º 22
0
void LLFloaterOutbox::updateFolderCount()
{
    S32 item_count = 0;

    if (mOutboxId.notNull())
    {
        LLInventoryModel::cat_array_t * cats;
        LLInventoryModel::item_array_t * items;
        gInventory.getDirectDescendentsOf(mOutboxId, cats, items);

        item_count = cats->count() + items->count();
    }

    mOutboxItemCount = item_count;

    if (!mImportBusy)
    {
        updateFolderCountStatus();
    }
}
Exemplo n.º 23
0
void LLFriendCardsManager::collectFriendsLists(folderid_buddies_map_t& folderBuddiesMap) const
{
	folderBuddiesMap.clear();

	LLInventoryModel::cat_array_t* listFolders;
	LLInventoryModel::item_array_t* items;

	// get folders in the Friend folder. Items should be NULL due to Cards should be in lists.
	gInventory.getDirectDescendentsOf(findFriendFolderUUIDImpl(), listFolders, items);

	if (NULL == listFolders)
		return;

	LLInventoryModel::cat_array_t::const_iterator itCats;	// to iterate Friend Lists (categories)
	LLInventoryModel::item_array_t::const_iterator itBuddy;	// to iterate Buddies in each List
	LLInventoryModel::cat_array_t* fakeCatsArg;
	for (itCats = listFolders->begin(); itCats != listFolders->end(); ++itCats)
	{
		if (items)
			items->clear();

		// *HACK: Only Friends/All content will be shown for now
		// *TODO: Remove this hack, implement sorting if it will be needded by spec.
		if ((*itCats)->getUUID() != findFriendAllSubfolderUUIDImpl())
			continue;

		gInventory.getDirectDescendentsOf((*itCats)->getUUID(), fakeCatsArg, items);

		if (NULL == items)
			continue;

		uuid_vec_t buddyUUIDs;
		for (itBuddy = items->begin(); itBuddy != items->end(); ++itBuddy)
		{
			buddyUUIDs.push_back((*itBuddy)->getCreatorUUID());
		}

		folderBuddiesMap.insert(make_pair((*itCats)->getUUID(), buddyUUIDs));
	}
}
Exemplo n.º 24
0
void LLCOFMgr::checkCOF()
{
    const LLUUID idCOF = getCOF();
    const LLUUID idLAF = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);

    // Check COF for non-links and move them to Lost&Found
    LLInventoryModel::cat_array_t* pFolders;
    LLInventoryModel::item_array_t* pItems;
    gInventory.getDirectDescendentsOf(idCOF, pFolders, pItems);
    for (S32 idxFolder = 0, cntFolder = pFolders->count(); idxFolder < cntFolder; idxFolder++)
    {
        LLViewerInventoryCategory* pFolder = pFolders->get(idxFolder).get();
        if ( (pFolder) && (idLAF.notNull()) )
            change_category_parent(&gInventory, pFolder, idLAF, false);
    }
    for (S32 idxItem = 0, cntItem = pItems->count(); idxItem < cntItem; idxItem++)
    {
        LLViewerInventoryItem* pItem = pItems->get(idxItem).get();
        if ( (pItem) && (!pItem->getIsLinkType()) && (idLAF.notNull()) )
            change_item_parent(&gInventory, pItem, idLAF, false);
    }
}
Exemplo n.º 25
0
	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;
	}
Exemplo n.º 26
0
// LLUUID catID=TraverseCategories("/My Inventory/#Luna/Durp")
LLUUID TraverseCategories(const std::string& target_cat, LLViewerInventoryCategory *ccat, int i)
{
    // Split the path into an array.
    boost::char_separator<char> sep("/");
    boost::tokenizer<boost::char_separator<char> > tok(target_cat,sep);
    std::vector<std::string> vec;
    vec.assign(tok.begin(),tok.end());

    std::string cat = vec[i];
    LLUUID id;
    if(i==0)
    {
        id=gAgent.getInventoryRootID();
    } else {
        id = ccat->getUUID();
    }
    LLInventoryModel::cat_array_t *cats;
    LLInventoryModel::item_array_t *items;

    gInventory.getDirectDescendentsOf(id,cats,items);

    LLInventoryModel::cat_array_t::iterator cat_iter = cats->begin();
    LLInventoryModel::cat_array_t::iterator cat_end = cats->end();
    for( ; cat_iter != cat_end; ++cat_iter)
    {
        LLViewerInventoryCategory *c_cat=(*cat_iter);
        if(c_cat->getName() == cat)
        {
            if(vec.size() == i+1)
            {
                return c_cat->getUUID();
            } else {
                ++i;
                return TraverseCategories(target_cat,*cat_iter,i);
            }
        }
    }
    return LLUUID::null;
}
Exemplo n.º 27
0
// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c
bool RlvInventory::getPath(const uuid_vec_t& idItems, LLInventoryModel::cat_array_t& folders) const
{
	// Sanity check - can't do anything without a shared root
	const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot();
	if (!pRlvRoot)
		return false;

	folders.clear();
	for (uuid_vec_t::const_iterator itItem = idItems.begin(); itItem != idItems.end(); ++itItem)
	{
		const LLInventoryItem* pItem = gInventory.getItem(*itItem);
		if ( (pItem) && (gInventory.isObjectDescendentOf(pItem->getUUID(), pRlvRoot->getUUID())) )
		{
			// If the containing folder is a folded folder we need its parent
			LLViewerInventoryCategory* pFolder = gInventory.getCategory(pItem->getParentUUID());
			if (RlvInventory::instance().isFoldedFolder(pFolder, true))
				pFolder = gInventory.getCategory(pFolder->getParentUUID());
			folders.push_back(pFolder);
		}
	}

	return (folders.count() != 0);
}
void LLPanelLandmarkInfo::populateFoldersList()
{
	// Collect all folders that can contain landmarks.
	LLInventoryModel::cat_array_t cats;
	collectLandmarkFolders(cats);

	mFolderCombo->removeall();

	// Put the "Landmarks" folder first in list.
	LLUUID landmarks_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK);
	const LLViewerInventoryCategory* lmcat = gInventory.getCategory(landmarks_id);
	if (!lmcat)
	{
		LL_WARNS() << "Cannot find the landmarks folder" << LL_ENDL;
	}
	else
	{
		std::string cat_full_name = getFullFolderName(lmcat);
		mFolderCombo->add(cat_full_name, lmcat->getUUID());
	}

	typedef std::vector<folder_pair_t> folder_vec_t;
	folder_vec_t folders;
	// Sort the folders by their full name.
	for (S32 i = 0; i < cats.size(); i++)
	{
		const LLViewerInventoryCategory* cat = cats.at(i);
		std::string cat_full_name = getFullFolderName(cat);
		folders.push_back(folder_pair_t(cat->getUUID(), cat_full_name));
	}
	sort(folders.begin(), folders.end(), cmp_folders);

	// Finally, populate the combobox.
	for (folder_vec_t::const_iterator it = folders.begin(); it != folders.end(); it++)
		mFolderCombo->add(it->second, LLSD(it->first));
}
Exemplo n.º 29
0
void LLInventoryCategoriesObserver::changed(U32 mask)
{
	if (!mCategoryMap.size())
		return;

	std::vector<LLUUID> deleted_categories_ids;

	for (category_map_t::iterator iter = mCategoryMap.begin();
		 iter != mCategoryMap.end();
		 ++iter)
	{
		const LLUUID& cat_id = (*iter).first;
		LLCategoryData& cat_data = (*iter).second;
        
		LLViewerInventoryCategory* category = gInventory.getCategory(cat_id);
		if (!category)
        {
            LL_WARNS() << "Category : Category id = " << cat_id << " disappeared" << LL_ENDL;
			cat_data.mCallback();
            // Keep track of those deleted categories so we can remove them
            deleted_categories_ids.push_back(cat_id);
			continue;
        }

		const S32 version = category->getVersion();
		const S32 expected_num_descendents = category->getDescendentCount();
		if ((version == LLViewerInventoryCategory::VERSION_UNKNOWN) ||
			(expected_num_descendents == LLViewerInventoryCategory::DESCENDENT_COUNT_UNKNOWN))
		{
			continue;
		}

		// Check number of known descendents to find out whether it has changed.
		LLInventoryModel::cat_array_t* cats;
		LLInventoryModel::item_array_t* items;
		gInventory.getDirectDescendentsOf(cat_id, cats, items);
		if (!cats || !items)
		{
			LL_WARNS() << "Category '" << category->getName() << "' descendents corrupted, fetch failed." << LL_ENDL;
			// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
			// that the cat just doesn't have any items or subfolders).
			// Unrecoverable, so just skip this category.

			llassert(cats != NULL && items != NULL);

			continue;
		}
		
		const S32 current_num_known_descendents = cats->size() + items->size();

		bool cat_changed = false;

		// If category version or descendents count has changed
		// update category data in mCategoryMap
		if (version != cat_data.mVersion || current_num_known_descendents != cat_data.mDescendentsCount)
		{
			cat_data.mVersion = version;
			cat_data.mDescendentsCount = current_num_known_descendents;
			cat_changed = true;
		}

		// If any item names have changed, update the name hash 
		// Only need to check if (a) name hash has not previously been
		// computed, or (b) a name has changed.
		if (!cat_data.mIsNameHashInitialized || (mask & LLInventoryObserver::LABEL))
		{
			LLMD5 item_name_hash = gInventory.hashDirectDescendentNames(cat_id);
			if (cat_data.mItemNameHash != item_name_hash)
			{
				cat_data.mIsNameHashInitialized = true;
				cat_data.mItemNameHash = item_name_hash;
				cat_changed = true;
			}
		}

		// If anything has changed above, fire the callback.
		if (cat_changed)
			cat_data.mCallback();
	}
    
    // Remove deleted categories from the list
 	for (std::vector<LLUUID>::iterator deleted_id = deleted_categories_ids.begin(); deleted_id != deleted_categories_ids.end(); ++deleted_id)
	{
		removeCategory(*deleted_id);
    }
}
void AIFetchInventoryFolder::multiplex_impl(void)
{
  switch (mRunState)
  {
	case AIFetchInventoryFolder_checkFolderExists:
	{
	  // If LLInventoryModel_mIsAgentInvUsable_true then this should be and stay true forever.
	  llassert(gInventory.isInventoryUsable());
	  if (mParentFolder.isNull())
		mParentFolder = gAgent.getInventoryRootID();
	  if (mFolderUUID.isNull() || !gInventory.getCategory(mFolderUUID))		// Is the UUID unknown, or doesn't exist?
	  {
		// Set this to null here in case we abort.
		mFolderUUID.setNull();
		if (mFolderName.empty())
		{
		  // We can only find a folder by name, or create it, if we know it's name.
		  llwarns << "Unknown folder ID " << mFolderUUID << llendl;
		  abort();
		  break;
		}
		// Check if the parent exists.
		if (mParentFolder != gAgent.getInventoryRootID() && !gInventory.getCategory(mParentFolder))
		{
		  llwarns << "Unknown parent folder ID " << mParentFolder << llendl;
		  abort();
		  break;
		}
		// Look up UUID by name.
		LLInventoryModel::cat_array_t* categories;
		gInventory.getDirectDescendentsOf(mParentFolder, categories);
		for (S32 i = 0; i < categories->getLength(); ++i)
		{
		  LLPointer<LLViewerInventoryCategory> const& category(categories->get(i));
		  if (category->getName() == mFolderName)
		  {
			mFolderUUID = category->getUUID();
			break;
		  }
		}
		if (mFolderUUID.isNull())											// Does the folder exist?
		{
		  if (!mCreate)
		  {
			// We're done.
			finish();
			break;
		  }
		  // Create the folder.
		  mFolderUUID = gInventory.createNewCategory(mParentFolder, LLAssetType::AT_NONE, mFolderName);
		  llassert_always(!mFolderUUID.isNull());
		  Dout(dc::statemachine, "Created folder \"" << mFolderName << "\".");
		  mNeedNotifyObservers = true;
		}
		mCreated = true;
	  }
	  // mFolderUUID is now valid.
	  mExists = true;
	  if (!mFetchContents ||							// No request to fetch contents.
		  LLInventoryModel::isEverythingFetched())		// No need to fetch contents.
	  {
		// We're done.
		finish();
		break;
	  }
	  set_state(AIFetchInventoryFolder_fetchDescendents);
	  /*Fall-through*/
	}
	case AIFetchInventoryFolder_fetchDescendents:
	{
	  // This sets the state to AIFetchInventoryFolder_folderCompleted once the folder is complete.
	  new AIInventoryFetchDescendentsObserver(this, mFolderUUID);
	  break;
	}
	case AIFetchInventoryFolder_folderCompleted:
	{
	  // Does it still exist?
	  if (!gInventory.getCategory(mFolderUUID))
	  {
		// Assume the folder was deleted in the meantime.
		abort();
		break;
	  }
	  llassert(gInventory.isCategoryComplete(mFolderUUID));
	  // The folder is complete!
	  finish();
	  break;
	}
  }
}