예제 #1
0
// ---------------------------------------------------------------------------
// XIMPEventCodec::PackL()
// ---------------------------------------------------------------------------
//
EXPORT_C HBufC8* XIMPEventCodec::PackL( CXIMPApiEventBase& aEventObj,
                                        TInt32& aTypeOfEvent )
    {
    CBufFlat* buffer = CBufFlat::NewL( 10 ); // initial granularity to 10
    CleanupStack::PushL( buffer );

    RBufWriteStream ws;
    CleanupClosePushL( ws );
    ws.Open( *buffer ); // CSI: 65 #

    //Ask real event type through the event base interface
    TInt32 eventIfId = aEventObj.Base().GetInterfaceId();

    //And write both event type and data
    ws.WriteInt32L( eventIfId );
    aEventObj.ExternalizeL( ws );
    ws.CommitL();
    CleanupStack::PopAndDestroy();  //ws

    HBufC8* heapBuf = buffer->Ptr( 0 ).AllocL();

    CleanupStack::PopAndDestroy( buffer );


    aTypeOfEvent = eventIfId;
    return heapBuf;
    }
예제 #2
0
// ---------------------------------------------------------
// RNSmlPrivateAPI::GetDMAuthInfoL( CNSmlDMAuthInfo& aAuthInfo )
// Retrieves DM auhentication info from settings
// ---------------------------------------------------------
//	
EXPORT_C void RNSmlPrivateAPI::GetDMAuthInfoL( CNSmlDMAuthInfo& aAuthInfo )
	{
	TPckgBuf<TInt> buf;
	TIpcArgs args(aAuthInfo.iProfileId, &buf);
	
	User::LeaveIfError( SendReceive( ECmdInitDMAuthInfo, args) );
	
	CBufFlat* buffer = CBufFlat::NewL( KDefaultNSmlBufferGranularity );
	CleanupStack::PushL( buffer );
	buffer->ResizeL( buf() );
	
	TPtr8 pBuffer(0, NULL, 0);
	pBuffer.Set( buffer->Ptr(0) );
	                
	TIpcArgs argsGet( &pBuffer );
	User::LeaveIfError( SendReceive( ECmdGetDMAuthInfo, argsGet) );
	
	RDesReadStream stream;
	stream.Open( pBuffer );
	CleanupClosePushL( stream );
	
	aAuthInfo.InternalizeL( stream );
	
	CleanupStack::PopAndDestroy(2); // stream, buffer	
	}
/**
Helper function to compare the data of the command.
*/
void CCmdTestWaitForApparcInit::CompareCommandsDataL(CCmdWaitForApparcInit* aTestCmd, TCmdErrorSeverity aSeverity, const TUint16 aPriority)
	{
	// create output buffer and stream
 	CBufFlat* outputBuffer = CBufFlat::NewL(KTempDataLength);
	CleanupStack::PushL(outputBuffer);
	RBufWriteStream writeStream(*outputBuffer);
	CleanupClosePushL(writeStream);

	// externalise the data
	aTestCmd->ExternalizeL(writeStream);
	RDesReadStream readStream(outputBuffer->Ptr(0));
	CleanupClosePushL(readStream);
	TCmdErrorSeverity severity = static_cast<TCmdErrorSeverity>(readStream.ReadInt16L());
	TEST(aSeverity == severity);
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	TUint16 priority = readStream.ReadUint16L();
	TEST(aPriority == priority);
#else
	TEST(aPriority == KDefaultPriority);
#endif

	CleanupStack::PopAndDestroy(&readStream);
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(outputBuffer);
	}
예제 #4
0
CIntent* CIntent::CopyL() const
	{
	// Write the object out to a buffer, send to client
	CBufFlat* buf = CBufFlat::NewL(50);
	CleanupStack::PushL(buf);
	
	// create write stream
	RBufWriteStream writeStream(*buf);
	CleanupClosePushL(writeStream);

	// write *this to the stream
	ExternalizeL(writeStream);
	CleanupStack::PopAndDestroy(&writeStream);
	
	TPtr8 source = buf->Ptr(0);
	RDesReadStream readStream(source);
	CleanupClosePushL(readStream);
	
	// Create copy 
	CIntent* copy = CIntent::NewL(readStream);
	
	CleanupStack::PopAndDestroy(2, buf); //readStream, buf
	
	return copy;
	}
void CRtaContentHandler::SearchL(const RMessage2& aMessage)
	{
	RStreamablePtrArray<CEmbeddedObject> array;
	CleanupClosePushL(array);
	
	HBufC8* mimeType = ReadDesC8LC(aMessage, 1);
	TBool recursive;
	TPckg<TBool> recursivePckg(recursive);
	
	aMessage.Read(2, recursivePckg);
	
	User::LeaveIfError(iArchive->DrmFilesL().CurrentContainer().Search(array, *mimeType, recursive));

	// Write the object out to a buffer, send to client
	CBufFlat* buf = CBufFlat::NewL(50);
	CleanupStack::PushL(buf);
	// create write stream
	RBufWriteStream writeStream(*buf);
	// write the directory to the stream
	array.ExternalizeL(writeStream);
	TPtr8 bufPtr = buf->Ptr(0);
	WriteL(aMessage, 0, bufPtr);
	
	CleanupStack::PopAndDestroy(3, &array); // buf, mimeType, array
	}
