|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Language database class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ecom.h> |
|
20 #include "PtiLanguageDatabase.h" |
|
21 #include "PtiUids.hrh" |
|
22 #include <languages.hrh> |
|
23 |
|
24 const TInt KDefaultDatabasesGran = 3; |
|
25 |
|
26 // |
|
27 // LOCAl METHODS |
|
28 // |
|
29 |
|
30 void DBCleanup( TAny* aAny ) |
|
31 { |
|
32 RImplInfoPtrArray* implArray = |
|
33 reinterpret_cast< RImplInfoPtrArray*> ( aAny ); |
|
34 implArray->ResetAndDestroy(); |
|
35 implArray->Close(); |
|
36 } |
|
37 |
|
38 // |
|
39 // CPtiLanguageDatabase |
|
40 // |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CPtiLanguageDatabase::CreateDatabaseL |
|
44 // |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C CPtiLanguageDatabase* CPtiLanguageDatabase::CreateDatabaseL(TUid aImplUid) |
|
48 { |
|
49 TUid dtorIDKey; |
|
50 CPtiLanguageDatabase* iface = (CPtiLanguageDatabase*)REComSession::CreateImplementationL(aImplUid, dtorIDKey); |
|
51 if (iface) |
|
52 { |
|
53 iface->SetDestructorKeyId(dtorIDKey.iUid); |
|
54 } |
|
55 return iface; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CPtiLanguageDatabase::ListDatabasesLC |
|
61 // |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C CArrayFix<TInt>* CPtiLanguageDatabase::ListDatabasesLC(TInt aCoreUID) |
|
65 { |
|
66 RImplInfoPtrArray infoArray; |
|
67 TInt i; |
|
68 |
|
69 CArrayFixFlat<TInt>* result = new (ELeave) CArrayFixFlat<TInt>(KDefaultDatabasesGran); |
|
70 CleanupStack::PushL( result ); |
|
71 |
|
72 CleanupStack::PushL( TCleanupItem( DBCleanup, &infoArray ) ); |
|
73 REComSession::ListImplementationsL(TUid::Uid(aCoreUID), infoArray); |
|
74 |
|
75 for (i = 0; i < infoArray.Count(); i++) |
|
76 { |
|
77 result->AppendL(infoArray[i]->ImplementationUid().iUid); |
|
78 } |
|
79 |
|
80 CleanupStack::PopAndDestroy(); // infoArray |
|
81 |
|
82 return result; |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CPtiLanguageDatabase::~CPtiLanguageDatabase |
|
88 // |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C CPtiLanguageDatabase::~CPtiLanguageDatabase() |
|
92 { |
|
93 REComSession::DestroyedImplementation(TUid::Uid(iDtorKeyId)); |
|
94 } |
|
95 |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CPtiLanguageDatabase::CoreUID |
|
99 // |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C TInt CPtiLanguageDatabase::CoreUID() const |
|
103 { |
|
104 return 0; |
|
105 } |
|
106 |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CPtiLanguageDatabase::NumLanguages |
|
110 // |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C TInt CPtiLanguageDatabase::NumLanguages() const |
|
114 { |
|
115 return 0; |
|
116 } |
|
117 |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CPtiLanguageDatabase::LanguageCode |
|
121 // |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 EXPORT_C TInt CPtiLanguageDatabase::LanguageCode(TInt /*aIndex*/) const |
|
125 { |
|
126 return 0; |
|
127 } |
|
128 |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CPtiLanguageDatabase::SubLanguageCode |
|
132 // |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C TInt CPtiLanguageDatabase::SubLanguageCode(TInt /*aIndex*/) const |
|
136 { |
|
137 return 0; |
|
138 } |
|
139 |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CPtiLanguageDatabase::LangData |
|
143 // |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C TInt8* CPtiLanguageDatabase::LangData(TInt /*aIndex*/) const |
|
147 { |
|
148 return NULL; |
|
149 } |
|
150 |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CPtiLanguageDatabase::LangData |
|
154 // |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C TInt8* CPtiLanguageDatabase::LangData(TInt /*aIndex*/, |
|
158 TAny* /*aNativeParams*/) const |
|
159 { |
|
160 return NULL; |
|
161 } |
|
162 |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // CPtiLanguageDatabase::PinyinPhraseData |
|
166 // |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 EXPORT_C TInt8* CPtiLanguageDatabase::PinyinPhraseData() const |
|
170 { |
|
171 return NULL; |
|
172 } |
|
173 |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CPtiLanguageDatabase::ZhuyinPhraseData |
|
177 // |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C TInt8* CPtiLanguageDatabase::ZhuyinPhraseData() const |
|
181 { |
|
182 return NULL; |
|
183 } |
|
184 |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // CPtiLanguageDatabase::NativeId |
|
188 // |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 EXPORT_C TInt CPtiLanguageDatabase::NativeId(TInt /*aIndex*/) const |
|
192 { |
|
193 return 0; |
|
194 } |
|
195 |
|
196 |
|
197 // List of known language database uids. There maybe also others, |
|
198 // but we don't need to instantiate databases for uids listed here |
|
199 // to find out which language is implemented in it. |
|
200 const TPtiLangDatabaseMapping langUids[] = |
|
201 { |
|
202 {EPtiLangImplUidEnglish, ELangEnglish}, |
|
203 {EPtiLangImplUidFrench, ELangFrench}, |
|
204 {EPtiLangImplUidGerman, ELangGerman}, |
|
205 {EPtiLangImplUidSpanish, ELangSpanish}, |
|
206 {EPtiLangImplUidItalian, ELangItalian}, |
|
207 {EPtiLangImplUidSwedish, ELangSwedish}, |
|
208 {EPtiLangImplUidDanish, ELangDanish}, |
|
209 {EPtiLangImplUidNorwegian, ELangNorwegian}, |
|
210 {EPtiLangImplUidFinnish, ELangFinnish}, |
|
211 {EPtiLangImplUidPortuguese, ELangPortuguese}, |
|
212 {EPtiLangImplUidTurkish, ELangTurkish}, |
|
213 {EPtiLangImplUidIcelandic, ELangIcelandic}, |
|
214 {EPtiLangImplUidRussian, ELangRussian}, |
|
215 {EPtiLangImplUidHungarian, ELangHungarian}, |
|
216 {EPtiLangImplUidDutch, ELangDutch}, |
|
217 {EPtiLangImplUidCzech, ELangCzech}, |
|
218 {EPtiLangImplUidSlovak, ELangSlovak}, |
|
219 {EPtiLangImplUidPolish, ELangPolish}, |
|
220 {EPtiLangImplUidSlovenian, ELangSlovenian}, |
|
221 {EPtiLangImplUidJapanese, ELangJapanese}, |
|
222 {EPtiLangImplUidThai, ELangThai}, |
|
223 {EPtiLangImplUidArabic, ELangArabic}, |
|
224 {EPtiLangImplUidTagalog, ELangTagalog}, |
|
225 {EPtiLangImplUidCroatian, ELangCroatian}, |
|
226 {EPtiLangImplUidEstonian, ELangEstonian}, |
|
227 {EPtiLangImplUidGreek, ELangGreek}, |
|
228 {EPtiLangImplUidHebrew, ELangHebrew}, |
|
229 {EPtiLangImplUidHindi, ELangHindi}, |
|
230 {EPtiLangImplUidIndonesian, ELangIndonesian}, |
|
231 {EPtiLangImplUidLatvian, ELangLatvian}, |
|
232 {EPtiLangImplUidLithuanian, ELangLithuanian}, |
|
233 {EPtiLangImplUidMalay, ELangMalay}, |
|
234 {EPtiLangImplUidRomanian, ELangRomanian}, |
|
235 {EPtiLangImplUidSerbian, ELangSerbian}, |
|
236 {EPtiLangImplUidUkrainian, ELangUkrainian}, |
|
237 {EPtiLangImplUidBulgarian, ELangBulgarian}, |
|
238 {EPtiLangImplUidVietnamese, ELangVietnamese}, |
|
239 {EPtiLangImplUidPrcChinese, ELangPrcChinese}, |
|
240 {EPtiLangImplUidHongKongChinese, ELangHongKongChinese}, |
|
241 {EPtiLangImplUidTaiwanChinese, ELangTaiwanChinese}, |
|
242 {EPtiLangImplUidCatalan, ELangCatalan}, |
|
243 {EPtiLangImplUidGalician, KLangGalician}, |
|
244 {EPtiLangImplUidBasque, KLangBasque}, |
|
245 {EPtiLangImplUidUrdu, ELangUrdu}, |
|
246 |
|
247 // Second set begins here. |
|
248 {EPtiLangImplUidEnglish2, ELangEnglish}, |
|
249 {EPtiLangImplUidFinnish2, ELangFinnish}, |
|
250 {EPtiLangImplUidGerman2, ELangGerman}, |
|
251 {EPtiLangImplUidFrench2, ELangFrench}, |
|
252 {EPtiLangImplUidDanish2, ELangDanish}, |
|
253 {EPtiLangImplUidHindi2, ELangHindi}, |
|
254 {EPtiLangImplUidRussian2, ELangRussian}, |
|
255 {EPtiLangImplUidArabic2, ELangArabic}, |
|
256 {EPtiLangImplUidHebrew2, ELangHebrew}, |
|
257 {EPtiLangImplUidSwedish2, ELangSwedish}, |
|
258 {EPtiLangImplUidEstonian2, ELangEstonian}, |
|
259 {EPtiLangImplUidIcelandic2, ELangIcelandic}, |
|
260 {EPtiLangImplUidItalian2, ELangItalian}, |
|
261 {EPtiLangImplUidCroatian2, ELangCroatian}, |
|
262 {EPtiLangImplUidHungarian2, ELangHungarian}, |
|
263 {EPtiLangImplUidNorwegian2, ELangNorwegian}, |
|
264 {EPtiLangImplUidDutch2, ELangDutch}, |
|
265 {EPtiLangImplUidChinesePrc2, ELangPrcChinese}, |
|
266 {EPtiLangImplUidChineseTW2, ELangTaiwanChinese}, |
|
267 {EPtiLangImplUidChineseHK2, ELangHongKongChinese}, |
|
268 |
|
269 // {EPtiLangImplUidChinesePAN2, ELangEnglish}, |
|
270 {EPtiLangImplUidTagalog2, ELangTagalog}, |
|
271 {EPtiLangImplUidThai2, ELangThai}, |
|
272 {EPtiLangImplUidSlovenian2, ELangSlovenian}, |
|
273 {EPtiLangImplUidSlovak2, ELangSlovak}, |
|
274 {EPtiLangImplUidSerbian2, ELangSerbian}, |
|
275 {EPtiLangImplUidCzech2, ELangCzech}, |
|
276 {EPtiLangImplUidBulgarian2, ELangBulgarian}, |
|
277 {EPtiLangImplUidGreek2, ELangGreek}, |
|
278 {EPtiLangImplUidSpanish2, ELangSpanish}, |
|
279 {EPtiLangImplUidLithuanian2, ELangLithuanian}, |
|
280 {EPtiLangImplUidLatvian2, ELangLatvian}, |
|
281 {EPtiLangImplUidMalay2, ELangMalay}, |
|
282 |
|
283 {EPtiLangImplUidPolish2, ELangPolish}, |
|
284 {EPtiLangImplUidRomanian2, ELangRomanian}, |
|
285 {EPtiLangImplUidUkrainian2, ELangUkrainian}, |
|
286 {EPtiLangImplUidTurkish2, ELangTurkish}, |
|
287 {EPtiLangImplUidVietnamese2, ELangVietnamese}, |
|
288 |
|
289 {EPtiLangImplUidPortuguese2, ELangPortuguese}, |
|
290 {EPtiLangImplUidFarsi2, ELangFarsi}, |
|
291 {EPtiLangImplUidUrdu2, ELangUrdu}, |
|
292 {EPtiLangImplUidMarathi2, ELangMarathi}, |
|
293 {EPtiLangImplUidCanadianFrench2, ELangCanadianFrench}, |
|
294 {EPtiLangImplUidIndonesian2, ELangIndonesian}, |
|
295 {EPtiLangImplUidBrazilianPortuguese2, ELangBrazilianPortuguese}, |
|
296 {EPtiLangImplUidLatinAmericanSpanish2, ELangLatinAmericanSpanish}, |
|
297 {EPtiLangImplUidCatalan2, ELangCatalan}, |
|
298 {EPtiLangImplUidGalician2, KLangGalician}, |
|
299 {EPtiLangImplUidBasque2, KLangBasque}, |
|
300 // third set begins here. |
|
301 {EPtiLangImplUidEnglish3, ELangEnglish}, |
|
302 {EPtiLangImplUidFrench3, ELangFrench}, |
|
303 {EPtiLangImplUidGerman3, ELangGerman}, |
|
304 {EPtiLangImplUidSpanish3, ELangSpanish}, |
|
305 {EPtiLangImplUidItalian3, ELangItalian}, |
|
306 {EPtiLangImplUidSwedish3, ELangSwedish}, |
|
307 {EPtiLangImplUidDanish3, ELangDanish}, |
|
308 {EPtiLangImplUidNorwegian3, ELangNorwegian}, |
|
309 {EPtiLangImplUidFinnish3, ELangFinnish}, |
|
310 {EPtiLangImplUidPortuguese3, ELangPortuguese}, |
|
311 {EPtiLangImplUidTurkish3, ELangTurkish}, |
|
312 {EPtiLangImplUidIcelandic3, ELangIcelandic}, |
|
313 {EPtiLangImplUidRussian3, ELangRussian}, |
|
314 {EPtiLangImplUidHungarian3, ELangHungarian}, |
|
315 {EPtiLangImplUidDutch3, ELangDutch}, |
|
316 {EPtiLangImplUidCzech3, ELangCzech}, |
|
317 {EPtiLangImplUidSlovak3, ELangSlovak}, |
|
318 {EPtiLangImplUidPolish3, ELangPolish}, |
|
319 {EPtiLangImplUidSlovenian3, ELangSlovenian}, |
|
320 {EPtiLangImplUidThai3, ELangThai}, |
|
321 {EPtiLangImplUidArabic3, ELangArabic}, |
|
322 {EPtiLangImplUidTagalog3, ELangTagalog}, |
|
323 {EPtiLangImplUidCroatian3, ELangCroatian}, |
|
324 {EPtiLangImplUidEstonian3, ELangEstonian}, |
|
325 {EPtiLangImplUidGreek3, ELangGreek}, |
|
326 {EPtiLangImplUidHebrew3, ELangHebrew}, |
|
327 {EPtiLangImplUidHindi3, ELangHindi}, |
|
328 {EPtiLangImplUidIndonesian3, ELangIndonesian}, |
|
329 {EPtiLangImplUidLatvian3, ELangLatvian}, |
|
330 {EPtiLangImplUidLithuanian3, ELangLithuanian}, |
|
331 {EPtiLangImplUidMalay3, ELangMalay}, |
|
332 {EPtiLangImplUidRomanian3, ELangRomanian}, |
|
333 {EPtiLangImplUidSerbian3, ELangSerbian}, |
|
334 {EPtiLangImplUidUkrainian3, ELangUkrainian}, |
|
335 {EPtiLangImplUidVietnamese3, ELangVietnamese}, |
|
336 {EPtiLangImplUidBulgarian3, ELangBulgarian}, |
|
337 {EPtiLangImplUidBasque3, KLangBasque}, |
|
338 {EPtiLangImplUidCatalan3, ELangCatalan}, |
|
339 {EPtiLangImplUidGalician3, KLangGalician}, |
|
340 {EPtiLangImplUidUrdu3, ELangUrdu}, |
|
341 {EPtiLangImplUidMarathi3, ELangMarathi}, |
|
342 {0, 0} |
|
343 }; |
|
344 |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // CPtiLanguageDatabase::LanguageCodeForUid |
|
348 // |
|
349 // --------------------------------------------------------------------------- |
|
350 // |
|
351 EXPORT_C TInt CPtiLanguageDatabase::LanguageCodeForUid(TInt aUid) |
|
352 { |
|
353 TInt i; |
|
354 |
|
355 for (i = 0; ; i++) |
|
356 { |
|
357 if (langUids[i].iUid == 0) |
|
358 { |
|
359 break; |
|
360 } |
|
361 else if (langUids[i].iUid == aUid) |
|
362 { |
|
363 return langUids[i].iLangCode; |
|
364 } |
|
365 } |
|
366 |
|
367 return 0; |
|
368 } |
|
369 |
|
370 |
|
371 // --------------------------------------------------------------------------- |
|
372 // CPtiLanguageDatabase::CreateMappingTableL |
|
373 // |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 EXPORT_C TInt CPtiLanguageDatabase::CreateMappingTableL(TInt aCoreUid, RArray<TPtiLangDatabaseMapping>& aResult) |
|
377 { |
|
378 TInt res = 0, i, lc; |
|
379 TPtiLangDatabaseMapping map; |
|
380 CArrayFix<TInt>* dbs = ListDatabasesLC(aCoreUid); |
|
381 |
|
382 for (i = 0; i < dbs->Count(); i++) |
|
383 { |
|
384 lc = LanguageCodeForUid(dbs->At(i)); |
|
385 map.iUid = dbs->At(i); |
|
386 if (lc) |
|
387 { |
|
388 map.iLangCode = lc; |
|
389 User::LeaveIfError(aResult.Append(map)); |
|
390 } |
|
391 else |
|
392 { |
|
393 CPtiLanguageDatabase* db = CreateDatabaseL(TUid::Uid(dbs->At(i))); |
|
394 if (db) |
|
395 { |
|
396 CleanupStack::PushL(db); |
|
397 map.iLangCode = db->LanguageCode(0); |
|
398 User::LeaveIfError(aResult.Append(map)); |
|
399 CleanupStack::PopAndDestroy(); // db |
|
400 } |
|
401 } |
|
402 } |
|
403 |
|
404 CleanupStack::PopAndDestroy(); // dbs |
|
405 return res; |
|
406 } |
|
407 |
|
408 |
|
409 // --------------------------------------------------------------------------- |
|
410 // CPtiLanguageDatabase::CreateMappingTableOpaqueL |
|
411 // |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 EXPORT_C TInt CPtiLanguageDatabase::CreateMappingTableWithOpaqueL(TInt aCoreUid, RArray<TPtiLangDatabaseMappingOpaque>& aResult) |
|
415 { |
|
416 TInt res = 0, lc; |
|
417 TPtiLangDatabaseMappingOpaque map; |
|
418 RImplInfoPtrArray infoArray; |
|
419 TInt i; |
|
420 |
|
421 CleanupStack::PushL( TCleanupItem( DBCleanup, &infoArray ) ); |
|
422 REComSession::ListImplementationsL(TUid::Uid(aCoreUid), infoArray); |
|
423 |
|
424 for (i = 0; i < infoArray.Count(); i++) |
|
425 { |
|
426 lc = LanguageCodeForUid(infoArray[i]->ImplementationUid().iUid); |
|
427 |
|
428 map.iUid = infoArray[i]->ImplementationUid().iUid; |
|
429 map.iOpaque.Copy(infoArray[i]->OpaqueData().Left(KOpaqueDataLen)); |
|
430 |
|
431 if (lc) |
|
432 { |
|
433 map.iLangCode = lc; |
|
434 User::LeaveIfError(aResult.Append(map)); |
|
435 } |
|
436 else |
|
437 { |
|
438 CPtiLanguageDatabase* db = CreateDatabaseL(infoArray[i]->ImplementationUid()); |
|
439 if (db) |
|
440 { |
|
441 CleanupStack::PushL(db); |
|
442 map.iLangCode = db->LanguageCode(0); |
|
443 User::LeaveIfError(aResult.Append(map)); |
|
444 CleanupStack::PopAndDestroy(); // db |
|
445 } |
|
446 } |
|
447 } |
|
448 |
|
449 CleanupStack::PopAndDestroy(); // infoArray |
|
450 |
|
451 return res; |
|
452 } |
|
453 |
|
454 |
|
455 // End of file |
|
456 |
|
457 |