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