// ---------------------------------------------------------------------------
// Data request from CatalogsPCConnectivityPlugin
// First ask the size from server, then give correct size CBufFlat
// ---------------------------------------------------------------------------
//
void RCatalogsPCConnectivityClient::GetDataL( 
    TDataType& aMimeType, CBufFlat& aData )
    {
    TPckgBuf<TInt> pckgSize;
    TPckgBuf<TDataType> pckgMIME;
    
    User::LeaveIfError( SendReceive( 
            ECatalogsPCConnectivityGetSize, 
            TIpcArgs( &pckgMIME, &pckgSize ) ) );
    
    TInt size = pckgSize();
    aMimeType = pckgMIME();
    
    RBuf8 desData;
    desData.CreateL( size );
    desData.CleanupClosePushL();
    
    User::LeaveIfError( SendReceive( 
            ECatalogsPCConnectivityGetData, 
            TIpcArgs( &desData ) ) );
    
    aData.Reset();
    aData.ExpandL( 0, size );
    aData.Write( 0, desData, size );        
            
    CleanupStack::Pop(); //desData
    desData.Close();
    }
// ============================================================================
// RCwrtRegistryClientSession::getAttributeL()
// Returns the attribute value for the widget
//
// ============================================================================
EXPORT_C QVariant RWACRegistryClientSession::getAttributeL( const QString& appId,
                                                           const QString& attribute,
                                                           const QVariant& defaultValue )
    {
    const TInt maxSize = 5120;

    CBufFlat* sendBuf = CBufFlat::NewL( maxSize );
    CleanupStack::PushL( sendBuf );
    RBufWriteStream stream( *sendBuf );
    CleanupClosePushL( stream );
    SerializeStringL( stream, appId );
    SerializeStringL( stream, attribute );
    SerializeStringL( stream, defaultValue.toString() );
    CleanupStack::PopAndDestroy( &stream );

    CBufFlat* recvBuf = CBufFlat::NewL( maxSize );
    CleanupStack::PushL( recvBuf );
    recvBuf->ExpandL( 0, maxSize );

    TPtr8 sendArg( sendBuf->Ptr(0) );
    TPtr8 recvArg( recvBuf->Ptr(0) );

    User::LeaveIfError(
            SendReceive( EOpCodeGetWebAttribute, TIpcArgs( &sendArg, &recvArg ) )
            );

    // deserialize
    RDesReadStream rstream( recvArg );
    CleanupClosePushL( rstream );
    QString attrValue = DeserializeStringL( rstream );
    CleanupStack::PopAndDestroy( 3, sendBuf ); // rstream, recvBuf, sendBuf

    return ( QVariant( attrValue ) );
    }
void CRtaContentHandler::GetWMDRMStringAttributeSetL(const RMessage2& aMessage)     
    {     
    RStringAttributeSet attributeSet;     
    CleanupClosePushL(attributeSet);     
         
    HBufC8* value = ReadDes8LC(aMessage, 1);     
    TPtr8 valuePtr = value->Des();     
    RDesReadStream readStream(valuePtr);     
    CleanupClosePushL(readStream);     
         
    attributeSet.InternalizeL(readStream);     
    CleanupStack::PopAndDestroy(2, value);     
         
    iWmdrmContentObject->GetStringAttributeSetL(attributeSet);     
      
    // Write the object out to a buffer, send to client     
    CBufFlat* buf = CBufFlat::NewL(50);     
    CleanupStack::PushL(buf);     
    // create write stream     
    RBufWriteStream writeStream(*buf);     
    CleanupClosePushL(writeStream);     
         
    // write the directory to the stream     
    attributeSet.ExternalizeL(writeStream);     
    CleanupStack::PopAndDestroy(&writeStream);     
         
    TPtr8 bufPtr = buf->Ptr(0);     
    WriteL(aMessage, 1, bufPtr);     
             
    CleanupStack::PopAndDestroy(2, &attributeSet); // buf, attributeSet     
    }     
// ---------------------------------------------------------
// CDownloadDataClient::MarshalDataL()
// ---------------------------------------------------------
//
HBufC8* CDownloadDataClient::MarshalDataL() const
    {
    TInt bufLen = Bytes();      // Size of class including iMediaArray elements.
                                //  Note that this includes actual bytes occupied by
                                //  contents of descriptors and pointers.
                                
    bufLen += sizeof(TInt);  // We include the count of elements in iMediaArray
                                //  while externalizing.
                                
    bufLen += sizeof(TInt) * iMediaArray.Count();
                                // iMediaArray has an array iTypes. We are including
                                //  count of elements in iTypes array while externalizing
                                //  each element of iMediaArray.
    
    // Dynamic data buffer
    CBufFlat* buf = CBufFlat::NewL(bufLen);
    CleanupStack::PushL(buf);
    // Stream over the buffer
    RBufWriteStream stream(*buf);
    CleanupClosePushL(stream);
    
    ExternalizeL(stream);
    CleanupStack::PopAndDestroy(); //stream
    
    // Create a heap descriptor from the buffer
    HBufC8* des = HBufC8::NewL(buf->Size());
    TPtr8 ptr(des->Des());
    buf->Read(0, ptr, buf->Size());
    CleanupStack::PopAndDestroy(); //buf
    
    return des;
    }
void CSmfCredMgrClientSymbian::changePluginIDListL(const QString NewPluginID,
		const bool Flag, const QString OldPluginID)
	{
	CSmfPluginIDUpdate* changePluginListParams =
			new (ELeave) CSmfPluginIDUpdate;
	CleanupStack::PushL(changePluginListParams);

	//set the input params
	changePluginListParams->iNewPluginID = qt_QString2HBufC(NewPluginID);
	changePluginListParams->iOldPluginID = qt_QString2HBufC(OldPluginID);
	changePluginListParams->pluginIDEnabled = Flag;

	//create buffer to serialize data
	CBufFlat* buf = CBufFlat::NewL(KMaxBufSize);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf);
	CleanupClosePushL(stream);

	changePluginListParams->ExternalizeL(stream);
	stream.CommitL();

	TPtr8 bufPtr = buf->Ptr(0);

	TIpcArgs args;
	args.Set(0, &bufPtr);

	iSession.RequestService(EUpdatePluginIDList, args);

	CleanupStack::PopAndDestroy(&stream);
	CleanupStack::PopAndDestroy(buf);
	CleanupStack::PopAndDestroy(changePluginListParams);

	}
