// ============================================================================
// 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 ) );
    }
// ---------------------------------------------------------------------------
// 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();
    }
Example #3
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);
	}
Example #4
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);
	}
// ============================================================================
// RCwrtRegistryClientSession::nativeIdToAppIdL()
// Returns the AppId
//
// ============================================================================
EXPORT_C QString RWACRegistryClientSession::nativeIdToAppIdL( const QString& Id )
    {
    const TInt maxSize = 512;
    CBufFlat* buf = CBufFlat::NewL( maxSize );
    CleanupStack::PushL( buf );
    buf->ExpandL( 0, maxSize );
    TPtr8 p( buf->Ptr(0) );

    User::LeaveIfError(
            SendReceive( EOpCodeNativeIdToAppId, TIpcArgs( Id.toInt(), &p ) )
            );

    // deserialize
    RDesReadStream stream( p );
    CleanupClosePushL( stream );

    QString appId = DeserializeStringL( stream );

    CleanupStack::PopAndDestroy( 2, buf ); // stream, buf

    return appId;
    }
Example #6
0
/**
Provides conversion between view indexes and contact IDs.

@param aMessage.Int0() Buffer size (from client).
@param aMessage.Ptr1() Descriptor containing indices (from client).
@param aMessage.Ptr2() Descriptor containing contact IDs (to client).
*/
void CViewSubSessionBase::GetContactIdsL(const RMessage2& aMessage)
	{
	TPckgBuf<TInt> size;
	aMessage.ReadL(0,size);
	const TInt bufferSize = size();
	
	CBufFlat* buffer = CBufFlat::NewL(bufferSize);
	CleanupStack::PushL(buffer);
	buffer->ExpandL(0,bufferSize);
	TPtr8 des(buffer->Ptr(0));
	aMessage.ReadL(1,des);

	RBufReadStream readStream(*buffer);
	CleanupClosePushL(readStream);
	const TInt count = readStream.ReadUint32L(); 

	CArrayFixFlat<TInt>* indexes = new(ELeave) CArrayFixFlat<TInt>(8);	
	CleanupStack::PushL(indexes);

	for (TInt i=0; i<count; ++i)
		{
		TInt index = readStream.ReadUint32L();
		indexes->AppendL(index);
		}

	CContactIdArray* array = CContactIdArray::NewLC();
	iView->GetContactIdsL(*indexes, *array);

	HBufC8* buf=HBufC8::NewLC(bufferSize);
	TPtr8 bufPtr(buf->Des());
	RDesWriteStream writeStream(bufPtr);
	CleanupClosePushL(writeStream);
	writeStream << *array;
	bufPtr.SetLength(bufferSize);
	aMessage.WriteL(2,*buf);

	CleanupStack::PopAndDestroy(6, buffer); // &writeStream, buf, array, indexes, &readStream, buffer
	}