epoc32/include/mw/cmsvplainbodytext.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mw/cmsvplainbodytext.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,156 @@
     1.4 +// CMSVPLAINBODYTEXT.H
     1.5 +
     1.6 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +// All rights reserved.
     1.8 +// This component and the accompanying materials are made available
     1.9 +// 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
    1.10 +// which accompanies this distribution, and is available
    1.11 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +//
    1.13 +// Initial Contributors:
    1.14 +// Nokia Corporation - initial contribution.
    1.15 +//
    1.16 +// Contributors:
    1.17 +//
    1.18 +// Description:
    1.19 +//
    1.20 +
    1.21 +#ifndef __CMSVPLAINBODYTEXT_H__
    1.22 +#define __CMSVPLAINBODYTEXT_H__
    1.23 +
    1.24 +
    1.25 +#include <msvstore.h>
    1.26 +#include <mentact.h>
    1.27 +#include <charconv.h>
    1.28 +
    1.29 +class CMsvStore;
    1.30 +class CRichText;
    1.31 +class CParaFormatLayer;
    1.32 +class CCharFormatLayer;
    1.33 +class CCnvCharacterSetConverter;
    1.34 +
    1.35 +/**
    1.36 +This class encapsulates plainbody text information for storage within the
    1.37 +Message Store.It also populates a CRichText object with the 8 bit data
    1.38 +decoded to the specified character set.If a character set is not specified,
    1.39 +then the default character set is used.
    1.40 +
    1.41 +@publishedAll
    1.42 +@released
    1.43 +*/
    1.44 +class CMsvPlainBodyText : public CMsgActive
    1.45 +	{
    1.46 +public:
    1.47 +	static CMsvPlainBodyText* NewL(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId, TMsvId aMessageId, RFs& aFs);
    1.48 +	static CMsvPlainBodyText* NewL(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TMsvId aMessageId, RFs& aFs, TInt aChunkLength);
    1.49 +
    1.50 +	IMPORT_C ~CMsvPlainBodyText();
    1.51 +
    1.52 +	IMPORT_C void StoreChunkL(const TDesC8& aChunk, TRequestStatus& aStatus);
    1.53 +	IMPORT_C void StoreChunkL(const TDesC8& aChunk);
    1.54 +
    1.55 +	IMPORT_C void StoreChunkL(const TDesC16& aChunk, TRequestStatus& aStatus);
    1.56 +	IMPORT_C void StoreChunkL(const TDesC16& aChunk);
    1.57 +
    1.58 +	IMPORT_C void StoreRichTextAsPlainTextL(CRichText& aRichText);
    1.59 +
    1.60 +	IMPORT_C void CommitL();
    1.61 +
    1.62 +	IMPORT_C void NextChunkL(TDes8& aChunk, TRequestStatus& aStatus);
    1.63 +	IMPORT_C void NextChunkL(TDes8& aChunk);
    1.64 +
    1.65 +	IMPORT_C void NextChunkL(TDes16& aChunk, TRequestStatus& aStatus);
    1.66 +	IMPORT_C void NextChunkL(TDes16& aChunk);
    1.67 +
    1.68 +	IMPORT_C void PreviousChunkL(TDes8& aChunk, TRequestStatus& aStatus);
    1.69 +	IMPORT_C void PreviousChunkL(TDes8& aChunk);
    1.70 +
    1.71 +	IMPORT_C void PreviousChunkL(TDes16& aChunk, TRequestStatus& aStatus);
    1.72 +	IMPORT_C void PreviousChunkL(TDes16& aChunk);
    1.73 +
    1.74 +
    1.75 +	IMPORT_C void SetCharacterSetL(const TUint aCharset);
    1.76 +	IMPORT_C TUint CharacterSet();
    1.77 +	IMPORT_C TUint DefaultCharacterSet();
    1.78 +
    1.79 + 	IMPORT_C TInt Size();
    1.80 +
    1.81 +private:
    1.82 +	CMsvPlainBodyText(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId, TMsvId aMessageId, RFs& aFs);
    1.83 +	void ConstructWriteL();
    1.84 +
    1.85 +	CMsvPlainBodyText(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore,TMsvId aMessageId, RFs& aFs,TInt aChunkLength);
    1.86 +	void ConstructReadL();
    1.87 +
    1.88 +	void PrepareToConvertL();
    1.89 +	void ConvertChunkToUnicodeForStoreL(const TDesC8& aChunk);
    1.90 +	TInt ConvertChunkToUnicodeForRestoreL();
    1.91 +	void ExtractNextChunkFromRichText(TDes16& aChunk);
    1.92 +	void ExtractPreviousChunkFromRichText(TDes16& aChunk);
    1.93 +	void RevertL();
    1.94 +	void DoRunL();
    1.95 +	void DoComplete();
    1.96 +	void DoCancel();
    1.97 +
    1.98 +private:
    1.99 +	/** To access APIs related to RFile operations.*/
   1.100 +	MMsvStoreManager& 			  iMsvStoreManager;
   1.101 +	CMsvStore& 					  iStore;
   1.102 +	/** Indicates whether to store text as 8 bit or 16 bit.*/
   1.103 +	TBool 						  iIs8Bit;
   1.104 +	/** The charset of the body text*/
   1.105 +	TUint 						  iCharsetId;
   1.106 + 	TUint 					 	  iDefaultCharsetId;
   1.107 +
   1.108 + 	/** The RFile Path.*/
   1.109 +	HBufC*	 					  iFilePath;
   1.110 +  	TMsvId 						  iMessageId;
   1.111 +	RFs& 						  iFSession;
   1.112 +
   1.113 +	/** The RFile to which body text is written.*/
   1.114 +	RFile 						  iFile;
   1.115 +	/** Character converter for 8 to 16 bit conversion.*/
   1.116 +	CCnvCharacterSetConverter* 	  iConverter;
   1.117 +	CRichText* 					  iRichText;
   1.118 +	CParaFormatLayer* 			  iParaLayer;
   1.119 +	CCharFormatLayer* 			  iCharLayer;
   1.120 +	TInt 						  iReadChunkLength;
   1.121 +	/** Temporary buffer created to Store chunk while it is being written aynchronously.*/
   1.122 +	RBuf16	 					  iTempChunk16;
   1.123 +	/** Buffer used to read data from RFile.*/
   1.124 +	RBuf8 						  iRfileReadBuf8;
   1.125 +	/** Pointer to 8-bit buffer that needs to be written to RFile.*/
   1.126 +	TPtrC8 						  iRfileWritePtr8;
   1.127 +	/** The position from where to extract data in CRichText*/
   1.128 +	TInt 						  iPos;
   1.129 +	/** Contains the size of the chunk that will be read or write in the RFile*/
   1.130 +	TInt 					 	  iChunkMaxLength;
   1.131 +	/** Contains the remaining unconverted Unicode Data*/
   1.132 +	HBufC8* 					  iRemainingUnConvertedData;
   1.133 +	/** Array that stores the start positions of each chunk,in Rfile*/
   1.134 +	RArray<TInt> 			 	  iStartPosOfEachChunkInFile;
   1.135 +	/** Contains the start position of the next chunk*/
   1.136 +	TInt 						  iStartPosOfNextChunk;
   1.137 +	/** Contains the remaining converted Unicode Data*/
   1.138 +	RBuf16						  iRemainingConvertedData;
   1.139 +	/** Pointer to a 16 bit chunk that is being read from the store.*/
   1.140 +	TDes16*	 					  iChunk16;
   1.141 +	/** Pointer to a 8 bit chunk that is being read from the store.*/
   1.142 +	TDes8* 						  iChunk8;
   1.143 +	/** Indicates whether the Rfile is commited or not.*/
   1.144 +	TBool 						  iIsCommitted;
   1.145 +
   1.146 +	/** Indicates whether the chunk being read is last.*/
   1.147 +	TBool 						  iIsLastChunk;
   1.148 +	/** Indicates whether call to DoRunl was initiated by PreviousChunkL method.*/
   1.149 +	TBool 						  iPrevChunk;
   1.150 +	/** Indicates whether call to DoRunl was initiated by 8 bit PreviousChunkL and NextChunkL methods.*/
   1.151 +	TBool 						  iRetrieving8bit;
   1.152 +	/** Enum indicating if RFile is being written or read */
   1.153 +	enum {EMsvFileReading, EMsvFileWriting} iMsvFileStatus;
   1.154 +	CCnvCharacterSetConverter::TAvailability iAvailable;
   1.155 +	//Containes current position of the Rfile
   1.156 +	TInt 						 iCurrentFilePos;
   1.157 +	};
   1.158 +
   1.159 +#endif//__CMSVPLAINBODYTEXT_H__