static void ReadDesc(TDes& aDes, const TDesC& aFilename, RFs& aFs) { RFile file; TInt err = file.Open(aFs, aFilename, EFileRead); TheTest(err == KErrNone); CleanupClosePushL(file); TPtr8 ptr(reinterpret_cast<TUint8*>(const_cast<TUint16*>(aDes.Ptr())), aDes.MaxSize()); err = file.Read(ptr); TheTest(err == KErrNone); aDes.SetLength(ptr.Length() / sizeof(TText)); CleanupStack::PopAndDestroy(&file); }
EXPORT_C void CBasePlugin::GetContentToBufferL( const TFSMailMsgId& aMailBoxId, const TFSMailMsgId& /*aParentFolderId*/, const TFSMailMsgId& aMessageId, const TFSMailMsgId& aMessagePartId, TDes& aBuffer, const TUint aStartOffset ) { __LOG_ENTER( "GetContentToBufferL" ) CMsgStoreMessage* msg = GetCachedMsgL( aMailBoxId.Id(), aMessageId.Id() ); //could the cache be extended to cache the child parts in this case ? CMsgStoreMessagePart* part = msg->ChildPartL( aMessagePartId.Id(), ETrue ); CleanupStack::PushL( part ); TUint outSize = aBuffer.MaxSize(); /**@ look for ways to avoid the copying.*/ __LOG_WRITE8_FORMAT1_INFO( "Output buffer size: %d bytes.", outSize ); HBufC8* buf = HBufC8::NewLC( outSize ); TPtr8 ptr = buf->Des(); part->FetchContentToBufferL( ptr, aStartOffset ); __LOG_WRITE8_FORMAT1_INFO( "Msgstore content buffer size: %d bytes.", buf->Size() ); TUint msgStoreSize = ptr.Size(); TUint theSize = outSize > msgStoreSize ? msgStoreSize : outSize; TPtrC16 convert( reinterpret_cast<const TUint16*>( buf->Ptr() ), theSize/2 ); aBuffer = convert; CleanupStack::PopAndDestroy( buf ); CleanupStack::PopAndDestroy( part ); __LOG_EXIT } //GetContentToBufferL.