epoc32/include/app/miuthdr.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1998-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 // MIUTHDR.H
    14 //
    15 //
       
    16 
       
    17 /**
       
    18  * @file 
       
    19  * @publishedAll
       
    20  * @released
       
    21  */
    15 
    22 
    16 #ifndef __MIUTHDR_H__
    23 #ifndef __MIUTHDR_H__
    17 #define __MIUTHDR_H__
    24 #define __MIUTHDR_H__
    18 
    25 
    19 #include <s32strm.h>
    26 #include <s32strm.h>
    20 #include <badesca.h>
    27 #include <badesca.h>
    21 #include <pop3cmds.h>
    28 #include <pop3cmds.h>
    22 #include <msvstd.h>
    29 #include <msvstd.h>
    23 #include <msvids.h>			// KMsvNullIndexEntryId
    30 #include <msvids.h>			// KMsvNullIndexEntryId
    24 #include <miutstd.hrh>			// KUidMsvEmailTextEntryValue
    31 #include <miutstd.hrh>			// KUidMsvEmailTextEntryValue
    25 
    32 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS  
    26 // IMail-specific stream type within an IMail file store for CImHeader
    33 #include "timrfc822datefield.h"
       
    34 #endif
       
    35 /** 
       
    36  * IMail-specific stream type within an IMail file store for CImHeader
       
    37  * @publishedAll
       
    38  * @released
       
    39  */
    27 const TUid KUidMsgFileMimeHeader	= {0x1000160F};		// 268441103 decimal
    40 const TUid KUidMsgFileMimeHeader	= {0x1000160F};		// 268441103 decimal
    28 // IMail-specific stream type within an IMail file store for CImMimeHeader
    41 /** 
       
    42  * IMail-specific stream type within an IMail file store for CImMimeHeader
       
    43  * @publishedAll
       
    44  * @released
       
    45  */
    29 const TUid KUidMsgFileIMailHeader	= {0x100001D8};		// 268435928 decimal
    46 const TUid KUidMsgFileIMailHeader	= {0x100001D8};		// 268435928 decimal
    30 
    47 
    31 // Identifies which version of CImHeader has been stored in stream
    48 /** 
    32 const TUint16 KImHeaderVersion = 2; 
    49  * @publishedAll
    33 
    50  * @released
    34 const TUid KUidMsvEmailTextEntry			= {KUidMsvEmailTextEntryValue};
    51  */
    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;
    52 class CMsvStore;
    72 class TMsvEntry;
    53 class TMsvEntry;
    73 class RMsvReadStream;
    54 class RMsvReadStream;
    74 class RMsvWriteStream;
    55 class RMsvWriteStream;
    75 class CImConvertHeader;
    56 /** 
       
    57  * @internalTechnology
       
    58  * @released
       
    59  */
    76 class CImEncodedHeader;
    60 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 
    61 
    88 /** Defines how emails will be encoded when they are sent.
    62 /** Defines how emails will be encoded when they are sent.
    89 
    63 
    90 MIME standards are defined in RFC 2045, RFC 2046 and RFC 2047. 
    64 MIME standards are defined in RFC 2045, RFC 2046 and RFC 2047. 
    91 @publishedAll
    65 @publishedAll
   258 	IMPORT_C void ExternalizeL(RMsvWriteStream& aWriteStream) const;
   232 	IMPORT_C void ExternalizeL(RMsvWriteStream& aWriteStream) const;
   259 	IMPORT_C void RestoreL(CMsvStore& aMessageStore);
   233 	IMPORT_C void RestoreL(CMsvStore& aMessageStore);
   260 	IMPORT_C void StoreL  (CMsvStore& aMessageStore) const;
   234 	IMPORT_C void StoreL  (CMsvStore& aMessageStore) const;
   261 	IMPORT_C void StoreWithoutCommitL(CMsvStore& aMessageStore) const;
   235 	IMPORT_C void StoreWithoutCommitL(CMsvStore& aMessageStore) const;
   262 
   236 
       
   237 
   263 	// the bulk of the member functions are accessors & mutators so we can use
   238 	// 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
   239 	// objects of the class as data repositories during the data-marshalling stage
   265 	// of getting imail headers to/from the internet
   240 	// of getting imail headers to/from the internet
   266 	IMPORT_C const TPtrC Subject() const;
   241 	IMPORT_C const TPtrC Subject() const;
   267 	IMPORT_C void SetSubjectL(const TDesC8& aSubject);
   242 	IMPORT_C void SetSubjectL(const TDesC8& aSubject);
   370 	void FormatSubjectL(CImHeader&, TDesC&);
   345 	void FormatSubjectL(CImHeader&, TDesC&);
   371 
   346 
   372 	//finds the duplicate recipients in To and Cc list
   347 	//finds the duplicate recipients in To and Cc list
   373 	TBool IsRecipientPresent(CImHeader& aCImHeader, TPtrC16 newRecipient);
   348 	TBool IsRecipientPresent(CImHeader& aCImHeader, TPtrC16 newRecipient);
   374 
   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 
   375 private:
   358 private:
   376 	TUint16 iVersion;
   359 	TUint16 iVersion;
   377 
   360 
   378 	HBufC16* iFrom;
   361 	HBufC16* iFrom;
   379 	HBufC* iSubject;
   362 	HBufC* iSubject;
   403 	// The character set to be when sending message.
   386 	// The character set to be when sending message.
   404 	// Overrides the charset passed in from the settings.
   387 	// Overrides the charset passed in from the settings.
   405 	TUint							i822HeaderCharset; 
   388 	TUint							i822HeaderCharset; 
   406 
   389 
   407 	CImEncodedHeader* iEncodedHeader;
   390 	CImEncodedHeader* iEncodedHeader;
       
   391 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   392 	friend class CTestEmailHeaderStoreReStore;
       
   393 #endif 
   408 	};
   394 	};
   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 
   395 
   426 /** Folder type flags.
   396 /** Folder type flags.
   427 
   397 
   428 The flags correspond to the MIME multipart subtype. 
   398 The flags correspond to the MIME multipart subtype. 
   429 @publishedAll
   399 @publishedAll
   722 	IMPORT_C TInt Size();	// number of header fields stored in object
   692 	IMPORT_C TInt Size();	// number of header fields stored in object
   723 
   693 
   724 	// streaming operations
   694 	// streaming operations
   725 	IMPORT_C void InternalizeL( RMsvReadStream& aReadStream );
   695 	IMPORT_C void InternalizeL( RMsvReadStream& aReadStream );
   726 	IMPORT_C void ExternalizeL( RMsvWriteStream& aWriteStream ) const;
   696 	IMPORT_C void ExternalizeL( RMsvWriteStream& aWriteStream ) const;
       
   697 	IMPORT_C void StoreWithoutCommitL(CMsvStore& aMessageStore) const;
   727 	IMPORT_C void RestoreL( CMsvStore& aMessageStore );
   698 	IMPORT_C void RestoreL( CMsvStore& aMessageStore );
   728 	IMPORT_C void StoreL  ( CMsvStore& aMessageStore ) const;
   699 	IMPORT_C void StoreL  ( CMsvStore& aMessageStore ) const;
   729 	IMPORT_C void StoreWithoutCommitL(CMsvStore& aMessageStore) const;
   700 
   730 
   701 
   731 	/** Sets the Content-Type field value (e.g. "text" in Content-Type:text/plain). 
   702 	/** Sets the Content-Type field value (e.g. "text" in Content-Type:text/plain). 
   732 	
   703 	
   733 	The value is MIME defined and should always be 8-bit. 
   704 	The value is MIME defined and should always be 8-bit. 
   734 	
   705 	
   813 private:
   784 private:
   814 	CImMimeHeader();
   785 	CImMimeHeader();
   815 	void ConstructL();
   786 	void ConstructL();
   816 	TBool ArrayEntryExists(CDesCArray& aArray, TInt aField);
   787 	TBool ArrayEntryExists(CDesCArray& aArray, TInt aField);
   817 
   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 
   818 private:
   795 private:
   819 	TUint16 iVersion;
   796 	TUint16 iVersion;
   820 	HBufC8* iRelativePath;
   797 	HBufC8* iRelativePath;
   821 	HBufC8* iContentDescription;
   798 	HBufC8* iContentDescription;
   822 
   799 
   842 	TUint iMimeCharset;	
   819 	TUint iMimeCharset;	
   843 	};
   820 	};
   844 
   821 
   845 
   822 
   846 
   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 
   847 #include <miuthdr.inl>
   855 #include <miuthdr.inl>
   848 
   856 
   849 #endif // #defined __MIUTHDR_H__
   857 #endif // #defined __MIUTHDR_H__