|
1 // Copyright (c) 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 // cimconvertheader.h |
|
15 // |
|
16 /** |
|
17 * @file |
|
18 * @internal |
|
19 * @released |
|
20 */ |
|
21 |
|
22 #if !defined(__CIMCONVERTHEADER_H__) |
|
23 #define __CIMCONVERTHEADER_H__ |
|
24 |
|
25 #include <s32buf.h> |
|
26 #include <s32stor.h> |
|
27 #include <txtrich.h> |
|
28 #include <miutatch.h> |
|
29 #include <miutconv.h> |
|
30 #include <miuthdr.h> |
|
31 #include <mentact.h> // CMsgActive |
|
32 |
|
33 #include <imcvdata.h> |
|
34 #include <imcvtext.h> |
|
35 #include <imutdll.h> |
|
36 #include <imcvcodc.h> |
|
37 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
38 #include "timrfc822datefield.h" |
|
39 #include "cimconvertcharconv.h" |
|
40 #endif |
|
41 |
|
42 /** |
|
43 Maximum length allowed for an 'encoded-word' rfc2047 |
|
44 @internalComponent |
|
45 @released |
|
46 */ |
|
47 const TInt KEncodedWordMaxLength = 75; |
|
48 |
|
49 /** |
|
50 All encoding information except data and charset name length. =?B?=? => 7 |
|
51 @internalComponent |
|
52 @released |
|
53 */ |
|
54 const TInt KMaxEncodedInformationLength = 7; |
|
55 |
|
56 /** |
|
57 Length of the field name, eg "Subject: ". This may change as other fields are processed. |
|
58 @internalComponent |
|
59 @released |
|
60 */ |
|
61 const TInt KMaxHeaderFieldNameLength = 12; |
|
62 |
|
63 /** |
|
64 @internalComponent |
|
65 @released |
|
66 */ |
|
67 const TInt KImCvFinished=(-1); |
|
68 const TInt KImCvAdvance=(1); |
|
69 |
|
70 // error states involved in sending attachments etc. |
|
71 /** |
|
72 @internalComponent |
|
73 @deprecated |
|
74 */ |
|
75 enum TIattErrorCode |
|
76 { |
|
77 KImAttNoError = 0, |
|
78 KImAttFinished = 1 |
|
79 }; |
|
80 |
|
81 |
|
82 /** |
|
83 @internalComponent |
|
84 @released |
|
85 */ |
|
86 enum TImBodyConvAlgorithm |
|
87 { |
|
88 ENoAlgorithm, |
|
89 EQPEncode, |
|
90 EQPDecode, |
|
91 EBase64Encode, |
|
92 EBase64Decode, |
|
93 EUUEncode, |
|
94 EUUDecode |
|
95 }; |
|
96 |
|
97 // Used in CImSendConvert |
|
98 /** |
|
99 @internalComponent |
|
100 @deprecated |
|
101 */ |
|
102 enum TImSendEncoding |
|
103 { |
|
104 ESendNoAlgorithm, |
|
105 ESendMimeAlgorithm |
|
106 }; |
|
107 |
|
108 struct SAttachmentInfo |
|
109 /** |
|
110 @internalComponent |
|
111 @released |
|
112 */ |
|
113 { |
|
114 TInt iSize; |
|
115 TFileName iName; |
|
116 TFileName iPath; |
|
117 TBool iComplete; |
|
118 }; |
|
119 |
|
120 class TImCodecB64WithLineBreaks : public TImCodecB64 |
|
121 /** |
|
122 @internalComponent |
|
123 @released |
|
124 */ |
|
125 { |
|
126 public: |
|
127 TInt Encode(const TDesC8& aSrcString, TDes8& rDestString); |
|
128 }; |
|
129 |
|
130 // For converting a text string to/from encoded form |
|
131 // Note: 'Word' here has special meaning derived from the one defined in rfc2047. |
|
132 // It refers to one encoding instance. |
|
133 |
|
134 //---------------------------------------------------------------------------------------- |
|
135 class CImConvertHeader : public CBase |
|
136 //---------------------------------------------------------------------------------------- |
|
137 /** |
|
138 @internalTechnology |
|
139 @released |
|
140 */ |
|
141 { |
|
142 public: |
|
143 IMPORT_C static CImConvertHeader* NewL(CImConvertCharconv& aConverter); |
|
144 ~CImConvertHeader(); |
|
145 |
|
146 IMPORT_C void SetMessageType(TBool aIsMIME); |
|
147 IMPORT_C void DecodeAllHeaderFieldsL(CImHeader& rHeader); |
|
148 |
|
149 // Functions for decoding & converting descriptors |
|
150 |
|
151 IMPORT_C void DecodeNonMIMEHeaderFieldL(const TDesC8& aBufIn, TDes& aBufOut); |
|
152 IMPORT_C void DecodeHeaderFieldL(const TDesC8& aBufIn, TDes& aBufOut); |
|
153 IMPORT_C void DecodeHeaderFieldL(const TDesC16& aBufIn, TDes& aBufOut); |
|
154 IMPORT_C void ConvertHeaderFieldL(const TDesC16& aBufIn, RBuf8& aBufOut, TBool aIsAddressField); |
|
155 |
|
156 // Header needed for retrieving encoding information, used in Send code. |
|
157 IMPORT_C void EncodeHeaderFieldL(const TDesC& aBufIn, RBuf8& aBufOut, |
|
158 CArrayFix<TImHeaderEncodingInfo>* aInfoArray, TInt aState, TInt aArrayVal = 0); |
|
159 |
|
160 IMPORT_C void EncodeHeaderFieldL(const TDesC& aBufIn, RBuf8& aBufOut, |
|
161 const TUint aCharset, const TImHeaderEncodingInfo::TEncodingType aType, TBool aIsAddressField); |
|
162 |
|
163 IMPORT_C TBool FindEncodedWord(TPtrC8& aData, TInt& aInit,TInt& rStart, TInt& rEnd); |
|
164 |
|
165 void Append(TDes& aBuffer, const TDesC8& aAddition); |
|
166 inline CImConvertCharconv& CharConv(); |
|
167 |
|
168 IMPORT_C TUint OverrideCharset() const; |
|
169 IMPORT_C void SetOverrideCharset(TUint aCharset); |
|
170 |
|
171 private: |
|
172 void ConstructL(); |
|
173 CImConvertHeader(CImConvertCharconv&); |
|
174 // Functions dealing only with single 'encoded-word's |
|
175 void GetCharsetAndEncodeDataL(const TDesC& aBufIn, RBuf8& aBufOut, TImHeaderEncodingInfo& aInfo); |
|
176 void EncodeWordL(const TDesC& aBufIn, RBuf8& aBufOut, TImHeaderEncodingInfo& aInfo, |
|
177 const TDesC8& aCharsetName, RBuf8& aEncodedWord); |
|
178 |
|
179 TBool DecodeWordL(const TDesC8& aBufIn, TDes& aBufOut, TInt rRemainder); |
|
180 void DecodeRecipientListL( CDesCArray& aArray); |
|
181 void DecodeFieldL(const TDesC& aField); |
|
182 |
|
183 TBool DoCharsetConversionL(const TDesC& aDataToConvert, RBuf8& aEncodedWord); |
|
184 |
|
185 void DoEncodingL(RBuf8& aEncodedWord, TImHeaderEncodingInfo& aInfo); |
|
186 |
|
187 TInt AddEncodedWordInfoL(const TDesC8& aEncodedWord, RBuf8& aBufOut, |
|
188 TImHeaderEncodingInfo& aInfo, const TDesC8& aCharsetName); |
|
189 |
|
190 TBool IsAscii( TUint aChar ) const; |
|
191 TBool ExtractTextToEncode(const TDesC& aBufIn, TInt& rStart, TInt& rEnd, TBool aIsAddressField); |
|
192 void Insert(TDes8& aBuffer, const TDesC16& aInsert); |
|
193 |
|
194 private: |
|
195 TImHeaderEncodingInfo iEncodingInfo; |
|
196 CImConvertCharconv& iCharConv; |
|
197 |
|
198 // Get access to QP/ Base64 encoding/decoding functions |
|
199 TImCodecB64 iB64Codec; |
|
200 TImCodecQP iQPCodec; |
|
201 |
|
202 // Need in the narrow build, to check if possible to convert to/from |
|
203 // the machines character set. |
|
204 TUint iCharacterSetId; |
|
205 |
|
206 CImHeader* iHeader; |
|
207 |
|
208 // Converted static variables used in EncodeWordL() |
|
209 TBool isMIMEMessageHeader; |
|
210 TUint iOverrideCharset; |
|
211 }; |
|
212 |
|
213 #include <imcvcodc.inl> |
|
214 |
|
215 #endif //__CIMCONVERTHEADER_H__ |
|
216 |