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