コード例 #1
0
ファイル: llinventory.cpp プロジェクト: AlexRa/Kirstens-clone
LLPointer<LLInventoryItem> ll_create_item_from_sd(const LLSD& sd_item)
{
	LLPointer<LLInventoryItem> rv = new LLInventoryItem;
	rv->setUUID(sd_item[INV_ITEM_ID_LABEL].asUUID());
	rv->setParent(sd_item[INV_PARENT_ID_LABEL].asUUID());
	rv->rename(sd_item[INV_NAME_LABEL].asString());
	rv->setType(
		LLAssetType::lookup(sd_item[INV_ASSET_TYPE_LABEL].asString()));
	if (sd_item.has("shadow_id"))
	{
		LLUUID asset_id = sd_item["shadow_id"];
		LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
		cipher.decrypt(asset_id.mData, UUID_BYTES);
		rv->setAssetUUID(asset_id);
	}
	if (sd_item.has(INV_ASSET_ID_LABEL))
	{
		rv->setAssetUUID(sd_item[INV_ASSET_ID_LABEL].asUUID());
	}
	rv->setDescription(sd_item[INV_DESC_LABEL].asString());
	rv->setSaleInfo(ll_sale_info_from_sd(sd_item[INV_SALE_INFO_LABEL]));
	rv->setPermissions(ll_permissions_from_sd(sd_item[INV_PERMISSIONS_LABEL]));
	rv->setInventoryType(
		LLInventoryType::lookup(
			sd_item[INV_INVENTORY_TYPE_LABEL].asString()));
	rv->setFlags((U32)(sd_item[INV_FLAGS_LABEL].asInteger()));
	rv->setCreationDate(sd_item[INV_CREATION_DATE_LABEL].asInteger());
	return rv;
}
コード例 #2
0
// Checked: 2010-04-18 (RLVa-1.1.3a) | Modified: RLVa-1.2.0e
void RlvGiveToRLVAgentOffer::doneIdle()
{
	const LLViewerInventoryCategory* pRlvRoot = RlvInventory::instance().getSharedRoot();
	const LLViewerInventoryCategory* pFolder = (mComplete.size()) ? gInventory.getCategory(mComplete[0]) : NULL;
	if ( (pRlvRoot) && (pFolder) )
	{
		std::string strName = pFolder->getName();
		if (strName.find(RLV_PUTINV_PREFIX) == 0)
		{
			LLInventoryModel::update_list_t update;
			LLInventoryModel::LLCategoryUpdate updOldParent(pFolder->getParentUUID(), -1);
			update.push_back(updOldParent);
			LLInventoryModel::LLCategoryUpdate updNewParent(pRlvRoot->getUUID(), 1);
			update.push_back(updNewParent);
			gInventory.accountForUpdate(update);

			LLPointer<LLViewerInventoryCategory> pNewFolder = new LLViewerInventoryCategory(pFolder);
			pNewFolder->setParent(pRlvRoot->getUUID());
			pNewFolder->updateParentOnServer(FALSE);
			pNewFolder->rename(strName.erase(0, strName.find(RLV_FOLDER_PREFIX_PUTINV)));
			pNewFolder->updateServer(FALSE);
			gInventory.updateCategory(pNewFolder);

			gInventory.notifyObservers();
		}
	}
	delete this;
}
コード例 #3
0
ファイル: llinventory.cpp プロジェクト: AlexRa/Kirstens-clone
LLPointer<LLInventoryCategory> ll_create_category_from_sd(const LLSD& sd_cat)
{
	LLPointer<LLInventoryCategory> rv = new LLInventoryCategory;
	rv->setUUID(sd_cat[INV_FOLDER_ID_LABEL].asUUID());
	rv->setParent(sd_cat[INV_PARENT_ID_LABEL].asUUID());
	rv->rename(sd_cat[INV_NAME_LABEL].asString());
	rv->setType(
		LLAssetType::lookup(sd_cat[INV_ASSET_TYPE_LABEL].asString()));
	rv->setPreferredType(
		LLAssetType::lookup(
			sd_cat[INV_PREFERRED_TYPE_LABEL].asString()));
	return rv;
}
コード例 #4
0
ファイル: inventory.cpp プロジェクト: Boy/netbook
	void inventory_object::test<6>()
	{
		LLPointer<LLInventoryItem> src = create_random_inventory_item();
		
		LLUUID new_item_id, new_parent_id;
		new_item_id.generate();
		src->setUUID(new_item_id);
		
		new_parent_id.generate();
		src->setParent(new_parent_id);
		
		LLString new_name = "LindenLab";
		src->rename(new_name);
		
		src->setType(LLAssetType::AT_SOUND);

		LLUUID new_asset_id;
		new_asset_id.generate();
		
		src->setAssetUUID(new_asset_id);
		LLString new_desc = "SecondLife Testing";
		src->setDescription(new_desc);
		
		S32 new_price = rand();
		LLSaleInfo new_sale_info(LLSaleInfo::FS_COPY, new_price);
		src->setSaleInfo(new_sale_info);

		U32 new_flags = rand();
		S32 new_creation = time(NULL);

		LLPermissions new_perm;

		LLUUID new_creator_id;
		new_creator_id.generate();
	
		LLUUID new_owner_id;
		new_owner_id.generate();

		LLUUID last_owner_id;
		last_owner_id.generate();

		LLUUID new_group_id;
		new_group_id.generate();
		new_perm.init(new_creator_id, new_owner_id, last_owner_id, new_group_id);
		new_perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY);
		src->setPermissions(new_perm);

		src->setInventoryType(LLInventoryType::IT_SOUND);
		src->setFlags(new_flags);
		src->setCreationDate(new_creation);

		LLSD sd = ll_create_sd_from_inventory_item(src);
		LLPointer<LLInventoryItem> dst = ll_create_item_from_sd(sd);


		LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
		src1->copy(src);
		src1->clone(src);
		
		ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src1->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src1->getParentUUID());
		ensure_equals("3.name::getName() failed", dst->getName(), src1->getName());
		ensure_equals("4.type::getType() failed", dst->getType(), src1->getType());
		
		ensure_equals("5.permissions::getPermissions() failed", dst->getPermissions(), src1->getPermissions());
		ensure_equals("6.description::getDescription() failed", dst->getDescription(), src1->getDescription());
		ensure_equals("7.sale type::getSaleType() failed type", dst->getSaleInfo().getSaleType(), src1->getSaleInfo().getSaleType());
		ensure_equals("8.sale price::getSalePrice() failed price", dst->getSaleInfo().getSalePrice(), src1->getSaleInfo().getSalePrice());
		ensure_equals("9.asset id::getAssetUUID() failed id", dst->getAssetUUID(), src1->getAssetUUID());
		ensure_equals("10.inventory type::getInventoryType() failed type", dst->getInventoryType(), src1->getInventoryType());
		ensure_equals("11.flags::getFlags() failed", dst->getFlags(), src1->getFlags());
		ensure_equals("12.creation::getCreationDate() failed", dst->getCreationDate(), src1->getCreationDate());

		LLPointer<LLInventoryItem> src2;
		src1->clone(src2);
		
		ensure_not_equals("13.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
		ensure_equals("14.parent::getParentUUID() failed", src2->getParentUUID(), src1->getParentUUID());
		ensure_equals("15.name::getName() failed", src2->getName(), src1->getName());
		ensure_equals("16.type::getType() failed", src2->getType(), src1->getType());
		
		ensure_equals("17.permissions::getPermissions() failed", src2->getPermissions(), src1->getPermissions());
		ensure_equals("18.description::getDescription() failed", src2->getDescription(), src1->getDescription());
		ensure_equals("19.sale type::getSaleType() failed type", src2->getSaleInfo().getSaleType(), src1->getSaleInfo().getSaleType());
		ensure_equals("20.sale price::getSalePrice() failed price", src2->getSaleInfo().getSalePrice(), src1->getSaleInfo().getSalePrice());
		ensure_equals("21.asset id::getAssetUUID() failed id", src2->getAssetUUID(), src1->getAssetUUID());
		ensure_equals("22.inventory type::getInventoryType() failed type", src2->getInventoryType(), src1->getInventoryType());
		ensure_equals("23.flags::getFlags() failed", src2->getFlags(), src1->getFlags());
		ensure_equals("24.creation::getCreationDate() failed", src2->getCreationDate(), src1->getCreationDate());


	}
