// static
void LLKeyTool::onTransferInfo(LLMessageSystem *msg, void **user_data)
{
	S32 params_size = msg->getSize(_PREHASH_TransferInfo, _PREHASH_Params);
	if(params_size < 1) return;
	U8 tmp[1024];
	msg->getBinaryDataFast(_PREHASH_TransferInfo, _PREHASH_Params, tmp, params_size);
	LLDataPackerBinaryBuffer dpb(tmp, 1024);
	LLUUID asset_id;
	dpb.unpackUUID(asset_id, "AssetID");
	S32 asset_type;
	dpb.unpackS32(asset_type, "AssetType");
	S32 status;
	msg->getS32Fast(_PREHASH_TransferInfo, _PREHASH_Status, status, 0);

	BOOL wanted = callback(asset_id, KT_ASSET, (LLAssetType::EType)asset_type, BOOL(status == 0)); // LLTS_OK (e_status_codes)
	if(wanted)
	{
		LLKeyTool::sTransferRequests--;
		if(LLKeyTool::sTransferRequests <= 0)
		{
			LLKeyTool::sTransferRequests = 0;
			gMessageSystem->delHandlerFuncFast(_PREHASH_TransferInfo, &onTransferInfo);
		}
	}
}
Esempio n. 2
0
int main(int argc, char** argv)
{
	if (argc != 2)
	{
		printf("Usage: %s <new db name>\n", argv[0]);
		return -1;
	}

	ISC_STATUS_ARRAY sv;
	isc_db_handle db = 0;
	isc_tr_handle tr = 0;


	isc_create_database(sv, 0, argv[1], &db, 0, 0, 0);
	if (sv[0] == 1 && sv[1] > 0)
	{
		isc_print_status(sv);
		return -2;
	}
	isc_start_transaction(sv, &tr, 1, &db, 0, 0);
	if (sv[0] == 1 && sv[1] > 0)
	{
		isc_print_status(sv);
		return -3;
	}
	isc_commit_transaction(sv, &tr);
	if (sv[0] == 1 && sv[1] > 0)
	{
		isc_print_status(sv);
		return -3;
	}
	isc_detach_database(sv, &db);
	if (sv[0] == 1 && sv[1] > 0)
	{
		isc_print_status(sv);
		return -3;
	}

	Firebird::ClumpletWriter dpb(Firebird::ClumpletReader::Tagged, MAX_DPB_SIZE, isc_dpb_version1);
	dpb.insertByte(isc_dpb_set_db_readonly, TRUE);
	isc_attach_database(sv, 0, argv[1], &db, dpb.getBufferLength(),
		reinterpret_cast<const char*>(dpb.getBuffer()));
	if (sv[0] == 1 && sv[1] > 0)
	{
		isc_print_status(sv);
		return -4;
	}
	isc_detach_database(sv, &db);
	if (sv[0] == 1 && sv[1] > 0)
	{
		isc_print_status(sv);
		return -5;
	}

	return 0;
}
void LLKeyTool::tryAsset(LLAssetType::EType asset_type)
{
	if(asset_type == LLAssetType::AT_TEXTURE)
	{
		if(sImageRequests <= 0)
		{
			// Prepare to receive ImageData ot ImageNotInDatabase packets
			sImageRequests = 0;
			gMessageSystem->addHandlerFuncFast(_PREHASH_ImageData, &onImageData);
			gMessageSystem->addHandlerFuncFast(_PREHASH_ImageNotInDatabase, &onImageNotInDatabase);
		}
		
		gMessageSystem->newMessageFast(_PREHASH_RequestImage);
		gMessageSystem->nextBlockFast(_PREHASH_AgentData);
		gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
		gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
		gMessageSystem->nextBlockFast(_PREHASH_RequestImage);
		gMessageSystem->addUUIDFast(_PREHASH_Image, mKey);
		gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, 0);
		gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, 1015000);
		gMessageSystem->addU32Fast(_PREHASH_Packet, 0);
		gMessageSystem->addU8Fast(_PREHASH_Type, 0); // TYPE_NORMAL
		gMessageSystem->sendReliable(gAgent.getRegionHost());
		sImageRequests++;
		mImageRequests++;
	}
	else
	{
		if(sTransferRequests <= 0)
		{
			// Prepare to receive TransferInfo packets
			sTransferRequests = 0;
			gMessageSystem->addHandlerFuncFast(_PREHASH_TransferInfo, &onTransferInfo);
		}
		
		S32 type = (S32)(asset_type);
		LLUUID transfer_id;
		transfer_id.generate();
		U8 params[20];
		LLDataPackerBinaryBuffer dpb(params, 20);
		dpb.packUUID(mKey, "AssetID");
		dpb.packS32(type, "AssetType");

		gMessageSystem->newMessageFast(_PREHASH_TransferRequest);
		gMessageSystem->nextBlockFast(_PREHASH_TransferInfo);
		gMessageSystem->addUUIDFast(_PREHASH_TransferID, transfer_id);
		gMessageSystem->addS32Fast(_PREHASH_ChannelType, 2); // LLTCT_ASSET (e_transfer_channel_type)
		gMessageSystem->addS32Fast(_PREHASH_SourceType, 2); // LLTST_ASSET (e_transfer_source_type)
		gMessageSystem->addF32Fast(_PREHASH_Priority, 100.0f);
		gMessageSystem->addBinaryDataFast(_PREHASH_Params, params, 20);
		gMessageSystem->sendReliable(gAgent.getRegionHost());
		sTransferRequests++;
		mTransferRequests++;
	}
}
Esempio n. 4
0
// static
void LLKeyTool::onTransferInfo(LLMessageSystem *msg)
{
	S32 params_size = msg->getSize(_PREHASH_TransferInfo, _PREHASH_Params);
	if(params_size < 1) return;
	U8 tmp[1024];
	msg->getBinaryDataFast(_PREHASH_TransferInfo, _PREHASH_Params, tmp, params_size);
	LLDataPackerBinaryBuffer dpb(tmp, 1024);
	LLUUID asset_id;
	dpb.unpackUUID(asset_id, "AssetID");
	S32 asset_type;
	dpb.unpackS32(asset_type, "AssetType");
	S32 status;
	msg->getS32Fast(_PREHASH_TransferInfo, _PREHASH_Status, status, 0);

	callback(asset_id, KT_ASSET, (LLAssetType::EType)asset_type, BOOL(status == 0)); // LLTS_OK (e_status_codes)
}
 int minCut(string s) {
     const int n = s.size();
     
     //vector<int> dpc(n + 1);
     vector<int> dpc(n);
     vector<vector<bool> > dpb(n, vector<bool>(n, false));
     
     //dpc[n] = -1;  // can not be cut
     for (int i = n-1; i >= 0; --i)
     {
         dpc[i] = n - 1 - i;  // init, the worst case is cutting by each char
         for (int j = i; j < n; ++j)
         {
             dpb[i][j] = (s[i] == s[j]) && ((j-i < 2) || dpb[i+1][j-1]);
             if (dpb[i][j])  // can cut here
                 dpc[i] = (j == n-1) ? 0 : min(dpc[i], dpc[j+1] + 1);  // need not be cut
         }
     }
     return dpc[0];
 }