// -----------------------------------------------------------------------------
// CTestSDKNotes::TestNPIWriteInternalStateL
// -----------------------------------------------------------------------------
TInt CTestSDKNotes::TestNPIWriteInternalStateL( CStifItemParser& /*aItem*/ )
    {
    CEikProgressInfo::SInfo sInfo;
    sInfo.iTextType = EEikProgressTextPercentage;
    CTestSDKNotesProgressInfo* progress = CTestSDKNotesProgressInfo::NewLC( sInfo );
    STIF_ASSERT_NOT_NULL( progress );
    
    const TInt size = 2000;
    CBufFlat* buf = CBufFlat::NewL( size );
    STIF_ASSERT_EQUALS( 0, buf->Ptr( 0 ).Length() );
    CleanupStack::PushL( buf );
    
    RBufWriteStream stream;
    CleanupClosePushL( stream );
    stream.Open( *buf );
    progress->WriteInternalStateL( stream );
    stream.CommitL();
    stream.Close();
    
    CleanupStack::PopAndDestroy( &stream );
    CleanupStack::PopAndDestroy( buf );
    CleanupStack::PopAndDestroy( progress );
    
    return KErrNone;
    
    }
예제 #12
0
/**
@SYMTestCaseID			PDS-STORE-UT-4056
@SYMTestCaseDesc		Test for DEF141471 - STORE, new stream performance tests.
						PREQ2505 Insturmentation of PDS.
						RBufWriteStream & RBufReadStream performance tests.
@SYMTestPriority		High
@SYMTestActions			Test for DEF141471 - STORE, new stream performance tests.
@SYMTestExpectedResults Test must not fail
@SYMDEF					DEF141471
*/
void BufStreamTestL()
	{
	CBufFlat* bufFlat = CBufFlat::NewL(KTestDataLen);
	CleanupStack::PushL(bufFlat);
	
	//RBufWriteStream::Open()
	RBufWriteStream strm1;
	CleanupClosePushL(strm1);
	TUint32 fc = User::FastCounter();
	strm1.Open(*bufFlat);
	TUint32 openFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufWriteStream::Open(), Time=%d us\r\n"), openFc);
	DoStreamWriteTestL(strm1);
	CleanupStack::PopAndDestroy(&strm1);
	TheTest.Printf(_L("       Buffer size=%d\r\n"), bufFlat->Size());

	//RBufWriteStream::Append()
	RBufWriteStream strm2;
	CleanupClosePushL(strm2);
	fc = User::FastCounter();
	strm2.Append(*bufFlat);
	TUint32 appendFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufWriteStream::Append(), Time=%d us\r\n"), appendFc);
	DoStreamWriteTestL(strm2);
	CleanupStack::PopAndDestroy(&strm2);
	TheTest.Printf(_L("       Buffer size=%d\r\n"), bufFlat->Size());
	
	//RBufWriteStream::Insert()
	RBufWriteStream strm3;
	CleanupClosePushL(strm3);
	fc = User::FastCounter();
	strm3.Insert(*bufFlat, KBufSize);
	TUint32 insertFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufWriteStream::Insert(), Time=%d us\r\n"), insertFc);
	DoStreamWriteTestL(strm3);
	CleanupStack::PopAndDestroy(&strm3);
	TheTest.Printf(_L("       Buffer size=%d\r\n"), bufFlat->Size());
	
	//RBufWriteStream::Truncate()
	RBufWriteStream strm4;
	CleanupClosePushL(strm4);
	fc = User::FastCounter();
	strm4.Truncate(*bufFlat);
	TUint32 truncateFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufWriteStream::Truncate(), Time=%d us\r\n"), truncateFc);
	DoStreamWriteTestL(strm4);
	CleanupStack::PopAndDestroy(&strm4);
	TheTest.Printf(_L("       Buffer size=%d\r\n"), bufFlat->Size());
	
	RBufReadStream strm5;
	CleanupClosePushL(strm5);
	fc = User::FastCounter();
	strm5.Open(*bufFlat);
	openFc = CalcTickDiff(fc, User::FastCounter());
	PrintFcDiffAsUs(_L("###  RBufReadStream::Open(), Time=%d us\r\n"), openFc);
	DoStreamReadTestL(strm5);
	CleanupStack::PopAndDestroy(&strm5);
	
	CleanupStack::PopAndDestroy(bufFlat);
	}
SMFCredMgrErrorCode CSmfCredMgrClientSymbian::signMessageL(QString Message,
		QString Key, QString& Signature, SmfSignatureMethod AlgorithmUsed)
	{
	SMFCredMgrErrorCode signError = SmfErrNone;
	TPtr msgPtr((qt_QString2HBufC(Message))->Des());
	TPtr keyPtr((qt_QString2HBufC(Key))->Des());

	CSmfSignParameters* signMsgParams = CSmfSignParameters::NewL(
			msgPtr.Collapse(), keyPtr.Collapse());
	CleanupStack::PushL(signMsgParams);

	CBufFlat* buf = CBufFlat::NewL(KMinBufSize);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf);
	CleanupClosePushL(stream);

	signMsgParams->ExternalizeL(stream);
	stream.CommitL();

	TPtr8 bufPtr = buf->Ptr(0);

	TIpcArgs args;
	args.Set(0, &bufPtr);

	HBufC8* msgBuf = HBufC8::NewL(KMaxSignedMsgLength);
	TPtr8 msgBufPtr(msgBuf->Des());
	CleanupStack::PushL(msgBuf);
	args.Set(1, &msgBufPtr);

	switch (AlgorithmUsed)
		{
		case ESMFRSAProtocol:
			{
			iSession.RequestService(ESmfRSASignMessage, args);
			}
			break;
		case ESMFHMACProtocol:
			{
			iSession.RequestService(ESmfHMACSHA1SignMessage, args);
			}
			break;
		default:
			{
			RDebug::Printf("Unsupported Algo:");
			return SmfErrBadParameter;
			}
		}

	TBuf<KMaxSignedMsgLength> signedMsg;
	signedMsg.Copy(msgBufPtr);

	Signature = qt_TDesC2QString(signedMsg);

	CleanupStack::Pop(msgBuf);
	CleanupStack::PopAndDestroy(&stream);
	CleanupStack::PopAndDestroy(buf);
	CleanupStack::PopAndDestroy(signMsgParams);

	return signError;
	}
