|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __MIUTCONV_H__ |
|
17 #define __MIUTCONV_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 |
|
22 #if !defined (__CHARCONV_H_) |
|
23 #include <charconv.h> |
|
24 #endif |
|
25 |
|
26 #if !defined (__MIUTHDR_H__) |
|
27 #include <miuthdr.h> |
|
28 #endif |
|
29 |
|
30 #if !defined (__UTF_H_) |
|
31 #include <utf.h> |
|
32 #endif |
|
33 |
|
34 // IMail-specific stream type within an IMail file store for TImEmailTransformingInfo |
|
35 // |
|
36 const TUint KUidMsvCharsetNone = {0x10003C7F}; // 268450943 |
|
37 const TUid KUidMsgFileTransformingInfo = {0x100094A5}; // 268473509 |
|
38 const TUid KUidMsgEmailGeneralCenRep = {0x10285A25}; // 271079973 |
|
39 |
|
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 |
|
44 |
|
45 _LIT8(KMiutUndisplayableChar, "?"); |
|
46 |
|
47 /** SMTP send methods. |
|
48 @publishedAll |
|
49 @released |
|
50 */ |
|
51 enum TImSendMethod |
|
52 { |
|
53 /** Simple email. */ |
|
54 ESendAsSimpleEmail, |
|
55 /** MIME email. */ |
|
56 ESendAsMimeEmail |
|
57 }; |
|
58 |
|
59 |
|
60 // Information to be used when sending an email message. |
|
61 // Relating to how parts are encoded and converted. |
|
62 // |
|
63 class TImEmailTransformingInfo |
|
64 /** Encapsulates character conversion and encoding settings for sending SMTP email. |
|
65 |
|
66 The default outcomes for header, body, HTML, and attachment parts respectively |
|
67 for each of the listed categories are given below: |
|
68 |
|
69 Plain Charset: ISO-8859-1,ISO-8859-1,N/A,N/A |
|
70 |
|
71 Plain Encoding:None,None,N/A,UU |
|
72 |
|
73 MIME Charset:UTF8,UTF8,UTF8*,N/A |
|
74 |
|
75 MIME Encoding:B,QP,Base64,Base64 |
|
76 |
|
77 *: the UTF8 value set in the header field, but no conversion is done. The |
|
78 HTML converter converts to UTF8. |
|
79 @publishedAll |
|
80 @released |
|
81 */ |
|
82 { |
|
83 public: |
|
84 IMPORT_C TImEmailTransformingInfo& operator=(const TImEmailTransformingInfo& aInfo); |
|
85 IMPORT_C TBool operator==(const TImEmailTransformingInfo& aInfo); |
|
86 |
|
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 ); |
|
92 |
|
93 // Setting functions |
|
94 IMPORT_C void SetToDefault(const TImSendMethod aMethod); |
|
95 IMPORT_C void SetSendMethod(const TImSendMethod aMethod); |
|
96 IMPORT_C TImSendMethod SendMethod() const; |
|
97 |
|
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); |
|
103 |
|
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); |
|
108 |
|
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; |
|
114 |
|
115 IMPORT_C TUint HeaderCharset() const; |
|
116 IMPORT_C TUint BodyTextCharset() const; |
|
117 IMPORT_C TUint HTMLCharset() const; |
|
118 |
|
119 private: |
|
120 void SetHeaderEncoding(TImEncodingType aType); |
|
121 |
|
122 private: |
|
123 TImEncodingType iHeaderEncoding; |
|
124 TImEncodingType iBodyEncoding; |
|
125 TImEncodingType iHTMLEncoding; |
|
126 TImEncodingType iAttachmentEncoding; |
|
127 |
|
128 TUint iHeaderCharset; |
|
129 TUint iBodyCharset; |
|
130 TUint iHTMLCharset; |
|
131 TUint iTextAttachmentCharset; |
|
132 |
|
133 TImSendMethod iSendMethod; |
|
134 }; |
|
135 |
|
136 |
|
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; |
|
142 |
|
143 #define KDefaultPlainCharset KCharacterSetIdentifierIso88591 |
|
144 |
|
145 const TImEncodingType KDefaultPlainHeaderEncoding = EEncodingTypeNone; // Non-MIME or Plain |
|
146 const TImEncodingType KDefaultPlainBodyTextEncoding = EEncodingTypeNone; |
|
147 const TImEncodingType KDefaultPlainAttachmentEncoding = EEncodingTypeUU; |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 // Wrapper class for CHARCONV. |
|
153 // 'Our' charset dependant on build, UNICODE or CodePage 1252. |
|
154 // |
|
155 class CImConvertCharconv : public CBase |
|
156 /** |
|
157 @internalTechnology |
|
158 @released |
|
159 */ |
|
160 { |
|
161 public: |
|
162 IMPORT_C static CImConvertCharconv* NewL(CCnvCharacterSetConverter& aConverter, RFs& anFs); |
|
163 ~CImConvertCharconv(); |
|
164 |
|
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); |
|
172 |
|
173 // MUST be called prior to calling above two functions. |
|
174 IMPORT_C TInt PrepareToConvertToFromOurCharsetL(const TUint aUid); |
|
175 |
|
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; |
|
180 |
|
181 static TInt StraightCopy( const TDesC8& aBufIn, TDes& rBufOut); |
|
182 static TInt StraightCopy( const TDesC& aBufIn, TDes8& rBufOut); |
|
183 private: |
|
184 void ConstructL(); |
|
185 CImConvertCharconv(CCnvCharacterSetConverter& aConverter, RFs& anFs); |
|
186 TBool CharsetAvailable(const TUint aUid); |
|
187 void SetSystemDefaultCharsetL(); |
|
188 |
|
189 TInt GetSystemCharsetFromCenRepL(TDes8& aMimeCharSet); |
|
190 |
|
191 enum TEmailGeneralSettingsCenRepId |
|
192 { |
|
193 EEmailGeneralCharSetId = 0x00000000 |
|
194 }; |
|
195 |
|
196 private: |
|
197 CCnvCharacterSetConverter& iConverter; |
|
198 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* iCharsetsAvailable; |
|
199 |
|
200 RFs& iFs; |
|
201 TUint iCharsetUid; |
|
202 TUint iSystemDefaultCharset; // Value obtained from .ini file |
|
203 TInt iCharconvState; |
|
204 }; |
|
205 |
|
206 #endif |