void TBuildPublishAndRootDeviceInfo::DoL ( )
	{
	if ( iContext.Node ( ).PublishInfo ( ) )
		{
		return;
		}
	
	TUpnpMessage::TRegisterRootDevice& msg = message_cast< TUpnpMessage::TRegisterRootDevice > ( iContext.iMessage );
	CUPnPDevice* device = static_cast <CUPnPDevice*> ( msg.iPtr );
	
	CStringPoolManager& stringPoolMgr = iContext.Node ().ConnectionProvider ().StringPoolManager ();
	RStringPool& sp = stringPoolMgr.StringPool ( );
	const TStringTable& upnpTable = stringPoolMgr.GetUPnPTable();
	CUPnPPublishInfoElement* publishInfo = CUPnPPublishInfoElement::NewL ( );
    CleanupStack::PushL ( publishInfo );
    
    publishInfo->SetKeyL( iContext.Node ().ConnectionProvider ().RootDeviceLocation () );
    publishInfo->SetSearchTargetL( KRootDevice ( ) ); //upnp:rootdevice
	publishInfo->SetCacheControlL( KCacheControl );
	
	const TDesC8& udnPtr = device->Property( sp.String ( UPNPDESCRIPTIONXMLTAGS::EUdn, upnpTable ) );
	const TDesC8& deviceTypePtr = device->Property( sp.String(UPNPDESCRIPTIONXMLTAGS::EDeviceType,upnpTable ) );
	
	publishInfo->SetUuidL ( udnPtr );
	
	// Set Usn to udn + devicetype
	TInt len = udnPtr.Length ( ) + KSeperator.iTypeLength + deviceTypePtr.Length ( );	
	RBuf8 tempBuf;
	tempBuf.CreateMaxL ( len );
	CleanupClosePushL ( tempBuf );
	
	tempBuf.Copy ( udnPtr );
	tempBuf.Append ( KSeperator ( ) );
	tempBuf.Append ( deviceTypePtr );
	publishInfo->SetUsnL( tempBuf );
		
	iContext.Node ( ).SetPublishInfoL ( publishInfo );
	// store deviceType in SCPr node for reference in M-Search Response Activity
	iContext.Node ( ).SetRootDeviceUrnL ( deviceTypePtr );
	
	CleanupStack::PopAndDestroy ( &tempBuf );
	CleanupStack::Pop ( publishInfo );	
	}
Exemplo n.º 2
0
TInt CryptoSpiUtil::RetrieveCharacteristicsL(TInt32 aInterface, RDesReadStream& aStream, RBuf8& aBuf, TInt& aCount)
	{
	// first we are only trying to retrieve the length of the buffer
	TBuf8<sizeof(TInt32)> buf;
	TInt testResult = RProperty::Get(KCryptoSpiPropertyCat, aInterface, buf);
	if (testResult==KErrNotFound)
		{
		//run the exe to Publish the properties
		RunCryptoSpiPropertySetupExe();
		// testresult would be checked outside the loop
		testResult = RProperty::Get(KCryptoSpiPropertyCat, aInterface, buf);
		}
	
	// overflow will occur as we are only retrieving the length first.
	// any other error we should leave
	if(testResult != KErrOverflow)
		{
		User::LeaveIfError(testResult);
		}
	
	//read the length
	RDesReadStream rStream(buf);
	TInt32 len=rStream.ReadInt32L();
	
	//If the property is empty
	if (len<=4)
		{
		return len;
		}

	//Allocate memory 
	aBuf.CreateMaxL(len);
	User::LeaveIfError(RProperty::Get(KCryptoSpiPropertyCat, aInterface, aBuf));
	
	//Read the length
	aStream.Open(aBuf);
	len=aStream.ReadInt32L();
	
	//Read the count of the characteristics
	aCount=aStream.ReadInt16L();
	return len;	
	}