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