コード例 #5
0
ファイル: inventorymisc_test.cpp プロジェクト: HizWylder/GIS
	void inventory_object::test<6>()
	{
		LLPointer<LLInventoryItem> src = create_random_inventory_item();
		
		LLUUID new_item_id, new_parent_id;
		new_item_id.generate();
		src->setUUID(new_item_id);
		
		new_parent_id.generate();
		src->setParent(new_parent_id);
		
		std::string new_name = "LindenLab";
		src->rename(new_name);
		
		src->setType(LLAssetType::AT_SOUND);

		LLUUID new_asset_id;
		new_asset_id.generate();
		
		src->setAssetUUID(new_asset_id);
		std::string new_desc = "GIS Testing";
		src->setDescription(new_desc);
		
		S32 new_price = rand();
		LLSaleInfo new_sale_info(LLSaleInfo::FS_COPY, new_price);
		src->setSaleInfo(new_sale_info);

		U32 new_flags = rand();
		S32 new_creation = time(NULL);

		LLPermissions new_perm;

		LLUUID new_creator_id;
		new_creator_id.generate();
	
		LLUUID new_owner_id;
		new_owner_id.generate();

		LLUUID last_owner_id;
		last_owner_id.generate();

		LLUUID new_group_id;
		new_group_id.generate();
		new_perm.init(new_creator_id, new_owner_id, last_owner_id, new_group_id);
		new_perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY);
		src->setPermissions(new_perm);

		src->setInventoryType(LLInventoryType::IT_SOUND);
		src->setFlags(new_flags);
		src->setCreationDate(new_creation);

		// test a save/load cycle to LLSD and back again
		LLSD sd = ll_create_sd_from_inventory_item(src);
		LLPointer<LLInventoryItem> dst = new LLInventoryItem;
		bool successful_parse = dst->fromLLSD(sd);
		ensure_equals("0.LLInventoryItem::fromLLSD()", successful_parse, true);

		LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
		src1->copyItem(src);
		
		ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src1->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src1->getParentUUID());
		ensure_equals("3.name::getName() failed", dst->getName(), src1->getName());
		ensure_equals("4.type::getType() failed", dst->getType(), src1->getType());
		
		ensure_equals("5.permissions::getPermissions() failed", dst->getPermissions(), src1->getPermissions());
		ensure_equals("6.description::getDescription() failed", dst->getDescription(), src1->getDescription());
		ensure_equals("7.sale type::getSaleType() failed type", dst->getSaleInfo().getSaleType(), src1->getSaleInfo().getSaleType());
		ensure_equals("8.sale price::getSalePrice() failed price", dst->getSaleInfo().getSalePrice(), src1->getSaleInfo().getSalePrice());
		ensure_equals("9.asset id::getAssetUUID() failed id", dst->getAssetUUID(), src1->getAssetUUID());
		ensure_equals("10.inventory type::getInventoryType() failed type", dst->getInventoryType(), src1->getInventoryType());
		ensure_equals("11.flags::getFlags() failed", dst->getFlags(), src1->getFlags());
		ensure_equals("12.creation::getCreationDate() failed", dst->getCreationDate(), src1->getCreationDate());

		// quick test to make sure generateUUID() really works
		src1->generateUUID();	
		ensure_not_equals("13.item id::generateUUID() failed", src->getUUID(), src1->getUUID());
	}
