|
1 /* |
|
2 * Copyright (c) 2002-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: Defines an internal concrete class CAknsAppSkinInstance and |
|
15 * related types. This class encapsulates the concrete skin |
|
16 * instance which is a singleton in thread scope. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
23 #include <uikon/eikdefconst.h> |
|
24 #endif |
|
25 #include "AknsCppPreface.h" |
|
26 |
|
27 #include <eikenv.h> |
|
28 #include <eikappui.h> |
|
29 #include <eikapp.h> |
|
30 #include <AknCapServerDefs.h> |
|
31 |
|
32 #include <centralrepository.h> |
|
33 #include <AknSkinsInternalCRKeys.h> |
|
34 #include <apgcli.h> |
|
35 |
|
36 #include <AknsItemData.h> |
|
37 #include <AknsImageAttributeData.h> |
|
38 #include <AknsItemDef.h> |
|
39 #include <AknsConstants.h> |
|
40 #include <AknsUtils.h> |
|
41 |
|
42 #include "AknsAppSkinInstance.h" |
|
43 #include "AknsItemDataFactory.h" |
|
44 #include "AknsASICacheEntry.h" |
|
45 #include "AknsTemporaryBitmap.h" |
|
46 #include "AknsScalabilityUtils.h" |
|
47 #include "AknsRlDefaultRenderer.h" |
|
48 #include "AknsRlMasterLayout.h" |
|
49 #include "AknsDebug.h" |
|
50 #include <pslninternalcrkeys.h> |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CAknsAppSkinInstance::CAknsAppSkinInstance |
|
56 // C++ default constructor can NOT contain any code, that might leave. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CAknsAppSkinInstance::CAknsAppSkinInstance() : |
|
60 CCoeStatic( KAknsSkinInstanceTls, EThread ), iChangeEventsEnabled( ETrue ), |
|
61 iChangeEventPending( EFalse ), iAppConfigurationCenrepNotUsed( EFalse ) |
|
62 // CBase initializes: iChunkLookup(0), iRenderer(0), iMasterLayout(0), |
|
63 // iVariantHlAnimStatus(0) |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CAknsAppSkinInstance::ContructL |
|
69 // EPOC default constructor can leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CAknsAppSkinInstance::ConstructL() |
|
73 { |
|
74 User::LeaveIfError( iSession.Connect( this ) ); |
|
75 iChunkLookup = iSession.CreateChunkLookupL(); |
|
76 iRenderer = CAknsRlDefaultRenderer::NewL(&iSession); |
|
77 iMasterLayout = CAknsRlMasterLayout::NewL(); |
|
78 |
|
79 InitPslnCenrepL(); |
|
80 |
|
81 InitAnimBackgroundL( ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CAknsAppSkinInstance::InitAnimBackgroundL |
|
86 // Initalize Animation background State |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CAknsAppSkinInstance::InitAnimBackgroundL( ) |
|
90 { |
|
91 CRepository* theme = CRepository::NewL(KCRUidThemes); |
|
92 iAnimBgState = EFalse; |
|
93 |
|
94 TInt value = KMaxTInt; |
|
95 TInt err = theme->Get( KThemesAnimBackgroundSupport, value ); |
|
96 delete theme; |
|
97 |
|
98 if( !err && !value ) |
|
99 { |
|
100 iAnimBgState = ETrue; |
|
101 } |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CAknsAppSkinInstance::AnimBackgroundState |
|
106 // Get Animation background State |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TBool CAknsAppSkinInstance::AnimBackgroundState( ) const |
|
110 { |
|
111 return iAnimBgState; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CAknsAppSkinInstance::InitPslnCenrepL |
|
116 // Get Psln Cenrep |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CAknsAppSkinInstance::InitPslnCenrepL( TBool aOnlyWP ) |
|
120 { |
|
121 CRepository* rep = CRepository::NewL( KCRUidPersonalisation ); |
|
122 CleanupStack::PushL( rep ); |
|
123 |
|
124 TInt err = 0; |
|
125 if ( !aOnlyWP ) |
|
126 { |
|
127 TInt value = 0; |
|
128 // Product variant's animation status is read-only -> can be safely cached |
|
129 // for fast access. |
|
130 err = rep->Get( KPslnHighlightAnimationEnabled, value ); |
|
131 |
|
132 if( err || !value ) |
|
133 { |
|
134 iVariantHlAnimStatus = EFalse; |
|
135 } |
|
136 else // No error and enable flag was set |
|
137 { |
|
138 iVariantHlAnimStatus = ETrue; |
|
139 } |
|
140 } |
|
141 |
|
142 iWallpaperDefined = EFalse; |
|
143 TFileName name; |
|
144 err = rep->Get( KPslnIdleBackgroundImagePath, name ); |
|
145 if ( !err && name.Length()) |
|
146 { |
|
147 iWallpaperDefined = ETrue; |
|
148 } |
|
149 |
|
150 CleanupStack::PopAndDestroy( rep ); |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CAknsAppSkinInstance::WallpaperType |
|
155 // Get wallpaper type |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 TBool CAknsAppSkinInstance::WallpaperDefined( ) const |
|
159 { |
|
160 return iWallpaperDefined; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CAknsAppSkinInstance::CreateSingletonL |
|
165 // Two-phased constructor. |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CAknsAppSkinInstance::CreateSingletonL() |
|
169 { |
|
170 AKNS_TRACE_INFO("CAknsAppSkinInstance::CreateSingletonL"); |
|
171 CAknsAppSkinInstance* self = new (ELeave) CAknsAppSkinInstance; |
|
172 |
|
173 CleanupStack::PushL( self ); |
|
174 self->ConstructL(); |
|
175 CleanupStack::Pop( self ); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // Destructor |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 CAknsAppSkinInstance::~CAknsAppSkinInstance() |
|
183 { |
|
184 AKNS_TRACE_INFO("CAknsAppSkinInstance::destructor"); |
|
185 iLocalItemDefArray.ResetAndDestroy(); |
|
186 iCache.ResetAndDestroy(); |
|
187 iControlPositionList.Close(); |
|
188 iPointerStoreList.Close(); |
|
189 iTmpBmpArray.ResetAndDestroy(); |
|
190 iLayoutBmpArray.ResetAndDestroy(); |
|
191 iSession.Close(); |
|
192 delete iChunkLookup; |
|
193 delete iRenderer; |
|
194 delete iMasterLayout; |
|
195 if (iCachedApaSession) |
|
196 { |
|
197 iCachedApaSession->Close(); |
|
198 } |
|
199 delete iCachedApaSession; |
|
200 } //lint !e1740 Debug variables not freed |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CAknsAppSkinInstance::RootDataContext() |
|
204 // (documented in the header). |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 MAknsDataContext* CAknsAppSkinInstance::RootDataContext() |
|
208 { |
|
209 return static_cast<MAknsDataContext*>(this); |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CAknsAppSkinInstance::GetCachedItemData |
|
214 // (documented in the header). |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 CAknsItemData* CAknsAppSkinInstance::GetCachedItemData( const TAknsItemID& aID, |
|
218 const TAknsItemType aType ) |
|
219 { |
|
220 AKNS_TRACE_INFO3("CAknsAppSkinInstance::GetCachedItemData %i,%i %i", |
|
221 aID.iMajor,aID.iMinor,aType); |
|
222 CAknsAppSkinInstanceCacheEntry* cacheEntry = FindFromCache( aID ); |
|
223 |
|
224 if( !cacheEntry ) |
|
225 { |
|
226 AKNS_TRACE_INFO("CAknsAppSkinInstance::GetCachedItemData MISS"); |
|
227 TRAPD(result, (cacheEntry=LookupCreateAndCacheL( aID, aType )) ); |
|
228 if( result != KErrNone ) |
|
229 { |
|
230 AKNS_TRACE_ERROR1("CAknsAppSkinInstance::GetCachedItemData ERROR %i", result ); |
|
231 if( result == KErrNoMemory ) |
|
232 { |
|
233 HandleClientError( EAknsClientErrorOOM ); |
|
234 } |
|
235 else |
|
236 { |
|
237 HandleClientError( EAknsClientErrorUnspecified ); |
|
238 } |
|
239 return NULL; |
|
240 } |
|
241 if( !cacheEntry ) |
|
242 { |
|
243 return NULL; |
|
244 } |
|
245 } |
|
246 else |
|
247 { |
|
248 if( !cacheEntry->Data() ) |
|
249 { |
|
250 // Cache entry without data is a cached miss |
|
251 AKNS_TRACE_INFO("CAknsAppSkinInstance:GetCachedItemData CACHED MISS"); |
|
252 return NULL; |
|
253 } |
|
254 if( !AknsUtils::IsDerivedType( aType, cacheEntry->Data()->Type()) ) |
|
255 { |
|
256 AKNS_TRACE_INFO("CAknsAppSkinInstance::GetCachedItemData TYPE MISMATCH"); |
|
257 return NULL; |
|
258 } |
|
259 } |
|
260 |
|
261 return cacheEntry->Data(); |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CAknsAppSkinInstance::GetCachedItemData |
|
266 // (documented in the header). |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 CAknsItemData* CAknsAppSkinInstance::GetCachedItemData( const TAknsItemID& aID ) |
|
270 { |
|
271 return GetCachedItemData( aID, EAknsITUnknown ); |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CAknsAppSkinInstance::CreateUncachedItemDataL |
|
276 // (documented in the header). |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 CAknsItemData* CAknsAppSkinInstance::CreateUncachedItemDataL( |
|
280 const TAknsItemID& aID, const TAknsItemType aType ) |
|
281 { |
|
282 AKNS_TRACE_INFO3("CAknsAppSkinInstance::CreateUncachedItemData %i,%i %i", |
|
283 aID.iMajor,aID.iMinor,aType); |
|
284 |
|
285 return LookupAndCreateL( aID, aType ); |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CAknsAppSkinInstance::CreateUncachedItemDataL |
|
290 // (documented in the header). |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 CAknsItemData* CAknsAppSkinInstance::CreateUncachedItemDataL( |
|
294 const TAknsItemID& aID ) |
|
295 { |
|
296 AKNS_TRACE_INFO2("CAknsAppSkinInstance::CreateUncachedItemData %i,%i", |
|
297 aID.iMajor,aID.iMinor); |
|
298 |
|
299 return LookupAndCreateL( aID, EAknsITUnknown ); |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // CAknsAppSkinInstance::SetLocalItemDefL() |
|
304 // (documented in the header). |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void CAknsAppSkinInstance::SetLocalItemDefL( CAknsItemDef* aDef ) |
|
308 { |
|
309 AKNS_TRACE_INFO("CAknsAppSkinInstance::SetLocalItemDef"); |
|
310 __ASSERT_DEBUG( aDef, AKNS_DEBUG_PANIC(EAknsDPanicInvalidParameter) ); |
|
311 |
|
312 TInt index; |
|
313 if( iLocalItemDefArray.FindInOrder( aDef, index, |
|
314 CAknsItemDef::LinearOrder ) == KErrNone ) |
|
315 { |
|
316 CAknsItemDef* oldEntry = iLocalItemDefArray[index]; |
|
317 iLocalItemDefArray.Remove( index ); |
|
318 delete oldEntry; |
|
319 |
|
320 CleanupStack::PushL( aDef ); |
|
321 User::LeaveIfError( |
|
322 iLocalItemDefArray.InsertInOrder( aDef, |
|
323 CAknsItemDef::LinearOrder ) ); |
|
324 CleanupStack::Pop( aDef ); |
|
325 } |
|
326 else |
|
327 { |
|
328 CleanupStack::PushL( aDef ); |
|
329 User::LeaveIfError( |
|
330 iLocalItemDefArray.InsertInOrder( aDef, |
|
331 CAknsItemDef::LinearOrder ) ); |
|
332 CleanupStack::Pop( aDef ); |
|
333 } |
|
334 |
|
335 UpdateCachedItemL( FindFromCache(aDef->ID()), EFalse ); |
|
336 |
|
337 iLayoutBmpArray.ResetAndDestroy(); |
|
338 NotifyItemDefChange(); |
|
339 } |
|
340 |
|
341 void CAknsAppSkinInstance::RemoveLocalItemDefs() |
|
342 { |
|
343 iLocalItemDefArray.ResetAndDestroy(); |
|
344 iCache.ResetAndDestroy(); |
|
345 iTmpBmpArray.ResetAndDestroy(); |
|
346 iLayoutBmpArray.ResetAndDestroy(); |
|
347 NotifyItemDefChange(); |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CAknsAppSkinInstance::SetChangeEventsEnabled() |
|
352 // (documented in the header). |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 void CAknsAppSkinInstance::SetChangeEventsEnabled( TBool aEnabled ) |
|
356 { |
|
357 iChangeEventsEnabled = aEnabled; |
|
358 |
|
359 if( iChangeEventPending ) |
|
360 { |
|
361 NotifyItemDefChange(); |
|
362 } |
|
363 } |
|
364 |
|
365 // ----------------------------------------------------------------------------- |
|
366 // CAknsAppSkinInstance::NotifyClientError() |
|
367 // (documented in the header). |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void CAknsAppSkinInstance::NotifyClientError( const TAknsClientError aError ) |
|
371 { |
|
372 AKNS_TRACE_ERROR1("CAknsAppSkinInstance::NotifyClientError %i", aError ); |
|
373 HandleClientError( aError ); |
|
374 } |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // CAknsAppSkinInstance::SkinChangeReason() |
|
378 // (documented in the header). |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 TAknsSkinChangeReason CAknsAppSkinInstance::SkinChangeReason() |
|
382 { |
|
383 return iLastChangeReason; |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // CAknsAppSkinInstance::ReserveItemL() |
|
388 // (documented in the header). |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 void CAknsAppSkinInstance::ReserveItemL( const TAknsItemID& aID ) |
|
392 { |
|
393 CAknsAppSkinInstanceCacheEntry* entry = FindFromCache( aID ); |
|
394 |
|
395 if( entry ) |
|
396 { |
|
397 AKNS_TRACE_INFO2("CAknsAppSkinInstance::ReserveItemL %i,%i ref++", |
|
398 aID.iMajor, aID.iMinor); |
|
399 entry->IncreaseRefCount(); |
|
400 } |
|
401 else |
|
402 { |
|
403 AKNS_TRACE_INFO2("CAknsAppSkinInstance::ReserveItemL %i,%i NEW", |
|
404 aID.iMajor, aID.iMinor); |
|
405 // Since the misses are cached as well, there is no reason to leave if |
|
406 // not found. |
|
407 LookupCreateAndCacheL( aID, EAknsITUnknown ); |
|
408 } |
|
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // CAknsAppSkinInstance::ReleaseItem() |
|
413 // (documented in the header). |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 void CAknsAppSkinInstance::ReleaseItem( const TAknsItemID& aID ) |
|
417 { |
|
418 CAknsAppSkinInstanceCacheEntry* entry = FindFromCache( aID ); |
|
419 |
|
420 //Comment out for BUG:UKAL-7JY8FD |
|
421 //__ASSERT_DEBUG( entry, AKNS_DEBUG_PANIC(EAknsDPanicReleaseUnderflow) ); |
|
422 |
|
423 // For release builds, play it safe |
|
424 if( !entry ) //lint !e774 Necessary for UREL |
|
425 { |
|
426 return; |
|
427 } |
|
428 |
|
429 AKNS_TRACE_INFO2("CAknsAppSkinInstance::ReleaseItem %i,%i ref--", |
|
430 aID.iMajor, aID.iMinor); |
|
431 entry->DecreaseRefCount(); |
|
432 |
|
433 if( !entry->IsReferenced() ) |
|
434 { |
|
435 AKNS_TRACE_INFO2("CAknsAppSkinInstance::ReleaseItem %i,%i DELETE", |
|
436 aID.iMajor, aID.iMinor); |
|
437 RemoveAndDestroyFromCache( aID ); |
|
438 } |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CAknsAppSkinInstance::FlushLocalCaches() |
|
443 // (documented in the header). |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 void CAknsAppSkinInstance::FlushLocalCaches() |
|
447 { |
|
448 iTmpBmpArray.ResetAndDestroy(); |
|
449 iCache.ResetAndDestroy(); |
|
450 iLayoutBmpArray.ResetAndDestroy(); |
|
451 } |
|
452 |
|
453 // ----------------------------------------------------------------------------- |
|
454 // CAknsAppSkinInstance::SkinContentChanged |
|
455 // (documented in the header). |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 void CAknsAppSkinInstance::SkinContentChanged() |
|
459 { |
|
460 iUpdateInProgress = ETrue; |
|
461 |
|
462 // Reset temporary bitmaps first |
|
463 iTmpBmpArray.ResetAndDestroy(); |
|
464 |
|
465 // Reset cache |
|
466 iCache.ResetAndDestroy(); |
|
467 |
|
468 // Layout bmp reset and notifications are done in SkinConfigurationChanged |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // CAknsAppSkinInstance::SkinConfigurationChanged |
|
473 // (documented in the header). |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 void CAknsAppSkinInstance::SkinConfigurationChanged( |
|
477 const TAknsSkinStatusConfigurationChangeReason aReason ) |
|
478 { |
|
479 if( aReason == EAknsSkinStatusConfigurationDeployed ) |
|
480 { |
|
481 // All clients have now processed SkinContentChanged |
|
482 // and server has cleared layout bitmaps |
|
483 |
|
484 // Cache is reset - clear layout bitmaps from client |
|
485 iLayoutBmpArray.ResetAndDestroy(); |
|
486 |
|
487 // Update completed |
|
488 iUpdateInProgress = EFalse; |
|
489 iLastChangeReason = ENormalSkinChange; |
|
490 // Finally, notify |
|
491 NotifyItemDefChange(); |
|
492 } |
|
493 else if( aReason == EAknsSkinStatusMorphingStateChange ) |
|
494 { |
|
495 // @TODO Only selective update is actually needed |
|
496 iUpdateInProgress = ETrue; |
|
497 iLayoutBmpArray.ResetAndDestroy(); |
|
498 iUpdateInProgress = EFalse; |
|
499 iLastChangeReason = EMorphingStateChange; |
|
500 NotifyItemDefChange(EFalse); |
|
501 } |
|
502 else if (aReason == EAknsSkinStatusWallpaperChanged ) |
|
503 { |
|
504 TRAP_IGNORE( InitPslnCenrepL( ETrue )); |
|
505 iUpdateInProgress = ETrue; |
|
506 RemoveAndDestroyFromCache( KAknsIIDWallpaper ); |
|
507 iLayoutBmpArray.ResetAndDestroy(); |
|
508 iUpdateInProgress = EFalse; |
|
509 iLastChangeReason = EWallpaperChange; |
|
510 //NotifyItemDefChange(EFalse); |
|
511 } |
|
512 else if ( aReason == EAknsSkinStatusAnimBackgroundChanged ) |
|
513 { |
|
514 TRAP_IGNORE( InitAnimBackgroundL( ) ); |
|
515 NotifyItemDefChange(EFalse); |
|
516 } |
|
517 } |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // CAknsAppSkinInstance::SkinPackageChanged |
|
521 // (documented in the header). |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 void CAknsAppSkinInstance::SkinPackageChanged( |
|
525 const TAknsSkinStatusPackageChangeReason /*aReason*/ ) |
|
526 { |
|
527 } |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CAknsAppSkinInstance::DebugLocalItemDefCount |
|
531 // (documented in the header). |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 AKNS_EXPORTED_METHOD(CAknsAppSkinInstance::DebugLocalItemDefCount) |
|
535 EXPORT_C TInt CAknsAppSkinInstance::DebugLocalItemDefCount() |
|
536 { |
|
537 return iLocalItemDefArray.Count(); |
|
538 } |
|
539 |
|
540 // ----------------------------------------------------------------------------- |
|
541 // CAknsAppSkinInstance::DebugCacheCount |
|
542 // (documented in the header). |
|
543 // ----------------------------------------------------------------------------- |
|
544 // |
|
545 AKNS_EXPORTED_METHOD(CAknsAppSkinInstance::DebugCacheCount) |
|
546 EXPORT_C TInt CAknsAppSkinInstance::DebugCacheCount() |
|
547 { |
|
548 return iCache.Count(); |
|
549 } |
|
550 |
|
551 // ----------------------------------------------------------------------------- |
|
552 // CAknsAppSkinInstance::DebugHookClientErrors |
|
553 // (documented in the header). |
|
554 // ----------------------------------------------------------------------------- |
|
555 // |
|
556 AKNS_EXPORTED_METHOD(CAknsAppSkinInstance::DebugHookClientErrors) |
|
557 EXPORT_C void CAknsAppSkinInstance::DebugHookClientErrors( |
|
558 void (*aCallback)(TAny*), TAny* aParam ) |
|
559 { |
|
560 iDebugErrorCallback = aCallback; |
|
561 iDebugErrorCallbackParam = aParam; |
|
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // CAknsAppSkinInstance::DebugHookChangeNotifications |
|
566 // (documented in the header). |
|
567 // ----------------------------------------------------------------------------- |
|
568 // |
|
569 AKNS_EXPORTED_METHOD(CAknsAppSkinInstance::DebugHookChangeNotifications) |
|
570 EXPORT_C void CAknsAppSkinInstance::DebugHookChangeNotifications( |
|
571 void (*aCallback)(TAny*), TAny* aParam ) |
|
572 { |
|
573 iDebugChangeCallback = aCallback; |
|
574 iDebugChangeCallbackParam = aParam; |
|
575 } |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // CAknsAppSkinInstance::DebugReset |
|
579 // (documented in the header). |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 AKNS_EXPORTED_METHOD(CAknsAppSkinInstance::DebugReset) |
|
583 EXPORT_C void CAknsAppSkinInstance::DebugReset() |
|
584 { |
|
585 iLocalItemDefArray.ResetAndDestroy(); |
|
586 iCache.ResetAndDestroy(); |
|
587 iControlPositionList.Reset(); |
|
588 iPointerStoreList.Reset(); |
|
589 iTmpBmpArray.ResetAndDestroy(); |
|
590 iLayoutBmpArray.ResetAndDestroy(); |
|
591 } |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // CAknsAppSkinInstance::UpdateCachedItemL() |
|
595 // (documented in the header). |
|
596 // ----------------------------------------------------------------------------- |
|
597 // |
|
598 void CAknsAppSkinInstance::UpdateCachedItemL( |
|
599 CAknsAppSkinInstanceCacheEntry* aCacheEntry, const TBool aRemoveIfNotFound ) |
|
600 { |
|
601 AKNS_TRACE_INFO("CAknsAppSkinInstance::UpdateCachedItemL"); |
|
602 if( !aCacheEntry ) |
|
603 { |
|
604 return; |
|
605 } |
|
606 |
|
607 AKNS_TRACE_INFO2("CAknsAppSkinInstance::UpdateCachedItemL cache update %i,%i", |
|
608 aCacheEntry->ID().iMajor, aCacheEntry->ID().iMinor ); |
|
609 |
|
610 TInt createStatus = KErrNone; |
|
611 CAknsItemData* newData = NULL; |
|
612 TRAP( createStatus, |
|
613 ( newData = LookupAndCreateL( aCacheEntry->ID(), |
|
614 EAknsITUnknown ) ) ); |
|
615 |
|
616 if( createStatus == KErrNone ) |
|
617 { |
|
618 if( newData || (!aRemoveIfNotFound) ) |
|
619 { |
|
620 aCacheEntry->DestroyAndSetData( newData ); |
|
621 } |
|
622 else |
|
623 { |
|
624 AKNS_TRACE_INFO("CAknsAppSkinInstance::UpdateCachedItemL cache REMOVE"); |
|
625 RemoveAndDestroyFromCache( aCacheEntry->ID() ); |
|
626 } |
|
627 } |
|
628 else |
|
629 { |
|
630 AKNS_TRACE_INFO("CAknsAppSkinInstance::UpdateCachedItemL cache DELETE"); |
|
631 RemoveAndDestroyFromCache( aCacheEntry->ID() ); |
|
632 } |
|
633 |
|
634 User::LeaveIfError( createStatus ); |
|
635 } |
|
636 |
|
637 // ----------------------------------------------------------------------------- |
|
638 // CAknsAppSkinInstance::NotifyItemDefChange() |
|
639 // (documented in the header). |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 void CAknsAppSkinInstance::NotifyItemDefChange(TBool aFgOnly) |
|
643 { |
|
644 if( iChangeEventsEnabled ) |
|
645 { |
|
646 iChangeEventPending = EFalse; |
|
647 |
|
648 if( iDebugChangeCallback ) |
|
649 { |
|
650 (*iDebugChangeCallback)( iDebugChangeCallbackParam ); |
|
651 } |
|
652 else |
|
653 { |
|
654 TInt focusWgroup; |
|
655 TInt currentGroup; |
|
656 |
|
657 CEikonEnv* env = CEikonEnv::Static(); |
|
658 |
|
659 if (aFgOnly) |
|
660 { |
|
661 focusWgroup = env->WsSession().GetFocusWindowGroup(); |
|
662 currentGroup = env->RootWin().Identifier(); |
|
663 TUid appdlluid = KNullUid; |
|
664 CEikAppUi* appui = (CEikAppUi*)(env->AppUi()); |
|
665 CEikApplication* app = NULL; |
|
666 if (appui) |
|
667 { |
|
668 app = appui->Application(); |
|
669 } |
|
670 if (app) |
|
671 { |
|
672 appdlluid = app->AppDllUid(); |
|
673 } |
|
674 if ( appdlluid != KAknCapServerUid && (focusWgroup != currentGroup)) |
|
675 { |
|
676 return; |
|
677 } |
|
678 if (appui) |
|
679 { |
|
680 TRAP_IGNORE( |
|
681 appui->ReportResourceChangedToAppL(KAknsMessageSkinChange); |
|
682 appui->ReportResourceChangedToAppL(KEikMessageColorSchemeChange); |
|
683 ); |
|
684 return; |
|
685 } |
|
686 } |
|
687 else |
|
688 { |
|
689 CEikAppUi* appui = (CEikAppUi*)(env->AppUi()); |
|
690 if (appui) |
|
691 { |
|
692 TRAP_IGNORE( |
|
693 appui->ReportResourceChangedToAppL(KAknsMessageSkinChange); |
|
694 appui->ReportResourceChangedToAppL(KEikMessageColorSchemeChange); ); |
|
695 return; |
|
696 } |
|
697 else |
|
698 { |
|
699 TWsEvent event; |
|
700 event.SetType(KUidValueAknsSkinChangeEvent); |
|
701 |
|
702 env->WsSession().SendEventToWindowGroup( |
|
703 env->RootWin().Identifier(), event); |
|
704 |
|
705 event.SetType(KUidValueEikColorSchemeChangeEvent); |
|
706 env->WsSession().SendEventToWindowGroup( |
|
707 env->RootWin().Identifier(), event); |
|
708 } |
|
709 } |
|
710 RedrawScreen(); |
|
711 } |
|
712 } |
|
713 else |
|
714 { |
|
715 iChangeEventPending = ETrue; |
|
716 } |
|
717 } |
|
718 |
|
719 // ----------------------------------------------------------------------------- |
|
720 // CAknsAppSkinInstance::RedrawScreen() |
|
721 // (documented in the header). |
|
722 // ----------------------------------------------------------------------------- |
|
723 // |
|
724 void CAknsAppSkinInstance::RedrawScreen() const |
|
725 { |
|
726 /*CEikAppUi* appUi = CEikonEnv::Static()->EikAppUi(); |
|
727 TBool faded = appUi->IsFaded(); |
|
728 |
|
729 // Toggle fade (and toggle it back to the original state). This ensures |
|
730 // that the whole screen is properly redrawn, even if there are backed up |
|
731 // windows. |
|
732 appUi->SetFaded( !faded ); //lint !e730 Intentional |
|
733 appUi->SetFaded( faded );*/ |
|
734 } |
|
735 |
|
736 // ----------------------------------------------------------------------------- |
|
737 // CAknsAppSkinInstance::LookupCreateAndCacheL |
|
738 // (documented in the header). |
|
739 // ----------------------------------------------------------------------------- |
|
740 // |
|
741 CAknsAppSkinInstanceCacheEntry* CAknsAppSkinInstance::LookupCreateAndCacheL( |
|
742 const TAknsItemID& aID, const TAknsItemType aType ) |
|
743 { |
|
744 AKNS_TRACE_INFO3("CAknsAppSkinInstance::LookupCreateAndCacheL %i,%i %i", |
|
745 aID.iMajor,aID.iMinor,aType); |
|
746 CAknsAppSkinInstanceCacheEntry* entry; |
|
747 |
|
748 CAknsItemData* itemData = LookupAndCreateL( aID, aType ); |
|
749 if( !itemData ) |
|
750 { |
|
751 if( aType == EAknsITUnknown ) |
|
752 { |
|
753 // Create an entry for miss only for unknown type |
|
754 entry = new (ELeave) CAknsAppSkinInstanceCacheEntry( aID, NULL ); |
|
755 entry->IncreaseRefCount(); |
|
756 } |
|
757 else |
|
758 { |
|
759 // Do not create an entry for typed miss, otherwise we might hide |
|
760 // a real item |
|
761 delete itemData; |
|
762 return NULL; |
|
763 } |
|
764 } |
|
765 else |
|
766 { |
|
767 CleanupStack::PushL( itemData ); |
|
768 entry = new (ELeave) CAknsAppSkinInstanceCacheEntry( aID, itemData ); |
|
769 CleanupStack::Pop( itemData ); //itemData is now owned by cache entry |
|
770 } |
|
771 |
|
772 entry->IncreaseRefCount(); |
|
773 |
|
774 CleanupStack::PushL( entry ); |
|
775 User::LeaveIfError( iCache.InsertInOrder( entry, |
|
776 CAknsAppSkinInstanceCacheEntry::LinearOrder ) ); |
|
777 CleanupStack::Pop( entry ); |
|
778 |
|
779 if( !itemData ) |
|
780 { |
|
781 // For cache miss, return NULL |
|
782 return NULL; |
|
783 } |
|
784 |
|
785 return entry; |
|
786 } |
|
787 |
|
788 // ----------------------------------------------------------------------------- |
|
789 // CAknsAppSkinInstance::LookupAndCreateL() |
|
790 // (documented in the header). |
|
791 // ----------------------------------------------------------------------------- |
|
792 // |
|
793 CAknsItemData* CAknsAppSkinInstance::LookupAndCreateL( const TAknsItemID& aID, |
|
794 const TAknsItemType aType ) |
|
795 { |
|
796 AKNS_TRACE_INFO3("CAknsAppSkinInstance::LookupAndCreateL %i,%i %i", |
|
797 aID.iMajor,aID.iMinor,aType); |
|
798 CAknsItemDef* itemDef = NULL; |
|
799 |
|
800 // CAknsItemDef is not actually a complex class, and therefore can be |
|
801 // instantiated as stack object without problems. |
|
802 CAknsItemDef itemToFind( aID ); |
|
803 TInt index; |
|
804 |
|
805 // FindInOrder does not store pointer to item, address to stack object |
|
806 // provided intentionally |
|
807 if( iLocalItemDefArray.FindInOrder( &itemToFind, index, |
|
808 CAknsItemDef::LinearOrder ) == KErrNone ) |
|
809 { |
|
810 itemDef = iLocalItemDefArray[ index ]; |
|
811 } |
|
812 |
|
813 if( itemDef ) |
|
814 { |
|
815 if( !AknsUtils::IsDerivedType( aType, itemDef->Type() ) ) |
|
816 { |
|
817 AKNS_TRACE_INFO("CAknsAppSkinInstance::LookupAndCreateL LTYPE MISMATCH"); |
|
818 return NULL; |
|
819 } |
|
820 |
|
821 return AknsItemDataFactory::CreateL( itemDef ); |
|
822 } |
|
823 |
|
824 itemDef = iChunkLookup->LookupAndCreateDefL( aID ); |
|
825 |
|
826 // Do any post-processing that might be needed |
|
827 itemDef = AknsScalabilityUtils::ProcessDefL( itemDef ); |
|
828 |
|
829 if( itemDef ) |
|
830 { |
|
831 CleanupStack::PushL( itemDef ); |
|
832 } |
|
833 else |
|
834 { |
|
835 return NULL; |
|
836 } |
|
837 |
|
838 CAknsItemData* itemData = NULL; |
|
839 if( AknsUtils::IsDerivedType( aType, itemDef->Type() ) ) |
|
840 { |
|
841 itemData = AknsItemDataFactory::CreateL( itemDef ); |
|
842 } |
|
843 else |
|
844 { |
|
845 AKNS_TRACE_INFO("CAknsAppSkinInstance::LookupAndCreateL TYPE MISMATCH"); |
|
846 } |
|
847 |
|
848 CleanupStack::PopAndDestroy( itemDef ); |
|
849 |
|
850 return itemData; |
|
851 } |
|
852 |
|
853 // ----------------------------------------------------------------------------- |
|
854 // CAknsAppSkinInstance::FindFromCache() |
|
855 // (documented in the header). |
|
856 // ----------------------------------------------------------------------------- |
|
857 // |
|
858 CAknsAppSkinInstanceCacheEntry* CAknsAppSkinInstance::FindFromCache( |
|
859 const TAknsItemID& aID ) |
|
860 { |
|
861 CAknsAppSkinInstanceCacheEntry* entry = NULL; |
|
862 TInt index; |
|
863 |
|
864 // CAknsAppSkinInstanceCacheEntry is not a complex object (until data |
|
865 // has been set). It can be instantiated into stack. |
|
866 CAknsAppSkinInstanceCacheEntry entryToFind( aID, NULL ); |
|
867 |
|
868 // FindInOrder does not store pointer to search criteria, address of a stack |
|
869 // object provided intentionally. |
|
870 if( iCache.FindInOrder( &entryToFind, index, |
|
871 CAknsAppSkinInstanceCacheEntry::LinearOrder ) == KErrNone ) |
|
872 { |
|
873 entry = iCache[index]; |
|
874 } |
|
875 |
|
876 return entry; |
|
877 } |
|
878 |
|
879 // ----------------------------------------------------------------------------- |
|
880 // CAknsAppSkinInstance::RemoveAndDestroyFromCache |
|
881 // (documented in the header). |
|
882 // ----------------------------------------------------------------------------- |
|
883 // |
|
884 void CAknsAppSkinInstance::RemoveAndDestroyFromCache( const TAknsItemID& aID ) |
|
885 { |
|
886 AKNS_TRACE_INFO2("CAknsAppSkinInstance::RemoveAndDestroyFromCache %i,%i", |
|
887 aID.iMajor,aID.iMinor); |
|
888 CAknsAppSkinInstanceCacheEntry* entry = NULL; |
|
889 TInt index; |
|
890 |
|
891 CAknsAppSkinInstanceCacheEntry entryToFind( aID, NULL ); |
|
892 |
|
893 if( iCache.FindInOrder( &entryToFind, index, |
|
894 CAknsAppSkinInstanceCacheEntry::LinearOrder ) == KErrNone ) |
|
895 { |
|
896 entry = iCache[index]; |
|
897 iCache.Remove( index ); |
|
898 delete entry; |
|
899 } |
|
900 } |
|
901 |
|
902 // ----------------------------------------------------------------------------- |
|
903 // CAknsAppSkinInstance::HandleClientError |
|
904 // (documented in the header). |
|
905 // ----------------------------------------------------------------------------- |
|
906 // |
|
907 void CAknsAppSkinInstance::HandleClientError( |
|
908 const TAknsClientError aError ) |
|
909 { |
|
910 if( iDebugErrorCallback ) |
|
911 { |
|
912 (*iDebugErrorCallback)( iDebugErrorCallbackParam ); |
|
913 } |
|
914 else |
|
915 { |
|
916 iSession.ClientError( aError ); |
|
917 } |
|
918 } |
|
919 |
|
920 // ----------------------------------------------------------------------------- |
|
921 // CAknsAppSkinInstance::LookupDef |
|
922 // (documented in the header). |
|
923 // ----------------------------------------------------------------------------- |
|
924 // |
|
925 CAknsItemDef* CAknsAppSkinInstance::LookupDef( TBool& aOwnershipTransfer, |
|
926 const TAknsItemID& aID, const TAknsItemType aType ) |
|
927 { |
|
928 AKNS_TRACE_INFO3("CAknsAppSkinInstance::LookupDef %i,%i %i", |
|
929 aID.iMajor,aID.iMinor,aType); |
|
930 |
|
931 CAknsItemDef* itemDef = NULL; |
|
932 aOwnershipTransfer = EFalse; |
|
933 |
|
934 // CAknsItemDef is not actually a complex class, and therefore can be |
|
935 // instantiated as stack object without problems. |
|
936 CAknsItemDef itemToFind( aID ); |
|
937 TInt index; |
|
938 |
|
939 // FindInOrder does not store pointer to item, address to stack object |
|
940 // provided intentionally |
|
941 if( iLocalItemDefArray.FindInOrder( &itemToFind, index, |
|
942 CAknsItemDef::LinearOrder ) == KErrNone ) |
|
943 { |
|
944 itemDef = iLocalItemDefArray[ index ]; |
|
945 } |
|
946 |
|
947 if( itemDef ) |
|
948 { |
|
949 if( !AknsUtils::IsDerivedType( aType, itemDef->Type() ) ) |
|
950 { |
|
951 AKNS_TRACE_INFO("CAknsAppSkinInstance::LookupDef LTYPE MISMATCH"); |
|
952 return NULL; |
|
953 } |
|
954 |
|
955 return itemDef; |
|
956 } |
|
957 |
|
958 TRAP_IGNORE( itemDef = iChunkLookup->LookupAndCreateDefL( aID ) ); |
|
959 |
|
960 if( (!itemDef) || |
|
961 (!AknsUtils::IsDerivedType( aType, itemDef->Type() )) ) |
|
962 { |
|
963 delete itemDef; |
|
964 return NULL; |
|
965 } |
|
966 |
|
967 aOwnershipTransfer = ETrue; |
|
968 return itemDef; |
|
969 } |
|
970 |
|
971 // ----------------------------------------------------------------------------- |
|
972 // CAknsAppSkinInstance::GetTemporaryBitmapL |
|
973 // (documented in the header). |
|
974 // ----------------------------------------------------------------------------- |
|
975 // |
|
976 CAknsTemporaryBitmap* CAknsAppSkinInstance::GetTemporaryBitmapL( |
|
977 const TAknsItemID& aID, const TSize& aSize ) |
|
978 { |
|
979 TInt index( 0 ); |
|
980 CAknsTemporaryBitmap itemToFind( aID, aSize, 0,TSize(0,0) ); |
|
981 if( iTmpBmpArray.FindInOrder( &itemToFind, index, |
|
982 CAknsTemporaryBitmap::LinearOrder ) == KErrNone ) |
|
983 { |
|
984 return iTmpBmpArray[index]; |
|
985 } |
|
986 |
|
987 CAknsBitmapItemData* bmpData = static_cast<CAknsBitmapItemData*>( |
|
988 GetCachedItemData( aID, EAknsITBitmap ) ); |
|
989 if( !bmpData ) |
|
990 { |
|
991 return NULL; |
|
992 } |
|
993 |
|
994 CFbsBitmap* bitmap = bmpData->Bitmap(); |
|
995 CFbsBitmap* mask = NULL; |
|
996 if( AknsUtils::IsDerivedType( EAknsITMaskedBitmap, |
|
997 bmpData->Type() ) ) |
|
998 { |
|
999 mask = static_cast<CAknsMaskedBitmapItemData*>(bmpData)->Mask(); |
|
1000 } |
|
1001 |
|
1002 CAknsTemporaryBitmap* tmpBmp = CAknsTemporaryBitmap::NewL( |
|
1003 aID, aSize, 0, EFalse, TSize(0,0) ); |
|
1004 CleanupStack::PushL( tmpBmp ); |
|
1005 |
|
1006 if( bitmap ) |
|
1007 { |
|
1008 tmpBmp->ActivateGcL( bitmap->DisplayMode(), EFalse )-> |
|
1009 DrawBitmap( TRect( TPoint(0,0), aSize ), bitmap ); |
|
1010 tmpBmp->ReleaseGc(); |
|
1011 } |
|
1012 if( mask ) |
|
1013 { |
|
1014 tmpBmp->ActivateGcL( mask->DisplayMode(), ETrue )-> |
|
1015 DrawBitmap( TRect( TPoint(0,0), aSize ), mask ); |
|
1016 tmpBmp->ReleaseGc(); |
|
1017 } |
|
1018 |
|
1019 User::LeaveIfError( |
|
1020 iTmpBmpArray.InsertInOrder( tmpBmp, |
|
1021 CAknsTemporaryBitmap::LinearOrder ) ); |
|
1022 CleanupStack::Pop( tmpBmp ); |
|
1023 |
|
1024 return tmpBmp; |
|
1025 } |
|
1026 |
|
1027 // ----------------------------------------------------------------------------- |
|
1028 // CAknsAppSkinInstance::DefaultRenderer |
|
1029 // (documented in the header). |
|
1030 // ----------------------------------------------------------------------------- |
|
1031 // |
|
1032 MAknsRlRenderer* CAknsAppSkinInstance::DefaultRenderer() |
|
1033 { |
|
1034 return iRenderer; |
|
1035 } |
|
1036 |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // CAknsAppSkinInstance::MasterLayout |
|
1039 // (documented in the header). |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // |
|
1042 CAknsRlMasterLayout* CAknsAppSkinInstance::MasterLayout() |
|
1043 { |
|
1044 return iMasterLayout; |
|
1045 } |
|
1046 |
|
1047 // ----------------------------------------------------------------------------- |
|
1048 // CAknsAppSkinInstance::UpdateLocalLayoutBitmapToServer |
|
1049 // (documented in the header). |
|
1050 // ----------------------------------------------------------------------------- |
|
1051 // |
|
1052 void CAknsAppSkinInstance::UpdateLocalLayoutBitmapToServerL( |
|
1053 const TAknsItemID& aID, const TInt aLayout, const TSize& aLayoutSize, |
|
1054 CFbsBitmap* aBitmap, CFbsBitmap* aMask, const TBool aMorphing ) |
|
1055 { |
|
1056 TInt storeErr = iSession.StoreScalableGraphics( aID, aLayout, aLayoutSize, |
|
1057 aBitmap, aMask, aMorphing ); |
|
1058 if( storeErr ) |
|
1059 { |
|
1060 AKNS_TRACE_ERROR1("CAknsAppSkinInstance::ULLBTS Srv store failed %i", storeErr ); |
|
1061 User::Leave( storeErr ); |
|
1062 } |
|
1063 } |
|
1064 |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // CAknsAppSkinInstance::UpdateLocalLayoutBitmapFromServer |
|
1067 // (documented in the header). |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // |
|
1070 void CAknsAppSkinInstance::UpdateLocalLayoutBitmapFromServerL( |
|
1071 const TAknsItemID& aID, const TInt aLayout, const TSize& aLayoutSize ) |
|
1072 { |
|
1073 // Ensure space for 2 items |
|
1074 CleanupStack::PushL(static_cast<TAny*>(NULL)); |
|
1075 CleanupStack::PushL(static_cast<TAny*>(NULL)); |
|
1076 CleanupStack::Pop(2); |
|
1077 |
|
1078 CAknsTemporaryBitmap* tmpBmp = NULL; |
|
1079 CAknsTemporaryBitmap itemToFind( aID, TSize(0,0), aLayout, aLayoutSize ); |
|
1080 TInt index = iLayoutBmpArray.FindInOrder( &itemToFind, |
|
1081 CAknsTemporaryBitmap::LinearOrder ); |
|
1082 if( index>=0 ) |
|
1083 { |
|
1084 tmpBmp = iLayoutBmpArray[index]; |
|
1085 } |
|
1086 |
|
1087 if (tmpBmp && tmpBmp->ItemData()->ParentIID() != KAknsIIDNone) |
|
1088 { |
|
1089 // Draw from parent, nothing can be found from the server... |
|
1090 return; |
|
1091 } |
|
1092 |
|
1093 CFbsBitmap* bitmap = NULL; |
|
1094 CFbsBitmap* mask = NULL; |
|
1095 TBool morphing( EFalse ); |
|
1096 if( tmpBmp ) |
|
1097 { |
|
1098 // Detach, ownership is transferred in lookup |
|
1099 bitmap = tmpBmp->ItemData()->Bitmap(); |
|
1100 tmpBmp->ItemData()->SetBitmap(NULL); |
|
1101 mask = tmpBmp->ItemData()->Mask(); |
|
1102 tmpBmp->ItemData()->SetMask(NULL); |
|
1103 } |
|
1104 // @TODO Morphing property must be fetched from the chunk as well! |
|
1105 iChunkLookup->LookupAndCreateScalableItemL( aID, aLayout, |
|
1106 aLayoutSize, bitmap, mask, morphing ); |
|
1107 // These pushes are safe |
|
1108 CleanupStack::PushL(bitmap); // (1) |
|
1109 CleanupStack::PushL(mask); // (2) |
|
1110 |
|
1111 if( !bitmap ) |
|
1112 { |
|
1113 // Server-side item does not exist |
|
1114 // Must leave to remove the item! |
|
1115 User::Leave( KErrNotFound ); |
|
1116 } |
|
1117 |
|
1118 // Create, if local item does not exist yet |
|
1119 if( !tmpBmp ) |
|
1120 { |
|
1121 tmpBmp = CAknsTemporaryBitmap::NewL( |
|
1122 aID, TSize(0,0), aLayout, morphing, aLayoutSize ); |
|
1123 CleanupStack::PushL( tmpBmp ); // (3) |
|
1124 User::LeaveIfError( |
|
1125 iLayoutBmpArray.InsertInOrder( tmpBmp, |
|
1126 CAknsTemporaryBitmap::LinearOrder ) ); |
|
1127 CleanupStack::Pop( tmpBmp ); // (2) |
|
1128 index = iLayoutBmpArray.FindInOrder( &itemToFind, |
|
1129 CAknsTemporaryBitmap::LinearOrder ); |
|
1130 if( index == KErrNotFound ) |
|
1131 { |
|
1132 AKNS_TRACE_ERROR("CAknsAppSkinInstance::ULLBFS Local data item vanished!"); |
|
1133 User::Leave( KErrUnknown ); |
|
1134 } |
|
1135 } |
|
1136 |
|
1137 tmpBmp->ItemData()->SetType( EAknsITMaskedBitmap ); |
|
1138 // Ownership is transferred |
|
1139 tmpBmp->ItemData()->DestroyAndSetBitmap( bitmap ); |
|
1140 tmpBmp->ItemData()->DestroyAndSetMask( mask ); |
|
1141 CleanupStack::Pop(2); // mask, bitmap (0) |
|
1142 |
|
1143 if( !mask ) |
|
1144 { |
|
1145 tmpBmp->ItemData()->SetType( EAknsITBitmap ); |
|
1146 } |
|
1147 |
|
1148 TAknsImageAttributeData attributes; |
|
1149 // Disable backward compatibility, size should be already correct |
|
1150 attributes.iAttributes = EAknsImageAttributeNBC; |
|
1151 tmpBmp->ItemData()->SetAttributesL( attributes ); |
|
1152 } |
|
1153 |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // CAknsAppSkinInstance::AddLayoutBitmapL |
|
1156 // (documented in the header). |
|
1157 // ----------------------------------------------------------------------------- |
|
1158 // |
|
1159 void CAknsAppSkinInstance::AddLayoutBitmapL( const TAknsItemID& aID, |
|
1160 CAknsMaskedBitmapItemData* aData, const TInt aLayout, |
|
1161 const TSize& aLayoutSize, const TBool aMorphing, const TBool aLocalItem ) |
|
1162 { |
|
1163 TBool store = ETrue; |
|
1164 CleanupStack::PushL( aData ); |
|
1165 |
|
1166 CAknsTemporaryBitmap* tmpBmp = CAknsTemporaryBitmap::NewL( |
|
1167 aID, TSize(0,0), aLayout, aMorphing, aLayoutSize ); |
|
1168 CleanupStack::PushL( tmpBmp ); |
|
1169 |
|
1170 // Set and detach |
|
1171 tmpBmp->ItemData()->DestroyAndSetBitmap( aData->Bitmap() ); |
|
1172 aData->SetBitmap( NULL ); |
|
1173 tmpBmp->ItemData()->DestroyAndSetMask( aData->Mask() ); |
|
1174 aData->SetMask( NULL ); |
|
1175 |
|
1176 // If there is no mask, change type to bitmap |
|
1177 if( !tmpBmp->Mask() ) |
|
1178 { |
|
1179 tmpBmp->ItemData()->SetType( EAknsITBitmap ); |
|
1180 } |
|
1181 |
|
1182 if (aData->ParentIID() != KAknsIIDNone) |
|
1183 { |
|
1184 store = EFalse; |
|
1185 tmpBmp->ItemData()->SetParentIID(aData->ParentIID()); |
|
1186 tmpBmp->ItemData()->SetDrawRect(aData->DrawRect()); |
|
1187 } |
|
1188 |
|
1189 // Attributes |
|
1190 if( aData->Attributes() ) |
|
1191 { |
|
1192 tmpBmp->ItemData()->SetAttributesL( *aData->Attributes() ); |
|
1193 } |
|
1194 |
|
1195 User::LeaveIfError( |
|
1196 iLayoutBmpArray.InsertInOrder( tmpBmp, |
|
1197 CAknsTemporaryBitmap::LinearOrder ) ); |
|
1198 CleanupStack::Pop( tmpBmp ); |
|
1199 |
|
1200 CleanupStack::PopAndDestroy( aData ); |
|
1201 if (store && !aLocalItem) |
|
1202 { |
|
1203 UpdateLocalLayoutBitmapToServerL( aID, aLayout, aLayoutSize, |
|
1204 tmpBmp->ItemData()->Bitmap(), tmpBmp->ItemData()->Mask(), |
|
1205 aMorphing ); |
|
1206 } |
|
1207 } |
|
1208 |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // CAknsAppSkinInstance::GetLayoutBitmap |
|
1211 // (documented in the header). |
|
1212 // ----------------------------------------------------------------------------- |
|
1213 // |
|
1214 CAknsImageItemData* CAknsAppSkinInstance::GetLayoutBitmap( |
|
1215 const TAknsItemID& aID, const TSize& aLayoutSize, const TInt aLayout, TBool& aMorphingOut, const TBool& aLocalItem ) |
|
1216 { |
|
1217 aMorphingOut = EFalse; |
|
1218 |
|
1219 TInt updateErr( KErrNone ); |
|
1220 // Postpone error handling |
|
1221 if (!aLocalItem) |
|
1222 { |
|
1223 TRAP( updateErr, |
|
1224 UpdateLocalLayoutBitmapFromServerL( aID, aLayout, aLayoutSize ) ); |
|
1225 |
|
1226 #if defined(_DEBUG) |
|
1227 if( updateErr ) |
|
1228 { |
|
1229 AKNS_TRACE_INFO1("CAknsAppSkinInstance::GetLayoutBitmap Srv update failed %i", updateErr ); |
|
1230 } |
|
1231 #endif |
|
1232 } |
|
1233 TInt index( 0 ); |
|
1234 CAknsTemporaryBitmap itemToFind( aID, TSize(0,0), aLayout, aLayoutSize ); |
|
1235 if( iLayoutBmpArray.FindInOrder( &itemToFind, index, |
|
1236 CAknsTemporaryBitmap::LinearOrder ) != KErrNone ) |
|
1237 { |
|
1238 // No local data instance found, return NULL regardless of updateErr |
|
1239 return NULL; |
|
1240 } |
|
1241 |
|
1242 CAknsTemporaryBitmap* entry = iLayoutBmpArray[index]; |
|
1243 |
|
1244 if( updateErr && entry->ItemData()->ParentIID() == KAknsIIDNone) |
|
1245 { |
|
1246 // Entry must be removed and destroyed if update failed |
|
1247 AKNS_TRACE_ERROR2("CAknsAppSkinInstance::GetLayoutBitmap Removing %x %x for update failure", aID.iMajor, aID.iMinor ); |
|
1248 iLayoutBmpArray.Remove(index); |
|
1249 delete entry; |
|
1250 return NULL; |
|
1251 } |
|
1252 |
|
1253 aMorphingOut = entry->IsMorphing(); |
|
1254 return entry->ItemData(); |
|
1255 } |
|
1256 |
|
1257 // ----------------------------------------------------------------------------- |
|
1258 // CAknsAppSkinInstance::BeginRender |
|
1259 // (documented in the header). |
|
1260 // ----------------------------------------------------------------------------- |
|
1261 // |
|
1262 void CAknsAppSkinInstance::BeginRender() |
|
1263 { |
|
1264 iChunkLookup->BeginRender(); |
|
1265 } |
|
1266 |
|
1267 // ----------------------------------------------------------------------------- |
|
1268 // CAknsAppSkinInstance::EndRender |
|
1269 // (documented in the header). |
|
1270 // ----------------------------------------------------------------------------- |
|
1271 // |
|
1272 void CAknsAppSkinInstance::EndRender() |
|
1273 { |
|
1274 iChunkLookup->EndRender(); |
|
1275 } |
|
1276 |
|
1277 // ----------------------------------------------------------------------------- |
|
1278 // CAknsAppSkinInstance::IsUpdateInProgress |
|
1279 // (documented in the header). |
|
1280 // ----------------------------------------------------------------------------- |
|
1281 // |
|
1282 TBool CAknsAppSkinInstance::IsUpdateInProgress() |
|
1283 { |
|
1284 return iUpdateInProgress; |
|
1285 } |
|
1286 |
|
1287 // ----------------------------------------------------------------------------- |
|
1288 // CAknsAppSkinInstance::VariantHighlightAnimationEnabled |
|
1289 // (documented in the header). |
|
1290 // ----------------------------------------------------------------------------- |
|
1291 // |
|
1292 TBool CAknsAppSkinInstance::VariantHighlightAnimationEnabled() |
|
1293 { |
|
1294 return iVariantHlAnimStatus; |
|
1295 } |
|
1296 |
|
1297 // ----------------------------------------------------------------------------- |
|
1298 // CAknsAppSkinInstance::IsIconConfiguredL |
|
1299 // (documented in the header). |
|
1300 // ----------------------------------------------------------------------------- |
|
1301 // |
|
1302 TBool CAknsAppSkinInstance::IsIconConfiguredL( TUid aAppUid ) |
|
1303 { |
|
1304 if ( iAppConfigurationCenrepNotUsed ) |
|
1305 { |
|
1306 return EFalse; |
|
1307 } |
|
1308 TInt ret = iSession.CheckIconConfiguration( aAppUid ); |
|
1309 // Error codes mean: |
|
1310 // KErrNotFound - no cenrep file in the device. |
|
1311 // KErrAlreadyExists - there is double definition of some key in the cenrep file. |
|
1312 if ( ret == KErrNotFound || ret == KErrAlreadyExists ) |
|
1313 { |
|
1314 iAppConfigurationCenrepNotUsed = ETrue; |
|
1315 } |
|
1316 if ( ret > 0 ) |
|
1317 { |
|
1318 return ETrue; |
|
1319 } |
|
1320 return EFalse; |
|
1321 } |
|
1322 |
|
1323 // End of File |