epoc32/include/mw/cmsvplainbodytext.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/cmsvplainbodytext.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
// CMSVPLAINBODYTEXT.H
williamr@2
     2
williamr@2
     3
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     4
// All rights reserved.
williamr@2
     5
// This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     7
// which accompanies this distribution, and is available
williamr@2
     8
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     9
//
williamr@2
    10
// Initial Contributors:
williamr@2
    11
// Nokia Corporation - initial contribution.
williamr@2
    12
//
williamr@2
    13
// Contributors:
williamr@2
    14
//
williamr@2
    15
// Description:
williamr@2
    16
//
williamr@2
    17
williamr@2
    18
#ifndef __CMSVPLAINBODYTEXT_H__
williamr@2
    19
#define __CMSVPLAINBODYTEXT_H__
williamr@2
    20
williamr@2
    21
williamr@2
    22
#include <msvstore.h>
williamr@2
    23
#include <mentact.h>
williamr@2
    24
#include <charconv.h>
williamr@2
    25
williamr@2
    26
class CMsvStore;
williamr@2
    27
class CRichText;
williamr@2
    28
class CParaFormatLayer;
williamr@2
    29
class CCharFormatLayer;
williamr@2
    30
class CCnvCharacterSetConverter;
williamr@2
    31
williamr@2
    32
/**
williamr@2
    33
This class encapsulates plainbody text information for storage within the
williamr@2
    34
Message Store.It also populates a CRichText object with the 8 bit data
williamr@2
    35
decoded to the specified character set.If a character set is not specified,
williamr@2
    36
then the default character set is used.
williamr@2
    37
williamr@2
    38
@publishedAll
williamr@2
    39
@released
williamr@2
    40
*/
williamr@2
    41
