コード例 #1
0
ファイル: rlvhelper.cpp プロジェクト: Frans/SingularityViewer
// Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a
bool RlvForceWear::isStrippable(const LLInventoryItem* pItem)
{
	// An item is exempt from @detach or @remoutfit if:
	//   - its name contains "nostrip" (anywhere in the name)
	//   - its parent folder contains "nostrip" (anywhere in the name)
	if (pItem)
	{
		// If the item is an inventory link then we first examine its target before examining the link itself (and never its name)
		if (LLAssetType::AT_LINK == pItem->getActualType())
		{
			if (!isStrippable(pItem->getLinkedUUID()))
				return false;
		}
		else
		{
			if (std::string::npos != pItem->getName().find(RLV_FOLDER_FLAG_NOSTRIP))
				return false;
		}

		LLViewerInventoryCategory* pFolder = gInventory.getCategory(pItem->getParentUUID());
		while (pFolder)
		{
			if (std::string::npos != pFolder->getName().find(RLV_FOLDER_FLAG_NOSTRIP))
				return false;
			// If the item's parent is a folded folder then we need to check its parent as well
			if ( (gInventory.getRootFolderID() != pFolder->getParentUUID()) && (RlvInventory::isFoldedFolder(pFolder, true)) )
				pFolder = gInventory.getCategory(pFolder->getParentUUID());
			else
				pFolder = NULL;
		}
	}
	return true;
}
コード例 #2
0
void move_to_outbox_cb_action(const LLSD& payload)
{
	LLViewerInventoryItem * viitem = gInventory.getItem(payload["item_id"].asUUID());
	LLUUID dest_folder_id = payload["dest_folder_id"].asUUID();

	if (viitem)
	{	
		// when moving item directly into outbox create folder with that name
		if (dest_folder_id == gInventory.findCategoryUUIDForType(LLFolderType::FT_OUTBOX, false))
		{
			S32 operation_id = payload["operation_id"].asInteger();
			dest_folder_id = create_folder_in_outbox_for_item(viitem, dest_folder_id, operation_id);
		}

		LLUUID parent = viitem->getParentUUID();

		gInventory.changeItemParent(
			viitem,
			dest_folder_id,
			false);

		LLUUID top_level_folder = payload["top_level_folder"].asUUID();

		if (top_level_folder != LLUUID::null)
		{
			LLViewerInventoryCategory* category;

			while (parent.notNull())
			{
				LLInventoryModel::cat_array_t* cat_array;
				LLInventoryModel::item_array_t* item_array;
				gInventory.getDirectDescendentsOf(parent,cat_array,item_array);

				LLUUID next_parent;

				category = gInventory.getCategory(parent);

				if (!category) break;

				next_parent = category->getParentUUID();

				if (cat_array->empty() && item_array->empty())
				{
					gInventory.removeCategory(parent);
				}

				if (parent == top_level_folder)
				{
					break;
				}

				parent = next_parent;
			}
		}

		open_outbox();
	}
}
コード例 #3
0
//static
void LLInventoryPanel::openInventoryPanelAndSetSelection(BOOL auto_open, const LLUUID& obj_id)
{
	LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(auto_open);

	if (active_panel)
	{
		LL_DEBUGS("Messaging") << "Highlighting" << obj_id  << LL_ENDL;
		
		LLViewerInventoryItem * item = gInventory.getItem(obj_id);
		LLViewerInventoryCategory * cat = gInventory.getCategory(obj_id);
		
		bool in_inbox = false;
		
		LLViewerInventoryCategory * parent_cat = NULL;
		
		if (item)
		{
			parent_cat = gInventory.getCategory(item->getParentUUID());
		}
		else if (cat)
		{
			parent_cat = gInventory.getCategory(cat->getParentUUID());
		}
		
		if (parent_cat)
		{
			in_inbox = (LLFolderType::FT_INBOX == parent_cat->getPreferredType());
		}
		
		if (in_inbox)
		{
			LLSidepanelInventory * sidepanel_inventory =	LLFloaterSidePanelContainer::getPanel<LLSidepanelInventory>("inventory");
			LLInventoryPanel * inventory_panel = NULL;
			
			if (in_inbox)
			{
				sidepanel_inventory->openInbox();
				inventory_panel = sidepanel_inventory->getInboxPanel();
			}

			if (inventory_panel)
			{
				inventory_panel->setSelection(obj_id, TAKE_FOCUS_YES);
			}
		}
		else
		{
			active_panel->setSelection(obj_id, TAKE_FOCUS_YES);
		}
	}
}
コード例 #4
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);
}
コード例 #5
0
//static
void LLLocalInventory::loadInvCache(std::string filename)
{
    std::string extension = gDirUtilp->getExtension(filename);
    std::string inv_filename = filename;
    if(extension == "gz")
    {
        LLUUID random;
        random.generate();
        inv_filename = filename.substr(0, filename.length() - 3) + "." + random.asString();

        if(!gunzip_file(filename, inv_filename))
        {
            // failure... message?
            return;
        }
    }

    LLInventoryModel::cat_array_t cats;
    LLInventoryModel::item_array_t items;
    bool is_cache_obsolete = false;
    if(LLInventoryModel::loadFromFile(inv_filename, cats, items, is_cache_obsolete))
    {
        // create a container category for everything
        LLViewerInventoryCategory* container = new LLViewerInventoryCategory(gAgent.getID());
        container->rename(gDirUtilp->getBaseFileName(filename, false));
        LLUUID container_id;
        container_id.generate();
        container->setUUID(container_id);
        container->setParent(gSystemFolderRoot);
        container->setPreferredType(LLFolderType::FT_NONE);
        LLInventoryModel::update_map_t container_update;
        ++container_update[container->getParentUUID()];
        gInventory.accountForUpdate(container_update);
        gInventory.updateCategory(container);
        gInventory.notifyObservers();

        LLViewerInventoryCategory* orphaned_items = new LLViewerInventoryCategory(gAgent.getID());
        orphaned_items->rename("Orphaned Items");
        LLUUID orphaned_items_id;

        orphaned_items_id.generate();
        orphaned_items->setUUID(orphaned_items_id);
        orphaned_items->setParent(container_id);
        orphaned_items->setPreferredType(LLFolderType::FT_NONE);

        LLInventoryModel::update_map_t orphaned_items_update;
        ++orphaned_items_update[orphaned_items->getParentUUID()];
        gInventory.accountForUpdate(orphaned_items_update);
        gInventory.updateCategory(orphaned_items);
        gInventory.notifyObservers();

        //conflict handling
        std::map<LLUUID,LLUUID> conflicting_cats;
        int dropped_cats = 0;
        int dropped_items = 0;

        // Add all categories
        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)
        {
            // Conditionally change its parent
            // Note: Should I search for missing parent id's?

            //if the parent is null, it goes in the very root of the tree!
            if((*cat_iter)->getParentUUID().isNull())
            {
                (*cat_iter)->setParent(container_id);
            }
            // If the parent exists and outside of pretend inventory, generate a new uuid
            else if(gInventory.getCategory((*cat_iter)->getParentUUID()))
            {
                if(!gInventory.isObjectDescendentOf((*cat_iter)->getParentUUID(), gSystemFolderRoot, TRUE))
                {
                    std::map<LLUUID,LLUUID>::iterator itr = conflicting_cats.find((*cat_iter)->getParentUUID());
                    if(itr == conflicting_cats.end())
                    {
                        dropped_cats++;
                        continue;
                    }
                    (*cat_iter)->setParent(itr->second);
                }
            } else {
                //well balls, this is orphaned.
                (*cat_iter)->setParent(orphaned_items_id);
            }
            // If this category already exists, generate a new uuid
            if(gInventory.getCategory((*cat_iter)->getUUID()))
            {
                LLUUID cat_random;
                cat_random.generate();
                conflicting_cats[(*cat_iter)->getUUID()] = cat_random;
                (*cat_iter)->setUUID(cat_random);
            }

            LLInventoryModel::update_map_t update;
            ++update[(*cat_iter)->getParentUUID()];
            gInventory.accountForUpdate(update);
            gInventory.updateCategory(*cat_iter);
            gInventory.notifyObservers();
        }

        // Add all items
        LLInventoryModel::item_array_t::iterator item_iter = items.begin();
        LLInventoryModel::item_array_t::iterator item_end = items.end();
        for(; item_iter != item_end; ++item_iter)
        {
            // Conditionally change its parent
            // Note: Should I search for missing parent id's?

            //if the parent is null, it goes in the very root of the tree!
            if((*item_iter)->getParentUUID().isNull())
            {
                (*item_iter)->setParent(container_id);
            }

            // If the parent exists and outside of pretend inventory, generate a new uuid
            if(gInventory.getCategory((*item_iter)->getParentUUID()))
            {
                if(!gInventory.isObjectDescendentOf((*item_iter)->getParentUUID(), gSystemFolderRoot, TRUE))
                {
                    std::map<LLUUID,LLUUID>::iterator itr = conflicting_cats.find((*item_iter)->getParentUUID());
                    if(itr == conflicting_cats.end())
                    {
                        dropped_items++;
                        continue;
                    }
                    (*item_iter)->setParent(itr->second);
                }
            } else {
                //well balls, this is orphaned.
                (*item_iter)->setParent(orphaned_items_id);
            }
            // Avoid conflicts with real inventory...
            // If this item id already exists, generate a new uuid
            if(gInventory.getItem((*item_iter)->getUUID()))
            {
                LLUUID item_random;
                item_random.generate();
                (*item_iter)->setUUID(item_random);
            }

            LLInventoryModel::update_map_t update;
            ++update[(*item_iter)->getParentUUID()];
            gInventory.accountForUpdate(update);
            gInventory.updateItem(*item_iter);
            gInventory.notifyObservers();
        }

        // Quality time
        if(dropped_items || dropped_cats)
        {
            std::ostringstream message;
            message << "Some items were ignored due to conflicts:\n\n";
            if(dropped_cats) message << dropped_cats << " folders\n";
            if(dropped_items) message << dropped_items << " items\n";

            LLSD args;
            args["ERROR_MESSAGE"] = message.str();
            LLNotificationsUtil::add("ErrorMessage", args);
        }
        conflicting_cats.clear();// srsly dont think this is need but w/e :D
    }

    // remove temporary unzipped file
    if(extension == "gz")
    {
        LLFile::remove(inv_filename);
    }

}
コード例 #6
0
// Checked: 2010-03-14 (RLVa-1.1.3a) | Added: RLVa-1.2.0a
void RlvRenameOnWearObserver::doneIdle()
{
	const LLViewerInventoryCategory* pRlvRoot = NULL; LLVOAvatar* pAvatar = gAgentAvatarp;
	if ( (RlvSettings::getEnableSharedWear()) || (!RlvSettings::getSharedInvAutoRename()) || (LLStartUp::getStartupState() < STATE_STARTED) || 
		 (!pAvatar) || ((pRlvRoot = RlvInventory::instance().getSharedRoot()) == NULL) )
	{
		delete this;
		return;
	}

	const LLViewerJointAttachment* pAttachPt = NULL; S32 idxAttachPt = 0;
//	RLV_ASSERT(mComplete.size() > 0);	// Catch instances where we forgot to call startFetch()
	for (uuid_vec_t::const_iterator itItem = mComplete.begin(); itItem != mComplete.end(); ++itItem)
	{
		const LLUUID& idAttachItem = *itItem;

		// If the item resides under #RLV we'll rename it directly; otherwise settle for "renaming" all of its links residing under #RLV
		LLInventoryModel::item_array_t items;
		if (gInventory.isObjectDescendentOf(idAttachItem, pRlvRoot->getUUID()))
			items.push_back(gInventory.getItem(idAttachItem));
		else
			items = gInventory.collectLinkedItems(idAttachItem, pRlvRoot->getUUID());
		if (items.empty())
			continue;

		if ( ((pAttachPt = pAvatar->getWornAttachmentPoint(idAttachItem)) == NULL) ||
			 ((idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pAttachPt)) == 0) )
		{
//			RLV_ASSERT(false);
			continue;
		}

		static const std::string &new_category_name = LLViewerFolderType::lookupNewCategoryName(LLFolderType::FT_NONE);
		for (S32 idxItem = 0, cntItem = items.count(); idxItem < cntItem; idxItem++)
		{
			LLViewerInventoryItem* pItem = items.get(idxItem);
			if (!pItem)
				continue;

			S32 idxAttachPtItem = RlvAttachPtLookup::getAttachPointIndex(pItem);
			if ( (idxAttachPt == idxAttachPtItem) || (idxAttachPtItem) )
				continue;

			std::string strAttachPt = pAttachPt->getName();
			LLStringUtil::toLower(strAttachPt);

			// If we can modify the item then we rename it directly, otherwise we create a new folder and move it
			if (pItem->getPermissions().allowModifyBy(gAgent.getID()))
			{
				std::string strName = pItem->getName();
				LLStringUtil::truncate(strName, DB_INV_ITEM_NAME_STR_LEN - strAttachPt.length() - 3);

				strName += " (" + strAttachPt + ")";

				pItem->rename(strName);
				pItem->updateServer(FALSE);
				gInventory.addChangedMask(LLInventoryObserver::LABEL, pItem->getUUID());
			}
			else
			{
				// Don't do anything if the item is a direct descendant of the shared root, or a folded folder
				LLViewerInventoryCategory* pFolder = gInventory.getCategory(pItem->getParentUUID());
				if ( (pFolder) && (pFolder->getUUID() != pRlvRoot->getUUID()) && (!RlvInventory::isFoldedFolder(pFolder, false)) )
				{
					std::string strFolderName = ".(" + strAttachPt + ")";

					// Rename the item's parent folder if it's called "New Folder", isn't directly under #RLV and contains exactly 1 object
					if ( (new_category_name == pFolder->getName()) && 
						 (pFolder->getParentUUID() != pRlvRoot->getUUID()) && 
						 (1 == RlvInventory::getDirectDescendentsCount(pFolder, LLAssetType::AT_OBJECT)) )
					{
						pFolder->rename(strFolderName);
						pFolder->updateServer(FALSE);
						gInventory.addChangedMask(LLInventoryObserver::LABEL, pFolder->getUUID());
					}
					else
					{
						// "No modify" item with a non-renameable parent: create a new folder named and move the item into it
						LLUUID idAttachFolder = gInventory.createNewCategory(pFolder->getUUID(), LLFolderType::FT_NONE, strFolderName);
						move_inventory_item(gAgent.getID(), gAgent.getSessionID(), pItem->getUUID(), idAttachFolder, std::string(), NULL);
					}
				}
			}
		}
	}
	gInventory.notifyObservers();

	delete this;
}
コード例 #7
0
void AISUpdate::parseMeta(const LLSD& update)
{
	// parse _categories_removed -> mObjectsDeletedIds
	uuid_list_t cat_ids;
	parseUUIDArray(update,"_categories_removed",cat_ids);
	for (uuid_list_t::const_iterator it = cat_ids.begin();
		 it != cat_ids.end(); ++it)
	{
		LLViewerInventoryCategory *cat = gInventory.getCategory(*it);
		if(cat)
		{
			mCatDescendentDeltas[cat->getParentUUID()]--;
			mObjectsDeletedIds.insert(*it);
		}
		else
		{
			LL_WARNS("Inventory") << "removed category not found " << *it << LL_ENDL;
		}
	}

	// parse _categories_items_removed -> mObjectsDeletedIds
	uuid_list_t item_ids;
	parseUUIDArray(update,"_category_items_removed",item_ids);
	parseUUIDArray(update,"_removed_items",item_ids);
	for (uuid_list_t::const_iterator it = item_ids.begin();
		 it != item_ids.end(); ++it)
	{
		LLViewerInventoryItem *item = gInventory.getItem(*it);
		if(item)
		{
			mCatDescendentDeltas[item->getParentUUID()]--;
			mObjectsDeletedIds.insert(*it);
		}
		else
		{
			LL_WARNS("Inventory") << "removed item not found " << *it << LL_ENDL;
		}
	}

	// parse _broken_links_removed -> mObjectsDeletedIds
	uuid_list_t broken_link_ids;
	parseUUIDArray(update,"_broken_links_removed",broken_link_ids);
	for (uuid_list_t::const_iterator it = broken_link_ids.begin();
		 it != broken_link_ids.end(); ++it)
	{
		LLViewerInventoryItem *item = gInventory.getItem(*it);
		if(item)
		{
			mCatDescendentDeltas[item->getParentUUID()]--;
			mObjectsDeletedIds.insert(*it);
		}
		else
		{
			LL_WARNS("Inventory") << "broken link not found " << *it << LL_ENDL;
		}
	}

	// parse _created_items
	parseUUIDArray(update,"_created_items",mItemIds);

	// parse _created_categories
	parseUUIDArray(update,"_created_categories",mCategoryIds);

	// Parse updated category versions.
	const std::string& ucv = "_updated_category_versions";
	if (update.has(ucv))
	{
		for(LLSD::map_const_iterator it = update[ucv].beginMap(),
				end = update[ucv].endMap();
			it != end; ++it)
		{
			const LLUUID id((*it).first);
			S32 version = (*it).second.asInteger();
			mCatVersionsUpdated[id] = version;
		}
	}
}