epoc32/include/app/miutmsg.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     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
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
       
    14 // MIUTMSG.H
    14 //
    15 //
    15 
    16 
    16 #ifndef __MIUTMSG_H__
    17 #ifndef __MIUTMSG_H__
    17 #define __MIUTMSG_H__
    18 #define __MIUTMSG_H__
    18 
    19 
    30 #include <barsc.h>		// RResourceFile
    31 #include <barsc.h>		// RResourceFile
    31 #include <conarc.h>
    32 #include <conarc.h>
    32 #include <conlist.h>
    33 #include <conlist.h>
    33 
    34 
    34 #include <txtmrtsr.h>
    35 #include <txtmrtsr.h>
    35 
       
    36 
       
    37 
    36 
    38 //#include <mmsvattachmentmanager.h>
    37 //#include <mmsvattachmentmanager.h>
    39 #include <s32mem.h>
    38 #include <s32mem.h>
    40 
    39 
    41 //Content-Transfer-Encoding: types
    40 //Content-Transfer-Encoding: types
    84 _LIT8(KMimeZip, "x-gzip");
    83 _LIT8(KMimeZip, "x-gzip");
    85 _LIT(KMimeHtmlExtension, ".html");
    84 _LIT(KMimeHtmlExtension, ".html");
    86 _LIT(KMiutMsgDefaultHtmlFileName, "attachment.html");
    85 _LIT(KMiutMsgDefaultHtmlFileName, "attachment.html");
    87 const TUid KUidMimeHeaders = {0x10204281};
    86 const TUid KUidMimeHeaders = {0x10204281};
    88 
    87 
       
    88 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    89 #include "cimmessagepart.h"
       
    90 #endif
       
    91 
    89 class CImHtmlConverter;
    92 class CImHtmlConverter;
    90 
    93 
    91 class CImAttachmentManager;
    94 class CImAttachmentManager;
    92 class CMsvMimeHeaders;
    95 class CMsvMimeHeaders;
    93 class CMsvPlainBodyText;
       
    94 class CImPlainBodyText;
    96 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 
    97 
   108 // Mixin provides interface to Browser control to resolve MHTML URIs.
    98 // Mixin provides interface to Browser control to resolve MHTML URIs.
   109 
    99 
   110 class MImURITranslator
   100 class MImURITranslator
   111 /** Translates a URI in an MHTML message into a message body part file name.
   101 /** Translates a URI in an MHTML message into a message body part file name.
   397 		EDeleteAttachment,
   387 		EDeleteAttachment,
   398 		ECreateAttachment
   388 		ECreateAttachment
   399 		};	
   389 		};	
   400 	TInt		iAttachmentState;
   390 	TInt		iAttachmentState;
   401 	
   391 	
   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 	};
   392 	};
   658 
   393 
   659 class CImEmailOperation : public CMsvOperation
   394 class CImEmailOperation : public CMsvOperation
   660 /** Provides simple email messages creation functions, including creation of new 
   395 /** Provides simple email messages creation functions, including creation of new 
   661 messages, replies, forwarded messages, and receipts.
   396 messages, replies, forwarded messages, and receipts.
   880 	TBool  iUsePlainTextStorage;
   615 	TBool  iUsePlainTextStorage;
   881 	// The error value returned when CRichText is populated with message body text.
   616 	// The error value returned when CRichText is populated with message body text.
   882 	TInt iRestoreErr;
   617 	TInt iRestoreErr;
   883 	};
   618 	};
   884 
   619 
   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__
   620 #endif // __MIUTMSG_H__