1 // Copyright (c) 1999-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MIUTCONV_H__
17 #define __MIUTCONV_H__
22 #if !defined (__CHARCONV_H_)
26 #if !defined (__MIUTHDR_H__)
30 #if !defined (__UTF_H_)
34 // IMail-specific stream type within an IMail file store for TImEmailTransformingInfo
36 const TUint KUidMsvCharsetNone = {0x10003C7F}; // 268450943
37 const TUid KUidMsgFileTransformingInfo = {0x100094A5}; // 268473509
38 const TUid KUidMsgEmailGeneralCenRep = {0x10285A25}; // 271079973
40 // No longer used as the charset information retrieved from resource file.
41 // Might possibly needed in the future ? maybe
42 // const TUid KUidMiutSystemDefaultCharset = {0x10009418}; // 268473368
43 // const TUid KUidMiutOverrideCharset = {0x10009419}; // 268473369
45 _LIT8(KMiutUndisplayableChar, "?");
47 /** SMTP send methods.
60 // Information to be used when sending an email message.
61 // Relating to how parts are encoded and converted.
63 class TImEmailTransformingInfo
64 /** Encapsulates character conversion and encoding settings for sending SMTP email.
66 The default outcomes for header, body, HTML, and attachment parts respectively
67 for each of the listed categories are given below:
69 Plain Charset: ISO-8859-1,ISO-8859-1,N/A,N/A
71 Plain Encoding:None,None,N/A,UU
73 MIME Charset:UTF8,UTF8,UTF8*,N/A
75 MIME Encoding:B,QP,Base64,Base64
77 *: the UTF8 value set in the header field, but no conversion is done. The
78 HTML converter converts to UTF8.
84 IMPORT_C TImEmailTransformingInfo& operator=(const TImEmailTransformingInfo& aInfo);
85 IMPORT_C TBool operator==(const TImEmailTransformingInfo& aInfo);
87 // streaming operations
88 IMPORT_C void ExternalizeL( RWriteStream& aWriteStream ) const;
89 IMPORT_C void InternalizeL( RReadStream& aReadStream );
90 IMPORT_C void StoreL( CMsvStore& aStore ) const;
91 IMPORT_C void RestoreL( CMsvStore& aStore );
94 IMPORT_C void SetToDefault(const TImSendMethod aMethod);
95 IMPORT_C void SetSendMethod(const TImSendMethod aMethod);
96 IMPORT_C TImSendMethod SendMethod() const;
98 IMPORT_C void SetHeaderEncodingQ();
99 IMPORT_C void SetHeaderEncodingB();
100 IMPORT_C void SetBodyTextEncoding(TImEncodingType aType);
101 IMPORT_C void SetHTMLEncoding(TImEncodingType aType);
102 IMPORT_C void SetAttachmentEncoding(TImEncodingType aType);
104 IMPORT_C void SetHeaderAndBodyCharset(TUint aCharset);
105 IMPORT_C void SetHeaderCharset(TUint aCharset);
106 IMPORT_C void SetBodyTextCharset(TUint aCharset);
107 IMPORT_C void SetHTMLCharset(TUint aCharset);
109 // Accessor functions
110 IMPORT_C TImEncodingType HeaderEncoding() const;
111 IMPORT_C TImEncodingType BodyTextEncoding() const;
112 IMPORT_C TImEncodingType HTMLEncoding() const;
113 IMPORT_C TImEncodingType AttachmentEncoding() const;
115 IMPORT_C TUint HeaderCharset() const;
116 IMPORT_C TUint BodyTextCharset() const;
117 IMPORT_C TUint HTMLCharset() const;
120 void SetHeaderEncoding(TImEncodingType aType);
123 TImEncodingType iHeaderEncoding;
124 TImEncodingType iBodyEncoding;
125 TImEncodingType iHTMLEncoding;
126 TImEncodingType iAttachmentEncoding;
128 TUint iHeaderCharset;
131 TUint iTextAttachmentCharset;
133 TImSendMethod iSendMethod;
137 // Default Sending Charset/Encoding Values
138 const TImEncodingType KDefaultMIMEHeaderEncoding = EEncodingTypeBASE64; // MIME
139 const TImEncodingType KDefaultMIMEBodyTextEncoding = EEncodingTypeQP;
140 const TImEncodingType KDefaultMIMEHTMLEncoding = EEncodingTypeBASE64;
141 const TImEncodingType KDefaultMIMEAttachmentEncoding= EEncodingTypeBASE64;
143 #define KDefaultPlainCharset KCharacterSetIdentifierIso88591
145 const TImEncodingType KDefaultPlainHeaderEncoding = EEncodingTypeNone; // Non-MIME or Plain
146 const TImEncodingType KDefaultPlainBodyTextEncoding = EEncodingTypeNone;
147 const TImEncodingType KDefaultPlainAttachmentEncoding = EEncodingTypeUU;
152 // Wrapper class for CHARCONV.
153 // 'Our' charset dependant on build, UNICODE or CodePage 1252.
155 class CImConvertCharconv : public CBase
162 IMPORT_C static CImConvertCharconv* NewL(CCnvCharacterSetConverter& aConverter, RFs& anFs);
163 ~CImConvertCharconv();
165 // MUST call prepare function first.
166 IMPORT_C TInt ConvertToOurCharsetL( const TDesC8& aBufIn, TDes& rBufOut,
167 TInt& rNumUnconvertedChars,
168 TInt& rIndexOfFirstUnconvertedChar);
169 IMPORT_C TInt ConvertFromOurCharsetL(const TDesC& aBufIn, TDes8& rBufOut,
170 TInt& rNumUnconvertedChars,
171 TInt& rIndexOfFirstUnconvertedChar);
173 // MUST be called prior to calling above two functions.
174 IMPORT_C TInt PrepareToConvertToFromOurCharsetL(const TUint aUid);
176 IMPORT_C TUint GetMimeCharsetUidL(const TDesC8& aBufIn) const;
177 IMPORT_C HBufC8* GetMimeCharsetTextStringL(const TUint& aUid) const;
178 IMPORT_C TUint DefaultCharset() const;
179 IMPORT_C TUint SystemDefaultCharset() const;
181 static TInt StraightCopy( const TDesC8& aBufIn, TDes& rBufOut);
182 static TInt StraightCopy( const TDesC& aBufIn, TDes8& rBufOut);
185 CImConvertCharconv(CCnvCharacterSetConverter& aConverter, RFs& anFs);
186 TBool CharsetAvailable(const TUint aUid);
187 void SetSystemDefaultCharsetL();
189 TInt GetSystemCharsetFromCenRepL(TDes8& aMimeCharSet);
191 enum TEmailGeneralSettingsCenRepId
193 EEmailGeneralCharSetId = 0x00000000
197 CCnvCharacterSetConverter& iConverter;
198 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iCharsetsAvailable;
202 TUint iSystemDefaultCharset; // Value obtained from .ini file