class CMsvPlainBodyText : public CMsgActive
williamr@2
    42
	{
williamr@2
    43
public:
williamr@2
    44
	static CMsvPlainBodyText* NewL(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId, TMsvId aMessageId, RFs& aFs);
williamr@2
    45
	static CMsvPlainBodyText* NewL(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TMsvId aMessageId, RFs& aFs, TInt aChunkLength);
williamr@2
    46
williamr@2
    47
	IMPORT_C ~CMsvPlainBodyText();
williamr@2
    48
williamr@2
    49
	IMPORT_C void StoreChunkL(const TDesC8& aChunk, TRequestStatus& aStatus);
williamr@2
    50
	IMPORT_C void StoreChunkL(const TDesC8& aChunk);
williamr@2
    51
williamr@2
    52
	IMPORT_C void StoreChunkL(const TDesC16& aChunk, TRequestStatus& aStatus);
williamr@2
    53
	IMPORT_C void StoreChunkL(const TDesC16& aChunk);
williamr@2
    54
williamr@2
    55
	IMPORT_C void StoreRichTextAsPlainTextL(CRichText& aRichText);
williamr@2
    56
williamr@2
    57
	IMPORT_C void CommitL();
williamr@2
    58
williamr@2
    59
	IMPORT_C void NextChunkL(TDes8& aChunk, TRequestStatus& aStatus);
williamr@2
    60
	IMPORT_C void NextChunkL(TDes8& aChunk);
williamr@2
    61
williamr@2
    62
	IMPORT_C void NextChunkL(TDes16& aChunk, TRequestStatus& aStatus);
williamr@2
    63
	IMPORT_C void NextChunkL(TDes16& aChunk);
williamr@2
    64
williamr@2
    65
	IMPORT_C void PreviousChunkL(TDes8& aChunk, TRequestStatus& aStatus);
williamr@2
    66
	IMPORT_C void PreviousChunkL(TDes8& aChunk);
williamr@2
    67
williamr@2
    68
	IMPORT_C void PreviousChunkL(TDes16& aChunk, TRequestStatus& aStatus);
williamr@2
    69
	IMPORT_C void PreviousChunkL(TDes16& aChunk);
williamr@2
    70
williamr@2
    71
williamr@2
    72
	IMPORT_C void SetCharacterSetL(const TUint aCharset);
williamr@2
    73
	IMPORT_C TUint CharacterSet();
williamr@2
    74
	IMPORT_C TUint DefaultCharacterSet();
williamr@2
    75
williamr@2
    76
 	IMPORT_C TInt Size();
williamr@2
    77
williamr@2
    78
private:
williamr@2
    79
	CMsvPlainBodyText(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore, TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId, TMsvId aMessageId, RFs& aFs);
williamr@2
    80
	void ConstructWriteL();
williamr@2
    81
williamr@2
    82
	CMsvPlainBodyText(MMsvStoreManager& aMsvStoreManager, CMsvStore& aStore,TMsvId aMessageId, RFs& aFs,TInt aChunkLength);
williamr@2
    83
	void ConstructReadL();
williamr@2
    84
williamr@2
    85
	void PrepareToConvertL();
williamr@2
    86
	void ConvertChunkToUnicodeForStoreL(const TDesC8& aChunk);
williamr@2
    87
	TInt ConvertChunkToUnicodeForRestoreL();
williamr@2
    88
	void ExtractNextChunkFromRichText(TDes16& aChunk);
williamr@2
    89
	void ExtractPreviousChunkFromRichText(TDes16& aChunk);
williamr@2
    90
	void RevertL();
williamr@2
    91
	void DoRunL();
williamr@2
    92
	void DoComplete();
williamr@2
    93
	void DoCancel();
williamr@2
    94
williamr@2
    95
private:
williamr@2
    96
	/** To access APIs related to RFile operations.*/
williamr@2
    97
	MMsvStoreManager& 			  iMsvStoreManager;
williamr@2
    98
	CMsvStore& 					  iStore;
williamr@2
    99
	/** Indicates whether to store text as 8 bit or 16 bit.*/
williamr@2
   100
	TBool 						  iIs8Bit;
williamr@2
   101
	/** The charset of the body text*/
williamr@2
   102
	TUint 						  iCharsetId;
williamr@2
   103
 	TUint 					 	  iDefaultCharsetId;
williamr@2
   104
williamr@2
   105
 	/** The RFile Path.*/
williamr@2
   106
	HBufC*	 					  iFilePath;
williamr@2
   107
  	TMsvId 						  iMessageId;
williamr@2
   108
	RFs& 						  iFSession;
williamr@2
   109
williamr@2
   110
	/** The RFile to which body text is written.*/
williamr@2
   111
	RFile 						  iFile;
williamr@2
   112
	/** Character converter for 8 to 16 bit conversion.*/
williamr@2
   113
	CCnvCharacterSetConverter* 	  iConverter;
williamr@2
   114
	CRichText* 					  iRichText;
williamr@2
   115
	CParaFormatLayer* 			  iParaLayer;
williamr@2
   116
	CCharFormatLayer* 			  iCharLayer;
williamr@2
   117
	TInt 						  iReadChunkLength;
williamr@2
   118
	/** Temporary buffer created to Store chunk while it is being written aynchronously.*/
williamr@2
   119
	RBuf16	 					  iTempChunk16;
williamr@2
   120
	/** Buffer used to read data from RFile.*/
williamr@2
   121
	RBuf8 						  iRfileReadBuf8;
williamr@2
   122
	/** Pointer to 8-bit buffer that needs to be written to RFile.*/
williamr@2
   123
	TPtrC8 						  iRfileWritePtr8;
williamr@2
   124
	/** The position from where to extract data in CRichText*/
williamr@2
   125
	TInt 						  iPos;
williamr@2
   126
	/** Contains the size of the chunk that will be read or write in the RFile*/
williamr@2
   127
	TInt 					 	  iChunkMaxLength;
williamr@2
   128
	/** Contains the remaining unconverted Unicode Data*/
williamr@2
   129
	HBufC8* 					  iRemainingUnConvertedData;
williamr@2
   130
	/** Array that stores the start positions of each chunk,in Rfile*/
williamr@2
   131
	RArray<TInt> 			 	  iStartPosOfEachChunkInFile;
williamr@2
   132
	/** Contains the start position of the next chunk*/
williamr@2
   133
	TInt 						  iStartPosOfNextChunk;
williamr@2
   134
	/** Contains the remaining converted Unicode Data*/
williamr@2
   135
	RBuf16						  iRemainingConvertedData;
williamr@2
   136
	/** Pointer to a 16 bit chunk that is being read from the store.*/
williamr@2
   137
	TDes16*	 					  iChunk16;
williamr@2
   138
	/** Pointer to a 8 bit chunk that is being read from the store.*/
williamr@2
   139
	TDes8* 						  iChunk8;
williamr@2
   140
	/** Indicates whether the Rfile is commited or not.*/
williamr@2
   141
	TBool 						  iIsCommitted;
williamr@2
   142
williamr@2
   143
	/** Indicates whether the chunk being read is last.*/
williamr@2
   144
	TBool 						  iIsLastChunk;
williamr@2
   145
	/** Indicates whether call to DoRunl was initiated by PreviousChunkL method.*/
williamr@2
   146
	TBool 						  iPrevChunk;
williamr@2
   147
	/** Indicates whether call to DoRunl was initiated by 8 bit PreviousChunkL and NextChunkL methods.*/
williamr@2
   148
	TBool 						  iRetrieving8bit;
williamr@2
   149
	/** Enum indicating if RFile is being written or read */
williamr@2
   150
	enum {EMsvFileReading, EMsvFileWriting} iMsvFileStatus;
williamr@2
   151
	CCnvCharacterSetConverter::TAvailability iAvailable;
williamr@2
   152
	//Containes current position of the Rfile
williamr@2
   153
	TInt 						 iCurrentFilePos;
williamr@2
   154
	};
williamr@2
   155
williamr@2
   156
#endif//__CMSVPLAINBODYTEXT_H__