|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 #include <conarc.h> |
|
17 #include <ecom/implementationinformation.h> |
|
18 #include <ecom/ecom.h> |
|
19 |
|
20 /** ROM patchable constant. Determines whether to perform Quoted Printable conversion for all the special |
|
21 characters or not. The default value is 1. |
|
22 When set to non zero, the conversion is performed for all the special characters. |
|
23 When set to zero, special characters are not converted. |
|
24 |
|
25 The constant can be changed at ROM build time using patchdata keyword in IBY file. |
|
26 To patch the value, add a line to an iby file that is included in the ROM being built using the following format: |
|
27 "patchdata <dll> @ <symbol> <newvalue>" |
|
28 |
|
29 @publishedPartner |
|
30 @released */ |
|
31 EXPORT_C extern const TInt KEnableAllSplCharForQpCnv = 1; |
|
32 |
|
33 // |
|
34 // class CConverterBase |
|
35 // |
|
36 |
|
37 EXPORT_C TInt CConverterBase::Capabilities() |
|
38 /** Gets the converter's capabilities. |
|
39 |
|
40 The default is to return a bitmask of all the TCapability flags. |
|
41 |
|
42 @return A bitmask of TCapability flags describing the capabilities. */ |
|
43 { |
|
44 return EConvertsFiles|EConvertsObjects|EConvertsExtract; |
|
45 } |
|
46 |
|
47 EXPORT_C void CConverterBase::ConvertL(const TFileName& aSourceFile, const TFileName& aTargetFile, MConverterUiObserver* aObserver) |
|
48 /** Converts a file in a single step. |
|
49 |
|
50 The caller can supply a MConverterUiObserver to be informed of progress in |
|
51 the conversion. |
|
52 |
|
53 The default implementation calls ConvertAL() to prepare the object to perform |
|
54 the conversion, and then calls DoConvertL() in a loop until conversion is |
|
55 complete. |
|
56 |
|
57 @param aSourceFile File to convert |
|
58 @param aTargetFile File to which to write the converted output |
|
59 @param aObserver Optional observer of the conversion process |
|
60 @leave KErrNotSupported File conversion is not supported */ |
|
61 { |
|
62 ConvertAL(aSourceFile,aTargetFile,aObserver); |
|
63 while (DoConvertL()) |
|
64 ; |
|
65 } |
|
66 |
|
67 EXPORT_C void CConverterBase::ConvertObjectL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver) |
|
68 /** Converts a stream object in a single step. |
|
69 |
|
70 The caller can supply a MConverterUiObserver to be informed of progress in |
|
71 the conversion. |
|
72 |
|
73 The default implementation calls ConvertObjectAL() to prepare the object to |
|
74 perform the conversion, and then calls DoConvertL() in a loop until conversion |
|
75 is complete. |
|
76 |
|
77 @param aReadStream Stream from which to read the data to convert |
|
78 @param aWriteStream Stream to which to write the converted data |
|
79 @param aObserver Optional observer of the conversion process */ |
|
80 { |
|
81 ConvertObjectAL(aReadStream,aWriteStream,aObserver); |
|
82 while (DoConvertL()) |
|
83 ; |
|
84 } |
|
85 |
|
86 EXPORT_C void CConverterBase::ConvertAL(const TFileName& /*aSourceFile*/, const TFileName& /*aTargetFile*/, MConverterUiObserver* /*aObserver*/) |
|
87 /** Prepares for conversion in multiple steps of a file. |
|
88 |
|
89 Clients must call this function before calling DoConvertL() one or more times |
|
90 to do the conversion. The function can call back the MaxSteps() function of |
|
91 the supplied MConverterUiObserver to tell the client the maximum number of |
|
92 calls to DoConvertL() that will be required. |
|
93 |
|
94 The rest of this description describes how to implement this function. |
|
95 |
|
96 The function should initialise the object before performing a conversion, |
|
97 but should not do the conversion itself. Such initialisation should include: |
|
98 |
|
99 storing the MConverterUiObserver pointer (if supplied), so the client can |
|
100 later be notified of conversion progress |
|
101 |
|
102 validating the integrity of the input data |
|
103 |
|
104 optionally, creating the appropriate application engine, either for input |
|
105 or output, to enable access to the data |
|
106 |
|
107 determining the number of steps (i.e. calls to DoConvertL()) required to perform |
|
108 the conversion and pass this to the client by calling MConverterUiObserver::MaxSteps() |
|
109 |
|
110 The default implementation leaves with KErrNotSupported. |
|
111 |
|
112 @param aSourceFile File to convert |
|
113 @param aTargetFile File to which to write the converted output. The file can |
|
114 be overwritten if it already exists. |
|
115 @param aObserver Observer of the conversion process |
|
116 @leave KErrNotSupported File conversion is not supported */ |
|
117 { |
|
118 User::Leave(KErrNotSupported); |
|
119 } |
|
120 |
|
121 EXPORT_C void CConverterBase::ConvertObjectAL(RReadStream& /*aReadStream*/, RWriteStream& /*aWriteStream*/, MConverterUiObserver* /*aObserver*/) |
|
122 /** Prepares for conversion in multiple steps of a stream object. |
|
123 |
|
124 Clients must call this function before calling DoConvertL() one or more times |
|
125 to do the conversion. The function can call back the MaxSteps() function of |
|
126 the supplied MConverterUiObserver to tell the client the maximum number of |
|
127 calls to DoConvertL() that will be required. |
|
128 |
|
129 For a description of how to implement this function, see ConvertAL(). |
|
130 |
|
131 @param aReadStream Stream from which to read the data to convert |
|
132 @param aWriteStream Stream to which to write the converted data |
|
133 @param aObserver Optional observer of the conversion process |
|
134 @leave KErrNotSupported Stream object conversion is not supported */ |
|
135 { |
|
136 User::Leave(KErrNotSupported); |
|
137 } |
|
138 |
|
139 EXPORT_C TBool CConverterBase::DoConvertL() |
|
140 /** Performs a step in converting the data. |
|
141 |
|
142 The function advances a step in converting the data each time that it is called. |
|
143 When conversion is complete, the function returns EFalse. |
|
144 |
|
145 @return EFalse if conversion is complete, else ETrue */ |
|
146 { |
|
147 User::Leave(KErrNotSupported); |
|
148 return EFalse; |
|
149 } |
|
150 |
|
151 EXPORT_C void CConverterBase::CancelConvert() |
|
152 /** Cleans up a conversion that has been prepared or is in progress. |
|
153 |
|
154 It should free any resources and reset the converter object to an initial |
|
155 state. |
|
156 |
|
157 The default is to do nothing. */ |
|
158 { |
|
159 } |
|
160 |
|
161 EXPORT_C CConverterBase* CConverterBase::EmbeddedObjectL(TDataType& /*aType*/) |
|
162 /** Gets a converter for an embedded object of the specified type. |
|
163 |
|
164 The default is to return NULL. |
|
165 |
|
166 @param aType Type of the embedded object |
|
167 @return Converter for the embedded object */ |
|
168 { |
|
169 return NULL; |
|
170 } |
|
171 |
|
172 EXPORT_C TBool CConverterBase::GetEmbeddedFileName(TFileName& /*aFileName*/) |
|
173 /** Gets a filename embedded in the object. |
|
174 |
|
175 @param aFileName The file name found |
|
176 @return True if a filename was found, false otherwise */ |
|
177 { |
|
178 return EFalse; |
|
179 } |
|
180 |
|
181 EXPORT_C void CConverterBase::ExtendedInterfaceL(TUid /*aInterfaceUid*/, CBase*& /*aInterface*/) |
|
182 /** Allows licensees to extend the Converter Architecture API. |
|
183 |
|
184 This function replaces the private Reserved_1() function, so the change is |
|
185 binary compatible with v7.0. |
|
186 |
|
187 If overridden by the converter, it allows third party code to request the |
|
188 extended interface object by UID. If not overridden, the default implementation |
|
189 does nothing. |
|
190 |
|
191 @param aInterfaceUid A UID that identifies the required extended interface |
|
192 object. |
|
193 @param aInterface On return, an object that extends the Converter Architecture |
|
194 interface, or NULL, if the UID specified is not recognised. */ |
|
195 { |
|
196 } |
|
197 |
|
198 // |
|
199 // class MConverterUiObserver |
|
200 // |
|
201 |
|
202 EXPORT_C void MConverterUiObserver::Reserved1_Conv_Obs() |
|
203 { |
|
204 } |
|
205 |
|
206 // |
|
207 // class CConverterBase2 |
|
208 // |
|
209 |
|
210 EXPORT_C CConverterBase2::~CConverterBase2() |
|
211 { |
|
212 if (iDestructionKey.iUid!=0) |
|
213 { |
|
214 REComSession::DestroyedImplementation(iDestructionKey); |
|
215 } |
|
216 } |
|
217 |
|
218 CConverterBase2* CConverterBase2:: CreateConverterL(TUid aImplUid) |
|
219 { |
|
220 return ((CConverterBase2*)REComSession::CreateImplementationL(aImplUid, _FOFF(CConverterBase2, iDestructionKey))); |
|
221 } |
|
222 |
|
223 EXPORT_C void CConverterBase2::ConvertL(const TFileName& aSourceFile, const TFileName& aTargetFile, MConverterUiObserver* aObserver) |
|
224 /** Converts a file in a single step. |
|
225 |
|
226 The caller can supply a MConverterUiObserver to be informed of progress in |
|
227 the conversion. |
|
228 |
|
229 The default implementation calls ConvertAL() to prepare the object to perform |
|
230 the conversion, and then calls DoConvertL() in a loop until conversion is |
|
231 complete. |
|
232 |
|
233 @param aSourceFile File to convert |
|
234 @param aTargetFile File to which to write the converted output |
|
235 @param aObserver Optional observer of the conversion process |
|
236 @leave KErrNotSupported File conversion is not supported */ |
|
237 { |
|
238 ConvertAL(aSourceFile,aTargetFile,aObserver); |
|
239 while (DoConvertL()) |
|
240 ; |
|
241 } |
|
242 |
|
243 EXPORT_C void CConverterBase2::ConvertObjectL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver) |
|
244 /** Converts a stream object in a single step. |
|
245 |
|
246 The caller can supply a MConverterUiObserver to be informed of progress in |
|
247 the conversion. |
|
248 |
|
249 The default implementation calls ConvertObjectAL() to prepare the object to |
|
250 perform the conversion, and then calls DoConvertL() in a loop until conversion |
|
251 is complete. |
|
252 |
|
253 @param aReadStream Stream from which to read the data to convert |
|
254 @param aWriteStream Stream to which to write the converted data |
|
255 @param aObserver Optional observer of the conversion process */ |
|
256 { |
|
257 CConverterBase::ConvertObjectL(aReadStream,aWriteStream,aObserver); |
|
258 } |
|
259 |
|
260 |
|
261 EXPORT_C void CConverterBase2::ConvertAL(const TFileName& /*aSourceFile*/, const TFileName& /*aTargetFile*/, MConverterUiObserver* /*aObserver*/) |
|
262 /** Prepares for conversion in multiple steps of a file. |
|
263 |
|
264 Clients must call this function before calling DoConvertL() one or more times |
|
265 to do the conversion. The function can call back the MaxSteps() function of |
|
266 the supplied MConverterUiObserver to tell the client the maximum number of |
|
267 calls to DoConvertL() that will be required. |
|
268 |
|
269 The rest of this description describes how to implement this function. |
|
270 |
|
271 The function should initialise the object before performing a conversion, |
|
272 but should not do the conversion itself. Such initialisation should include: |
|
273 |
|
274 storing the MConverterUiObserver pointer (if supplied), so the client can |
|
275 later be notified of conversion progress |
|
276 |
|
277 validating the integrity of the input data |
|
278 |
|
279 optionally, creating the appropriate application engine, either for input |
|
280 or output, to enable access to the data |
|
281 |
|
282 determining the number of steps (i.e. calls to DoConvertL()) required to perform |
|
283 the conversion and pass this to the client by calling MConverterUiObserver::MaxSteps() |
|
284 |
|
285 The default implementation leaves with KErrNotSupported. |
|
286 |
|
287 @param aSourceFile File to convert |
|
288 @param aTargetFile File to which to write the converted output. The file can |
|
289 be overwritten if it already exists. |
|
290 @param aObserver Observer of the conversion process |
|
291 @leave KErrNotSupported File conversion is not supported */ |
|
292 { |
|
293 User::Leave(KErrNotSupported); |
|
294 } |
|
295 |
|
296 EXPORT_C void CConverterBase2::ConvertObjectAL(RReadStream& /*aReadStream*/, RWriteStream& /*aWriteStream*/, MConverterUiObserver* /*aObserver*/) |
|
297 /** Prepares for conversion in multiple steps of a stream object. |
|
298 |
|
299 Clients must call this function before calling DoConvertL() one or more times |
|
300 to do the conversion. The function can call back the MaxSteps() function of |
|
301 the supplied MConverterUiObserver to tell the client the maximum number of |
|
302 calls to DoConvertL() that will be required. |
|
303 |
|
304 For a description of how to implement this function, see ConvertAL(). |
|
305 |
|
306 @param aReadStream Stream from which to read the data to convert |
|
307 @param aWriteStream Stream to which to write the converted data |
|
308 @param aObserver Optional observer of the conversion process |
|
309 @leave KErrNotSupported Stream object conversion is not supported */ |
|
310 { |
|
311 User::Leave(KErrNotSupported); |
|
312 } |
|
313 |
|
314 EXPORT_C TBool CConverterBase2::DoConvertL() |
|
315 /** Performs a step in converting the data. |
|
316 |
|
317 The function advances a step in converting the data each time that it is called. |
|
318 When conversion is complete, the function returns EFalse. |
|
319 |
|
320 @return EFalse if conversion is complete, else ETrue */ |
|
321 { |
|
322 User::Leave(KErrNotSupported); |
|
323 return EFalse; |
|
324 } |
|
325 |
|
326 EXPORT_C TInt CConverterBase2::Capabilities() |
|
327 /** Gets the converter's capabilities. |
|
328 |
|
329 The default is to return a bitmask of all the TCapability flags. |
|
330 |
|
331 @return A bitmask of TCapability flags describing the capabilities. */ |
|
332 { |
|
333 return EConvertsFiles|EConvertsObjects|EConvertsExtract; |
|
334 } |
|
335 |
|
336 EXPORT_C void CConverterBase2::CancelConvert() |
|
337 /** Cleans up a conversion that has been prepared or is in progress. |
|
338 |
|
339 It should free any resources and reset the converter object to an initial |
|
340 state. |
|
341 |
|
342 The default is to do nothing. */ |
|
343 { |
|
344 } |
|
345 |
|
346 EXPORT_C CConverterBase* CConverterBase2::EmbeddedObjectL(TDataType& /*aType*/) |
|
347 /** Gets a converter for an embedded object of the specified type. |
|
348 |
|
349 The default is to return NULL. |
|
350 |
|
351 @param aType Type of the embedded object |
|
352 @return Converter for the embedded object */ |
|
353 { |
|
354 return NULL; |
|
355 } |
|
356 |
|
357 EXPORT_C TBool CConverterBase2::GetEmbeddedFileName(TFileName& /*aFileName*/) |
|
358 /** Gets a filename embedded in the object. |
|
359 |
|
360 @param aFileName The file name found |
|
361 @return True if a filename was found, false otherwise */ |
|
362 { |
|
363 return EFalse; |
|
364 } |
|
365 |
|
366 EXPORT_C void CConverterBase2::ExtendedInterfaceL(TUid /*aInterfaceUid*/, CBase*& /*aInterface*/) |
|
367 /** Allows licensees to extend the Converter Architecture API. |
|
368 |
|
369 |
|
370 If overridden by the converter, it allows third party code to request the |
|
371 extended interface object by UID. If not overridden, the default implementation |
|
372 does nothing. |
|
373 |
|
374 @param aInterfaceUid A UID that identifies the required extended interface |
|
375 object. |
|
376 @param aInterface On return, an object that extends the Converter Architecture |
|
377 interface, or NULL, if the UID specified is not recognised. */ |
|
378 { |
|
379 } |
|
380 |
|
381 EXPORT_C void CConverterBase2::Reserved_1() |
|
382 { |
|
383 } |
|
384 |
|
385 EXPORT_C void CConverterBase2::Reserved_2() |
|
386 { |
|
387 } |