email/pop3andsmtpmtm/clientmtms/inc/MIUTHDR.H
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 1998-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 // MIUTHDR.H
       
    15 //
       
    16 
       
    17 /**
       
    18  * @file 
       
    19  * @publishedAll
       
    20  * @released
       
    21  */
       
    22 
       
    23 #ifndef __MIUTHDR_H__
       
    24 #define __MIUTHDR_H__
       
    25 
       
    26 #include <s32strm.h>
       
    27 #include <badesca.h>
       
    28 #include <pop3cmds.h>
       
    29 #include <msvstd.h>
       
    30 #include <msvids.h>			// KMsvNullIndexEntryId
       
    31 #include <miutstd.hrh>			// KUidMsvEmailTextEntryValue
       
    32 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    33 #include "timrfc822datefield.h"
       
    34 #endif
       
    35 /** 
       
    36  * IMail-specific stream type within an IMail file store for CImHeader
       
    37  * @publishedAll
       
    38  * @released
       
    39  */
       
    40 const TUid KUidMsgFileMimeHeader	= {0x1000160F};		// 268441103 decimal
       
    41 /** 
       
    42  * IMail-specific stream type within an IMail file store for CImMimeHeader
       
    43  * @publishedAll
       
    44  * @released
       
    45  */
       
    46 const TUid KUidMsgFileIMailHeader	= {0x100001D8};		// 268435928 decimal
       
    47 
       
    48 /** 
       
    49  * @publishedAll
       
    50  * @released
       
    51  */
       
    52 class CMsvStore;
       
    53 class TMsvEntry;
       
    54 class RMsvReadStream;
       
    55 class RMsvWriteStream;
       
    56 /** 
       
    57  * @internalTechnology
       
    58  * @released
       
    59  */
       
    60 class CImEncodedHeader;
       
    61 
       
    62 /** Defines how emails will be encoded when they are sent.
       
    63 
       
    64 MIME standards are defined in RFC 2045, RFC 2046 and RFC 2047. 
       
    65 @publishedAll
       
    66 @released
       
    67 */
       
    68 enum TMsgOutboxBodyEncoding
       
    69 	{
       
    70 	/** Emails are sent with the default encoding, which is as for EMsgOutboxMIME. */
       
    71 	EMsgOutboxDefault,
       
    72 	/** Emails are sent as plain text RFC822 messages. 
       
    73 	
       
    74 	Attachments are encoded using UUEncoding algorithm. This method would not 
       
    75 	normally be used unless the sender was sure that the receiving mail clients 
       
    76 	don't support MIME. */
       
    77 	EMsgOutboxNoAlgorithm,
       
    78 	/** Text is encoded using quoted-printable encoding, and all attachments are encoded 
       
    79 	using BASE64 encoding.
       
    80 	
       
    81 	This is the default setting for this option. */
       
    82 	EMsgOutboxMIME,
       
    83 	/** Text parts of the message are sent as MIME TEXT/HTML parts, and are encoded 
       
    84 	using UTF-8 encoding system. 
       
    85 	
       
    86 	All attachments are encoded using BASE64 encoding. Receiving mail clients 
       
    87 	that do no support MHTML mail will display the HTML message text to the user 
       
    88 	including all HTML tags, etc. */
       
    89 	EMsgOutboxMHTMLAsMIME,
       
    90 	/** Each text part of the message is sent as two alternative MIME parts.
       
    91 	
       
    92 	The first part is sent as plain text using quoted-printable encoding, the 
       
    93 	second part is sent as a TEXT/HTML part which is encoded using UTF-8 encoding 
       
    94 	system. All attachments are encoded using BASE64 encoding. This is the standard 
       
    95 	encoding method if the user wishes to send MHTML mail. */
       
    96 	EMsgOutboxMHTMLAlternativeAsMIME
       
    97 	};
       
    98 
       
    99 /** Messaging encoding types. 
       
   100 @publishedAll
       
   101 @released
       
   102 */
       
   103 enum TImEncodingType 
       
   104 	{
       
   105 	/** Unknown. */
       
   106 	EEncodingTypeUnknown,
       
   107 	/** None. */
       
   108 	EEncodingTypeNone,
       
   109 	/** 7-bit. */
       
   110 	EEncodingType7Bit,
       
   111 	/** 8-bit. */
       
   112 	EEncodingType8Bit,		// ie lines still <1000 chars and terminated by CRLF
       
   113 	/** Binary. */
       
   114 	EEncodingTypeBinary,	// ie any length of data, not terminated by CRLF
       
   115 	/** QP. */
       
   116 	EEncodingTypeQP,
       
   117 	/** Base64. */
       
   118 	EEncodingTypeBASE64,
       
   119 	/** UU. */
       
   120 	EEncodingTypeUU
       
   121 	};
       
   122 
       
   123 
       
   124 // Class used for storing extracting information (to/from header)..
       
   125 // regarding the encoding in an incoming email message header.
       
   126 //----------------------------------------------------------------------------------------
       
   127 class TImHeaderEncodingInfo
       
   128 //----------------------------------------------------------------------------------------
       
   129 /** Stores encoding data found in message headers. 
       
   130 @publishedAll
       
   131 @released
       
   132 */
       
   133 	{
       
   134 public:
       
   135 	/** Message field types. */
       
   136 	enum TFieldList 
       
   137 		{ 
       
   138 		EFrom, 		/**< "From" field. */
       
   139 		EReplyTo, 	/**< "Reply To" field. */
       
   140 		ETo, 		/**< "To" field. */
       
   141 		ECc, 		/**< "Cc" field. */
       
   142 		EBcc, 		/**< "Bcc" field. */
       
   143 		ESubject	/**< Subject field. */
       
   144 		};
       
   145 	/** Encoding types. */
       
   146 	enum TEncodingType 
       
   147 		{ 
       
   148 		EBase64, 		/**< Base64. */
       
   149 		EQP, 			/**< QP. */
       
   150 		ENoEncoding, 	/**< No encoding */
       
   151 		EUU				/**< UU. */
       
   152 		};
       
   153 
       
   154 public:
       
   155 	IMPORT_C TImHeaderEncodingInfo();
       
   156 	IMPORT_C TImHeaderEncodingInfo(const TImHeaderEncodingInfo& aFrom);
       
   157 
       
   158 	IMPORT_C void ExternalizeL( RWriteStream& aWriteStream ) const;
       
   159 	IMPORT_C void InternalizeL( RReadStream& aReadStream );
       
   160 
       
   161 	inline void SetField(const TFieldList aField);
       
   162 	inline TFieldList Field() const;
       
   163 
       
   164 	inline void SetOffset(const TInt aOffset);
       
   165 	inline TInt Offset() const;
       
   166 
       
   167 	inline void SetLength(const TInt aLength);
       
   168 	inline TInt Length() const;
       
   169 
       
   170 	inline void SetCharsetUid(const TUint aUid);
       
   171 	inline TUint CharsetUid() const;
       
   172 
       
   173 	inline void SetEncodingType(const TDesC8& aChar);
       
   174 	inline void SetEncodingType(const TEncodingType aType);
       
   175 	inline  TEncodingType EncodingType() const;
       
   176 
       
   177 	inline void SetArrayValue(const TInt aValue);
       
   178 	inline  TInt ArrayValue() const;
       
   179 
       
   180 	inline void SetAddSpace(const TBool atrueFalse);
       
   181 	inline  TBool AddSpace() const;
       
   182 
       
   183 	inline void SetEncodedLength(const TInt aLength);
       
   184 	inline TInt EncodedLength() const;
       
   185 
       
   186 private:
       
   187 	TFieldList		iField; 
       
   188 	TUint16			iOffset;
       
   189 	TUint16			iLength;
       
   190 	TEncodingType	iType;
       
   191 	TUint16			iArrayValue;
       
   192 	TBool	iAddSpace; // A space char needs adding between two adjoining 'encoded-words'
       
   193 	TUint8	iEncodedLength; // This can be used to determine space needed for buffer.
       
   194 	TUint	iCharsetUid; 
       
   195 
       
   196 	};
       
   197 
       
   198 
       
   199 //------------------------------------------------------------------------------
       
   200 
       
   201 
       
   202 class CImHeader : public CBase
       
   203 /** Encapsulates an Internet Mail (RFC822) header.
       
   204 
       
   205 Note that the class contains some obsolete functions that take a narrow descriptor: 
       
   206 always use the equivalent wide descriptor function instead. 
       
   207 @publishedAll
       
   208 @released
       
   209 */
       
   210 	{
       
   211 public:
       
   212 /** Flags used to determine where to obtain the ReplyTo address for the header 
       
   213 field of that name. */
       
   214 	enum TReplyTo 
       
   215 		{ 
       
   216 	/** Get address from originator. */
       
   217 		EOriginator, 
       
   218 	/** Get address from sender. */
       
   219 		ESender, 
       
   220 	/** Get address from all sources. */
       
   221 		EAll,
       
   222 	/** Get address from recipients. */
       
   223 		ERecipients
       
   224 		};
       
   225 
       
   226 	IMPORT_C static CImHeader* NewLC();
       
   227 	IMPORT_C ~CImHeader();
       
   228 	IMPORT_C void Reset();
       
   229 
       
   230 	// streaming operations
       
   231 	IMPORT_C void InternalizeL(RMsvReadStream& aReadStream);
       
   232 	IMPORT_C void ExternalizeL(RMsvWriteStream& aWriteStream) const;
       
   233 	IMPORT_C void RestoreL(CMsvStore& aMessageStore);
       
   234 	IMPORT_C void StoreL  (CMsvStore& aMessageStore) const;
       
   235 	IMPORT_C void StoreWithoutCommitL(CMsvStore& aMessageStore) const;
       
   236 
       
   237 
       
   238 	// the bulk of the member functions are accessors & mutators so we can use
       
   239 	// objects of the class as data repositories during the data-marshalling stage
       
   240 	// of getting imail headers to/from the internet
       
   241 	IMPORT_C const TPtrC Subject() const;
       
   242 	IMPORT_C void SetSubjectL(const TDesC8& aSubject);
       
   243 
       
   244 	// Internet message ID
       
   245 	IMPORT_C const TPtrC8 ImMsgId() const;
       
   246 	/** Sets the "MessageId" header field.
       
   247 	
       
   248 	@param aImMsgIdL Field value */
       
   249 	IMPORT_C void SetImMsgIdL(const TDesC8& aImMsgIdL);
       
   250 
       
   251 	IMPORT_C const TPtrC From() const;
       
   252 	IMPORT_C void SetFromL(const TDesC8& aFrom);
       
   253 
       
   254 	IMPORT_C const TPtrC ReplyTo() const;
       
   255 	IMPORT_C void SetReplyToL(const TDesC8& aReplyTo);
       
   256 
       
   257 	IMPORT_C const TPtrC ReceiptAddress() const;
       
   258 	/** Sets the "Receipt" header field. 
       
   259 	
       
   260 	@param aReceiptAddress Field value */
       
   261 	IMPORT_C void SetReceiptAddressL(const TDesC8& aReceiptAddress);
       
   262 
       
   263 	IMPORT_C TUint Charset() const;
       
   264 	IMPORT_C void SetCharset(const TUint aCharset);
       
   265 
       
   266 #if defined (_UNICODE)
       
   267 	IMPORT_C void SetFromL(const TDesC16& aFrom);
       
   268 	IMPORT_C void SetReplyToL(const TDesC16& aReplyTo);
       
   269 	/** Sets the "Receipt" header field. 
       
   270 	
       
   271 	@param aReceiptAddress Field value */
       
   272 	IMPORT_C void SetReceiptAddressL(const TDesC16& aReceiptAddress);
       
   273 	IMPORT_C void SetSubjectL(const TDesC16& aSubject);
       
   274 #endif
       
   275 
       
   276 	IMPORT_C TInt DataSize();
       
   277 
       
   278 	inline const TUint RemoteSize() const;
       
   279 	inline void SetRemoteSize(TUint aSize);
       
   280 
       
   281 	inline const TUint16 Version() const;
       
   282 	inline void SetVersion(TUint16 aVersion);
       
   283 
       
   284 	// give const access to the recipient lists
       
   285 	inline const CDesCArray& ToRecipients () const;
       
   286 	inline const CDesCArray& CcRecipients () const;
       
   287 	inline const CDesCArray& BccRecipients() const;
       
   288 	
       
   289 	// give non-const access to the recipient lists
       
   290 	inline CDesCArray& ToRecipients () ;
       
   291 	inline CDesCArray& CcRecipients () ;
       
   292 	inline CDesCArray& BccRecipients() ;
       
   293 
       
   294 	inline CArrayFix<TImHeaderEncodingInfo>& EncodingInfo() ;
       
   295 	inline const CArrayFix<TImHeaderEncodingInfo>& EncodingInfo() const;
       
   296 
       
   297 	IMPORT_C void AddEncodingInfoL(TImHeaderEncodingInfo& aInfo);
       
   298 
       
   299 //-------------------------------------------------------------------------------------
       
   300 //----------------------Used for forwarding/replying to an email ----------------------
       
   301 
       
   302 	IMPORT_C const TPtrC8 ResentMsgId() const;
       
   303 	IMPORT_C void SetResentMsgIdL( const TDesC8& );
       
   304 
       
   305 	IMPORT_C const TPtrC ResentFrom() const;
       
   306 	IMPORT_C void SetResentFromL( const TDesC& );
       
   307 
       
   308 	// give const access to the recipient lists
       
   309 	inline const CDesCArray& ResentToRecipients () const;
       
   310 	inline const CDesCArray& ResentCcRecipients () const;
       
   311 	inline const CDesCArray& ResentBccRecipients() const;
       
   312 
       
   313 	// give non-const access to the recipient lists
       
   314 	inline CDesCArray& ResentToRecipients ();
       
   315 	inline CDesCArray& ResentCcRecipients ();
       
   316 	inline CDesCArray& ResentBccRecipients();
       
   317 
       
   318 	IMPORT_C const TPtrC8 InReplyTo() const;
       
   319 	IMPORT_C void SetInReplyToL(const TDesC8&);
       
   320 
       
   321 	IMPORT_C TInt CreateForwardL(CImHeader&, TDesC&);
       
   322 	IMPORT_C TInt CreateReplyL(CImHeader&, TReplyTo, TDesC&);
       
   323 	IMPORT_C void CreateReceiptL(CImHeader&, TDesC&);
       
   324 
       
   325 //-------------------------------------------------------------------------------------
       
   326 //-------------------------------------------------------------------------------------
       
   327 
       
   328 	// Body Encoding (charset) stored on a per message basis
       
   329 	IMPORT_C TMsgOutboxBodyEncoding BodyEncoding() const;
       
   330 	IMPORT_C void SetBodyEncoding(TMsgOutboxBodyEncoding aMessageBodyEncoding);
       
   331 
       
   332 	IMPORT_C void ReDecodeL(RFs& aFS);
       
   333 	IMPORT_C TUint OverrideCharset() const;
       
   334 	IMPORT_C void SetOverrideCharset(TUint aCharset);
       
   335 	IMPORT_C void SaveEncodedHeadersL();
       
   336 
       
   337 private:
       
   338 	CImHeader();
       
   339 	void ConstructL();
       
   340 	
       
   341 	// these four functions keep the line count down as there are several instances
       
   342 	// of streaming in/out HBufC objects.
       
   343 	void ReadRecipientsL ( RReadStream&, CDesCArray* );
       
   344 	void WriteRecipientsL( RWriteStream&, const CDesCArray* ) const;
       
   345 	void FormatSubjectL(CImHeader&, TDesC&);
       
   346 
       
   347 	//finds the duplicate recipients in To and Cc list
       
   348 	TBool IsRecipientPresent(CImHeader& aCImHeader, TPtrC16 newRecipient);
       
   349 
       
   350 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   351 	void ReStoreDBL(CMsvStore& aMessageStore);
       
   352 	void StoreDBL  (CMsvStore& aMessageStore) const;
       
   353 	void CreateImHeaderArrayListL(TDesC16& aStr, CDesCArray& aRecipients);
       
   354 	void CreateEncodingInfoL(TDesC16& aEncodingStr);
       
   355 	HBufC16* Convert8to16L(const TDesC8& aStr) const;
       
   356 	void CreateBufferL( RBuf16& aBuf, CDesCArray& aRecipients)const;
       
   357 #endif 
       
   358 private:
       
   359 	TUint16 iVersion;
       
   360 
       
   361 	HBufC16* iFrom;
       
   362 	HBufC* iSubject;
       
   363 	HBufC8* iImMsgId;
       
   364 	HBufC16* iReplyTo;
       
   365 	HBufC16* iReceipt;
       
   366 
       
   367 	CDesCArray* iTo;
       
   368 	CDesCArray* iCc;
       
   369 	CDesCArray* iBcc;
       
   370 	TUint iRemoteSize;
       
   371 
       
   372 //-------------------------------------------------------------------------------------
       
   373 //----------------------Used for forwarding/replying to an email ----------------------
       
   374 
       
   375 	HBufC* iResentFrom;
       
   376 	HBufC8* iResentMsgId;
       
   377  	CDesCArray* iResentTo;
       
   378 	CDesCArray* iResentCc;
       
   379 	CDesCArray* iResentBcc;
       
   380 	HBufC8* iInReplyTo;
       
   381 
       
   382 //-------------------------------------------------------------------------------------
       
   383 //-------------------------------------------------------------------------------------
       
   384 	CArrayFix<TImHeaderEncodingInfo>* iEncodingInfo;
       
   385 	TMsgOutboxBodyEncoding			iBodyEncoding;
       
   386 	// The character set to be when sending message.
       
   387 	// Overrides the charset passed in from the settings.
       
   388 	TUint							i822HeaderCharset; 
       
   389 
       
   390 	CImEncodedHeader* iEncodedHeader;
       
   391 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   392 	friend class CTestEmailHeaderStoreReStore;
       
   393 #endif 
       
   394 	};
       
   395 
       
   396 /** Folder type flags.
       
   397 
       
   398 The flags correspond to the MIME multipart subtype. 
       
   399 @publishedAll
       
   400 @released
       
   401 */
       
   402 enum TImEmailFolderType
       
   403 	{
       
   404 	/** Unknown. */
       
   405 	EFolderTypeUnknown,
       
   406 	/** Related. */
       
   407 	EFolderTypeRelated,
       
   408 	/** Mixed. */
       
   409 	EFolderTypeMixed,
       
   410 	/** Parallel. */
       
   411 	EFolderTypeParallel,
       
   412 	/** Alternative. */
       
   413 	EFolderTypeAlternative,
       
   414 	/** Digest. */
       
   415 	EFolderTypeDigest,
       
   416 	/** RFC822. */
       
   417 	EFolderTypeRFC822,
       
   418 	/** Partial. */
       
   419 	EFolderTypePartial,
       
   420 	/** Directory. */
       
   421 	EFolderTypeDirectory,
       
   422 	/** External. */
       
   423 	EFolderTypeExternal
       
   424 	};
       
   425 
       
   426 /** Describes the types of off-line email operations than can occur.
       
   427 
       
   428 @see TMsvEmailEntry::DisconnectedOperation() 
       
   429 @publishedAll
       
   430 @released
       
   431 */
       
   432 enum TImDisconnectedOperationType
       
   433 	{
       
   434 	/** No operation. */
       
   435 	ENoDisconnectedOperations,
       
   436 	/** Create operation. */
       
   437 	EDisconnectedCreateOperation,
       
   438 	/** Delete operation. */
       
   439 	EDisconnectedDeleteOperation,
       
   440 	/** Change operation. */
       
   441 	EDisconnectedChangeOperation,
       
   442 	/** "Copy to" operation. */
       
   443 	EDisconnectedCopyToOperation,
       
   444 	/** "Copy from" operation. */
       
   445 	EDisconnectedCopyFromOperation,
       
   446 	/** "Copy within service" operation. */
       
   447 	EDisconnectedCopyWithinServiceOperation,
       
   448 	/** "Move to" operation. */
       
   449 	EDisconnectedMoveToOperation,
       
   450 	/** "Move from" operation. */
       
   451 	EDisconnectedMoveFromOperation,
       
   452 	/** "Move within service" operation. */
       
   453 	EDisconnectedMoveWithinServiceOperation,
       
   454 	/** Special operation. */
       
   455 	EDisconnectedSpecialOperation,
       
   456 	/** Unknown operation. */
       
   457 	EDisconnectedUnknownOperation,
       
   458 	/** Multiple operations. */
       
   459 	EDisconnectedMultipleOperation
       
   460 	};
       
   461 
       
   462 // Remote folder message count limited to TUint16 by using lower 16 bits of "iMtmData3".
       
   463 // Note: The upper 16 bits of "iMtmData3" are not currently used by "TMsvEmailEntry".
       
   464 const TUint KMsvRemoteFolderEntriesMask =		0x0000FFFF;
       
   465 
       
   466 class TMsvEmailEntry : public TMsvEntry
       
   467 /** Provides storage for and access to extra email specific information for a message.
       
   468 
       
   469 To get a TMsvEmailEntry, get the entry's TMsvEntry, e.g. using
       
   470 @c CMsvEntry::Entry(), and use the constructor that takes a TMsvEntry parameter.
       
   471 
       
   472 Many of the flags are only used by IMAP4 entries. These can be grouped as follows:
       
   473 
       
   474 - IMAP-specific flags, as defined by the IMAP protocol (see RFC3501, 2.3.2. Flags Message Attribute)
       
   475   - GetIMAP4Flags() and SetIMAP4Flags() handle all the flags as a group
       
   476   - \\Seen flag: SetSeenIMAP4Flag(), SeenIMAP4Flag(). 
       
   477   - \\Answered flag: SetAnsweredIMAP4Flag(), AnsweredIMAP4Flag()
       
   478   - \\Flagged flag: SetFlaggedIMAP4Flag(), FlaggedIMAP4Flag()
       
   479   - \\Deleted flag: SetDeletedIMAP4Flag(), DeletedIMAP4Flag() 
       
   480   - \\Draft flag: SetDraftIMAP4Flag(), DraftIMAP4Flag() 
       
   481   - \\Recent flag: SetRecentIMAP4Flag(), RecentIMAP4Flag()
       
   482 - Folder subscriptions and other folder-related flags: 
       
   483   - SetMailbox(), Mailbox(), 
       
   484   - SetSubscribed(), Subscribed(), 
       
   485   - SetLocalSubscription(), LocalSubscription()
       
   486   - SetRemoteFolderEntries(), RemoteFolderEntries()  
       
   487 - Disconnected operation information:
       
   488   - SetDisconnectedOperation(), DisconnectedOperation().
       
   489 - Partial download flags: these flags allow a client to test if a message or its body has
       
   490   been partially downloaded (see TImImap4GetPartialMailInfo)   
       
   491   - SetPartialDownloaded(), PartialDownloaded() 
       
   492   - SetBodyTextComplete(), BodyTextComplete()
       
   493 - UID information: IMAP messages have a unique identifier number (see 
       
   494   RFC3501, 2.3.1.1. Unique Identifier (UID) Message Attribute)
       
   495   - SetValidUID(), ValidUID()
       
   496   - SetUID(), UID().
       
   497   
       
   498 The following flags are set only by the IMAP MTM. They indicate if the 
       
   499 message contains a vCard, vCalendar (http://www.imc.org), or iCalendar (RFC 2445) attachment.
       
   500 
       
   501 - VCard(), SetVCard()
       
   502 - VCalendar(), SetVCalendar() 
       
   503 - ICalendar(), SetICalendar()
       
   504 
       
   505 The following flags apply to all email protocols:
       
   506 
       
   507 - Receipt requested: Receipt(), SetReceipt()
       
   508 - MHTML content: MHTMLEmail(), SetMHTMLEmail()
       
   509 
       
   510 Note that the email specific data is stored in the reserved data members @c iMtmData1, 
       
   511 @c iMtmData2 and @c iMtmData3 of the TMsvEntry base class. These public data members 
       
   512 must not be directly altered by clients.
       
   513 
       
   514 @publishedAll
       
   515 @released
       
   516 @see CImap4ClientMtm
       
   517 */
       
   518 	{
       
   519 public: // Public member functions
       
   520 	IMPORT_C TMsvEmailEntry();	// default constructor
       
   521 	IMPORT_C TMsvEmailEntry(const TMsvEntry& aGenericEntry); 
       
   522 
       
   523 	IMPORT_C TBool operator==(const TMsvEntry& aEntry) const;
       
   524 	IMPORT_C TBool operator==(const TMsvEmailEntry& aEntry) const;
       
   525 
       
   526 	IMPORT_C void GetIMAP4Flags(TBool& rUnread,TBool& rSeen,TBool& rAnswered,TBool& rFlagged,TBool& rDeleted,TBool& rDraft,TBool& rRecent);
       
   527 	IMPORT_C void SetIMAP4Flags(TBool aUnread,TBool aSeen,TBool aAnswered,TBool aFlagged,TBool aDeleted,TBool aDraft,TBool aRecent);
       
   528 
       
   529 	IMPORT_C void SetMessageFolderType(TImEmailFolderType aFolderType);
       
   530 	IMPORT_C TImEmailFolderType MessageFolderType() const;
       
   531 
       
   532 	IMPORT_C void SetDisconnectedOperation(TImDisconnectedOperationType aDisconnectedOperationType);
       
   533 	IMPORT_C TImDisconnectedOperationType DisconnectedOperation() const;
       
   534 
       
   535 	IMPORT_C void SetPartialDownloaded(TBool aPartialDownloaded);
       
   536 	IMPORT_C TBool PartialDownloaded() const;
       
   537 
       
   538 	//
       
   539 	inline void SetEncrypted(TBool aEncrypt);
       
   540 	inline TBool Encrypted() const;
       
   541 	//
       
   542 	inline void SetSigned(TBool aSignature);
       
   543 	inline TBool Signed() const;
       
   544 	//
       
   545 	inline TBool VCard() const;
       
   546 	inline void SetVCard(TBool aVCard);
       
   547 	//
       
   548 	inline TBool VCalendar() const;
       
   549 	inline void SetVCalendar(TBool aVCal);
       
   550 	//
       
   551 	inline TBool ICalendar() const;
       
   552 	inline void SetICalendar(TBool aICal);
       
   553 	//
       
   554 	inline TBool Receipt() const;
       
   555 	inline void SetReceipt(TBool aReceipt);
       
   556 
       
   557 	inline TBool MHTMLEmail() const;
       
   558 	inline void SetMHTMLEmail(TBool aMhtml);
       
   559 
       
   560 	inline TBool BodyTextComplete() const;
       
   561 	inline void SetBodyTextComplete(TBool aFlag);
       
   562 
       
   563 	//
       
   564 	// IMAP4-specific flags
       
   565 	//
       
   566 	inline void SetUnreadIMAP4Flag(TBool aUnread);
       
   567 	inline TBool UnreadIMAP4Flag() const;
       
   568 	//
       
   569 	inline void SetSeenIMAP4Flag(TBool aSeen);
       
   570 	inline TBool SeenIMAP4Flag() const;
       
   571 	//
       
   572 	inline void SetAnsweredIMAP4Flag(TBool aAnswered);
       
   573 	inline TBool AnsweredIMAP4Flag() const;
       
   574 	//
       
   575 	inline void SetFlaggedIMAP4Flag(TBool aFlagged);
       
   576 	inline TBool FlaggedIMAP4Flag() const;
       
   577 	//
       
   578 	inline void SetDeletedIMAP4Flag(TBool aDeleted);
       
   579 	inline TBool DeletedIMAP4Flag() const;
       
   580 	//
       
   581 	inline void SetDraftIMAP4Flag(TBool aDraft);
       
   582 	inline TBool DraftIMAP4Flag() const;
       
   583 	//
       
   584 	inline void SetRecentIMAP4Flag(TBool aRecent);
       
   585 	inline TBool RecentIMAP4Flag() const;
       
   586 	//
       
   587 	inline void SetMailbox(TBool aMailbox);
       
   588 	inline TBool Mailbox() const;
       
   589 	//
       
   590 	inline TBool Orphan() const;
       
   591 
       
   592 	inline void SetOrphan(TBool aOrphan);
       
   593 	//
       
   594 	inline void SetValidUID(TBool aValid);
       
   595 	inline TBool ValidUID() const;
       
   596 	//
       
   597 	inline void SetSubscribed(TBool aSubscribed);
       
   598 	inline TBool Subscribed() const;
       
   599 	//
       
   600 	inline void SetLocalSubscription(TBool aLocal);		// i.e. is subscription local, or remote
       
   601 	inline TBool LocalSubscription() const;
       
   602 	//
       
   603 	inline void SetUID(TUint32 aUid);
       
   604 	inline TUint32 UID() const;
       
   605 	//
       
   606 	inline TInt RemoteFolderEntries() const;
       
   607 	inline void SetRemoteFolderEntries(TInt aEntries);
       
   608 
       
   609 private:
       
   610 	enum TMsvEmailEntryFlags
       
   611 		{	
       
   612 		KMsvEmailEntryClearFlag				=0x00,
       
   613 		// Flags set on Message entries...
       
   614 		KMsvEmailEntryEncryptedFlag			=0x00000001,
       
   615 		KMsvEmailEntrySignedFlag			=0x00000002,
       
   616 		KMsvEmailEntryReceiptFlag			=0x00000004,
       
   617 		KMsvEmailEntryOrphanFlag			=0x00000008,
       
   618 
       
   619 		// VCard and VCalendar entries may be set on folders or attachments
       
   620 		KMsvEmailEntryVCardFlag				=0x00000010,
       
   621 		KMsvEmailEntryVCalendarFlag			=0x00000020,
       
   622 
       
   623 		// Message contains HTML data
       
   624 		// (Note: HTML and not only MHTML)
       
   625 		KMsvEmailEntryMHTMLFlag				= 0x00000040,
       
   626 		KMsvEmailEntryBodyTextCompleteFlag	= 0x00000080,
       
   627 
       
   628 		KMsvEmailEntryNoDisconnectedOperations					= 0x00000000,
       
   629 		KMsvEmailEntryDisconnectedCreateOperation				= 0x00000100,
       
   630 		KMsvEmailEntryDisconnectedDeleteOperation				= 0x00000200,
       
   631 		KMsvEmailEntryDisconnectedChangeOperation				= 0x00000300,
       
   632 		KMsvEmailEntryDisconnectedCopyToOperation				= 0x00000400,
       
   633 		KMsvEmailEntryDisconnectedCopyFromOperation				= 0x00000500,
       
   634 		KMsvEmailEntryDisconnectedCopyWithinServiceOperation	= 0x00000600,
       
   635 		KMsvEmailEntryDisconnectedMoveToOperation				= 0x00000700,
       
   636 		KMsvEmailEntryDisconnectedMoveFromOperation				= 0x00000800,
       
   637 		KMsvEmailEntryDisconnectedMoveWithinServiceOperation	= 0x00000900,
       
   638 		KMsvEmailEntryDisconnectedSpecialOperation				= 0x00000A00,
       
   639 		KMsvEmailEntryDisconnectedUnknownOperation				= 0x00000B00,
       
   640 		KMsvEmailEntryDisconnectedMultipleOperation				= 0x00000C00,
       
   641 		KMsvEmailEntryDisconnectedOperation						= 0x00000F00,
       
   642 
       
   643 		// IMAP4-specific masks. Can be re-used by non-IMAP4 entries (eg POP3, SMTP)
       
   644 		KMsvEmailEntryIMAP4SubscribedFlag	=0x00001000,
       
   645 		KMsvEmailEntryIMAP4UnreadFlag		=0x00002000,
       
   646 		KMsvEmailEntryIMAP4SeenFlag			=0x00004000,
       
   647 		KMsvEmailEntryIMAP4AnsweredFlag		=0x00008000,	
       
   648 		KMsvEmailEntryIMAP4FlaggedFlag		=0x00010000,	
       
   649 		KMsvEmailEntryIMAP4DeletedFlag		=0x00020000,	
       
   650 		KMsvEmailEntryIMAP4DraftFlag		=0x00040000,	
       
   651 		KMsvEmailEntryIMAP4RecentFlag		=0x00080000,	
       
   652 		KMsvEmailEntryIMAP4ValidUIDFlag		=0x00100000,
       
   653 		KMsvEmailEntryIMAP4MailboxFlag		=0x00200000,
       
   654 		KMsvEmailEntryIMAP4LocalSubFlag		=0x00400000,
       
   655 
       
   656 		// MIME "multipart" types assigned to folders. 
       
   657 		KMsvMimeFolderUnknownMask			=0x00000000,
       
   658 		KMsvMimeFolderRelatedMask			=0x01000000,
       
   659 		KMsvMimeFolderMixedMask				=0x02000000,
       
   660 		KMsvMimeFolderAlternativeMask		=0x03000000,
       
   661 		KMsvMimeFolderParallelMask			=0x04000000,
       
   662 		KMsvMimeFolderDigestMask			=0x05000000,
       
   663 
       
   664 		// MIME message types
       
   665 		KMsvMimeFolderRFC822Mask			=0x06000000,
       
   666 		KMsvMimeFolderPartialMask			=0x07000000,
       
   667 		KMsvMimeFolderDirectoryMask			=0x08000000,	// for VCard, VCalendar types
       
   668 		KMsvMimeFolderExternalMask			=0x09000000,
       
   669 		KMsvMimeFolderMask					=0x0F000000,
       
   670 		
       
   671 		// Can be used by POP3 and IMAP4 MTMs.
       
   672 		KMsvEmailEntryPartialDownloadFlag	=0x10000000,
       
   673 		
       
   674 		KMsvEmailEntryICalendarFlag			=0x20000000
       
   675 		};
       
   676 
       
   677 	};
       
   678 
       
   679 const TUint16 KImMimeHeaderVersion = 2; // identify which version of this class has been stored
       
   680 
       
   681 class CImMimeHeader : public CBase
       
   682 /** Stores a MIME email header. 
       
   683 @publishedAll
       
   684 @released
       
   685 */
       
   686 	{
       
   687 public:
       
   688 	IMPORT_C static CImMimeHeader* NewLC();
       
   689 	IMPORT_C static CImMimeHeader* NewL();
       
   690 	IMPORT_C ~CImMimeHeader();
       
   691 	IMPORT_C void Reset();
       
   692 	IMPORT_C TInt Size();	// number of header fields stored in object
       
   693 
       
   694 	// streaming operations
       
   695 	IMPORT_C void InternalizeL( RMsvReadStream& aReadStream );
       
   696 	IMPORT_C void ExternalizeL( RMsvWriteStream& aWriteStream ) const;
       
   697 	IMPORT_C void StoreWithoutCommitL(CMsvStore& aMessageStore) const;
       
   698 	IMPORT_C void RestoreL( CMsvStore& aMessageStore );
       
   699 	IMPORT_C void StoreL  ( CMsvStore& aMessageStore ) const;
       
   700 
       
   701 
       
   702 	/** Sets the Content-Type field value (e.g. "text" in Content-Type:text/plain). 
       
   703 	
       
   704 	The value is MIME defined and should always be 8-bit. 
       
   705 	
       
   706 	@param aPath Field value */
       
   707 	IMPORT_C void SetContentTypeL(const TDesC8& aPath);
       
   708 	IMPORT_C const TPtrC8 ContentType() const;
       
   709 
       
   710 	/** Sets the Content-Type subtype field value (e.g. "plain" in Content-Type:text/plain). 
       
   711 	
       
   712 	
       
   713 	The value is MIME defined and should always be 8-bit. 
       
   714 	
       
   715 	@param aPath Field value */
       
   716 	IMPORT_C void SetContentSubTypeL(const TDesC8& aPath);
       
   717 	IMPORT_C const TPtrC8 ContentSubType() const;
       
   718 
       
   719 	/** Sets the Content-Disposition field value (either inline or attachment). 
       
   720 	
       
   721 	The value is MIME defined and should always be 8-bit. 
       
   722 	
       
   723 	@param aPath Field value */
       
   724 	IMPORT_C void SetContentDispositionL(const TDesC8& aPath);
       
   725 	IMPORT_C const TPtrC8 ContentDisposition() const;
       
   726 
       
   727 	/** Sets the Content-Description field value.
       
   728 	
       
   729 	The value is MIME defined and should always be 8-bit. 
       
   730 	
       
   731 	@param aPath Field value */
       
   732 	IMPORT_C void SetContentDescriptionL(const TDesC8& aPath);
       
   733 	IMPORT_C const TPtrC8 ContentDescription() const;
       
   734 
       
   735 	/** Sets the Content-Base field value.
       
   736 	
       
   737 	@param aPath Field value */
       
   738 	IMPORT_C void SetContentBaseL(const TDesC8& aPath);
       
   739 	IMPORT_C const TPtrC8 ContentBase() const;
       
   740 
       
   741 	/** Sets the Content-ID field value.
       
   742 	
       
   743 	@param aPath Field value */
       
   744 	IMPORT_C void SetContentIDL(const TDesC8& aPath);
       
   745 	IMPORT_C const TPtrC8 ContentID() const;
       
   746 
       
   747 	/** Sets the Content-Location field value.
       
   748 	
       
   749 	@param aPath Field value */
       
   750 	IMPORT_C void SetContentLocationL(const TDesC16& aPath);
       
   751 	IMPORT_C const TPtrC16 ContentLocation() const;
       
   752 
       
   753 	// IMAP-specific info describing relative location of entry w.r.t. parent Email message
       
   754 	/** Sets IMAP-specific information for the relative location of the entry to the 
       
   755 	parent email message.
       
   756 	
       
   757 	@param aPath Relative location */
       
   758 	IMPORT_C void SetRelativePathL(const TDesC8& aPath);
       
   759 	IMPORT_C const TPtrC8 RelativePath() const;
       
   760 
       
   761 	/** Sets the Content-Transfer-Encoding field value.
       
   762 	
       
   763 	@param aType Field value */
       
   764 	IMPORT_C void SetContentTransferEncodingL(const TDesC8& aType);
       
   765 	IMPORT_C TImEncodingType ContentTransferEncoding() const;
       
   766 	IMPORT_C TImEncodingType ContentTransferEncoding(TDes8& rType) const;
       
   767 	IMPORT_C const TPtrC8 GetContentTypeValue(const TDesC8& aContentTypeParameter) const;
       
   768 
       
   769 	// inlines to access arrays
       
   770 	inline const CDesC8Array& ContentTypeParams() const;
       
   771 	inline const CDesC8Array& ContentDispositionParams() const;
       
   772 	inline const CDesC8Array& XTypeParams() const;
       
   773 
       
   774 	inline CDesC8Array& ContentTypeParams();
       
   775 	inline CDesC8Array& ContentDispositionParams();
       
   776 	inline CDesC8Array& XTypeParams();		// anything else that is in the header, but not recognised
       
   777 
       
   778 	inline const TUint16 Version() const;
       
   779 	inline void SetVersion( TUint16 aVersion );
       
   780 
       
   781 	IMPORT_C void SetMimeCharset(const TUint aCharset);
       
   782 	IMPORT_C TUint MimeCharset() const;
       
   783 
       
   784 private:
       
   785 	CImMimeHeader();
       
   786 	void ConstructL();
       
   787 	TBool ArrayEntryExists(CDesCArray& aArray, TInt aField);
       
   788 
       
   789 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   790 	void ReStoreMimeDBL(CMsvStore& aMessageStore);
       
   791 	void StoreMimeDBL  (CMsvStore& aMessageStore) const;
       
   792 	void CreateMimeArrayListL(TPtrC16 astr1 ,TInt ai);
       
   793 	TInt BufSize() const;
       
   794 #endif 
       
   795 private:
       
   796 	TUint16 iVersion;
       
   797 	HBufC8* iRelativePath;
       
   798 	HBufC8* iContentDescription;
       
   799 
       
   800 	TImEncodingType iContentTransferEncoding;
       
   801 
       
   802 	// MHTML parameters
       
   803 	HBufC8* iContentBase;
       
   804 	HBufC16* iContentLocation;
       
   805 	HBufC8* iContentID;
       
   806 	//
       
   807 	HBufC8* iContentType;
       
   808 	HBufC8* iContentSubType;
       
   809 	HBufC8* iContentDisposition;
       
   810 	//
       
   811 	CDesC8Array* iContentTypeParams;			// zero or more "parameter"
       
   812 	CDesC8Array* iContentDispositionParams;		// zero or more "parameters"
       
   813 	CDesC8Array* iXTypeParams;					// zero or more X-Type "parameters"
       
   814 	//
       
   815 	TBuf<20> iContentTransferEncodingBuffer;	// must be big enough to store "quoted-printable" string
       
   816 
       
   817 	// The uid value is always used in preference to the stored string.
       
   818 	// Only when the uid is not set is the string used when sending.
       
   819 	TUint iMimeCharset;	
       
   820 	};
       
   821 
       
   822 
       
   823 
       
   824 /**
       
   825  * Convert16to8L()
       
   826  *
       
   827  * Convert the 16 bit descripter to 8 bit.
       
   828  * @param astr A descripter to be convert into 8 bit discripter.
       
   829  * @return HBufC16* A 8 bit discripter.
       
   830  */
       
   831 static inline HBufC8* Convert16to8L(TDesC16& aStr)//const
       
   832 	{
       
   833 	HBufC8* newFrom1 = HBufC8::NewL(aStr.Length());
       
   834 	newFrom1->Des().Copy(aStr);
       
   835 	return newFrom1;
       
   836 	}
       
   837 
       
   838 
       
   839 /**
       
   840  * ConvertToTInt()
       
   841  * 
       
   842  * Converts a string to an integer.
       
   843  * @param aStr A string to make Integer.
       
   844  * @return TInt A integer value 
       
   845  */
       
   846 static inline TInt ConvertToTInt(TDesC16& aStr)
       
   847 	{
       
   848 	TLex string(aStr);
       
   849 	TInt32 stringIntValue;
       
   850 	string.Val(stringIntValue);
       
   851 	return stringIntValue;
       
   852 	}
       
   853 
       
   854 
       
   855 #include <miuthdr.inl>
       
   856 
       
   857 #endif // #defined __MIUTHDR_H__