114
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <mcsmenuutils.h>
|
|
18 |
#include <e32property.h>
|
|
19 |
#include <widgetregistryclient.h>
|
|
20 |
#include "menusrvappscanner.h"
|
|
21 |
#include "menusrvmmchistory.h"
|
|
22 |
#include "menueng.h"
|
|
23 |
#include "menuengobject.h"
|
|
24 |
#include "pathinfo.h"
|
|
25 |
#include "menulogger.h"
|
|
26 |
#include "centralrepository.h"
|
|
27 |
#include "mcssathandler.h"
|
|
28 |
#include "menusrvengutils.h"
|
|
29 |
#include "bautils.h"
|
|
30 |
#include "menuutil.h"
|
|
31 |
|
|
32 |
_LIT( KMenuOne, "1" );
|
|
33 |
_LIT( KMenuAttrMmcId, "mmc_id" );
|
|
34 |
_LIT( KMenuMassStorage, "mass_storage" );
|
|
35 |
_LIT( KMenuMmcHistoryFname, "mmchistory" );
|
|
36 |
|
|
37 |
// ==================== LOCAL FUNCTIONS ====================
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Identity function to search in an array of TMenuItems.
|
|
41 |
* Identity is the ID.
|
|
42 |
* @param aLeft Search term.
|
|
43 |
* @param aRight Array item.
|
|
44 |
* @return ETrue if ID-s match.
|
|
45 |
*/
|
|
46 |
LOCAL_C TBool IdMatch( const TMenuItem& aLeft, const TMenuItem& aRight )
|
|
47 |
{
|
|
48 |
return aLeft.Id() == aRight.Id();
|
|
49 |
}
|
|
50 |
|
|
51 |
// ==================== MEMBER FUNCTIONS ====================
|
|
52 |
|
|
53 |
// ---------------------------------------------------------
|
|
54 |
// CMenuSrvAppScanner::NewL
|
|
55 |
// ---------------------------------------------------------
|
|
56 |
//
|
|
57 |
CMenuSrvAppScanner* CMenuSrvAppScanner::NewL(
|
|
58 |
CMenuEng& aEng, CMenuSrvEngUtils& aSrvEngUtils )
|
|
59 |
{
|
|
60 |
CMenuSrvAppScanner* scanner = new (ELeave) CMenuSrvAppScanner(
|
|
61 |
aEng, aSrvEngUtils );
|
|
62 |
CleanupStack::PushL( scanner );
|
|
63 |
scanner->ConstructL();
|
|
64 |
CleanupStack::Pop( scanner );
|
|
65 |
return scanner;
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------
|
|
69 |
// CMenuSrvAppScanner::~CMenuSrvAppScanner
|
|
70 |
// ---------------------------------------------------------
|
|
71 |
//
|
|
72 |
CMenuSrvAppScanner::~CMenuSrvAppScanner()
|
|
73 |
{
|
|
74 |
Cancel();
|
|
75 |
delete iMcsSatNotifier;
|
|
76 |
delete iNotifier;
|
|
77 |
iEng.DequeueOperation( *this );
|
|
78 |
delete iMmcHistory;
|
|
79 |
iFs.Close();
|
|
80 |
|
|
81 |
if( iCenRepNotifyHandlerHiddenApps )
|
|
82 |
{
|
|
83 |
iCenRepNotifyHandlerHiddenApps->StopListening();
|
|
84 |
}
|
|
85 |
delete iCenRepNotifyHandlerHiddenApps;
|
|
86 |
|
|
87 |
if( iCenRepNotifyHandlerCPHiddenApps )
|
|
88 |
{
|
|
89 |
iCenRepNotifyHandlerCPHiddenApps->StopListening();
|
|
90 |
}
|
|
91 |
delete iCenRepNotifyHandlerCPHiddenApps;
|
|
92 |
|
|
93 |
if( iCenRepNotifyHandlerCPHiddenFolders )
|
|
94 |
{
|
|
95 |
iCenRepNotifyHandlerCPHiddenFolders->StopListening();
|
|
96 |
}
|
|
97 |
delete iCenRepNotifyHandlerCPHiddenFolders;
|
|
98 |
delete iCenRepSession;
|
|
99 |
delete iFreeSpaceObserver;
|
|
100 |
|
|
101 |
}
|
|
102 |
|
|
103 |
// ---------------------------------------------------------
|
|
104 |
// CMenuSrvAppScanner::CMenuSrvAppScanner
|
|
105 |
// ---------------------------------------------------------
|
|
106 |
//
|
|
107 |
CMenuSrvAppScanner::CMenuSrvAppScanner(
|
|
108 |
CMenuEng& aEng, CMenuSrvEngUtils& aSrvEngUtils )
|
|
109 |
: CActive( CActive::EPriorityStandard ), iEng( aEng ),
|
|
110 |
iSrvEngUtils( aSrvEngUtils )
|
|
111 |
{
|
|
112 |
CActiveScheduler::Add( this );
|
|
113 |
}
|
|
114 |
|
|
115 |
// ---------------------------------------------------------
|
|
116 |
// CMenuSrvAppScanner::ConstructL
|
|
117 |
// ---------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CMenuSrvAppScanner::ConstructL()
|
|
120 |
{
|
|
121 |
iOpStatus = EFalse;
|
|
122 |
User::LeaveIfError( iFs.Connect() );
|
|
123 |
TFileName path;
|
|
124 |
User::LeaveIfError( iFs.PrivatePath( path ) );
|
|
125 |
TUint attribute;
|
|
126 |
if( iFs.Att( path, attribute) == KErrNotFound )
|
|
127 |
{
|
|
128 |
TInt mdRes = iFs.MkDirAll( path );
|
|
129 |
if ( mdRes != KErrNone )
|
|
130 |
{
|
|
131 |
User::Leave( mdRes );
|
|
132 |
}
|
|
133 |
}
|
|
134 |
|
|
135 |
iMmcHistory = new (ELeave) CMenuSrvMmcHistory();
|
|
136 |
iMmcHistory->LoadL( iFs, KMenuMmcHistoryFname() );
|
|
137 |
// The notifier has its own session to apparc, instead of taking
|
|
138 |
// it as argument... :(
|
|
139 |
iNotifier = CApaAppListNotifier::NewL( this, CActive::EPriorityStandard );
|
|
140 |
|
|
141 |
iCenRepSession = CRepository::NewL( KCRUidMenu );
|
|
142 |
|
|
143 |
iCenRepNotifyHandlerHiddenApps = CCenRepNotifyHandler::NewL(
|
|
144 |
*this, *iCenRepSession,
|
|
145 |
CCenRepNotifyHandler::EStringKey, KMenuHideApplication );
|
|
146 |
iCenRepNotifyHandlerCPHiddenApps = CCenRepNotifyHandler::NewL(
|
|
147 |
*this, *iCenRepSession,
|
|
148 |
CCenRepNotifyHandler::EStringKey, KMenuHideCPApplication );
|
|
149 |
|
|
150 |
iCenRepNotifyHandlerCPHiddenFolders = CCenRepNotifyHandler::NewL(
|
|
151 |
*this, *iCenRepSession,
|
|
152 |
CCenRepNotifyHandler::EStringKey, KMenuHideCPFolder );
|
|
153 |
|
|
154 |
iCenRepNotifyHandlerHiddenApps->StartListeningL();
|
|
155 |
iCenRepNotifyHandlerCPHiddenApps->StartListeningL();
|
|
156 |
iCenRepNotifyHandlerCPHiddenFolders->StartListeningL();
|
|
157 |
|
|
158 |
iMcsSatNotifier = CMcsSatNotifier::NewL(
|
|
159 |
this, KCRUidMenu, KMenuShowSatUI );
|
|
160 |
|
|
161 |
iFreeSpaceObserver = CMcsFreeSpaceObserver::NewL( *this );
|
|
162 |
|
|
163 |
//SetActive();
|
|
164 |
ScheduleScan();
|
|
165 |
//iOpStatus = ETrue;
|
|
166 |
}
|
|
167 |
|
|
168 |
// ---------------------------------------------------------
|
|
169 |
// CMenuSrvAppScanner::RunL
|
|
170 |
// ---------------------------------------------------------
|
|
171 |
//
|
|
172 |
void CMenuSrvAppScanner::RunL()
|
|
173 |
{
|
|
174 |
User::LeaveIfError( iStatus.Int() ); // Handle errors in RunL.
|
|
175 |
// AppArc app scan complete, we have the app list.
|
|
176 |
// Now queue this operation to be executed by the Engine.
|
|
177 |
if ( !MenuUtil::BackupInProgressL() )
|
|
178 |
{
|
|
179 |
iEng.QueueOperationL( *this );
|
|
180 |
}
|
|
181 |
else
|
|
182 |
{
|
|
183 |
iOpStatus = EFalse;
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------
|
|
188 |
// CMenuSrvAppScanner::DoCancel
|
|
189 |
// ---------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CMenuSrvAppScanner::DoCancel()
|
|
192 |
{
|
|
193 |
}
|
|
194 |
|
|
195 |
// ---------------------------------------------------------
|
|
196 |
// CMenuSrvAppScanner::RunError
|
|
197 |
// ---------------------------------------------------------
|
|
198 |
//
|
|
199 |
TInt CMenuSrvAppScanner::RunError( TInt /*aError*/ )
|
|
200 |
{
|
|
201 |
// Ignore the error (what else could we do?).
|
|
202 |
// When next AppArc update occurs, we will run again.
|
|
203 |
return KErrNone;
|
|
204 |
}
|
|
205 |
|
|
206 |
// ---------------------------------------------------------
|
|
207 |
// CMenuSrvAppScanner::UpdateApplicationWithHideIfInstalledItemsL
|
|
208 |
// ---------------------------------------------------------
|
|
209 |
//
|
|
210 |
void CMenuSrvAppScanner::UpdateApplicationWithHideIfInstalledItemsL()
|
|
211 |
{
|
|
212 |
TInt root;
|
|
213 |
iEng.RootFolderL( root );
|
|
214 |
|
|
215 |
TMenuSrvAttrExistsFilter appFilter;
|
|
216 |
appFilter.SetAttr( KMenuAttrHideIfInstalledUid() );
|
|
217 |
|
|
218 |
RArray<TMenuItem> items;
|
|
219 |
CleanupClosePushL( items );
|
|
220 |
iEng.GetItemsL( items, root, &appFilter, ETrue );
|
|
221 |
|
|
222 |
for (TInt i=0; i < items.Count(); i++)
|
|
223 |
{
|
|
224 |
TBool wasHidden;
|
|
225 |
TPtrC uidTmp;
|
|
226 |
|
|
227 |
GetHiddenFlagAndUidL( items[i].Id(), wasHidden, uidTmp );
|
|
228 |
|
|
229 |
HideItemIfPresentL( root, items[i].Id(), uidTmp, wasHidden );
|
|
230 |
}
|
|
231 |
CleanupStack::PopAndDestroy( &items );
|
|
232 |
}
|
|
233 |
|
|
234 |
// ---------------------------------------------------------
|
|
235 |
// CMenuSrvAppScanner::GetHiddenFlagAndUidL
|
|
236 |
// ---------------------------------------------------------
|
|
237 |
//
|
|
238 |
void CMenuSrvAppScanner::GetHiddenFlagAndUidL( TInt aId, TBool& aHidden, TPtrC& aUidStr )
|
|
239 |
{
|
|
240 |
const CMenuEngObject& object = iEng.ObjectL( aId );
|
|
241 |
aHidden = (0 != (object.Flags() & TMenuItem::EHidden));
|
|
242 |
|
|
243 |
TBool tmp;
|
|
244 |
object.FindAttribute( KMenuAttrHideIfInstalledUid(), aUidStr, tmp);
|
|
245 |
}
|
|
246 |
|
|
247 |
// ---------------------------------------------------------
|
|
248 |
// CMenuSrvAppScanner::HideAppIfExists
|
|
249 |
// ---------------------------------------------------------
|
|
250 |
//
|
|
251 |
void CMenuSrvAppScanner::HideItemIfPresentL( TInt aFolder, TInt aId, const TDesC& aUid, TBool aWasHidden )
|
|
252 |
{
|
|
253 |
TBool hideItem = EFalse;
|
|
254 |
TMenuSrvAttrFilter uidAppFilter;
|
|
255 |
uidAppFilter.SetAttr( KMenuAttrUid(), aUid );
|
|
256 |
|
|
257 |
RArray<TMenuItem> appItems;
|
|
258 |
CleanupClosePushL( appItems );
|
|
259 |
iEng.GetItemsL( appItems, aFolder, &uidAppFilter, ETrue );
|
|
260 |
|
|
261 |
for (TInt i=0; i < appItems.Count(); i++)
|
|
262 |
{
|
|
263 |
if(appItems[i].Type() != KMenuTypeLink())
|
|
264 |
{
|
|
265 |
const TMenuItem& item = appItems[i];
|
|
266 |
|
|
267 |
TBool itemHidden = (0 != (item.Flags() & TMenuItem::EHidden));
|
|
268 |
TBool itemMissing = (0 != (item.Flags() & TMenuItem::EMissing));
|
|
269 |
if ( !itemHidden && !itemMissing )
|
|
270 |
{
|
|
271 |
hideItem = ETrue;
|
|
272 |
}
|
|
273 |
}
|
|
274 |
}
|
|
275 |
|
|
276 |
SetHiddenFlagL( aId, aWasHidden, hideItem );
|
|
277 |
|
|
278 |
CleanupStack::PopAndDestroy( &appItems );
|
|
279 |
}
|
|
280 |
|
|
281 |
// ---------------------------------------------------------
|
|
282 |
// CMenuSrvAppScanner::SetHiddenFlagL
|
|
283 |
// ---------------------------------------------------------
|
|
284 |
//
|
|
285 |
void CMenuSrvAppScanner::SetHiddenFlagL( TInt aId, TBool aWasHidden, TBool aHide )
|
|
286 |
{
|
|
287 |
if ( aWasHidden ^ aHide )
|
|
288 |
{
|
|
289 |
iEng.ModifiableObjectL( aId, RMenuNotifier::EItemsAddedRemoved ).
|
|
290 |
SetFlags( TMenuItem::EHidden, aHide );
|
|
291 |
}
|
|
292 |
}
|
|
293 |
|
|
294 |
// ---------------------------------------------------------
|
|
295 |
// CMenuSrvAppScanner::ValidateLinkUidL
|
|
296 |
// ---------------------------------------------------------
|
|
297 |
//
|
|
298 |
void CMenuSrvAppScanner::ValidateLinkUidL( TInt aFolder, TInt aId, const TDesC& aUidStr )
|
|
299 |
{
|
|
300 |
TMenuSrvAttrFilter uidAppFilter;
|
|
301 |
uidAppFilter.SetAttr( KMenuAttrUid(), aUidStr );
|
|
302 |
|
|
303 |
RArray<TMenuItem> appItems;
|
|
304 |
CleanupClosePushL( appItems );
|
|
305 |
iEng.GetItemsL( appItems, aFolder, &uidAppFilter, ETrue );
|
|
306 |
|
|
307 |
TBool showItem = EFalse;
|
|
308 |
TBool exists = EFalse;
|
|
309 |
TBool itemMissing = EFalse;
|
|
310 |
for (TInt i=0; i < appItems.Count(); i++)
|
|
311 |
{
|
|
312 |
if(appItems[i].Id() != aId)
|
|
313 |
{
|
|
314 |
exists = ETrue;
|
|
315 |
const TMenuItem& item = appItems[i];
|
|
316 |
|
|
317 |
TBool itemHidden = (0 != (item.Flags() & TMenuItem::EHidden));
|
|
318 |
itemMissing = (0 != (item.Flags() & TMenuItem::EMissing));
|
|
319 |
if ( !itemHidden && !itemMissing )
|
|
320 |
{
|
|
321 |
showItem = ETrue;
|
|
322 |
}
|
|
323 |
}
|
|
324 |
}
|
|
325 |
|
|
326 |
UpdateLinkL( aId, exists, showItem, itemMissing );
|
|
327 |
|
|
328 |
CleanupStack::PopAndDestroy( &appItems );
|
|
329 |
}
|
|
330 |
|
|
331 |
// ---------------------------------------------------------
|
|
332 |
// CMenuSrvAppScanner::UpdateLinkL
|
|
333 |
// ---------------------------------------------------------
|
|
334 |
//
|
|
335 |
void CMenuSrvAppScanner::UpdateLinkL(
|
|
336 |
TInt aId,
|
|
337 |
TBool aExists,
|
|
338 |
TBool aShowItem,
|
|
339 |
TBool aMissingItem )
|
|
340 |
{
|
|
341 |
if (!aExists)
|
|
342 |
{
|
|
343 |
iEng.ModifiableObjectL( aId ).SetFlags( TMenuItem::ELockDelete, EFalse );
|
|
344 |
iEng.RemoveL( aId );
|
|
345 |
}
|
|
346 |
else if ( !aMissingItem )
|
|
347 |
{
|
|
348 |
const CMenuEngObject& object = iEng.ObjectL( aId );
|
|
349 |
TBool itemHidden = (0 != (object.Flags() & TMenuItem::EHidden));
|
|
350 |
TBool itemMissing = (0 != (object.Flags() & TMenuItem::EMissing));
|
|
351 |
if ( itemHidden == aShowItem )
|
|
352 |
{
|
|
353 |
iEng.ModifiableObjectL( aId, RMenuNotifier::EItemsAddedRemoved ).
|
|
354 |
SetFlags( TMenuItem::EHidden, !aShowItem );
|
|
355 |
}
|
|
356 |
if ( itemMissing != aMissingItem )
|
|
357 |
{
|
|
358 |
iEng.ModifiableObjectL( aId, RMenuNotifier::EItemsAddedRemoved ).
|
|
359 |
SetFlags( TMenuItem::EMissing, aMissingItem );
|
|
360 |
}
|
|
361 |
}
|
|
362 |
else
|
|
363 |
{
|
|
364 |
const CMenuEngObject& object = iEng.ObjectL( aId );
|
|
365 |
TBool itemMissing = (0 != (object.Flags() & TMenuItem::EMissing));
|
|
366 |
if ( itemMissing != aMissingItem )
|
|
367 |
{
|
|
368 |
iEng.ModifiableObjectL( aId, RMenuNotifier::EItemsAddedRemoved ).
|
|
369 |
SetFlags( TMenuItem::EMissing, aMissingItem );
|
|
370 |
}
|
|
371 |
}
|
|
372 |
}
|
|
373 |
|
|
374 |
// ---------------------------------------------------------
|
|
375 |
// CMenuSrvAppScanner::ValidateLinkRefIdL
|
|
376 |
// ---------------------------------------------------------
|
|
377 |
//
|
|
378 |
void CMenuSrvAppScanner::ValidateLinkRefIdL( TInt aId, const TDesC& refIdStr )
|
|
379 |
{
|
|
380 |
TUint refItemId;
|
|
381 |
MenuUtils::GetTUint( refIdStr, refItemId );
|
|
382 |
|
|
383 |
TMenuItem refItem;
|
|
384 |
|
|
385 |
TBool showItem = EFalse;
|
|
386 |
TBool exists = EFalse;
|
|
387 |
|
|
388 |
TRAPD( err, iEng.GetItemL( refItemId, refItem ) );
|
|
389 |
|
|
390 |
if (err == KErrNone)
|
|
391 |
{
|
|
392 |
exists = ETrue;
|
|
393 |
}
|
|
394 |
|
|
395 |
TBool itemHidden = (0 != (refItem.Flags() & TMenuItem::EHidden));
|
|
396 |
TBool itemMissing = (0 != (refItem.Flags() & TMenuItem::EMissing));
|
|
397 |
if ( !itemHidden && !itemMissing )
|
|
398 |
{
|
|
399 |
showItem = ETrue;
|
|
400 |
}
|
|
401 |
|
|
402 |
UpdateLinkL( aId, exists, showItem, itemMissing );
|
|
403 |
}
|
|
404 |
|
|
405 |
// ---------------------------------------------------------
|
|
406 |
// CMenuSrvAppScanner::ValidateLinkL
|
|
407 |
// ---------------------------------------------------------
|
|
408 |
//
|
|
409 |
void CMenuSrvAppScanner::ValidateLinkL( TInt aFolder, TInt aId )
|
|
410 |
{
|
|
411 |
const CMenuEngObject& object = iEng.ObjectL( aId );
|
|
412 |
|
|
413 |
TBool tmp;
|
|
414 |
TPtrC refIdStr;
|
|
415 |
TPtrC uidStr;
|
|
416 |
if ( object.FindAttribute( KMenuAttrRefId(), refIdStr, tmp) )
|
|
417 |
{
|
|
418 |
ValidateLinkRefIdL( aId, refIdStr );
|
|
419 |
}
|
|
420 |
else if ( object.FindAttribute( KMenuAttrUid(), uidStr, tmp) )
|
|
421 |
{
|
|
422 |
ValidateLinkUidL( aFolder, aId, uidStr );
|
|
423 |
}
|
|
424 |
else
|
|
425 |
{
|
|
426 |
UpdateLinkL( aId, EFalse, EFalse, EFalse );
|
|
427 |
}
|
|
428 |
}
|
|
429 |
|
|
430 |
// ---------------------------------------------------------
|
|
431 |
// CMenuSrvAppScanner::UpdateLinkItemsL
|
|
432 |
// ---------------------------------------------------------
|
|
433 |
//
|
|
434 |
void CMenuSrvAppScanner::UpdateLinkItemsL()
|
|
435 |
{
|
|
436 |
TInt root;
|
|
437 |
iEng.RootFolderL( root );
|
|
438 |
|
|
439 |
TMenuSrvTypeFilter linkFilter;
|
|
440 |
linkFilter.SetType( KMenuTypeLink() );
|
|
441 |
|
|
442 |
RArray<TMenuItem> items;
|
|
443 |
CleanupClosePushL( items );
|
|
444 |
iEng.GetItemsL( items, root, &linkFilter, ETrue );
|
|
445 |
|
|
446 |
for (TInt i=0; i < items.Count(); i++)
|
|
447 |
{
|
|
448 |
ValidateLinkL( root, items[i].Id() );
|
|
449 |
}
|
|
450 |
CleanupStack::PopAndDestroy( &items );
|
|
451 |
}
|
|
452 |
|
|
453 |
// ---------------------------------------------------------
|
|
454 |
// CMenuSrvAppScanner::HandleFreeSpaceEventL
|
|
455 |
// ---------------------------------------------------------
|
|
456 |
//
|
|
457 |
void CMenuSrvAppScanner::HandleFreeSpaceEventL()
|
|
458 |
{
|
|
459 |
if ( !IsActive() && !iOpStatus )
|
|
460 |
{
|
|
461 |
iOpStatus = ETrue;
|
|
462 |
TRequestStatus* ownStatus = &iStatus;
|
|
463 |
*ownStatus = KRequestPending;
|
|
464 |
SetActive();
|
|
465 |
User::RequestComplete( ownStatus, KErrNone );
|
|
466 |
}
|
|
467 |
}
|
|
468 |
// ---------------------------------------------------------
|
|
469 |
// CMenuSrvAppScanner::RunMenuEngOperationL
|
|
470 |
// ---------------------------------------------------------
|
|
471 |
//
|
|
472 |
void CMenuSrvAppScanner::RunMenuEngOperationL()
|
|
473 |
{
|
|
474 |
UpdateApplicationItemsL();
|
|
475 |
UpdateApplicationWithHideIfInstalledItemsL();
|
|
476 |
UpdateLinkItemsL();
|
|
477 |
iOpStatus = EFalse;
|
|
478 |
}
|
|
479 |
|
|
480 |
|
|
481 |
// ---------------------------------------------------------
|
|
482 |
// CMenuSrvAppScanner::UpdateApplicationItemL
|
|
483 |
// ---------------------------------------------------------
|
|
484 |
//
|
|
485 |
void CMenuSrvAppScanner::UpdateApplicationItemL(
|
|
486 |
RArray<TMenuItem>& aMcsItems, const CMenuSrvAppAttributes& aApaItem,
|
|
487 |
TUint aMmcId, TBool isLegacy)
|
|
488 |
{
|
|
489 |
RArray<TMenuItem> mcsUidItems;
|
|
490 |
CleanupClosePushL( mcsUidItems );
|
|
491 |
TUid appuid = aApaItem.GetUid();
|
|
492 |
GetMcsAppItemsL( isLegacy, appuid.iUid, mcsUidItems );
|
|
493 |
TBool isApaItemHidden( aApaItem.IsHidden() );
|
|
494 |
|
|
495 |
// This app is not in the menu, add it now.
|
|
496 |
// We don't add hidden items, there are too many of them!
|
|
497 |
// do not display Menu app
|
|
498 |
if ( !mcsUidItems.Count()
|
|
499 |
&& !isApaItemHidden
|
|
500 |
&& appuid != KMmUid3 )
|
|
501 |
{
|
|
502 |
if( appuid == KSatUid )
|
|
503 |
{
|
|
504 |
if( CMcsSatHandler::CheckVisibility() )
|
|
505 |
{
|
|
506 |
AddAppItemL( aApaItem, aMmcId );
|
|
507 |
}
|
|
508 |
}
|
|
509 |
else
|
|
510 |
{
|
|
511 |
AddAppItemL( aApaItem, aMmcId );
|
|
512 |
GetMcsAppItemsL( isLegacy, appuid.iUid, mcsUidItems );
|
|
513 |
}
|
|
514 |
}//if
|
|
515 |
|
|
516 |
// if there are any items with legacy UID format
|
|
517 |
// update them to new uid format
|
|
518 |
else if ( mcsUidItems.Count() && isLegacy )
|
|
519 |
{
|
|
520 |
//for every item with matching UID
|
|
521 |
for (TInt j=0; j < mcsUidItems.Count(); j++)
|
|
522 |
{
|
|
523 |
CMenuEngObject& object =
|
|
524 |
iEng.ModifiableObjectL( mcsUidItems[j].Id() );
|
|
525 |
TBuf<KUidChars> uidString;
|
|
526 |
MenuSrvUtil::UidToStringL( appuid.iUid, uidString, EFalse, EHex );
|
|
527 |
object.SetAttributeL( KMenuAttrUid(), uidString, EFalse );
|
|
528 |
}//for
|
|
529 |
}//else if
|
|
530 |
// "hidden", "missing" and "lock_delete" flags update
|
|
531 |
for ( TInt j = 0; j < mcsUidItems.Count(); j++ )
|
|
532 |
{
|
|
533 |
const TMenuItem& item = mcsUidItems[j];
|
|
534 |
|
|
535 |
//we need to handle first run of appscanner,
|
|
536 |
//there might be some incorrect data in content xml file
|
|
537 |
//if this will have impact on performance we may run this methods only at start up
|
|
538 |
HandleMmcAttrUpdateL( item, aApaItem, aMmcId );
|
|
539 |
HandleNativeAttrUpdateL( item, aApaItem );
|
|
540 |
|
|
541 |
// "hidden" flag handling.
|
|
542 |
HandleHiddenFlagUpdateL( item, aApaItem );
|
|
543 |
|
|
544 |
// "missing" flag handling
|
|
545 |
HandleMissingFlagUpdateL( item );
|
|
546 |
|
|
547 |
//"lock_delete" flag handling
|
|
548 |
HandleLockDeleteFlagUpdateL(item, aApaItem );
|
|
549 |
// if item was just added to MCS it is not present in aMcsItems
|
|
550 |
// so we cannot remove it
|
|
551 |
TInt index = aMcsItems.Find( item, TIdentityRelation<TMenuItem>( IdMatch ) );
|
|
552 |
if ( index != KErrNotFound )
|
|
553 |
{
|
|
554 |
aMcsItems.Remove( index );
|
|
555 |
}
|
|
556 |
}//for
|
|
557 |
CleanupStack::PopAndDestroy( &mcsUidItems );
|
|
558 |
}
|
|
559 |
|
|
560 |
// ---------------------------------------------------------
|
|
561 |
// CMenuSrvAppScanner::HandleHiddenFlagUpdateL
|
|
562 |
// ---------------------------------------------------------
|
|
563 |
//
|
|
564 |
void CMenuSrvAppScanner::HandleHiddenFlagUpdateL( const TMenuItem & aItem,
|
|
565 |
const CMenuSrvAppAttributes& aApaItem )
|
|
566 |
{
|
|
567 |
TBool itemHidden = (0 != (aItem.Flags() & TMenuItem::EHidden));
|
|
568 |
if ( aApaItem.GetUid() == KSatUid )
|
|
569 |
{
|
|
570 |
if (itemHidden == CMcsSatHandler::CheckVisibility())
|
|
571 |
{
|
|
572 |
iEng.ModifiableObjectL(aItem.Id(), RMenuNotifier::EItemsAddedRemoved).
|
|
573 |
SetFlags( TMenuItem::EHidden, !CMcsSatHandler::CheckVisibility());
|
|
574 |
}
|
|
575 |
}
|
|
576 |
else if ( itemHidden != aApaItem.IsHidden() )
|
|
577 |
{
|
|
578 |
iEng.ModifiableObjectL(aItem.Id(), RMenuNotifier::EItemsAddedRemoved).
|
|
579 |
SetFlags( TMenuItem::EHidden, aApaItem.IsHidden() );
|
|
580 |
}
|
|
581 |
}
|
|
582 |
|
|
583 |
// ---------------------------------------------------------
|
|
584 |
// CMenuSrvAppScanner::HandleNativeAttrUpdateL
|
|
585 |
// ---------------------------------------------------------
|
|
586 |
//
|
|
587 |
void CMenuSrvAppScanner::HandleNativeAttrUpdateL(
|
|
588 |
const TMenuItem& aItem, const CMenuSrvAppAttributes& aApaItem )
|
|
589 |
{
|
|
590 |
//we need this to delete uninstalled java app item
|
|
591 |
if( aApaItem.GetAppType() != iEng.ObjectL( aItem.Id() ).GetAppType() )
|
|
592 |
{
|
|
593 |
iEng.ModifiableObjectL( aItem.Id(),
|
|
594 |
RMenuNotifier::EItemsNone ).SetAppType( aApaItem.GetAppType() );
|
|
595 |
}
|
|
596 |
}
|
|
597 |
|
|
598 |
|
|
599 |
// ---------------------------------------------------------
|
|
600 |
// CMenuSrvAppScanner::HandleMmcAttrUpdateL
|
|
601 |
// ---------------------------------------------------------
|
|
602 |
//
|
|
603 |
void CMenuSrvAppScanner::HandleMmcAttrUpdateL(
|
|
604 |
const TMenuItem& aItem, const CMenuSrvAppAttributes& aApaItem, TUint aMmcId )
|
|
605 |
{
|
|
606 |
if ( IsInMmc( aApaItem ) )
|
|
607 |
{
|
|
608 |
//app is instaled on mmc - KMenuAttrMmcId attribute update
|
|
609 |
TBuf<KUidChars> uidString;
|
|
610 |
uidString.Format( KHexFormat, aMmcId );
|
|
611 |
iEng.ModifiableObjectL( aItem.Id(), RMenuNotifier::EItemsAddedRemoved ).
|
|
612 |
SetAttributeL( KMenuAttrMmcId, uidString, EFalse );
|
|
613 |
}
|
|
614 |
else if ( IsInMassStorage( aApaItem )
|
|
615 |
&& aApaItem.GetAppType() == CMenuEngObject::EWidgetApp )
|
|
616 |
{
|
|
617 |
//its java app installed on mass storage, we need to leave it in xml
|
|
618 |
//in case of connecting usb in mass storage mode
|
|
619 |
iEng.ModifiableObjectL( aItem.Id(), RMenuNotifier::EItemsAddedRemoved ).
|
|
620 |
SetAttributeL( KMenuAttrMmcId, KMenuMassStorage, EFalse );
|
|
621 |
}
|
|
622 |
else
|
|
623 |
{
|
|
624 |
//its installed on c: drive - remove attribute
|
|
625 |
iEng.ModifiableObjectL( aItem.Id(), RMenuNotifier::EItemsAddedRemoved ).
|
|
626 |
RemoveAttribute( KMenuAttrMmcId );
|
|
627 |
}
|
|
628 |
}
|
|
629 |
// ---------------------------------------------------------
|
|
630 |
// CMenuSrvAppScanner::UpdateApplicationItemsL
|
|
631 |
// ---------------------------------------------------------
|
|
632 |
//
|
|
633 |
void CMenuSrvAppScanner::UpdateApplicationItemsL()
|
|
634 |
{
|
|
635 |
TUint currentMmcId = UpdateMmcHistoryL();
|
|
636 |
// get all MCS items
|
|
637 |
RArray<TMenuItem> mcsItems;
|
|
638 |
CleanupClosePushL( mcsItems );
|
|
639 |
GetMcsAppItemsL( mcsItems );
|
|
640 |
iSrvEngUtils.ReloadApaItemsL();
|
|
641 |
GetCrItemsL( iSrvEngUtils.GetAppItemsL() );
|
|
642 |
TBool isLegacy = iEng.GetOnceLegacyFormat();
|
|
643 |
|
|
644 |
|
|
645 |
//for every item in apaAndCrItems array
|
|
646 |
for ( TInt i = ( iSrvEngUtils.GetAppItemsL().Count() - 1 ); i >= 0 ; i-- )
|
|
647 |
{
|
|
648 |
// if there was leave for any item we ignore it
|
|
649 |
// and proceed to the next one
|
|
650 |
TRAP_IGNORE(UpdateApplicationItemL(
|
|
651 |
mcsItems, *iSrvEngUtils.GetAppItemsL()[i], currentMmcId, isLegacy));
|
|
652 |
}
|
|
653 |
// Here the big list contains menu items that refer to missing apps.
|
|
654 |
HandleMissingItemsL( mcsItems );
|
|
655 |
CleanupStack::PopAndDestroy( &mcsItems );
|
|
656 |
}
|
|
657 |
|
|
658 |
// ---------------------------------------------------------
|
|
659 |
// CMenuSrvAppScanner::HandleLockDeleteFlagUpdateL
|
|
660 |
// ---------------------------------------------------------
|
|
661 |
//
|
|
662 |
void CMenuSrvAppScanner::HandleLockDeleteFlagUpdateL(
|
|
663 |
const TMenuItem& aItem, const CMenuSrvAppAttributes& aApaItem )
|
|
664 |
{
|
|
665 |
TBool isHidden = ( ( iEng.ObjectL( aItem.Id() )
|
|
666 |
.Flags() & TMenuItem::EHidden ) != 0 );
|
|
667 |
if ( !isHidden && IsInRomL( aApaItem ) )
|
|
668 |
{
|
|
669 |
if ( ( aItem.Flags() & TMenuItem::ELockDelete ) == 0 )
|
|
670 |
{
|
|
671 |
iEng.ModifiableObjectL(aItem.Id())
|
|
672 |
.SetFlags( TMenuItem::ELockDelete, ETrue );
|
|
673 |
}
|
|
674 |
}
|
|
675 |
else
|
|
676 |
{
|
|
677 |
if ( ( aItem.Flags() & TMenuItem::ELockDelete ) != 0 )
|
|
678 |
{
|
|
679 |
iEng.ModifiableObjectL(aItem.Id())
|
|
680 |
.SetFlags( TMenuItem::ELockDelete, EFalse );
|
|
681 |
}
|
|
682 |
}
|
|
683 |
}
|
|
684 |
|
|
685 |
// ---------------------------------------------------------
|
|
686 |
// CMenuSrvAppScanner::HandleMissingFlagUpdateL
|
|
687 |
// ---------------------------------------------------------
|
|
688 |
//
|
|
689 |
void CMenuSrvAppScanner::HandleMissingFlagUpdateL( const TMenuItem& aItem )
|
|
690 |
{
|
|
691 |
if ( aItem.Flags() & TMenuItem::EMissing )
|
|
692 |
{
|
|
693 |
CLOG_WRITE_FORMAT8( "Unsetting flag EMissing on %d", item.Id() );
|
|
694 |
//application found so we unset "missing" flag
|
|
695 |
iEng.ModifiableObjectL( aItem.Id(), RMenuNotifier::EItemsAddedRemoved ).
|
|
696 |
SetFlags( TMenuItem::EMissing, EFalse );
|
|
697 |
}
|
|
698 |
}
|
|
699 |
|
|
700 |
// ---------------------------------------------------------
|
|
701 |
// CMenuSrvAppScanner::GetCrItemsL
|
|
702 |
// ---------------------------------------------------------
|
|
703 |
//
|
|
704 |
void CMenuSrvAppScanner::GetCrItemsL( RPointerArray<CMenuSrvAppAttributes>& aArray )
|
|
705 |
{
|
|
706 |
TBuf<KCenRepBufferSize> buf;
|
|
707 |
iCenRepSession->Get( KMenuHideCPApplication, buf );
|
|
708 |
ParseUidsL( buf, aArray );// parses UIDs from buf and appends them to array
|
|
709 |
iCenRepSession->Get( KMenuHideApplication, buf );
|
|
710 |
ParseUidsL( buf, aArray );// parses UIDs from buf and appends them to array
|
|
711 |
}
|
|
712 |
|
|
713 |
// ---------------------------------------------------------
|
|
714 |
// CMenuSrvAppScanner::ParseUidsL
|
|
715 |
// ---------------------------------------------------------
|
|
716 |
//
|
|
717 |
void CMenuSrvAppScanner::ParseUidsL( const TDesC& aHiddenApplications,
|
|
718 |
RPointerArray<CMenuSrvAppAttributes>& aArray )
|
|
719 |
{
|
|
720 |
TLex input( aHiddenApplications );
|
|
721 |
TLexMark startMark;
|
|
722 |
input.Mark( startMark );
|
|
723 |
TBool notEmpty = EFalse;
|
|
724 |
while ( !input.Eos() )
|
|
725 |
{
|
|
726 |
if( input.Peek() == ',')
|
|
727 |
{
|
|
728 |
SetHidden(input.MarkedToken( startMark ), aArray);
|
|
729 |
input.Inc();
|
|
730 |
input.Mark( startMark );
|
|
731 |
}
|
|
732 |
input.Inc();
|
|
733 |
notEmpty = ETrue;
|
|
734 |
}
|
|
735 |
if ( notEmpty )
|
|
736 |
{
|
|
737 |
SetHidden(input.MarkedToken( startMark ), aArray);
|
|
738 |
}
|
|
739 |
|
|
740 |
|
|
741 |
}
|
|
742 |
|
|
743 |
// ---------------------------------------------------------
|
|
744 |
// CMenuSrvAppScanner::SetHidden
|
|
745 |
// ---------------------------------------------------------
|
|
746 |
//
|
|
747 |
void CMenuSrvAppScanner::SetHidden(
|
|
748 |
const TDesC& aHiddenAppUid, RPointerArray<CMenuSrvAppAttributes>& aArray )
|
|
749 |
{
|
|
750 |
TLex appUidDescriptor(aHiddenAppUid);
|
|
751 |
TUint hiddenAppUid( 0 );
|
|
752 |
appUidDescriptor.Val( hiddenAppUid, EHex );
|
|
753 |
if ( hiddenAppUid )
|
|
754 |
{
|
|
755 |
TApaAppCapabilityBuf capability;
|
|
756 |
TApaAppInfo appInfo;
|
|
757 |
appInfo.iUid = TUid::Uid( hiddenAppUid );
|
|
758 |
CMenuSrvAppAttributes* attribute = CMenuSrvAppAttributes::NewLC( capability, appInfo );
|
|
759 |
TInt index = aArray.Find( attribute,
|
|
760 |
TIdentityRelation<CMenuSrvAppAttributes>( CMenuSrvAppAttributes::MatchItems ) );
|
|
761 |
if( index >= 0 && !aArray[index]->IsHidden() )
|
|
762 |
{
|
|
763 |
aArray[index]->SetHidden( ETrue );
|
|
764 |
}
|
|
765 |
CleanupStack::PopAndDestroy( attribute );
|
|
766 |
}
|
|
767 |
}
|
|
768 |
|
|
769 |
|
|
770 |
// ---------------------------------------------------------
|
|
771 |
// CMenuSrvAppScanner::GetMcsItemsL
|
|
772 |
// ---------------------------------------------------------
|
|
773 |
//
|
|
774 |
void CMenuSrvAppScanner::GetMcsAppItemsL( RArray<TMenuItem>& aArray )
|
|
775 |
{
|
|
776 |
TInt root;
|
|
777 |
iEng.RootFolderL( root );
|
|
778 |
TMenuSrvTypeFilter appFilter;
|
|
779 |
appFilter.SetType( KMenuTypeApp() );
|
|
780 |
iEng.GetItemsL( aArray, root, &appFilter, ETrue );
|
|
781 |
}
|
|
782 |
|
|
783 |
// ---------------------------------------------------------
|
|
784 |
// CMenuSrvAppScanner::GetMcsItemsL
|
|
785 |
// ---------------------------------------------------------
|
|
786 |
//
|
|
787 |
void CMenuSrvAppScanner::GetMcsAppItemsL( TBool aLegacy,
|
|
788 |
const TUint aUid, RArray<TMenuItem>& aArray )
|
|
789 |
{
|
|
790 |
TInt root;
|
|
791 |
iEng.RootFolderL( root );
|
|
792 |
TMenuSrvTypeAttrFilter appFilter;
|
|
793 |
appFilter.SetType( KMenuTypeApp() );
|
|
794 |
TBuf<KUidChars> uidString;
|
|
795 |
MenuSrvUtil::UidToStringL( aUid, uidString, aLegacy, EHex );
|
|
796 |
appFilter.SetAttr( KMenuAttrUid(), uidString );
|
|
797 |
iEng.GetItemsL( aArray, root, &appFilter, ETrue );
|
|
798 |
//if not found in mcs try with UID in decimal format
|
|
799 |
if (!aArray.Count())
|
|
800 |
{
|
|
801 |
MenuSrvUtil::UidToStringL( aUid, uidString, aLegacy, EDecimal );
|
|
802 |
appFilter.SetAttr( KMenuAttrUid(), uidString );
|
|
803 |
iEng.GetItemsL( aArray, root, &appFilter, ETrue );
|
|
804 |
}
|
|
805 |
}
|
|
806 |
|
|
807 |
|
|
808 |
// ---------------------------------------------------------
|
|
809 |
// CMenuSrvAppScanner::CompletedMenuEngOperation
|
|
810 |
// ---------------------------------------------------------
|
|
811 |
//
|
|
812 |
void CMenuSrvAppScanner::CompletedMenuEngOperation( TInt /*aErr*/ )
|
|
813 |
{
|
|
814 |
iOpStatus = EFalse;
|
|
815 |
}
|
|
816 |
|
|
817 |
// ---------------------------------------------------------
|
|
818 |
// CMenuSrvAppScanner::HandleAppListEvent
|
|
819 |
// ---------------------------------------------------------
|
|
820 |
//
|
|
821 |
void CMenuSrvAppScanner::HandleAppListEvent( TInt /*aEvent*/ )
|
|
822 |
{
|
|
823 |
// We only have one event, EAppListChanged.
|
|
824 |
// Call back RunL async, to requeue and initiate rescan.
|
|
825 |
if ( !IsActive() && !iOpStatus)
|
|
826 |
{
|
|
827 |
iOpStatus = ETrue;
|
|
828 |
TRequestStatus* ownStatus = &iStatus;
|
|
829 |
*ownStatus = KRequestPending;
|
|
830 |
SetActive();
|
|
831 |
User::RequestComplete( ownStatus, KErrNone );
|
|
832 |
}
|
|
833 |
}
|
|
834 |
|
|
835 |
// -----------------------------------------------------------------------------
|
|
836 |
// CMenuSrvAppScanner::HandleNotifyString
|
|
837 |
// -----------------------------------------------------------------------------
|
|
838 |
//
|
|
839 |
void CMenuSrvAppScanner::HandleNotifyString( TUint32 aKey,
|
|
840 |
const TDesC16& /*aNewValue*/ )
|
|
841 |
{
|
|
842 |
if((aKey == KMenuHideApplication )||(aKey == KMenuHideCPApplication))
|
|
843 |
{
|
|
844 |
if ( !IsActive() && !iOpStatus )
|
|
845 |
{
|
|
846 |
iOpStatus = ETrue;
|
|
847 |
TRequestStatus* ownStatus = &iStatus;
|
|
848 |
*ownStatus = KRequestPending;
|
|
849 |
SetActive();
|
|
850 |
User::RequestComplete( ownStatus, KErrNone );
|
|
851 |
}
|
|
852 |
}
|
|
853 |
}
|
|
854 |
|
|
855 |
// -----------------------------------------------------------------------------
|
|
856 |
// CMenuSrvAppScanner::SATChangeL
|
|
857 |
// -----------------------------------------------------------------------------
|
|
858 |
//
|
|
859 |
void CMenuSrvAppScanner::SATChangeL()
|
|
860 |
{
|
|
861 |
ScheduleScan();
|
|
862 |
}
|
|
863 |
|
|
864 |
// ---------------------------------------------------------
|
|
865 |
// CMenuSrvAppScanner::ScheduleScan
|
|
866 |
// ---------------------------------------------------------
|
|
867 |
//
|
|
868 |
void CMenuSrvAppScanner::ScheduleScan()
|
|
869 |
{
|
|
870 |
if ( !IsActive() && !iOpStatus )
|
|
871 |
{
|
|
872 |
iOpStatus = ETrue;
|
|
873 |
TRequestStatus* ownStatus = &iStatus;
|
|
874 |
*ownStatus = KRequestPending;
|
|
875 |
SetActive();
|
|
876 |
User::RequestComplete( ownStatus, KErrNone );
|
|
877 |
}
|
|
878 |
}
|
|
879 |
|
|
880 |
// ---------------------------------------------------------
|
|
881 |
// CMenuSrvAppScanner::CreateInstallFolderL
|
|
882 |
// ---------------------------------------------------------
|
|
883 |
//
|
|
884 |
TInt CMenuSrvAppScanner::CreateInstallFolderL( const CMenuSrvAppAttributes& aApaItem )
|
|
885 |
{
|
|
886 |
// Find a folder for this app.
|
|
887 |
TInt folder(0);
|
|
888 |
if ( aApaItem.GetGroupName().Length() )
|
|
889 |
{
|
|
890 |
// appgroup_name is defined for this app. Find or create folder.
|
|
891 |
AppGroupFolderL( aApaItem.GetGroupName(), folder );
|
|
892 |
}
|
|
893 |
else
|
|
894 |
{
|
|
895 |
// No appgroup_name, use default folder, if any.
|
|
896 |
DefaultFolderL( folder );
|
|
897 |
}
|
|
898 |
if ( !folder )
|
|
899 |
{
|
|
900 |
// Last resort: it goes to the root.
|
|
901 |
iEng.RootFolderL( folder );
|
|
902 |
}
|
|
903 |
return folder;
|
|
904 |
}
|
|
905 |
|
|
906 |
// ---------------------------------------------------------
|
|
907 |
// CMenuSrvAppScanner::AddAppItemL
|
|
908 |
// ---------------------------------------------------------
|
|
909 |
//
|
|
910 |
void CMenuSrvAppScanner::AddAppItemL(
|
|
911 |
const CMenuSrvAppAttributes& aApaItem,
|
|
912 |
TUint aCurrentMmcId )
|
|
913 |
{
|
|
914 |
TInt folder = CreateInstallFolderL( aApaItem );
|
|
915 |
// Now add the app item.
|
|
916 |
CMenuEngObject* object = iEng.NewObjectL( KMenuTypeApp() );
|
|
917 |
CleanupStack::PushL( object );
|
|
918 |
TBuf<KUidChars> uidString;
|
|
919 |
_LIT(KHexFormat, "0x%X");
|
|
920 |
uidString.Format( KHexFormat, aApaItem.GetUid().iUid );
|
|
921 |
|
|
922 |
object->SetAttributeL( KMenuAttrUid(), uidString, EFalse );
|
|
923 |
if ( aCurrentMmcId && IsInMmc( aApaItem ) )
|
|
924 |
{
|
|
925 |
// This app is on the MMC, set the "mmc_id" attribute.
|
|
926 |
uidString.Format( KHexFormat, aCurrentMmcId );
|
|
927 |
object->SetAttributeL( KMenuAttrMmcId, uidString, EFalse );
|
|
928 |
}
|
|
929 |
if( aApaItem.GetAppType() == CMenuEngObject::EWidgetApp )
|
|
930 |
{
|
|
931 |
//we need this to delete uninstalled java or wrt widget app item
|
|
932 |
if ( !IsInMmc( aApaItem )
|
|
933 |
&& IsInMassStorage( aApaItem ) )
|
|
934 |
{
|
|
935 |
object->SetAttributeL( KMenuAttrMmcId, KMenuMassStorage, EFalse );
|
|
936 |
}
|
|
937 |
}
|
|
938 |
object->SetAppType( aApaItem.GetAppType() );
|
|
939 |
EnsureFolderWritableL( folder );
|
|
940 |
iEng.AddL( *object, folder, 0 );
|
|
941 |
CleanupStack::Pop( object );
|
|
942 |
}
|
|
943 |
|
|
944 |
// ---------------------------------------------------------
|
|
945 |
// CMenuSrvAppScanner::AppGroupFolderL
|
|
946 |
// ---------------------------------------------------------
|
|
947 |
//
|
|
948 |
void CMenuSrvAppScanner::AppGroupFolderL( const TDesC& aAppGroupName, TInt& aFolderId )
|
|
949 |
{
|
|
950 |
__ASSERT_DEBUG( aAppGroupName.Length(), User::Invariant() );
|
|
951 |
|
|
952 |
TInt folder = 0;
|
|
953 |
TInt defaultFolderId( 0 );
|
|
954 |
iEng.RootFolderL( defaultFolderId );
|
|
955 |
const CMenuEngObject& rootObject = iEng.ObjectL( defaultFolderId );
|
|
956 |
TPtrC groupName;
|
|
957 |
TBool localized;
|
|
958 |
|
|
959 |
if ( rootObject.FindAttribute( KMenuAttrAppGroupName, groupName, localized ) &&
|
|
960 |
groupName.Compare( aAppGroupName )==0 )
|
|
961 |
{
|
|
962 |
folder = defaultFolderId;
|
|
963 |
}
|
|
964 |
else
|
|
965 |
{
|
|
966 |
TMenuSrvTypeAttrFilter filter;
|
|
967 |
filter.SetType( KMenuTypeFolder() );
|
|
968 |
filter.SetAttr( KMenuAttrAppGroupName(), aAppGroupName );
|
|
969 |
RArray<TMenuItem> items;
|
|
970 |
CleanupClosePushL( items );
|
|
971 |
|
|
972 |
iEng.GetItemsL( items, defaultFolderId, &filter, ETrue );
|
|
973 |
if ( items.Count() )
|
|
974 |
{
|
|
975 |
folder = items[0].Id();
|
|
976 |
}
|
|
977 |
CleanupStack::PopAndDestroy( &items );
|
|
978 |
}
|
|
979 |
if ( !folder )
|
|
980 |
{
|
|
981 |
// No such folder, create it now.
|
|
982 |
CMenuEngObject* object = iEng.NewObjectL( KMenuTypeFolder() );
|
|
983 |
CleanupStack::PushL( object );
|
|
984 |
object->SetAttributeL
|
|
985 |
( KMenuAttrAppGroupName(), aAppGroupName, EFalse );
|
|
986 |
EnsureFolderWritableL( defaultFolderId );
|
|
987 |
iEng.AddL( *object, defaultFolderId, 0 );
|
|
988 |
|
|
989 |
CleanupStack::Pop( object );
|
|
990 |
folder = object->Id();
|
|
991 |
}
|
|
992 |
__ASSERT_DEBUG( folder, User::Invariant() );
|
|
993 |
aFolderId = folder;
|
|
994 |
}
|
|
995 |
|
|
996 |
// ---------------------------------------------------------
|
|
997 |
// CMenuSrvAppScanner::DefaultFolderL
|
|
998 |
// ---------------------------------------------------------
|
|
999 |
//
|
|
1000 |
void CMenuSrvAppScanner::DefaultFolderL( TInt& aFolderId )
|
|
1001 |
{
|
|
1002 |
TInt folder = 0;
|
|
1003 |
TMenuSrvTypeAttrFilter filter;
|
|
1004 |
filter.SetType( KMenuTypeFolder() );
|
|
1005 |
filter.SetAttr( KMenuAttrDefault(), KMenuOne() );
|
|
1006 |
RArray<TMenuItem> items;
|
|
1007 |
CleanupClosePushL( items );
|
|
1008 |
TInt rootId;
|
|
1009 |
iEng.RootFolderL( rootId );
|
|
1010 |
iEng.GetItemsL( items, rootId, &filter, ETrue );
|
|
1011 |
if ( items.Count() )
|
|
1012 |
{
|
|
1013 |
folder = items[0].Id();
|
|
1014 |
}
|
|
1015 |
CleanupStack::PopAndDestroy( &items );
|
|
1016 |
aFolderId = folder;
|
|
1017 |
}
|
|
1018 |
|
|
1019 |
// ---------------------------------------------------------
|
|
1020 |
// CMenuSrvAppScanner::EnsureFolderWritableL
|
|
1021 |
// ---------------------------------------------------------
|
|
1022 |
//
|
|
1023 |
void CMenuSrvAppScanner::EnsureFolderWritableL( TInt aFolder )
|
|
1024 |
{
|
|
1025 |
// This folder should not be read-only! Remove the protection.
|
|
1026 |
// Otherwise we can't add the items to it.
|
|
1027 |
if ( iEng.ObjectL( aFolder ).Flags() & TMenuItem::ELockMoveInto )
|
|
1028 |
{
|
|
1029 |
iEng.ModifiableObjectL( aFolder ).
|
|
1030 |
SetFlags( TMenuItem::ELockMoveInto, EFalse );
|
|
1031 |
}
|
|
1032 |
}
|
|
1033 |
|
|
1034 |
// ---------------------------------------------------------
|
|
1035 |
// CMenuSrvAppScanner::HandleMissingItemsL
|
|
1036 |
// ---------------------------------------------------------
|
|
1037 |
//
|
|
1038 |
TMenuItem::TFlags CMenuSrvAppScanner::GetProperFlagL( const TMenuItem& aItem )
|
|
1039 |
{
|
|
1040 |
TMenuItem::TFlags flags = TMenuItem::ENoFlag;
|
|
1041 |
|
|
1042 |
TUint mmcId = 0;
|
|
1043 |
TPtrC val;
|
|
1044 |
TBool dummy;
|
|
1045 |
if( iEng.ObjectL( aItem.Id() ).FindAttribute( KMenuAttrMmcId(), val, dummy ) )
|
|
1046 |
{
|
|
1047 |
MenuUtils::GetTUint( val, mmcId );
|
|
1048 |
if ( mmcId && KErrNotFound != iMmcHistory->Find( mmcId ) )
|
|
1049 |
{
|
|
1050 |
// This item is on an MMC which is currently in the MMC history.
|
|
1051 |
// Set it "missing" but keep it.
|
|
1052 |
flags = TMenuItem::EMissing;
|
|
1053 |
}
|
|
1054 |
else if ( val == KMenuMassStorage()
|
|
1055 |
&& IsDriveInUse( DriveInfo::EDefaultMassStorage ) )
|
|
1056 |
{
|
|
1057 |
flags = TMenuItem::EMissing;
|
|
1058 |
}
|
|
1059 |
else if ( iEng.ObjectL( aItem.Id() ).FindAttribute(
|
|
1060 |
KMenuAttrPredefined(), val, dummy ) )
|
|
1061 |
{
|
|
1062 |
flags = TMenuItem::EMissing;
|
|
1063 |
}
|
|
1064 |
}
|
|
1065 |
else if( iEng.ObjectL( aItem.Id() ).GetAppType()
|
|
1066 |
!= CMenuEngObject::EWidgetApp
|
|
1067 |
|| iEng.ObjectL( aItem.Id() ).FindAttribute(
|
|
1068 |
KMenuAttrPredefined(), val, dummy ) )
|
|
1069 |
{
|
|
1070 |
flags = TMenuItem::EHidden;
|
|
1071 |
}
|
|
1072 |
return flags;
|
|
1073 |
}
|
|
1074 |
|
|
1075 |
// ---------------------------------------------------------
|
|
1076 |
// CMenuSrvAppScanner::HandleMissingItemsL
|
|
1077 |
// ---------------------------------------------------------
|
|
1078 |
//
|
|
1079 |
void CMenuSrvAppScanner::HandleMissingItemsL(
|
|
1080 |
const RArray<TMenuItem>& aItems )
|
|
1081 |
{
|
|
1082 |
for ( TInt i = 0; i < aItems.Count(); i++ )
|
|
1083 |
{
|
|
1084 |
TMenuItem::TFlags flags = GetProperFlagL( aItems[i] );
|
|
1085 |
if( flags == TMenuItem::ENoFlag )
|
|
1086 |
{
|
|
1087 |
iEng.RemoveL( aItems[i].Id() );
|
|
1088 |
}
|
|
1089 |
else
|
|
1090 |
{
|
|
1091 |
SetObjectFlagsL( ETrue, aItems[i], flags,
|
|
1092 |
RMenuNotifier::EItemsAddedRemoved );
|
|
1093 |
}
|
|
1094 |
}
|
|
1095 |
}
|
|
1096 |
|
|
1097 |
// ---------------------------------------------------------
|
|
1098 |
// CMenuSrvAppScanner::SetObjectFlagsL
|
|
1099 |
// ---------------------------------------------------------
|
|
1100 |
//
|
|
1101 |
void CMenuSrvAppScanner::SetObjectFlagsL( TBool aFlagValue, const TMenuItem& aItem,
|
|
1102 |
const TMenuItem::TFlags& aFlag, const RMenuNotifier::TEvent& aEvent )
|
|
1103 |
{
|
|
1104 |
TBool itemFlagPresent = (0 != (aItem.Flags() & aFlag));
|
|
1105 |
if( aFlagValue != itemFlagPresent )
|
|
1106 |
{
|
|
1107 |
iEng.ModifiableObjectL( aItem.Id(), aEvent ).
|
|
1108 |
SetFlags( aFlag, aFlagValue );
|
|
1109 |
}
|
|
1110 |
}
|
|
1111 |
|
|
1112 |
// ---------------------------------------------------------
|
|
1113 |
// CMenuSrvAppScanner::UpdateMmcHistoryL
|
|
1114 |
// ---------------------------------------------------------
|
|
1115 |
//
|
|
1116 |
TUint CMenuSrvAppScanner::UpdateMmcHistoryL()
|
|
1117 |
{
|
|
1118 |
TUint mmcId = CurrentMmcId();
|
|
1119 |
if( mmcId )
|
|
1120 |
{
|
|
1121 |
iMmcHistory->InsertL( mmcId );
|
|
1122 |
iMmcHistory->SaveL( iFs, KMenuMmcHistoryFname() );
|
|
1123 |
}
|
|
1124 |
return mmcId;
|
|
1125 |
}
|
|
1126 |
|
|
1127 |
// ---------------------------------------------------------
|
|
1128 |
// CMenuSrvAppScanner::CurrentMmcId
|
|
1129 |
// ---------------------------------------------------------
|
|
1130 |
//
|
|
1131 |
TUint CMenuSrvAppScanner::CurrentMmcId() const
|
|
1132 |
{
|
|
1133 |
// Get mmc id. Errors are ignored.
|
|
1134 |
TUint mmcId = 0;
|
|
1135 |
TInt mmcDrive;
|
|
1136 |
TInt err;
|
|
1137 |
err = DriveInfo::GetDefaultDrive(
|
|
1138 |
DriveInfo::EDefaultRemovableMassStorage, mmcDrive );
|
|
1139 |
if ( !err )
|
|
1140 |
{
|
|
1141 |
TVolumeInfo volumeInfo;
|
|
1142 |
err = iFs.Volume( volumeInfo, mmcDrive );
|
|
1143 |
if( !err )
|
|
1144 |
{
|
|
1145 |
mmcId = volumeInfo.iUniqueID;
|
|
1146 |
}
|
|
1147 |
}
|
|
1148 |
return mmcId;
|
|
1149 |
}
|
|
1150 |
|
|
1151 |
// ---------------------------------------------------------
|
|
1152 |
// CMenuSrvAppScanner::IsFileInDrive
|
|
1153 |
// ---------------------------------------------------------
|
|
1154 |
//
|
|
1155 |
TBool CMenuSrvAppScanner::IsFileInDrive(
|
|
1156 |
const TDesC& aFileName,
|
|
1157 |
const DriveInfo::TDefaultDrives& aDefaultDrive ) const
|
|
1158 |
{
|
|
1159 |
if ( aFileName.Length() )
|
|
1160 |
{
|
|
1161 |
TInt mmcDrive;
|
|
1162 |
TInt err = DriveInfo::GetDefaultDrive(
|
|
1163 |
aDefaultDrive, mmcDrive );
|
|
1164 |
if ( !err )
|
|
1165 |
{
|
|
1166 |
TInt fileDrive;
|
|
1167 |
err = RFs::CharToDrive( aFileName[0], fileDrive );
|
|
1168 |
if ( !err && fileDrive == mmcDrive )
|
|
1169 |
{
|
|
1170 |
return ETrue;
|
|
1171 |
}
|
|
1172 |
}
|
|
1173 |
}
|
|
1174 |
return EFalse;
|
|
1175 |
}
|
|
1176 |
|
|
1177 |
// ---------------------------------------------------------
|
|
1178 |
// CMenuSrvAppScanner::IsAppInDrive
|
|
1179 |
// ---------------------------------------------------------
|
|
1180 |
//
|
|
1181 |
TBool CMenuSrvAppScanner::IsAppInDrive(
|
|
1182 |
const CMenuSrvAppAttributes& aApaItem,
|
|
1183 |
const DriveInfo::TDefaultDrives& aDefaultDrive ) const
|
|
1184 |
{
|
|
1185 |
TBool ret( EFalse );
|
|
1186 |
if ( IsFileInDrive( aApaItem.GetFullName(), aDefaultDrive ) )
|
|
1187 |
{
|
|
1188 |
ret = ETrue;
|
|
1189 |
}
|
|
1190 |
return ret;
|
|
1191 |
}
|
|
1192 |
|
|
1193 |
// ---------------------------------------------------------
|
|
1194 |
// CMenuSrvAppScanner::IsInMmc
|
|
1195 |
// ---------------------------------------------------------
|
|
1196 |
//
|
|
1197 |
TBool CMenuSrvAppScanner::IsInMmc( const CMenuSrvAppAttributes& aApaItem ) const
|
|
1198 |
{
|
|
1199 |
return IsAppInDrive( aApaItem, DriveInfo::EDefaultRemovableMassStorage );
|
|
1200 |
}
|
|
1201 |
|
|
1202 |
// ---------------------------------------------------------
|
|
1203 |
// CMenuSrvAppScanner::IsInMassStorage
|
|
1204 |
// ---------------------------------------------------------
|
|
1205 |
//
|
|
1206 |
TBool CMenuSrvAppScanner::IsInMassStorage( const CMenuSrvAppAttributes& aApaItem ) const
|
|
1207 |
{
|
|
1208 |
return IsAppInDrive( aApaItem, DriveInfo::EDefaultMassStorage );
|
|
1209 |
}
|
|
1210 |
|
|
1211 |
// ---------------------------------------------------------
|
|
1212 |
// CMenuSrvAppScanner::IsInRomL
|
|
1213 |
// ---------------------------------------------------------
|
|
1214 |
//
|
|
1215 |
TBool CMenuSrvAppScanner::IsInRomL( const CMenuSrvAppAttributes& aApaItem ) const
|
|
1216 |
{
|
|
1217 |
return IsAppInDrive( aApaItem, DriveInfo::EDefaultRom );
|
|
1218 |
}
|
|
1219 |
|
|
1220 |
// ---------------------------------------------------------
|
|
1221 |
// CMenuSrvAppScanner::IsDriveInUse
|
|
1222 |
// ---------------------------------------------------------
|
|
1223 |
//
|
|
1224 |
TBool CMenuSrvAppScanner::IsDriveInUse(
|
|
1225 |
const DriveInfo::TDefaultDrives& aDefaultDrive )
|
|
1226 |
{
|
|
1227 |
TBool inUse( EFalse );
|
|
1228 |
TInt drive;
|
|
1229 |
|
|
1230 |
TInt err = DriveInfo::GetDefaultDrive( aDefaultDrive, drive );
|
|
1231 |
if( err == KErrNone )
|
|
1232 |
{
|
|
1233 |
TUint status;
|
|
1234 |
err = DriveInfo::GetDriveStatus( iFs, drive, status );
|
|
1235 |
if( err == KErrNone
|
|
1236 |
&& ( status & DriveInfo::EDriveInUse ) )
|
|
1237 |
{
|
|
1238 |
inUse = ETrue;
|
|
1239 |
}
|
|
1240 |
}
|
|
1241 |
|
|
1242 |
return inUse;
|
|
1243 |
}
|
|
1244 |
|
|
1245 |
// End of File
|