|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Declares character converter for application. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef MSGMAILVIEWERCHARCONV_H |
|
21 #define MSGMAILVIEWERCHARCONV_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <AknWaitNoteWrapper.h> |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CImConvertCharconv; |
|
30 class CCnvCharacterSetConverter; |
|
31 // CLASS DECLARATION |
|
32 |
|
33 |
|
34 /** |
|
35 * CMsgMailViewerDocument application class. |
|
36 */ |
|
37 class CMsgMailViewerCharConv : public CBase, public MAknBackgroundProcess |
|
38 { |
|
39 public: // Constructors and destructor |
|
40 /** |
|
41 * Two-phased constructor. |
|
42 */ |
|
43 static CMsgMailViewerCharConv* NewL( TUint aCharset ); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 virtual ~CMsgMailViewerCharConv(); |
|
49 |
|
50 public: // from MAknBackgroundProcess |
|
51 |
|
52 /** |
|
53 * Completes one cycle of the process. |
|
54 */ |
|
55 void StepL(); |
|
56 |
|
57 /** |
|
58 * Return true when the process is done. |
|
59 */ |
|
60 TBool IsProcessDone() const; |
|
61 |
|
62 private: |
|
63 |
|
64 /** |
|
65 * Default constructor. |
|
66 */ |
|
67 CMsgMailViewerCharConv(); |
|
68 |
|
69 /** |
|
70 * Symbian OS default constructor. |
|
71 */ |
|
72 void ConstructL( TUint aCharset ); |
|
73 |
|
74 public: // new methods |
|
75 /** |
|
76 * Prepares to convert from Unicode. |
|
77 * @param aSource The text to be converted. |
|
78 */ |
|
79 void PrepareToConvertFromUnicodeL( const TDesC16& aSource ); |
|
80 |
|
81 /** |
|
82 * Prepares to convert to Unicode. |
|
83 * @param aSource The text to be converted. |
|
84 */ |
|
85 void PrepareToConvertToUnicodeL( const TDesC8& aSource ); |
|
86 |
|
87 /** |
|
88 * Returns the result of the conversion to Unicode. The ownership is |
|
89 * transferred to the caller. |
|
90 * @return The result of conversion. |
|
91 */ |
|
92 HBufC16* GetUnicodeText(); |
|
93 |
|
94 /** |
|
95 * Returns the result of the conversion from Unicode. The ownership is |
|
96 * transferred to the caller. |
|
97 * @return The result of conversion. |
|
98 */ |
|
99 HBufC8* GetForeignText(); |
|
100 |
|
101 /** |
|
102 * Returns the number of failed characters for Unicode->foreign conversion. |
|
103 * @return The number of failed characters. |
|
104 */ |
|
105 TInt GetFailedCount() const; |
|
106 |
|
107 private: // new methods |
|
108 /** |
|
109 * Converts one block from Unicode. |
|
110 */ |
|
111 void StepFromUnicodeL(); |
|
112 |
|
113 /** |
|
114 * Converts one block to Unicode. |
|
115 */ |
|
116 void StepToUnicodeL(); |
|
117 |
|
118 /** |
|
119 * Appends data to iTarget16 possibly extending it. |
|
120 * @param aData Data to be appended. |
|
121 */ |
|
122 void AppendTextL( const TDesC16& aData ); |
|
123 |
|
124 /** |
|
125 * Appends data to iTarget8 possibly extending it. |
|
126 * @param aData Data to be appended. |
|
127 */ |
|
128 void AppendTextL( const TDesC8& aData ); |
|
129 |
|
130 private: // Member data |
|
131 /// Owns: Character converter instance. |
|
132 CCnvCharacterSetConverter* iCharConv; |
|
133 /// Own |
|
134 CImConvertCharconv* iImCharConv; |
|
135 |
|
136 /// Own: The text in target character set if converting from Unicode. |
|
137 HBufC8* iTarget8; |
|
138 |
|
139 /// Own: The text in target character set if converting to Unicode |
|
140 HBufC16* iTarget16; |
|
141 |
|
142 /// Refs: The text in source character set if converting from Unicode. |
|
143 TPtrC16 iSource16; |
|
144 |
|
145 /// Refs: The text in source character set if converting to Unicode. |
|
146 TPtrC8 iSource8; |
|
147 |
|
148 /// ETrue, if converting from Unicode |
|
149 TBool iFromUnicode; |
|
150 |
|
151 /// State when converting to Unicode |
|
152 TInt iState; |
|
153 |
|
154 /// Number of failed characters when converting from Unicode. |
|
155 TInt iFailCount; |
|
156 }; |
|
157 |
|
158 #endif |
|
159 |
|
160 // End of File |
|
161 |