3 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
4 // All rights reserved.
5 // This component and the accompanying materials are made available
6 // 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
7 // which accompanies this distribution, and is available
8 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
10 // Initial Contributors:
11 // Nokia Corporation - initial contribution.
18 #ifndef __CMSVPLAINBODYTEXT_H__
19 #define __CMSVPLAINBODYTEXT_H__
28 class CParaFormatLayer;
29 class CCharFormatLayer;
30 class CCnvCharacterSetConverter;
33 This class encapsulates plainbody text information for storage within the
34 Message Store.It also populates a CRichText object with the 8 bit data
35 decoded to the specified character set.If a character set is not specified,
36 then the default character set is used.
41 class CMsvPlainBodyText : public CMsgActive
44 static CMsvPlainBodyText* NewL(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId, TMsvId aMessageId, RFs& aFs);
45 static CMsvPlainBodyText* NewL(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TMsvId aMessageId, RFs& aFs, TInt aChunkLength);
47 IMPORT_C ~CMsvPlainBodyText();
49 IMPORT_C void StoreChunkL(const TDesC8& aChunk, TRequestStatus& aStatus);
50 IMPORT_C void StoreChunkL(const TDesC8& aChunk);
52 IMPORT_C void StoreChunkL(const TDesC16& aChunk, TRequestStatus& aStatus);
53 IMPORT_C void StoreChunkL(const TDesC16& aChunk);
55 IMPORT_C void StoreRichTextAsPlainTextL(CRichText& aRichText);
57 IMPORT_C void CommitL();
59 IMPORT_C void NextChunkL(TDes8& aChunk, TRequestStatus& aStatus);
60 IMPORT_C void NextChunkL(TDes8& aChunk);
62 IMPORT_C void NextChunkL(TDes16& aChunk, TRequestStatus& aStatus);
63 IMPORT_C void NextChunkL(TDes16& aChunk);
65 IMPORT_C void PreviousChunkL(TDes8& aChunk, TRequestStatus& aStatus);
66 IMPORT_C void PreviousChunkL(TDes8& aChunk);
68 IMPORT_C void PreviousChunkL(TDes16& aChunk, TRequestStatus& aStatus);
69 IMPORT_C void PreviousChunkL(TDes16& aChunk);
72 IMPORT_C void SetCharacterSetL(const TUint aCharset);
73 IMPORT_C TUint CharacterSet();
74 IMPORT_C TUint DefaultCharacterSet();
79 CMsvPlainBodyText(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId, TMsvId aMessageId, RFs& aFs);
80 void ConstructWriteL();
82 CMsvPlainBodyText(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore,TMsvId aMessageId, RFs& aFs,TInt aChunkLength);
83 void ConstructReadL();
85 void PrepareToConvertL();
86 void ConvertChunkToUnicodeForStoreL(const TDesC8& aChunk);
87 TInt ConvertChunkToUnicodeForRestoreL();
88 void ExtractNextChunkFromRichText(TDes16& aChunk);
89 void ExtractPreviousChunkFromRichText(TDes16& aChunk);
96 /** To access APIs related to RFile operations.*/
97 MMsvStoreManager& iMsvStoreManager;
99 /** Indicates whether to store text as 8 bit or 16 bit.*/
101 /** The charset of the body text*/
103 TUint iDefaultCharsetId;
105 /** The RFile Path.*/
110 /** The RFile to which body text is written.*/
112 /** Character converter for 8 to 16 bit conversion.*/
113 CCnvCharacterSetConverter* iConverter;
114 CRichText* iRichText;
115 CParaFormatLayer* iParaLayer;
116 CCharFormatLayer* iCharLayer;
117 TInt iReadChunkLength;
118 /** Temporary buffer created to Store chunk while it is being written aynchronously.*/
120 /** Buffer used to read data from RFile.*/
121 RBuf8 iRfileReadBuf8;
122 /** Pointer to 8-bit buffer that needs to be written to RFile.*/
123 TPtrC8 iRfileWritePtr8;
124 /** The position from where to extract data in CRichText*/
126 /** Contains the size of the chunk that will be read or write in the RFile*/
127 TInt iChunkMaxLength;
128 /** Contains the remaining unconverted Unicode Data*/
129 HBufC8* iRemainingUnConvertedData;
130 /** Array that stores the start positions of each chunk,in Rfile*/
131 RArray<TInt> iStartPosOfEachChunkInFile;
132 /** Contains the start position of the next chunk*/
133 TInt iStartPosOfNextChunk;
134 /** Contains the remaining converted Unicode Data*/
135 RBuf16 iRemainingConvertedData;
136 /** Pointer to a 16 bit chunk that is being read from the store.*/
138 /** Pointer to a 8 bit chunk that is being read from the store.*/
140 /** Indicates whether the Rfile is commited or not.*/
143 /** Indicates whether the chunk being read is last.*/
145 /** Indicates whether call to DoRunl was initiated by PreviousChunkL method.*/
147 /** Indicates whether call to DoRunl was initiated by 8 bit PreviousChunkL and NextChunkL methods.*/
148 TBool iRetrieving8bit;
149 /** Enum indicating if RFile is being written or read */
150 enum {EMsvFileReading, EMsvFileWriting} iMsvFileStatus;
151 CCnvCharacterSetConverter::TAvailability iAvailable;
152 //Containes current position of the Rfile
153 TInt iCurrentFilePos;
156 #endif//__CMSVPLAINBODYTEXT_H__