epoc32/include/app/miutmsg.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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 "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // MIUTMSG.H
    15 //
    16 
    17 #ifndef __MIUTMSG_H__
    18 #define __MIUTMSG_H__
    19 
    20 #include <msvstd.h>
    21 #include <msvapi.h>			// TMsvEntry, CMsvOperation etc
    22 #include <mentact.h>		// CMsgActive
    23 #include <miuthdr.h>		// CImHeader, CImMimeHeader
    24 #include <txtrich.h>		// CRichText etc
    25 #include <miutdef.h>		// CImHeader, CImMimeHeader
    26 #include <mtmdef.h>
    27 #include <miutatch.h>
    28 #include <smtpset.h>
    29 #include <miutpars.h>		// TImMessageField
    30 
    31 #include <barsc.h>		// RResourceFile
    32 #include <conarc.h>
    33 #include <conlist.h>
    34 
    35 #include <txtmrtsr.h>
    36 
    37 //#include <mmsvattachmentmanager.h>
    38 #include <s32mem.h>
    39 
    40 //Content-Transfer-Encoding: types
    41 _LIT8(KMimeQuotedPrintable, " quoted-printable");
    42 _LIT8(KMimeApplOctet, " application/octet-stream");
    43 _LIT8(KMime7Bit, " 7-bit");
    44 _LIT8(KMimeBase64, " base64");
    45 _LIT8(KMimeMime, "MIME*");
    46 // Content-Disposition: types
    47 _LIT8(KMimeInline, "inline");
    48 _LIT8(KMimeAttachment, "attachment");
    49 // Content-Type: types
    50 _LIT8(KMimeMultipart, "multipart");
    51 _LIT8(KMimeText, "text");
    52 _LIT8(KMimeImage, "image");
    53 _LIT8(KMimeAudio, "audio");
    54 _LIT8(KMimeVideo, "video");
    55 _LIT8(KMimeApplication, "application");
    56 _LIT8(KMimeMessage, "message");
    57 // Content-Type: Multipart types
    58 _LIT8(KMimeMixed, "mixed");
    59 _LIT8(KMimeRelated, "related");
    60 _LIT8(KMimeAlternative, "alternative");
    61 _LIT8(KMimeEncrypted, "encrypted");
    62 _LIT8(KMimeParallel, "parallel");
    63 _LIT8(KMimeDigest, "digest");
    64 _LIT8(KMimeSigned, "signed");
    65 // Content-Type: Text types
    66 _LIT8(KMimeHtml, "html");
    67 _LIT8(KMimePlain, "plain");
    68 _LIT8(KMimeDirectory, "directory");
    69 // Content-Type: Message types
    70 _LIT8(KMimePartial, "partial");
    71 _LIT8(KMimeExternal, "external-body");
    72 _LIT8(KMimeRfc822, "rfc822");
    73 // Content-Type: Directory types
    74 _LIT8(KMimeProfile, "profile");
    75 _LIT(KMimeVCardExtension, ".vcf");
    76 _LIT8(KMimeVCalender, "vcalendar");
    77 // Content-Type: Image, Audio, Video, Application types
    78 _LIT8(KMimeBmp, "bmp");
    79 _LIT8(KMimeGif, "gif");
    80 _LIT8(KMimeJpeg, "jpeg");
    81 _LIT8(KMimeTiff, "tiff");
    82 _LIT8(KMimeWav, "wav");
    83 _LIT8(KMimeZip, "x-gzip");
    84 _LIT(KMimeHtmlExtension, ".html");
    85 _LIT(KMiutMsgDefaultHtmlFileName, "attachment.html");
    86 const TUid KUidMimeHeaders = {0x10204281};
    87 
    88 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS  
    89 #include "cimmessagepart.h"
    90 #endif
    91 
    92 class CImHtmlConverter;
    93 
    94 class CImAttachmentManager;
    95 class CMsvMimeHeaders;
    96 class CImPlainBodyText;
    97 
    98 // Mixin provides interface to Browser control to resolve MHTML URIs.
    99 
   100 class MImURITranslator
   101 /** Translates a URI in an MHTML message into a message body part file name.
   102 
   103 MHTML messages may contain multiple HTML body parts. Each of these body parts 
   104 is able to reference another body part within the same multipart structure, 
   105 or a body part within a parent multipart structure [RFC2110]. These references 
   106 are called URI's.
   107 
   108 When an MHTML message is parsed by the message engine, the HTML body of each 
   109 part is stored as a binary file. This interface provides a means of finding 
   110 the file name of the body part that corresponds to a given a URI.
   111 
   112 The URI resolving process has the potential to become time consuming, therefore 
   113 it is broken into two steps:
   114 
   115 Resolve asynchronously the relative URI into an absolute URI. The message 
   116 body parts are recursively searched in order to find an absolute base for 
   117 the relative URI [RFC2110, RFC1808]. 
   118 
   119 Once a relative URI has been resolved in to an absolute URI, then the message 
   120 is searched for a body part that corresponds to it [RFC2110].
   121 
   122 If no matching body part can be found, then the absolute URI is returned to 
   123 the caller in place of the filename. This absolute URI should be used to search 
   124 for the required data externally, for example by using HTTP.
   125 
   126 @see CImEmailMessage 
   127 @publishedAll
   128 @released
   129 */
   130 	{
   131 public:
   132 	/** Starts an asynchronous operation to resolve a specified URI.
   133 	
   134 	@param aMessageId The ID of the body part containing the URI which is to be 
   135 	resolved. CImEmailMessage::FindFirstHTMLPageL() can be used to find the aMessageId 
   136 	parameter for the first HTML page in a message.
   137 	@param rBase The base parameter from the HTML part that contains the URI to 
   138 	be resolved. If there is no base parameter in the HTML, then an empty descriptor 
   139 	should be passed in.
   140 	@param rURI The URI to be resolved.
   141 	@param aStatus Asynchronous status word */
   142 	virtual void FindUniversalResourceIdentifierL(TMsvId aMessageId, const TDesC& rBase, const TDesC& rURI, TRequestStatus &aStatus) = 0;
   143 
   144 	/** Gets the results after a search.
   145 	
   146 	@param aLinkedEntryId On return, the message ID of the linked body part, providing 
   147 	one is found. Note that you should keep a record of the returned message ID 
   148 	as it is required for resolving any URI's that may be found in the linked 
   149 	body part.
   150 	@param aFileFound On return, true if a linked body part has been found. It 
   151 	is set to false otherwise.
   152 	@return If successful, the filename that corresponds to the URI, or the absolute 
   153 	URI if no matching file can be found. If failed, NULL. */
   154 	virtual HBufC* GetUniversalResourceIdentifierL(TMsvId& aLinkedEntryId, TBool& aFileFound) const = 0;
   155 
   156 	/** Starts an asynchronous operation to resolve a specified URI.
   157 	
   158 	@param aMessageId The ID of the body part containing the URI which is to be 
   159 	resolved. CImEmailMessage::FindFirstHTMLPageFileHandleL() can be used to find the aMessageId 
   160 	parameter for the first HTML page in a message.
   161 	@param aBase The base parameter from the HTML part that contains the URI to 
   162 	be resolved. If there is no base parameter in the HTML, then an empty descriptor 
   163 	should be passed in.
   164 	@param aURI The URI to be resolved.
   165 	@param aStatus Asynchronous status word */
   166 	virtual void FindUniversalResourceIdentifierFileHandleL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus) = 0;
   167 	
   168 	/** Gets the results after a search.
   169 	
   170 	@param aLinkedEntryId On return, the message ID of the linked body part, providing 
   171 	one is found. Note that you should keep a record of the returned message ID 
   172 	as it is required for resolving any URI's that may be found in the linked 
   173 	body part.
   174 	
   175 	@param aFile On return, the file handle corresponding to the URI if successful.
   176 	If not successful, then this is not valid.
   177 	
   178 	@return KErrNone if successful and therefore aFile contains the filehandle 
   179 	that corresponds to the URI. An error code if unsuccessful and therefore 
   180 	aFile is not valid. */
   181 	virtual TInt GetUniversalResourceIdentifierFileHandle(TMsvId& aLinkedEntryId, RFile& aFile) const = 0;
   182 	};
   183 
   184 
   185 
   186 
   187 class CImMhtmlUriResolver;
   188 class CImRemoveMessagePart;
   189 class CImStoreMessagePart;
   190 class CImMimeHeader;
   191 
   192 class CImEmailMessage : public CMsgActive , public MImURITranslator
   193 /**
   194 This class can be used to manipulate new emails that
   195 have been created using CImEmailOperation when composing a message.
   196 
   197 Use an instance of this class to add attachments, MHTML parts, body
   198 text, and existing messages to a new message before it is to be sent.
   199 
   200 This class can also be used to retrieve the body text, list of attachments,
   201 and embedded messages from emails that have been downloaded and stored within
   202 the message store.
   203 
   204 If the store_8bit_body_text flag in imcm.rss is enabled, an instance of this class
   205 can be used to retrieve the original body text character set for a particular message.
   206 It can also be used to override the original body text character set so it will
   207 be decoded in a new character set next time it is viewed. 
   208 
   209 @see CImEmailOperation
   210 
   211 @publishedAll
   212 @released
   213 */
   214 	{
   215 public:
   216 	/** Flags that specify to process on any messages embedded in this message. */
   217 	enum TImEmailEntryType
   218 		{
   219 	/** Do not process embedded messages. */
   220 		EThisMessageOnly,
   221 	/** Process embedded messages. */
   222 		EThisMessageAndEmbeddedMessages  // i.e messages with in a message
   223 		};
   224 	/** Flags to specify types of attachment. */
   225 	enum TImAttachmentType
   226 		{
   227 	/** All attachments. */
   228 		EAllAttachments=0,	// all attachment files contained within this message (but not inside messages within this message)
   229 	/** VCards. */
   230 		EVCards,
   231 	/** VCalendars. */
   232 		EVCalendars,
   233 	/** VCards, VCalendars and ICalendars. */
   234 		EVEntries,			// ie VCards, VCalendars or ICalendars (or all three)
   235 	/** Encrypted. */
   236 		EEncrypted,
   237 	/** Signed. */
   238 		ESigned,
   239 	/** Secure. */
   240 		ESecure,			// ie Encrypted or signed (or both)
   241 	/** ICalendars. */
   242 		EICalendars
   243 		//.. add new items here
   244 		};
   245 public:
   246 	IMPORT_C static CImEmailMessage* NewL(CMsvEntry& aEntry);
   247 	IMPORT_C static CImEmailMessage* NewLC(CMsvEntry& aEntry);
   248 	IMPORT_C ~CImEmailMessage();
   249 
   250 	IMPORT_C void GetAttachmentsListL(TRequestStatus& aStatus, TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
   251 	IMPORT_C void GetAttachmentsListL(TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
   252 	void DoGetAttachmentsListL(TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
   253 
   254 	IMPORT_C void FindFirstHTMLPageL(TMsvId aMessageId, TRequestStatus& aStatus);
   255 
   256 	IMPORT_C const CMsvEntrySelection& Selection() const;	// return selection
   257 	IMPORT_C const TDesC8& ProgressL() const;
   258 
   259 	IMPORT_C void GetBodyTextL(TRequestStatus& aStatus, TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer,CCharFormatLayer& aCharLayer);
   260 	IMPORT_C void GetBodyTextL(TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer,CCharFormatLayer& aCharLayer);
   261 	void DoGetBodyTextInitL(TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer);
   262 
   263 	IMPORT_C void GetBodyTextEntryIdL(TRequestStatus& aStatus, TMsvId aMessageId, TImEmailEntryType aEntryType);
   264 	IMPORT_C void GetBodyTextEntryIdL(TMsvId aMessageId, TImEmailEntryType aEntryType);
   265 
   266 	IMPORT_C CImPlainBodyText* OpenPlainBodyTextForWriteL();
   267 	
   268 	IMPORT_C CImPlainBodyText* OpenPlainBodyTextForReadL(TImEmailEntryType aEntryType, TInt aChunkLength);
   269 	
   270 	IMPORT_C virtual void FindUniversalResourceIdentifierL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus);
   271 	IMPORT_C virtual HBufC* GetUniversalResourceIdentifierL(TMsvId& aLinkedEntryId, TBool& aFileFound) const;
   272 	IMPORT_C void FindUniversalResourceIdentifierFileHandleL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus);
   273 	IMPORT_C void FindFirstHTMLPageFileHandleL(TMsvId aMessageId, TRequestStatus& aStatus);
   274 	IMPORT_C virtual TInt GetUniversalResourceIdentifierFileHandle(TMsvId& aLinkedEntryId, RFile& aFile) const;
   275 	IMPORT_C MMsvAttachmentManager& AttachmentManager() const;
   276 	void AddAttachmentL(const TDesC& aFilePath, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
   277 	void AddAttachmentL(RFile& aFileHandle, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
   278 	void AddLinkedAttachmentL(const TDesC& aFilePath, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus);
   279 	void AddEntryAsAttachmentL(TMsvId aAttachmentEntryId, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus);
   280 	const RPointerArray<CMsvAttachment>& AttachmentInfoSelection() const;
   281 	void RemoveAttachmentL(TMsvAttachmentId aAttachmentId,TRequestStatus& aStatus) ;
   282 	void RemoveAttachedMessageL(TMsvAttachmentId aAttachmentId,TRequestStatus& aStatus) ;
   283 	void CreateAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
   284 	void CheckEntryAndResetStoreMessageL(TMsvId aMessageId);
   285 	void CheckEntryAndResetRemoveMessageL(TMsvId aMessageId);
   286 	void DoSetActive(TRequestStatus& aStatus);
   287 	CImMimeHeader* ConvertToImMimeHeadersL(CMsvMimeHeaders* aMimeHeaders);
   288 	CMsvMimeHeaders* ConvertToMsvMimeHeadersL(CImMimeHeader* aMimeHeader);
   289 	void AppendEntryAttachmentInfoL();
   290 	IMPORT_C void AddRelatedPartL(TMsvId aMessageId, const TDesC& aAttachmentFullName, TRequestStatus& aStatus, TMsvId aRelatedPartId, const TDesC8& aContentId);
   291 	IMPORT_C void StoreBodyTextL(TMsvId aMessageId, CRichText& aRichText, TRequestStatus& aStatus);
   292 	IMPORT_C void StoreBodyTextL(TMsvId aMessageId, CRichText& aRichText, TRequestStatus& aStatus, TBool aUsePlainTextStorage);
   293 	IMPORT_C void GetMessageDigestEntriesL(TRequestStatus& aStatus, TMsvId aMessageId);	
   294 	IMPORT_C void GetCharacterSetL(TMsvId aMessageId, TUint& aCharacterSetId, TBool& aOverride);
   295 	IMPORT_C void SetCharacterSetL(TMsvId aMessageId, TUint aCharacterSetId);
   296 	IMPORT_C void StoreBodyTextWithMimeHeaderL(TMsvId aMessageId, CRichText& aRichText, const CImMimeHeader& aMimeHeader, TRequestStatus& aStatus);
   297 
   298 	TMsvId EmailEntryId();
   299 
   300 private:
   301 	void DoRunL();
   302 	void DoCancel();
   303 	CImEmailMessage(CMsvEntry& aEntry);
   304 	void ConstructL();
   305 	void DoComplete(TInt&);
   306 	void DoStateL();
   307 
   308 	void Start(TRequestStatus& aStatus);
   309 	void StartL();
   310 
   311 	void Reset();
   312 	void ChangeMessageContextL();
   313 	void CompareChildrenAndPopulateSelL();
   314 	void AttachmentInfoL();
   315 	void AssembleBodyTextL();
   316 	void CheckAndInitialiseL(TMsvId aMessageId);
   317 	
   318 	void AppendAttachmentL();
   319 	TBool MessageDigestEntry();
   320 	TBool HandleDifferentFolderTypesL();
   321 	void GetTextForAlternateFolderL();
   322 	void GetTextForRelatedFolderL();
   323 	void GetAttachmentsForRelatedFolderL();
   324 	TBool GetBodyTextCharacterSetL();
   325 	TUint GetOverrideCharacterSetL();
   326 	TInt FindFilename(const CImMimeHeader& aMimeInfo, TPtrC8& aFilename);
   327 	void FindFilenameDecodeL(
   328 		const CImMimeHeader& aMimeInfo, TFileName& aFileName, TUint aCharset);	
   329 	void AppendAttachmentNameL();
   330 	void SetBodyTextCharacterSetL(TMsvId aEntryId, TUint8 aNewCharacterSetId);
   331 	void FindFirstBodyTextPartL(TMsvId aEntryId, TBool& found);
   332 
   333 	CImMimeHeader* FindAttachmentMimeHeaderL();
   334 	TMsvEntry FindIdEntryL(TMsvId aMessageId);
   335 
   336 	void DoGetBodyTextEntryIdL(TMsvId aMessageId, TImEmailEntryType aEntryType);
   337 
   338 
   339 	enum TImEmailMessageStates
   340 		{
   341 		EIdle=0,
   342 		ETextForThisMsg,
   343 		ETextForMsgDigest,
   344 		ETextEntryIdForThisMsg,
   345 		ETextEntryIdMsgDigest,
   346 		ETextForThisMsgGetCharacterSet,
   347 		EAttachmentsForThisMsg,
   348 		EAttachmentsForMsgDigest,
   349 		EMsgDigestEntries,
   350 		EResolveURI,
   351 		EStoreMessagePart,
   352 		ERemoveMessagePart,
   353 		EFinished
   354 		};
   355 	CMsvEntry& iClientEntry;
   356 	CMsvEntrySelection* iCompleteSel;
   357 	CMsvEntrySelection* iResultSel;
   358 
   359 	CRichText* iRichText;
   360 	CParaFormatLayer* iParaLayer;
   361 	CCharFormatLayer* iCharLayer;
   362 	TMsvId iParentMsgId;			// the Id passed into Getxxx() function representing the 'parent' message ID
   363 	TImEmailMessageStates iState;
   364 	TImAttachmentType iAttachmentType;
   365 	TMsvEmailEntry iEntry;
   366 	CImMhtmlUriResolver* iUriResolver;
   367 	TBool iUriFileFound;
   368 	CImStoreMessagePart* iStoreMessagePart;
   369 	CImRemoveMessagePart* iRemoveMessagePart;
   370 	TPckgBuf<TMsvId>	iProgress;
   371 	TImEmailEntryType iEntryType;
   372 	TBool iIsAMHTMLmessage;
   373 	TUint iCharacterSetId;
   374 	RFs iFs;
   375 	CDesCArray* iAttachmentNameList;
   376 	CImAttachmentManager* 			iAttachmentManager;
   377 	CMsvStore* 						iStore;
   378 	
   379 	// This is the entry Id using which the CImEmailMessage was created.
   380 	// store this , so that when the  message id to which attachment is 
   381 	// retrieved then the CIMEmailMessage is reset with this Id.
   382 	TMsvId							iEmailEntryId;
   383 	enum TImAttachmentStates
   384 		{
   385 		ENoAttachment=0,
   386 		EAddAttachment,
   387 		EDeleteAttachment,
   388 		ECreateAttachment
   389 		};	
   390 	TInt		iAttachmentState;
   391 	
   392 	};
   393 
   394 class CImEmailOperation : public CMsvOperation
   395 /** Provides simple email messages creation functions, including creation of new 
   396 messages, replies, forwarded messages, and receipts.
   397 
   398 Both plain-text and HTML messages, with or without attachments, can be created. 
   399 @publishedAll
   400 @released
   401 */
   402 	{
   403 public:
   404 	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   405 	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority = EPriorityStandard);
   406 	
   407 	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority , TBool aUsePlainTextStorage);
   408 	
   409 	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   410 	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   411 	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority);
   412 	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
   413 	IMPORT_C static CImEmailOperation* CreateForwardL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   414 	IMPORT_C static CImEmailOperation* CreateForwardL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   415 	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);
   416 	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);
   417 	IMPORT_C static CImEmailOperation* CreateForwardAsAttachmentL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   418 	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);
   419 	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   420 	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   421 	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority);
   422 	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
   423 	IMPORT_C ~CImEmailOperation();
   424 	IMPORT_C const TDesC8& FinalProgress();
   425 	void DoCancel();
   426 	void RunL();
   427 	const TDesC8& ProgressL();
   428 
   429 	static CImEmailOperation* CreateCopyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   430 
   431 private:
   432 	enum TImEmailOperation 
   433 		{
   434 		ENew					= 0,
   435 		EReply					= 1,
   436 		EForward				= 2,
   437 		EReceipt				= 3,
   438 		EDeletingBadEmail		= 4,
   439 		ECopy					= 5,
   440 		EAttachOriginal			= 0x80,
   441 		EForwardAsAttachment    = EForward | EAttachOriginal,
   442 		EReplyAsAttachment		= EReply | EAttachOriginal
   443 		};
   444 
   445 private:
   446 	CImEmailOperation(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
   447 	void ConstructL(TMsvId aMessageId, const TDesC& aFormatString, TImEmailOperation aOperation);
   448 	void ConstructL(TMsvId aMessageId, TImEmailOperation aOperation);
   449 	void ConstructL(TImEmailOperation aOperation);
   450 	void OpenAndReadResourceFileL();
   451 	void SetSmtpServiceFromDefaultsL();
   452 	void SetSmtpServiceFromOriginalMessageL();
   453 	void ErrorRecovery(TInt error);
   454 	void SelectNextStateL();
   455 	void ProcessStateL();
   456 	void SelectAndProcessNextStateL();
   457 	void RequestComplete(TInt aError);
   458 	void CreateNewHeaderL();
   459 	void GetBodyTextL();
   460 	TInt RemoveIncompleteAttachments();
   461 	void CreateEntryDetails(TMsvEmailEntry& aMsvEmailEntry);
   462 	void CreateNewMessageL(TMsvId aDestinationId);
   463 	void CreateMultipartMixedFolderEntryL();
   464 	void CreateTextEntryL(TMsvId aFolderId);
   465 	void StoreBodyL();
   466 	void StorePlainBodyL();
   467 	void CheckForSignatureOrVCardL();
   468 	void CreateAttachmentEntryL();
   469 	void StoreAttachmentL();
   470 	void CreateMultipartAlternativeFolderEntryL();
   471 	void AppendHtmlAttachmentL();
   472 	void AttachOriginalMessageToNewMessageL();
   473 	void CompleteEmailOperationL();
   474 	void CreateHTMLEntryL();
   475 	void PrepareToStoreHTMLEntryTextL();
   476 	void StoreHTMLEntryTextL();
   477 	void CreateVCardAttachmentL();
   478 	void AddVCardAttachmentL();
   479 	void AddMessageAsAttachmentL();
   480 	TPtrC GetDefaultAttachmentName();
   481 	void RestoreSmtpSettingsL();
   482 	TMsvId ServiceId();
   483 	TBool NeedMultipartMixedFolder() const;
   484 	void ReadDefaultHtmlAttachmentNameL(TDes& aFileName);
   485 	void CreateDefaultAttachmentL();
   486 	void AddMessageAttachmentInfoL(TMsvId aAttachmentMessageId);
   487 	void ResetStoreL();
   488 	void CreateAddressListStringL(HBufC*& aListBuffer, const CDesCArray& aAddressArray);
   489 	void RestoreOriginalHeaderL();
   490 	void SetBodyHeaderFormatL();
   491 	static void ClosePlainBodyTextArray(TAny* aPtr);
   492 	void StorePlainTextL();
   493 	TInt GetPlainBodyTextSizeL();
   494 	
   495 private:
   496 	enum TImEmailOperationState
   497 		{
   498 		ECreateNewHeader,
   499 		EGetBodyText,
   500 		EGetAttachmentList,
   501 		EGetMessageDigest,
   502 		ECreateNewMessageEntry,
   503 		ECheckMultipartMixedFolderRequired,
   504 		ECreateMultipartMixedFolderEntry,
   505 		ECheckMultipartAlternativeFolderRequired,
   506 		ECreateMultipartAlternativeFolderEntry,
   507 		ECheckTextEntryRequired,
   508 		ECreateTextEntry,
   509 		EStoreBody,
   510 		ECheckVCardRequired,
   511 		ECreateVCardAttachment,
   512 		EAddVCardAttachment,
   513 		ECheckHTMLEntryRequired,
   514 		ECreateHTMLEntry,
   515 		EPrepareToStoreHTMLEntryText,
   516 		EStoreHTMLEntryText,
   517 		ECheckAttachOriginalMessageRequired,
   518 		EAttachOriginalMessage,
   519 		ECheckHTMLPageRequired,
   520 		EFindHTMLPage,
   521 		ECopyHTMLPartToAttachment,
   522 		ECheckAttachmentsRequired,
   523 		ECreateAttachmentEntry,
   524 		EStoreAttachment,
   525 		ECheckEmbeddedMessagesRequired,
   526 		EAddEmbeddedMessagesAsAttachments,
   527 		ECompleteEmailOperation,
   528 		EFinished
   529 		,ECreateDefaultHtmlAttachment,
   530 		EStoreHTMLTextInEntry,
   531 		EAddMessageAttachmentInfo
   532 		};
   533 
   534 	// Flags specifying format of body header information to include
   535 	// in reply and forwarded email addresses
   536 	enum TImBodyHeaderFormat
   537 		{
   538 		ENoToCcInfo=0,
   539 		EToOnly,
   540 		ECcOnly,
   541 		EToAndCc
   542 		};
   543 	
   544 	CMsvEntry* iMsvEntry;
   545 	CMsvOperation* iMsvOperation;
   546 	
   547 	CImHeader* iNewHeader;
   548 	CParaFormatLayer* iParaLayer;
   549 	CCharFormatLayer* iCharLayer;
   550 	CRichText* iRichText;
   551 	CImEmailMessage* iEmailMessage;
   552 	HBufC* iFormatString;
   553 	CFileMan* iFileMan;
   554 	CImSmtpSettings* iSmtpSettings;
   555 	TInt iState;
   556 	TImEmailOperation iOperation;
   557 	TMsvId iDestinationId;
   558 	TMsvId iMultipartMixedId;
   559 	TMsvId iMultipartAlternativeId;
   560 	TMsvId iOrigMessageId;
   561 	TMsvId iNewMessageId;
   562 	TMsvId iSmtpServiceId;
   563 	TMsvId iAttachedMessageId;
   564 	TUid iMsgType;
   565 	TMsvPartList iPartList;
   566 	TMsvEmailTypeList iMsvEmailTypeList;
   567 	TInt iAttachmentCount;
   568 	TInt iTotalAttachments;
   569 	TPckgBuf<TMsvId> iDataMember;
   570 	HBufC* iBodyHeaderFormatString;
   571 	HBufC* iBodyHeaderDateTimeFormatString;
   572 	HBufC* iBodyHeaderToString;
   573 	HBufC* iBodyHeaderCcString;
   574 	HBufC* iBodyHeader;
   575 	HBufC* iUserEmailAddress;
   576 	TInt iRichTextSize;
   577 	TInt iVCardAndHtmlSize;
   578 	TBool iOrigMessageHtml;
   579 	TBool iHtmlNoTextAlt;
   580 	TInt iEmbeddedMessagesToProcess;
   581 	TImMessageField iMessageField;
   582 
   583 	// for MIME messages:
   584 	TBool iCreateHtmlMessage;
   585 	TBool iMultipartMixedFolderCreated;
   586 	TBool iMultipartAlternativeFolderCreated;
   587 	TMsvId iTextId;
   588 	TMsvId iHtmlId;
   589 	TMsvId iVcardId;
   590 
   591 	// Used when converting rich text to html
   592 	CImHtmlConverter* iHtmlConverter;
   593 	TBool iFinishedConvertingHTML;
   594 
   595 	// Relating to adding Signature and/or Vcard to an email
   596 	TBool iNeedToAddVCardAttachment;
   597 	HBufC* iDefaultVCardNameFormatString;
   598 	TStreamId iVcardStoreId;
   599 	CStreamStore* iVcardStore;
   600 	CRichText* iSignatureText;
   601 	TFileName iFileName;
   602 	TImAttachmentFile iAttachmentFile;
   603 
   604 	// PCMail
   605 	TMsvId iPCMailServiceId;
   606 	RPointerArray<CMsvAttachment>	iAttachmentInfoList;
   607 	// set this anytime during the object life cycle attachment manager was used
   608 	TBool iAttachmentMgrUsed;
   609 	CMsvStore* iStore;
   610 	RFile iFile;
   611 
   612 	TImBodyHeaderFormat iBodyHeaderFormat;
   613 	CImHeader* iOriginalHeader;
   614 	/** Indicates if the body text entry is plain text */
   615 	TBool  iUsePlainTextStorage;
   616 	// The error value returned when CRichText is populated with message body text.
   617 	TInt iRestoreErr;
   618 	};
   619 
   620 #endif // __MIUTMSG_H__