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