epoc32/include/app/miutmsg.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/app/miutmsg.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,950 @@
     1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// 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.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __MIUTMSG_H__
    1.20 +#define __MIUTMSG_H__
    1.21 +
    1.22 +#include <msvstd.h>
    1.23 +#include <msvapi.h>			// TMsvEntry, CMsvOperation etc
    1.24 +#include <mentact.h>		// CMsgActive
    1.25 +#include <miuthdr.h>		// CImHeader, CImMimeHeader
    1.26 +#include <txtrich.h>		// CRichText etc
    1.27 +#include <miutdef.h>		// CImHeader, CImMimeHeader
    1.28 +#include <mtmdef.h>
    1.29 +#include <miutatch.h>
    1.30 +#include <smtpset.h>
    1.31 +#include <miutpars.h>		// TImMessageField
    1.32 +
    1.33 +#include <barsc.h>		// RResourceFile
    1.34 +#include <conarc.h>
    1.35 +#include <conlist.h>
    1.36 +
    1.37 +#include <txtmrtsr.h>
    1.38 +
    1.39 +
    1.40 +
    1.41 +//#include <mmsvattachmentmanager.h>
    1.42 +#include <s32mem.h>
    1.43 +
    1.44 +//Content-Transfer-Encoding: types
    1.45 +_LIT8(KMimeQuotedPrintable, " quoted-printable");
    1.46 +_LIT8(KMimeApplOctet, " application/octet-stream");
    1.47 +_LIT8(KMime7Bit, " 7-bit");
    1.48 +_LIT8(KMimeBase64, " base64");
    1.49 +_LIT8(KMimeMime, "MIME*");
    1.50 +// Content-Disposition: types
    1.51 +_LIT8(KMimeInline, "inline");
    1.52 +_LIT8(KMimeAttachment, "attachment");
    1.53 +// Content-Type: types
    1.54 +_LIT8(KMimeMultipart, "multipart");
    1.55 +_LIT8(KMimeText, "text");
    1.56 +_LIT8(KMimeImage, "image");
    1.57 +_LIT8(KMimeAudio, "audio");
    1.58 +_LIT8(KMimeVideo, "video");
    1.59 +_LIT8(KMimeApplication, "application");
    1.60 +_LIT8(KMimeMessage, "message");
    1.61 +// Content-Type: Multipart types
    1.62 +_LIT8(KMimeMixed, "mixed");
    1.63 +_LIT8(KMimeRelated, "related");
    1.64 +_LIT8(KMimeAlternative, "alternative");
    1.65 +_LIT8(KMimeEncrypted, "encrypted");
    1.66 +_LIT8(KMimeParallel, "parallel");
    1.67 +_LIT8(KMimeDigest, "digest");
    1.68 +_LIT8(KMimeSigned, "signed");
    1.69 +// Content-Type: Text types
    1.70 +_LIT8(KMimeHtml, "html");
    1.71 +_LIT8(KMimePlain, "plain");
    1.72 +_LIT8(KMimeDirectory, "directory");
    1.73 +// Content-Type: Message types
    1.74 +_LIT8(KMimePartial, "partial");
    1.75 +_LIT8(KMimeExternal, "external-body");
    1.76 +_LIT8(KMimeRfc822, "rfc822");
    1.77 +// Content-Type: Directory types
    1.78 +_LIT8(KMimeProfile, "profile");
    1.79 +_LIT(KMimeVCardExtension, ".vcf");
    1.80 +_LIT8(KMimeVCalender, "vcalendar");
    1.81 +// Content-Type: Image, Audio, Video, Application types
    1.82 +_LIT8(KMimeBmp, "bmp");
    1.83 +_LIT8(KMimeGif, "gif");
    1.84 +_LIT8(KMimeJpeg, "jpeg");
    1.85 +_LIT8(KMimeTiff, "tiff");
    1.86 +_LIT8(KMimeWav, "wav");
    1.87 +_LIT8(KMimeZip, "x-gzip");
    1.88 +_LIT(KMimeHtmlExtension, ".html");
    1.89 +_LIT(KMiutMsgDefaultHtmlFileName, "attachment.html");
    1.90 +const TUid KUidMimeHeaders = {0x10204281};
    1.91 +
    1.92 +class CImHtmlConverter;
    1.93 +
    1.94 +class CImAttachmentManager;
    1.95 +class CMsvMimeHeaders;
    1.96 +class CMsvPlainBodyText;
    1.97 +class CImPlainBodyText;
    1.98 +
    1.99 +class TImCreateMessageOptions
   1.100 +/**
   1.101 +@internalComponent
   1.102 +@released
   1.103 +*/
   1.104 +	{
   1.105 +public:
   1.106 +	TMsvPartList		iMsvPartList;
   1.107 +	TMsvEmailTypeList	iMsvEmailTypeList;
   1.108 +	TUid				iMessageType;
   1.109 +	};
   1.110 +
   1.111 +// Mixin provides interface to Browser control to resolve MHTML URIs.
   1.112 +
   1.113 +class MImURITranslator
   1.114 +/** Translates a URI in an MHTML message into a message body part file name.
   1.115 +
   1.116 +MHTML messages may contain multiple HTML body parts. Each of these body parts 
   1.117 +is able to reference another body part within the same multipart structure, 
   1.118 +or a body part within a parent multipart structure [RFC2110]. These references 
   1.119 +are called URI's.
   1.120 +
   1.121 +When an MHTML message is parsed by the message engine, the HTML body of each 
   1.122 +part is stored as a binary file. This interface provides a means of finding 
   1.123 +the file name of the body part that corresponds to a given a URI.
   1.124 +
   1.125 +The URI resolving process has the potential to become time consuming, therefore 
   1.126 +it is broken into two steps:
   1.127 +
   1.128 +Resolve asynchronously the relative URI into an absolute URI. The message 
   1.129 +body parts are recursively searched in order to find an absolute base for 
   1.130 +the relative URI [RFC2110, RFC1808]. 
   1.131 +
   1.132 +Once a relative URI has been resolved in to an absolute URI, then the message 
   1.133 +is searched for a body part that corresponds to it [RFC2110].
   1.134 +
   1.135 +If no matching body part can be found, then the absolute URI is returned to 
   1.136 +the caller in place of the filename. This absolute URI should be used to search 
   1.137 +for the required data externally, for example by using HTTP.
   1.138 +
   1.139 +@see CImEmailMessage 
   1.140 +@publishedAll
   1.141 +@released
   1.142 +*/
   1.143 +	{
   1.144 +public:
   1.145 +	/** Starts an asynchronous operation to resolve a specified URI.
   1.146 +	
   1.147 +	@param aMessageId The ID of the body part containing the URI which is to be 
   1.148 +	resolved. CImEmailMessage::FindFirstHTMLPageL() can be used to find the aMessageId 
   1.149 +	parameter for the first HTML page in a message.
   1.150 +	@param rBase The base parameter from the HTML part that contains the URI to 
   1.151 +	be resolved. If there is no base parameter in the HTML, then an empty descriptor 
   1.152 +	should be passed in.
   1.153 +	@param rURI The URI to be resolved.
   1.154 +	@param aStatus Asynchronous status word */
   1.155 +	virtual void FindUniversalResourceIdentifierL(TMsvId aMessageId, const TDesC& rBase, const TDesC& rURI, TRequestStatus &aStatus) = 0;
   1.156 +
   1.157 +	/** Gets the results after a search.
   1.158 +	
   1.159 +	@param aLinkedEntryId On return, the message ID of the linked body part, providing 
   1.160 +	one is found. Note that you should keep a record of the returned message ID 
   1.161 +	as it is required for resolving any URI's that may be found in the linked 
   1.162 +	body part.
   1.163 +	@param aFileFound On return, true if a linked body part has been found. It 
   1.164 +	is set to false otherwise.
   1.165 +	@return If successful, the filename that corresponds to the URI, or the absolute 
   1.166 +	URI if no matching file can be found. If failed, NULL. */
   1.167 +	virtual HBufC* GetUniversalResourceIdentifierL(TMsvId& aLinkedEntryId, TBool& aFileFound) const = 0;
   1.168 +
   1.169 +	/** Starts an asynchronous operation to resolve a specified URI.
   1.170 +	
   1.171 +	@param aMessageId The ID of the body part containing the URI which is to be 
   1.172 +	resolved. CImEmailMessage::FindFirstHTMLPageFileHandleL() can be used to find the aMessageId 
   1.173 +	parameter for the first HTML page in a message.
   1.174 +	@param aBase The base parameter from the HTML part that contains the URI to 
   1.175 +	be resolved. If there is no base parameter in the HTML, then an empty descriptor 
   1.176 +	should be passed in.
   1.177 +	@param aURI The URI to be resolved.
   1.178 +	@param aStatus Asynchronous status word */
   1.179 +	virtual void FindUniversalResourceIdentifierFileHandleL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus) = 0;
   1.180 +	
   1.181 +	/** Gets the results after a search.
   1.182 +	
   1.183 +	@param aLinkedEntryId On return, the message ID of the linked body part, providing 
   1.184 +	one is found. Note that you should keep a record of the returned message ID 
   1.185 +	as it is required for resolving any URI's that may be found in the linked 
   1.186 +	body part.
   1.187 +	
   1.188 +	@param aFile On return, the file handle corresponding to the URI if successful.
   1.189 +	If not successful, then this is not valid.
   1.190 +	
   1.191 +	@return KErrNone if successful and therefore aFile contains the filehandle 
   1.192 +	that corresponds to the URI. An error code if unsuccessful and therefore 
   1.193 +	aFile is not valid. */
   1.194 +	virtual TInt GetUniversalResourceIdentifierFileHandle(TMsvId& aLinkedEntryId, RFile& aFile) const = 0;
   1.195 +	};
   1.196 +
   1.197 +
   1.198 +
   1.199 +
   1.200 +class CImMhtmlUriResolver;
   1.201 +class CImRemoveMessagePart;
   1.202 +class CImStoreMessagePart;
   1.203 +class CImMimeHeader;
   1.204 +
   1.205 +class CImEmailMessage : public CMsgActive , public MImURITranslator
   1.206 +/**
   1.207 +This class can be used to manipulate new emails that
   1.208 +have been created using CImEmailOperation when composing a message.
   1.209 +
   1.210 +Use an instance of this class to add attachments, MHTML parts, body
   1.211 +text, and existing messages to a new message before it is to be sent.
   1.212 +
   1.213 +This class can also be used to retrieve the body text, list of attachments,
   1.214 +and embedded messages from emails that have been downloaded and stored within
   1.215 +the message store.
   1.216 +
   1.217 +If the store_8bit_body_text flag in imcm.rss is enabled, an instance of this class
   1.218 +can be used to retrieve the original body text character set for a particular message.
   1.219 +It can also be used to override the original body text character set so it will
   1.220 +be decoded in a new character set next time it is viewed. 
   1.221 +
   1.222 +@see CImEmailOperation
   1.223 +
   1.224 +@publishedAll
   1.225 +@released
   1.226 +*/
   1.227 +	{
   1.228 +public:
   1.229 +	/** Flags that specify to process on any messages embedded in this message. */
   1.230 +	enum TImEmailEntryType
   1.231 +		{
   1.232 +	/** Do not process embedded messages. */
   1.233 +		EThisMessageOnly,
   1.234 +	/** Process embedded messages. */
   1.235 +		EThisMessageAndEmbeddedMessages  // i.e messages with in a message
   1.236 +		};
   1.237 +	/** Flags to specify types of attachment. */
   1.238 +	enum TImAttachmentType
   1.239 +		{
   1.240 +	/** All attachments. */
   1.241 +		EAllAttachments=0,	// all attachment files contained within this message (but not inside messages within this message)
   1.242 +	/** VCards. */
   1.243 +		EVCards,
   1.244 +	/** VCalendars. */
   1.245 +		EVCalendars,
   1.246 +	/** VCards, VCalendars and ICalendars. */
   1.247 +		EVEntries,			// ie VCards, VCalendars or ICalendars (or all three)
   1.248 +	/** Encrypted. */
   1.249 +		EEncrypted,
   1.250 +	/** Signed. */
   1.251 +		ESigned,
   1.252 +	/** Secure. */
   1.253 +		ESecure,			// ie Encrypted or signed (or both)
   1.254 +	/** ICalendars. */
   1.255 +		EICalendars
   1.256 +		//.. add new items here
   1.257 +		};
   1.258 +public:
   1.259 +	IMPORT_C static CImEmailMessage* NewL(CMsvEntry& aEntry);
   1.260 +	IMPORT_C static CImEmailMessage* NewLC(CMsvEntry& aEntry);
   1.261 +	IMPORT_C ~CImEmailMessage();
   1.262 +
   1.263 +	IMPORT_C void GetAttachmentsListL(TRequestStatus& aStatus, TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
   1.264 +	IMPORT_C void GetAttachmentsListL(TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
   1.265 +	void DoGetAttachmentsListL(TMsvId aMessageId, TImAttachmentType aAttachmentType,TImEmailEntryType aEntryType);
   1.266 +
   1.267 +	IMPORT_C void FindFirstHTMLPageL(TMsvId aMessageId, TRequestStatus& aStatus);
   1.268 +
   1.269 +	IMPORT_C const CMsvEntrySelection& Selection() const;	// return selection
   1.270 +	IMPORT_C const TDesC8& ProgressL() const;
   1.271 +
   1.272 +	IMPORT_C void GetBodyTextL(TRequestStatus& aStatus, TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer,CCharFormatLayer& aCharLayer);
   1.273 +	IMPORT_C void GetBodyTextL(TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer,CCharFormatLayer& aCharLayer);
   1.274 +	void DoGetBodyTextInitL(TMsvId aMessageId, TImEmailEntryType aEntryType, CRichText& aRichText,CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer);
   1.275 +
   1.276 +	IMPORT_C void GetBodyTextEntryIdL(TRequestStatus& aStatus, TMsvId aMessageId, TImEmailEntryType aEntryType);
   1.277 +	IMPORT_C void GetBodyTextEntryIdL(TMsvId aMessageId, TImEmailEntryType aEntryType);
   1.278 +
   1.279 +	IMPORT_C CImPlainBodyText* OpenPlainBodyTextForWriteL();
   1.280 +	
   1.281 +	IMPORT_C CImPlainBodyText* OpenPlainBodyTextForReadL(TImEmailEntryType aEntryType, TInt aChunkLength);
   1.282 +	
   1.283 +	IMPORT_C virtual void FindUniversalResourceIdentifierL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus);
   1.284 +	IMPORT_C virtual HBufC* GetUniversalResourceIdentifierL(TMsvId& aLinkedEntryId, TBool& aFileFound) const;
   1.285 +	IMPORT_C void FindUniversalResourceIdentifierFileHandleL(TMsvId aMessageId, const TDesC& aBase, const TDesC& aURI, TRequestStatus &aStatus);
   1.286 +	IMPORT_C void FindFirstHTMLPageFileHandleL(TMsvId aMessageId, TRequestStatus& aStatus);
   1.287 +	IMPORT_C virtual TInt GetUniversalResourceIdentifierFileHandle(TMsvId& aLinkedEntryId, RFile& aFile) const;
   1.288 +	IMPORT_C MMsvAttachmentManager& AttachmentManager() const;
   1.289 +	void AddAttachmentL(const TDesC& aFilePath, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
   1.290 +	void AddAttachmentL(RFile& aFileHandle, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
   1.291 +	void AddLinkedAttachmentL(const TDesC& aFilePath, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus);
   1.292 +	void AddEntryAsAttachmentL(TMsvId aAttachmentEntryId, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus);
   1.293 +	const RPointerArray<CMsvAttachment>& AttachmentInfoSelection() const;
   1.294 +	void RemoveAttachmentL(TMsvAttachmentId aAttachmentId,TRequestStatus& aStatus) ;
   1.295 +	void RemoveAttachedMessageL(TMsvAttachmentId aAttachmentId,TRequestStatus& aStatus) ;
   1.296 +	void CreateAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
   1.297 +	void CheckEntryAndResetStoreMessageL(TMsvId aMessageId);
   1.298 +	void CheckEntryAndResetRemoveMessageL(TMsvId aMessageId);
   1.299 +	void DoSetActive(TRequestStatus& aStatus);
   1.300 +	CImMimeHeader* ConvertToImMimeHeadersL(CMsvMimeHeaders* aMimeHeaders);
   1.301 +	CMsvMimeHeaders* ConvertToMsvMimeHeadersL(CImMimeHeader* aMimeHeader);
   1.302 +	void AppendEntryAttachmentInfoL();
   1.303 +	IMPORT_C void AddRelatedPartL(TMsvId aMessageId, const TDesC& aAttachmentFullName, TRequestStatus& aStatus, TMsvId aRelatedPartId, const TDesC8& aContentId);
   1.304 +	IMPORT_C void StoreBodyTextL(TMsvId aMessageId, CRichText& aRichText, TRequestStatus& aStatus);
   1.305 +	IMPORT_C void StoreBodyTextL(TMsvId aMessageId, CRichText& aRichText, TRequestStatus& aStatus, TBool aUsePlainTextStorage);
   1.306 +	IMPORT_C void GetMessageDigestEntriesL(TRequestStatus& aStatus, TMsvId aMessageId);	
   1.307 +	IMPORT_C void GetCharacterSetL(TMsvId aMessageId, TUint& aCharacterSetId, TBool& aOverride);
   1.308 +	IMPORT_C void SetCharacterSetL(TMsvId aMessageId, TUint aCharacterSetId);
   1.309 +	IMPORT_C void StoreBodyTextWithMimeHeaderL(TMsvId aMessageId, CRichText& aRichText, const CImMimeHeader& aMimeHeader, TRequestStatus& aStatus);
   1.310 +
   1.311 +	TMsvId EmailEntryId();
   1.312 +
   1.313 +private:
   1.314 +	void DoRunL();
   1.315 +	void DoCancel();
   1.316 +	CImEmailMessage(CMsvEntry& aEntry);
   1.317 +	void ConstructL();
   1.318 +	void DoComplete(TInt&);
   1.319 +	void DoStateL();
   1.320 +
   1.321 +	void Start(TRequestStatus& aStatus);
   1.322 +	void StartL();
   1.323 +
   1.324 +	void Reset();
   1.325 +	void ChangeMessageContextL();
   1.326 +	void CompareChildrenAndPopulateSelL();
   1.327 +	void AttachmentInfoL();
   1.328 +	void AssembleBodyTextL();
   1.329 +	void CheckAndInitialiseL(TMsvId aMessageId);
   1.330 +	
   1.331 +	void AppendAttachmentL();
   1.332 +	TBool MessageDigestEntry();
   1.333 +	TBool HandleDifferentFolderTypesL();
   1.334 +	void GetTextForAlternateFolderL();
   1.335 +	void GetTextForRelatedFolderL();
   1.336 +	void GetAttachmentsForRelatedFolderL();
   1.337 +	TBool GetBodyTextCharacterSetL();
   1.338 +	TUint GetOverrideCharacterSetL();
   1.339 +	TInt FindFilename(const CImMimeHeader& aMimeInfo, TPtrC8& aFilename);
   1.340 +	void FindFilenameDecodeL(
   1.341 +		const CImMimeHeader& aMimeInfo, TFileName& aFileName, TUint aCharset);	
   1.342 +	void AppendAttachmentNameL();
   1.343 +	void SetBodyTextCharacterSetL(TMsvId aEntryId, TUint8 aNewCharacterSetId);
   1.344 +	void FindFirstBodyTextPartL(TMsvId aEntryId, TBool& found);
   1.345 +
   1.346 +	CImMimeHeader* FindAttachmentMimeHeaderL();
   1.347 +	TMsvEntry FindIdEntryL(TMsvId aMessageId);
   1.348 +
   1.349 +	void DoGetBodyTextEntryIdL(TMsvId aMessageId, TImEmailEntryType aEntryType);
   1.350 +
   1.351 +
   1.352 +	enum TImEmailMessageStates
   1.353 +		{
   1.354 +		EIdle=0,
   1.355 +		ETextForThisMsg,
   1.356 +		ETextForMsgDigest,
   1.357 +		ETextEntryIdForThisMsg,
   1.358 +		ETextEntryIdMsgDigest,
   1.359 +		ETextForThisMsgGetCharacterSet,
   1.360 +		EAttachmentsForThisMsg,
   1.361 +		EAttachmentsForMsgDigest,
   1.362 +		EMsgDigestEntries,
   1.363 +		EResolveURI,
   1.364 +		EStoreMessagePart,
   1.365 +		ERemoveMessagePart,
   1.366 +		EFinished
   1.367 +		};
   1.368 +	CMsvEntry& iClientEntry;
   1.369 +	CMsvEntrySelection* iCompleteSel;
   1.370 +	CMsvEntrySelection* iResultSel;
   1.371 +
   1.372 +	CRichText* iRichText;
   1.373 +	CParaFormatLayer* iParaLayer;
   1.374 +	CCharFormatLayer* iCharLayer;
   1.375 +	TMsvId iParentMsgId;			// the Id passed into Getxxx() function representing the 'parent' message ID
   1.376 +	TImEmailMessageStates iState;
   1.377 +	TImAttachmentType iAttachmentType;
   1.378 +	TMsvEmailEntry iEntry;
   1.379 +	CImMhtmlUriResolver* iUriResolver;
   1.380 +	TBool iUriFileFound;
   1.381 +	CImStoreMessagePart* iStoreMessagePart;
   1.382 +	CImRemoveMessagePart* iRemoveMessagePart;
   1.383 +	TPckgBuf<TMsvId>	iProgress;
   1.384 +	TImEmailEntryType iEntryType;
   1.385 +	TBool iIsAMHTMLmessage;
   1.386 +	TUint iCharacterSetId;
   1.387 +	RFs iFs;
   1.388 +	CDesCArray* iAttachmentNameList;
   1.389 +	CImAttachmentManager* 			iAttachmentManager;
   1.390 +	CMsvStore* 						iStore;
   1.391 +	
   1.392 +	// This is the entry Id using which the CImEmailMessage was created.
   1.393 +	// store this , so that when the  message id to which attachment is 
   1.394 +	// retrieved then the CIMEmailMessage is reset with this Id.
   1.395 +	TMsvId							iEmailEntryId;
   1.396 +	enum TImAttachmentStates
   1.397 +		{
   1.398 +		ENoAttachment=0,
   1.399 +		EAddAttachment,
   1.400 +		EDeleteAttachment,
   1.401 +		ECreateAttachment
   1.402 +		};	
   1.403 +	TInt		iAttachmentState;
   1.404 +	
   1.405 +	};
   1.406 +
   1.407 +class CImRemoveMessagePart : public CMsvOperation
   1.408 +/**
   1.409 +@internalComponent
   1.410 +@released
   1.411 +*/
   1.412 +	{
   1.413 +public:
   1.414 +	static CImRemoveMessagePart* DeleteAttachmentL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TMsvId aAttachmentId);
   1.415 +	static CImRemoveMessagePart* DeleteAttachedMessageL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TMsvId aAttachedMessageId);
   1.416 +	~CImRemoveMessagePart();
   1.417 +	const TDesC8& FinalProgress();
   1.418 +	void DoCancel();
   1.419 +	void RunL();
   1.420 +	const TDesC8& ProgressL();		// returns NULL until operation completed - then returns MessageId
   1.421 +	TMsvId RemovedAttachmentId();	
   1.422 +private:
   1.423 +	CImRemoveMessagePart(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId);
   1.424 +	void ConstructL(TMsvId aAttachmentId);
   1.425 +	void ErrorRecovery(TInt aError);
   1.426 +	void SelectNextStateL();					// selects next state to go to
   1.427 +	void ChangeStateL();					// initiates the next state operation
   1.428 +	void SelectAndChangeToNextStateL();
   1.429 +	void RequestComplete(TInt aError);
   1.430 +	void Recover();							// leave message in a 'good' state
   1.431 +
   1.432 +	void CheckAttachmentParentTypeL();
   1.433 +	void MoveOtherEntryToParentOfFolderL();
   1.434 +	void DeleteAttachmentEntryL();
   1.435 +	void DeleteFolderEntryL();
   1.436 +	void CompleteRemoveMessagePartL();
   1.437 +private:
   1.438 +	enum TImRemoveMessagePartState
   1.439 +		{
   1.440 +		ECheckAttachmentParentType,
   1.441 +		EMoveOtherEntryToParentOfFolder,
   1.442 +		EDeleteAttachmentEntry,
   1.443 +		EDeleteFolderEntry,
   1.444 +		ECompleteRemoveMessagePart,
   1.445 +		EFinished
   1.446 +		};
   1.447 +	CMsvEntry&			iMsvEntry;
   1.448 +	CMsvOperation*		iMsvOperation;
   1.449 +
   1.450 +	CMsvEntrySelection*	iMessageEntrySelection;
   1.451 +	CImEmailMessage*	iEmailMessage;
   1.452 +
   1.453 +	TInt				iState;
   1.454 +	TPckgBuf<TMsvId>	iDataMember;
   1.455 +	TMsvId				iMessageId;
   1.456 +	TMsvId				iFolderToDeleteId;
   1.457 +	TInt				iAttachmentSize;
   1.458 +	TMsvId				iAttachmentId;
   1.459 +	TMsvId				iEntryToMoveId;
   1.460 +	};
   1.461 +
   1.462 +class CImStoreMessagePart : public CMsvOperation
   1.463 +/**
   1.464 +@internalComponent
   1.465 +@released
   1.466 +*/
   1.467 +	{
   1.468 +public:
   1.469 +	static CImStoreMessagePart* AddAttachmentL(TMsvId aMessageId, const TDesC& aFilePath, CMsvEntry& aMsvEntry,CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus );
   1.470 +	static CImStoreMessagePart* AddEntryAsAttachmentL(TMsvId aMessageId,TMsvId aAttachmentMessageId, CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus);
   1.471 +	static CImStoreMessagePart* AddAttachmentL(TMsvId aMessageId,RFile& aFile, CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
   1.472 +	static CImStoreMessagePart* AddLinkedAttachmentL(TMsvId aMessageId,const TDesC& aFilePath, CMsvEntry& aMsvEntry,CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus );	
   1.473 +	static CImStoreMessagePart* CreateAttachmentL(TMsvId aMessageId,const TDesC& aFileName, RFile& aAttachmentFile,CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus);
   1.474 +	static CImStoreMessagePart* AddRelatedPartL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, const TDesC& aAttachmentFullName, TMsvId aRelatedPartId, const TDesC8& aContentId);
   1.475 +	static CImStoreMessagePart* StoreBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CRichText& aRichText, TBool aUsePlainTextStorage = EFalse);
   1.476 +	static CImStoreMessagePart* StoreBodyTextWithMimeHeaderL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CRichText& aRichText, const CImMimeHeader& aMimeHeader, TBool aUsePlainTextStorage = EFalse);
   1.477 +	static CImStoreMessagePart* StorePlainBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TBool aUsePlainTextStorage = ETrue);
   1.478 +	static CImStoreMessagePart* StorePlainBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CImMimeHeader& aMimeHeader, TBool aUsePlainTextStorage = ETrue);
   1.479 +	~CImStoreMessagePart();
   1.480 +	const TDesC8& FinalProgress();
   1.481 +	void DoCancel();
   1.482 +	void RunL();
   1.483 +	const TDesC8& ProgressL();
   1.484 +private:
   1.485 +	enum TImMessagePart
   1.486 +		{
   1.487 +		EMessagePartAttachment,
   1.488 +		EMessagePartBody,
   1.489 +		EMessagePartMessageAttachment
   1.490 +		};
   1.491 +	void ConstructL(RFile& aFile);
   1.492 +	void ConstructL(RFile& aFile,const TDesC& aAttachmentName);
   1.493 +	void ConstructL(const TDesC& aAttachmentFullName, const TDesC8& aContentId);
   1.494 +	void ConstructAttachmentInfo(CMsvAttachment* aAttachmentInfo,TInt aAttachmentCreationState);
   1.495 +	CImStoreMessagePart(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TBool aUsePlainTextStorage = EFalse);
   1.496 +	
   1.497 +	void ConstructL();
   1.498 +	void ConstructL(const TDesC& aAttachmentFullName);
   1.499 +	void ConstructL(TMsvId aAttachmentMessageId);
   1.500 +	void ConstructL(const TDesC& aAttachmentFullName, TMsvId aRelatedPartId, const TDesC8& aContentId);
   1.501 +	void ConstructL(CRichText& aRichText);
   1.502 +	void ConstructL(CRichText& aRichText, const CImMimeHeader& aMimeHeader);
   1.503 +	void ConstructL(CImMimeHeader& aMimeHeader);
   1.504 +	void ConstructL(TImMessagePart aMessagePart);
   1.505 +	void ErrorRecovery(TInt error);
   1.506 +	void SelectNextStateL();				// selects next state to go to
   1.507 +	void ChangeStateL();					// initiates the next state operation
   1.508 +	void SelectAndChangeToNextStateL();
   1.509 +	void RequestComplete(TInt aError);
   1.510 +	void Recover();
   1.511 +
   1.512 +	TBool HTMLMessage() const;
   1.513 +	void SetHTMLMessage(TBool aFlag);
   1.514 +	TBool MultipartMixedExists() const;
   1.515 +	void SetMultipartMixedExists(TBool aFlag);
   1.516 +	TBool MultipartMixedCreated() const;
   1.517 +	void SetMultipartMixedCreated(TBool aFlag);
   1.518 +	TBool MultipartAlternativeExists() const;
   1.519 +	void SetMultipartAlternativeExists(TBool aFlag);
   1.520 +	TBool MultipartAlternativeCreated() const;
   1.521 +	void SetMultipartAlternativeCreated(TBool aFlag);
   1.522 +	TBool MultipartRelatedExists() const;
   1.523 +	void SetMultipartRelatedExists(TBool aFlag);
   1.524 +	TBool MultipartRelatedCreated() const;
   1.525 +	void SetMultipartRelatedCreated(TBool aFlag);
   1.526 +	TBool TextPartExists() const;
   1.527 +	void SetTextPartExists(TBool aFlag);
   1.528 +	TBool TextPartCreated() const;
   1.529 +	void SetTextPartCreated(TBool aFlag);
   1.530 + 	TBool AttachmentEntryCreated() const;
   1.531 +	void SetAttachmentEntryCreated(TBool aFlag);
   1.532 +
   1.533 +	void FindMultipartRelatedFolderL();
   1.534 +	void CheckForSubfolderL();
   1.535 +	void CreateAttachmentEntryL();
   1.536 +	void CopyOrigMessageToMessageL();
   1.537 +	void CreateMultipartMixedFolderEntryL();
   1.538 +	void CreateMultipartAlternativeFolderEntryL();
   1.539 +	void CreateMultipartRelatedFolderEntryL();
   1.540 +	void MoveOriginalMessageEntryChildrenToNewFolderL();
   1.541 +	void CreateTextEntryL();
   1.542 +	void StoreRichTextL();
   1.543 +	void CompleteStoreMessagePartL();
   1.544 +	void CreateHTMLEntryL();
   1.545 +	void PrepareToStoreHTMLEntryTextL();
   1.546 +	void StoreHTMLEntryTextL();
   1.547 +	void RemoveHTMLEntryL();
   1.548 +	void MoveTextEntryToAltFolderL();
   1.549 +	TPtrC GetDefaultAttachmentName();
   1.550 +	void OpenAndReadResourceFileL();
   1.551 +	void StoreMimeHeaderL();
   1.552 +	TBool CreateAttachmentMimeHeaderL(CImMimeHeader& aMimeHeader, const TDesC& aDetails);
   1.553 +	void CreateFolderMimeHeaderL(CImMimeHeader& aMimeHeader);
   1.554 +	void CreateMessageMimeHeaderL(CImMimeHeader& aMimeHeader);
   1.555 +	void AddAttachmentL();
   1.556 +	void AddAttachmentUsingFileHandleL();
   1.557 +	void AddLinkedAttachmentL();
   1.558 +	void AddEntryAsAttachmentL();	
   1.559 +	void CreateAttachmentL();
   1.560 +	void DoAttachmentStoreL();
   1.561 +	TInt CheckMimeInAttachmentInfoL(CMsvMimeHeaders& aMsvMimeHeaders);
   1.562 +	CImMimeHeader* ProcessAttachmentMimeHeadersL();
   1.563 +	void SetEntryDetailsL(TMsvEntry& aEntry);
   1.564 +	void StorePlainTextL();
   1.565 +private:
   1.566 +	enum TImStoreMessagePartState
   1.567 +		{
   1.568 +		EFindMultipartRelatedFolder,
   1.569 +		ECheckForSubfolder,
   1.570 +		ECreateAttachmentEntry,
   1.571 +		EStoreAttachment,
   1.572 +		ECopyOrigMessageToMessage,
   1.573 +		ECreateMultipartMixedFolderEntry,
   1.574 +		ECreateMultipartRelatedFolderEntry,
   1.575 +		ECreateMultipartAlternativeFolderEntry,
   1.576 +		EMoveOriginalMessageEntryChildrenToNewFolder,
   1.577 +		ECreateTextEntry,
   1.578 +		EStoreRichText,
   1.579 +		ERemoveHTMLEntry,
   1.580 +		EMoveTextToAlternativeFolder,
   1.581 +		ECreateHTMLEntry,
   1.582 +		EPrepareToStoreHTMLEntryText,
   1.583 +		EStoreHTMLEntryText,
   1.584 +		ECompleteStoreMessage,
   1.585 +		EFinished
   1.586 +		,EStoreHTMLTextInEntry,
   1.587 +		EAddEntryAttachment	
   1.588 +		};
   1.589 +
   1.590 +	enum TImStoreMessagePartFlags
   1.591 +		{
   1.592 +		KStoreMessagePartClearFlag							= 0x00000000,
   1.593 +		KStoreMessagePartHTMLMessage						= 0x00000001,
   1.594 +		KStoreMessagePartMultipartMixedExists				= 0x00000002,
   1.595 +		KStoreMessagePartMultipartMixedCreated				= 0x00000004,
   1.596 +		KStoreMessagePartMultipartAlternativeExists			= 0x00000008,
   1.597 +		KStoreMessagePartMultipartAlternativeCreated		= 0x00000010,
   1.598 +		KStoreMessagePartTextPartExists						= 0x00000020,
   1.599 +		KStoreMessagePartTextPartCreated					= 0x00000040,
   1.600 +		KStoreMessagePartAttachmentEntryCreated				= 0x00000080,
   1.601 +		KStoreMessagePartOrigMessageEntryChildrenCopied		= 0x00000100,
   1.602 +		KStoreMessagePartOrigMessageEntryChildrenDeleted	= 0x00000200,
   1.603 +		KStoreMessagePartMultipartRelatedExists				= 0x00000400,
   1.604 +		KStoreMessagePartMultipartRelatedCreated			= 0x00000800
   1.605 +		};
   1.606 +	CMsvEntry&			iMsvEntry;
   1.607 +	CMsvOperation*		iMsvOperation;
   1.608 +	
   1.609 +	CRichText*			iRichTextToStore; // I don't own this object!
   1.610 +	CImMimeHeader*		iMimeHeaderOfBodyText;
   1.611 +	CRichText*			iRichText;
   1.612 +	CFileMan*			iFileMan;
   1.613 +	CMsvEntrySelection* iMessageEntrySelection;
   1.614 +
   1.615 +	TInt				iState;
   1.616 +	TPckgBuf<TMsvId>	iDataMember;
   1.617 +	TMsvId				iMessageId;
   1.618 +	TImMessagePart		iMessagePart;
   1.619 +	TMsvId				iMixFolderId;
   1.620 +	TMsvId				iAltFolderId;
   1.621 +	TMsvId				iRelFolderId;
   1.622 +	HBufC*				iAttachmentFullName;
   1.623 +	TInt				iAttachmentSize;
   1.624 +	TMsvId				iAttachmentId;
   1.625 +	TMsvId				iTextId;
   1.626 +	TMsvId				iHtmlId;
   1.627 +	TMsvId				iRelatedPartId;
   1.628 +	TMsvId				iAttachmentMessageId;
   1.629 +	TUint32				iFlags;
   1.630 +	HBufC8*				iContentId;
   1.631 +	CImEmailMessage*	iEmailMessage;
   1.632 +
   1.633 +	// Used when converting rich text to html
   1.634 +	CParaFormatLayer*	iParaLayer;
   1.635 +	CCharFormatLayer*	iCharLayer;
   1.636 +	CImHtmlConverter* 	iHtmlConverter;
   1.637 +	TBool iFinishedConvertingHTML;
   1.638 +	CMsvAttachment*		iAttachmentInfo;
   1.639 +	CMsvStore* 			iStore;
   1.640 +	TInt 				iAttachmentCreateState;
   1.641 +	TBool				iIsAddByFileHandle;
   1.642 +	RFile*				iFileHandle;
   1.643 +	RFile               iFile;
   1.644 +	// Indicates whether to store message body as CRichText or plaintext.
   1.645 +	TBool 				iUsePlainTextStorage;
   1.646 +	// Size of the plain text body.
   1.647 +	TInt				iSizeOfBody;
   1.648 +	// Size of the Fwd'ed/ReplyTo plaintext body part.
   1.649 +	TInt				iSizeFwdReplyBody;
   1.650 +	// The error value returned when CRichText is populated with message body text.
   1.651 +	TInt 				iRestoreErr;
   1.652 +	enum TImAttachmentCreation
   1.653 +		{
   1.654 +		EAddAttachment,
   1.655 +		EAddAttachmentUsingFileHandle,
   1.656 +		EAddLinkedAttachment,
   1.657 +		EAddEntryAsAttachment,
   1.658 +		ECreateAttachment
   1.659 +		};
   1.660 +	};
   1.661 +
   1.662 +class CImEmailOperation : public CMsvOperation
   1.663 +/** Provides simple email messages creation functions, including creation of new 
   1.664 +messages, replies, forwarded messages, and receipts.
   1.665 +
   1.666 +Both plain-text and HTML messages, with or without attachments, can be created. 
   1.667 +@publishedAll
   1.668 +@released
   1.669 +*/
   1.670 +	{
   1.671 +public:
   1.672 +	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.673 +	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority = EPriorityStandard);
   1.674 +	
   1.675 +	IMPORT_C static CImEmailOperation* CreateNewL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority , TBool aUsePlainTextStorage);
   1.676 +	
   1.677 +	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.678 +	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.679 +	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority);
   1.680 +	IMPORT_C static CImEmailOperation* CreateReplyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
   1.681 +	IMPORT_C static CImEmailOperation* CreateForwardL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.682 +	IMPORT_C static CImEmailOperation* CreateForwardL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.683 +	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);
   1.684 +	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);
   1.685 +	IMPORT_C static CImEmailOperation* CreateForwardAsAttachmentL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.686 +	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);
   1.687 +	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TDesC& aFormatString, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.688 +	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.689 +	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority);
   1.690 +	IMPORT_C static CImEmailOperation* CreateReceiptL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
   1.691 +	IMPORT_C ~CImEmailOperation();
   1.692 +	IMPORT_C const TDesC8& FinalProgress();
   1.693 +	void DoCancel();
   1.694 +	void RunL();
   1.695 +	const TDesC8& ProgressL();
   1.696 +
   1.697 +	static CImEmailOperation* CreateCopyL(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aMessageId, TMsvId aDestination, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType);
   1.698 +
   1.699 +private:
   1.700 +	enum TImEmailOperation 
   1.701 +		{
   1.702 +		ENew					= 0,
   1.703 +		EReply					= 1,
   1.704 +		EForward				= 2,
   1.705 +		EReceipt				= 3,
   1.706 +		EDeletingBadEmail		= 4,
   1.707 +		ECopy					= 5,
   1.708 +		EAttachOriginal			= 0x80,
   1.709 +		EForwardAsAttachment    = EForward | EAttachOriginal,
   1.710 +		EReplyAsAttachment		= EReply | EAttachOriginal
   1.711 +		};
   1.712 +
   1.713 +private:
   1.714 +	CImEmailOperation(TRequestStatus& aObserverRequestStatus, CMsvSession& aMsvSession, TMsvId aDestination, TMsvId aSmtpServiceId, TMsvPartList aPartList, const TMsvEmailTypeList& aMsvEmailTypeList, TUid aMsgType, TInt aPriority, TBool aUsePlainTextStorage);
   1.715 +	void ConstructL(TMsvId aMessageId, const TDesC& aFormatString, TImEmailOperation aOperation);
   1.716 +	void ConstructL(TMsvId aMessageId, TImEmailOperation aOperation);
   1.717 +	void ConstructL(TImEmailOperation aOperation);
   1.718 +	void OpenAndReadResourceFileL();
   1.719 +	void SetSmtpServiceFromDefaultsL();
   1.720 +	void SetSmtpServiceFromOriginalMessageL();
   1.721 +	void ErrorRecovery(TInt error);
   1.722 +	void SelectNextStateL();
   1.723 +	void ProcessStateL();
   1.724 +	void SelectAndProcessNextStateL();
   1.725 +	void RequestComplete(TInt aError);
   1.726 +	void CreateNewHeaderL();
   1.727 +	void GetBodyTextL();
   1.728 +	TInt RemoveIncompleteAttachments();
   1.729 +	void CreateEntryDetails(TMsvEmailEntry& aMsvEmailEntry);
   1.730 +	void CreateNewMessageL(TMsvId aDestinationId);
   1.731 +	void CreateMultipartMixedFolderEntryL();
   1.732 +	void CreateTextEntryL(TMsvId aFolderId);
   1.733 +	void StoreBodyL();
   1.734 +	void StorePlainBodyL();
   1.735 +	void CheckForSignatureOrVCardL();
   1.736 +	void CreateAttachmentEntryL();
   1.737 +	void StoreAttachmentL();
   1.738 +	void CreateMultipartAlternativeFolderEntryL();
   1.739 +	void AppendHtmlAttachmentL();
   1.740 +	void AttachOriginalMessageToNewMessageL();
   1.741 +	void CompleteEmailOperationL();
   1.742 +	void CreateHTMLEntryL();
   1.743 +	void PrepareToStoreHTMLEntryTextL();
   1.744 +	void StoreHTMLEntryTextL();
   1.745 +	void CreateVCardAttachmentL();
   1.746 +	void AddVCardAttachmentL();
   1.747 +	void AddMessageAsAttachmentL();
   1.748 +	TPtrC GetDefaultAttachmentName();
   1.749 +	void RestoreSmtpSettingsL();
   1.750 +	TMsvId ServiceId();
   1.751 +	TBool NeedMultipartMixedFolder() const;
   1.752 +	void ReadDefaultHtmlAttachmentNameL(TDes& aFileName);
   1.753 +	void CreateDefaultAttachmentL();
   1.754 +	void AddMessageAttachmentInfoL(TMsvId aAttachmentMessageId);
   1.755 +	void ResetStoreL();
   1.756 +	void CreateAddressListStringL(HBufC*& aListBuffer, const CDesCArray& aAddressArray);
   1.757 +	void RestoreOriginalHeaderL();
   1.758 +	void SetBodyHeaderFormatL();
   1.759 +	static void ClosePlainBodyTextArray(TAny* aPtr);
   1.760 +	void StorePlainTextL();
   1.761 +	TInt GetPlainBodyTextSizeL();
   1.762 +	
   1.763 +private:
   1.764 +	enum TImEmailOperationState
   1.765 +		{
   1.766 +		ECreateNewHeader,
   1.767 +		EGetBodyText,
   1.768 +		EGetAttachmentList,
   1.769 +		EGetMessageDigest,
   1.770 +		ECreateNewMessageEntry,
   1.771 +		ECheckMultipartMixedFolderRequired,
   1.772 +		ECreateMultipartMixedFolderEntry,
   1.773 +		ECheckMultipartAlternativeFolderRequired,
   1.774 +		ECreateMultipartAlternativeFolderEntry,
   1.775 +		ECheckTextEntryRequired,
   1.776 +		ECreateTextEntry,
   1.777 +		EStoreBody,
   1.778 +		ECheckVCardRequired,
   1.779 +		ECreateVCardAttachment,
   1.780 +		EAddVCardAttachment,
   1.781 +		ECheckHTMLEntryRequired,
   1.782 +		ECreateHTMLEntry,
   1.783 +		EPrepareToStoreHTMLEntryText,
   1.784 +		EStoreHTMLEntryText,
   1.785 +		ECheckAttachOriginalMessageRequired,
   1.786 +		EAttachOriginalMessage,
   1.787 +		ECheckHTMLPageRequired,
   1.788 +		EFindHTMLPage,
   1.789 +		ECopyHTMLPartToAttachment,
   1.790 +		ECheckAttachmentsRequired,
   1.791 +		ECreateAttachmentEntry,
   1.792 +		EStoreAttachment,
   1.793 +		ECheckEmbeddedMessagesRequired,
   1.794 +		EAddEmbeddedMessagesAsAttachments,
   1.795 +		ECompleteEmailOperation,
   1.796 +		EFinished
   1.797 +		,ECreateDefaultHtmlAttachment,
   1.798 +		EStoreHTMLTextInEntry,
   1.799 +		EAddMessageAttachmentInfo
   1.800 +		};
   1.801 +
   1.802 +	// Flags specifying format of body header information to include
   1.803 +	// in reply and forwarded email addresses
   1.804 +	enum TImBodyHeaderFormat
   1.805 +		{
   1.806 +		ENoToCcInfo=0,
   1.807 +		EToOnly,
   1.808 +		ECcOnly,
   1.809 +		EToAndCc
   1.810 +		};
   1.811 +	
   1.812 +	CMsvEntry* iMsvEntry;
   1.813 +	CMsvOperation* iMsvOperation;
   1.814 +	
   1.815 +	CImHeader* iNewHeader;
   1.816 +	CParaFormatLayer* iParaLayer;
   1.817 +	CCharFormatLayer* iCharLayer;
   1.818 +	CRichText* iRichText;
   1.819 +	CImEmailMessage* iEmailMessage;
   1.820 +	HBufC* iFormatString;
   1.821 +	CFileMan* iFileMan;
   1.822 +	CImSmtpSettings* iSmtpSettings;
   1.823 +	TInt iState;
   1.824 +	TImEmailOperation iOperation;
   1.825 +	TMsvId iDestinationId;
   1.826 +	TMsvId iMultipartMixedId;
   1.827 +	TMsvId iMultipartAlternativeId;
   1.828 +	TMsvId iOrigMessageId;
   1.829 +	TMsvId iNewMessageId;
   1.830 +	TMsvId iSmtpServiceId;
   1.831 +	TMsvId iAttachedMessageId;
   1.832 +	TUid iMsgType;
   1.833 +	TMsvPartList iPartList;
   1.834 +	TMsvEmailTypeList iMsvEmailTypeList;
   1.835 +	TInt iAttachmentCount;
   1.836 +	TInt iTotalAttachments;
   1.837 +	TPckgBuf<TMsvId> iDataMember;
   1.838 +	HBufC* iBodyHeaderFormatString;
   1.839 +	HBufC* iBodyHeaderDateTimeFormatString;
   1.840 +	HBufC* iBodyHeaderToString;
   1.841 +	HBufC* iBodyHeaderCcString;
   1.842 +	HBufC* iBodyHeader;
   1.843 +	HBufC* iUserEmailAddress;
   1.844 +	TInt iRichTextSize;
   1.845 +	TInt iVCardAndHtmlSize;
   1.846 +	TBool iOrigMessageHtml;
   1.847 +	TBool iHtmlNoTextAlt;
   1.848 +	TInt iEmbeddedMessagesToProcess;
   1.849 +	TImMessageField iMessageField;
   1.850 +
   1.851 +	// for MIME messages:
   1.852 +	TBool iCreateHtmlMessage;
   1.853 +	TBool iMultipartMixedFolderCreated;
   1.854 +	TBool iMultipartAlternativeFolderCreated;
   1.855 +	TMsvId iTextId;
   1.856 +	TMsvId iHtmlId;
   1.857 +	TMsvId iVcardId;
   1.858 +
   1.859 +	// Used when converting rich text to html
   1.860 +	CImHtmlConverter* iHtmlConverter;
   1.861 +	TBool iFinishedConvertingHTML;
   1.862 +
   1.863 +	// Relating to adding Signature and/or Vcard to an email
   1.864 +	TBool iNeedToAddVCardAttachment;
   1.865 +	HBufC* iDefaultVCardNameFormatString;
   1.866 +	TStreamId iVcardStoreId;
   1.867 +	CStreamStore* iVcardStore;
   1.868 +	CRichText* iSignatureText;
   1.869 +	TFileName iFileName;
   1.870 +	TImAttachmentFile iAttachmentFile;
   1.871 +
   1.872 +	// PCMail
   1.873 +	TMsvId iPCMailServiceId;
   1.874 +	RPointerArray<CMsvAttachment>	iAttachmentInfoList;
   1.875 +	// set this anytime during the object life cycle attachment manager was used
   1.876 +	TBool iAttachmentMgrUsed;
   1.877 +	CMsvStore* iStore;
   1.878 +	RFile iFile;
   1.879 +
   1.880 +	TImBodyHeaderFormat iBodyHeaderFormat;
   1.881 +	CImHeader* iOriginalHeader;
   1.882 +	/** Indicates if the body text entry is plain text */
   1.883 +	TBool  iUsePlainTextStorage;
   1.884 +	// The error value returned when CRichText is populated with message body text.
   1.885 +	TInt iRestoreErr;
   1.886 +	};
   1.887 +
   1.888 +
   1.889 +class CImHtmlConverter : public CBase
   1.890 +/**
   1.891 +@internalComponent
   1.892 +@released
   1.893 +*/
   1.894 +	{
   1.895 +public:
   1.896 +	static CImHtmlConverter* CImHtmlConverter::NewL(CMsvEntry& aMsvEntry, 
   1.897 +								   CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer);
   1.898 +	~CImHtmlConverter();
   1.899 +	void PrepareToStoreHTMLEntryTextL(TMsvId& aHtmlId, const TMsvId aTextId);
   1.900 +	void ResetStoreL();
   1.901 +	void ResetStoreWithoutCommit();
   1.902 +	TBool StoreHTMLEntryTextAL(TRequestStatus& aStatus);
   1.903 +	CMsvOperation* ChangeHTMLTextInEnrtyL(TRequestStatus& aStatus);
   1.904 +	
   1.905 +	void ReadDefaultAttachmentNameL( RResourceFile& resourceFile);
   1.906 +	TInt Size() const;
   1.907 +
   1.908 +private:
   1.909 +	CImHtmlConverter(CMsvEntry&	aMsvEntry, CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer);
   1.910 +	TFileName HtmlFilename(CMsvEntry& aEntry, TPtrC aFileName);
   1.911 +	TPtrC GetDefaultAttachmentName();
   1.912 +	void ConstructL();
   1.913 +
   1.914 +private:
   1.915 +	CMsvEntry&			iMsvEntry;
   1.916 +	CParaFormatLayer&	iParaLayer;
   1.917 +	CCharFormatLayer&	iCharLayer;
   1.918 +
   1.919 +	CConverterBase*		iToHTMLConverter;
   1.920 +	CCnaConverterList*	iConverterList;
   1.921 +
   1.922 +	TMsvId				iTextId;
   1.923 +	TMsvId				iHtmlId;
   1.924 +	TInt				iSize;
   1.925 +	HBufC*				iDefaultAttachmentName;
   1.926 +	CRichText*			iRichText;
   1.927 +	RDesReadStream 		iSourceStream;
   1.928 +	RFileWriteStream	iTargetStream;
   1.929 +	CMsvStore*			iStore;
   1.930 +	RFile 				iFile;
   1.931 +	};
   1.932 +
   1.933 +class CImStoreResolver : public CBase, public MRichTextStoreResolver
   1.934 +/**
   1.935 +@internalComponent
   1.936 +@released
   1.937 +*/
   1.938 +	{
   1.939 +public:
   1.940 +	CImStoreResolver(CStreamStore* aStore);
   1.941 +	~CImStoreResolver();
   1.942 +	//
   1.943 +private:
   1.944 +	const CStreamStore& StreamStoreL(TInt aPos)const;
   1.945 +	//
   1.946 +private:
   1.947 +	CStreamStore* iStore;
   1.948 +	};
   1.949 +
   1.950 +
   1.951 +
   1.952 +
   1.953 +#endif // __MIUTMSG_H__