|
1 /* |
|
2 * Copyright (c) 2009 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 |
|
18 #ifndef __MENUSRVAPPSCANNER_H__ |
|
19 #define __MENUSRVAPPSCANNER_H__ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <apgcli.h> |
|
23 #include <apgnotif.h> |
|
24 #include <cenrepnotifyhandler.h> |
|
25 #include "menuengoperation.h" |
|
26 #include "mcssatnotifier.h" |
|
27 #include "menuengfilter.h" |
|
28 #include "mcsfreespaceobserver.h" |
|
29 #include "mcsmenuitem.h" |
|
30 #include "mcsmenunotifier.h" |
|
31 #include <driveinfo.h> |
|
32 |
|
33 // FORWARD DECLARATION |
|
34 |
|
35 class CMenuEng; |
|
36 class TAppAtributes; |
|
37 class CMenuSrvMmcHistory; |
|
38 class CRepository; |
|
39 class CCenRepNotifyHandler; |
|
40 class RWidgetRegistryClientSession; |
|
41 |
|
42 /** |
|
43 * Application scanner. |
|
44 * Using AppArc application information, keeps menu application |
|
45 * items ("menu:application") up-to-date. |
|
46 * |
|
47 * Operation is asynchronous (because AppArc startup is asynchronous): |
|
48 * 1. ConstructL(): invokes iApaLsSession to build app list (async). |
|
49 * 2. RunL(): App list is complete, this object schedules itself to Engine. |
|
50 * 3. RunMenuEngOperationL(): The operation is executed by the engine. |
|
51 * 4. HandleAppListEvent(): change in app list, go back to step 2. |
|
52 * |
|
53 * App scanning does the following: |
|
54 * - Applications present in the system but not appearing in the menu are added |
|
55 * to the appropriate folder. |
|
56 * - Java apps should appear / disappear. TODO not impemented yet! |
|
57 * - Hide hidden applications, show non-hidden applications (flag "hidden"). |
|
58 * - Hide / show MMC-related items, according to whether MMC is present or not |
|
59 * (flag "missing"). Keep an MMC history, purge old MMC-based menu items |
|
60 * (== missing menu items whose MMC card has not been seen for long). |
|
61 * - Observing AppArc (and MMC, and Java, etc etc) to keep the menu data up |
|
62 * to date continuously. |
|
63 */ |
|
64 NONSHARABLE_CLASS( CMenuSrvAppScanner ) |
|
65 : public CActive, public MMenuEngOperation, public MApaAppListServObserver, |
|
66 public MCenRepNotifyHandlerCallback, public MMcsSATNotifierCallback, |
|
67 MMcsFreeSpaceObserver |
|
68 { |
|
69 |
|
70 public: // Constructor |
|
71 |
|
72 /** |
|
73 * Destructor. |
|
74 */ |
|
75 virtual ~CMenuSrvAppScanner(); |
|
76 |
|
77 /** |
|
78 * Two-phased constructor. |
|
79 * @param aEng Engine. |
|
80 */ |
|
81 static CMenuSrvAppScanner* NewL( CMenuEng& aEng ); |
|
82 |
|
83 |
|
84 private: // Constructors and destructor |
|
85 |
|
86 /** |
|
87 * Constructor. |
|
88 * @param aEng Engine. |
|
89 */ |
|
90 CMenuSrvAppScanner( CMenuEng& aEng ); |
|
91 |
|
92 /** |
|
93 * Second phased constructor. |
|
94 */ |
|
95 void ConstructL(); |
|
96 |
|
97 private: // from CActive |
|
98 |
|
99 /** |
|
100 * Request completed, schedule engine operation. |
|
101 */ |
|
102 void RunL(); |
|
103 |
|
104 /** |
|
105 * Cancel request. |
|
106 */ |
|
107 void DoCancel(); |
|
108 |
|
109 /** |
|
110 * Error handling: ignore error. |
|
111 * @param aErr Error code. |
|
112 */ |
|
113 TInt RunError( TInt aError ); |
|
114 |
|
115 private: // from MMcsFreeSpaceObserver |
|
116 /** |
|
117 * Handle Free Space Event. |
|
118 */ |
|
119 void HandleFreeSpaceEventL(); |
|
120 |
|
121 private: // from MMenuEngOperation |
|
122 |
|
123 /** |
|
124 * Execute engine operation: |
|
125 * Do the application scan and update menu accordingly. |
|
126 */ |
|
127 void RunMenuEngOperationL(); |
|
128 |
|
129 /** |
|
130 * Error handling: ignore error. |
|
131 * @param aErr Error code. |
|
132 */ |
|
133 void CompletedMenuEngOperation( TInt aErr ); |
|
134 |
|
135 private: // from MApaAppListServObserver |
|
136 |
|
137 void HandleAppListEvent( TInt aEvent ); |
|
138 |
|
139 private: // from MCenRepNotifyHandlerCallback |
|
140 |
|
141 /** |
|
142 * Called if one of CR keys has changed |
|
143 * @param aId Id of the key that has changed. |
|
144 * @param aNewValue The new value of the key. |
|
145 */ |
|
146 void HandleNotifyString( TUint32 aKey, const TDesC16& aNewValue ); |
|
147 |
|
148 private: // from MMcsSATNotifierCallback |
|
149 |
|
150 /** |
|
151 * Inherited from MNotifierMMcsSATNotifierCallbackCallback |
|
152 * |
|
153 * @since Series 60 3.1 |
|
154 * @return void |
|
155 */ |
|
156 void SATChangeL(); |
|
157 |
|
158 public: |
|
159 /** |
|
160 * Schedule appscanner run. |
|
161 * Self complete active object. |
|
162 */ |
|
163 void ScheduleScan(); |
|
164 |
|
165 private: // new methods |
|
166 |
|
167 /** |
|
168 */ |
|
169 void HandleLockDeleteFlagUpdateL( const TMenuItem& aItem,TInt aUid ); |
|
170 |
|
171 /** |
|
172 * Updates application's missing attribute. |
|
173 * Add new menu item referring to this application. |
|
174 * @param aItem menu item. |
|
175 */ |
|
176 void HandleMissingFlagUpdateL( const TMenuItem& aItem ); |
|
177 |
|
178 /** |
|
179 * Updates hidden flag. |
|
180 * @param aItem menu item. |
|
181 * @param aUid Application's uid. |
|
182 * @param aApaItemHidden Application's hidden status from ApaLsSession. |
|
183 */ |
|
184 void HandleHiddenFlagUpdateL( |
|
185 const TMenuItem & aItem, |
|
186 TInt & aAppUid, |
|
187 TBool aApaItemHidden ); |
|
188 /** |
|
189 * Updates native attribute. |
|
190 * @param aItem menu item. |
|
191 * @param aUid Application's uid. |
|
192 */ |
|
193 void HandleNativeAttrUpdateL( |
|
194 const TMenuItem& aItem, |
|
195 TInt aUid ); |
|
196 |
|
197 /** |
|
198 * Updates mmc attribute. |
|
199 * @param aItem menu item. |
|
200 * @param aUid Application's uid. |
|
201 * @param aMmcId MMC ID of currently inserted MMC, or 0. |
|
202 */ |
|
203 void HandleMmcAttrUpdateL( |
|
204 const TMenuItem& aItem, |
|
205 TInt aUid, |
|
206 TUint aMmcId ); |
|
207 |
|
208 |
|
209 /** |
|
210 */ |
|
211 TBool IsInRomL( TInt aUid ); |
|
212 |
|
213 /** |
|
214 */ |
|
215 void GetCrItemsL( RArray<TAppAtributes>& aArray ); |
|
216 |
|
217 |
|
218 /** |
|
219 */ |
|
220 void ParseUidsL( const TDesC& aHiddenApplications, |
|
221 RArray<TAppAtributes>& aArray ); |
|
222 /** |
|
223 */ |
|
224 void GetApaItemsL( RArray<TAppAtributes>& aArray ); |
|
225 |
|
226 /** |
|
227 */ |
|
228 void SetHidden( const TDesC& aHiddenAppUid, |
|
229 RArray<TAppAtributes>& aArray ); |
|
230 |
|
231 /** |
|
232 */ |
|
233 void GetMcsAppItemsL( RArray<TMenuItem>& aArray); |
|
234 |
|
235 /** |
|
236 */ |
|
237 void GetMcsAppItemsL( TBool aLegacy, const TUint aUid, |
|
238 RArray<TMenuItem>& aArray); |
|
239 |
|
240 |
|
241 /** |
|
242 * New application is found, no menu item refers to it. |
|
243 * Add new menu item referring to this application. |
|
244 * @param aUid Application capability. |
|
245 * @param aCurrentMmcId MMC ID of currently inserted MMC, or 0. |
|
246 */ |
|
247 void AddAppItemL( |
|
248 TUint aUid, |
|
249 TUint aCurrentMmcId ); |
|
250 |
|
251 TInt CreateInstallFolderL( TUint aUid ); |
|
252 |
|
253 /** |
|
254 * @param aAppUid application UID |
|
255 * @return TBool |
|
256 */ |
|
257 TBool IsMidlet( const TUid aAppUid ); |
|
258 |
|
259 |
|
260 /** |
|
261 * Find menu folder which has the specified "applicationgroup_name" |
|
262 * attribute. If no such folder exists, create. |
|
263 * @param aAppGroupName value of the "applicationgroup_name" attribute |
|
264 * @param aFolderId Folder ID. |
|
265 */ |
|
266 void AppGroupFolderL( const TDesC& aAppGroupName, TInt& aFolderId ); |
|
267 |
|
268 /** |
|
269 * Find the default folder (folder having attribute 'default="1"'). |
|
270 * If not found, return 0. |
|
271 * @param aFolderId Dedault folder or 0. |
|
272 */ |
|
273 void DefaultFolderL( TInt& aFolderId ); |
|
274 |
|
275 /** |
|
276 * Make sure that folder is writable (remove "lock_moveinto"). |
|
277 * @param aFolder Folder id. |
|
278 */ |
|
279 void EnsureFolderWritableL( TInt aFolder ); |
|
280 |
|
281 /** |
|
282 * Handle items are in the menu but no corresponding app is present: |
|
283 * - Items that are on a recently used MMC are get "missing" flag but kept. |
|
284 * - Items that are not on MMC or the MMC is not recently used, are |
|
285 * removed form the menu. |
|
286 * @param aItems Missing items. |
|
287 */ |
|
288 void HandleMissingItemsL( const RArray<TMenuItem>& aItems ); |
|
289 |
|
290 /** |
|
291 * Updates objects flags to aFlagPresent if needed. |
|
292 * @param aFlagValue value for flag. |
|
293 * @param aItem menu item. |
|
294 * @param aFlag menu item's flag. |
|
295 * @param aEvent menu item's event for engine. |
|
296 */ |
|
297 void SetObjectFlagsL( |
|
298 TBool aFlagValue, |
|
299 const TMenuItem& aItem, |
|
300 const TMenuItem::TFlags& aFlag, |
|
301 const RMenuNotifier::TEvent& aEvent = RMenuNotifier::EItemAttributeChanged ); |
|
302 |
|
303 /** |
|
304 * Check currently inserted MMC card, update and save MMC history. |
|
305 * @return Current MMC id, or 0 if no MMC is inserted. |
|
306 */ |
|
307 TUint UpdateMmcHistoryL(); |
|
308 |
|
309 /** |
|
310 * Get current MMC id. 0 if no MMC is inserted, or in case of any errors. |
|
311 * @return Current MMC id, or 0. |
|
312 */ |
|
313 TUint CurrentMmcId() const; |
|
314 |
|
315 /** |
|
316 * Check if file is on given default drive type. |
|
317 * @param aFileName File name. |
|
318 * @return ETrue if aFileName is on given default drive type. |
|
319 */ |
|
320 TBool IsFileInDrive( |
|
321 const TDesC& aFileName, |
|
322 const DriveInfo::TDefaultDrives& aDefaultDrive ) const; |
|
323 |
|
324 /** |
|
325 * Check if application is installed on given drive type. |
|
326 * @param aUid app uid. |
|
327 * @param aDefaultDrive drive type. |
|
328 * @return ETrue if app is installed on given drive type. |
|
329 */ |
|
330 TBool IsAppInDrive( |
|
331 const TUid aUid, |
|
332 const DriveInfo::TDefaultDrives& aDefaultDrive ) const; |
|
333 |
|
334 /** |
|
335 * Check if application is installed on MMC. |
|
336 * @param aUid app uid. |
|
337 * @return ETrue if app is installed on MMC. |
|
338 */ |
|
339 TBool IsMmcApp( const TUid aUid ) const; |
|
340 |
|
341 /** |
|
342 * Check if application is installed on mass storage. |
|
343 * @param aUid app uid. |
|
344 * @return ETrue if app is installed on mass storage. |
|
345 */ |
|
346 TBool IsMassStorageApp( const TUid aUid ) const; |
|
347 |
|
348 /** |
|
349 * Check if drive's status is EDriveInUse. |
|
350 * @param aDefaultDrive default drive type. |
|
351 * @return ETrue if drive is in use. |
|
352 */ |
|
353 TBool IsDriveInUse( |
|
354 const DriveInfo::TDefaultDrives& aDefaultDrive ); |
|
355 |
|
356 /** |
|
357 TODO |
|
358 */ |
|
359 void HideItemIfPresentL( TInt aFolder, TInt aId, const TDesC& aUid, TBool aWasHidden ); |
|
360 |
|
361 /** |
|
362 TODO |
|
363 */ |
|
364 void GetHiddenFlagAndUidL( TInt aId, TBool& aHidden, TPtrC& aUidStr ); |
|
365 |
|
366 /** |
|
367 TODO |
|
368 */ |
|
369 void SetHiddenFlagL( TInt aId, TBool aWasHidden, TBool aHide ); |
|
370 |
|
371 /** |
|
372 TODO |
|
373 */ |
|
374 void ValidateLinkUidL( TInt aFolder, TInt aId, const TDesC& aUidStr ); |
|
375 |
|
376 /** |
|
377 TODO |
|
378 */ |
|
379 void UpdateLinkL( TInt aId, TBool aExists, TBool aShowItem, TBool aMissingItem ); |
|
380 |
|
381 /** |
|
382 TODO |
|
383 */ |
|
384 void ValidateLinkRefIdL( TInt aId, const TDesC& refIdStr ); |
|
385 |
|
386 /** |
|
387 TODO |
|
388 */ |
|
389 void ValidateLinkL( TInt aFolder, TInt aId ); |
|
390 |
|
391 /** |
|
392 TODO |
|
393 */ |
|
394 void UpdateApplicationItemL( |
|
395 RArray<TMenuItem>& aMcsItems, |
|
396 const TAppAtributes& aApaItem, |
|
397 TUint aMmcId, |
|
398 TBool isLegacy ); |
|
399 |
|
400 /** |
|
401 TODO |
|
402 */ |
|
403 void UpdateApplicationItemsL(); |
|
404 |
|
405 /** |
|
406 TODO |
|
407 */ |
|
408 void UpdateApplicationWithHideIfInstalledItemsL(); |
|
409 |
|
410 /** |
|
411 TODO |
|
412 */ |
|
413 void UpdateLinkItemsL(); |
|
414 |
|
415 |
|
416 private: // data |
|
417 |
|
418 CMenuEng& iEng ; ///< Engine. |
|
419 RApaLsSession iApaLsSession; ///< AppArc session. Own. |
|
420 CApaAppListNotifier* iNotifier; ///< Change notifier. Own. |
|
421 CMenuSrvMmcHistory* iMmcHistory; ///< MMC history. Own. |
|
422 RFs iFs; ///< File Server Session. Own. |
|
423 RWidgetRegistryClientSession iWidgetSession;///<Own. |
|
424 |
|
425 /* |
|
426 * Sat change notifier. Own |
|
427 */ |
|
428 CMcsSatNotifier* iMcsSatNotifier; |
|
429 |
|
430 /* |
|
431 * Central repository session |
|
432 */ |
|
433 CRepository* iCenRepSession; |
|
434 |
|
435 /* |
|
436 * Central repository change handler for Hidden Apps |
|
437 */ |
|
438 CCenRepNotifyHandler* iCenRepNotifyHandlerHiddenApps; |
|
439 |
|
440 /* |
|
441 *Central repository change handler for Control Panel Hidden Apps |
|
442 */ |
|
443 CCenRepNotifyHandler* iCenRepNotifyHandlerCPHiddenApps; |
|
444 |
|
445 /* |
|
446 *Central repository change handler for Control Panel Hidden Folders |
|
447 */ |
|
448 CCenRepNotifyHandler* iCenRepNotifyHandlerCPHiddenFolders; |
|
449 |
|
450 /* |
|
451 * Free space observer. Own. |
|
452 */ |
|
453 CMcsFreeSpaceObserver* iFreeSpaceObserver; |
|
454 |
|
455 TBool iOpStatus; |
|
456 }; |
|
457 |
|
458 |
|
459 class TAppAtributes |
|
460 { |
|
461 |
|
462 public: |
|
463 /* |
|
464 * |
|
465 */ |
|
466 TAppAtributes ( TUint aUid, TBool aHidden /*,TBool aMissing*/); |
|
467 |
|
468 /* |
|
469 * |
|
470 */ |
|
471 TUint GetUid() const; |
|
472 |
|
473 /* |
|
474 * |
|
475 */ |
|
476 TBool IsHidden() const; |
|
477 |
|
478 /* |
|
479 * |
|
480 */ |
|
481 void SetHidden( TBool aHidden ); |
|
482 |
|
483 /* |
|
484 * |
|
485 */ |
|
486 static TBool MatchItems(const TAppAtributes& item1, |
|
487 const TAppAtributes& item2); |
|
488 |
|
489 private: // data |
|
490 |
|
491 TUint iUid; |
|
492 TBool iHidden; |
|
493 }; |
|
494 |
|
495 #endif // __MENUSRVAPPSCANNER_H__ |