// ============================================================================
// 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 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);
	}
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
	}
// ---------------------------------------------------------
// 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	
	}
// ---------------------------------------------------------------------------
// 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;
    }
Exemple #6
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;
	}
/**
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);
	}
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     
    }     
// ============================================================================
// 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;
    }
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);
	}
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);

	}
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;
	}
// -----------------------------------------------------------------------------
// 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;
    
    }
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
	}
// ============================================================================
// 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);

	}
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;
    }
// ---------------------------------------------------------
// 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;
	}
Exemple #19
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);
	}
/**
 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);	
	}
Exemple #21
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);
	}
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 );
	}
TBool CSmfCredMgrClientSymbian::isPluginAuthenticatedL(QString PluginID)
	{
	CBufFlat* buf = CBufFlat::NewL(KMinBufSize);
	CleanupStack::PushL(buf);

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

	TPtr idPtr(qt_QString2HBufC(PluginID)->Des());
	SmfUtils::ExternalizeDesL(idPtr, stream);

	stream.CommitL();

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

	TPtr8 bufPtr = buf->Ptr(0);
	TPtr8 flag(retBuf->Des());

	TIpcArgs args;

	args.Set(0, &bufPtr);
	args.Set(1, &flag);

	iSession.RequestService(ECheckPluginAuthentication, args);

	TLex8 iLex = TLex8(flag);
	TInt value = 0;
	iLex.Val(value);

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

	if (value)
		{
		RDebug::Printf("flag returned is ETrue");
		return ETrue;
		}
	else
		{
		RDebug::Printf("flag returned is EFalse");
		return EFalse;
		}
	}
/**
Helper function to create instance of CCmdPersistHalAttributes trough readstream.
*/
CCmdPersistHalAttributes* CCmdTestPersistHalAttributes::CreateCmdFromStreamL(TCmdErrorSeverity aSeverity)
	{
	CBufFlat* inputBuffer = CBufFlat::NewL(KTempDataLength);
	CleanupStack::PushL(inputBuffer);
	RBufWriteStream writeStream(*inputBuffer);
	CleanupClosePushL(writeStream);
	writeStream.WriteInt16L(aSeverity);
	writeStream.CommitL();
	RDesReadStream readStream(inputBuffer->Ptr(0));
	CleanupClosePushL(readStream);
	CCmdPersistHalAttributes* newCmd = CCmdPersistHalAttributes::NewL(readStream);
	CleanupStack::PopAndDestroy(&readStream);
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(inputBuffer);
	
	return newCmd;
	}
void CMsvSendErrorActionsStep::TestRestoreFromResourceL()
	{
	CBufFlat *buf = CBufFlat::NewL(32);
	CleanupStack::PushL(buf);
	buf->ResizeL(0x10000);		
	RBufWriteStream writer(*buf);
	writer.PushL();	
	
	//default error action
	writer.WriteInt8L(0); //flag, action + retry + retry spacing
	writer.WriteInt16L(3); //max retries
	writer.WriteInt16L(1); //error code count
	writer.WriteInt32L(-1); //error code
	
	//error action count
	writer.WriteInt16L(1);
	
	//error action
	writer.WriteInt8L(1);
	writer.WriteInt16L(2);
	writer.WriteInt16L(2);	//error code count
	writer.WriteInt32L(-2);	//error code -2
	writer.WriteInt32L(-3);	//error code -3
	
	writer.CommitL();
	CleanupStack::PopAndDestroy(&writer);
		
	CMsvSendErrorActions* errorActions = CMsvSendErrorActions::NewL();
	CleanupStack::PushL(errorActions);

	TResourceReader reader;
	TPtr8 bufPtr = buf->Ptr(0);
	reader.SetBuffer(&bufPtr);
	errorActions->RestoreFromResourceL(reader);
	
	TMsvSendErrorAction errorAction;
	if(errorActions->GetSendErrorAction(-2, errorAction) != KErrNone ||
		errorActions->GetSendErrorAction(-3, errorAction) != KErrNone ||
		errorActions->Errors().Count() != 2)
		{
		INFO_PRINTF1(_L("CMsvSendErrorActions::RestoreFromResourceL failed"));
		SetTestStepResult(EFail);
		}
	CleanupStack::PopAndDestroy(errorActions); 
	CleanupStack::PopAndDestroy(buf);
	}
// -----------------------------------------------------------------------------
// TMSCallSession::HandleFormatGetSupportedBitRatesL
//
// -----------------------------------------------------------------------------
//
void TMSCallSession::HandleFormatGetSupportedBitRatesL(
        const RMessage2& aMessage)
    {
    TRACE_PRN_FN_ENT;
    gint status(TMS_RESULT_DOES_NOT_EXIST);
    if (iCallAdpt && (iActiveCallType == TMS_CALL_IP))
        {
        CBufFlat* brbuf = CBufFlat::NewL(KArrayExpandSize);
        CleanupStack::PushL(brbuf);
        status = static_cast<TMSCallIPAdpt*>(iCallAdpt)->GetSupportedBitRates(
                brbuf);
        aMessage.WriteL(0, brbuf->Ptr(0));
        CleanupStack::PopAndDestroy(brbuf);
        }
    aMessage.Complete(status);
    TRACE_PRN_FN_EXT;
    }
//-----------------------------------------------------------------------------
// CAknDynamicSoftNotifier::SendMessageL
//-----------------------------------------------------------------------------
//
TInt CAknDynamicSoftNotifier::SendMessageL(
    TInt aNoteId,
    TInt aCount,
    TBool aCancel,
    TBool aAddCount,
    TAknDynamicSoftNotificationParams& aParams )
    {
    CBufFlat* buf = CBufFlat::NewL( KAknBufferGranularity );
    CleanupStack::PushL( buf );

    RBufWriteStream bufStream( *buf );
    bufStream.PushL();
    
    // Common data for dynamic notification
    bufStream.WriteInt32L( KAKNNOTIFIERSIGNATURE );
    bufStream.WriteUint8L( ECustomSoftNotification );
    bufStream.WriteInt16L( aCount );  // count
    bufStream.WriteUint8L( aCancel ? ETrue : EFalse ); // convert TBool to 0 or 1
    bufStream.WriteUint8L( aAddCount ? ETrue : EFalse ); // convert TBool to 0 or 1
    // text prompt (not used in this type of notification). 
    // It's put here to simplify changes in server side
    bufStream << KNullDesC();   
    bufStream.WriteInt32L( aNoteId ); // notification id
    
    // Type Specific data for this dynamic notification
    // Keep this synchronized with AknDynamicNotificationData
    //
    bufStream.WriteInt16L( KAknSoftNotificationDynamic ); // parameter type id
    bufStream.WriteInt32L( aNoteId ); // notification id
    bufStream << aParams;

    // Additional data
    //
    // Secondary display data not available
    bufStream.WriteInt8L( EFalse );
    
    bufStream.CommitL();
    CleanupStack::PopAndDestroy();  // bufStream

    TPckgBuf<TInt> response;
    User::LeaveIfError( iNotifier->StartOrUpdate( buf->Ptr( 0 ), response ) );
    
    CleanupStack::PopAndDestroy( buf );
    return response();
    }