예제 #14
0
void CReferenceHandler::CreateReferenceObject2L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
{
    //Reset the object (also resets the buffer)
    aObject.Reset();
    const TUint KNumOfObjects = 2;
    aObjectBuf.ResizeL(KNumOfObjects * 20);
    //populate the buffer...
    _LIT8(KRefDesc2, "*Reference Object 2*");
    TUint i;
    for (i=0; i<KNumOfObjects; i++)
    {
        aObjectBuf.Write(20*i, KRefDesc2);
    }
    //populate the object
    aObject.SetNameL(KRef2Name);
    aObject.SetTypeL(KRefType);
    aObject.SetLengthL(aObjectBuf.Size());
    const TTime KRef2Time = TDateTime(2002, EJanuary, 0, 0, 0, 0, 0);
    aObject.SetTimeL(KRef2Time);

    // Set up the MF description header
    const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
    HBufC* descBuf = HBufC::NewLC(KDescLength);
    ASSERT(descBuf);
    TPtr ptr(descBuf->Des());
    ptr.Zero();
    for (i=0; i<KDescLength; i++)
    {
        ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
    }
    aObject.SetDescriptionL(ptr);
    CleanupStack::PopAndDestroy(descBuf);
    aObject.SetTargetL(KRefIrMCTarget);
    aObject.SetHeaderMask(KObexHdrName | KObexHdrType | KObexHdrLength  | KObexHdrTime | KObexHdrDescription | KObexHdrTarget);
}
예제 #15
0
EXPORT_C void RRtaRights::AddRightsL(CRightsObject& aRights)
	{
	// Write the object out to a buffer, send to client
	CBufFlat* buf = CBufFlat::NewL(50);
	CleanupStack::PushL(buf);
	
	// create write stream
	RBufWriteStream writeStream(*buf);
	CleanupClosePushL(writeStream);

	// write the directory to the stream
	aRights.ExternalizeL(writeStream);
	CleanupStack::PopAndDestroy(&writeStream);
	
	TPtr8 bufPtr = buf->Ptr(0);

	if(IsDrmCapabilityEnforced())
		{
		User::LeaveIfError(SendReceive(EAddRights, TIpcArgs(&bufPtr)));
		}
	else
		{
		User::LeaveIfError(SendReceive(ENoEnforceAddRights, TIpcArgs(&bufPtr)));
		}
	CleanupStack::PopAndDestroy(buf);
	}
예제 #16
0
void CCmdTestList::AddMultipleWaitCommandL(TInt32 aTimeout)
	{
	RDebug::Printf("CCmdTestList::AddMultipleWaitCommandL");
	SSMLOGLEAVEIFNULL(iCommandList);
	//
	const TInt KTempDataLength = 1024;
	CBufFlat* inputBuffer = CBufFlat::NewL(KTempDataLength);
	CleanupStack::PushL(inputBuffer);
	RBufWriteStream writeStream(*inputBuffer);
	CleanupClosePushL(writeStream);
	writeStream.WriteInt32L(aTimeout);
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	writeStream.WriteUint16L(KDefaultCommandPriority);
#endif //SYMBIAN_SSM_FLEXIBLE_MERGE
	writeStream.CommitL();
	RDesReadStream readStream(inputBuffer->Ptr(0));
	CleanupClosePushL(readStream);
	TArray<MSsmCommand*> deferredList = iDeferredList.Array();
	CSsmCommandBase* cmd = CCmdMultipleWait::NewL(readStream, deferredList);
	CleanupStack::PushL(cmd);
	static_cast<MSsmCommandList&>(*iCommandList).AppendL(cmd);
	iDeferredList.Reset();
	CleanupStack::Pop(cmd);

	CleanupStack::PopAndDestroy(&readStream);
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(inputBuffer);
	}
// ============================================================================
// RCwrtRegistryClientSession::RegisterWidgetL()
// Registers the widget
//
// ============================================================================
EXPORT_C bool RWACRegistryClientSession::RegisterWidgetL(
                        const QString& appId, const QString& appTitle,
                        const QString& appPath, const QString& iconPath,
                        const AttributeMap& attributes, const QString& type,
                        unsigned long size, const QString& startPath)
    {
    CBufFlat* buf = CBufFlat::NewL( 5120 );
    CleanupStack::PushL( buf );

    RBufWriteStream stream( *buf );
    CleanupClosePushL( stream );

    SerializeStringL( stream, appId );
    SerializeStringL( stream, appTitle );
    SerializeStringL( stream, appPath );
    SerializeStringL( stream, iconPath );
    SerializeMapL( stream, attributes );
    SerializeStringL( stream, type );
    SerializeIntL( stream, size );
    SerializeStringL( stream, startPath );

    CleanupStack::PopAndDestroy( &stream );

    TPtr8 p( buf->Ptr(0) );
    bool ret = SendReceive( EOpCodeRegisterWidget, TIpcArgs( &p ) );

    CleanupStack::PopAndDestroy( buf );

    return ret;
    }
