30
|
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 CMenuSrvAppAttributes;
|
|
37 |
class CMenuSrvMmcHistory;
|
|
38 |
class CRepository;
|
|
39 |
class CCenRepNotifyHandler;
|
|
40 |
class CMenuSrvEngUtils;
|
|
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(
|
|
82 |
CMenuEng& aEng,
|
|
83 |
CMenuSrvEngUtils& aSrvEngUtils );
|
|
84 |
|
|
85 |
private: // Constructors and destructor
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Constructor.
|
|
89 |
* @param aEng Engine.
|
|
90 |
*/
|
|
91 |
CMenuSrvAppScanner( CMenuEng& aEng, CMenuSrvEngUtils& aSrvEngUtils );
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Second phased constructor.
|
|
95 |
*/
|
|
96 |
void ConstructL();
|
|
97 |
|
|
98 |
private: // from CActive
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Request completed, schedule engine operation.
|
|
102 |
*/
|
|
103 |
void RunL();
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Cancel request.
|
|
107 |
*/
|
|
108 |
void DoCancel();
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Error handling: ignore error.
|
|
112 |
* @param aErr Error code.
|
|
113 |
*/
|
|
114 |
TInt RunError( TInt aError );
|
|
115 |
|
|
116 |
private: // from MMcsFreeSpaceObserver
|
|
117 |
/**
|
|
118 |
* Handle Free Space Event.
|
|
119 |
*/
|
|
120 |
void HandleFreeSpaceEventL();
|
|
121 |
|
|
122 |
private: // from MMenuEngOperation
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Execute engine operation:
|
|
126 |
* Do the application scan and update menu accordingly.
|
|
127 |
*/
|
|
128 |
void RunMenuEngOperationL();
|
|
129 |
|
|
130 |
/**
|
|
131 |
* Error handling: ignore error.
|
|
132 |
* @param aErr Error code.
|
|
133 |
*/
|
|
134 |
void CompletedMenuEngOperation( TInt aErr );
|
|
135 |
|
|
136 |
private: // from MApaAppListServObserver
|
|
137 |
|
|
138 |
void HandleAppListEvent( TInt aEvent );
|
|
139 |
|
|
140 |
private: // from MCenRepNotifyHandlerCallback
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Called if one of CR keys has changed
|
|
144 |
* @param aId Id of the key that has changed.
|
|
145 |
* @param aNewValue The new value of the key.
|
|
146 |
*/
|
|
147 |
void HandleNotifyString( TUint32 aKey, const TDesC16& aNewValue );
|
|
148 |
|
|
149 |
private: // from MMcsSATNotifierCallback
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Inherited from MNotifierMMcsSATNotifierCallbackCallback
|
|
153 |
*
|
|
154 |
* @since Series 60 3.1
|
|
155 |
* @return void
|
|
156 |
*/
|
|
157 |
void SATChangeL();
|
|
158 |
|
|
159 |
public:
|
|
160 |
/**
|
|
161 |
* Schedule appscanner run.
|
|
162 |
* Self complete active object.
|
|
163 |
*/
|
|
164 |
void ScheduleScan();
|
|
165 |
|
|
166 |
private: // new methods
|
|
167 |
|
|
168 |
/**
|
|
169 |
*/
|
|
170 |
void HandleLockDeleteFlagUpdateL(
|
|
171 |
const TMenuItem& aItem, const CMenuSrvAppAttributes& aApaItem );
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Updates application's missing attribute.
|
|
175 |
* Add new menu item referring to this application.
|
|
176 |
* @param aItem menu item.
|
|
177 |
*/
|
|
178 |
void HandleMissingFlagUpdateL( const TMenuItem& aItem );
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Updates hidden flag.
|
|
182 |
* @param aItem menu item.
|
|
183 |
* @param aUid Application's uid.
|
|
184 |
* @param aApaItemHidden Application's hidden status from ApaLsSession.
|
|
185 |
*/
|
|
186 |
void HandleHiddenFlagUpdateL(
|
|
187 |
const TMenuItem & aItem,
|
|
188 |
const CMenuSrvAppAttributes& aApaItem );
|
|
189 |
/**
|
|
190 |
* Updates native attribute.
|
|
191 |
* @param aItem menu item.
|
|
192 |
* @param aUid Application's uid.
|
|
193 |
*/
|
|
194 |
void HandleNativeAttrUpdateL(
|
|
195 |
const TMenuItem& aItem,
|
|
196 |
const CMenuSrvAppAttributes& aApaItem );
|
|
197 |
|
|
198 |
/**
|
|
199 |
* Updates mmc attribute.
|
|
200 |
* @param aItem menu item.
|
|
201 |
* @param aUid Application's uid.
|
|
202 |
* @param aMmcId MMC ID of currently inserted MMC, or 0.
|
|
203 |
*/
|
|
204 |
void HandleMmcAttrUpdateL(
|
|
205 |
const TMenuItem& aItem,
|
|
206 |
const CMenuSrvAppAttributes& aApaItem,
|
|
207 |
TUint aMmcId );
|
|
208 |
|
|
209 |
/**
|
|
210 |
*/
|
|
211 |
void GetCrItemsL( RPointerArray<CMenuSrvAppAttributes>& aArray );
|
|
212 |
|
|
213 |
|
|
214 |
/**
|
|
215 |
*/
|
|
216 |
void ParseUidsL( const TDesC& aHiddenApplications,
|
|
217 |
RPointerArray<CMenuSrvAppAttributes>& aArray );
|
|
218 |
|
|
219 |
/**
|
|
220 |
*/
|
|
221 |
void SetHidden( const TDesC& aHiddenAppUid,
|
|
222 |
RPointerArray<CMenuSrvAppAttributes>& aArray );
|
|
223 |
|
|
224 |
/**
|
|
225 |
*/
|
|
226 |
void GetMcsAppItemsL( RArray<TMenuItem>& aArray);
|
|
227 |
|
|
228 |
/**
|
|
229 |
*/
|
|
230 |
void GetMcsAppItemsL( TBool aLegacy, const TUint aUid,
|
|
231 |
RArray<TMenuItem>& aArray);
|
|
232 |
|
|
233 |
|
|
234 |
/**
|
|
235 |
* New application is found, no menu item refers to it.
|
|
236 |
* Add new menu item referring to this application.
|
|
237 |
* @param aUid Application capability.
|
|
238 |
* @param aCurrentMmcId MMC ID of currently inserted MMC, or 0.
|
|
239 |
*/
|
|
240 |
void AddAppItemL(
|
|
241 |
const CMenuSrvAppAttributes& aApaItem,
|
|
242 |
TUint aCurrentMmcId );
|
|
243 |
|
|
244 |
TInt CreateInstallFolderL( const CMenuSrvAppAttributes& aApaItem );
|
|
245 |
|
|
246 |
|
|
247 |
/**
|
|
248 |
* Find menu folder which has the specified "applicationgroup_name"
|
|
249 |
* attribute. If no such folder exists, create.
|
|
250 |
* @param aAppGroupName value of the "applicationgroup_name" attribute
|
|
251 |
* @param aFolderId Folder ID.
|
|
252 |
*/
|
|
253 |
void AppGroupFolderL( const TDesC& aAppGroupName, TInt& aFolderId );
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Find the default folder (folder having attribute 'default="1"').
|
|
257 |
* If not found, return 0.
|
|
258 |
* @param aFolderId Dedault folder or 0.
|
|
259 |
*/
|
|
260 |
void DefaultFolderL( TInt& aFolderId );
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Make sure that folder is writable (remove "lock_moveinto").
|
|
264 |
* @param aFolder Folder id.
|
|
265 |
*/
|
|
266 |
void EnsureFolderWritableL( TInt aFolder );
|
|
267 |
|
|
268 |
/**
|
|
269 |
* Handle items are in the menu but no corresponding app is present:
|
|
270 |
* - Items that are on a recently used MMC are get "missing" flag but kept.
|
|
271 |
* - Items that are not on MMC or the MMC is not recently used, are
|
|
272 |
* removed form the menu.
|
|
273 |
* @param aItems Missing items.
|
|
274 |
*/
|
|
275 |
void HandleMissingItemsL( const RArray<TMenuItem>& aItems );
|
|
276 |
|
|
277 |
/**
|
|
278 |
* Returns proper flag to be set for missing or hidden item.
|
|
279 |
* @param aItem menu item.
|
|
280 |
* @return item proper flags for hidding.
|
|
281 |
*/
|
|
282 |
TMenuItem::TFlags GetProperFlagL( const TMenuItem& aItem );
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Updates objects flags to aFlagPresent if needed.
|
|
286 |
* @param aFlagValue value for flag.
|
|
287 |
* @param aItem menu item.
|
|
288 |
* @param aFlag menu item's flag.
|
|
289 |
* @param aEvent menu item's event for engine.
|
|
290 |
*/
|
|
291 |
void SetObjectFlagsL(
|
|
292 |
TBool aFlagValue,
|
|
293 |
const TMenuItem& aItem,
|
|
294 |
const TMenuItem::TFlags& aFlag,
|
|
295 |
const RMenuNotifier::TEvent& aEvent = RMenuNotifier::EItemAttributeChanged );
|
|
296 |
|
|
297 |
/**
|
|
298 |
* Check currently inserted MMC card, update and save MMC history.
|
|
299 |
* @return Current MMC id, or 0 if no MMC is inserted.
|
|
300 |
*/
|
|
301 |
TUint UpdateMmcHistoryL();
|
|
302 |
|
|
303 |
/**
|
|
304 |
* Get current MMC id. 0 if no MMC is inserted, or in case of any errors.
|
|
305 |
* @return Current MMC id, or 0.
|
|
306 |
*/
|
|
307 |
TUint CurrentMmcId() const;
|
|
308 |
|
|
309 |
/**
|
|
310 |
* Check if file is on given default drive type.
|
|
311 |
* @param aFileName File name.
|
|
312 |
* @return ETrue if aFileName is on given default drive type.
|
|
313 |
*/
|
|
314 |
TBool IsFileInDrive(
|
|
315 |
const TDesC& aFileName,
|
|
316 |
const DriveInfo::TDefaultDrives& aDefaultDrive ) const;
|
|
317 |
|
|
318 |
/**
|
|
319 |
* Check if application is installed on given drive type.
|
|
320 |
* @param aUid app uid.
|
|
321 |
* @param aDefaultDrive drive type.
|
|
322 |
* @return ETrue if app is installed on given drive type.
|
|
323 |
*/
|
|
324 |
TBool IsAppInDrive(
|
|
325 |
const CMenuSrvAppAttributes& aApaItem,
|
|
326 |
const DriveInfo::TDefaultDrives& aDefaultDrive ) const;
|
|
327 |
|
|
328 |
/**
|
|
329 |
* Check if application is installed on MMC.
|
|
330 |
* @param aUid app uid.
|
|
331 |
* @return ETrue if app is installed on MMC.
|
|
332 |
*/
|
|
333 |
TBool IsInMmc( const CMenuSrvAppAttributes& aApaItem ) const;
|
|
334 |
|
|
335 |
/**
|
|
336 |
* Check if application is installed on mass storage.
|
|
337 |
* @param aUid app uid.
|
|
338 |
* @return ETrue if app is installed on mass storage.
|
|
339 |
*/
|
|
340 |
TBool IsInMassStorage( const CMenuSrvAppAttributes& aApaItem ) const;
|
|
341 |
|
|
342 |
/**
|
|
343 |
* Check if application is installed on ROM.
|
|
344 |
* @param aUid app uid.
|
|
345 |
* @return ETrue if app is installed on ROM.
|
|
346 |
*/
|
|
347 |
TBool IsInRomL( const CMenuSrvAppAttributes& aApaItem ) const;
|
|
348 |
|
|
349 |
/**
|
|
350 |
* Check if drive's status is EDriveInUse.
|
|
351 |
* @param aDefaultDrive default drive type.
|
|
352 |
* @return ETrue if drive is in use.
|
|
353 |
*/
|
|
354 |
TBool IsDriveInUse(
|
|
355 |
const DriveInfo::TDefaultDrives& aDefaultDrive );
|
|
356 |
|
|
357 |
/**
|
|
358 |
TODO
|
|
359 |
*/
|
|
360 |
void HideItemIfPresentL( TInt aFolder, TInt aId, const TDesC& aUid, TBool aWasHidden );
|
|
361 |
|
|
362 |
/**
|
|
363 |
TODO
|
|
364 |
*/
|
|
365 |
void GetHiddenFlagAndUidL( TInt aId, TBool& aHidden, TPtrC& aUidStr );
|
|
366 |
|
|
367 |
/**
|
|
368 |
TODO
|
|
369 |
*/
|
|
370 |
void SetHiddenFlagL( TInt aId, TBool aWasHidden, TBool aHide );
|
|
371 |
|
|
372 |
/**
|
|
373 |
TODO
|
|
374 |
*/
|
|
375 |
void ValidateLinkUidL( TInt aFolder, TInt aId, const TDesC& aUidStr );
|
|
376 |
|
|
377 |
/**
|
|
378 |
TODO
|
|
379 |
*/
|
|
380 |
void UpdateLinkL( TInt aId, TBool aExists, TBool aShowItem, TBool aMissingItem );
|
|
381 |
|
|
382 |
/**
|
|
383 |
TODO
|
|
384 |
*/
|
|
385 |
void ValidateLinkRefIdL( TInt aId, const TDesC& refIdStr );
|
|
386 |
|
|
387 |
/**
|
|
388 |
TODO
|
|
389 |
*/
|
|
390 |
void ValidateLinkL( TInt aFolder, TInt aId );
|
|
391 |
|
|
392 |
/**
|
|
393 |
TODO
|
|
394 |
*/
|
|
395 |
void UpdateApplicationItemL(
|
|
396 |
RArray<TMenuItem>& aMcsItems,
|
|
397 |
const CMenuSrvAppAttributes& aApaItem,
|
|
398 |
TUint aMmcId,
|
|
399 |
TBool isLegacy );
|
|
400 |
|
|
401 |
/**
|
|
402 |
TODO
|
|
403 |
*/
|
|
404 |
void UpdateApplicationItemsL();
|
|
405 |
|
|
406 |
/**
|
|
407 |
TODO
|
|
408 |
*/
|
|
409 |
void UpdateApplicationWithHideIfInstalledItemsL();
|
|
410 |
|
|
411 |
/**
|
|
412 |
TODO
|
|
413 |
*/
|
|
414 |
void UpdateLinkItemsL();
|
|
415 |
|
|
416 |
|
|
417 |
private: // data
|
|
418 |
|
|
419 |
CMenuEng& iEng; ///< Engine.
|
|
420 |
CMenuSrvEngUtils& iSrvEngUtils; ///< Server engine utils.
|
|
421 |
CApaAppListNotifier* iNotifier; ///< Change notifier. Own.
|
|
422 |
CMenuSrvMmcHistory* iMmcHistory; ///< MMC history. Own.
|
|
423 |
RFs iFs; ///< File Server Session. 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 |
#endif // __MENUSRVAPPSCANNER_H__
|