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