예제 #18
0
void CRtaContentHandler::GetStringAttributeSetL(const RMessage2& aMessage)
	{
	RStringAttributeSet attributeSet;
	CleanupClosePushL(attributeSet);
	
	HBufC* uniqueId = ReadDesC16LC(aMessage, 0);
	
	HBufC8* value = ReadDes8LC(aMessage, 1);
	TPtr8 valuePtr = value->Des();
	RDesReadStream readStream(valuePtr);
	attributeSet.InternalizeL(readStream);
	CleanupStack::PopAndDestroy(value);
	
	iArchive->DrmFilesL().FindL(*uniqueId).GetStringAttributeSet(attributeSet);

	// Write the object out to a buffer, send to client
	CBufFlat* buf = CBufFlat::NewL(50);
	CleanupStack::PushL(buf);
	// create write stream
	RBufWriteStream writeStream(*buf);
	// write the directory to the stream
	attributeSet.ExternalizeL(writeStream);
	TPtr8 bufPtr = buf->Ptr(0);
	WriteL(aMessage, 1, bufPtr);
		
	CleanupStack::PopAndDestroy(3, &attributeSet); // buf, attributeSet, uniqueid
	}
// ============================================================================
// CCwrtRegistryServerSession::OpGetWebAttributeL()
// Returns the attribute value for the widget
//
// ============================================================================
//
TInt CCwrtRegistryServerSession::OpGetWebAttributeL( const RMessage2& aMessage )
    {
    TInt l = aMessage.GetDesMaxLength( 0 );
    HBufC8* msgData = HBufC8::NewLC( l );
    TPtr8 readPtr( msgData->Des() );
    aMessage.ReadL( 0, readPtr );
    RDesReadStream stream( *msgData );
    CleanupClosePushL( stream );
    QString appId = DeserializeStringL( stream );
    QString attribute = DeserializeStringL( stream );
    QString defaultValue = DeserializeStringL( stream );
    CleanupStack::PopAndDestroy( 2 ); //stream, msgData,

    QVariant attrValue =  WebAppRegistry::instance()->getAttribute( appId, attribute, QVariant( defaultValue ) );

    TInt maxLength = aMessage.GetDesMaxLength( 1 );
    CBufFlat* buf = CBufFlat::NewL( maxLength );
    CleanupStack::PushL( buf );
    RBufWriteStream wstream( *buf ); // stream over the buffer
    CleanupClosePushL( wstream );
    SerializeStringL( wstream, attrValue.toString() );
    CleanupStack::PopAndDestroy( &wstream );
    aMessage.WriteL( 1, buf->Ptr(0) );
    CleanupStack::PopAndDestroy( buf ); // buf

    return KErrNone;
    }
QString CSmfCredMgrClientSymbian::storeRSAKeysL(const QString KeyLabel,
		const QString keydata, const QDateTime Validity)
	{
	RDebug::Printf("Sending store RSA key message to server");

	TPtrC labelPtr(qt_QString2TPtrC(KeyLabel));
	TPtr dataPtr((qt_QString2HBufC(keydata)->Des()));

	QDateTime CurrentTime = QDateTime::currentDateTime();
	TTimeIntervalSeconds duration(CurrentTime.secsTo(Validity));

	TTime startDate;
	startDate.UniversalTime();

	TTime endDate(startDate);
	endDate += duration;

	CSmfRsaKeyParameters* storeRSAKeysparams = CSmfRsaKeyParameters::NewL(
			labelPtr, startDate, endDate, (dataPtr.Collapse()));
	CleanupStack::PushL(storeRSAKeysparams);

	CBufFlat* buf = CBufFlat::NewL(KMinBufSize);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf);
	CleanupClosePushL(stream);

	storeRSAKeysparams->ExternalizeL(stream);
	stream.CommitL();

	TPtr8 bufPtr = buf->Ptr(0);

	TIpcArgs args;
	args.Set(0, &bufPtr);

	CleanupStack::PopAndDestroy(&stream);

	HBufC8* retBuf = HBufC8::NewLC(KSHA1HashLengthBytes);
	TPtr8 retBufPtr(retBuf->Des());
	args.Set(1, &retBufPtr);

	iSession.RequestService(ESmfStoreRSAKey, args);

	RDebug::Printf("SMF: Message completed");

	TBuf<KSHA1HashLengthBytes> key;
	key.Copy(retBufPtr);

	QString RetString(qt_TDesC2QString(key));

	CleanupStack::Pop(retBuf);
	CleanupStack::PopAndDestroy(buf);
	CleanupStack::PopAndDestroy(storeRSAKeysparams);

	RDebug::Printf("-In storeAuthDataL()");
	
	return (RetString);

	}
