williamr@2: // CMSVPLAINBODYTEXT.H williamr@2: williamr@2: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __CMSVPLAINBODYTEXT_H__ williamr@2: #define __CMSVPLAINBODYTEXT_H__ williamr@2: williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CMsvStore; williamr@2: class CRichText; williamr@2: class CParaFormatLayer; williamr@2: class CCharFormatLayer; williamr@2: class CCnvCharacterSetConverter; williamr@2: williamr@2: /** williamr@2: This class encapsulates plainbody text information for storage within the williamr@2: Message Store.It also populates a CRichText object with the 8 bit data williamr@2: decoded to the specified character set.If a character set is not specified, williamr@2: then the default character set is used. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CMsvPlainBodyText : public CMsgActive williamr@2: { williamr@2: public: williamr@2: static CMsvPlainBodyText* NewL(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId, TMsvId aMessageId, RFs& aFs); williamr@2: static CMsvPlainBodyText* NewL(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TMsvId aMessageId, RFs& aFs, TInt aChunkLength); williamr@2: williamr@2: IMPORT_C ~CMsvPlainBodyText(); williamr@2: williamr@2: IMPORT_C void StoreChunkL(const TDesC8& aChunk, TRequestStatus& aStatus); williamr@2: IMPORT_C void StoreChunkL(const TDesC8& aChunk); williamr@2: williamr@2: IMPORT_C void StoreChunkL(const TDesC16& aChunk, TRequestStatus& aStatus); williamr@2: IMPORT_C void StoreChunkL(const TDesC16& aChunk); williamr@2: williamr@2: IMPORT_C void StoreRichTextAsPlainTextL(CRichText& aRichText); williamr@2: williamr@2: IMPORT_C void CommitL(); williamr@2: williamr@2: IMPORT_C void NextChunkL(TDes8& aChunk, TRequestStatus& aStatus); williamr@2: IMPORT_C void NextChunkL(TDes8& aChunk); williamr@2: williamr@2: IMPORT_C void NextChunkL(TDes16& aChunk, TRequestStatus& aStatus); williamr@2: IMPORT_C void NextChunkL(TDes16& aChunk); williamr@2: williamr@2: IMPORT_C void PreviousChunkL(TDes8& aChunk, TRequestStatus& aStatus); williamr@2: IMPORT_C void PreviousChunkL(TDes8& aChunk); williamr@2: williamr@2: IMPORT_C void PreviousChunkL(TDes16& aChunk, TRequestStatus& aStatus); williamr@2: IMPORT_C void PreviousChunkL(TDes16& aChunk); williamr@2: williamr@2: williamr@2: IMPORT_C void SetCharacterSetL(const TUint aCharset); williamr@2: IMPORT_C TUint CharacterSet(); williamr@2: IMPORT_C TUint DefaultCharacterSet(); williamr@2: williamr@2: IMPORT_C TInt Size(); williamr@2: williamr@2: private: williamr@2: CMsvPlainBodyText(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId, TMsvId aMessageId, RFs& aFs); williamr@2: void ConstructWriteL(); williamr@2: williamr@2: CMsvPlainBodyText(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore,TMsvId aMessageId, RFs& aFs,TInt aChunkLength); williamr@2: void ConstructReadL(); williamr@2: williamr@2: void PrepareToConvertL(); williamr@2: void ConvertChunkToUnicodeForStoreL(const TDesC8& aChunk); williamr@2: TInt ConvertChunkToUnicodeForRestoreL(); williamr@2: void ExtractNextChunkFromRichText(TDes16& aChunk); williamr@2: void ExtractPreviousChunkFromRichText(TDes16& aChunk); williamr@2: void RevertL(); williamr@2: void DoRunL(); williamr@2: void DoComplete(); williamr@2: void DoCancel(); williamr@2: williamr@2: private: williamr@2: /** To access APIs related to RFile operations.*/ williamr@2: MMsvStoreManager& iMsvStoreManager; williamr@2: CMsvStore& iStore; williamr@2: /** Indicates whether to store text as 8 bit or 16 bit.*/ williamr@2: TBool iIs8Bit; williamr@2: /** The charset of the body text*/ williamr@2: TUint iCharsetId; williamr@2: TUint iDefaultCharsetId; williamr@2: williamr@2: /** The RFile Path.*/ williamr@2: HBufC* iFilePath; williamr@2: TMsvId iMessageId; williamr@2: RFs& iFSession; williamr@2: williamr@2: /** The RFile to which body text is written.*/ williamr@2: RFile iFile; williamr@2: /** Character converter for 8 to 16 bit conversion.*/ williamr@2: CCnvCharacterSetConverter* iConverter; williamr@2: CRichText* iRichText; williamr@2: CParaFormatLayer* iParaLayer; williamr@2: CCharFormatLayer* iCharLayer; williamr@2: TInt iReadChunkLength; williamr@2: /** Temporary buffer created to Store chunk while it is being written aynchronously.*/ williamr@2: RBuf16 iTempChunk16; williamr@2: /** Buffer used to read data from RFile.*/ williamr@2: RBuf8 iRfileReadBuf8; williamr@2: /** Pointer to 8-bit buffer that needs to be written to RFile.*/ williamr@2: TPtrC8 iRfileWritePtr8; williamr@2: /** The position from where to extract data in CRichText*/ williamr@2: TInt iPos; williamr@2: /** Contains the size of the chunk that will be read or write in the RFile*/ williamr@2: TInt iChunkMaxLength; williamr@2: /** Contains the remaining unconverted Unicode Data*/ williamr@2: HBufC8* iRemainingUnConvertedData; williamr@2: /** Array that stores the start positions of each chunk,in Rfile*/ williamr@2: RArray iStartPosOfEachChunkInFile; williamr@2: /** Contains the start position of the next chunk*/ williamr@2: TInt iStartPosOfNextChunk; williamr@2: /** Contains the remaining converted Unicode Data*/ williamr@2: RBuf16 iRemainingConvertedData; williamr@2: /** Pointer to a 16 bit chunk that is being read from the store.*/ williamr@2: TDes16* iChunk16; williamr@2: /** Pointer to a 8 bit chunk that is being read from the store.*/ williamr@2: TDes8* iChunk8; williamr@2: /** Indicates whether the Rfile is commited or not.*/ williamr@2: TBool iIsCommitted; williamr@2: williamr@2: /** Indicates whether the chunk being read is last.*/ williamr@2: TBool iIsLastChunk; williamr@2: /** Indicates whether call to DoRunl was initiated by PreviousChunkL method.*/ williamr@2: TBool iPrevChunk; williamr@2: /** Indicates whether call to DoRunl was initiated by 8 bit PreviousChunkL and NextChunkL methods.*/ williamr@2: TBool iRetrieving8bit; williamr@2: /** Enum indicating if RFile is being written or read */ williamr@2: enum {EMsvFileReading, EMsvFileWriting} iMsvFileStatus; williamr@2: CCnvCharacterSetConverter::TAvailability iAvailable; williamr@2: //Containes current position of the Rfile williamr@2: TInt iCurrentFilePos; williamr@2: }; williamr@2: williamr@2: #endif//__CMSVPLAINBODYTEXT_H__