// If we get back a normal response, handle it here.
void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
{
	LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
	if (content.has("folders"))	
	{

		for(LLSD::array_const_iterator folder_it = content["folders"].beginArray();
			folder_it != content["folders"].endArray();
			++folder_it)
		{	
			LLSD folder_sd = *folder_it;
			

			//LLUUID agent_id = folder_sd["agent_id"];

			//if(agent_id != gAgent.getID())	//This should never happen.
			//{
			//	llwarns << "Got a UpdateInventoryItem for the wrong agent."
			//			<< llendl;
			//	break;
			//}

			LLUUID parent_id = folder_sd["folder_id"];
			LLUUID owner_id = folder_sd["owner_id"];
			S32    version  = (S32)folder_sd["version"].asInteger();
			S32    descendents = (S32)folder_sd["descendents"].asInteger();
			LLPointer<LLViewerInventoryCategory> tcategory = new LLViewerInventoryCategory(owner_id);

            if (parent_id.isNull())
            {
			    LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
			    for(LLSD::array_const_iterator item_it = folder_sd["items"].beginArray();
				    item_it != folder_sd["items"].endArray();
				    ++item_it)
			    {	
                    const LLUUID lost_uuid = gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
                    if (lost_uuid.notNull())
                    {
				        LLSD item = *item_it;
				        titem->unpackMessage(item);
				
                        LLInventoryModel::update_list_t update;
                        LLInventoryModel::LLCategoryUpdate new_folder(lost_uuid, 1);
                        update.push_back(new_folder);
                        gInventory.accountForUpdate(update);

                        titem->setParent(lost_uuid);
                        titem->updateParentOnServer(FALSE);
                        gInventory.updateItem(titem);
                        gInventory.notifyObservers("fetchDescendents");
                        
                    }
                }
            }

	        LLViewerInventoryCategory* pcat = gInventory.getCategory(parent_id);
			if (!pcat)
			{
				continue;
			}

			for(LLSD::array_const_iterator category_it = folder_sd["categories"].beginArray();
				category_it != folder_sd["categories"].endArray();
				++category_it)
			{	
				LLSD category = *category_it;
				tcategory->fromLLSD(category); 
				
				const BOOL recursive = getIsRecursive(tcategory->getUUID());
				
				if (recursive)
				{
					fetcher->mFetchQueue.push_back(LLInventoryModelBackgroundFetch::FetchQueueInfo(tcategory->getUUID(), recursive));
				}
				else if ( !gInventory.isCategoryComplete(tcategory->getUUID()) )
				{
					gInventory.updateCategory(tcategory);
				}

			}
			LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
			for(LLSD::array_const_iterator item_it = folder_sd["items"].beginArray();
				item_it != folder_sd["items"].endArray();
				++item_it)
			{	
				LLSD item = *item_it;
				titem->unpackMessage(item);
				
				gInventory.updateItem(titem);
			}

			// Set version and descendentcount according to message.
			LLViewerInventoryCategory* cat = gInventory.getCategory(parent_id);
			if(cat)
			{
				cat->setVersion(version);
				cat->setDescendentCount(descendents);
				cat->determineFolderType();
			}

		}
	}
		
	if (content.has("bad_folders"))
	{
		for(LLSD::array_const_iterator folder_it = content["bad_folders"].beginArray();
			folder_it != content["bad_folders"].endArray();
			++folder_it)
		{	
			LLSD folder_sd = *folder_it;
			
			// These folders failed on the dataserver.  We probably don't want to retry them.
			llinfos << "Folder " << folder_sd["folder_id"].asString() 
					<< "Error: " << folder_sd["error"].asString() << llendl;
		}
	}

	fetcher->incrBulkFetch(-1);
	
	if (fetcher->isBulkFetchProcessingComplete())
	{
		llinfos << "Inventory fetch completed" << llendl;
		fetcher->setAllFoldersFetched();
	}
	
	gInventory.notifyObservers("fetchDescendents");
}