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.cpp
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <e32property.h>
|
|
19 |
#include <bautils.h>
|
|
20 |
#include <swi/sisregistrysession.h>
|
|
21 |
#include <swi/sisregistryentry.h>
|
|
22 |
#include <swi/sisregistrypackage.h>
|
94
|
23 |
#include <usif/scr/screntries.h>
|
85
|
24 |
|
|
25 |
#include "cadef.h"
|
|
26 |
#include "casrvappscanner.h"
|
|
27 |
#include "cautils.h"
|
|
28 |
#include "casrvmmchistory.h"
|
|
29 |
#include "pathinfo.h"
|
|
30 |
#include "casrvengutils.h"
|
|
31 |
#include "cainnerquery.h"
|
|
32 |
#include "cainnerentry.h"
|
|
33 |
#include "caarraycleanup.inl"
|
|
34 |
#include "castorageproxy.h"
|
|
35 |
|
94
|
36 |
#include "caarraycleanup.inl"
|
92
|
37 |
|
94
|
38 |
using namespace Usif;
|
92
|
39 |
|
85
|
40 |
// ==================== LOCAL FUNCTIONS ====================
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Identity function to search in an array of CCaInnerEntry.
|
|
44 |
* Identity is the ID.
|
|
45 |
* @param aLeft Search term.
|
|
46 |
* @param aRight Array item.
|
|
47 |
* @return ETrue if ID-s match.
|
|
48 |
*/
|
|
49 |
LOCAL_C TBool IdMatch( const CCaInnerEntry& aLeft,
|
|
50 |
const CCaInnerEntry& aRight )
|
|
51 |
{
|
|
52 |
return aLeft.GetId() == aRight.GetId();
|
|
53 |
}
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Identity function to search in an array of CCaInnerEntry.
|
|
57 |
* Identity is the ID.
|
|
58 |
* @param aLeft Search term.
|
|
59 |
* @param aRight Array item.
|
|
60 |
* @return ETrue if ID-s match.
|
|
61 |
*/
|
|
62 |
LOCAL_C TBool UidMatch( const CCaInnerEntry& aLeft,
|
|
63 |
const CCaInnerEntry& aRight )
|
|
64 |
{
|
|
65 |
return aLeft.GetUid() == aRight.GetUid();
|
|
66 |
}
|
|
67 |
|
|
68 |
// ==================== MEMBER FUNCTIONS ====================
|
|
69 |
|
|
70 |
// ---------------------------------------------------------
|
94
|
71 |
//
|
85
|
72 |
// ---------------------------------------------------------
|
|
73 |
//
|
|
74 |
CCaSrvAppScanner* CCaSrvAppScanner::NewL( CCaStorageProxy& aCaStorageProxy,
|
|
75 |
CCaSrvEngUtils& aUtils )
|
|
76 |
{
|
|
77 |
CCaSrvAppScanner* scanner = new ( ELeave ) CCaSrvAppScanner(
|
|
78 |
aCaStorageProxy, aUtils );
|
|
79 |
CleanupStack::PushL( scanner );
|
|
80 |
scanner->ConstructL();
|
|
81 |
CleanupStack::Pop( scanner );
|
|
82 |
return scanner;
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------
|
94
|
86 |
//
|
85
|
87 |
// ---------------------------------------------------------
|
|
88 |
//
|
|
89 |
CCaSrvAppScanner::~CCaSrvAppScanner()
|
|
90 |
{
|
|
91 |
Cancel();
|
94
|
92 |
iSoftwareRegistry.Close();
|
85
|
93 |
iApaLsSession.Close();
|
|
94 |
iInstalledPackages.Close();
|
|
95 |
delete iInstallNotifier;
|
|
96 |
delete iNotifier;
|
|
97 |
delete iMmcHistory;
|
|
98 |
iFs.Close();
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------
|
94
|
102 |
//
|
85
|
103 |
// ---------------------------------------------------------
|
|
104 |
//
|
|
105 |
CCaSrvAppScanner::CCaSrvAppScanner( CCaStorageProxy& aCaStorageProxy,
|
|
106 |
CCaSrvEngUtils& aUtils ) :
|
|
107 |
CActive( CActive::EPriorityStandard ),
|
|
108 |
iCaStorageProxy( aCaStorageProxy ), iSrvEngUtils( aUtils )
|
|
109 |
{
|
|
110 |
CActiveScheduler::Add( this );
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------
|
94
|
114 |
//
|
85
|
115 |
// ---------------------------------------------------------
|
|
116 |
//
|
|
117 |
void CCaSrvAppScanner::ConstructL()
|
|
118 |
{
|
|
119 |
User::LeaveIfError( iFs.Connect() );
|
|
120 |
TFileName path;
|
|
121 |
User::LeaveIfError( iFs.PrivatePath( path ) );
|
|
122 |
TUint attribute;
|
94
|
123 |
if( iFs.Att( path, attribute ) == KErrNotFound )
|
85
|
124 |
{
|
|
125 |
TInt mdRes = iFs.MkDirAll( path );
|
|
126 |
if ( mdRes != KErrNone )
|
|
127 |
{
|
|
128 |
User::Leave( mdRes );
|
|
129 |
}
|
|
130 |
}
|
94
|
131 |
iMmcHistory = CCaSrvMmcHistory::NewL();
|
85
|
132 |
iMmcHistory->LoadL( iFs, KCaMmcHistoryFname() );
|
|
133 |
iNotifier = CApaAppListNotifier::NewL(
|
|
134 |
this, CActive::EPriorityStandard );
|
|
135 |
iInstallNotifier = CCaInstallNotifier::NewL(
|
|
136 |
*this, CCaInstallNotifier::ESisInstallNotification );
|
|
137 |
|
|
138 |
User::LeaveIfError( iApaLsSession.Connect() );
|
|
139 |
User::LeaveIfError( iApaLsSession.GetAllApps() ); // This is async.
|
94
|
140 |
User::LeaveIfError( iSoftwareRegistry.Connect() );
|
85
|
141 |
iApaLsSession.RegisterListPopulationCompleteObserver( iStatus );
|
|
142 |
iCollectionDownloadId = 0;
|
92
|
143 |
iAllCollectionId = 0;
|
85
|
144 |
SetActive();
|
|
145 |
}
|
|
146 |
|
|
147 |
// ---------------------------------------------------------
|
94
|
148 |
//
|
85
|
149 |
// ---------------------------------------------------------
|
|
150 |
//
|
|
151 |
void CCaSrvAppScanner::RunL()
|
|
152 |
{
|
94
|
153 |
User::LeaveIfError( iStatus.Int() );
|
85
|
154 |
// AppArc app scan complete, we have the app list.
|
|
155 |
UpdateApplicationEntriesL();
|
|
156 |
InstallationNotifyL();
|
92
|
157 |
MakeNotEmptyCollectionsVisibleL();
|
85
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------
|
94
|
161 |
//
|
85
|
162 |
// ---------------------------------------------------------
|
|
163 |
//
|
|
164 |
void CCaSrvAppScanner::DoCancel()
|
|
165 |
{
|
|
166 |
iApaLsSession.CancelListPopulationCompleteObserver();
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------
|
94
|
170 |
//
|
85
|
171 |
// ---------------------------------------------------------
|
|
172 |
//
|
|
173 |
TInt CCaSrvAppScanner::RunError( TInt /*aError*/)
|
|
174 |
{
|
|
175 |
// Ignore the error (what else could we do?).
|
94
|
176 |
// When next update occurs, we will run again.
|
85
|
177 |
return KErrNone;
|
|
178 |
}
|
|
179 |
|
|
180 |
// ---------------------------------------------------------
|
94
|
181 |
//
|
85
|
182 |
// ---------------------------------------------------------
|
|
183 |
//
|
|
184 |
void CCaSrvAppScanner::UpdateApplicationEntryL(
|
|
185 |
RPointerArray<CCaInnerEntry>& aCaEntries,
|
94
|
186 |
TUint aAppUid, TUint aMmcId )
|
85
|
187 |
{
|
|
188 |
RPointerArray<CCaInnerEntry> resultArray;
|
|
189 |
CleanupResetAndDestroyPushL( resultArray );
|
94
|
190 |
GetCaAppEntriesL( aAppUid, resultArray );
|
85
|
191 |
|
|
192 |
// This app is not in the storage, add it now.
|
|
193 |
// We don't add hidden items, there are too many of them!
|
|
194 |
// do not display Menu app
|
87
|
195 |
if( !resultArray.Count() )
|
85
|
196 |
{
|
94
|
197 |
AddAppEntryL( aAppUid, aMmcId );
|
85
|
198 |
}//if
|
|
199 |
|
87
|
200 |
// "removable", "missing" and "visible" flags update
|
85
|
201 |
for( TInt j = 0; j < resultArray.Count(); j++ )
|
|
202 |
{
|
94
|
203 |
//We need to handle first run of appscanner,
|
|
204 |
//there might be some incorrect data. If this will have impact
|
|
205 |
//on performance we may run this methods only at start up.
|
85
|
206 |
|
|
207 |
UpdateAppEntryL( resultArray[j], aMmcId );
|
|
208 |
TInt index = aCaEntries.Find( resultArray[j],
|
|
209 |
TIdentityRelation<CCaInnerEntry>( IdMatch ) );
|
|
210 |
if( index != KErrNotFound )
|
|
211 |
{
|
|
212 |
delete aCaEntries[index];
|
|
213 |
aCaEntries.Remove( index );
|
|
214 |
}
|
|
215 |
}//for
|
|
216 |
CleanupStack::PopAndDestroy( &resultArray );
|
|
217 |
}
|
|
218 |
|
|
219 |
// ---------------------------------------------------------
|
94
|
220 |
//
|
85
|
221 |
// ---------------------------------------------------------
|
|
222 |
//
|
|
223 |
void CCaSrvAppScanner::UpdateAppEntryL( CCaInnerEntry* aEntry, TUint aMmcId )
|
|
224 |
{
|
|
225 |
TBool toUpdate = HandleMmcAttrUpdateL( aEntry, aMmcId );
|
93
|
226 |
TBool missingVisibleFlagChanged =
|
|
227 |
HandleMissingVisibleFlagsUpdate( aEntry );
|
|
228 |
toUpdate = missingVisibleFlagChanged || toUpdate;
|
94
|
229 |
toUpdate = HandleRemovableVisibleFlagsUpdateL( aEntry ) || toUpdate;
|
85
|
230 |
toUpdate = SetApaAppInfoL( aEntry ) || toUpdate;
|
94
|
231 |
|
85
|
232 |
if( iInstalledPackages.Find( aEntry->GetUid() ) != KErrNotFound )
|
|
233 |
{
|
|
234 |
AddEntryToDownloadedCollectionL( aEntry->GetId() );
|
93
|
235 |
toUpdate = HandleUsedFlagUpdate( aEntry ) || toUpdate;
|
|
236 |
AddEntryToPredefinedCollectionL( aEntry, ETrue );
|
85
|
237 |
}
|
|
238 |
if( toUpdate )
|
|
239 |
{
|
|
240 |
//update app in storage
|
93
|
241 |
TItemAppearance itemAppearanceChange = EItemAppearanceNotChanged;
|
|
242 |
if( missingVisibleFlagChanged )
|
|
243 |
{
|
|
244 |
itemAppearanceChange = EItemAppeared;
|
|
245 |
}
|
|
246 |
iCaStorageProxy.AddL( aEntry, EFalse, itemAppearanceChange );
|
85
|
247 |
RemoveFromInstalledPackages( aEntry->GetUid() );
|
|
248 |
}
|
|
249 |
}
|
94
|
250 |
|
|
251 |
// ---------------------------------------------------------
|
|
252 |
//
|
|
253 |
// ---------------------------------------------------------
|
|
254 |
//
|
|
255 |
TBool CCaSrvAppScanner::HandleMmcAttrUpdateL(
|
|
256 |
CCaInnerEntry* aItem, TUint aMmcId )
|
|
257 |
{
|
|
258 |
TBool toUpdate( ETrue );
|
|
259 |
if( IsInMmcL( TUid::Uid( aItem->GetUid() ) ) )
|
|
260 |
{
|
|
261 |
//app is instaled on mmc - KCaAttrMmcId attribute update
|
|
262 |
RBuf uidString;
|
|
263 |
uidString.CleanupClosePushL();
|
|
264 |
uidString.CreateL(KUidChars);
|
|
265 |
uidString.Format( KHexFormat, aMmcId );
|
|
266 |
aItem->AddAttributeL( KCaAttrMmcId, uidString );
|
|
267 |
CleanupStack::PopAndDestroy( &uidString );
|
|
268 |
}
|
|
269 |
else if ( IsInMassStorageL( TUid::Uid( aItem->GetUid() ) ) )
|
|
270 |
{
|
|
271 |
//its app installed on mass storage, we need to leave it
|
|
272 |
//in case of connecting usb in mass storage mode
|
|
273 |
aItem->AddAttributeL( KCaAttrMmcId, KCaMassStorage );
|
|
274 |
}
|
|
275 |
else
|
|
276 |
{
|
|
277 |
RBuf attrVal;
|
|
278 |
attrVal.CleanupClosePushL();
|
|
279 |
attrVal.CreateL( KCaMaxAttrValueLen );
|
|
280 |
if( aItem->FindAttribute( KCaAttrMmcId, attrVal ) )
|
|
281 |
{
|
|
282 |
aItem->RemoveAttributeL( KCaAttrMmcId );
|
|
283 |
}
|
|
284 |
else
|
|
285 |
{
|
|
286 |
toUpdate = EFalse;
|
|
287 |
}
|
|
288 |
CleanupStack::PopAndDestroy( &attrVal );
|
|
289 |
//its installed on c: drive - remove attribute
|
|
290 |
}
|
|
291 |
return toUpdate;
|
|
292 |
}
|
|
293 |
|
|
294 |
// ---------------------------------------------------------
|
|
295 |
//
|
|
296 |
// ---------------------------------------------------------
|
|
297 |
//
|
|
298 |
void CCaSrvAppScanner::InstallationNotifyL()
|
|
299 |
{
|
|
300 |
for( TInt i = iInstalledPackages.Count() - 1; i >= 0; i-- )
|
|
301 |
{
|
|
302 |
NotifyL( iInstalledPackages[i] );
|
|
303 |
iInstalledPackages.Remove( i );
|
|
304 |
}
|
|
305 |
}
|
|
306 |
|
|
307 |
// ---------------------------------------------------------
|
|
308 |
//
|
|
309 |
// ---------------------------------------------------------
|
|
310 |
//
|
|
311 |
void CCaSrvAppScanner::UpdateApplicationEntriesL()
|
|
312 |
{
|
|
313 |
TUint currentMmcId = UpdateMmcHistoryL();
|
|
314 |
// get all Content arsenal enties with type application
|
|
315 |
RPointerArray<CCaInnerEntry> resultArray;
|
|
316 |
CleanupResetAndDestroyPushL( resultArray );
|
|
317 |
GetCaAppEntriesL( resultArray );
|
|
318 |
HandleHsAppEntryL( resultArray );
|
|
319 |
RemoveSatAppL( resultArray );
|
|
320 |
|
|
321 |
RArray<TUint> appUids;
|
|
322 |
CleanupClosePushL( appUids );
|
|
323 |
GetApaItemsL( appUids );
|
|
324 |
RemoveApp( appUids, KSatUid.iUid );
|
|
325 |
RemoveApp( appUids, KHsAppUid.iUid );
|
|
326 |
|
|
327 |
//for every item in apaAndCrItems array
|
|
328 |
for( TInt i = 0; i < appUids.Count(); i++ )
|
|
329 |
{
|
|
330 |
// if there was leave for any item we ignore it
|
|
331 |
// and proceed to the next one
|
|
332 |
TRAP_IGNORE(UpdateApplicationEntryL(
|
|
333 |
resultArray, appUids[i], currentMmcId));
|
|
334 |
}
|
|
335 |
// Here the big list with items that refer to missing apps.
|
|
336 |
HandleMissingItemsL( resultArray );
|
|
337 |
CleanupStack::PopAndDestroy( &appUids );
|
|
338 |
CleanupStack::PopAndDestroy( &resultArray );
|
|
339 |
}
|
|
340 |
|
|
341 |
// ---------------------------------------------------------
|
|
342 |
//
|
|
343 |
// ---------------------------------------------------------
|
|
344 |
//
|
|
345 |
TBool CCaSrvAppScanner::HandleRemovableVisibleFlagsUpdateL(
|
|
346 |
CCaInnerEntry* aItem )
|
|
347 |
{
|
|
348 |
TBool toChange( EFalse );
|
|
349 |
if( ( aItem->GetFlags() & EVisible ) && IsInRomL( aItem->GetUid() ) )
|
|
350 |
{
|
|
351 |
if( ( aItem->GetFlags() & ERemovable ) != 0 )
|
|
352 |
{
|
|
353 |
aItem->SetFlags( aItem->GetFlags() & ~ERemovable );
|
|
354 |
toChange = ETrue;
|
|
355 |
}
|
|
356 |
}
|
|
357 |
else
|
|
358 |
{
|
|
359 |
if( ( aItem->GetFlags() & ERemovable ) == 0 )
|
|
360 |
{
|
|
361 |
aItem->SetFlags( aItem->GetFlags() | ERemovable );
|
|
362 |
toChange = ETrue;
|
|
363 |
}
|
|
364 |
}
|
|
365 |
return toChange;
|
|
366 |
}
|
|
367 |
|
|
368 |
// ---------------------------------------------------------
|
|
369 |
//
|
|
370 |
// ---------------------------------------------------------
|
|
371 |
//
|
|
372 |
TBool CCaSrvAppScanner::HandleMissingVisibleFlagsUpdate(
|
|
373 |
CCaInnerEntry* aItem )
|
|
374 |
{
|
|
375 |
TBool ret( EFalse );
|
|
376 |
if( aItem->GetFlags() & EMissing ||
|
|
377 |
!( aItem->GetFlags() & EVisible ) )
|
|
378 |
{
|
|
379 |
//application found so we unset "missing" and set "visible" flags
|
|
380 |
aItem->SetFlags( aItem->GetFlags() & ~EMissing | EVisible );
|
|
381 |
ret = ETrue;
|
|
382 |
}
|
|
383 |
return ret;
|
|
384 |
}
|
|
385 |
|
85
|
386 |
// ---------------------------------------------------------
|
93
|
387 |
//
|
85
|
388 |
// ---------------------------------------------------------
|
|
389 |
//
|
93
|
390 |
TBool CCaSrvAppScanner::HandleVisibleFlagUpdate( CCaInnerEntry* aItem )
|
85
|
391 |
{
|
|
392 |
TBool toChange( EFalse );
|
93
|
393 |
if( !( aItem->GetFlags() & EVisible ) )
|
85
|
394 |
{
|
|
395 |
aItem->SetFlags( aItem->GetFlags() | EVisible );
|
|
396 |
toChange = ETrue;
|
|
397 |
}
|
|
398 |
return toChange;
|
|
399 |
}
|
|
400 |
|
|
401 |
// ---------------------------------------------------------
|
93
|
402 |
//
|
85
|
403 |
// ---------------------------------------------------------
|
|
404 |
//
|
93
|
405 |
TBool CCaSrvAppScanner::HandleUsedFlagUpdate( CCaInnerEntry* aItem )
|
85
|
406 |
{
|
93
|
407 |
TBool changed( EFalse );
|
85
|
408 |
if( aItem->GetFlags() & EUsed )
|
|
409 |
{
|
|
410 |
aItem->SetFlags( aItem->GetFlags() & ~EUsed );
|
93
|
411 |
changed = ETrue;
|
85
|
412 |
}
|
93
|
413 |
return changed;
|
85
|
414 |
}
|
|
415 |
|
|
416 |
// ---------------------------------------------------------
|
|
417 |
//
|
|
418 |
// ---------------------------------------------------------
|
|
419 |
//
|
94
|
420 |
void CCaSrvAppScanner::RemoveApp( RArray<TUint>& aArray, TInt32 aUid )
|
85
|
421 |
{
|
94
|
422 |
TInt id = aArray.Find( aUid );
|
85
|
423 |
if( id != KErrNotFound )
|
|
424 |
{
|
|
425 |
aArray.Remove( id );
|
|
426 |
}
|
|
427 |
}
|
|
428 |
|
|
429 |
// ---------------------------------------------------------
|
94
|
430 |
//
|
85
|
431 |
// ---------------------------------------------------------
|
|
432 |
//
|
|
433 |
void CCaSrvAppScanner::RemoveSatAppL( RPointerArray<CCaInnerEntry>& aArray )
|
|
434 |
{
|
|
435 |
CCaInnerEntry* sat = CCaInnerEntry::NewL();
|
|
436 |
sat->SetUid( KSatUid.iUid );
|
|
437 |
TInt index = aArray.Find(
|
|
438 |
sat, TIdentityRelation<CCaInnerEntry>( UidMatch ) );
|
|
439 |
if ( index != KErrNotFound )
|
|
440 |
{
|
|
441 |
delete aArray[index];
|
|
442 |
aArray.Remove( index );
|
|
443 |
}
|
|
444 |
delete sat;
|
|
445 |
}
|
|
446 |
|
|
447 |
// ---------------------------------------------------------
|
94
|
448 |
//
|
87
|
449 |
// ---------------------------------------------------------
|
|
450 |
//
|
94
|
451 |
void CCaSrvAppScanner::HandleHsAppEntryL(
|
|
452 |
RPointerArray<CCaInnerEntry>& aArray )
|
87
|
453 |
{
|
|
454 |
CCaInnerEntry* appEntry = CCaInnerEntry::NewLC();
|
|
455 |
appEntry->SetUid( KHsAppUid.iUid );
|
|
456 |
TInt index = aArray.Find(
|
|
457 |
appEntry, TIdentityRelation<CCaInnerEntry>( UidMatch ) );
|
92
|
458 |
|
87
|
459 |
if ( index != KErrNotFound )
|
93
|
460 |
{
|
|
461 |
// hs app already in storage - ensure it is hidden
|
|
462 |
// and remove from resultArray
|
|
463 |
if ( aArray[index]->GetFlags() & EVisible )
|
87
|
464 |
{
|
|
465 |
aArray[index]->SetFlags( aArray[index]->GetFlags() & ~EVisible);
|
93
|
466 |
iCaStorageProxy.AddL( aArray[index], EFalse, EItemDisappeared );
|
92
|
467 |
}
|
87
|
468 |
delete aArray[index];
|
92
|
469 |
aArray.Remove( index );
|
87
|
470 |
}
|
|
471 |
else
|
93
|
472 |
{
|
|
473 |
// if not found add as not visible to the storage
|
87
|
474 |
appEntry->SetEntryTypeNameL( KCaTypeApp );
|
92
|
475 |
appEntry->SetFlags( 0 );
|
87
|
476 |
appEntry->SetRole( EItemEntryRole );
|
|
477 |
SetApaAppInfoL( appEntry );
|
|
478 |
iCaStorageProxy.AddL( appEntry );
|
|
479 |
}
|
|
480 |
CleanupStack::PopAndDestroy( appEntry );
|
|
481 |
}
|
|
482 |
|
|
483 |
|
|
484 |
// ---------------------------------------------------------
|
94
|
485 |
//
|
85
|
486 |
// ---------------------------------------------------------
|
|
487 |
//
|
94
|
488 |
void CCaSrvAppScanner::GetApaItemsL( RArray<TUint>& aArray )
|
85
|
489 |
{
|
94
|
490 |
TApaAppInfo* appInfo = new ( ELeave ) TApaAppInfo();
|
92
|
491 |
CleanupStack::PushL(appInfo);
|
85
|
492 |
TApaAppCapabilityBuf appCap;
|
|
493 |
|
|
494 |
User::LeaveIfError( iApaLsSession.GetAllApps( 0 ) );
|
|
495 |
// for every application get uid, hidden and missing attribute
|
|
496 |
// and add to aArray.
|
92
|
497 |
while( KErrNone == iApaLsSession.GetNextApp( *appInfo ) )
|
85
|
498 |
{
|
|
499 |
User::LeaveIfError( iApaLsSession.GetAppCapability(
|
92
|
500 |
appCap, appInfo->iUid ) );
|
85
|
501 |
// "Hidden" status according to AppArc.
|
|
502 |
if( !appCap().iAppIsHidden )
|
|
503 |
{
|
94
|
504 |
aArray.AppendL( appInfo->iUid.iUid );
|
85
|
505 |
}
|
|
506 |
}
|
92
|
507 |
CleanupStack::PopAndDestroy(appInfo);
|
85
|
508 |
}
|
|
509 |
|
|
510 |
// ---------------------------------------------------------
|
94
|
511 |
//
|
85
|
512 |
// ---------------------------------------------------------
|
|
513 |
//
|
|
514 |
void CCaSrvAppScanner::GetCaAppEntriesL(
|
|
515 |
RPointerArray<CCaInnerEntry>& aArray )
|
|
516 |
{
|
|
517 |
CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC();
|
94
|
518 |
CDesC16ArrayFlat* appType =
|
|
519 |
new ( ELeave ) CDesC16ArrayFlat( KGranularityOne );
|
85
|
520 |
CleanupStack::PushL( appType );
|
|
521 |
appType->AppendL( KCaTypeApp );
|
|
522 |
allAppQuery->SetEntryTypeNames( appType );
|
|
523 |
CleanupStack::Pop( appType );
|
|
524 |
iCaStorageProxy.GetEntriesL( allAppQuery, aArray );
|
|
525 |
CleanupStack::PopAndDestroy( allAppQuery );
|
|
526 |
}
|
|
527 |
|
|
528 |
// ---------------------------------------------------------
|
94
|
529 |
//
|
85
|
530 |
// ---------------------------------------------------------
|
|
531 |
//
|
|
532 |
TInt CCaSrvAppScanner::GetCollectionDownloadIdL()
|
|
533 |
{
|
|
534 |
if( iCollectionDownloadId == 0 )
|
|
535 |
{
|
|
536 |
RPointerArray<CCaInnerEntry> resultArray;
|
|
537 |
CleanupResetAndDestroyPushL( resultArray );
|
|
538 |
CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC();
|
94
|
539 |
CDesC16ArrayFlat* appType =
|
|
540 |
new ( ELeave ) CDesC16ArrayFlat( KGranularityOne );
|
85
|
541 |
CleanupStack::PushL( appType );
|
|
542 |
appType->AppendL( KCaTypeCollectionDownload );
|
|
543 |
allAppQuery->SetEntryTypeNames( appType );
|
|
544 |
CleanupStack::Pop( appType );
|
|
545 |
iCaStorageProxy.GetEntriesL( allAppQuery, resultArray );
|
|
546 |
CleanupStack::PopAndDestroy( allAppQuery );
|
|
547 |
if( resultArray.Count() )
|
|
548 |
{
|
|
549 |
iCollectionDownloadId = resultArray[0]->GetId();
|
|
550 |
}
|
|
551 |
CleanupStack::PopAndDestroy( &resultArray );
|
|
552 |
}
|
|
553 |
return iCollectionDownloadId;
|
|
554 |
}
|
|
555 |
|
|
556 |
// ---------------------------------------------------------
|
94
|
557 |
//
|
92
|
558 |
// ---------------------------------------------------------
|
|
559 |
//
|
|
560 |
TInt CCaSrvAppScanner::GetAllCollectionIdL()
|
|
561 |
{
|
|
562 |
if( iAllCollectionId == 0 )
|
|
563 |
{
|
|
564 |
CCaInnerQuery *getAllCollectionIdQuery = CCaInnerQuery::NewLC();
|
|
565 |
CDesC16ArrayFlat *typenameArray = new(ELeave) CDesC16ArrayFlat(
|
94
|
566 |
KGranularityOne );
|
92
|
567 |
CleanupStack::PushL( typenameArray );
|
|
568 |
typenameArray->AppendL( KCaTypeMenuCollections );
|
|
569 |
getAllCollectionIdQuery->SetEntryTypeNames( typenameArray );
|
|
570 |
CleanupStack::Pop( typenameArray );
|
93
|
571 |
|
92
|
572 |
RArray<TInt> idArray;
|
|
573 |
CleanupClosePushL( idArray );
|
|
574 |
iCaStorageProxy.GetEntriesIdsL( getAllCollectionIdQuery,
|
|
575 |
idArray );
|
|
576 |
if( idArray.Count() )
|
|
577 |
{
|
|
578 |
iAllCollectionId = idArray[0];
|
|
579 |
}
|
|
580 |
CleanupStack::PopAndDestroy( &idArray );
|
|
581 |
CleanupStack::PopAndDestroy( getAllCollectionIdQuery );
|
|
582 |
}
|
|
583 |
return iAllCollectionId;
|
|
584 |
}
|
|
585 |
|
|
586 |
// ---------------------------------------------------------
|
94
|
587 |
//
|
85
|
588 |
// ---------------------------------------------------------
|
|
589 |
//
|
|
590 |
void CCaSrvAppScanner::GetCaAppEntriesL( TInt aUid,
|
|
591 |
RPointerArray<CCaInnerEntry>& aArray )
|
|
592 |
{
|
|
593 |
CCaInnerQuery* allAppQuery = CCaInnerQuery::NewLC();
|
|
594 |
allAppQuery->SetUid( aUid );
|
|
595 |
iCaStorageProxy.GetEntriesL( allAppQuery, aArray );
|
|
596 |
CleanupStack::PopAndDestroy( allAppQuery );
|
|
597 |
}
|
|
598 |
|
|
599 |
// ---------------------------------------------------------
|
94
|
600 |
//
|
85
|
601 |
// ---------------------------------------------------------
|
|
602 |
//
|
|
603 |
void CCaSrvAppScanner::HandleAppListEvent( TInt /*aEvent*/)
|
|
604 |
{
|
|
605 |
// We only have one event, EAppListChanged.
|
|
606 |
// Call back RunL async, to requeue and initiate rescan.
|
|
607 |
if( !IsActive() )
|
|
608 |
{
|
|
609 |
ScheduleScan();
|
|
610 |
}
|
|
611 |
}
|
|
612 |
|
|
613 |
// ---------------------------------------------------------
|
94
|
614 |
//
|
85
|
615 |
// ---------------------------------------------------------
|
|
616 |
//
|
|
617 |
void CCaSrvAppScanner::HandleInstallNotifyL( TInt aUid )
|
|
618 |
{
|
|
619 |
NotifyL( aUid );
|
|
620 |
RArray<TUid> uids;
|
|
621 |
CleanupClosePushL( uids );
|
|
622 |
|
|
623 |
Swi::RSisRegistrySession iSisRegSession;
|
94
|
624 |
CleanupClosePushL( iSisRegSession );
|
85
|
625 |
User::LeaveIfError( iSisRegSession.Connect() );
|
|
626 |
|
|
627 |
// Open sis package entry related to aUid
|
|
628 |
Swi::RSisRegistryEntry packageEntry;
|
|
629 |
if( KErrNone
|
|
630 |
== packageEntry.Open( iSisRegSession, TUid::Uid( aUid ) ) )
|
|
631 |
{
|
|
632 |
CleanupClosePushL( packageEntry );
|
|
633 |
|
|
634 |
// Get packageEntry's embedded sis'
|
|
635 |
RPointerArray<Swi::CSisRegistryPackage> embedded;
|
94
|
636 |
CleanupResetAndDestroyPushL( embedded );
|
85
|
637 |
packageEntry.EmbeddedPackagesL( embedded );
|
|
638 |
if( embedded.Count() )
|
|
639 |
{
|
|
640 |
// For each embadded sis we notify storage - recursive call
|
|
641 |
for( TInt i = 0; i < embedded.Count(); ++i )
|
|
642 |
{
|
|
643 |
HandleInstallNotifyL( embedded[i]->Uid().iUid );
|
|
644 |
}
|
|
645 |
}
|
|
646 |
else
|
|
647 |
{
|
|
648 |
// There are no embaddes sis', so we can notify storage
|
|
649 |
// of changes in apps included in packageEntry
|
|
650 |
NotifyL( packageEntry );
|
|
651 |
}
|
|
652 |
CleanupStack::PopAndDestroy( &embedded );
|
|
653 |
CleanupStack::PopAndDestroy( &packageEntry );
|
|
654 |
}
|
|
655 |
CleanupStack::PopAndDestroy( &iSisRegSession );
|
|
656 |
CleanupStack::PopAndDestroy( &uids );
|
|
657 |
}
|
|
658 |
|
|
659 |
// ---------------------------------------------------------
|
94
|
660 |
//
|
85
|
661 |
// ---------------------------------------------------------
|
|
662 |
//
|
|
663 |
void CCaSrvAppScanner::NotifyL( Swi::RSisRegistryEntry & aPackageEntry )
|
|
664 |
{
|
|
665 |
// Get sids ( == uids of exetucables included in aPackageEntry )
|
|
666 |
RArray<TUid> sids;
|
|
667 |
CleanupClosePushL( sids );
|
|
668 |
aPackageEntry.SidsL( sids );
|
|
669 |
if( sids.Count() )
|
|
670 |
{
|
|
671 |
// For each sid we notify storage
|
|
672 |
for( TInt i = 0; i < sids.Count(); ++i )
|
|
673 |
{
|
|
674 |
iInstalledPackages.Append( sids[i].iUid );
|
|
675 |
}
|
|
676 |
}
|
|
677 |
CleanupStack::PopAndDestroy( &sids );
|
|
678 |
}
|
|
679 |
|
|
680 |
// ---------------------------------------------------------
|
94
|
681 |
//
|
85
|
682 |
// ---------------------------------------------------------
|
|
683 |
//
|
|
684 |
void CCaSrvAppScanner::NotifyL( TInt aAppUid )
|
|
685 |
{
|
|
686 |
// Get entries for given aAppUid
|
|
687 |
RPointerArray<CCaInnerEntry> resultArray;
|
|
688 |
CleanupResetAndDestroyPushL( resultArray );
|
|
689 |
GetCaAppEntriesL( aAppUid, resultArray );
|
93
|
690 |
if( resultArray.Count() && ( resultArray[0]->GetFlags() & EVisible ) )
|
94
|
691 |
{//TODO: this only for icons. This functionality should be change
|
85
|
692 |
iCaStorageProxy.AddL( resultArray[0] );
|
|
693 |
}
|
|
694 |
CleanupStack::PopAndDestroy( &resultArray );
|
|
695 |
}
|
|
696 |
|
|
697 |
// ---------------------------------------------------------
|
94
|
698 |
//
|
85
|
699 |
// ---------------------------------------------------------
|
|
700 |
//
|
|
701 |
void CCaSrvAppScanner::AddEntryToDownloadedCollectionL( TInt aEntryId )
|
|
702 |
{
|
94
|
703 |
TCaOperationParams params;
|
|
704 |
params.iOperationType = TCaOperationParams::EPrepend;
|
|
705 |
params.iGroupId = GetCollectionDownloadIdL();
|
|
706 |
params.iBeforeEntryId = 0; // Not used.
|
85
|
707 |
|
|
708 |
RArray<TInt> entryIds;
|
|
709 |
CleanupClosePushL( entryIds );
|
|
710 |
entryIds.AppendL( aEntryId );
|
|
711 |
iCaStorageProxy.OrganizeL( entryIds, params );
|
|
712 |
|
|
713 |
CleanupStack::PopAndDestroy( &entryIds );
|
|
714 |
}
|
|
715 |
|
|
716 |
// ---------------------------------------------------------
|
94
|
717 |
//
|
92
|
718 |
// ---------------------------------------------------------
|
|
719 |
//
|
|
720 |
void CCaSrvAppScanner::AddEntryToPredefinedCollectionL(
|
|
721 |
CCaInnerEntry* aEntry, TBool aUpdate )
|
|
722 |
{
|
|
723 |
TApaAppCapabilityBuf capability;
|
|
724 |
User::LeaveIfError( iApaLsSession.GetAppCapability( capability,
|
|
725 |
TUid::Uid( aEntry->GetUid() ) ) );
|
|
726 |
|
|
727 |
if( capability().iGroupName.Length() )
|
|
728 |
{
|
|
729 |
// appgroup_name is defined for this app. Find or create folder.
|
|
730 |
CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
|
93
|
731 |
innerQuery->SetRole( CCaInnerQuery::Group );
|
92
|
732 |
innerQuery->AddAttributeL( KCaAppGroupName,
|
|
733 |
capability().iGroupName );
|
93
|
734 |
|
92
|
735 |
// get entries by attributes
|
|
736 |
RPointerArray<CCaInnerEntry> resultArrayItems;
|
|
737 |
CleanupResetAndDestroyPushL( resultArrayItems );
|
|
738 |
iCaStorageProxy.GetEntriesL( innerQuery, resultArrayItems );
|
|
739 |
|
|
740 |
RArray<TInt> entryIds;
|
|
741 |
CleanupClosePushL( entryIds );
|
94
|
742 |
entryIds.AppendL( aEntry->GetId() );
|
92
|
743 |
TCaOperationParams organizeParams;
|
|
744 |
organizeParams.iBeforeEntryId = 0;
|
94
|
745 |
organizeParams.iOperationType = TCaOperationParams::EAppend;
|
93
|
746 |
|
92
|
747 |
if( resultArrayItems.Count() )
|
|
748 |
{
|
93
|
749 |
// collection with appgroup_name exist - add entry
|
92
|
750 |
// to this collection
|
|
751 |
organizeParams.iGroupId = resultArrayItems[0]->GetId();
|
|
752 |
}
|
|
753 |
else
|
|
754 |
{
|
|
755 |
// create new collection
|
|
756 |
TInt predefinedCollectionId = CreatePredefinedCollectionL(
|
|
757 |
capability().iGroupName );
|
93
|
758 |
|
92
|
759 |
organizeParams.iGroupId = predefinedCollectionId;
|
|
760 |
|
93
|
761 |
// add new collection to all collection
|
92
|
762 |
AddCollectionToAllCollectionL( predefinedCollectionId );
|
93
|
763 |
|
92
|
764 |
if( aUpdate )
|
|
765 |
{
|
|
766 |
iCaStorageProxy.OrganizeL( entryIds, organizeParams );
|
|
767 |
}
|
|
768 |
}
|
93
|
769 |
|
92
|
770 |
if( !aUpdate )
|
|
771 |
{
|
|
772 |
iCaStorageProxy.OrganizeL( entryIds, organizeParams );
|
|
773 |
}
|
93
|
774 |
|
92
|
775 |
CleanupStack::PopAndDestroy( &entryIds );
|
|
776 |
CleanupStack::PopAndDestroy( &resultArrayItems );
|
|
777 |
CleanupStack::PopAndDestroy( innerQuery );
|
93
|
778 |
}
|
92
|
779 |
}
|
|
780 |
|
|
781 |
// ---------------------------------------------------------
|
94
|
782 |
//
|
92
|
783 |
// ---------------------------------------------------------
|
|
784 |
//
|
|
785 |
TInt CCaSrvAppScanner::CreatePredefinedCollectionL( const TDesC& aGroupName )
|
|
786 |
{
|
|
787 |
CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC();
|
|
788 |
innerEntry->SetTextL( aGroupName );
|
|
789 |
innerEntry->SetEntryTypeNameL( KCaTypeCollection );
|
|
790 |
innerEntry->SetRole( CCaInnerQuery::Group );
|
|
791 |
innerEntry->AddAttributeL( KCaAppGroupName, aGroupName );
|
94
|
792 |
innerEntry->SetFlags( EVisible | ERemovable );
|
92
|
793 |
innerEntry->SetIconDataL( KCollectionIconFileName,
|
|
794 |
KNullDesC, KNullDesC );
|
|
795 |
iCaStorageProxy.AddL( innerEntry );
|
|
796 |
// Get new collection Id
|
|
797 |
TInt newCollectionId = innerEntry->GetId();
|
|
798 |
CleanupStack::PopAndDestroy( innerEntry );
|
93
|
799 |
|
92
|
800 |
return newCollectionId;
|
|
801 |
}
|
|
802 |
|
|
803 |
// ---------------------------------------------------------
|
94
|
804 |
//
|
92
|
805 |
// ---------------------------------------------------------
|
|
806 |
//
|
|
807 |
void CCaSrvAppScanner::AddCollectionToAllCollectionL( TInt aCollectionId )
|
|
808 |
{
|
|
809 |
RArray<TInt> entryIds;
|
|
810 |
CleanupClosePushL( entryIds );
|
|
811 |
entryIds.AppendL( aCollectionId );
|
93
|
812 |
|
92
|
813 |
TCaOperationParams organizeParams;
|
|
814 |
organizeParams.iBeforeEntryId = 0;
|
|
815 |
organizeParams.iOperationType = TCaOperationParams::EAppend;
|
|
816 |
organizeParams.iGroupId = GetAllCollectionIdL();
|
|
817 |
iCaStorageProxy.OrganizeL( entryIds, organizeParams );
|
|
818 |
CleanupStack::PopAndDestroy( &entryIds );
|
|
819 |
}
|
|
820 |
|
|
821 |
|
|
822 |
|
|
823 |
// ---------------------------------------------------------
|
94
|
824 |
//
|
85
|
825 |
// ---------------------------------------------------------
|
|
826 |
//
|
|
827 |
void CCaSrvAppScanner::RemoveEntryFromDownloadedL( TInt aEntryId )
|
|
828 |
{
|
94
|
829 |
TCaOperationParams params;
|
|
830 |
params.iOperationType = TCaOperationParams::ERemove;
|
|
831 |
params.iGroupId = GetCollectionDownloadIdL();
|
|
832 |
params.iBeforeEntryId = 0; // Not Used
|
85
|
833 |
|
|
834 |
RArray<TInt> entryIds;
|
|
835 |
CleanupClosePushL( entryIds );
|
|
836 |
entryIds.AppendL( aEntryId );
|
|
837 |
iCaStorageProxy.OrganizeL( entryIds, params );
|
|
838 |
|
|
839 |
CleanupStack::PopAndDestroy( &entryIds );
|
|
840 |
}
|
|
841 |
|
|
842 |
// ---------------------------------------------------------
|
94
|
843 |
//
|
85
|
844 |
// ---------------------------------------------------------
|
|
845 |
//
|
|
846 |
void CCaSrvAppScanner::ScheduleScan()
|
|
847 |
{
|
|
848 |
if( !IsActive() )
|
|
849 |
{
|
|
850 |
TRequestStatus* ownStatus = &iStatus;
|
|
851 |
*ownStatus = KRequestPending;
|
|
852 |
SetActive();
|
|
853 |
User::RequestComplete( ownStatus, KErrNone );
|
|
854 |
}
|
|
855 |
}
|
|
856 |
|
|
857 |
// ---------------------------------------------------------
|
94
|
858 |
//
|
85
|
859 |
// ---------------------------------------------------------
|
|
860 |
//
|
|
861 |
void CCaSrvAppScanner::AddAppEntryL( TUint aUid, TUint aCurrentMmcId )
|
|
862 |
{
|
|
863 |
// Now add the app entry.
|
|
864 |
CCaInnerEntry* appEntry = CCaInnerEntry::NewLC();
|
|
865 |
|
|
866 |
appEntry->SetEntryTypeNameL( KCaTypeApp );
|
|
867 |
appEntry->SetUid( aUid );
|
|
868 |
appEntry->SetFlags( EVisible );
|
|
869 |
appEntry->SetRole( EItemEntryRole );
|
|
870 |
|
|
871 |
SetApaAppInfoL( appEntry );
|
94
|
872 |
HandleRemovableVisibleFlagsUpdateL( appEntry );
|
85
|
873 |
HandleMmcAttrUpdateL( appEntry, aCurrentMmcId );
|
|
874 |
|
|
875 |
iCaStorageProxy.AddL( appEntry );
|
93
|
876 |
|
92
|
877 |
AddEntryToPredefinedCollectionL( appEntry );
|
93
|
878 |
|
85
|
879 |
if( iInstalledPackages.Find( aUid ) != KErrNotFound )
|
|
880 |
{
|
|
881 |
AddEntryToDownloadedCollectionL( appEntry->GetId() );
|
94
|
882 |
RemoveFromInstalledPackages( aUid );
|
85
|
883 |
}
|
|
884 |
|
|
885 |
CleanupStack::PopAndDestroy( appEntry );
|
|
886 |
}
|
|
887 |
|
|
888 |
// ---------------------------------------------------------
|
94
|
889 |
//
|
85
|
890 |
// ---------------------------------------------------------
|
|
891 |
//
|
|
892 |
void CCaSrvAppScanner::RemoveFromInstalledPackages( TUint aUid )
|
|
893 |
{
|
|
894 |
TInt appIndex = iInstalledPackages.Find( aUid );
|
|
895 |
if( appIndex != KErrNotFound )
|
|
896 |
{
|
|
897 |
iInstalledPackages.Remove( appIndex );
|
|
898 |
}
|
|
899 |
}
|
|
900 |
|
|
901 |
// ---------------------------------------------------------------------------
|
94
|
902 |
//
|
85
|
903 |
// ---------------------------------------------------------------------------
|
|
904 |
//
|
|
905 |
TBool CCaSrvAppScanner::SetApaAppInfoL( CCaInnerEntry* aEntry )
|
|
906 |
{
|
|
907 |
TBool changed( EFalse );
|
94
|
908 |
TApaAppInfo* info = new ( ELeave ) TApaAppInfo();
|
|
909 |
CleanupStack::PushL(info);
|
|
910 |
if( KErrNone == iSrvEngUtils.GetAppInfo( *aEntry, *info ) )
|
85
|
911 |
{
|
|
912 |
RBuf attrVal;
|
|
913 |
attrVal.CleanupClosePushL();
|
|
914 |
attrVal.CreateL( KCaMaxAttrValueLen );
|
|
915 |
aEntry->FindAttribute( KCaAttrLongName, attrVal );
|
94
|
916 |
if( attrVal.Compare( info->iCaption ) != KErrNone
|
|
917 |
|| aEntry->GetText().Compare( info->iCaption )
|
85
|
918 |
!= KErrNone )
|
|
919 |
{
|
94
|
920 |
aEntry->SetTextL( info->iCaption );
|
|
921 |
aEntry->AddAttributeL( KCaAttrLongName, info->iCaption );
|
85
|
922 |
changed = ETrue;
|
|
923 |
}
|
94
|
924 |
|
|
925 |
|
96
|
926 |
if ( UpdateComponentIdL( *aEntry ) )
|
94
|
927 |
{
|
|
928 |
changed = ETrue;
|
|
929 |
}
|
|
930 |
|
85
|
931 |
CleanupStack::PopAndDestroy( &attrVal );
|
94
|
932 |
|
|
933 |
// check if its java app and add attr for entries
|
92
|
934 |
TUid appTypeUid;
|
94
|
935 |
if( KErrNone == iApaLsSession.GetAppType( appTypeUid, info->iUid ) )
|
92
|
936 |
{
|
|
937 |
if( appTypeUid == KMidletApplicationTypeUid )
|
|
938 |
{
|
94
|
939 |
aEntry->AddAttributeL(
|
|
940 |
KCaAttrAppType,
|
|
941 |
KCaAttrAppTypeValueJava );
|
|
942 |
aEntry->AddAttributeL(
|
|
943 |
KCaAttrAppSettingsPlugin,
|
|
944 |
KCaAttrJavaAppSettingsPluginValue );
|
92
|
945 |
}
|
96
|
946 |
else if ( appTypeUid == KCWRTApplicationTypeUid )
|
92
|
947 |
{
|
94
|
948 |
aEntry->AddAttributeL(
|
|
949 |
KCaAttrAppType,
|
|
950 |
KCaAttrAppTypeValueCWRT );
|
96
|
951 |
TComponentId compId =
|
|
952 |
iSoftwareRegistry.GetComponentIdForAppL( info->iUid );
|
|
953 |
CPropertyEntry* isMiniview =
|
|
954 |
iSoftwareRegistry.GetComponentPropertyL( compId,
|
|
955 |
KCaScrPropertyIsMiniviewSupported );
|
|
956 |
CleanupStack::PushL( isMiniview );
|
|
957 |
// check first if we support mini view
|
|
958 |
if (isMiniview && isMiniview->PropertyType() == CPropertyEntry::EIntProperty &&
|
|
959 |
static_cast<CIntPropertyEntry*>(isMiniview)->IntValue())
|
|
960 |
{
|
|
961 |
CPropertyEntry* appId =
|
|
962 |
iSoftwareRegistry.GetComponentPropertyL( compId, KCaScrPropertyAppId );
|
|
963 |
CleanupStack::PushL( appId );
|
|
964 |
if ( appId &&
|
|
965 |
appId->PropertyType() == CPropertyEntry::ELocalizedProperty )
|
|
966 |
{
|
|
967 |
aEntry->AddAttributeL(
|
|
968 |
KCaAttrAppWidgetUri,
|
|
969 |
KCaAttrAppWidgetUriCWRTValue );
|
|
970 |
aEntry->AddAttributeL(
|
|
971 |
KCaAttrAppWidgetParamWebAppId,
|
|
972 |
static_cast<CLocalizablePropertyEntry*>(appId)->StrValue() );
|
|
973 |
}
|
|
974 |
CleanupStack::PopAndDestroy( appId );
|
|
975 |
}
|
|
976 |
CleanupStack::PopAndDestroy( isMiniview );
|
92
|
977 |
}
|
|
978 |
}
|
85
|
979 |
}
|
94
|
980 |
CleanupStack::PopAndDestroy( info );
|
85
|
981 |
return changed;
|
|
982 |
}
|
|
983 |
|
|
984 |
// ---------------------------------------------------------
|
94
|
985 |
//
|
85
|
986 |
// ---------------------------------------------------------
|
|
987 |
//
|
|
988 |
void CCaSrvAppScanner::HandleMissingItemsL(
|
|
989 |
RPointerArray<CCaInnerEntry>& aCaEntries )
|
|
990 |
{
|
|
991 |
for( TInt i = 0; i < aCaEntries.Count(); i++ )
|
|
992 |
{
|
|
993 |
RBuf attrVal;
|
|
994 |
attrVal.CleanupClosePushL();
|
|
995 |
attrVal.CreateL( KCaMaxAttrValueLen );
|
|
996 |
if( aCaEntries[i]->FindAttribute( KCaAttrMmcId(), attrVal ) )
|
|
997 |
{
|
93
|
998 |
TUint mmcId = 0;
|
85
|
999 |
MenuUtils::GetTUint( attrVal, mmcId );
|
93
|
1000 |
if( ( mmcId && KErrNotFound != iMmcHistory->Find( mmcId )
|
|
1001 |
&& mmcId != CurrentMmcId() ) ||
|
|
1002 |
( attrVal == KCaMassStorage() &&
|
|
1003 |
IsDriveInUse( DriveInfo::EDefaultMassStorage ) ) )
|
85
|
1004 |
{
|
93
|
1005 |
// This item is on an MMC which is currently
|
|
1006 |
// in the MMC history or on a mass storage in use.
|
85
|
1007 |
// Set it "missing" but keep it.
|
93
|
1008 |
SetMissingFlagL( aCaEntries[i] );
|
85
|
1009 |
}
|
|
1010 |
else
|
|
1011 |
{
|
93
|
1012 |
aCaEntries[i]->RemoveAttributeL(KCaAttrMmcId());
|
|
1013 |
ClearVisibleFlagL( aCaEntries[i] );
|
85
|
1014 |
}
|
|
1015 |
}
|
|
1016 |
else
|
|
1017 |
{
|
93
|
1018 |
ClearVisibleFlagL( aCaEntries[i] );
|
85
|
1019 |
}
|
|
1020 |
CleanupStack::PopAndDestroy( &attrVal );
|
|
1021 |
}
|
|
1022 |
}
|
|
1023 |
|
|
1024 |
// ---------------------------------------------------------
|
94
|
1025 |
//
|
85
|
1026 |
// ---------------------------------------------------------
|
|
1027 |
//
|
|
1028 |
void CCaSrvAppScanner::RemoveAppL( CCaInnerEntry* aAppEntry )
|
|
1029 |
{
|
|
1030 |
RArray<TInt> idsToRemove;
|
|
1031 |
CleanupClosePushL( idsToRemove );
|
|
1032 |
idsToRemove.AppendL( aAppEntry->GetId() );
|
|
1033 |
iCaStorageProxy.RemoveL( idsToRemove );
|
|
1034 |
CleanupStack::PopAndDestroy( &idsToRemove );
|
|
1035 |
}
|
|
1036 |
|
|
1037 |
// ---------------------------------------------------------
|
93
|
1038 |
//
|
85
|
1039 |
// ---------------------------------------------------------
|
|
1040 |
//
|
93
|
1041 |
void CCaSrvAppScanner::SetMissingFlagL( CCaInnerEntry* aEntry )
|
85
|
1042 |
{
|
93
|
1043 |
if( !( aEntry->GetFlags() & EMissing ) )
|
85
|
1044 |
{
|
93
|
1045 |
aEntry->SetFlags( aEntry->GetFlags() | EMissing );
|
|
1046 |
iCaStorageProxy.AddL( aEntry, EFalse, EItemDisappeared );
|
|
1047 |
}
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
// ---------------------------------------------------------
|
|
1051 |
//
|
|
1052 |
// ---------------------------------------------------------
|
|
1053 |
//
|
|
1054 |
void CCaSrvAppScanner::ClearVisibleFlagL( CCaInnerEntry* aEntry )
|
|
1055 |
{
|
|
1056 |
if( aEntry->GetFlags() & EVisible )
|
|
1057 |
{
|
94
|
1058 |
aEntry->SetFlags(
|
|
1059 |
aEntry->GetFlags() &
|
|
1060 |
~EVisible &
|
|
1061 |
~EMissing &
|
|
1062 |
~EUsed );
|
93
|
1063 |
iCaStorageProxy.AddL( aEntry, EFalse, EItemDisappeared );
|
85
|
1064 |
}
|
|
1065 |
}
|
|
1066 |
|
|
1067 |
// ---------------------------------------------------------
|
94
|
1068 |
//
|
85
|
1069 |
// ---------------------------------------------------------
|
|
1070 |
//
|
|
1071 |
TUint CCaSrvAppScanner::UpdateMmcHistoryL()
|
|
1072 |
{
|
|
1073 |
TUint mmcId = CurrentMmcId();
|
|
1074 |
if( mmcId )
|
|
1075 |
{
|
|
1076 |
iMmcHistory->InsertL( mmcId );
|
|
1077 |
iMmcHistory->SaveL( iFs, KCaMmcHistoryFname() );
|
|
1078 |
}
|
|
1079 |
return mmcId;
|
|
1080 |
}
|
|
1081 |
|
|
1082 |
// ---------------------------------------------------------
|
94
|
1083 |
//
|
85
|
1084 |
// ---------------------------------------------------------
|
|
1085 |
//
|
|
1086 |
TUint CCaSrvAppScanner::CurrentMmcId() const
|
|
1087 |
{
|
|
1088 |
// Get mmc id. Errors are ignored.
|
|
1089 |
TUint mmcId = 0;
|
|
1090 |
TInt mmcDrive;
|
94
|
1091 |
TInt err = DriveInfo::GetDefaultDrive(
|
85
|
1092 |
DriveInfo::EDefaultRemovableMassStorage, mmcDrive );
|
|
1093 |
if( !err )
|
|
1094 |
{
|
|
1095 |
TVolumeInfo volumeInfo;
|
|
1096 |
err = iFs.Volume( volumeInfo, mmcDrive );
|
|
1097 |
if( !err )
|
|
1098 |
{
|
|
1099 |
mmcId = volumeInfo.iUniqueID;
|
|
1100 |
}
|
|
1101 |
}
|
|
1102 |
return mmcId;
|
|
1103 |
}
|
|
1104 |
|
|
1105 |
// ---------------------------------------------------------
|
94
|
1106 |
//
|
85
|
1107 |
// ---------------------------------------------------------
|
|
1108 |
//
|
|
1109 |
TBool CCaSrvAppScanner::IsFileInDrive(
|
94
|
1110 |
const TDesC& aFileName,
|
|
1111 |
const DriveInfo::TDefaultDrives& aDefaultDrive ) const
|
|
1112 |
{
|
|
1113 |
TBool retVal( EFalse );
|
|
1114 |
if ( aFileName.Length()>0 )
|
85
|
1115 |
{
|
94
|
1116 |
TInt mmcDrive;
|
85
|
1117 |
TInt err = DriveInfo::GetDefaultDrive( aDefaultDrive, mmcDrive );
|
|
1118 |
if( !err )
|
|
1119 |
{
|
|
1120 |
TInt fileDrive;
|
|
1121 |
err = RFs::CharToDrive( aFileName[0], fileDrive );
|
|
1122 |
if( !err && fileDrive == mmcDrive )
|
|
1123 |
{
|
94
|
1124 |
retVal = ETrue;
|
85
|
1125 |
}
|
|
1126 |
}
|
|
1127 |
}
|
94
|
1128 |
return retVal;
|
85
|
1129 |
}
|
|
1130 |
|
|
1131 |
// ---------------------------------------------------------
|
94
|
1132 |
//
|
85
|
1133 |
// ---------------------------------------------------------
|
|
1134 |
//
|
92
|
1135 |
TBool CCaSrvAppScanner::IsAppInDriveL(
|
85
|
1136 |
const TUid aUid,
|
|
1137 |
const DriveInfo::TDefaultDrives& aDefaultDrive ) const
|
|
1138 |
{
|
|
1139 |
TBool ret( EFalse );
|
94
|
1140 |
TApaAppInfo* appInfo = new ( ELeave ) TApaAppInfo();
|
92
|
1141 |
TInt err = iApaLsSession.GetAppInfo( *appInfo, aUid );
|
|
1142 |
if( !err && IsFileInDrive( appInfo->iFullName, aDefaultDrive ) )
|
85
|
1143 |
{
|
|
1144 |
ret = ETrue;
|
|
1145 |
}
|
92
|
1146 |
delete appInfo;
|
85
|
1147 |
return ret;
|
|
1148 |
}
|
|
1149 |
|
|
1150 |
// ---------------------------------------------------------
|
94
|
1151 |
//
|
85
|
1152 |
// ---------------------------------------------------------
|
|
1153 |
//
|
92
|
1154 |
TBool CCaSrvAppScanner::IsInMmcL( const TUid aUid ) const
|
85
|
1155 |
{
|
92
|
1156 |
return IsAppInDriveL( aUid, DriveInfo::EDefaultRemovableMassStorage );
|
85
|
1157 |
}
|
|
1158 |
|
|
1159 |
// ---------------------------------------------------------
|
94
|
1160 |
//
|
85
|
1161 |
// ---------------------------------------------------------
|
|
1162 |
//
|
92
|
1163 |
TBool CCaSrvAppScanner::IsInMassStorageL( const TUid aUid ) const
|
85
|
1164 |
{
|
92
|
1165 |
return IsAppInDriveL( aUid, DriveInfo::EDefaultMassStorage );
|
85
|
1166 |
}
|
|
1167 |
|
|
1168 |
// ---------------------------------------------------------
|
94
|
1169 |
//
|
85
|
1170 |
// ---------------------------------------------------------
|
|
1171 |
//
|
92
|
1172 |
TBool CCaSrvAppScanner::IsInRomL( TInt aUid )
|
85
|
1173 |
{
|
92
|
1174 |
return IsAppInDriveL( TUid::Uid( aUid ), DriveInfo::EDefaultRom );
|
85
|
1175 |
}
|
|
1176 |
|
|
1177 |
// ---------------------------------------------------------
|
94
|
1178 |
//
|
85
|
1179 |
// ---------------------------------------------------------
|
|
1180 |
//
|
|
1181 |
TBool CCaSrvAppScanner::IsDriveInUse(
|
|
1182 |
const DriveInfo::TDefaultDrives& aDefaultDrive )
|
|
1183 |
{
|
|
1184 |
TBool inUse( EFalse );
|
|
1185 |
TInt drive;
|
|
1186 |
|
|
1187 |
TInt err = DriveInfo::GetDefaultDrive( aDefaultDrive, drive );
|
|
1188 |
if( err == KErrNone )
|
|
1189 |
{
|
|
1190 |
TUint status;
|
|
1191 |
err = DriveInfo::GetDriveStatus( iFs, drive, status );
|
|
1192 |
if( err == KErrNone && ( status & DriveInfo::EDriveInUse ) )
|
|
1193 |
{
|
|
1194 |
inUse = ETrue;
|
|
1195 |
}
|
|
1196 |
}
|
|
1197 |
|
|
1198 |
return inUse;
|
|
1199 |
}
|
|
1200 |
|
94
|
1201 |
// ---------------------------------------------------------
|
|
1202 |
//
|
|
1203 |
// ---------------------------------------------------------
|
|
1204 |
//
|
92
|
1205 |
void CCaSrvAppScanner::MakeNotEmptyCollectionsVisibleL()
|
|
1206 |
{
|
|
1207 |
RPointerArray<CCaInnerEntry> resultArray;
|
|
1208 |
CleanupResetAndDestroyPushL( resultArray );
|
|
1209 |
CCaInnerQuery* hiddenCollectionsQuery = CCaInnerQuery::NewLC();
|
|
1210 |
CDesC16ArrayFlat* entryType = new ( ELeave ) CDesC16ArrayFlat(
|
|
1211 |
KGranularityOne );
|
|
1212 |
CleanupStack::PushL( entryType );
|
|
1213 |
entryType->AppendL( KCaTypeCollection );
|
|
1214 |
hiddenCollectionsQuery->SetEntryTypeNames( entryType );
|
|
1215 |
hiddenCollectionsQuery->SetFlagsOff( EVisible );
|
|
1216 |
iCaStorageProxy.GetEntriesL( hiddenCollectionsQuery, resultArray );
|
|
1217 |
CleanupStack::Pop( entryType );
|
|
1218 |
CleanupStack::PopAndDestroy( hiddenCollectionsQuery );
|
|
1219 |
if( resultArray.Count() )
|
|
1220 |
{
|
|
1221 |
for( TInt i=0; i<resultArray.Count(); i++ )
|
|
1222 |
{
|
|
1223 |
// for any not visible collection
|
|
1224 |
MakeCollectionVisibleIfHasVisibleEntryL( resultArray[i] );
|
|
1225 |
}
|
|
1226 |
}
|
|
1227 |
CleanupStack::PopAndDestroy( &resultArray );
|
|
1228 |
}
|
|
1229 |
|
94
|
1230 |
// ---------------------------------------------------------
|
|
1231 |
//
|
|
1232 |
// ---------------------------------------------------------
|
|
1233 |
//
|
92
|
1234 |
void CCaSrvAppScanner::MakeCollectionVisibleIfHasVisibleEntryL(
|
|
1235 |
CCaInnerEntry* aEntry )
|
|
1236 |
{
|
|
1237 |
RPointerArray<CCaInnerEntry> resultEntriesArray;
|
|
1238 |
CleanupResetAndDestroyPushL( resultEntriesArray );
|
|
1239 |
CCaInnerQuery* visibleEntriesQuery = CCaInnerQuery::NewLC();
|
|
1240 |
visibleEntriesQuery->SetParentId( aEntry->GetId() );
|
|
1241 |
visibleEntriesQuery->SetFlagsOn( EVisible );
|
|
1242 |
visibleEntriesQuery->SetFlagsOff( EMissing );
|
|
1243 |
iCaStorageProxy.GetEntriesL( visibleEntriesQuery, resultEntriesArray );
|
|
1244 |
if( resultEntriesArray.Count() )
|
|
1245 |
{
|
|
1246 |
// set collection visible if hidden
|
93
|
1247 |
if( HandleVisibleFlagUpdate( aEntry ) )
|
92
|
1248 |
{
|
|
1249 |
// update here this collection
|
93
|
1250 |
iCaStorageProxy.AddL( aEntry );
|
92
|
1251 |
}
|
|
1252 |
}
|
|
1253 |
CleanupStack::PopAndDestroy( visibleEntriesQuery );
|
|
1254 |
CleanupStack::PopAndDestroy( &resultEntriesArray );
|
|
1255 |
}
|
|
1256 |
|
85
|
1257 |
// ---------------------------------------------------------
|
|
1258 |
//
|
94
|
1259 |
// ---------------------------------------------------------//
|
96
|
1260 |
TBool CCaSrvAppScanner::UpdateComponentIdL( CCaInnerEntry& aEntry ) const
|
85
|
1261 |
{
|
94
|
1262 |
TBool updated( EFalse );
|
|
1263 |
|
96
|
1264 |
TUid uid;
|
|
1265 |
TInt err(KErrNone);
|
|
1266 |
TComponentId componentId( 0 );
|
|
1267 |
TRAP(err, componentId =
|
|
1268 |
iSoftwareRegistry.GetComponentIdForAppL(
|
|
1269 |
uid.Uid( aEntry.GetUid() ) ) )
|
94
|
1270 |
|
96
|
1271 |
if ( componentId > 0 && err == KErrNone )
|
94
|
1272 |
{
|
|
1273 |
RBuf newComponentId;
|
|
1274 |
newComponentId.CleanupClosePushL();
|
|
1275 |
newComponentId.CreateL( sizeof(TComponentId) + 1 );
|
96
|
1276 |
newComponentId.AppendNum( componentId );
|
94
|
1277 |
|
|
1278 |
RBuf oldComponentId;
|
|
1279 |
oldComponentId.CleanupClosePushL();
|
|
1280 |
oldComponentId.CreateL( KCaMaxAttrValueLen );
|
|
1281 |
|
|
1282 |
const TBool componentIdAttributeFound =
|
|
1283 |
aEntry.FindAttribute( KCaComponentId, oldComponentId );
|
|
1284 |
|
|
1285 |
if ( !componentIdAttributeFound
|
|
1286 |
|| oldComponentId.Compare( newComponentId ) != 0 )
|
|
1287 |
{
|
|
1288 |
// 'add' or 'update' the component id attribute value
|
|
1289 |
aEntry.AddAttributeL( KCaComponentId,
|
|
1290 |
newComponentId );
|
|
1291 |
|
|
1292 |
updated = ETrue;
|
|
1293 |
}
|
|
1294 |
|
|
1295 |
CleanupStack::PopAndDestroy( &oldComponentId );
|
|
1296 |
CleanupStack::PopAndDestroy( &newComponentId );
|
|
1297 |
}
|
|
1298 |
return updated;
|
|
1299 |
}
|