epoc32/include/miutmsg.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 miutmsg.h
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // 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
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __MIUTMSG_H__
       
    17 #define __MIUTMSG_H__
       
    18 
       
    19 #include <msvstd.h>
       
    20 #include <msvapi.h>			// TMsvEntry, CMsvOperation etc
       
    21 #include <mentact.h>		// CMsgActive
       
    22 #include <miuthdr.h>		// CImHeader, CImMimeHeader
       
    23 #include <txtrich.h>		// CRichText etc
       
    24 #include <miutdef.h>		// CImHeader, CImMimeHeader
       
    25 #include <mtmdef.h>
       
    26 #include <miutatch.h>
       
    27 #include <smtpset.h>
       
    28 #include <miutpars.h>		// TImMessageField
       
    29 
       
    30 #include <barsc.h>		// RResourceFile
       
    31 #include <conarc.h>
       
    32 #include <conlist.h>
       
    33 
       
    34 #include <txtmrtsr.h>
       
    35 
       
    36 
       
    37 
       
    38 //#include <mmsvattachmentmanager.h>
       
    39 #include <s32mem.h>
       
    40 
       
    41 //Content-Transfer-Encoding: types
       
    42 _LIT8(KMimeQuotedPrintable, " quoted-printable");
       
    43 _LIT8(KMimeApplOctet, " application/octet-stream");
       
    44 _LIT8(KMime7Bit, " 7-bit");
       
    45 _LIT8(KMimeBase64, " base64");
       
    46 _LIT8(KMimeMime, "MIME*");
       
    47 // Content-Disposition: types
       
    48 _LIT8(KMimeInline, "inline");
       
    49 _LIT8(KMimeAttachment, "attachment");
       
    50 // Content-Type: types
       
    51 _LIT8(KMimeMultipart, "multipart");
       
    52 _LIT8(KMimeText, "text");
       
    53 _LIT8(KMimeImage, "image");
       
    54 _LIT8(KMimeAudio, "audio");
       
    55 _LIT8(KMimeVideo, "video");
       
    56 _LIT8(KMimeApplication, "application");
       
    57 _LIT8(KMimeMessage, "message");
       
    58 // Content-Type: Multipart types
       
    59 _LIT8(KMimeMixed, "mixed");
       
    60 _LIT8(KMimeRelated, "related");
       
    61 _LIT8(KMimeAlternative, "alternative");
       
    62 _LIT8(KMimeEncrypted, "encrypted");
       
    63 _LIT8(KMimeParallel, "parallel");
       
    64 _LIT8(KMimeDigest, "digest");
       
    65 _LIT8(KMimeSigned, "signed");
       
    66 // Content-Type: Text types
       
    67 _LIT8(KMimeHtml, "html");
       
    68 _LIT8(KMimePlain, "plain");
       
    69 _LIT8(KMimeDirectory, "directory");
       
    70 // Content-Type: Message types
       
    71 _LIT8(KMimePartial, "partial");
       
    72 _LIT8(KMimeExternal, "external-body");
       
    73 _LIT8(KMimeRfc822, "rfc822");
       
    74 // Content-Type: Directory types
       
    75 _LIT8(KMimeProfile, "profile");
       
    76 _LIT(KMimeVCardExtension, ".vcf");
       
    77 _LIT8(KMimeVCalender, "vcalendar");
       
    78 // Content-Type: Image, Audio, Video, Application types
       
    79 _LIT8(KMimeBmp, "bmp");
       
    80 _LIT8(KMimeGif, "gif");
       
    81 _LIT8(KMimeJpeg, "jpeg");
       
    82 _LIT8(KMimeTiff, "tiff");
       
    83 _LIT8(KMimeWav, "wav");
       
    84 _LIT8(KMimeZip, "x-gzip");
       
    85 _LIT(KMimeHtmlExtension, ".html");
       
    86 _LIT(KMiutMsgDefaultHtmlFileName, "attachment.html");
       
    87 const TUid KUidMimeHeaders = {0x10204281};
       
    88 
       
    89 class CImHtmlConverter;
       
    90 
       
    91 class CImAttachmentManager;
       
    92 class CMsvMimeHeaders;
       
    93 class CMsvPlainBodyText;
       
    94 class CImPlainBodyText;
       
    95 
       
    96 class TImCreateMessageOptions
       
    97 /**
       
    98 @internalComponent
       
    99 @released
       
   100 */
       
   101 	{
       
   102 public:
       
   103 	TMsvPartList		iMsvPartList;
       
   104 	TMsvEmailTypeList	iMsvEmailTypeList;
       
   105 	TUid				iMessageType;
       
   106 	};
       
   107 
       
   108 // Mixin provides interface to Browser control to resolve MHTML URIs.
       
   109 
       
   110 class MImURITranslator
       
   111 /** Translates a URI in an MHTML message into a message body part file name.
       
   112 
       
   113 MHTML messages may contain multiple HTML body parts. Each of these body parts 
       
   114 is able to reference another body part within the same multipart structure, 
       
   115 or a body part within a parent multipart structure [RFC2110]. These references 
       
   116 are called URI's.
       
   117 
       
   118 When an MHTML message is parsed by the message engine, the HTML body of each 
       
   119 part is stored as a binary file. This interface provides a means of finding 
       
   120 the file name of the body part that corresponds to a given a URI.
       
   121 
       
   122 The URI resolving process has the potential to become time consuming, therefore 
       
   123 it is broken into two steps:
       
   124 
       
   125 Resolve asynchronously the relative URI into an absolute URI. The message 
       
   126 body parts are recursively searched in order to find an absolute base for 
       
   127 the relative URI [RFC2110, RFC1808]. 
       
   128 
       
   129 Once a relative URI has been resolved in to an absolute URI, then the message 
       
   130 is searched for a body part that corresponds to it [RFC2110].
       
   131 
       
   132 If no matching body part can be found, then the absolute URI is returned to 
       
   133 the caller in place of the filename. This absolute URI should be used to search 
       
   134 for the required data externally, for example by using HTTP.
       
   135 
       
   136 @see CImEmailMessage 
       
   137 @publishedAll
       
   138 @released
       
   139 */
       
   140 	{
       
   141 public:
       
   142 	/** Starts an asynchronous operation to resolve a specified URI.
       
   143 	
       
   144 	@param aMessageId The ID of the body part containing the URI which is to be 
       
   145 	resolved. CImEmailMessage::FindFirstHTMLPageL() can be used to find the aMessageId 
       
   146 	parameter for the first HTML page in a message.
       
   147 	@param rBase The base parameter from the HTML part that contains the URI to 
       
   148 	be resolved. If there is no base parameter in the HTML, then an empty descriptor 
       
   149 	should be passed in.
       
   150 	@param rURI The URI to be resolved.
       
   151 	@param aStatus Asynchronous status word */
       
   152 	virtual void FindUniversalResourceIdentifierL(TMsvId aMessageId, const TDesC& rBase, const TDesC& rURI, TRequestStatus &aStatus) = 0;
       
   153 
       
   154 	/** Gets the results after a search.
       
   155 	
       
   156 	@param aLinkedEntryId On return, the message ID of the linked body part, providing 
       
   157 	one is found. Note that you should keep a record of the returned message ID 
       
   158 	as it is required for resolving any URI's that may be found in the linked 
       
   159 	body part.
       
   160 	@param aFileFound On return, true if a linked body part has been found. It 
       
   161 	is set to false otherwise.
       
   162 	@return If successful, the filename that corresponds to the URI, or the absolute 
       
   163 	URI if no matching file can be found. If failed, NULL. */
       
   164 	virtual HBufC* GetUniversalResourceIdentifierL(TMsvId& aLinkedEntryId, TBool& aFileFound) const = 0;
       
   165 
       
   166 	/** Starts an asynchronous operation to resolve a specified URI.
       
   167 	
       
   168 	@param aMessageId The ID of the body part containing the URI which is to be 
       
   169 	resolved. CImEmailMessage::FindFirstHTMLPageFileHandleL() can be used to find the aMessageId 
       
   170 	parameter for the first HTML page in a message.
       
   171 	@param aBase The base parameter from the HTML part that contains the URI to 
       
   172 	be resolved. If there is no base parameter in the HTML, then an empty descriptor 
       
   173 	should be passed in.
       
   174 	@param aURI The URI to be resolved.
       
   175 	@param aStatus Asynchronous status word */
       
   176 	virtual void FindUniversalResourceIdentifierFileHandleL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus) = 0;
       
   177 	
       
   178 	/** Gets the results after a search.
       
   179 	
       
   180 	@param aLinkedEntryId On return, the message ID of the linked body part, providing 
       
   181 	one is found. Note that you should keep a record of the returned message ID 
       
   182 	as it is required for resolving any URI's that may be found in the linked 
       
   183 	body part.
       
   184 	
       
   185 	@param aFile On return, the file handle corresponding to the URI if successful.
       
   186 	If not successful, then this is not valid.
       
   187 	
       
   188 	@return KErrNone if successful and therefore aFile contains the filehandle 
       
   189 	that corresponds to the URI. An error code if unsuccessful and therefore 
       
   190 	aFile is not valid. */
       
   191 	virtual TInt GetUniversalResourceIdentifierFileHandle(TMsvId& aLinkedEntryId, RFile& aFile) const = 0;
       
   192 	};
       
   193 
       
   194 
       
   195 
       
   196 
       
   197 class CImMhtmlUriResolver;
       
   198 class CImRemoveMessagePart;
       
   199 class CImStoreMessagePart;
       
   200 class CImMimeHeader;
       
   201 
       
   202 class CImEmailMessage : public CMsgActive , public MImURITranslator
       
   203 /**
       
   204 This class can be used to manipulate new emails that
       
   205 have been created using CImEmailOperation when composing a message.
       
   206 
       
   207 Use an instance of this class to add attachments, MHTML parts, body
       
   208 text, and existing messages to a new message before it is to be sent.
       
   209 
       
   210 This class can also be used to retrieve the body text, list of attachments,
       
   211 and embedded messages from emails that have been downloaded and stored within
       
   212 the message store.
       
   213 
       
   214 If the store_8bit_body_text flag in imcm.rss is enabled, an instance of this class
       
   215 can be used to retrieve the original body text character set for a particular message.
       
   216 It can also be used to override the original body text character set so it will
       
   217 be decoded in a new character set next time it is viewed. 
       
   218 
       
   219 @see CImEmailOperation
       
   220 
       
   221 @publishedAll
       
   222 @released
       
   223 */
       
   224 	{
       
   225 public:
       
   226 	/** Flags that specify to process on any messages embedded in this message. */
       
   227 	enum TImEmailEntryType
       
   228 		{
       
   229 	/** Do not process embedded messages. */
       
   230 		EThisMessageOnly,
       
   231 	/** Process embedded messages. */
       
   232 		EThisMessageAndEmbeddedMessages  // i.e messages with in a message
       
   233 		};
       
   234 	/** Flags to specify types of attachment. */
       
   235 	enum TImAttachmentType
       
   236 		{
       
   237 	/** All attachments. */
       
   238 		EAllAttachments=0,	// all attachment files contained within this message (but not inside messages within this message)
       
   239 	/** VCards. */
       
   240 		EVCards,
       
   241 	/** VCalendars. */
       
   242 		EVCalendars,
       
   243 	/** VCards, VCalendars and ICalendars. */
       
   244 		EVEntries,			// ie VCards, VCalendars or ICalendars (or all three)
       
   245 	/** Encrypted. */
       
   246 		EEncrypted,
       
   247 	/** Signed. */
       
   248 		ESigned,
       
   249 	/** Secure. */
       
   250 		ESecure,			// ie Encrypted or signed (or both)
       
   251 	/** ICalendars. */
       
   252 		EICalendars
       
   253 		//.. add new items here
       
   254 		};
       
   255 public:
       
   256 	IMPORT_C static CImEmailMessage* NewL(CMsvEntry& aEntry);
       
   257 	IMPORT_C static CImEmailMessage* NewLC(CMsvEntry& aEntry);
       
   258 	IMPORT_C ~CImEmailMessage();
       
   259 
       
   260 	IMPORT_C void GetAttachmentsListL(TRequestStatus& aStatus, TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
       
   261 	IMPORT_C void GetAttachmentsListL(TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
       
   262 	void DoGetAttachmentsListL(TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
       
   263 
       
   264 	IMPORT_C void FindFirstHTMLPageL(TMsvId aMessageId, TRequestStatus& aStatus);
       
   265 
       
   266 	IMPORT_C const CMsvEntrySelection& Selection() const;	// return selection
       
   267 	IMPORT_C const TDesC8& ProgressL() const;
       
   268 
       
   269 	IMPORT_C void GetBodyTextL(TRequestStatus& aStatus, TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer,CCharFormatLayer& aCharLayer);
       
   270 	IMPORT_C void GetBodyTextL(TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer,CCharFormatLayer& aCharLayer);
       
   271 	void DoGetBodyTextInitL(TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer);
       
   272 
       
   273 	IMPORT_C void GetBodyTextEntryIdL(TRequestStatus& aStatus, TMsvId aMessageId, TImEmailEntryType aEntryType);
       
   274 	IMPORT_C void GetBodyTextEntryIdL(TMsvId aMessageId, TImEmailEntryType aEntryType);
       
   275 
       
   276 	IMPORT_C CImPlainBodyText* OpenPlainBodyTextForWriteL();
       
   277 	
       
   278 	IMPORT_C CImPlainBodyText* OpenPlainBodyTextForReadL(TImEmailEntryType aEntryType, TInt aChunkLength);
       
   279 	
       
   280 	IMPORT_C virtual void FindUniversalResourceIdentifierL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus);
       
   281 	IMPORT_C virtual HBufC* GetUniversalResourceIdentifierL(TMsvId& aLinkedEntryId, TBool& aFileFound) const;
       
   282 	IMPORT_C void FindUniversalResourceIdentifierFileHandleL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus);
       
   283 	IMPORT_C void FindFirstHTMLPageFileHandleL(TMsvId aMessageId, TRequestStatus& aStatus);
       
   284 	IMPORT_C virtual TInt GetUniversalResourceIdentifierFileHandle(TMsvId& aLinkedEntryId, RFile& aFile) const;
       
   285 	IMPORT_C MMsvAttachmentManager& AttachmentManager() const;
       
   286 	void AddAttachmentL(const TDesC& aFilePath, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
       
   287 	void AddAttachmentL(RFile& aFileHandle, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
       
   288 	void AddLinkedAttachmentL(const TDesC& aFilePath, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus);
       
   289 	void AddEntryAsAttachmentL(TMsvId aAttachmentEntryId, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus);
       
   290 	const RPointerArray<CMsvAttachment>& AttachmentInfoSelection() const;
       
   291 	void RemoveAttachmentL(TMsvAttachmentId aAttachmentId,TRequestStatus& aStatus) ;
       
   292 	void RemoveAttachedMessageL(TMsvAttachmentId aAttachmentId,TRequestStatus& aStatus) ;
       
   293 	void CreateAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
       
   294 	void CheckEntryAndResetStoreMessageL(TMsvId aMessageId);
       
   295 	void CheckEntryAndResetRemoveMessageL(TMsvId aMessageId);
       
   296 	void DoSetActive(TRequestStatus& aStatus);
       
   297 	CImMimeHeader* ConvertToImMimeHeadersL(CMsvMimeHeaders* aMimeHeaders);
       
   298 	CMsvMimeHeaders* ConvertToMsvMimeHeadersL(CImMimeHeader* aMimeHeader);
       
   299 	void AppendEntryAttachmentInfoL();
       
   300 	IMPORT_C void AddRelatedPartL(TMsvId aMessageId, const TDesC& aAttachmentFullName, TRequestStatus& aStatus, TMsvId aRelatedPartId, const TDesC8& aContentId);
       
   301 	IMPORT_C void StoreBodyTextL(TMsvId aMessageId, CRichText& aRichText, TRequestStatus& aStatus);
       
   302 	IMPORT_C void StoreBodyTextL(TMsvId aMessageId, CRichText& aRichText, TRequestStatus& aStatus, TBool aUsePlainTextStorage);
       
   303 	IMPORT_C void GetMessageDigestEntriesL(TRequestStatus& aStatus, TMsvId aMessageId);	
       
   304 	IMPORT_C void GetCharacterSetL(TMsvId aMessageId, TUint& aCharacterSetId, TBool& aOverride);
       
   305 	IMPORT_C void SetCharacterSetL(TMsvId aMessageId, TUint aCharacterSetId);
       
   306 	IMPORT_C void StoreBodyTextWithMimeHeaderL(TMsvId aMessageId, CRichText& aRichText, const CImMimeHeader& aMimeHeader, TRequestStatus& aStatus);
       
   307 
       
   308 	TMsvId EmailEntryId();
       
   309 
       
   310 private:
       
   311 	void DoRunL();
       
   312 	void DoCancel();
       
   313 	CImEmailMessage(CMsvEntry& aEntry);
       
   314 	void ConstructL();
       
   315 	void DoComplete(TInt&);
       
   316 	void DoStateL();
       
   317 
       
   318 	void Start(TRequestStatus& aStatus);
       
   319 	void StartL();
       
   320 
       
   321 	void Reset();
       
   322 	void ChangeMessageContextL();
       
   323 	void CompareChildrenAndPopulateSelL();
       
   324 	void AttachmentInfoL();
       
   325 	void AssembleBodyTextL();
       
   326 	void CheckAndInitialiseL(TMsvId aMessageId);
       
   327 	
       
   328 	void AppendAttachmentL();
       
   329 	TBool MessageDigestEntry();
       
   330 	TBool HandleDifferentFolderTypesL();
       
   331 	void GetTextForAlternateFolderL();
       
   332 	void GetTextForRelatedFolderL();
       
   333 	void GetAttachmentsForRelatedFolderL();
       
   334 	TBool GetBodyTextCharacterSetL();
       
   335 	TUint GetOverrideCharacterSetL();
       
   336 	TInt FindFilename(const CImMimeHeader& aMimeInfo, TPtrC8& aFilename);
       
   337 	void FindFilenameDecodeL(
       
   338 		const CImMimeHeader& aMimeInfo, TFileName& aFileName, TUint aCharset);	
       
   339 	void AppendAttachmentNameL();
       
   340 	void SetBodyTextCharacterSetL(TMsvId aEntryId, TUint8 aNewCharacterSetId);
       
   341 	void FindFirstBodyTextPartL(TMsvId aEntryId, TBool& found);
       
   342 
       
   343 	CImMimeHeader* FindAttachmentMimeHeaderL();
       
   344 	TMsvEntry FindIdEntryL(TMsvId aMessageId);
       
   345 
       
   346 	void DoGetBodyTextEntryIdL(TMsvId aMessageId, TImEmailEntryType aEntryType);
       
   347 
       
   348 
       
   349 	enum TImEmailMessageStates
       
   350 		{
       
   351 		EIdle=0,
       
   352 		ETextForThisMsg,
       
   353 		ETextForMsgDigest,
       
   354 		ETextEntryIdForThisMsg,
       
   355 		ETextEntryIdMsgDigest,
       
   356 		ETextForThisMsgGetCharacterSet,
       
   357 		EAttachmentsForThisMsg,
       
   358 		EAttachmentsForMsgDigest,
       
   359 		EMsgDigestEntries,
       
   360 		EResolveURI,
       
   361 		EStoreMessagePart,
       
   362 		ERemoveMessagePart,
       
   363 		EFinished
       
   364 		};
       
   365 	CMsvEntry& iClientEntry;
       
   366 	CMsvEntrySelection* iCompleteSel;
       
   367 	CMsvEntrySelection* iResultSel;
       
   368 
       
   369 	CRichText* iRichText;
       
   370 	CParaFormatLayer* iParaLayer;
       
   371 	CCharFormatLayer* iCharLayer;
       
   372 	TMsvId iParentMsgId;			// the Id passed into Getxxx() function representing the 'parent' message ID
       
   373 	TImEmailMessageStates iState;
       
   374 	TImAttachmentType iAttachmentType;
       
   375 	TMsvEmailEntry iEntry;
       
   376 	CImMhtmlUriResolver* iUriResolver;
       
   377 	TBool iUriFileFound;
       
   378 	CImStoreMessagePart* iStoreMessagePart;
       
   379 	CImRemoveMessagePart* iRemoveMessagePart;
       
   380 	TPckgBuf<TMsvId>	iProgress;
       
   381 	TImEmailEntryType iEntryType;
       
   382 	TBool iIsAMHTMLmessage;
       
   383 	TUint iCharacterSetId;
       
   384 	RFs iFs;
       
   385 	CDesCArray* iAttachmentNameList;
       
   386 	CImAttachmentManager* 			iAttachmentManager;
       
   387 	CMsvStore* 						iStore;
       
   388 	
       
   389 	// This is the entry Id using which the CImEmailMessage was created.
       
   390 	// store this , so that when the  message id to which attachment is 
       
   391 	// retrieved then the CIMEmailMessage is reset with this Id.
       
   392 	TMsvId							iEmailEntryId;
       
   393 	enum TImAttachmentStates
       
   394 		{
       
   395 		ENoAttachment=0,
       
   396 		EAddAttachment,
       
   397 		EDeleteAttachment,
       
   398 		ECreateAttachment
       
   399 		};	
       
   400 	TInt		iAttachmentState;
       
   401 	
       
   402 	};
       
   403 
       
   404 class CImRemoveMessagePart : public CMsvOperation
       
   405 /**
       
   406 @internalComponent
       
   407 @released
       
   408 */
       
   409 	{
       
   410 public:
       
   411 	static CImRemoveMessagePart* DeleteAttachmentL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TMsvId aAttachmentId);
       
   412 	static CImRemoveMessagePart* DeleteAttachedMessageL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TMsvId aAttachedMessageId);
       
   413 	~CImRemoveMessagePart();
       
   414 	const TDesC8& FinalProgress();
       
   415 	void DoCancel();
       
   416 	void RunL();
       
   417 	const TDesC8& ProgressL();		// returns NULL until operation completed - then returns MessageId
       
   418 	TMsvId RemovedAttachmentId();	
       
   419 private:
       
   420 	CImRemoveMessagePart(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId);
       
   421 	void ConstructL(TMsvId aAttachmentId);
       
   422 	void ErrorRecovery(TInt aError);
       
   423 	void SelectNextStateL();					// selects next state to go to
       
   424 	void ChangeStateL();					// initiates the next state operation
       
   425 	void SelectAndChangeToNextStateL();
       
   426 	void RequestComplete(TInt aError);
       
   427 	void Recover();							// leave message in a 'good' state
       
   428 
       
   429 	void CheckAttachmentParentTypeL();
       
   430 	void MoveOtherEntryToParentOfFolderL();
       
   431 	void DeleteAttachmentEntryL();
       
   432 	void DeleteFolderEntryL();
       
   433 	void CompleteRemoveMessagePartL();
       
   434 private:
       
   435 	enum TImRemoveMessagePartState
       
   436 		{
       
   437 		ECheckAttachmentParentType,
       
   438 		EMoveOtherEntryToParentOfFolder,
       
   439 		EDeleteAttachmentEntry,
       
   440 		EDeleteFolderEntry,
       
   441 		ECompleteRemoveMessagePart,
       
   442 		EFinished
       
   443 		};
       
   444 	CMsvEntry&			iMsvEntry;
       
   445 	CMsvOperation*		iMsvOperation;
       
   446 
       
   447 	CMsvEntrySelection*	iMessageEntrySelection;
       
   448 	CImEmailMessage*	iEmailMessage;
       
   449 
       
   450 	TInt				iState;
       
   451 	TPckgBuf<TMsvId>	iDataMember;
       
   452 	TMsvId				iMessageId;
       
   453 	TMsvId				iFolderToDeleteId;
       
   454 	TInt				iAttachmentSize;
       
   455 	TMsvId				iAttachmentId;
       
   456 	TMsvId				iEntryToMoveId;
       
   457 	};
       
   458 
       
   459 class CImStoreMessagePart : public CMsvOperation
       
   460 /**
       
   461 @internalComponent
       
   462 @released
       
   463 */
       
   464 	{
       
   465 public:
       
   466 	static CImStoreMessagePart* AddAttachmentL(TMsvId aMessageId, const TDesC& aFilePath, CMsvEntry& aMsvEntry,CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus );
       
   467 	static CImStoreMessagePart* AddEntryAsAttachmentL(TMsvId aMessageId,TMsvId aAttachmentMessageId, CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus);
       
   468 	static CImStoreMessagePart* AddAttachmentL(TMsvId aMessageId,RFile& aFile, CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
       
   469 	static CImStoreMessagePart* AddLinkedAttachmentL(TMsvId aMessageId,const TDesC& aFilePath, CMsvEntry& aMsvEntry,CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus );	
       
   470 	static CImStoreMessagePart* CreateAttachmentL(TMsvId aMessageId,const TDesC& aFileName, RFile& aAttachmentFile,CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
       
   471 	static CImStoreMessagePart* AddRelatedPartL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, const TDesC& aAttachmentFullName, TMsvId aRelatedPartId, const TDesC8& aContentId);
       
   472 	static CImStoreMessagePart* StoreBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CRichText& aRichText, TBool aUsePlainTextStorage = EFalse);
       
   473 	static CImStoreMessagePart* StoreBodyTextWithMimeHeaderL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CRichText& aRichText, const CImMimeHeader& aMimeHeader, TBool aUsePlainTextStorage = EFalse);
       
   474 	static CImStoreMessagePart* StorePlainBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TBool aUsePlainTextStorage = ETrue);
       
   475 	static CImStoreMessagePart* StorePlainBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CImMimeHeader& aMimeHeader, TBool aUsePlainTextStorage = ETrue);
       
   476 	~CImStoreMessagePart();
       
   477 	const TDesC8& FinalProgress();
       
   478 	void DoCancel();
       
   479 	void RunL();
       
   480 	const TDesC8& ProgressL();
       
   481 private:
       
   482 	enum TImMessagePart
       
   483 		{
       
   484 		EMessagePartAttachment,
       
   485 		EMessagePartBody,
       
   486 		EMessagePartMessageAttachment
       
   487 		};
       
   488 	void ConstructL(RFile& aFile);
       
   489 	void ConstructL(RFile& aFile,const TDesC& aAttachmentName);
       
   490 	void ConstructL(const TDesC& aAttachmentFullName, const TDesC8& aContentId);
       
   491 	void ConstructAttachmentInfo(CMsvAttachment* aAttachmentInfo,TInt aAttachmentCreationState);
       
   492 	CImStoreMessagePart(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TBool aUsePlainTextStorage = EFalse);
       
   493 	
       
   494 	void ConstructL();
       
   495 	void ConstructL(const TDesC& aAttachmentFullName);
       
   496 	void ConstructL(TMsvId aAttachmentMessageId);
       
   497 	void ConstructL(const TDesC& aAttachmentFullName, TMsvId aRelatedPartId, const TDesC8& aContentId);
       
   498 	void ConstructL(CRichText& aRichText);
       
   499 	void ConstructL(CRichText& aRichText, const CImMimeHeader& aMimeHeader);
       
   500 	void ConstructL(CImMimeHeader& aMimeHeader);
       
   501 	void ConstructL(TImMessagePart aMessagePart);
       
   502 	void ErrorRecovery(TInt error);
       
   503 	void SelectNextStateL();				// selects next state to go to
       
   504 	void ChangeStateL();					// initiates the next state operation
       
   505 	void SelectAndChangeToNextStateL();
       
   506 	void RequestComplete(TInt aError);
       
   507 	void Recover();
       
   508 
       
   509 	TBool HTMLMessage() const;
       
   510 	void SetHTMLMessage(TBool aFlag);
       
   511 	TBool MultipartMixedExists() const;
       
   512 	void SetMultipartMixedExists(TBool aFlag);
       
   513 	TBool MultipartMixedCreated() const;
       
   514 	void SetMultipartMixedCreated(TBool aFlag);
       
   515 	TBool MultipartAlternativeExists() const;
       
   516 	void SetMultipartAlternativeExists(TBool aFlag);
       
   517 	TBool MultipartAlternativeCreated() const;
       
   518 	void SetMultipartAlternativeCreated(TBool aFlag);
       
   519 	TBool MultipartRelatedExists() const;
       
   520 	void SetMultipartRelatedExists(TBool aFlag);
       
   521 	TBool MultipartRelatedCreated() const;
       
   522 	void SetMultipartRelatedCreated(TBool aFlag);
       
   523 	TBool TextPartExists() const;
       
   524 	void SetTextPartExists(TBool aFlag);
       
   525 	TBool TextPartCreated() const;
       
   526 	void SetTextPartCreated(TBool aFlag);
       
   527  	TBool AttachmentEntryCreated() const;
       
   528 	void SetAttachmentEntryCreated(TBool aFlag);
       
   529 
       
   530 	void FindMultipartRelatedFolderL();
       
   531 	void CheckForSubfolderL();
       
   532 	void CreateAttachmentEntryL();
       
   533 	void CopyOrigMessageToMessageL();
       
   534 	void CreateMultipartMixedFolderEntryL();
       
   535 	void CreateMultipartAlternativeFolderEntryL();
       
   536 	void CreateMultipartRelatedFolderEntryL();
       
   537 	void MoveOriginalMessageEntryChildrenToNewFolderL();
       
   538 	void CreateTextEntryL();
       
   539 	void StoreRichTextL();
       
   540 	void CompleteStoreMessagePartL();
       
   541 	void CreateHTMLEntryL();
       
   542 	void PrepareToStoreHTMLEntryTextL();
       
   543 	void StoreHTMLEntryTextL();
       
   544 	void RemoveHTMLEntryL();
       
   545 	void MoveTextEntryToAltFolderL();
       
   546 	TPtrC GetDefaultAttachmentName();
       
   547 	void OpenAndReadResourceFileL();
       
   548 	void StoreMimeHeaderL();
       
   549 	TBool CreateAttachmentMimeHeaderL(CImMimeHeader& aMimeHeader, const TDesC& aDetails);
       
   550 	void CreateFolderMimeHeaderL(CImMimeHeader& aMimeHeader);
       
   551 	void CreateMessageMimeHeaderL(CImMimeHeader& aMimeHeader);
       
   552 	void AddAttachmentL();
       
   553 	void AddAttachmentUsingFileHandleL();
       
   554 	void AddLinkedAttachmentL();
       
   555 	void AddEntryAsAttachmentL();	
       
   556 	void CreateAttachmentL();
       
   557 	void DoAttachmentStoreL();
       
   558 	TInt CheckMimeInAttachmentInfoL(CMsvMimeHeaders& aMsvMimeHeaders);
       
   559 	CImMimeHeader* ProcessAttachmentMimeHeadersL();
       
   560 	void SetEntryDetailsL(TMsvEntry& aEntry);
       
   561 	void StorePlainTextL();
       
   562 private:
       
   563 	enum TImStoreMessagePartState
       
   564 		{
       
   565 		EFindMultipartRelatedFolder,
       
   566 		ECheckForSubfolder,
       
   567 		ECreateAttachmentEntry,
       
   568 		EStoreAttachment,
       
   569 		ECopyOrigMessageToMessage,
       
   570 		ECreateMultipartMixedFolderEntry,
       
   571 		ECreateMultipartRelatedFolderEntry,
       
   572 		ECreateMultipartAlternativeFolderEntry,
       
   573 		EMoveOriginalMessageEntryChildrenToNewFolder,
       
   574 		ECreateTextEntry,
       
   575 		EStoreRichText,
       
   576 		ERemoveHTMLEntry,
       
   577 		EMoveTextToAlternativeFolder,
       
   578 		ECreateHTMLEntry,
       
   579 		EPrepareToStoreHTMLEntryText,
       
   580 		EStoreHTMLEntryText,
       
   581 		ECompleteStoreMessage,
       
   582 		EFinished
       
   583 		,EStoreHTMLTextInEntry,
       
   584 		EAddEntryAttachment	
       
   585 		};
       
   586 
       
   587 	enum TImStoreMessagePartFlags
       
   588 		{
       
   589 		KStoreMessagePartClearFlag							= 0x00000000,
       
   590 		KStoreMessagePartHTMLMessage						= 0x00000001,
       
   591 		KStoreMessagePartMultipartMixedExists				= 0x00000002,
       
   592 		KStoreMessagePartMultipartMixedCreated				= 0x00000004,
       
   593 		KStoreMessagePartMultipartAlternativeExists			= 0x00000008,
       
   594 		KStoreMessagePartMultipartAlternativeCreated		= 0x00000010,
       
   595 		KStoreMessagePartTextPartExists						= 0x00000020,
       
   596 		KStoreMessagePartTextPartCreated					= 0x00000040,
       
   597 		KStoreMessagePartAttachmentEntryCreated				= 0x00000080,
       
   598 		KStoreMessagePartOrigMessageEntryChildrenCopied		= 0x00000100,
       
   599 		KStoreMessagePartOrigMessageEntryChildrenDeleted	= 0x00000200,
       
   600 		KStoreMessagePartMultipartRelatedExists				= 0x00000400,
       
   601 		KStoreMessagePartMultipartRelatedCreated			= 0x00000800
       
   602 		};
       
   603 	CMsvEntry&			iMsvEntry;
       
   604 	CMsvOperation*		iMsvOperation;
       
   605 	
       
   606 	CRichText*			iRichTextToStore; // I don't own this object!
       
   607 	CImMimeHeader*		iMimeHeaderOfBodyText;
       
   608 	CRichText*			iRichText;
       
   609 	CFileMan*			iFileMan;
       
   610 	CMsvEntrySelection* iMessageEntrySelection;
       
   611 
       
   612 	TInt				iState;
       
   613 	TPckgBuf<TMsvId>	iDataMember;
       
   614 	TMsvId				iMessageId;
       
   615 	TImMessagePart		iMessagePart;
       
   616 	TMsvId				iMixFolderId;
       
   617 	TMsvId				iAltFolderId;
       
   618 	TMsvId				iRelFolderId;
       
   619 	HBufC*				iAttachmentFullName;
       
   620 	TInt				iAttachmentSize;
       
   621 	TMsvId				iAttachmentId;
       
   622 	TMsvId				iTextId;
       
   623 	TMsvId				iHtmlId;
       
   624 	TMsvId				iRelatedPartId;
       
   625 	TMsvId				iAttachmentMessageId;
       
   626 	TUint32				iFlags;
       
   627 	HBufC8*				iContentId;
       
   628 	CImEmailMessage*	iEmailMessage;
       
   629 
       
   630 	// Used when converting rich text to html
       
   631 	CParaFormatLayer*	iParaLayer;
       
   632 	CCharFormatLayer*	iCharLayer;
       
   633 	CImHtmlConverter* 	iHtmlConverter;
       
   634 	TBool iFinishedConvertingHTML;
       
   635 	CMsvAttachment*		iAttachmentInfo;
       
   636 	CMsvStore* 			iStore;
       
   637 	TInt 				iAttachmentCreateState;
       
   638 	TBool				iIsAddByFileHandle;
       
   639 	RFile*				iFileHandle;
       
   640 	RFile               iFile;
       
   641 	// Indicates whether to store message body as CRichText or plaintext.
       
   642 	TBool 				iUsePlainTextStorage;
       
   643 	// Size of the plain text body.
       
   644 	TInt				iSizeOfBody;
       
   645 	// Size of the Fwd'ed/ReplyTo plaintext body part.
       
   646 	TInt				iSizeFwdReplyBody;
       
   647 	// The error value returned when CRichText is populated with message body text.
       
   648 	TInt 				iRestoreErr;
       
   649 	enum TImAttachmentCreation
       
   650 		{
       
   651 		EAddAttachment,
       
   652 		EAddAttachmentUsingFileHandle,
       
   653 		EAddLinkedAttachment,
       
   654 		EAddEntryAsAttachment,
       
   655 		ECreateAttachment
       
   656 		};
       
   657 	};
       
   658 
       
   659 class CImEmailOperation : public CMsvOperation
       
   660 /** Provides simple email messages creation functions, including creation of new 
       
   661 messages, replies, forwarded messages, and receipts.
       
   662 
       
   663 Both plain-text and HTML messages, with or without attachments, can be created. 
       
   664 @publishedAll
       
   665 @released
       
   666 */
       
   667 	{
       
   668 public:
       
   669 	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   670 	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority = EPriorityStandard);
       
   671 	
       
   672 	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority , TBool aUsePlainTextStorage);
       
   673 	
       
   674 	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   675 	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   676 	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority);
       
   677 	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
       
   678 	IMPORT_C static CImEmailOperation* CreateForwardL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   679 	IMPORT_C static CImEmailOperation* CreateForwardL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   680 	IMPORT_C static CImEmailOperation* CreateForwardL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority = EPriorityStandard);
       
   681 	IMPORT_C static CImEmailOperation* CreateForwardL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
       
   682 	IMPORT_C static CImEmailOperation* CreateForwardAsAttachmentL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   683 	IMPORT_C static CImEmailOperation* CreateForwardAsAttachmentL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aSmtpServiceId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority = EPriorityStandard);
       
   684 	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   685 	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   686 	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority);
       
   687 	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
       
   688 	IMPORT_C ~CImEmailOperation();
       
   689 	IMPORT_C const TDesC8& FinalProgress();
       
   690 	void DoCancel();
       
   691 	void RunL();
       
   692 	const TDesC8& ProgressL();
       
   693 
       
   694 	static CImEmailOperation* CreateCopyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
       
   695 
       
   696 private:
       
   697 	enum TImEmailOperation 
       
   698 		{
       
   699 		ENew					= 0,
       
   700 		EReply					= 1,
       
   701 		EForward				= 2,
       
   702 		EReceipt				= 3,
       
   703 		EDeletingBadEmail		= 4,
       
   704 		ECopy					= 5,
       
   705 		EAttachOriginal			= 0x80,
       
   706 		EForwardAsAttachment    = EForward | EAttachOriginal,
       
   707 		EReplyAsAttachment		= EReply | EAttachOriginal
       
   708 		};
       
   709 
       
   710 private:
       
   711 	CImEmailOperation(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
       
   712 	void ConstructL(TMsvId aMessageId, const TDesC& aFormatString, TImEmailOperation aOperation);
       
   713 	void ConstructL(TMsvId aMessageId, TImEmailOperation aOperation);
       
   714 	void ConstructL(TImEmailOperation aOperation);
       
   715 	void OpenAndReadResourceFileL();
       
   716 	void SetSmtpServiceFromDefaultsL();
       
   717 	void SetSmtpServiceFromOriginalMessageL();
       
   718 	void ErrorRecovery(TInt error);
       
   719 	void SelectNextStateL();
       
   720 	void ProcessStateL();
       
   721 	void SelectAndProcessNextStateL();
       
   722 	void RequestComplete(TInt aError);
       
   723 	void CreateNewHeaderL();
       
   724 	void GetBodyTextL();
       
   725 	TInt RemoveIncompleteAttachments();
       
   726 	void CreateEntryDetails(TMsvEmailEntry& aMsvEmailEntry);
       
   727 	void CreateNewMessageL(TMsvId aDestinationId);
       
   728 	void CreateMultipartMixedFolderEntryL();
       
   729 	void CreateTextEntryL(TMsvId aFolderId);
       
   730 	void StoreBodyL();
       
   731 	void StorePlainBodyL();
       
   732 	void CheckForSignatureOrVCardL();
       
   733 	void CreateAttachmentEntryL();
       
   734 	void StoreAttachmentL();
       
   735 	void CreateMultipartAlternativeFolderEntryL();
       
   736 	void AppendHtmlAttachmentL();
       
   737 	void AttachOriginalMessageToNewMessageL();
       
   738 	void CompleteEmailOperationL();
       
   739 	void CreateHTMLEntryL();
       
   740 	void PrepareToStoreHTMLEntryTextL();
       
   741 	void StoreHTMLEntryTextL();
       
   742 	void CreateVCardAttachmentL();
       
   743 	void AddVCardAttachmentL();
       
   744 	void AddMessageAsAttachmentL();
       
   745 	TPtrC GetDefaultAttachmentName();
       
   746 	void RestoreSmtpSettingsL();
       
   747 	TMsvId ServiceId();
       
   748 	TBool NeedMultipartMixedFolder() const;
       
   749 	void ReadDefaultHtmlAttachmentNameL(TDes& aFileName);
       
   750 	void CreateDefaultAttachmentL();
       
   751 	void AddMessageAttachmentInfoL(TMsvId aAttachmentMessageId);
       
   752 	void ResetStoreL();
       
   753 	void CreateAddressListStringL(HBufC*& aListBuffer, const CDesCArray& aAddressArray);
       
   754 	void RestoreOriginalHeaderL();
       
   755 	void SetBodyHeaderFormatL();
       
   756 	static void ClosePlainBodyTextArray(TAny* aPtr);
       
   757 	void StorePlainTextL();
       
   758 	TInt GetPlainBodyTextSizeL();
       
   759 	
       
   760 private:
       
   761 	enum TImEmailOperationState
       
   762 		{
       
   763 		ECreateNewHeader,
       
   764 		EGetBodyText,
       
   765 		EGetAttachmentList,
       
   766 		EGetMessageDigest,
       
   767 		ECreateNewMessageEntry,
       
   768 		ECheckMultipartMixedFolderRequired,
       
   769 		ECreateMultipartMixedFolderEntry,
       
   770 		ECheckMultipartAlternativeFolderRequired,
       
   771 		ECreateMultipartAlternativeFolderEntry,
       
   772 		ECheckTextEntryRequired,
       
   773 		ECreateTextEntry,
       
   774 		EStoreBody,
       
   775 		ECheckVCardRequired,
       
   776 		ECreateVCardAttachment,
       
   777 		EAddVCardAttachment,
       
   778 		ECheckHTMLEntryRequired,
       
   779 		ECreateHTMLEntry,
       
   780 		EPrepareToStoreHTMLEntryText,
       
   781 		EStoreHTMLEntryText,
       
   782 		ECheckAttachOriginalMessageRequired,
       
   783 		EAttachOriginalMessage,
       
   784 		ECheckHTMLPageRequired,
       
   785 		EFindHTMLPage,
       
   786 		ECopyHTMLPartToAttachment,
       
   787 		ECheckAttachmentsRequired,
       
   788 		ECreateAttachmentEntry,
       
   789 		EStoreAttachment,
       
   790 		ECheckEmbeddedMessagesRequired,
       
   791 		EAddEmbeddedMessagesAsAttachments,
       
   792 		ECompleteEmailOperation,
       
   793 		EFinished
       
   794 		,ECreateDefaultHtmlAttachment,
       
   795 		EStoreHTMLTextInEntry,
       
   796 		EAddMessageAttachmentInfo
       
   797 		};
       
   798 
       
   799 	// Flags specifying format of body header information to include
       
   800 	// in reply and forwarded email addresses
       
   801 	enum TImBodyHeaderFormat
       
   802 		{
       
   803 		ENoToCcInfo=0,
       
   804 		EToOnly,
       
   805 		ECcOnly,
       
   806 		EToAndCc
       
   807 		};
       
   808 	
       
   809 	CMsvEntry* iMsvEntry;
       
   810 	CMsvOperation* iMsvOperation;
       
   811 	
       
   812 	CImHeader* iNewHeader;
       
   813 	CParaFormatLayer* iParaLayer;
       
   814 	CCharFormatLayer* iCharLayer;
       
   815 	CRichText* iRichText;
       
   816 	CImEmailMessage* iEmailMessage;
       
   817 	HBufC* iFormatString;
       
   818 	CFileMan* iFileMan;
       
   819 	CImSmtpSettings* iSmtpSettings;
       
   820 	TInt iState;
       
   821 	TImEmailOperation iOperation;
       
   822 	TMsvId iDestinationId;
       
   823 	TMsvId iMultipartMixedId;
       
   824 	TMsvId iMultipartAlternativeId;
       
   825 	TMsvId iOrigMessageId;
       
   826 	TMsvId iNewMessageId;
       
   827 	TMsvId iSmtpServiceId;
       
   828 	TMsvId iAttachedMessageId;
       
   829 	TUid iMsgType;
       
   830 	TMsvPartList iPartList;
       
   831 	TMsvEmailTypeList iMsvEmailTypeList;
       
   832 	TInt iAttachmentCount;
       
   833 	TInt iTotalAttachments;
       
   834 	TPckgBuf<TMsvId> iDataMember;
       
   835 	HBufC* iBodyHeaderFormatString;
       
   836 	HBufC* iBodyHeaderDateTimeFormatString;
       
   837 	HBufC* iBodyHeaderToString;
       
   838 	HBufC* iBodyHeaderCcString;
       
   839 	HBufC* iBodyHeader;
       
   840 	HBufC* iUserEmailAddress;
       
   841 	TInt iRichTextSize;
       
   842 	TInt iVCardAndHtmlSize;
       
   843 	TBool iOrigMessageHtml;
       
   844 	TBool iHtmlNoTextAlt;
       
   845 	TInt iEmbeddedMessagesToProcess;
       
   846 	TImMessageField iMessageField;
       
   847 
       
   848 	// for MIME messages:
       
   849 	TBool iCreateHtmlMessage;
       
   850 	TBool iMultipartMixedFolderCreated;
       
   851 	TBool iMultipartAlternativeFolderCreated;
       
   852 	TMsvId iTextId;
       
   853 	TMsvId iHtmlId;
       
   854 	TMsvId iVcardId;
       
   855 
       
   856 	// Used when converting rich text to html
       
   857 	CImHtmlConverter* iHtmlConverter;
       
   858 	TBool iFinishedConvertingHTML;
       
   859 
       
   860 	// Relating to adding Signature and/or Vcard to an email
       
   861 	TBool iNeedToAddVCardAttachment;
       
   862 	HBufC* iDefaultVCardNameFormatString;
       
   863 	TStreamId iVcardStoreId;
       
   864 	CStreamStore* iVcardStore;
       
   865 	CRichText* iSignatureText;
       
   866 	TFileName iFileName;
       
   867 	TImAttachmentFile iAttachmentFile;
       
   868 
       
   869 	// PCMail
       
   870 	TMsvId iPCMailServiceId;
       
   871 	RPointerArray<CMsvAttachment>	iAttachmentInfoList;
       
   872 	// set this anytime during the object life cycle attachment manager was used
       
   873 	TBool iAttachmentMgrUsed;
       
   874 	CMsvStore* iStore;
       
   875 	RFile iFile;
       
   876 
       
   877 	TImBodyHeaderFormat iBodyHeaderFormat;
       
   878 	CImHeader* iOriginalHeader;
       
   879 	/** Indicates if the body text entry is plain text */
       
   880 	TBool  iUsePlainTextStorage;
       
   881 	// The error value returned when CRichText is populated with message body text.
       
   882 	TInt iRestoreErr;
       
   883 	};
       
   884 
       
   885 
       
   886 class CImHtmlConverter : public CBase
       
   887 /**
       
   888 @internalComponent
       
   889 @released
       
   890 */
       
   891 	{
       
   892 public:
       
   893 	static CImHtmlConverter* CImHtmlConverter::NewL(CMsvEntry& aMsvEntry, 
       
   894 								   CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer);
       
   895 	~CImHtmlConverter();
       
   896 	void PrepareToStoreHTMLEntryTextL(TMsvId& aHtmlId, const TMsvId aTextId);
       
   897 	void ResetStoreL();
       
   898 	void ResetStoreWithoutCommit();
       
   899 	TBool StoreHTMLEntryTextAL(TRequestStatus& aStatus);
       
   900 	CMsvOperation* ChangeHTMLTextInEnrtyL(TRequestStatus& aStatus);
       
   901 	
       
   902 	void ReadDefaultAttachmentNameL( RResourceFile& resourceFile);
       
   903 	TInt Size() const;
       
   904 
       
   905 private:
       
   906 	CImHtmlConverter(CMsvEntry&	aMsvEntry, CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer);
       
   907 	TFileName HtmlFilename(CMsvEntry& aEntry, TPtrC aFileName);
       
   908 	TPtrC GetDefaultAttachmentName();
       
   909 	void ConstructL();
       
   910 
       
   911 private:
       
   912 	CMsvEntry&			iMsvEntry;
       
   913 	CParaFormatLayer&	iParaLayer;
       
   914 	CCharFormatLayer&	iCharLayer;
       
   915 
       
   916 	CConverterBase*		iToHTMLConverter;
       
   917 	CCnaConverterList*	iConverterList;
       
   918 
       
   919 	TMsvId				iTextId;
       
   920 	TMsvId				iHtmlId;
       
   921 	TInt				iSize;
       
   922 	HBufC*				iDefaultAttachmentName;
       
   923 	CRichText*			iRichText;
       
   924 	RDesReadStream 		iSourceStream;
       
   925 	RFileWriteStream	iTargetStream;
       
   926 	CMsvStore*			iStore;
       
   927 	RFile 				iFile;
       
   928 	};
       
   929 
       
   930 class CImStoreResolver : public CBase, public MRichTextStoreResolver
       
   931 /**
       
   932 @internalComponent
       
   933 @released
       
   934 */
       
   935 	{
       
   936 public:
       
   937 	CImStoreResolver(CStreamStore* aStore);
       
   938 	~CImStoreResolver();
       
   939 	//
       
   940 private:
       
   941 	const CStreamStore& StreamStoreL(TInt aPos)const;
       
   942 	//
       
   943 private:
       
   944 	CStreamStore* iStore;
       
   945 	};
       
   946 
       
   947 
       
   948 
       
   949 
       
   950 #endif // __MIUTMSG_H__