예제 #21
0
// ---------------------------------------------------------
// RNSmlPrivateAPI::AddDMGenericAlertRequestL()
// Adds a Generic Alert to DM Agent if it is found in the 
// server.
// ---------------------------------------------------------
//	
EXPORT_C TInt RNSmlPrivateAPI::AddDMGenericAlertRequestL( const TDesC8& aCorrelator, RArray<CNSmlDMAlertItem>& aItemList ) const
	{
	TInt err = KErrNone;
	
	// create buffer
	CBufFlat* buffer = CBufFlat::NewL( KDefaultNSmlBufferGranularity );
	CleanupStack::PushL( buffer );
	
	// open stream to buffer
	RBufWriteStream stream( *buffer );	
	CleanupClosePushL( stream );
	
    // externalize data to stream
	stream.WriteInt32L( aCorrelator.Length() );
	stream.WriteL( aCorrelator );

	TInt count = aItemList.Count();
	stream.WriteInt32L( count );
	
	if(count > 0)
	{		
		for(TInt i =0 ; i <count; i++)
		{
			stream.WriteInt32L( (aItemList[i].iSource)->Length() );
			stream.WriteL( (aItemList[i].iSource)->Des() );
	
			stream.WriteInt32L( (aItemList[i].iTarget)->Length() );
			stream.WriteL( aItemList[i].iTarget->Des() );
	
			stream.WriteInt32L( (aItemList[i].iMetaType)->Length() );
			stream.WriteL( aItemList[i].iMetaType->Des() );

			stream.WriteInt32L( (aItemList[i].iMetaFormat)->Length()  );
			stream.WriteL( aItemList[i].iMetaFormat->Des());

			stream.WriteInt32L( (aItemList[i].iMetaMark)->Length() );
			stream.WriteL( aItemList[i].iMetaMark->Des() );
			
			stream.WriteInt32L( (aItemList[i].iData)->Length() );
			stream.WriteL( aItemList[i].iData->Des() );
		}		
	}
	
	// get modifiable pointer to buffer
	TPtr8 bufPtr( buffer->Ptr(0) );
	
	CleanupStack::PopAndDestroy( &stream );
	
	// send the data to sos server
	TIpcArgs args( &bufPtr );
	err = SendReceive( ECmdAddGenericAlert, args );
	
	CleanupStack::PopAndDestroy( buffer );
	
	return err;
	}
TInt CSenBaseIdentityManager::WriteConfigurationToL( const TDesC& aFile )
    {
    // First, collect everything into MEMORY
    CBufFlat *pBuf = CBufFlat::NewL(KFLATBUF_SIZE);
    CleanupStack::PushL(pBuf);

    RBufWriteStream bufWs(*pBuf);
    CleanupClosePushL(bufWs);

    bufWs.WriteL(KUsersStart);

    if(iIdentity)
        {
        iIdentity->WriteAsXMLToL(bufWs);
        }

    bufWs.WriteL(KUsersEnd);

    TPtrC8 p8 = pBuf->Ptr(0);

    CleanupStack::PopAndDestroy(1); // bufWs

    // Everything in MEMORY ok, prepare to write into file
    RFs fss;
    User::LeaveIfError(fss.Connect());
    CleanupClosePushL(fss);

    RFileWriteStream fileOutStream;
    CleanupClosePushL(fileOutStream);


    if(!SysUtil::FFSSpaceBelowCriticalLevelL(&fss, p8.Length()) )
        {
        // note, this will zero-length the file(!)
        // it is better to require that 2xfilesize is available and not to
        // dangerously zero the old file and find out
        // that there is no space left..

        //Data caging 2 implementation
#if defined( EKA2 ) || defined( RD_SECURE_PRIV_DATA )
        TBuf<KMaxPath> file;
        fss.CreatePrivatePath(EDriveC);
        fss.PrivatePath(file);
        file.Append(aFile);
        fileOutStream.Replace(fss, file, EFileWrite);
#else
        fileOutStream.Replace(fss, aFile, EFileWrite);
#endif
        // finally write the UTF-8 into the file. 
        fileOutStream.WriteL(p8);
        }

    CleanupStack::PopAndDestroy(3); // fileOutStream, fss, pBuf

    return KErrNone;
    }
예제 #23
0
void CReferenceHandler::CreateReferenceObject7L(CObexBufObject& aObject, CBufFlat& aObjectBuf, TTransport aTransport)
{
    //Reset the object (also resets the buffer)
    aObject.Reset();
    const TUint KNumOfAlphabets = 200;
    aObjectBuf.ResizeL(KNumOfAlphabets * 30);
    //populate the buffer...
    TBuf8<4> buf;
    TUint i;
    for (i=0; i<KNumOfAlphabets; i++)
    {
        buf.Zero();
        buf.AppendNumFixedWidth(i, EDecimal, 4);
        aObjectBuf.Write(30*i, buf);
        aObjectBuf.Write(30*i + 4, KAlphabet);
    }
    //populate the object

    aObject.SetNameL(KRef7Name);
    aObject.SetTypeL(KRefImageJpegType);
    aObject.SetLengthL(aObjectBuf.Size());
    const TTime KRef5Time = TDateTime(2001, EFebruary, 14, 15, 38, 24, 0);//set time to 15:38:24.0 on 14th Feb 2001 - obex doesn't transfer microseconds!!
    aObject.SetTimeL(KRef5Time);

    _LIT8(KRef1HTTP, "Accept: text/*");
    _LIT8(KRef2HTTP, "Location: http://www.w3.org");
    _LIT8(KRef3HTTP, "Date: Tue, 10 Nov 2002 09:17:21 GMT");

    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef3HTTP);
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef3HTTP);
    aObject.AddHttpL(KRef1HTTP);
    aObject.AddHttpL(KRef2HTTP);
    aObject.AddHttpL(KRef3HTTP);


    // Set up the MF description header
    const TUint KDescLength = ( (aTransport==EBluetooth?KObexPacketDefaultSize:2044) - KObexPacketHeaderSize - 5 - 5)/sizeof(TText); // Size in characters
    HBufC* descBuf = HBufC::NewLC(KDescLength);
    /*	ASSERT(descBuf);
    	TPtr ptr(descBuf->Des());
    	ptr.Zero();
    	for (i=0; i<KDescLength; i++)
    		{
    		ptr.AppendNumFixedWidth(i%10, EDecimal, 1);
    		}
    	aObject.SetDescriptionL(ptr);
    */
    CleanupStack::PopAndDestroy(descBuf);

    aObject.SetTargetL(KRefSyncMLTarget);
    aObject.SetHeaderMask(KObexHdrName | KObexHdrType  | KObexHdrTime | KObexHdrLength | KObexHdrHttp | KObexHdrTarget);
}
예제 #24
0
/** 
Match an array of search strings against the contacts in the view.

The descriptor from the client contains a flag at the start to indicate if a
prefix or substring search has been requested.

@param aMessage.Ptr0() Size of contact data to read (to client).
@param aMessage.Int1() Size of descriptor (from client).
@param aMessage.Ptr2() Descriptor (from client).
*/
void CViewSubSessionBase::ContactMatchingCriteriaExternalizedSizeL(const RMessage2& aMessage)
	{
	TPckgBuf<TInt> size;
	aMessage.ReadL(1,size);
	const TInt bufferSize = size();

	// Restore buffer.
	CBufFlat* buffer = CBufFlat::NewL(bufferSize);
	CleanupStack::PushL(buffer);
	buffer->ExpandL(0,bufferSize);
	TPtr8 des(buffer->Ptr(0));
	aMessage.ReadL(2,des);

	// Internalize the data from the stream.
	RBufReadStream readStream(*buffer);
	CleanupClosePushL(readStream);

	TBool prefixSearch = readStream.ReadUint32L(); 
	const TInt numFindWords = readStream.ReadUint32L();
	CPtrC16Array* findDesArray = new(ELeave) CPtrC16Array(numFindWords);
	CleanupStack::PushL(findDesArray);

	TInt findWordLength=0;
	for (TInt i=0; i<numFindWords; ++i)
		{
		findWordLength = readStream.ReadUint32L();
		HBufC* findword = HBufC::NewLC(readStream,findWordLength);
		findDesArray->AppendL(*findword);
		}

	DeleteFindContacts();

	if (prefixSearch)
		iView->ContactsMatchingPrefixL(*findDesArray,iContacts);
	else
		iView->ContactsMatchingCriteriaL(*findDesArray,iContacts);

	findDesArray->Reset();
	
	CleanupStack::PopAndDestroy(numFindWords);
	CleanupStack::PopAndDestroy(3, buffer);

	// Compute contacts externalized size.
	const TInt contactsCount = iContacts.Count();
	TInt contactsExternalizedSize=0;
	contactsExternalizedSize+=sizeof(TInt32);
	for (TInt jj=0;jj<contactsCount;++jj)
		{
		contactsExternalizedSize+=(iContacts)[jj]->ExternalizedSize();
		}

	TPckgBuf<TInt> pckg(contactsExternalizedSize);
	aMessage.WriteL(0,pckg);
	}
