85
|
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: casrvappscanner.h
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef CASRVAPPSCANNER_H_
|
|
19 |
#define CASRVAPPSCANNER_H_
|
|
20 |
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <apgcli.h>
|
|
23 |
#include <apgnotif.h>
|
|
24 |
#include <driveinfo.h>
|
|
25 |
#include "cainstallnotifier.h"
|
|
26 |
#include "castorage_global.h"
|
|
27 |
|
|
28 |
class TCaAppAtributes;
|
|
29 |
class CCaSrvMmcHistory;
|
|
30 |
class CCaInnerEntry;
|
|
31 |
class CCaStorageProxy;
|
|
32 |
class CCaSrvEngUtils;
|
|
33 |
namespace Swi
|
|
34 |
{
|
|
35 |
class RSisRegistryEntry;
|
|
36 |
}
|
|
37 |
|
|
38 |
/**
|
|
39 |
* Application scanner.
|
|
40 |
* Using AppArc application information, keeps menu application
|
|
41 |
* items up-to-date.
|
|
42 |
*
|
|
43 |
* Operation is asynchronous (because AppArc startup is asynchronous):
|
|
44 |
* 1. ConstructL(): invokes iApaLsSession to build app list (async).
|
|
45 |
* 2. RunL(): App list is complete - appscanner update entries with application.
|
|
46 |
* 4. HandleAppListEvent(): change in app list, go back to step 2.
|
|
47 |
*
|
|
48 |
* App scanning does the following:
|
|
49 |
* - Applications present in the system but not appearing in the menu are added
|
|
50 |
* to the appropriate folder.
|
|
51 |
* - Hide hidden applications, show non-hidden applications (flag "hidden").
|
|
52 |
* - Hide / show MMC-related items, according to whether MMC is present or not
|
|
53 |
* (flag "missing"). Keep an MMC history, purge old MMC-based menu items
|
|
54 |
* (== missing menu items whose MMC card has not been seen for long).
|
|
55 |
* - Observing AppArc (and MMC, etc etc) to keep the menu data up
|
|
56 |
* to date continuously.
|
|
57 |
*/
|
|
58 |
|
|
59 |
NONSHARABLE_CLASS( CCaSrvAppScanner ):
|
|
60 |
public CActive,
|
|
61 |
public MCaInstallListener,
|
|
62 |
public MApaAppListServObserver
|
|
63 |
{
|
|
64 |
|
|
65 |
public:
|
|
66 |
// Constructor
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Destructor.
|
|
70 |
*/
|
|
71 |
virtual ~CCaSrvAppScanner();
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Two-phased constructor.
|
|
75 |
* @param aCaStorageProxy storage.
|
|
76 |
* @param aUtils storage utils.
|
|
77 |
*/
|
|
78 |
static CCaSrvAppScanner* NewL( CCaStorageProxy& aCaStorageProxy,
|
|
79 |
CCaSrvEngUtils& aUtils );
|
|
80 |
|
|
81 |
private:
|
|
82 |
// Constructors and destructor
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Constructor.
|
|
86 |
* @param aCaStorageProxy storage.
|
|
87 |
* @param aUtils storage utils.
|
|
88 |
*/
|
|
89 |
CCaSrvAppScanner( CCaStorageProxy& aCaStorageProxy,
|
|
90 |
CCaSrvEngUtils& aUtils );
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Second phased constructor.
|
|
94 |
*/
|
|
95 |
void ConstructL();
|
|
96 |
|
|
97 |
public:
|
|
98 |
// from MCaInstallListener
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Handle Install Event.
|
|
102 |
* @since S60 v5.0
|
|
103 |
* @param aUid installed uid.
|
|
104 |
*/
|
|
105 |
void HandleInstallNotifyL( TInt aUid );
|
|
106 |
|
|
107 |
private:
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Notifies storage abaut change for aAppUid.
|
|
111 |
* @param aAppUid application uid.
|
|
112 |
*/
|
|
113 |
void NotifyL( TInt aAppUid );
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Notifies storage abaut change for aPackageEntry related app.
|
|
117 |
* @param aPackageEntry application package entry.
|
|
118 |
*/
|
|
119 |
void NotifyL( Swi::RSisRegistryEntry & aPackageEntry );
|
|
120 |
|
|
121 |
private:
|
|
122 |
// from CActive
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Request completed, schedule engine operation.
|
|
126 |
*/
|
|
127 |
void RunL();
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Cancel request.
|
|
131 |
*/
|
|
132 |
void DoCancel();
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Error handling: ignore error.
|
|
136 |
* @param aErr Error code.
|
|
137 |
*/
|
|
138 |
TInt RunError( TInt aError );
|
|
139 |
|
|
140 |
private:
|
|
141 |
// from MApaAppListServObserver
|
|
142 |
|
|
143 |
void HandleAppListEvent( TInt aEvent );
|
|
144 |
|
|
145 |
public:
|
|
146 |
/**
|
|
147 |
* Schedule appscanner run.
|
|
148 |
* Self complete active object.
|
|
149 |
*/
|
|
150 |
void ScheduleScan();
|
|
151 |
|
|
152 |
private:
|
|
153 |
// new methods
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Gets collectionId of download collection
|
|
157 |
* @result id of download collection
|
|
158 |
*/
|
|
159 |
TInt GetCollectionDownloadIdL();
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Adds application entry to downloaded collection
|
|
163 |
* @param aEntryId application entry id.
|
|
164 |
*/
|
|
165 |
void AddEntryToDownloadedCollectionL( TInt aEntryId );
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Removes application entry from downloaded collection
|
|
169 |
* @param aEntryId application entry id.
|
|
170 |
*/
|
|
171 |
void RemoveEntryFromDownloadedL( TInt aEntryId );
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Handles removal of stub items from download collection
|
|
175 |
* @param aEntryId application entry id.
|
|
176 |
*/
|
|
177 |
void HandleStubUpdatesL ();
|
|
178 |
|
|
179 |
TBool HandleLockDeleteFlagUpdateL( CCaInnerEntry* aItem );
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Updates application's missing attribute.
|
|
183 |
* Add new menu item referring to this application.
|
|
184 |
* @param aItem menu item.
|
|
185 |
* @return ETrue if missing flag was updated
|
|
186 |
*/
|
|
187 |
TBool HandleMissingFlagUpdate( CCaInnerEntry* aItem );
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Updates hidden flag.
|
|
191 |
* @param aItem menu item.
|
|
192 |
* @param aUid Application's uid.
|
|
193 |
* @return ETrue if hidden flag was updated
|
|
194 |
*/
|
|
195 |
TBool HandleHiddenFlagUpdateL( CCaInnerEntry* aItem );
|
|
196 |
|
|
197 |
/**
|
|
198 |
* Updates used flag.
|
|
199 |
* @param aItem menu item.
|
|
200 |
* @param aUid Application's uid.
|
|
201 |
* @return ETrue if used flag was updated
|
|
202 |
*/
|
|
203 |
TBool HandleUsedFlagUpdateL( CCaInnerEntry* aItem );
|
|
204 |
/**
|
|
205 |
* Updates mmc attribute.
|
|
206 |
* @param aItem menu item.
|
|
207 |
* @param aUid Application's uid.
|
|
208 |
* @param aMmcId MMC ID of currently inserted MMC, or 0.
|
|
209 |
* @return ETrue if mmc attribute was updated
|
|
210 |
*/
|
|
211 |
TBool HandleMmcAttrUpdateL( CCaInnerEntry* aItem, TUint aMmcId );
|
|
212 |
|
|
213 |
/**
|
|
214 |
* Check if application is in rom
|
|
215 |
* Add new menu item referring to this application.
|
|
216 |
* @param aUid uid applications
|
|
217 |
* @return ETrue if app is in rom
|
|
218 |
*/
|
|
219 |
TBool IsInRom( TInt aUid );
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Get applications from AppArc
|
|
223 |
* @param aArray RArray with applications
|
|
224 |
*/
|
|
225 |
void GetApaItemsL( RArray<TCaAppAtributes>& aArray );
|
|
226 |
|
|
227 |
/**
|
|
228 |
* Remove sat applications from array(found in AppArc)
|
|
229 |
* @param aArray RArray with application
|
|
230 |
*/
|
|
231 |
void RemoveSatApp( RArray<TCaAppAtributes>& aArray );
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Get applications from CaStorage
|
|
235 |
* @param aArray RPointerArray with CCaInnerEntries
|
|
236 |
* contains applications
|
|
237 |
*/
|
|
238 |
void GetCaAppEntriesL( RPointerArray<CCaInnerEntry>& aArray );
|
|
239 |
|
|
240 |
/**
|
|
241 |
* Remove sat application from array(found in CaStorage)
|
|
242 |
* @param aArray RPointerArray with CCaInnerEntries
|
|
243 |
* contains applications
|
|
244 |
*/
|
|
245 |
void RemoveSatAppL( RPointerArray<CCaInnerEntry>& aArray );
|
|
246 |
/**
|
|
247 |
* Get application with specified uid from CaStorage
|
|
248 |
* @param aUid RPointerArray with CCaInnerEntries
|
|
249 |
* @param aArray RPointerArray with CCaInnerEntries
|
|
250 |
* contains application
|
|
251 |
*/
|
|
252 |
void GetCaAppEntriesL( TInt aUid, RPointerArray<CCaInnerEntry>& aArray );
|
|
253 |
|
|
254 |
/**
|
|
255 |
* New application is found, no menu item refers to it.
|
|
256 |
* Add new menu item referring to this application.
|
|
257 |
* @param aUid Application capability.
|
|
258 |
* @param aCurrentMmcId MMC ID of currently inserted MMC, or 0.
|
|
259 |
*/
|
|
260 |
void AddAppEntryL( TUint aUid, TUint aCurrentMmcId );
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Removes given uid from iInstalledPackages.
|
|
264 |
* Add new menu item referring to this application.
|
|
265 |
* @param aUid Application capability.
|
|
266 |
*/
|
|
267 |
void RemoveFromInstalledPackages( TUint aUid );
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Set information from TApaAppInfo to entry
|
|
271 |
* @param aEntry CCaInnerEntry with application.
|
|
272 |
* @return ETrue if app info was updatedd
|
|
273 |
*/
|
|
274 |
TBool SetApaAppInfoL( CCaInnerEntry* aEntry );
|
|
275 |
|
|
276 |
/**
|
|
277 |
* Find the default folder (folder having attribute 'default="1"').
|
|
278 |
* If not found, return 0.
|
|
279 |
* @param aFolderId Dedault folder or 0.
|
|
280 |
*/
|
|
281 |
void DefaultFolderL( TInt& aFolderId );
|
|
282 |
|
|
283 |
/**
|
|
284 |
* Handle items are in the menu but no corresponding app is present:
|
|
285 |
* - Items that are on a recently used MMC are get "missing" flag but kept.
|
|
286 |
* - Items that are not on MMC or the MMC is not recently used, are
|
|
287 |
* removed form the menu.
|
|
288 |
* @param aItems Missing items.
|
|
289 |
*/
|
|
290 |
void HandleMissingItemsL( RPointerArray<CCaInnerEntry>& aCaEnties );
|
|
291 |
|
|
292 |
/**
|
|
293 |
* Removes app from storage.
|
|
294 |
* @param aAppEntry app to remove.
|
|
295 |
*/
|
|
296 |
void CCaSrvAppScanner::RemoveAppL( CCaInnerEntry* aAppEntry );
|
|
297 |
|
|
298 |
/**
|
|
299 |
* Adds flag objects(only one flag at time).
|
|
300 |
* @param aEntry entry.
|
|
301 |
* @param aFlag menu item's flag.
|
|
302 |
*/
|
|
303 |
void AddObjectFlagL( CCaInnerEntry* aEntry, const TInt& aFlag );
|
|
304 |
|
|
305 |
/**
|
|
306 |
* Check currently inserted MMC card, update and save MMC history.
|
|
307 |
* @return Current MMC id, or 0 if no MMC is inserted.
|
|
308 |
*/
|
|
309 |
TUint UpdateMmcHistoryL();
|
|
310 |
|
|
311 |
/**
|
|
312 |
* Get current MMC id. 0 if no MMC is inserted, or in case of any errors.
|
|
313 |
* @return Current MMC id, or 0.
|
|
314 |
*/
|
|
315 |
TUint CurrentMmcId() const;
|
|
316 |
|
|
317 |
/**
|
|
318 |
* Check if file is on given default drive type.
|
|
319 |
* @param aFileName File name.
|
|
320 |
* @return ETrue if aFileName is on given default drive type.
|
|
321 |
*/
|
|
322 |
TBool IsFileInDrive( const TDesC& aFileName,
|
|
323 |
const DriveInfo::TDefaultDrives& aDefaultDrive ) const;
|
|
324 |
|
|
325 |
/**
|
|
326 |
* Check if application is installed on given drive type.
|
|
327 |
* @param aUid app uid.
|
|
328 |
* @param aDefaultDrive drive type.
|
|
329 |
* @return ETrue if app is installed on given drive type.
|
|
330 |
*/
|
|
331 |
TBool IsAppInDrive( 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 IsInMmc( 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 IsInMassStorage( 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( const DriveInfo::TDefaultDrives& aDefaultDrive );
|
|
354 |
|
|
355 |
/**
|
|
356 |
* Add application to storage or update entry if necessary
|
|
357 |
* @param aCaEnties with applications from storage
|
|
358 |
* @param aApaItem application item with uid and hidden flag on or off
|
|
359 |
* @param aMmcId unique mmc id
|
|
360 |
*/
|
|
361 |
void UpdateApplicationEntryL( RPointerArray<CCaInnerEntry>& aCaEnties,
|
|
362 |
const TCaAppAtributes& aApaItem, TUint aMmcId );
|
|
363 |
|
|
364 |
/**
|
|
365 |
* Update entry from storage
|
|
366 |
* @param aEntry application entry
|
|
367 |
* @param aMmcId unique mmc id
|
|
368 |
*/
|
|
369 |
void UpdateAppEntryL( CCaInnerEntry* aEntry, TUint aMmcId );
|
|
370 |
|
|
371 |
/**
|
|
372 |
* Get all application from storage and visible from apparc
|
|
373 |
* and update if necessary
|
|
374 |
*/
|
|
375 |
void UpdateApplicationEntriesL();
|
|
376 |
|
|
377 |
/**
|
|
378 |
* Notifys storage abaut updated apps
|
|
379 |
*/
|
|
380 |
void InstallationNotifyL();
|
|
381 |
|
|
382 |
private:
|
|
383 |
// data
|
|
384 |
|
|
385 |
RApaLsSession iApaLsSession; ///< AppArc session. Own.
|
|
386 |
CApaAppListNotifier* iNotifier; ///< Change notifier. Own.
|
|
387 |
CCaInstallNotifier* iInstallNotifier;///< Install notifier. Own.
|
|
388 |
CCaSrvMmcHistory* iMmcHistory; ///< MMC history. Own.
|
|
389 |
RFs iFs; ///< File Server Session. Own.
|
|
390 |
|
|
391 |
CCaStorageProxy& iCaStorageProxy;///< not own
|
|
392 |
CCaSrvEngUtils& iSrvEngUtils;//<not own
|
|
393 |
RArray<TInt> iInstalledPackages;
|
|
394 |
|
|
395 |
TInt iCollectionDownloadId;
|
|
396 |
CA_STORAGE_TEST_FRIEND_CLASS (T_casrvAppScaner)
|
|
397 |
|
|
398 |
};
|
|
399 |
|
|
400 |
/**
|
|
401 |
* Application atributes.
|
|
402 |
* Object contains uid and hidden flag
|
|
403 |
*/
|
|
404 |
class TCaAppAtributes
|
|
405 |
{
|
|
406 |
|
|
407 |
public:
|
|
408 |
/**
|
|
409 |
* Constructor.
|
|
410 |
* @param aUid uid application.
|
|
411 |
*/
|
|
412 |
TCaAppAtributes( TUint aUid );
|
|
413 |
|
|
414 |
/*
|
|
415 |
* Get uid
|
|
416 |
* @return application uid
|
|
417 |
*/
|
|
418 |
TUint GetUid() const;
|
|
419 |
|
|
420 |
/*
|
|
421 |
* Match application items
|
|
422 |
* @param item1 first item to matching.
|
|
423 |
* @param item2 second item to matching.
|
|
424 |
*/
|
|
425 |
static TBool MatchItems( const TCaAppAtributes& item1,
|
|
426 |
const TCaAppAtributes& item2 );
|
|
427 |
|
|
428 |
private:
|
|
429 |
// data
|
|
430 |
|
|
431 |
TUint iUid;///< uid application
|
|
432 |
|
|
433 |
};
|
|
434 |
|
|
435 |
#endif /* CASRVAPPSCANNER_H_ */
|