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