85
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 |
*
|
|
16 |
*/
|
|
17 |
|
98
|
18 |
#include <driveinfo.h>
|
|
19 |
#include <hbtextresolversymbian.h>
|
|
20 |
|
85
|
21 |
#include "castorage.h"
|
|
22 |
#include "castorageproxy.h"
|
|
23 |
#include "castoragefactory.h"
|
|
24 |
#include "cainnerentry.h"
|
|
25 |
#include "cainnerquery.h"
|
|
26 |
#include "caarraycleanup.inl"
|
|
27 |
#include "calocalizationentry.h"
|
|
28 |
#include "casrvsession.h"
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
CCaStorageProxy::CCaStorageProxy()
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
// ---------------------------------------------------------------------------
|
86
|
41 |
//
|
85
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
void CCaStorageProxy::ConstructL()
|
|
45 |
{
|
|
46 |
iStorage = CaStorageFactory::NewDatabaseL();
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CCaStorageProxy* CCaStorageProxy::NewL()
|
|
54 |
{
|
|
55 |
CCaStorageProxy* self = CCaStorageProxy::NewLC();
|
|
56 |
CleanupStack::Pop( self );
|
|
57 |
return self;
|
|
58 |
}
|
|
59 |
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
CCaStorageProxy* CCaStorageProxy::NewLC()
|
|
65 |
{
|
|
66 |
CCaStorageProxy* self = new ( ELeave ) CCaStorageProxy();
|
|
67 |
CleanupStack::PushL( self );
|
|
68 |
self->ConstructL();
|
|
69 |
return self;
|
|
70 |
}
|
|
71 |
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
CCaStorageProxy::~CCaStorageProxy()
|
|
77 |
{
|
125
|
78 |
iTitleUserColName.Close();
|
85
|
79 |
delete iStorage;
|
|
80 |
iHandlerNotifier.Close();
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
EXPORT_C void CCaStorageProxy::GetEntriesL(const CCaInnerQuery* aQuery,
|
|
88 |
RPointerArray<CCaInnerEntry>& aResultContainer )
|
|
89 |
{
|
|
90 |
iStorage->GetEntriesL( aQuery, aResultContainer );
|
125
|
91 |
if( aResultContainer.Count() == 1
|
|
92 |
&& aResultContainer[0]->
|
|
93 |
GetEntryTypeName().Compare( KCaTypeCollection ) == KErrNone )
|
|
94 |
{
|
|
95 |
TPtrC titleName;
|
|
96 |
if( !aResultContainer[0]->FindAttribute( KCaAttrTitleName, titleName ) )
|
|
97 |
{
|
|
98 |
AddTitleNameL( aResultContainer[0] );
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
85
|
102 |
}
|
|
103 |
|
86
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
// ---------------------------------------------------------------------------
|
85
|
107 |
//
|
|
108 |
EXPORT_C void CCaStorageProxy::GetEntriesIdsL(const CCaInnerQuery* aQuery,
|
|
109 |
RArray<TInt>& aResultIdArray)
|
|
110 |
{
|
|
111 |
iStorage->GetEntriesIdsL( aQuery, aResultIdArray );
|
|
112 |
}
|
|
113 |
|
86
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
// ---------------------------------------------------------------------------
|
85
|
117 |
//
|
93
|
118 |
EXPORT_C void CCaStorageProxy::AddL( CCaInnerEntry* aEntry,
|
|
119 |
TBool aUpdate,
|
|
120 |
TItemAppearance aItemAppearanceChange )
|
85
|
121 |
{
|
|
122 |
TChangeType changeType = EAddChangeType;
|
|
123 |
RArray<TInt> parentArray;
|
|
124 |
CleanupClosePushL( parentArray );
|
127
|
125 |
|
85
|
126 |
if( aEntry->GetId() > 0 )
|
|
127 |
{
|
|
128 |
changeType = EUpdateChangeType;
|
|
129 |
RArray<TInt> id;
|
|
130 |
CleanupClosePushL( id );
|
|
131 |
id.AppendL( aEntry->GetId() );
|
98
|
132 |
if (aItemAppearanceChange == EItemUninstallProgressChanged)
|
|
133 |
{
|
127
|
134 |
// no need to search for parent parents for uninstall
|
98
|
135 |
// progress change
|
|
136 |
iStorage->GetParentsIdsL( id, parentArray, EFalse );
|
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
|
140 |
iStorage->GetParentsIdsL( id, parentArray );
|
|
141 |
}
|
85
|
142 |
CleanupStack::PopAndDestroy( &id );
|
|
143 |
}
|
93
|
144 |
|
|
145 |
if( aItemAppearanceChange==EItemDisappeared )
|
|
146 |
{
|
|
147 |
changeType = ERemoveChangeType;
|
|
148 |
}
|
|
149 |
else if( aItemAppearanceChange==EItemAppeared )
|
|
150 |
{
|
|
151 |
changeType = EAddChangeType;
|
|
152 |
}
|
127
|
153 |
|
98
|
154 |
// do not update entry in db with uninstall progress
|
|
155 |
if (aItemAppearanceChange != EItemUninstallProgressChanged)
|
|
156 |
{
|
|
157 |
RPointerArray<CCaLocalizationEntry> localizations;
|
|
158 |
CleanupResetAndDestroyPushL( localizations );
|
|
159 |
CCaLocalizationEntry* tempLocalization = NULL;
|
127
|
160 |
if( aEntry->isLocalized( CCaInnerEntry::ENameLocalized ) )
|
98
|
161 |
{
|
|
162 |
tempLocalization = LocalizeTextL( aEntry );
|
|
163 |
if( tempLocalization )
|
|
164 |
{
|
|
165 |
localizations.Append( tempLocalization );
|
|
166 |
tempLocalization = NULL;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
if( aEntry->isLocalized( CCaInnerEntry::EDescriptionLocalized ) )
|
|
170 |
{
|
|
171 |
tempLocalization = LocalizeDescriptionL( aEntry );
|
|
172 |
if (tempLocalization)
|
|
173 |
{
|
|
174 |
localizations.Append(tempLocalization);
|
|
175 |
tempLocalization = NULL;
|
|
176 |
}
|
|
177 |
}
|
127
|
178 |
|
98
|
179 |
iStorage->AddL( aEntry, aUpdate );
|
127
|
180 |
|
98
|
181 |
for( TInt j =0; j < localizations.Count(); j++ )
|
|
182 |
{
|
|
183 |
localizations[j]->SetRowId( aEntry->GetId() );
|
|
184 |
AddLocalizationL( *( localizations[j] ) );
|
|
185 |
}
|
|
186 |
if( localizations.Count() > 0 )
|
|
187 |
{
|
|
188 |
HbTextResolverSymbian::Init( _L(""), KLocalizationFilepathZ );
|
|
189 |
}
|
|
190 |
CleanupStack::PopAndDestroy( &localizations );
|
|
191 |
}
|
127
|
192 |
aEntry->SetParentIdsL( parentArray );
|
85
|
193 |
for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
|
|
194 |
{
|
|
195 |
iHandlerNotifier[i]->EntryChanged( aEntry, changeType, parentArray );
|
|
196 |
}
|
|
197 |
CleanupStack::PopAndDestroy( &parentArray );
|
|
198 |
}
|
|
199 |
|
86
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
// ---------------------------------------------------------------------------
|
85
|
203 |
//
|
|
204 |
EXPORT_C void CCaStorageProxy::RemoveL( const RArray<TInt>& aEntryIds )
|
|
205 |
{
|
|
206 |
CCaInnerQuery* query = CCaInnerQuery::NewLC();
|
|
207 |
query->SetIdsL( aEntryIds );
|
|
208 |
RPointerArray<CCaInnerEntry> resultContainer;
|
|
209 |
CleanupResetAndDestroyPushL( resultContainer );
|
|
210 |
RArray<TInt> parentArray;
|
|
211 |
CleanupClosePushL( parentArray );
|
|
212 |
if( aEntryIds.Count() > 0 )
|
|
213 |
{
|
|
214 |
iStorage->GetEntriesL( query, resultContainer );
|
|
215 |
iStorage->GetParentsIdsL( aEntryIds, parentArray );
|
|
216 |
}
|
|
217 |
iStorage->RemoveL( aEntryIds );
|
|
218 |
for( TInt i( 0 ); i < resultContainer.Count(); i++ )
|
|
219 |
{
|
127
|
220 |
resultContainer[i]->SetParentIdsL( parentArray );
|
85
|
221 |
for( TInt j( 0 ); j < iHandlerNotifier.Count(); j++ )
|
|
222 |
{
|
86
|
223 |
iHandlerNotifier[j]->EntryChanged( resultContainer[i],
|
85
|
224 |
ERemoveChangeType, parentArray );
|
|
225 |
}
|
|
226 |
}
|
|
227 |
CleanupStack::PopAndDestroy( &parentArray );
|
|
228 |
CleanupStack::PopAndDestroy( &resultContainer );
|
|
229 |
CleanupStack::PopAndDestroy( query );
|
|
230 |
}
|
|
231 |
|
86
|
232 |
// ---------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
// ---------------------------------------------------------------------------
|
85
|
235 |
//
|
|
236 |
EXPORT_C void CCaStorageProxy::OrganizeL( const RArray<TInt>& aEntryIds,
|
|
237 |
TCaOperationParams aParams )
|
|
238 |
{
|
|
239 |
iStorage->OrganizeL( aEntryIds, aParams );
|
|
240 |
RArray<TInt> parentArray;
|
|
241 |
CleanupClosePushL( parentArray );
|
|
242 |
parentArray.AppendL( aParams.iGroupId );
|
|
243 |
iStorage->GetParentsIdsL( parentArray, parentArray );
|
|
244 |
for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
|
|
245 |
{
|
|
246 |
iHandlerNotifier[i]->GroupContentChanged( parentArray );
|
|
247 |
}
|
|
248 |
CleanupStack::PopAndDestroy( &parentArray );
|
|
249 |
}
|
|
250 |
|
86
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
// ---------------------------------------------------------------------------
|
85
|
254 |
//
|
|
255 |
EXPORT_C void CCaStorageProxy::TouchL( CCaInnerEntry* aEntry )
|
|
256 |
{
|
127
|
257 |
if( aEntry->GetId() == 0 && aEntry->GetUid() != 0 )
|
85
|
258 |
{
|
127
|
259 |
CCaInnerQuery* query = CCaInnerQuery::NewLC();
|
|
260 |
query->SetUid( static_cast<TUint>( aEntry->GetUid()) );
|
|
261 |
query->SetFlagsOn( ERemovable );
|
|
262 |
query->SetFlagsOff( EUsed );
|
86
|
263 |
|
127
|
264 |
RPointerArray<CCaInnerEntry> resultArray;
|
|
265 |
CleanupClosePushL( resultArray );
|
|
266 |
iStorage->GetEntriesL( query, resultArray );
|
|
267 |
if( resultArray.Count() == 1 )
|
|
268 |
{
|
|
269 |
PrivateTouchL( resultArray[0] );
|
|
270 |
}
|
|
271 |
else
|
85
|
272 |
{
|
127
|
273 |
User::Leave( KErrNotFound );
|
85
|
274 |
}
|
127
|
275 |
CleanupStack::PopAndDestroy( &resultArray );
|
|
276 |
CleanupStack::PopAndDestroy( query );
|
85
|
277 |
}
|
127
|
278 |
else if( aEntry->GetId() > 0 )
|
|
279 |
{
|
|
280 |
PrivateTouchL( aEntry );
|
|
281 |
}
|
|
282 |
else
|
|
283 |
{
|
|
284 |
User::Leave( KErrArgument );
|
|
285 |
}
|
85
|
286 |
}
|
|
287 |
|
86
|
288 |
// ---------------------------------------------------------------------------
|
|
289 |
//
|
|
290 |
// ---------------------------------------------------------------------------
|
85
|
291 |
//
|
|
292 |
EXPORT_C void CCaStorageProxy::GetLocalizationsL(
|
|
293 |
RPointerArray<CCaLocalizationEntry>& aResultArray )
|
|
294 |
{
|
|
295 |
iStorage->GetLocalizationsL( aResultArray );
|
|
296 |
}
|
|
297 |
|
86
|
298 |
// ---------------------------------------------------------------------------
|
|
299 |
//
|
|
300 |
// ---------------------------------------------------------------------------
|
85
|
301 |
//
|
|
302 |
EXPORT_C void CCaStorageProxy::LocalizeEntryL(
|
|
303 |
CCaLocalizationEntry& aLocalization )
|
|
304 |
{
|
|
305 |
iStorage->LocalizeEntryL( aLocalization );
|
|
306 |
}
|
|
307 |
|
86
|
308 |
// ---------------------------------------------------------------------------
|
|
309 |
//
|
|
310 |
// ---------------------------------------------------------------------------
|
85
|
311 |
//
|
94
|
312 |
EXPORT_C void CCaStorageProxy::AddLocalizationL(
|
|
313 |
const CCaLocalizationEntry& aLocalization)
|
|
314 |
{
|
|
315 |
iStorage->AddLocalizationL(aLocalization);
|
|
316 |
}
|
|
317 |
|
|
318 |
// ---------------------------------------------------------------------------
|
|
319 |
//
|
|
320 |
// ---------------------------------------------------------------------------
|
|
321 |
//
|
85
|
322 |
EXPORT_C void CCaStorageProxy::DbPropertyL( const TDesC& aProperty,
|
|
323 |
TDes& aPropertyValue )
|
|
324 |
{
|
|
325 |
iStorage->DbPropertyL( aProperty, aPropertyValue );
|
|
326 |
}
|
|
327 |
|
86
|
328 |
// ---------------------------------------------------------------------------
|
|
329 |
//
|
|
330 |
// ---------------------------------------------------------------------------
|
85
|
331 |
//
|
|
332 |
EXPORT_C void CCaStorageProxy::SetDBPropertyL( const TDesC& aProperty,
|
|
333 |
const TDesC& aPropertyValue )
|
|
334 |
{
|
|
335 |
iStorage->SetDBPropertyL( aProperty, aPropertyValue );
|
|
336 |
}
|
|
337 |
|
86
|
338 |
// ---------------------------------------------------------------------------
|
|
339 |
//
|
|
340 |
// ---------------------------------------------------------------------------
|
85
|
341 |
//
|
|
342 |
EXPORT_C void CCaStorageProxy::CustomSortL( const RArray<TInt>& aEntryIds,
|
|
343 |
const TInt aGroupId )
|
|
344 |
{
|
|
345 |
iStorage->CustomSortL( aEntryIds, aGroupId );
|
86
|
346 |
|
85
|
347 |
RArray<TInt> parentArray;
|
|
348 |
CleanupClosePushL( parentArray );
|
|
349 |
parentArray.AppendL( aGroupId );
|
102
|
350 |
iStorage->GetParentsIdsL( parentArray, parentArray );
|
85
|
351 |
for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
|
|
352 |
{
|
|
353 |
iHandlerNotifier[i]->GroupContentChanged( parentArray );
|
|
354 |
}
|
|
355 |
CleanupStack::PopAndDestroy( &parentArray );
|
|
356 |
}
|
|
357 |
|
107
|
358 |
// ---------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
// ---------------------------------------------------------------------------
|
|
361 |
//
|
98
|
362 |
#ifdef COVERAGE_MEASUREMENT
|
|
363 |
#pragma CTC SKIP
|
|
364 |
#endif //COVERAGE_MEASUREMENT (calls another method)
|
107
|
365 |
|
|
366 |
EXPORT_C void CCaStorageProxy::SaveDatabaseL()
|
|
367 |
{
|
|
368 |
iStorage->SaveDatabaseL();
|
|
369 |
}
|
|
370 |
#ifdef COVERAGE_MEASUREMENT
|
|
371 |
#pragma CTC ENDSKIP
|
|
372 |
#endif //COVERAGE_MEASUREMENT
|
|
373 |
|
|
374 |
|
86
|
375 |
// ---------------------------------------------------------------------------
|
|
376 |
//
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
//
|
107
|
379 |
#ifdef COVERAGE_MEASUREMENT
|
|
380 |
#pragma CTC SKIP
|
|
381 |
#endif //COVERAGE_MEASUREMENT (calls another method)
|
|
382 |
|
86
|
383 |
EXPORT_C void CCaStorageProxy::LoadDataBaseFromRomL()
|
|
384 |
{
|
|
385 |
iStorage->LoadDataBaseFromRomL();
|
|
386 |
}
|
98
|
387 |
#ifdef COVERAGE_MEASUREMENT
|
|
388 |
#pragma CTC ENDSKIP
|
|
389 |
#endif //COVERAGE_MEASUREMENT
|
86
|
390 |
|
85
|
391 |
// ---------------------------------------------------------
|
86
|
392 |
//
|
85
|
393 |
// ---------------------------------------------------------
|
|
394 |
//
|
|
395 |
void CCaStorageProxy::AddSessionL( MCaSessionNorifier* aHandlerNotifier )
|
|
396 |
{
|
86
|
397 |
__ASSERT_ALWAYS(
|
|
398 |
iHandlerNotifier.Find( aHandlerNotifier ) == KErrNotFound,
|
85
|
399 |
User::Invariant() );
|
|
400 |
iHandlerNotifier.AppendL( aHandlerNotifier );
|
|
401 |
}
|
|
402 |
|
|
403 |
// ---------------------------------------------------------
|
86
|
404 |
//
|
85
|
405 |
// ---------------------------------------------------------
|
|
406 |
//
|
|
407 |
void CCaStorageProxy::RemoveSession( MCaSessionNorifier* aHandlerNotifier )
|
|
408 |
{
|
|
409 |
TInt i = iHandlerNotifier.Find( aHandlerNotifier );
|
|
410 |
if( i != KErrNotFound )
|
|
411 |
{
|
|
412 |
iHandlerNotifier.Remove( i );
|
|
413 |
}
|
|
414 |
}
|
98
|
415 |
|
|
416 |
// ---------------------------------------------------------
|
|
417 |
//
|
|
418 |
// ---------------------------------------------------------
|
|
419 |
//
|
|
420 |
CCaLocalizationEntry* CCaStorageProxy::LocalizeTextL( CCaInnerEntry* aEntry )
|
|
421 |
{
|
|
422 |
CCaLocalizationEntry* result = NULL;
|
|
423 |
TInt textLength = aEntry->GetText().Length();
|
125
|
424 |
if( textLength > 0 )
|
98
|
425 |
{
|
|
426 |
TChar delimiter = '/'; // cannot add it as global
|
|
427 |
RBuf title;
|
|
428 |
CleanupClosePushL( title );
|
|
429 |
title.CreateL( aEntry->GetText() );
|
|
430 |
TInt pos = title.LocateReverse( delimiter );
|
|
431 |
if ( pos > 0 && pos + 1 < textLength ) // 1 is for delimiters
|
|
432 |
{
|
127
|
433 |
TPtrC16 logString = title.Mid( pos + 1 );
|
125
|
434 |
TInt qmFileNameLength =
|
|
435 |
textLength - charsToFilename - 1 - logString.Length();
|
98
|
436 |
TPtrC16 qmFile = title.Mid( charsToFilename, qmFileNameLength );
|
|
437 |
if ( InitializeTranslatorL( qmFile ) )
|
|
438 |
{
|
127
|
439 |
result = CCaLocalizationEntry::NewLC();
|
125
|
440 |
HBufC* translatedString =
|
|
441 |
HbTextResolverSymbian::LoadLC( logString );
|
98
|
442 |
if ( translatedString->Compare( logString ) )
|
|
443 |
{
|
|
444 |
result->SetStringIdL( logString );
|
|
445 |
aEntry->SetTextL( *translatedString );
|
|
446 |
if( translatedString )
|
|
447 |
{
|
|
448 |
CleanupStack::PopAndDestroy( translatedString );
|
|
449 |
}
|
|
450 |
result->SetTableNameL( KLocalizationCaEntry );
|
|
451 |
result->SetAttributeNameL( KLocalizationEnText );
|
|
452 |
result->SetQmFilenameL( qmFile );
|
|
453 |
result->SetRowId( aEntry->GetId() ? 0 : aEntry->GetId() ); // must be added when present
|
99
|
454 |
CleanupStack::Pop( result );
|
98
|
455 |
}
|
127
|
456 |
else
|
98
|
457 |
{
|
99
|
458 |
CleanupStack::PopAndDestroy(translatedString);
|
|
459 |
CleanupStack::PopAndDestroy(result);
|
|
460 |
result = NULL;
|
98
|
461 |
}
|
|
462 |
}
|
|
463 |
}
|
|
464 |
CleanupStack::PopAndDestroy( &title );
|
|
465 |
}
|
|
466 |
return result;
|
|
467 |
}
|
|
468 |
|
|
469 |
// ---------------------------------------------------------
|
|
470 |
//
|
|
471 |
// ---------------------------------------------------------
|
|
472 |
//
|
|
473 |
CCaLocalizationEntry* CCaStorageProxy::LocalizeDescriptionL( CCaInnerEntry* aEntry )
|
|
474 |
{
|
|
475 |
CCaLocalizationEntry* result = NULL;
|
|
476 |
TInt dscLength = aEntry->GetDescription().Length();
|
125
|
477 |
if( dscLength )
|
98
|
478 |
{
|
|
479 |
TChar delimiter = '/'; // cannot add it as global
|
|
480 |
RBuf description;
|
|
481 |
CleanupClosePushL( description );
|
|
482 |
description.CreateL( aEntry->GetDescription() );
|
|
483 |
TInt pos = description.LocateReverse( delimiter );
|
|
484 |
if ( pos > 0 && pos + 1 < dscLength ) // 1 is for delimiters
|
|
485 |
{
|
|
486 |
TPtrC16 logString = description.Mid(pos + 1);
|
|
487 |
TInt qmFileNameLength = dscLength - charsToFilename - 1 - logString.Length();
|
|
488 |
TPtrC16 qmFile = description.Mid(charsToFilename, qmFileNameLength);
|
|
489 |
if ( InitializeTranslatorL( qmFile ) )
|
|
490 |
{
|
|
491 |
result = CCaLocalizationEntry::NewLC();
|
|
492 |
HBufC* translatedString = HbTextResolverSymbian::LoadLC( logString );
|
|
493 |
if ( translatedString->Compare( logString ) )
|
|
494 |
{
|
|
495 |
result->SetStringIdL( logString );
|
|
496 |
aEntry->SetDescriptionL( *translatedString );
|
|
497 |
CleanupStack::PopAndDestroy( translatedString );
|
|
498 |
result->SetTableNameL( KLocalizationCaEntry );
|
|
499 |
result->SetAttributeNameL( KLocalizationEnDescription );
|
|
500 |
result->SetQmFilenameL( qmFile );
|
|
501 |
result->SetRowId( aEntry->GetId() ? 0 : aEntry->GetId() ); // must be added when present
|
99
|
502 |
CleanupStack::Pop( result );
|
98
|
503 |
}
|
127
|
504 |
else
|
98
|
505 |
{
|
|
506 |
CleanupStack::PopAndDestroy( translatedString );
|
99
|
507 |
CleanupStack::PopAndDestroy( result );
|
|
508 |
result = NULL;
|
98
|
509 |
}
|
127
|
510 |
|
98
|
511 |
}
|
|
512 |
}
|
|
513 |
CleanupStack::PopAndDestroy( &description );
|
|
514 |
}
|
127
|
515 |
|
98
|
516 |
return result;
|
|
517 |
}
|
|
518 |
|
|
519 |
// ---------------------------------------------------------
|
|
520 |
//
|
|
521 |
// ---------------------------------------------------------
|
|
522 |
//
|
125
|
523 |
void CCaStorageProxy::AddTitleNameL( CCaInnerEntry* aEntry )
|
|
524 |
{
|
|
525 |
if( !iTitleUserColName.Length() )
|
|
526 |
{
|
|
527 |
if ( InitializeTranslatorL( KCaQmFile ) )
|
|
528 |
{
|
|
529 |
HBufC* translatedString =
|
|
530 |
HbTextResolverSymbian::LoadLC( KDefaultLocTitleName );
|
|
531 |
if ( translatedString->Compare( KDefaultLocTitleName ) )
|
|
532 |
{
|
|
533 |
iTitleUserColName.CreateL( *translatedString );
|
|
534 |
}
|
|
535 |
CleanupStack::PopAndDestroy( translatedString );
|
|
536 |
}
|
|
537 |
}
|
|
538 |
if( iTitleUserColName.Length() )
|
|
539 |
{
|
|
540 |
aEntry->AddAttributeL( KCaAttrTitleName, iTitleUserColName );
|
|
541 |
}
|
|
542 |
}
|
|
543 |
|
|
544 |
// ---------------------------------------------------------
|
|
545 |
//
|
|
546 |
// ---------------------------------------------------------
|
|
547 |
//
|
|
548 |
TBool CCaStorageProxy::InitializeTranslatorL( const TDesC& aQmFilename )
|
98
|
549 |
{
|
|
550 |
TBool result = HbTextResolverSymbian::Init( aQmFilename, KLocalizationFilepathC );
|
|
551 |
if ( !result )
|
|
552 |
{
|
127
|
553 |
// this should not be called too often
|
98
|
554 |
TChar currentDriveLetter;
|
|
555 |
TDriveList driveList;
|
|
556 |
RFs fs;
|
125
|
557 |
CleanupClosePushL( fs );
|
98
|
558 |
User::LeaveIfError( fs.Connect() );
|
|
559 |
User::LeaveIfError( fs.DriveList( driveList ) );
|
|
560 |
|
|
561 |
RBuf path;
|
|
562 |
CleanupClosePushL( path );
|
|
563 |
path.CreateL( KLocalizationFilepath().Length() + 1 );
|
|
564 |
|
|
565 |
for ( TInt driveNr = EDriveY; driveNr >= EDriveA; driveNr-- )
|
|
566 |
{
|
|
567 |
if ( driveList[driveNr] )
|
|
568 |
{
|
|
569 |
User::LeaveIfError(fs.DriveToChar( driveNr, currentDriveLetter ));
|
|
570 |
path.Append( currentDriveLetter );
|
|
571 |
path.Append( KLocalizationFilepath );
|
|
572 |
if (HbTextResolverSymbian::Init( aQmFilename, path ))
|
|
573 |
{
|
|
574 |
result = ETrue;
|
|
575 |
break;
|
|
576 |
}
|
|
577 |
}
|
|
578 |
path.Zero();
|
|
579 |
}
|
|
580 |
CleanupStack::PopAndDestroy( &path );
|
125
|
581 |
CleanupStack::PopAndDestroy( &fs );
|
127
|
582 |
|
98
|
583 |
if( !result )
|
|
584 |
{
|
|
585 |
result = HbTextResolverSymbian::Init( aQmFilename, KLocalizationFilepathZ );
|
|
586 |
}
|
|
587 |
}
|
|
588 |
return result;
|
|
589 |
}
|
127
|
590 |
|
|
591 |
// ---------------------------------------------------------
|
|
592 |
//
|
|
593 |
// ---------------------------------------------------------
|
|
594 |
//
|
|
595 |
void CCaStorageProxy::PrivateTouchL( CCaInnerEntry* aEntry )
|
|
596 |
{
|
|
597 |
iStorage->TouchL( aEntry->GetId(), aEntry->GetFlags() & ERemovable );
|
|
598 |
for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
|
|
599 |
{
|
|
600 |
iHandlerNotifier[i]->EntryTouched( aEntry->GetId() );
|
|
601 |
}
|
|
602 |
if( !( aEntry->GetFlags() & EUsed ) &&
|
|
603 |
( aEntry->GetFlags() & ERemovable ) )
|
|
604 |
{
|
|
605 |
RArray<TInt> id;
|
|
606 |
CleanupClosePushL( id );
|
|
607 |
id.AppendL( aEntry->GetId() );
|
|
608 |
RArray<TInt> parentArray;
|
|
609 |
CleanupClosePushL( parentArray );
|
|
610 |
iStorage->GetParentsIdsL( id, parentArray );
|
|
611 |
aEntry->SetParentIdsL( parentArray );
|
|
612 |
for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
|
|
613 |
{
|
|
614 |
aEntry->SetFlags(
|
|
615 |
aEntry->GetFlags() | EUsed );
|
|
616 |
iHandlerNotifier[i]->EntryChanged( aEntry,
|
|
617 |
EUpdateChangeType,
|
|
618 |
parentArray );
|
|
619 |
}
|
|
620 |
CleanupStack::PopAndDestroy( &parentArray );
|
|
621 |
CleanupStack::PopAndDestroy( &id );
|
|
622 |
}
|
|
623 |
}
|