예제 #25
0
/**
 Construct and delete a command using Internalise
*/ 
void CCmdTestLoadSup::CallInternalizeDataTestL(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, TInt16 aRetries, const TSsmSupInfo& aInfo, const TUint16 aPriority)
	{
	// create a set of data and put it into a buffer
 	CBufFlat* bufferin = CBufFlat::NewL(1024);
	CleanupStack::PushL(bufferin);	
	
	// create write stream on buffer and put the data in
	RBufWriteStream writeStream(*bufferin);
	CleanupClosePushL(writeStream);		
	writeStream.WriteInt16L(aSeverity);
	writeStream.WriteInt8L(aExecutionBehaviour);
	aInfo.ExternalizeL(writeStream);
	writeStream.WriteInt16L(aRetries);
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	writeStream.WriteUint16L(aPriority);
#else
	TEST(aPriority == KDefaultPriority);
#endif
	writeStream.CommitL();

	// create a readstream on the data and put the data into the command
	RDesReadStream aReadStream(bufferin->Ptr(0));
	CleanupClosePushL(aReadStream);
	CCmdLoadSup* loadSupCmd = CCmdLoadSup::NewL(aReadStream);
	CleanupStack::PushL(loadSupCmd);

	TEST(loadSupCmd->Type() == ESsmCmdLoadSup);
		
	// create output buffer and stream
 	CBufFlat* bufferout = CBufFlat::NewL(1024);
	CleanupStack::PushL(bufferout);	
	RBufWriteStream writeStream2(*bufferout);
	CleanupClosePushL(writeStream2);		

	// externalise the data
	loadSupCmd->ExternalizeL(writeStream2);
	
	// check the data is correct
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	CompareInputAndOutputL(aSeverity, aExecutionBehaviour, aRetries, aInfo, bufferout, aPriority);
#else
	CompareInputAndOutputL(aSeverity, aExecutionBehaviour, aRetries, aInfo, bufferout);
#endif
	
	CleanupStack::PopAndDestroy(&writeStream2);
	CleanupStack::PopAndDestroy(bufferout);	
	CleanupStack::PopAndDestroy(loadSupCmd);
	CleanupStack::PopAndDestroy(&aReadStream);
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(bufferin);	
	}
예제 #26
0
void CCntItemMsgHandler::FindAsyncTextDefInitL(const RMessage2& aMessage)
	{
	/* Initialisation for asynchronous find using CContactTextDef and array of 
	"find words" constructed on the client-side and required on the server-side 
	for matching.
	**/
	
	CheckForManagerL();

	// CContactTextDef can be NULL in which case the client will have
	// passed an empty descriptor.
	CContactTextDef* textDef = NULL;
	// Assuming that a KNullDesC parameter results in max length of 0.
	if(aMessage.GetDesLengthL(1) > 0)
		{
		// Use packager to unpack CContactTextDef.
		iPackager.SetBufferFromMessageL(aMessage,1);
		textDef = iPackager.UnpackCntTextDefLC();
		CleanupStack::Pop(textDef);
		}

	// Unpack the CDesCArray manually as the packager does not package
	// both.			
	CBufFlat* bufFlat = CBufFlat::NewL(1 << 8);
	CleanupStack::PushL(bufFlat);
	bufFlat->ExpandL(0,aMessage.GetDesLengthL(0));
	TPtr8 ptr8(bufFlat->Ptr(0));
	aMessage.ReadL(0,ptr8);
	RBufReadStream readStream;
	readStream.Open(*bufFlat);
	TInt count = readStream.ReadInt32L();
	CDesCArray* unpacked = new (ELeave) CDesCArrayFlat(8);
	CleanupStack::PushL(unpacked);
	for(TInt i=0;i<count;++i)
		{
		TBuf<256> buf;
		TInt length = readStream.ReadInt32L();
		readStream.ReadL(buf,length);
		unpacked->AppendL(buf);
		}
	readStream.Close();
	
	// Persistence Layer does the actual initialisation and also takes
	// ownership of textDef.
	MLplCollection& collection = iManager->GetPersistenceLayer().FactoryL().GetCollectorL();
	collection.FindAsyncTextDefInitL(*unpacked,textDef);
	
	CleanupStack::PopAndDestroy(unpacked);
	CleanupStack::PopAndDestroy(bufFlat);
	aMessage.Complete(KErrNone);
	}