void ImportTracker::send_extras(LLSD& prim)
{	
	LLMessageSystem* msg = gMessageSystem;
	msg->newMessageFast(_PREHASH_ObjectExtraParams);
	msg->nextBlockFast(_PREHASH_AgentData);
	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
	
	LLPrimitive obj;
	
	if (prim.has("flexible"))
	{
		LLFlexibleObjectData flexi;
		flexi.fromLLSD(prim["flexible"]);
		U8 tmp[MAX_OBJECT_PARAMS_SIZE];
		LLDataPackerBinaryBuffer dpb(tmp, MAX_OBJECT_PARAMS_SIZE);
		
		if (flexi.pack(dpb))
		{
			U32 datasize = (U32)dpb.getCurrentSize();
			
			msg->nextBlockFast(_PREHASH_ObjectData);
			msg->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger());

			msg->addU16Fast(_PREHASH_ParamType, 0x10);
			msg->addBOOLFast(_PREHASH_ParamInUse, true);

			msg->addU32Fast(_PREHASH_ParamSize, datasize);
			msg->addBinaryDataFast(_PREHASH_ParamData, tmp, datasize);
		}
	}
	
	if (prim.has("light"))
	{
		LLLightParams light;
		light.fromLLSD(prim["light"]);
		
		U8 tmp[MAX_OBJECT_PARAMS_SIZE];
		LLDataPackerBinaryBuffer dpb(tmp, MAX_OBJECT_PARAMS_SIZE);
		
		if (light.pack(dpb))
		{
			U32 datasize = (U32)dpb.getCurrentSize();
			
			msg->nextBlockFast(_PREHASH_ObjectData);
			msg->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger());

			msg->addU16Fast(_PREHASH_ParamType, 0x20);
			msg->addBOOLFast(_PREHASH_ParamInUse, true);

			msg->addU32Fast(_PREHASH_ParamSize, datasize);
			msg->addBinaryDataFast(_PREHASH_ParamData, tmp, datasize);
		}
	}

	if (prim.has("sculpt"))
	{
		LLSculptParams sculpt;
		sculpt.fromLLSD(prim["sculpt"]);
		
		U8 tmp[MAX_OBJECT_PARAMS_SIZE];
		LLDataPackerBinaryBuffer dpb(tmp, MAX_OBJECT_PARAMS_SIZE);
		
		if (sculpt.pack(dpb))
		{
			U32 datasize = (U32)dpb.getCurrentSize();
			
			msg->nextBlockFast(_PREHASH_ObjectData);
			msg->addU32Fast(_PREHASH_ObjectLocalID, prim["LocalID"].asInteger());

			msg->addU16Fast(_PREHASH_ParamType, 0x30);
			msg->addBOOLFast(_PREHASH_ParamInUse, true);

			msg->addU32Fast(_PREHASH_ParamSize, datasize);
			msg->addBinaryDataFast(_PREHASH_ParamData, tmp, datasize);
		}
	}
	
	msg->sendReliable(gAgent.getRegion()->getHost());
}
Esempio n. 7
0
void TextureBlitTest::setupContent()
{
    static const Ogre::String ColorTextureName = "VTests_TextureBlit_color_texture";
    static const Ogre::String DepthTextureName = "VTests_TextureBlit_depth_texture";
    static const int TextureSize = 8;

    mViewport->setBackgroundColour(ColourValue(0.8,0.8,0.8));

    /// TEST COLOUR
    m_colorTexture = Ogre::TextureManager::getSingleton().createManual(
                         ColorTextureName,
                         Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                         Ogre::TEX_TYPE_2D,
                         TextureSize, TextureSize,
                         0,
                         Ogre::PF_BYTE_RGB,
                         Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);

    Ogre::PixelBox pb(ColorImage.width, ColorImage.height, 1, Ogre::PF_BYTE_RGB, (void *)ColorImage.pixel_data);
    Ogre::HardwarePixelBufferSharedPtr buffer = m_colorTexture->getBuffer();
    buffer->blitFromMemory(pb);

    // Get the material
    Ogre::MaterialPtr matColourPtr = Ogre::MaterialManager::getSingleton().getByName("Examples/OgreDance");

    ReplaceTexture(matColourPtr, ColorTextureName);

    // create a standard plane entity
    Entity* ent = mSceneMgr->createEntity("Plane_color", SceneManager::PT_PLANE);

    // attach it to a node, scale it, and position appropriately
    SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    node->setPosition(-30.0, 0.0, 0.0);
    node->setScale(0.25, 0.25, 0.25);
    node->attachObject(ent);

    ent->setMaterial(matColourPtr);  // give it the material we prepared

    /// TEST DEPTH
    m_depthTexture = Ogre::TextureManager::getSingleton().createManual(
                         DepthTextureName,
                         Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                         Ogre::TEX_TYPE_2D,
                         TextureSize, TextureSize,
                         0,
                         Ogre::PF_DEPTH,
                         Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);

    Ogre::PixelBox dpb(DepthImage.width, DepthImage.height, 1, Ogre::PF_DEPTH, (void *)DepthImage.pixel_data);
    Ogre::HardwarePixelBufferSharedPtr dbuffer = m_depthTexture->getBuffer();
    dbuffer->blitFromMemory(dpb);

    // Get the material
    Ogre::MaterialPtr matDepthPtr = Ogre::MaterialManager::getSingleton().getByName("Examples/OgreParade");

    ReplaceTexture(matDepthPtr, DepthTextureName);

    // create a standard plane entity
    Entity* depthEnt = mSceneMgr->createEntity("Plane_depth", SceneManager::PT_PLANE);

    // attach it to a node, scale it, and position appropriately
    SceneNode* depthNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
    depthNode->setPosition(30.0, 0.0, 0.0);
    depthNode->setScale(0.25, 0.25, 0.25);
    depthNode->attachObject(depthEnt);

    depthEnt->setMaterial(matDepthPtr);  // give it the material we prepared

    mCamera->setPosition(0,0,125);
    mCamera->setDirection(0,0,-1);
}
//static
void LLTransferManager::processTransferInfo(LLMessageSystem *msgp, void **)
{
	//llinfos << "LLTransferManager::processTransferInfo" << llendl;

	LLUUID transfer_id;
	LLTransferTargetType target_type;
	LLTransferChannelType channel_type;
	LLTSCode status;
	S32 size;

	msgp->getUUID("TransferInfo", "TransferID", transfer_id);
	msgp->getS32("TransferInfo", "TargetType", (S32 &)target_type);
	msgp->getS32("TransferInfo", "ChannelType", (S32 &)channel_type);
	msgp->getS32("TransferInfo", "Status", (S32 &)status);
	msgp->getS32("TransferInfo", "Size", size);

	//llinfos << transfer_id << ":" << target_type<< ":" << channel_type << llendl;
	LLTransferTargetChannel *ttcp = gTransferManager.getTargetChannel(msgp->getSender(), channel_type);
	if (!ttcp)
	{
		llwarns << "Target channel not found" << llendl;
		// Should send a message to abort the transfer.
		return;
	}

	LLTransferTarget *ttp = ttcp->findTransferTarget(transfer_id);
	if (!ttp)
	{
		llwarns << "TransferInfo for unknown transfer!  Not able to handle this yet!" << llendl;
		// This could happen if we're doing a push transfer, although to avoid confusion,
		// maybe it should be a different message.
		return;
	}

	if (status != LLTS_OK)
	{
		llwarns << transfer_id << ": Non-ok status, cleaning up" << llendl;
		ttp->completionCallback(status);
		// Clean up the transfer.
		ttcp->deleteTransfer(ttp);
		return;
	}

	// unpack the params
	S32 params_size = msgp->getSize("TransferInfo", "Params");
	if(params_size > MAX_PARAMS_SIZE)
	{
		llwarns << "LLTransferManager::processTransferInfo params too big."
			<< llendl;
		return;
	}
	else if(params_size > 0)
	{
		U8 tmp[MAX_PARAMS_SIZE];
		msgp->getBinaryData("TransferInfo", "Params", tmp, params_size);
		LLDataPackerBinaryBuffer dpb(tmp, MAX_PARAMS_SIZE);
		if (!ttp->unpackParams(dpb))
		{
			// This should only happen if the data is corrupt or
			// incorrectly packed.
			llwarns << "LLTransferManager::processTransferRequest: bad params."
				<< llendl;
			ttp->abortTransfer();
			ttcp->deleteTransfer(ttp);
			return;
		}
	}

	llinfos << "Receiving " << transfer_id << ", size " << size << " bytes" << llendl;
	ttp->setSize(size);
	ttp->setGotInfo(TRUE);

	// OK, at this point we to handle any delayed transfer packets (which could happen
	// if this packet was lost)

	// This is a lame cut and paste of code down below.  If we change the logic down there,
	// we HAVE to change the logic up here.

	while (1)
	{
		S32 packet_id = 0;
		U8 tmp_data[MAX_PACKET_DATA_SIZE];
		// See if we've got any delayed packets
		packet_id = ttp->getNextPacketID();
		if (ttp->mDelayedPacketMap.find(packet_id) != ttp->mDelayedPacketMap.end())
		{
			// Perhaps this stuff should be inside a method in LLTransferPacket?
			// I'm too lazy to do it now, though.
// 			llinfos << "Playing back delayed packet " << packet_id << llendl;
			LLTransferPacket *packetp = ttp->mDelayedPacketMap[packet_id];

			// This is somewhat inefficient, but avoids us having to duplicate
			// code between the off-the-wire and delayed paths.
			packet_id = packetp->mPacketID;
			size = packetp->mSize;
			if (size)
			{
				if ((packetp->mDatap != NULL) && (size<(S32)sizeof(tmp_data)))
				{
					memcpy(tmp_data, packetp->mDatap, size);	/*Flawfinder: ignore*/
				}
			}
			status = packetp->mStatus;
			ttp->mDelayedPacketMap.erase(packet_id);
			delete packetp;
		}
		else
		{
			// No matching delayed packet, we're done.
			break;
		}

		LLTSCode ret_code = ttp->dataCallback(packet_id, tmp_data, size);
		if (ret_code == LLTS_OK)
		{
			ttp->setLastPacketID(packet_id);
		}

		if (status != LLTS_OK)
		{
			if (status != LLTS_DONE)
			{
				llwarns << "LLTransferManager::processTransferInfo Error in playback!" << llendl;
			}
			else
			{
				llinfos << "LLTransferManager::processTransferInfo replay FINISHED for " << transfer_id << llendl;
			}
			// This transfer is done, either via error or not.
			ttp->completionCallback(status);
			ttcp->deleteTransfer(ttp);
			return;
		}
	}
}
//static
void LLTransferManager::processTransferRequest(LLMessageSystem *msgp, void **)
{
	//llinfos << "LLTransferManager::processTransferRequest" << llendl;

	LLUUID transfer_id;
	LLTransferSourceType source_type;
	LLTransferChannelType channel_type;
	F32 priority;

	msgp->getUUID("TransferInfo", "TransferID", transfer_id);
	msgp->getS32("TransferInfo", "SourceType", (S32 &)source_type);
	msgp->getS32("TransferInfo", "ChannelType", (S32 &)channel_type);
	msgp->getF32("TransferInfo", "Priority", priority);

	LLTransferSourceChannel *tscp = gTransferManager.getSourceChannel(msgp->getSender(), channel_type);

	if (!tscp)
	{
		llwarns << "Source channel not found" << llendl;
		return;
	}

	if (tscp->findTransferSource(transfer_id))
	{
		llwarns << "Duplicate request for transfer " << transfer_id << ", aborting!" << llendl;
		return;
	}

	S32 size = msgp->getSize("TransferInfo", "Params");
	if(size > MAX_PARAMS_SIZE)
	{
		llwarns << "LLTransferManager::processTransferRequest params too big."
			<< llendl;
		return;
	}

	//llinfos << transfer_id << ":" << source_type << ":" << channel_type << ":" << priority << llendl;
	LLTransferSource* tsp = LLTransferSource::createSource(
		source_type,
		transfer_id,
		priority);
	if(!tsp)
	{
		llwarns << "LLTransferManager::processTransferRequest couldn't create"
			<< " transfer source!" << llendl;
		return;
	}
	U8 tmp[MAX_PARAMS_SIZE];
	msgp->getBinaryData("TransferInfo", "Params", tmp, size);

	LLDataPackerBinaryBuffer dpb(tmp, MAX_PARAMS_SIZE);
	BOOL unpack_ok = tsp->unpackParams(dpb);
	if (!unpack_ok)
	{
		// This should only happen if the data is corrupt or
		// incorrectly packed.
		// *NOTE: We may want to call abortTransfer().
		llwarns << "LLTransferManager::processTransferRequest: bad parameters."
			<< llendl;
		delete tsp;
		return;
	}

	tscp->addTransferSource(tsp);
	tsp->initTransfer();
}