|
1 /* |
|
2 * Copyright (c) 2002-2007 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 #ifndef AKNSAPPSKININSTANCE_H |
|
22 #define AKNSAPPSKININSTANCE_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <coemain.h> |
|
26 |
|
27 #include <AknsSkinInstance.h> |
|
28 #include <AknsSrvClient.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CAknsAppSkinInstanceCacheEntry; |
|
32 class CAknsTemporaryBitmap; |
|
33 class MAknsRlRenderer; |
|
34 class CAknsRlDefaultRenderer; |
|
35 class CAknsRlMasterLayout; |
|
36 class RApaLsSession; |
|
37 |
|
38 // DATA TYPES |
|
39 |
|
40 /** |
|
41 * Simple pointer array data type for item definitions. |
|
42 * |
|
43 * @internal |
|
44 */ |
|
45 typedef RPointerArray<CAknsItemDef> RAknsItemDefPointerArray; |
|
46 |
|
47 /** |
|
48 * Control position list entry. |
|
49 * |
|
50 * @internal |
|
51 */ |
|
52 struct TAknsControlPositionEntry |
|
53 { |
|
54 TUint iKey; |
|
55 TPoint iScreenPos; |
|
56 }; |
|
57 |
|
58 /** |
|
59 * Pointer store list entry. |
|
60 * |
|
61 * @internal |
|
62 */ |
|
63 struct TAknsPointerStoreEntry |
|
64 { |
|
65 TUint iKey; |
|
66 TAny* iValue; |
|
67 }; |
|
68 |
|
69 /** |
|
70 * Simple pointer array data type for cache entries. |
|
71 * |
|
72 * @internal |
|
73 */ |
|
74 typedef RPointerArray<CAknsAppSkinInstanceCacheEntry> |
|
75 RAknsAppSkinInstanceCacheEntryPointerArray; |
|
76 |
|
77 /** |
|
78 * Simple pointer array data type for temporary bitmap entries. |
|
79 * |
|
80 * @since 2.6 |
|
81 * |
|
82 * @internal |
|
83 */ |
|
84 typedef RPointerArray<CAknsTemporaryBitmap> |
|
85 RAknsAppSkinInstanceTemporaryBitmapArray; |
|
86 |
|
87 // CLASS DECLARATION |
|
88 |
|
89 /** |
|
90 * Concrete application skin instance. |
|
91 * Application skin instance is a thread-singleton class that implements |
|
92 * MAknsSkinInstance (and also MAknsDataContext to provide root data |
|
93 * context). |
|
94 * |
|
95 * This is an internal class that contains no exported functions. |
|
96 * The class is not intended for derivation outside the library. |
|
97 * |
|
98 * @since 2.0 |
|
99 * |
|
100 * @internal |
|
101 */ |
|
102 NONSHARABLE_CLASS(CAknsAppSkinInstance) : |
|
103 public CCoeStatic, public MAknsSkinInstance, public MAknsDataContext, |
|
104 public MAknsSkinChangeObserver |
|
105 { |
|
106 protected: // Protected constructor |
|
107 |
|
108 /** |
|
109 * C++ default constructor. |
|
110 * |
|
111 * @internal |
|
112 */ |
|
113 CAknsAppSkinInstance(); |
|
114 |
|
115 public: // Constructors and destructors |
|
116 |
|
117 /** |
|
118 * Creates application skin instance singleton. |
|
119 * |
|
120 * @par Exceptions: |
|
121 * If construction fails, leaves with an error code. |
|
122 * |
|
123 * @internal |
|
124 */ |
|
125 static void CreateSingletonL(); |
|
126 |
|
127 /** |
|
128 * Destructor. |
|
129 * |
|
130 * @internal |
|
131 */ |
|
132 virtual ~CAknsAppSkinInstance(); |
|
133 |
|
134 public: // Functions from MAknsSkinInstance - Item data |
|
135 |
|
136 /** |
|
137 * @copydoc MAknsSkinInstance::RootDataContext() |
|
138 */ |
|
139 MAknsDataContext* RootDataContext(); |
|
140 |
|
141 /** |
|
142 * @copydoc MAknsSkinInstance::GetCachedItemData(TAknsItemID,TAknsItemType) |
|
143 */ |
|
144 CAknsItemData* GetCachedItemData( const TAknsItemID& aID, |
|
145 const TAknsItemType aType ); |
|
146 |
|
147 /** |
|
148 * @copydoc MAknsSkinInstance::GetCachedItemData(TAknsItemID) |
|
149 */ |
|
150 CAknsItemData* GetCachedItemData( const TAknsItemID& aID ); |
|
151 |
|
152 /** |
|
153 * @copydoc MAknsSkinInstance::CreateUncachedItemDataL(TAknsItemID,TAknsItemType) |
|
154 */ |
|
155 CAknsItemData* CreateUncachedItemDataL( const TAknsItemID& aID, |
|
156 const TAknsItemType aType ); |
|
157 |
|
158 /** |
|
159 * @copydoc MAknsSkinInstance::CreateUncachedItemDataL(TAknsItemID) |
|
160 */ |
|
161 CAknsItemData* CreateUncachedItemDataL( const TAknsItemID& aID ); |
|
162 |
|
163 public: // Functions from MAknsSkinInstance - Item definitions |
|
164 |
|
165 /** |
|
166 * @copydoc MAknsSkinInstance::SetLocalItemDefL() |
|
167 */ |
|
168 void SetLocalItemDefL( CAknsItemDef* aDef ); |
|
169 |
|
170 /** |
|
171 * @copydoc MAknsSkinInstance::SetChangeEventsEnabled() |
|
172 */ |
|
173 void SetChangeEventsEnabled( TBool aEnabled ); |
|
174 |
|
175 public: // Functions from MAknsSkinInstance - Error handling |
|
176 |
|
177 /** |
|
178 * @copydoc MAknsSkinInstance::NotifyClientError(); |
|
179 */ |
|
180 void NotifyClientError( const TAknsClientError aError ); |
|
181 |
|
182 public: // Functions fro MAknsSkinInstance - Querying the change reason |
|
183 /** |
|
184 * @copydoc MAknsSkinInstance::SkinChangeReason() |
|
185 */ |
|
186 TAknsSkinChangeReason SkinChangeReason(); |
|
187 |
|
188 public: // Functions fro MAknsSkinInstance - removing local item defs |
|
189 /** |
|
190 * @copydoc MAknsSkinInstance::RemoveLocalItemDefs() |
|
191 */ |
|
192 void RemoveLocalItemDefs(); |
|
193 |
|
194 public: // Functions from MAknsDataContext |
|
195 |
|
196 /** |
|
197 * @copydoc MAknsDataContext::ReserveItemL() |
|
198 */ |
|
199 void ReserveItemL( const TAknsItemID& aID ); |
|
200 |
|
201 /** |
|
202 * @copydoc MAknsDataContext::ReleaseItem() |
|
203 */ |
|
204 void ReleaseItem( const TAknsItemID& aID ); |
|
205 |
|
206 public: // Functions from MAknsSkinChangeObserver |
|
207 |
|
208 void FlushLocalCaches(); |
|
209 /** |
|
210 * @copydoc MAknsSkinChangeObserver::SkinContentChanged() |
|
211 */ |
|
212 void SkinContentChanged(); |
|
213 |
|
214 /** |
|
215 * @copydoc MAknsSkinChangeObserver::SkinConfigurationChanged() |
|
216 */ |
|
217 void SkinConfigurationChanged( |
|
218 const TAknsSkinStatusConfigurationChangeReason aReason ); |
|
219 |
|
220 /** |
|
221 * @copydoc MAknsSkinChangeObserver::SkinPackageChanged() |
|
222 */ |
|
223 void SkinPackageChanged( |
|
224 const TAknsSkinStatusPackageChangeReason aReason ); |
|
225 |
|
226 public: // New functions - Testing |
|
227 |
|
228 /** |
|
229 * Returns the current count of local item definition list. |
|
230 */ |
|
231 IMPORT_C TInt DebugLocalItemDefCount(); |
|
232 |
|
233 /** |
|
234 * Returns the current count of item data cache. |
|
235 */ |
|
236 IMPORT_C TInt DebugCacheCount(); |
|
237 |
|
238 /** |
|
239 * Disables server error notification and registers observer. |
|
240 */ |
|
241 IMPORT_C void DebugHookClientErrors( void (*aCallback)(TAny*), TAny* aParam ); |
|
242 |
|
243 /** |
|
244 * Disables change notification and registers observer. |
|
245 */ |
|
246 IMPORT_C void DebugHookChangeNotifications( void (*aCallback)(TAny*), TAny* aParam ); |
|
247 |
|
248 /** |
|
249 * Resets the internal state. |
|
250 */ |
|
251 IMPORT_C void DebugReset(); |
|
252 |
|
253 protected: // New functions |
|
254 |
|
255 /** |
|
256 * Updates cached item. |
|
257 * This method should be called when an item definition changes. |
|
258 * If item data (for the specified IID) is in the ASI cache, |
|
259 * it is reconstructed. Type of the new item definition must |
|
260 * match the existing cached item, if one exists. |
|
261 * |
|
262 * @param aCacheEntry Cache entry to be updated. |
|
263 * |
|
264 * @param aRemoveIfNotFound Boolean flag to indicate whether |
|
265 * the cache item should be removed if no new definition is found. |
|
266 * |
|
267 * @par Exceptions: |
|
268 * If item data creation fails, leaves with an error code. |
|
269 * Cached item (if any) is automatically destroyed. |
|
270 * |
|
271 * @internal |
|
272 */ |
|
273 void UpdateCachedItemL( CAknsAppSkinInstanceCacheEntry* aCacheEntry, |
|
274 const TBool aRemoveIfNotFound ); |
|
275 |
|
276 /** |
|
277 * Notifies the application that an item definition has changed. |
|
278 * Sends skin resource change event to the window group of the |
|
279 * current application. Also redraws the screen (if there are items |
|
280 * in cache) to enable controls |
|
281 * that use cached items to update their appearance. |
|
282 * |
|
283 * @internal |
|
284 */ |
|
285 void NotifyItemDefChange(TBool aFgOnly = EFalse); |
|
286 |
|
287 /** |
|
288 * Redraws the screen. |
|
289 * |
|
290 * @internal |
|
291 */ |
|
292 void RedrawScreen() const; |
|
293 |
|
294 /** |
|
295 * Finds item definition for specified item, creates item data for |
|
296 * it and inserts it into the cache. |
|
297 * |
|
298 * @param aID Item ID to be cached. |
|
299 * @param aType Type of the item. EAknsITUnknown if any type is |
|
300 * acceptable. |
|
301 * |
|
302 * @return Pointer to cache entry. Application skin instance still |
|
303 * owns the cache entry object and controls its lifetime. |
|
304 * @c NULL value is returned if no item definition is found. |
|
305 * |
|
306 * @par Exceptions: |
|
307 * If creation fails, leaves with an error code. |
|
308 * |
|
309 * @internal |
|
310 */ |
|
311 CAknsAppSkinInstanceCacheEntry* LookupCreateAndCacheL( |
|
312 const TAknsItemID& aID, const TAknsItemType aType ); |
|
313 |
|
314 /** |
|
315 * Finds item definition for specified item and creates an independent |
|
316 * item data for it. |
|
317 * |
|
318 * @param aID Item ID matching the item data to be created. |
|
319 * @param aType Type of the item. EAknsITUnknown if any type is |
|
320 * acceptable. |
|
321 * |
|
322 * @return Newly created item data instance for the specified item. |
|
323 * Ownership of the item data is transferred to the caller. |
|
324 * @c NULL value is returned if no item definition is found. |
|
325 * |
|
326 * @par Exceptions: |
|
327 * If creation fails, leaves with an error code. |
|
328 * |
|
329 * @internal |
|
330 */ |
|
331 CAknsItemData* LookupAndCreateL( const TAknsItemID& aID, |
|
332 const TAknsItemType aType ); |
|
333 |
|
334 /** |
|
335 * Finds specified item from cache. |
|
336 * |
|
337 * @param aID Item ID to be found. |
|
338 * |
|
339 * @return Pointer to cache entry or @c NULL if none found. |
|
340 * Application skin instance still owns the cache entry and controls |
|
341 * its lifetime. |
|
342 * |
|
343 * @internal |
|
344 */ |
|
345 CAknsAppSkinInstanceCacheEntry* FindFromCache( const TAknsItemID& aID ); |
|
346 |
|
347 /** |
|
348 * Removes specified item from cache and destroys it. |
|
349 * |
|
350 * @param aID Item ID to be removed and destroyed. |
|
351 * |
|
352 * @internal |
|
353 */ |
|
354 void RemoveAndDestroyFromCache( const TAknsItemID& aID ); |
|
355 |
|
356 /** |
|
357 * Handles the client error condition. |
|
358 * |
|
359 * @param aError Type of the error. |
|
360 * |
|
361 * @internal |
|
362 */ |
|
363 void HandleClientError( const TAknsClientError aError ); |
|
364 |
|
365 /** |
|
366 * Finds the specified item definition, but does not construct the |
|
367 * item data object. |
|
368 * |
|
369 * @since 2.1 |
|
370 * |
|
371 * @param aOwnershipTransfer Output parameter that is assigned to |
|
372 * ETrue if the caller should destroy the returned definition |
|
373 * object. |
|
374 * |
|
375 * @param aID Item ID of the item definition to be retrieved. |
|
376 * |
|
377 * @param aType Type (or base type) of the item definition to be |
|
378 * retrieved. |
|
379 * |
|
380 * @return Pointer to the item definition object or @c NULL if |
|
381 * not found. The caller must observe aOwnershipTransfer |
|
382 * value to determine whether the object should be destroyed. |
|
383 * |
|
384 * @internal |
|
385 */ |
|
386 CAknsItemDef* LookupDef( TBool& aOwnershipTransfer, |
|
387 const TAknsItemID& aID, const TAknsItemType aType ); |
|
388 |
|
389 /** |
|
390 * |
|
391 * @since 2.8 |
|
392 * |
|
393 * @internal |
|
394 */ |
|
395 void UpdateLocalLayoutBitmapToServerL( const TAknsItemID& aID, |
|
396 const TInt aLayout, const TSize& aLayoutSize, CFbsBitmap* aBitmap, |
|
397 CFbsBitmap* aMask, const TBool aMorphing ); |
|
398 |
|
399 /** |
|
400 * |
|
401 * @since 2.8 |
|
402 * |
|
403 * @internal |
|
404 */ |
|
405 void UpdateLocalLayoutBitmapFromServerL( const TAknsItemID& aID, |
|
406 const TInt aLayout, const TSize& aLayoutSize ); |
|
407 |
|
408 public: // New methods |
|
409 |
|
410 /** |
|
411 * Retrieves (and creates if necessary) a temporary bitmap |
|
412 * for the given item ID and given size. |
|
413 * |
|
414 * @since 2.6 |
|
415 * |
|
416 * @internal |
|
417 */ |
|
418 CAknsTemporaryBitmap* GetTemporaryBitmapL( |
|
419 const TAknsItemID& aID, const TSize& aSize ); |
|
420 |
|
421 /** |
|
422 * Retrieves a non-owned pointer to the renderer. |
|
423 * |
|
424 * @since 2.8 |
|
425 * |
|
426 * @internal |
|
427 */ |
|
428 MAknsRlRenderer* DefaultRenderer(); |
|
429 |
|
430 /** |
|
431 * Retrieves a non-owned pointer to the master layout. |
|
432 * |
|
433 * @since 2.8 |
|
434 * |
|
435 * @internal |
|
436 */ |
|
437 CAknsRlMasterLayout* MasterLayout(); |
|
438 |
|
439 /** |
|
440 * Adds a layout bitmap, ownership transferred. |
|
441 * |
|
442 * @since 2.8 |
|
443 * |
|
444 * @internal |
|
445 */ |
|
446 void AddLayoutBitmapL( |
|
447 const TAknsItemID& aID, CAknsMaskedBitmapItemData* aData, |
|
448 const TInt aLayout, const TSize& aLayoutSize, |
|
449 const TBool aMorphing, const TBool aLocalItem ); |
|
450 |
|
451 /** |
|
452 * Retrieves a layout bitmap, ownership not transferred. |
|
453 * |
|
454 * @since 2.8 |
|
455 * |
|
456 * @internal |
|
457 */ |
|
458 CAknsImageItemData* GetLayoutBitmap( const TAknsItemID& aID, |
|
459 const TSize& aLayoutSize, const TInt aLayout, TBool& aMorphingOut, const TBool& aLocalItem ); |
|
460 |
|
461 /** |
|
462 * Begins rendering. EndRender must be called to free the mutex |
|
463 * after rendering completes. |
|
464 * |
|
465 * @since 2.8 |
|
466 * |
|
467 * @internal |
|
468 */ |
|
469 void BeginRender(); |
|
470 |
|
471 /** |
|
472 * Ends rendering. BeginRender must have been called, otherwise |
|
473 * the mutex state will be corrupted. |
|
474 * |
|
475 * @since 2.8 |
|
476 * |
|
477 * @internal |
|
478 */ |
|
479 void EndRender(); |
|
480 |
|
481 /** |
|
482 * From base class MAknsSkinChangeObserver. |
|
483 * @copydoc MAknsSkinChangeObserver::IsUpdateInProgress() |
|
484 */ |
|
485 TBool IsUpdateInProgress(); |
|
486 |
|
487 /** |
|
488 * The product variant status of highlight animation. |
|
489 * |
|
490 * @return ETrue if product supports highlight animations, EFalse if |
|
491 * highlight animations should not be used. |
|
492 * @since 3.1 |
|
493 * @internal |
|
494 */ |
|
495 TBool VariantHighlightAnimationEnabled(); |
|
496 |
|
497 /** |
|
498 * Checks if the given AppUid icon has been configured with AppArc cenrep configuration file. |
|
499 * @param aAppUid application UID to check |
|
500 * @return ETrue if the icon is configured with the cenrep file, otherwise EFalse. |
|
501 */ |
|
502 TBool IsIconConfiguredL( TUid aAppUid ); |
|
503 |
|
504 /** |
|
505 * Get Current Animation Backgournd State. |
|
506 * @return ETrue if the Animation Backgournd is ON, otherwise EFalse. |
|
507 */ |
|
508 TBool AnimBackgroundState( ) const; |
|
509 |
|
510 /** |
|
511 * Get if wallpaper defined. |
|
512 * @return if wallpaper defined. |
|
513 */ |
|
514 TBool WallpaperDefined( ) const; |
|
515 |
|
516 private: // Private ConstructL |
|
517 |
|
518 /** |
|
519 * By default Symbian OS constructor is private. |
|
520 */ |
|
521 void ConstructL(); |
|
522 |
|
523 /** |
|
524 * Read Animation Backgournd State |
|
525 */ |
|
526 void InitAnimBackgroundL( ); |
|
527 |
|
528 /** |
|
529 * Read Psln Cenrep |
|
530 */ |
|
531 void InitPslnCenrepL( TBool aOnlyWP = EFalse ); |
|
532 |
|
533 protected: // Data |
|
534 |
|
535 /** |
|
536 * Local item definition array. |
|
537 */ |
|
538 RAknsItemDefPointerArray iLocalItemDefArray; |
|
539 |
|
540 /** |
|
541 * Cache entry array. |
|
542 */ |
|
543 RAknsAppSkinInstanceCacheEntryPointerArray iCache; |
|
544 |
|
545 /** |
|
546 * Flag indicating whether change events are enabled. |
|
547 */ |
|
548 TBool iChangeEventsEnabled; |
|
549 |
|
550 /** |
|
551 * Flag indicating whether there is a pending change event. |
|
552 */ |
|
553 TBool iChangeEventPending; |
|
554 |
|
555 /** |
|
556 * Skin server session. |
|
557 */ |
|
558 RAknsSrvSession iSession; |
|
559 |
|
560 /** |
|
561 * Internal control position list used by AknsUtils. |
|
562 */ |
|
563 RArray<TAknsControlPositionEntry> iControlPositionList; |
|
564 |
|
565 /** |
|
566 * Internal pointer store used by AknsUtils. |
|
567 */ |
|
568 RArray<TAknsPointerStoreEntry> iPointerStoreList; |
|
569 |
|
570 /** |
|
571 * Chunk lookup instance. |
|
572 */ |
|
573 CAknsSrvChunkLookup* iChunkLookup; |
|
574 |
|
575 /** |
|
576 * Temporary bitmap array. |
|
577 */ |
|
578 RAknsAppSkinInstanceTemporaryBitmapArray iTmpBmpArray; |
|
579 |
|
580 /** |
|
581 * Default renderer instance. |
|
582 */ |
|
583 CAknsRlDefaultRenderer* iRenderer; |
|
584 |
|
585 /** |
|
586 * Master layout instance. |
|
587 */ |
|
588 CAknsRlMasterLayout* iMasterLayout; |
|
589 |
|
590 /** |
|
591 * Layout bitmap array. |
|
592 */ |
|
593 RAknsAppSkinInstanceTemporaryBitmapArray iLayoutBmpArray; |
|
594 |
|
595 /** |
|
596 * Update status |
|
597 */ |
|
598 TBool iUpdateInProgress; |
|
599 |
|
600 /** |
|
601 * Product variant enable/disable status for highlight animations. |
|
602 */ |
|
603 TBool iVariantHlAnimStatus; |
|
604 |
|
605 /** |
|
606 * Cached AppArc server session |
|
607 */ |
|
608 RApaLsSession* iCachedApaSession; |
|
609 |
|
610 /** |
|
611 * The last skin change reason |
|
612 */ |
|
613 TAknsSkinChangeReason iLastChangeReason; |
|
614 |
|
615 /** |
|
616 * Are the application icons configured with cenrep? |
|
617 * |
|
618 */ |
|
619 TBool iAppConfigurationCenrepNotUsed; |
|
620 |
|
621 /** |
|
622 * Animation Background State |
|
623 */ |
|
624 TBool iAnimBgState; |
|
625 |
|
626 /** |
|
627 * Wallpaper Type |
|
628 */ |
|
629 TBool iWallpaperDefined; |
|
630 |
|
631 private: // Data |
|
632 |
|
633 /** |
|
634 * Debug hook for client errors |
|
635 */ |
|
636 void (*iDebugErrorCallback)(TAny*); |
|
637 TAny* iDebugErrorCallbackParam; |
|
638 |
|
639 /** |
|
640 * Debug hook for change notifications |
|
641 */ |
|
642 void (*iDebugChangeCallback)(TAny*); |
|
643 TAny* iDebugChangeCallbackParam; |
|
644 |
|
645 public: // Friend classes |
|
646 |
|
647 friend class AknsUtils; |
|
648 friend class AknsPointerStore; |
|
649 friend class AknsItemDataFactory; |
|
650 friend class AknsScalabilityUtils; |
|
651 friend class CAknsAlAnimatorBmp; // To access iSession |
|
652 }; |
|
653 |
|
654 #endif // AKNSAPPSKININSTANCE_H |
|
655 |
|
656 // End of File |