예제 #27
0
EXPORT_C TInt RRtaContent::GetStringAttributeSetL(const TDesC& aUniqueId, RStringAttributeSet &aStringAttributeSet) const
	{
	TInt err = KErrOverflow;
	TInt length = 0;
	TPckg <TInt> lengthPckg(length);
	
	// Write the object out to a buffer, send to client
	CBufFlat* buf = CBufFlat::NewL(50);
	CleanupStack::PushL(buf);
	
	// create write stream
	RBufWriteStream writeStream(*buf);
	CleanupClosePushL(writeStream);

	// write the directory to the stream
	aStringAttributeSet.ExternalizeL(writeStream);
	CleanupStack::PopAndDestroy(&writeStream);
	
	
	TPtr8 bufPtr = buf->Ptr(0);
	// allocate arbitary receive buffer much larger than the size of the source buffer
	length = bufPtr.Length() * 15;
	
	while(err == KErrOverflow)
		{
		HBufC8* transferBuffer = HBufC8::NewLC(length);
		transferBuffer->Des().Copy(bufPtr);
		TPtr8 transferPtr = transferBuffer->Des();
	
		// attempt to retrieve the attributes
		err = SendReceive(EGetStringAttributeSet, TIpcArgs(&aUniqueId, &transferPtr));	
		if(err == KErrOverflow)
			{
			// Find out the length required to receive the resulting attribute set
			lengthPckg.Copy(transferPtr.Left(lengthPckg.MaxLength()));	
			}
		else if(err == KErrNone)
			{
			// read in the attribute values from the buffer
			RDesReadStream readStream(transferPtr);
			CleanupClosePushL(readStream);
			aStringAttributeSet.InternalizeL(readStream);
			CleanupStack::PopAndDestroy(&readStream);
			}
		CleanupStack::PopAndDestroy(transferBuffer);	
		}

	CleanupStack::PopAndDestroy(buf);
	return err;
	}
void CSmfCredMgrClientSymbian::authenticatedPluginListL(
		QString RegistrationToken, QStringList& List)
	{
	CSmfPluginIDListParams* fetchPluginListParams =
			new (ELeave) CSmfPluginIDListParams;
	CleanupStack::PushL(fetchPluginListParams);

	//fill input params
	fetchPluginListParams->iRegistrationToken = qt_QString2HBufC(
			RegistrationToken);

	//create buffer to serialize data
	CBufFlat* buf = CBufFlat::NewL(KMinBufSize);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf);
	CleanupClosePushL(stream);

	fetchPluginListParams->ExternalizeL(stream);
	stream.CommitL();

	TPtr8 bufPtr1 = buf->Ptr(0);
	TIpcArgs args;
	args.Set(0, &bufPtr1);

	// to get the data from server, we create a space.
	HBufC8* retBuf = HBufC8::NewL(KMaxBufSize);
	CleanupStack::PushL(retBuf);

	TPtr8 outputptr = retBuf->Des();
	args.Set(1, &outputptr);

	iSession.RequestService(ESendPluginIDList, args);

	//create buffer to read data received
	RBuf8 dataBuf;
	CleanupClosePushL(dataBuf);
	dataBuf.Create(outputptr);

	fetchPluginListParams->InternalizeL(dataBuf);

	smfcredmgrclientutil::convertToQStringList(
			fetchPluginListParams->iPluginList, List);

	CleanupStack::PopAndDestroy(&dataBuf);
	CleanupStack::PopAndDestroy(retBuf);
	CleanupStack::PopAndDestroy(&stream);
	CleanupStack::PopAndDestroy(buf);
	CleanupStack::PopAndDestroy(fetchPluginListParams);
	}
HBufC8* CSenLayeredXmlProperties::AsUtf8L()
    {
    CBufFlat *pBuf = CBufFlat::NewL(KFlatBufSize);
    CleanupStack::PushL(pBuf);
    RBufWriteStream bufWs(*pBuf);
    CleanupClosePushL(bufWs);
    this->WriteToL(bufWs);
    CleanupStack::PopAndDestroy(); // bufWs.Close();
    TPtrC8 p = pBuf->Ptr(0);    
    HBufC8* pRet = p.AllocL();
    CleanupStack::PopAndDestroy(); // pBuf;
    return pRet;
    
    // return ipFragment->AsXmlL();
    }
// -----------------------------------------------------------------------------
// CResultCollector::VisitL
// -----------------------------------------------------------------------------
// 
void CResultCollector::VisitL( CNSPTest& aTest )
	{
	CBufFlat* buffer = CBufFlat::NewL( 300 );
	CleanupStack::PushL( buffer );
	RBufWriteStream stream;
	stream.Open( *buffer );
	CleanupClosePushL( stream );
	aTest.ExternalizeL( stream );
	
	TPckgBuf<TResult> pkgIn;
	pkgIn.Copy( buffer->Ptr(0) );
	PrintResult( pkgIn() );
	
	CleanupStack::PopAndDestroy();
	CleanupStack::PopAndDestroy( buffer );
	}