|
1 /* |
|
2 * Copyright (c) 2002 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 the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef AKN_ICON_SERVER_H |
|
21 #define AKN_ICON_SERVER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <s32file.h> |
|
26 #include <fbs.h> |
|
27 #include <AknIconUtils.h> |
|
28 // CONSTANTS |
|
29 |
|
30 // needed for creating server thread in WINS. |
|
31 const TInt KAknIconSrvMinHeapSize = 0x10000; |
|
32 const TInt KAknIconSrvMaxHeapSize = 0x4000000; |
|
33 |
|
34 // opcodes used in message passing between client and server |
|
35 enum TAknIconServRequest |
|
36 { |
|
37 ERetrieveOrCreateSharedIcon, |
|
38 EFreeBitmap, |
|
39 EGetContentDimensions, |
|
40 EPreserveIconData, |
|
41 EDestroyIconData, |
|
42 EGetInitData, |
|
43 EAknIconServRequestEnableCache, |
|
44 // For debug |
|
45 EServerHeapMark, |
|
46 EServerHeapMarkEnd, |
|
47 EServerHeapFailNext, |
|
48 EServerHeapFailNextIncreasing, |
|
49 EServerHeapReset, |
|
50 EServerResetDynamicallyChangingAllocations, |
|
51 EServerHeapUsed, |
|
52 EServerSetPreferredIconDisplayMode |
|
53 }; |
|
54 |
|
55 // return codes to client side (not actual errors) |
|
56 const TInt KAknIconSrvCodeAnimated = -100; |
|
57 const TInt KAknIconSrvCodePanicClient = -101; // The AknIconSrv client has been panicked |
|
58 |
|
59 _LIT( KAknIconSrvName, "!AknIconServer" ); |
|
60 _LIT( KAknIconSrvExe, "AknIconSrv.exe" ); |
|
61 _LIT( KAknIconLibName, "AknIcon.dll" ); |
|
62 |
|
63 // FUNCTION PROTOTYPES |
|
64 |
|
65 // function to start the server thread/process |
|
66 GLREF_C TInt StartServer(); |
|
67 // function to signal server startup semaphore |
|
68 GLREF_C void SignalClient(); |
|
69 |
|
70 // FORWARD DECLARATIONS |
|
71 class CAknIconSrvIconItem; |
|
72 struct TAknIconParams; |
|
73 class CAknIconLoader; |
|
74 struct TAknIconSrvSessionIconItem; |
|
75 struct TAknIconSrvSessionPreservedItem; |
|
76 class CAknIconSrvCache; |
|
77 class CAknIconSrvPrecacheItem; |
|
78 class CAknIconSrvRequest; |
|
79 class CAknIconSrvPrecacher; |
|
80 struct TAknIconSrvReturnData; |
|
81 struct TAknIconInitData; |
|
82 class CAknIconDataPreserver; |
|
83 class MAknIconFormatHandler; |
|
84 class CAknIconDataItem; |
|
85 class CAknIconFileNameCache; |
|
86 |
|
87 // CLASS DECLARATION |
|
88 |
|
89 /** |
|
90 * The server class, an active object. |
|
91 * Contains an instance of RServer, a handle to the kernel server |
|
92 * representation which is used to receive messages. |
|
93 */ |
|
94 NONSHARABLE_CLASS(CAknIconServer) : public CServer2 |
|
95 { |
|
96 public: // Constructors and destructor |
|
97 |
|
98 /** |
|
99 * constructs and starts the server. |
|
100 */ |
|
101 static CAknIconServer* NewL(); |
|
102 |
|
103 virtual ~CAknIconServer(); |
|
104 |
|
105 public: |
|
106 |
|
107 /** |
|
108 * Opens a new session to the server. |
|
109 * |
|
110 * @param aVersion required version of the server. |
|
111 * |
|
112 * @return pointer to a new session |
|
113 * |
|
114 * Leaves if: |
|
115 * - Out of memory (KErrNoMemory) |
|
116 */ |
|
117 CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const; |
|
118 |
|
119 /** |
|
120 * Server bootstrap code. |
|
121 */ |
|
122 IMPORT_C static TInt ThreadStart(); |
|
123 |
|
124 const CAknIconSrvIconItem* RetrieveOrCreateSharedIconL(); |
|
125 const CAknIconSrvIconItem* FreeBitmapL(); |
|
126 |
|
127 const CAknIconDataItem* PreserveIconDataL(); |
|
128 const CAknIconDataItem* UnpreserveIconDataL(); |
|
129 |
|
130 void GetContentDimensionsL(); |
|
131 |
|
132 void CleanupSessionIconItem( |
|
133 const TAknIconSrvSessionIconItem& aItem ); |
|
134 void CleanupSessionPreservedItem( |
|
135 const TAknIconSrvSessionPreservedItem& aItem ); |
|
136 |
|
137 void RemoveCachedItem( const CAknIconSrvIconItem& aItem ); |
|
138 |
|
139 inline RFs& FsSession(); |
|
140 inline TRequestStatus& ThreadLaunchStatus(); |
|
141 inline CAknIconSrvPrecacher& Precacher(); |
|
142 inline TDisplayMode IconDepth() const; |
|
143 |
|
144 /* Clears "permanently cached" flag from the items that are premanently cached |
|
145 * according to the currently active skin. Deletes them from the icon item array, |
|
146 * if no-one is using them. |
|
147 */ |
|
148 void InvalidateItemsCachedFromSkin(); |
|
149 |
|
150 |
|
151 /* |
|
152 * For debug only. |
|
153 */ |
|
154 void ResetDynamicallyChangingAllocations(); |
|
155 void SetPreferredIconDisplayMode( TDisplayMode aMode ); |
|
156 |
|
157 /* |
|
158 * Gets information of handles to an empty bitmap used in error cases |
|
159 * and the configuration data from the resource file. |
|
160 */ |
|
161 void GetInitData( TAknIconInitData& aData ) const; |
|
162 |
|
163 CAknIconLoader* InitIconLoaderL( const TDesC& aFileName, RFile* aFile ); |
|
164 |
|
165 /** |
|
166 * Releases the icon loader if a backup/restore operation is going on. |
|
167 */ |
|
168 void IconLoaderUsed(); |
|
169 |
|
170 /** |
|
171 * Cleanup item function for making sure that the used icon file is properly |
|
172 * closed after use to avoid problems with e.g. uninstallations or backup/restore. |
|
173 */ |
|
174 static void CleanupIconLoader( TAny* aServer ); |
|
175 |
|
176 /** |
|
177 * Returns the file handle that is transferred from the client side |
|
178 * and adopted by the current session object. |
|
179 * If a file handle is not supplied by the client, this returns |
|
180 * a closed file handle. |
|
181 * Caller of this method does not need to close this file handle. |
|
182 */ |
|
183 RFile& RetrieveFileHandleL(); |
|
184 inline CAknIconFileNameCache& IconFileNameCache(); |
|
185 |
|
186 /* |
|
187 * Enable or disable the cache. |
|
188 */ |
|
189 void EnableCache(TBool aEnable); |
|
190 |
|
191 /** |
|
192 * Loads icon data and initializes icon format handler. |
|
193 * The returned icon format handler is owned by the |
|
194 * CAknIconServer object. |
|
195 */ |
|
196 TPtrC8 InitIconDataAndHandlerLC( |
|
197 const TAknIconParams& aParams, |
|
198 CAknIconLoader*& aLoader, |
|
199 MAknIconFormatHandler*& aHandler ); |
|
200 |
|
201 private: // New methods |
|
202 |
|
203 TInt RetrieveIcon( const TAknIconParams& aInfo ); |
|
204 |
|
205 |
|
206 |
|
207 CAknIconSrvIconItem* CreateIconL( const TAknIconParams& aInfo ); |
|
208 |
|
209 CAknIconSrvIconItem* CreateMbmIconL( |
|
210 const TAknIconParams& aInfo, |
|
211 const TAknIconSrvReturnData& aHandles ); |
|
212 |
|
213 static void ApplyIconColorL( CAknIconSrvIconItem* aItem, const TRgb aColor ); |
|
214 |
|
215 /* |
|
216 * Returns ETrue if aItem is deleted otherwise EFalse. |
|
217 */ |
|
218 TBool DeleteOrCacheUnusedIcon(CAknIconSrvIconItem* aItem); |
|
219 |
|
220 void ReCreateSvgL( TAknIconParams& aInfo, CAknIconSrvIconItem *& aItem); |
|
221 private: |
|
222 |
|
223 CAknIconServer(); |
|
224 void ConstructL(); |
|
225 |
|
226 private: // data |
|
227 |
|
228 // Configuration data from the resource file. |
|
229 TInt iCompression; |
|
230 TDisplayMode iIconMode; |
|
231 TDisplayMode iIconMaskMode; |
|
232 |
|
233 TDisplayMode iPhotoMode; |
|
234 TDisplayMode iVideoMode; |
|
235 |
|
236 TDisplayMode iOffscreenMode; |
|
237 TDisplayMode iOffscreenMaskMode; |
|
238 // --- |
|
239 |
|
240 RFs iFsSession; |
|
241 |
|
242 RPointerArray<CAknIconSrvIconItem> iIconItems; |
|
243 |
|
244 // List of Icon Format Handlers |
|
245 // Shared with other classes must be deleted at last. |
|
246 RPointerArray<MAknIconFormatHandler> iHandlerList; |
|
247 |
|
248 // Always icon loader for avkon icon file. |
|
249 CAknIconLoader* iAvkonIconLoader; |
|
250 |
|
251 // Icon loader for previously accessed other icon file. |
|
252 CAknIconLoader* iOtherIconLoader; |
|
253 HBufC* iCurrentIconFile; |
|
254 |
|
255 TInt iCurrentIndex; // Helper to keep array index valid. |
|
256 |
|
257 CAknIconDataPreserver* iIconDataPreserver; |
|
258 |
|
259 // Cache configuration |
|
260 CAknIconSrvCache* iCache; |
|
261 |
|
262 // --------------------------------------------------------------------- |
|
263 // Precache thread writes to the following member variables. |
|
264 // --------------------------------------------------------------------- |
|
265 |
|
266 TRequestStatus iThreadLaunchStatus; |
|
267 // Cached information of icon file names |
|
268 CAknIconFileNameCache* iFileNameCache; |
|
269 #ifdef PRECACHE2 |
|
270 // All precached items are copied to this array |
|
271 RPointerArray<CAknIconSrvIconItem> iNewPrecachedItems; |
|
272 |
|
273 // This list of bitmaps is used to keep track of bitmaps which are valid in precache |
|
274 RPointerArray<CFbsBitmap> iFreePrecacheBitmapHandles; |
|
275 |
|
276 //Used to indicate if all the items in the resource file have been parsed |
|
277 TBool iPrecacheComplete; |
|
278 |
|
279 //Thread in which the precaching occurs |
|
280 RThread iPreCacheThread; |
|
281 |
|
282 #endif |
|
283 |
|
284 private: |
|
285 |
|
286 friend class CAknIconSrvPrecacher; |
|
287 friend class CAknIconSrvCache; |
|
288 |
|
289 #ifdef _NGATESTING |
|
290 void LoadConfigurationL(RFs& aFs); |
|
291 TInt32 iConfigIconType; |
|
292 TFileName iNGADirectory; |
|
293 #endif |
|
294 }; |
|
295 |
|
296 #include "AknIconSrv.inl" |
|
297 |
|
298 #endif // AKN_ICON_SERVER_H |
|
299 |
|
300 // Enf of File |