1 /* |
|
2 * Copyright (c) 2009 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: String loader class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <exception> // must be before e32base.h so uncaught_exception gets defined |
|
19 #include <StringLoader.h> |
|
20 #include "phoneresourceadapter.h" |
|
21 #include "phoneaction.h" |
|
22 |
|
23 // ============================ MEMBER FUNCTIONS =============================== |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // StringLoader::StringLoader |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 /* |
|
30 StringLoader::StringLoader( ) |
|
31 { |
|
32 |
|
33 } |
|
34 */ |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // StringLoader::Load |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 EXPORT_C void StringLoader::Load( |
|
41 TDes & aDest, |
|
42 TInt aResourceId, |
|
43 CCoeEnv * aLoaderEnv ) |
|
44 { |
|
45 Q_UNUSED (aLoaderEnv); |
|
46 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId); |
|
47 if (map.contains (PhoneAction::Text)) { |
|
48 PhoneAction *text = map [PhoneAction::Text]; |
|
49 aDest.Copy (text->text ().utf16 ()); |
|
50 delete text; |
|
51 } |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // StringLoader::LoadL |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C HBufC * StringLoader::LoadL( |
|
59 TInt aResourceId, |
|
60 CCoeEnv * aLoaderEnv ) |
|
61 { |
|
62 Q_UNUSED (aLoaderEnv); |
|
63 HBufC *buf; |
|
64 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId); |
|
65 if (map.contains (PhoneAction::Text)) { |
|
66 PhoneAction *text = map [PhoneAction::Text]; |
|
67 buf = HBufC::NewL (text->text ().size ()); |
|
68 *buf = text->text ().utf16 (); |
|
69 delete text; |
|
70 } else { |
|
71 // TODO: this else branch MUST be removed after all strings are localized! |
|
72 // now here only to prevent crashing |
|
73 buf = HBufC::New (1); |
|
74 } |
|
75 return buf; |
|
76 } |
|
77 |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // StringLoader::LoadL |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 EXPORT_C HBufC * StringLoader::LoadL( |
|
84 TInt aResourceId, |
|
85 TInt aInt, |
|
86 CCoeEnv * aLoaderEnv ) |
|
87 { |
|
88 Q_UNUSED (aLoaderEnv); |
|
89 HBufC *buf; |
|
90 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, aInt); |
|
91 if (map.contains (PhoneAction::Text)) { |
|
92 PhoneAction *text = map [PhoneAction::Text]; |
|
93 buf = HBufC::NewL (text->text ().size ()); |
|
94 *buf = text->text ().utf16 (); |
|
95 delete text; |
|
96 } else { |
|
97 // TODO: this else branch MUST be removed after all strings are localized! |
|
98 // now here only to prevent crashing |
|
99 buf = HBufC::New (1); |
|
100 } |
|
101 return buf; |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // StringLoader::LoadL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C HBufC * StringLoader::LoadL( |
|
110 TInt aResourceId, |
|
111 const TDesC & aString, |
|
112 CCoeEnv * aLoaderEnv ) |
|
113 { |
|
114 Q_UNUSED (aLoaderEnv); |
|
115 HBufC *buf; |
|
116 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aString); |
|
117 if (map.contains (PhoneAction::Text)) { |
|
118 PhoneAction *text = map [PhoneAction::Text]; |
|
119 buf = HBufC::NewL (text->text ().size ()); |
|
120 *buf = text->text ().utf16 (); |
|
121 delete text; |
|
122 } else { |
|
123 // TODO: this else branch MUST be removed after all strings are localized! |
|
124 // now here only to prevent crashing |
|
125 buf = HBufC::New (1); |
|
126 } |
|
127 return buf; |
|
128 } |
|
129 |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // StringLoader::LoadL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C HBufC * StringLoader::LoadL( |
|
136 TInt aResourceId, |
|
137 const TDesC & aString, |
|
138 TInt aInt, |
|
139 CCoeEnv * aLoaderEnv ) |
|
140 { |
|
141 Q_UNUSED (aLoaderEnv); |
|
142 HBufC *buf; |
|
143 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aString, aInt); |
|
144 if (map.contains (PhoneAction::Text)) { |
|
145 PhoneAction *text = map [PhoneAction::Text]; |
|
146 buf = HBufC::NewL (text->text ().size ()); |
|
147 *buf = text->text ().utf16 (); |
|
148 delete text; |
|
149 } else { |
|
150 // TODO: this else branch MUST be removed after all strings are localized! |
|
151 // now here only to prevent crashing |
|
152 buf = HBufC::New (1); |
|
153 } |
|
154 return buf; |
|
155 } |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // StringLoader::LoadL |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C HBufC * StringLoader::LoadL( |
|
163 TInt aResourceId, |
|
164 const CArrayFix<TInt> & aInts, |
|
165 CCoeEnv * aLoaderEnv ) |
|
166 { |
|
167 Q_UNUSED (aLoaderEnv); |
|
168 HBufC *buf; |
|
169 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aInts); |
|
170 if (map.contains (PhoneAction::Text)) { |
|
171 PhoneAction *text = map [PhoneAction::Text]; |
|
172 buf = HBufC::NewL (text->text ().size ()); |
|
173 *buf = text->text ().utf16 (); |
|
174 delete text; |
|
175 } else { |
|
176 // TODO: this else branch MUST be removed after all strings are localized! |
|
177 // now here only to prevent crashing |
|
178 buf = HBufC::New (1); |
|
179 } |
|
180 return buf; |
|
181 } |
|
182 |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // StringLoader::LoadL |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 EXPORT_C HBufC * StringLoader::LoadL( |
|
189 TInt aResourceId, |
|
190 const MDesCArray & aStrings, |
|
191 CCoeEnv * aLoaderEnv ) |
|
192 { |
|
193 Q_UNUSED (aLoaderEnv); |
|
194 HBufC *buf; |
|
195 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aStrings); |
|
196 if (map.contains (PhoneAction::Text)) { |
|
197 PhoneAction *text = map [PhoneAction::Text]; |
|
198 buf = HBufC::NewL (text->text ().size ()); |
|
199 *buf = text->text ().utf16 (); |
|
200 delete text; |
|
201 } else { |
|
202 // TODO: this else branch MUST be removed after all strings are localized! |
|
203 // now here only to prevent crashing |
|
204 buf = HBufC::New (1); |
|
205 } |
|
206 return buf; |
|
207 } |
|
208 |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // StringLoader::LoadL |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 EXPORT_C HBufC * StringLoader::LoadL( |
|
215 TInt aResourceId, |
|
216 const MDesCArray & aStrings, |
|
217 const CArrayFix<TInt> & aInts, |
|
218 CCoeEnv * aLoaderEnv ) |
|
219 { |
|
220 Q_UNUSED (aLoaderEnv); |
|
221 HBufC *buf; |
|
222 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aStrings, &aInts); |
|
223 if (map.contains (PhoneAction::Text)) { |
|
224 PhoneAction *text = map [PhoneAction::Text]; |
|
225 buf = HBufC::NewL (text->text ().size ()); |
|
226 *buf = text->text ().utf16 (); |
|
227 delete text; |
|
228 } else { |
|
229 // TODO: this else branch MUST be removed after all strings are localized! |
|
230 // now here only to prevent crashing |
|
231 buf = HBufC::New (1); |
|
232 } |
|
233 return buf; |
|
234 } |
|
235 |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // StringLoader::LoadLC |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 EXPORT_C HBufC * StringLoader::LoadLC( |
|
242 TInt aResourceId, |
|
243 CCoeEnv * aLoaderEnv ) |
|
244 { |
|
245 Q_UNUSED (aLoaderEnv); |
|
246 HBufC *buf; |
|
247 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId); |
|
248 if (map.contains (PhoneAction::Text)) { |
|
249 PhoneAction *text = map [PhoneAction::Text]; |
|
250 buf = HBufC::NewLC (text->text ().size ()); |
|
251 *buf = text->text ().utf16 (); |
|
252 delete text; |
|
253 } else { |
|
254 // TODO: this else branch MUST be removed after all strings are localized! |
|
255 // now here only to prevent crashing |
|
256 buf = HBufC::NewLC (1); |
|
257 } |
|
258 return buf; |
|
259 } |
|
260 |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // StringLoader::LoadLC |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 EXPORT_C HBufC * StringLoader::LoadLC( |
|
267 TInt aResourceId, |
|
268 TInt aInt, |
|
269 CCoeEnv * aLoaderEnv ) |
|
270 { |
|
271 Q_UNUSED (aLoaderEnv); |
|
272 HBufC *buf; |
|
273 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, aInt); |
|
274 if (map.contains (PhoneAction::Text)) { |
|
275 PhoneAction *text = map [PhoneAction::Text]; |
|
276 buf = HBufC::NewLC (text->text ().size ()); |
|
277 *buf = text->text ().utf16 (); |
|
278 delete text; |
|
279 } else { |
|
280 // TODO: this else branch MUST be removed after all strings are localized! |
|
281 // now here only to prevent crashing |
|
282 buf = HBufC::NewLC (1); |
|
283 } |
|
284 return buf; |
|
285 } |
|
286 |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // StringLoader::LoadLC |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 EXPORT_C HBufC * StringLoader::LoadLC( |
|
293 TInt aResourceId, |
|
294 const TDesC & aString, |
|
295 CCoeEnv * aLoaderEnv ) |
|
296 { |
|
297 Q_UNUSED (aLoaderEnv); |
|
298 HBufC *buf; |
|
299 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aString); |
|
300 if (map.contains (PhoneAction::Text)) { |
|
301 PhoneAction *text = map [PhoneAction::Text]; |
|
302 buf = HBufC::NewLC (text->text ().size ()); |
|
303 *buf = text->text ().utf16 (); |
|
304 delete text; |
|
305 } else { |
|
306 // TODO: this else branch MUST be removed after all strings are localized! |
|
307 // now here only to prevent crashing |
|
308 buf = HBufC::NewLC (1); |
|
309 } |
|
310 return buf; |
|
311 } |
|
312 |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // StringLoader::LoadLC |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 EXPORT_C HBufC * StringLoader::LoadLC( |
|
319 TInt aResourceId, |
|
320 const TDesC & aString, |
|
321 TInt aInt, |
|
322 CCoeEnv * aLoaderEnv ) |
|
323 { |
|
324 Q_UNUSED (aLoaderEnv); |
|
325 HBufC *buf; |
|
326 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aString, aInt); |
|
327 if (map.contains (PhoneAction::Text)) { |
|
328 PhoneAction *text = map [PhoneAction::Text]; |
|
329 buf = HBufC::NewLC (text->text ().size ()); |
|
330 *buf = text->text ().utf16 (); |
|
331 delete text; |
|
332 } else { |
|
333 // TODO: this else branch MUST be removed after all strings are localized! |
|
334 // now here only to prevent crashing |
|
335 buf = HBufC::NewLC (1); |
|
336 } |
|
337 return buf; |
|
338 } |
|
339 |
|
340 |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // StringLoader::LoadLC |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 EXPORT_C HBufC * StringLoader::LoadLC( |
|
347 TInt aResourceId, |
|
348 const CArrayFix<TInt> & aInts, |
|
349 CCoeEnv * aLoaderEnv ) |
|
350 { |
|
351 Q_UNUSED (aLoaderEnv); |
|
352 HBufC *buf; |
|
353 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aInts); |
|
354 if (map.contains (PhoneAction::Text)) { |
|
355 PhoneAction *text = map [PhoneAction::Text]; |
|
356 buf = HBufC::NewLC (text->text ().size ()); |
|
357 *buf = text->text ().utf16 (); |
|
358 delete text; |
|
359 } else { |
|
360 // TODO: this else branch MUST be removed after all strings are localized! |
|
361 // now here only to prevent crashing |
|
362 buf = HBufC::NewLC (1); |
|
363 } |
|
364 return buf; |
|
365 } |
|
366 |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // StringLoader::LoadLC |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 EXPORT_C HBufC * StringLoader::LoadLC( |
|
373 TInt aResourceId, |
|
374 const MDesCArray & aStrings, |
|
375 CCoeEnv * aLoaderEnv ) |
|
376 { |
|
377 Q_UNUSED (aLoaderEnv); |
|
378 HBufC *buf; |
|
379 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aStrings); |
|
380 if (map.contains (PhoneAction::Text)) { |
|
381 PhoneAction *text = map [PhoneAction::Text]; |
|
382 buf = HBufC::NewLC (text->text ().size ()); |
|
383 *buf = text->text ().utf16 (); |
|
384 delete text; |
|
385 } else { |
|
386 // TODO: this else branch MUST be removed after all strings are localized! |
|
387 // now here only to prevent crashing |
|
388 buf = HBufC::NewLC (1); |
|
389 } |
|
390 return buf; |
|
391 } |
|
392 |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // StringLoader::LoadLC |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 EXPORT_C HBufC * StringLoader::LoadLC( |
|
399 TInt aResourceId, |
|
400 const MDesCArray & aStrings, |
|
401 const CArrayFix<TInt> & aInts, |
|
402 CCoeEnv * aLoaderEnv ) |
|
403 { |
|
404 Q_UNUSED (aLoaderEnv); |
|
405 HBufC *buf; |
|
406 QMap<PhoneAction::ActionType, PhoneAction *> map = PhoneResourceAdapter::Instance ()->convert (aResourceId, &aStrings, &aInts); |
|
407 if (map.contains (PhoneAction::Text)) { |
|
408 PhoneAction *text = map [PhoneAction::Text]; |
|
409 buf = HBufC::NewLC (text->text ().size ()); |
|
410 *buf = text->text ().utf16 (); |
|
411 delete text; |
|
412 } else { |
|
413 // TODO: this else branch MUST be removed after all strings are localized! |
|
414 // now here only to prevent crashing |
|
415 buf = HBufC::NewLC (1); |
|
416 } |
|
417 return buf; |
|
418 } |
|