|
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 |
|
18 // INCLUDE FILES |
|
19 #include "menusrveng.h" |
|
20 #include "menusrv.h" |
|
21 #include "menusrvsession.h" |
|
22 #include "menusrvdef.h" |
|
23 #include "menueng.h" |
|
24 #include "timeout.h" |
|
25 #include "menusrvappscanner.h" |
|
26 #include "mcssatmonitor.h" |
|
27 #include "menusrvfoldercrnotifier.h" |
|
28 #include "mcsmenuiconutility.h" |
|
29 #include "mcsmenuutils.h" |
|
30 #include "menusrvengutils.h" |
|
31 #include "mcsdrmhandler.h" |
|
32 #include "mcscachehandler.h" |
|
33 #include "mcschildrenhandler.h" |
|
34 #include "mcsrunningappshandler.h" |
|
35 #include "mcsgetlisthandler.h" |
|
36 #include "menusrvobjectfilter.h" |
|
37 #include "mcssuitehandler.h" |
|
38 #include <mcsdef.h> |
|
39 #include <mcsmenufilter.h> |
|
40 |
|
41 |
|
42 _LIT( KRunning16, "running" ); |
|
43 |
|
44 |
|
45 // ==================== LOCAL FUNCTIONS ==================== |
|
46 |
|
47 /** |
|
48 * Close Engine callback function. |
|
49 * @param aSrvEng CMenuSrvEng as TAny*. |
|
50 * @return KErrNone. |
|
51 */ |
|
52 LOCAL_C TInt CloseSrvEng( TAny* aSrvEng ) |
|
53 { |
|
54 CMenuSrvEng* srvEng = (CMenuSrvEng*)aSrvEng; |
|
55 // The timed close should be the last one closing it! |
|
56 __ASSERT_DEBUG( 1 == srvEng->AccessCount(), User::Invariant() ); |
|
57 srvEng->Close(); // Delete it. |
|
58 return KErrNone; |
|
59 } |
|
60 |
|
61 /** |
|
62 * Identity function to search in an array of TPtrC containing Attribute names. |
|
63 * Identity is the name of attribute. |
|
64 * @param aLeft Search term. |
|
65 * @param aRight Array item. |
|
66 * @return ETrue if names match. |
|
67 */ |
|
68 LOCAL_C TBool CmpAttrName( |
|
69 const TPtrC& aName1, |
|
70 const TPtrC& aName2 ) |
|
71 { |
|
72 return ( KErrNone == aName1.Compare( aName2 ) ); |
|
73 } |
|
74 |
|
75 // ==================== MEMBER FUNCTIONS ==================== |
|
76 // --------------------------------------------------------- |
|
77 // CMenuSrvEng::NewL |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 CMenuSrvEng* CMenuSrvEng::NewL |
|
81 ( CMenuSrv& aMenuSrv, const TDesC& aContentName ) |
|
82 { |
|
83 CMenuSrvEng* srv = new (ELeave) CMenuSrvEng( aMenuSrv ); |
|
84 CleanupClosePushL( *srv ); |
|
85 srv->ConstructL( aContentName ); |
|
86 CleanupStack::Pop( srv ); |
|
87 return srv; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // CMenuSrvEng::~CMenuSrvEng |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 CMenuSrvEng::~CMenuSrvEng() |
|
95 { |
|
96 __ASSERT_DEBUG( !iSessions.Count(), User::Invariant() ); |
|
97 delete iGetlistHandler; |
|
98 delete iDrmHander; |
|
99 delete iChildrenHandler; |
|
100 delete iTimedClose; |
|
101 delete iCMenuSrvEngUtils; |
|
102 iSessions.Close(); |
|
103 iContentName.Close(); |
|
104 delete iAppScanner; |
|
105 delete iFolderNotifier; |
|
106 delete iMcsSatMonitor; |
|
107 delete iRunningAppsHandler; |
|
108 delete iCacheHandler; |
|
109 delete iSuiteHandler; |
|
110 delete iEng; |
|
111 iMenuSrv.EngineDeleted(); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // CMenuSrvEng::CMenuSrvEng |
|
116 // --------------------------------------------------------- |
|
117 // |
|
118 CMenuSrvEng::CMenuSrvEng( CMenuSrv& aMenuSrv ): iMenuSrv( aMenuSrv ) |
|
119 { |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CMenuSrvEng::ConstructL |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 void CMenuSrvEng::ConstructL( const TDesC& aContentName ) |
|
127 { |
|
128 if ( !aContentName.Length() ) |
|
129 { |
|
130 // A name is required - only dead engines have empty name. |
|
131 User::Leave( KErrArgument ); |
|
132 } |
|
133 |
|
134 iContentName.CreateL( aContentName ); |
|
135 iTimedClose = CTimeout::NewL |
|
136 ( CActive::EPriorityStandard, TCallBack( CloseSrvEng, (TAny*)this ) ); |
|
137 iEng = CMenuEng::NewL( iContentName, *this ); |
|
138 if (iContentName.Length()) |
|
139 { |
|
140 iCacheHandler = CMcsCacheHandler::NewL( *iEng, *iCMenuSrvEngUtils ); |
|
141 |
|
142 iMcsSatMonitor = CMcsSatMonitor::NewL( *iEng ); |
|
143 |
|
144 iCMenuSrvEngUtils = CMenuSrvEngUtils::NewL( *iEng ); |
|
145 #ifndef __TEST_DISABLE_APPSCAN |
|
146 iAppScanner = CMenuSrvAppScanner::NewL( *iEng ); // Start automatic update. |
|
147 iFolderNotifier = CMenuSrvFolderCrNotifier::NewL( *iEng ); // Start automatic update. |
|
148 #endif |
|
149 |
|
150 iRunningAppsHandler = CMcsRunningAppsHandler::NewL( *iEng, |
|
151 *iCacheHandler ); |
|
152 |
|
153 iDrmHander = CMcsDrmHandler::NewL( |
|
154 *this, |
|
155 *iCMenuSrvEngUtils, |
|
156 *iCacheHandler ); |
|
157 iChildrenHandler = CMcsChildrenHandler::NewL( |
|
158 *this, |
|
159 *iCacheHandler); |
|
160 iSuiteHandler = CMcsSuiteHandler::NewL(*iEng, iContentName); |
|
161 |
|
162 iTimedClose->Cancel(); |
|
163 iTimedClose->After( TTimeIntervalMicroSeconds32( KMenuSrvExitDelay ) ); |
|
164 } |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // CMenuSrvEng::AddSessionL |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 void CMenuSrvEng::AddSessionL( CMenuSrvSession* aSession ) |
|
172 { |
|
173 // In AddSessionL() / RemoveSession(), the refcount is |
|
174 // increased / decreased. This has no other purpose than sanity-checking. |
|
175 // Otherwise, the session count controls the lifetime of this object. |
|
176 __ASSERT_DEBUG( KErrNotFound == iSessions.Find( aSession ), \ |
|
177 User::Invariant() ); |
|
178 iSessions.AppendL( aSession ); |
|
179 Open(); // Increase refcount. |
|
180 iTimedClose->Cancel(); // Stay alive. |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------- |
|
184 // CMenuSrvEng::RemoveSession |
|
185 // --------------------------------------------------------- |
|
186 // |
|
187 void CMenuSrvEng::RemoveSession( CMenuSrvSession* aSession ) |
|
188 { |
|
189 TInt i = iSessions.Find( aSession ); |
|
190 if ( KErrNotFound != i ) |
|
191 { |
|
192 iSessions.Remove( i ); |
|
193 Close(); // Decrease refcount. |
|
194 } |
|
195 if ( !iSessions.Count() ) |
|
196 { |
|
197 iTimedClose->Cancel(); |
|
198 CActiveScheduler* currentScheduler = CActiveScheduler::Current(); |
|
199 // No more sessions; schedule self-deletion. |
|
200 if (currentScheduler) |
|
201 { |
|
202 // No more sessions; schedule self-deletion. |
|
203 iTimedClose->After( TTimeIntervalMicroSeconds32( KMenuSrvExitDelay ) ); |
|
204 } |
|
205 else |
|
206 { |
|
207 // for Backup&Restore ActiveScheduler is closed ealier so we need |
|
208 // to decrease refcount here (not in CloseSrvEng()) |
|
209 Close(); |
|
210 } |
|
211 } |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------- |
|
215 // CMenuSrvEng::EngineEvents |
|
216 // --------------------------------------------------------- |
|
217 // |
|
218 void CMenuSrvEng::EngineEvents( TInt aFolder, TInt aEvents ) |
|
219 { |
|
220 // Broadcast to all sessions - for loop will do, we do not |
|
221 // expect any session to remove itself during this. |
|
222 for ( TInt i = 0; i < iSessions.Count(); i++ ) |
|
223 { |
|
224 iSessions[i]->EngineEvents( aFolder, aEvents ); |
|
225 } |
|
226 if (iDrmHander) |
|
227 { |
|
228 iDrmHander->EngineEvents( aFolder, aEvents ); |
|
229 } |
|
230 if (iChildrenHandler) |
|
231 { |
|
232 iChildrenHandler->EngineEvents( aFolder, aEvents ); |
|
233 } |
|
234 if (iRunningAppsHandler) |
|
235 { |
|
236 iRunningAppsHandler->EngineEvents( aFolder, aEvents ); |
|
237 } |
|
238 if( iCacheHandler && iCacheHandler->iAttrCache.Count() > 0 ) |
|
239 { |
|
240 iCacheHandler->EngineEvents( aEvents ); |
|
241 } |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------- |
|
245 // CMenuSrvEng::EngineError |
|
246 // --------------------------------------------------------- |
|
247 // |
|
248 void CMenuSrvEng::EngineError( TInt aErr ) |
|
249 { |
|
250 // Unrecoverable engine error. |
|
251 // Broadcast to all sessions before killing ourselves. |
|
252 while ( iSessions.Count() ) |
|
253 { |
|
254 CMenuSrvSession* session = iSessions[0]; |
|
255 iSessions.Remove( 0 ); |
|
256 Close(); // Decrease refcount. |
|
257 session->EngineError( aErr ); |
|
258 } |
|
259 // No more sessions; schedule self-deletion. |
|
260 // We could close ourselves immediately, but that would cause the server |
|
261 // to exit immediately. Therefore, we use the delayed exit, but clear the |
|
262 // name so the server cannot find us and reuse. |
|
263 delete iDrmHander; iDrmHander = NULL; |
|
264 delete iChildrenHandler, iChildrenHandler = NULL; |
|
265 delete iMcsSatMonitor; iMcsSatMonitor = NULL; |
|
266 delete iRunningAppsHandler; iRunningAppsHandler = NULL; |
|
267 delete iAppScanner; iAppScanner = NULL; |
|
268 delete iFolderNotifier; iFolderNotifier = NULL; |
|
269 delete iSuiteHandler; iSuiteHandler = NULL; |
|
270 delete iEng; iEng = NULL; |
|
271 |
|
272 iContentName.Close(); |
|
273 iTimedClose->Cancel(); |
|
274 iTimedClose->After( TTimeIntervalMicroSeconds32( KMenuSrvExitDelay ) ); |
|
275 } |
|
276 |
|
277 // CMenuSrvEng::TreeReloaded |
|
278 // --------------------------------------------------------- |
|
279 // |
|
280 void CMenuSrvEng::EngineTreeReloaded() |
|
281 { |
|
282 if (iAppScanner) |
|
283 { |
|
284 iAppScanner->ScheduleScan(); |
|
285 } |
|
286 } |
|
287 void CMenuSrvEng::GetAttributeListL( |
|
288 TInt aId, |
|
289 RArray<TPtrC>& aList ) |
|
290 { |
|
291 |
|
292 const CMenuEngObject& obj = iEng->ObjectL(aId); |
|
293 |
|
294 TPtrC name, value; |
|
295 TBool localized; |
|
296 for ( TInt ndx = 0; obj.GetAttribute( ndx, name, value, localized ); ndx++ ) |
|
297 { |
|
298 if( !( name.Compare( KMenuAttrIconFile ) == KErrNone |
|
299 || name.Compare( KMenuAttrIconId ) == KErrNone |
|
300 || name.Compare( KMenuAttrMaskId ) == KErrNone |
|
301 || name.Compare( KMenuAttrIconSkinMajorId ) == KErrNone |
|
302 || name.Compare( KMenuAttrIconSkinMinorId ) == KErrNone )) |
|
303 { |
|
304 aList.AppendL(name); |
|
305 } |
|
306 } |
|
307 |
|
308 AppendExtendedAttrributesL( obj.Type() , aList ); |
|
309 } |
|
310 |
|
311 // --------------------------------------------------------- |
|
312 // CExtendedMenuItem::GetAttributeL |
|
313 // --------------------------------------------------------- |
|
314 // |
|
315 |
|
316 void CMenuSrvEng::GetAttributeL( |
|
317 TInt aId, |
|
318 const TDesC& aAttrName, |
|
319 TBool& aAttrExists, |
|
320 TDes& aAttrVal ) |
|
321 { |
|
322 TBool dummy; |
|
323 TPtrC val(KNullDesC); |
|
324 |
|
325 aAttrExists = iEng->ObjectL(aId).FindAttribute( aAttrName, val, dummy); |
|
326 |
|
327 if( !aAttrExists ) |
|
328 { |
|
329 aAttrExists = iCacheHandler->iAttrCache.Find( aId, aAttrName, aAttrVal ); |
|
330 } |
|
331 |
|
332 if ( aAttrExists && val!=KNullDesC() ) |
|
333 { |
|
334 aAttrVal = val; |
|
335 } |
|
336 else if( !aAttrExists ) |
|
337 { |
|
338 GetExtendedAttributesL( aId, aAttrName, aAttrExists, aAttrVal ); |
|
339 } |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------- |
|
343 // CMenuSrvEng::InstalledSuiteExist |
|
344 // --------------------------------------------------------- |
|
345 // |
|
346 TBool CMenuSrvEng::InstalledSuiteExist(const TDesC& aSuiteName) |
|
347 { |
|
348 return iSuiteHandler->HaveSuite(aSuiteName); |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------- |
|
352 // CMenuSrvEng::GetSuiteAttributeL |
|
353 // --------------------------------------------------------- |
|
354 // |
|
355 void CMenuSrvEng::GetSuiteAttribute( const TDesC& aSuiteName, const TDesC& aAttrName, |
|
356 TBool& aAttrExists, TDes& aAttrVal ) |
|
357 { |
|
358 iSuiteHandler->GetAttribute(aSuiteName, aAttrName, |
|
359 aAttrExists, aAttrVal); |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------- |
|
363 // CMenuSrvEng::GetRunningAppsL() |
|
364 // --------------------------------------------------------- |
|
365 // |
|
366 void CMenuSrvEng::GetRunningAppsL( RArray<TUid>& aArray ) |
|
367 { |
|
368 iRunningAppsHandler->GetRunningAppsL( aArray ); |
|
369 } |
|
370 |
|
371 // --------------------------------------------------------- |
|
372 // CMenuSrvEng::GetRunningAppsL() |
|
373 // --------------------------------------------------------- |
|
374 // |
|
375 void CMenuSrvEng::GetExtendedAttributesL(TInt aId, |
|
376 const TDesC& aAttrName, TBool& aAttrExists, |
|
377 TDes& aAttrVal ) |
|
378 { |
|
379 TBool captionInfo(aAttrName.Compare( KMenuAttrShortName ) == KErrNone || |
|
380 aAttrName.Compare( KMenuAttrLongName ) == KErrNone || |
|
381 aAttrName.Compare( KMenuAttrTitleName ) == KErrNone ); |
|
382 |
|
383 TBool addToCache( ETrue ); |
|
384 if ( captionInfo ) |
|
385 { |
|
386 CaptionInfoL( aId, aAttrName, aAttrExists, aAttrVal ); |
|
387 addToCache = EFalse; |
|
388 } |
|
389 else if ( KErrNone == aAttrName.Compare( KMenuAttrDrmProtection ) ) |
|
390 { |
|
391 AppDrmProtectionL( aId, aAttrExists, aAttrVal ); |
|
392 } |
|
393 else if ( KErrNone == aAttrName.Compare( KRunningStatus ) ) |
|
394 { |
|
395 GetAppRunningL( aId, aAttrExists, aAttrVal ); |
|
396 } |
|
397 else if ( KErrNone == aAttrName.Compare( KChildrenCount ) ) |
|
398 { |
|
399 FolderChildrenCountL( aId, aAttrExists, aAttrVal ); |
|
400 } |
|
401 else if( KErrNone == aAttrName.Compare( KMenuAttrNative ) ) |
|
402 { |
|
403 ApplicationNativeAttributeL( aId, aAttrExists, aAttrVal ); |
|
404 } |
|
405 else // The attribute doesn't present for the item |
|
406 { |
|
407 aAttrExists = EFalse; |
|
408 aAttrVal = KNullDesC(); |
|
409 } |
|
410 if( aAttrExists && addToCache ) |
|
411 { |
|
412 AddToCacheL(aId, aAttrName, aAttrVal ); |
|
413 } |
|
414 } |
|
415 |
|
416 // --------------------------------------------------------- |
|
417 // CMenuSrvEng::ApplicationNativeAttributeL |
|
418 // --------------------------------------------------------- |
|
419 // |
|
420 void CMenuSrvEng::ApplicationNativeAttributeL( |
|
421 TInt aId, TBool & aAttrExists, TDes & aAttrVal ) |
|
422 { |
|
423 const CMenuEngObject & obj = iEng->ObjectL(aId); |
|
424 iCMenuSrvEngUtils->IsNative(obj, aAttrExists, aAttrVal); |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------- |
|
428 // CMenuSrvEng::AddToCacheL |
|
429 // --------------------------------------------------------- |
|
430 // |
|
431 void CMenuSrvEng::AddToCacheL( TInt aId, const TDesC& aAttrName, |
|
432 TDes& aAttrVal ) |
|
433 { |
|
434 CMenuSrvAttr* attr = CMenuSrvAttr::NewLC( aAttrName ); |
|
435 attr->SetValueL( aAttrVal ); // Takes ownership. |
|
436 attr->SetId( aId ); // New in cache -> not changed. |
|
437 iCacheHandler->iAttrCache.AppendL( attr ); |
|
438 CleanupStack::Pop( attr ); |
|
439 } |
|
440 |
|
441 // --------------------------------------------------------- |
|
442 // CMenuSrvEng::CaptionInfoL |
|
443 // Functions only for KMenuTypeApp type. |
|
444 // --------------------------------------------------------- |
|
445 // |
|
446 void CMenuSrvEng::CaptionInfoL( TInt aId, const TDesC& aAttrName, |
|
447 TBool& aExists, TDes& aAttrVal ) |
|
448 { |
|
449 const CMenuEngObject& obj = iEng->ObjectL(aId); |
|
450 if ( obj.Type().Compare( KMenuTypeFolder ) == KErrNone ) |
|
451 { |
|
452 TBool localized; |
|
453 TPtrC attrvalue; |
|
454 TBool attrExists = obj.FindAttribute( KMenuAttrAppGroupName, attrvalue, localized ); |
|
455 if ( attrExists ) |
|
456 { |
|
457 aExists = ETrue; |
|
458 aAttrVal = attrvalue; |
|
459 AddToCacheL(aId, KMenuAttrLongName, aAttrVal ); |
|
460 AddToCacheL(aId, KMenuAttrShortName, aAttrVal ); |
|
461 AddToCacheL(aId, KMenuAttrTitleName, aAttrVal ); |
|
462 } |
|
463 } |
|
464 else if ( obj.Type().Compare( KMenuTypeApp ) == KErrNone ) |
|
465 { |
|
466 aAttrVal = AppCaptionInfoL( obj, aAttrName, aExists ); |
|
467 AddToCacheL(aId, aAttrName, aAttrVal ); |
|
468 } |
|
469 else |
|
470 { |
|
471 aExists = EFalse; |
|
472 aAttrVal = KNullDesC(); |
|
473 } |
|
474 } |
|
475 |
|
476 // --------------------------------------------------------- |
|
477 // CMenuSrvEngUtils::AppDrmProtection |
|
478 // --------------------------------------------------------- |
|
479 // |
|
480 void CMenuSrvEng::AppDrmProtectionL( TInt aId, TBool& aExists, TDes& aAttrVal ) |
|
481 { |
|
482 CMenuSrvEngUtils::TDRMProtectionInfo drmProt; |
|
483 |
|
484 if ( KErrNone != iCMenuSrvEngUtils->GetDrmProtectionL( |
|
485 aId, |
|
486 drmProt ) ) |
|
487 { |
|
488 aExists = EFalse; |
|
489 aAttrVal = KNullDesC(); |
|
490 } |
|
491 else |
|
492 { |
|
493 aExists = ETrue; |
|
494 switch ( drmProt ) |
|
495 { |
|
496 case CMenuSrvEngUtils::EDRMUnknownProtection: |
|
497 { |
|
498 aAttrVal = KMenuDrmUnknown(); |
|
499 break; |
|
500 } |
|
501 case CMenuSrvEngUtils::EDRMNotProtected: |
|
502 { |
|
503 aAttrVal = KMenuDrmNotProtected(); |
|
504 break; |
|
505 } |
|
506 case CMenuSrvEngUtils::EDRMProtected: |
|
507 { |
|
508 aAttrVal = KMenuDrmProtected(); |
|
509 break; |
|
510 } |
|
511 case CMenuSrvEngUtils::EDRMRightsExpired: |
|
512 { |
|
513 aAttrVal = KMenuDrmRightsExpired(); |
|
514 break; |
|
515 } |
|
516 default: |
|
517 { |
|
518 User::Invariant(); |
|
519 aAttrVal = KNullDesC(); |
|
520 } |
|
521 } |
|
522 } |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------- |
|
526 // CMenuSrvEngUtils::AppCaptionInfoL |
|
527 // --------------------------------------------------------- |
|
528 // |
|
529 TPtrC CMenuSrvEng::AppCaptionInfoL( const CMenuEngObject& aEngObj, |
|
530 const TDesC& aAttrName, TBool& aExists ) |
|
531 { |
|
532 TApaAppInfo info; |
|
533 TPtrC val( KNullDesC ); |
|
534 if( KErrNone == iCMenuSrvEngUtils->GetAppInfo( aEngObj, info ) ) |
|
535 { |
|
536 aExists = ETrue; |
|
537 if( aAttrName.Compare( KMenuAttrTitleName ) == KErrNone || |
|
538 aAttrName.Compare( KMenuAttrShortName ) == KErrNone ) |
|
539 { |
|
540 val.Set( info.iShortCaption ); |
|
541 } |
|
542 else if( aAttrName.Compare( KMenuAttrLongName ) == KErrNone ) |
|
543 { |
|
544 val.Set( info.iCaption ); |
|
545 } |
|
546 else |
|
547 { |
|
548 User::Invariant(); |
|
549 } |
|
550 } |
|
551 else |
|
552 { |
|
553 aExists = EFalse; |
|
554 } |
|
555 return val; |
|
556 } |
|
557 |
|
558 // --------------------------------------------------------- |
|
559 // CMenuSrvEng::FolderChildrenCountL |
|
560 // --------------------------------------------------------- |
|
561 // |
|
562 void CMenuSrvEng::FolderChildrenCountL( TInt aId, TBool& aExists, TDes& aAttrVal ) |
|
563 { |
|
564 const CMenuEngObject& obj = iEng->ObjectL(aId); |
|
565 |
|
566 if( obj.Type().CompareF( KMenuTypeFolder ) == KErrNone ) |
|
567 { |
|
568 TUint32 childrenCount (0); |
|
569 RArray<TMenuItem> childrenArray; |
|
570 CleanupClosePushL( childrenArray ); |
|
571 |
|
572 CMenuFilter* appFilter = CMenuFilter::NewLC(); |
|
573 appFilter->SetFlags(0, TMenuItem::EMissing | TMenuItem::EHidden); |
|
574 TMenuSrvObjectFilter engFilter( *appFilter ); |
|
575 iEng->GetItemsL(childrenArray, aId, &engFilter, EFalse); |
|
576 childrenCount = childrenArray.Count(); |
|
577 |
|
578 CleanupStack::PopAndDestroy( appFilter ); |
|
579 CleanupStack::PopAndDestroy( &childrenArray ); |
|
580 |
|
581 aAttrVal.Num(childrenCount, EDecimal); |
|
582 aExists = ETrue; |
|
583 } |
|
584 else |
|
585 { |
|
586 aAttrVal.Append(KNullDesC()); |
|
587 aExists = EFalse; |
|
588 } |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------- |
|
592 // CMenuSrvEngUtils::GetAppRunningL |
|
593 // --------------------------------------------------------- |
|
594 // |
|
595 void CMenuSrvEng::GetAppRunningL( TInt aId, TBool& aExists, TDes& aAttrVal ) |
|
596 { |
|
597 aExists = iRunningAppsHandler->GetRunningStatusL(aId); |
|
598 if(aExists) |
|
599 { |
|
600 aAttrVal.Append(KRunning16()); |
|
601 } |
|
602 else |
|
603 { |
|
604 aAttrVal.Append(KNullDesC()); |
|
605 } |
|
606 } |
|
607 |
|
608 // --------------------------------------------------------- |
|
609 // CMenuSrvEng::GetChildrenCount |
|
610 // --------------------------------------------------------- |
|
611 // |
|
612 TUint CMenuSrvEng::GetChildrenCountL( TInt aId ) |
|
613 { |
|
614 TBool attrExists (EFalse); |
|
615 TUint count (0); |
|
616 RBuf attrVal; |
|
617 attrVal.CleanupClosePushL(); |
|
618 attrVal.CreateL(KMenuMaxAttrValueLen); |
|
619 |
|
620 // Get folder children count |
|
621 FolderChildrenCountL(aId, attrExists, attrVal); |
|
622 |
|
623 if (attrExists) |
|
624 { |
|
625 TLex lex(attrVal); |
|
626 User::LeaveIfError( lex.Val(count) ); |
|
627 } |
|
628 CleanupStack::PopAndDestroy( &attrVal ); |
|
629 |
|
630 return count; |
|
631 } |
|
632 |
|
633 // --------------------------------------------------------- |
|
634 // CMenuSrvEng::GetlistSizeL |
|
635 // --------------------------------------------------------- |
|
636 // |
|
637 TInt CMenuSrvEng::GetListSizeL( const TDesC8& aSerializedInput ) |
|
638 { |
|
639 delete iGetlistHandler; |
|
640 iGetlistHandler = NULL; |
|
641 |
|
642 iGetlistHandler = CMcsGetlistHandler::NewL( *this ); |
|
643 return iGetlistHandler->GetListSizeL( aSerializedInput ); |
|
644 } |
|
645 |
|
646 // --------------------------------------------------------- |
|
647 // CMenuSrvEng::CloseOutputBuffer |
|
648 // --------------------------------------------------------- |
|
649 // |
|
650 void CMenuSrvEng::CloseOutputBuffer() |
|
651 { |
|
652 iGetlistHandler->CloseOutputBuffer(); |
|
653 } |
|
654 |
|
655 // --------------------------------------------------------- |
|
656 // CMenuSrvEng::CleanAttributeCache |
|
657 // --------------------------------------------------------- |
|
658 // |
|
659 void CMenuSrvEng::CleanAttributeCache() |
|
660 { |
|
661 iCacheHandler->iAttrCache.ResetAndDestroy(); |
|
662 } |
|
663 |
|
664 // --------------------------------------------------------- |
|
665 // CMenuSrvEng::GetlistSizeL |
|
666 // --------------------------------------------------------- |
|
667 // |
|
668 TPtrC8 CMenuSrvEng::GetListDataL( ) |
|
669 { |
|
670 return iGetlistHandler->GetListDataL( ); |
|
671 } |
|
672 |
|
673 // --------------------------------------------------------- |
|
674 // CMenuSrvEng::AppendExtendedAttrributesL |
|
675 // --------------------------------------------------------- |
|
676 // |
|
677 void CMenuSrvEng::AppendExtendedAttrributesL( |
|
678 const TDesC& aType, |
|
679 RArray<TPtrC>& aList ) |
|
680 { |
|
681 |
|
682 if ( KErrNone == aType.Compare( KMenuTypeApp ) ) |
|
683 { |
|
684 if( KErrNotFound == aList.Find( KMenuAttrTitleName(), TIdentityRelation<TPtrC>( CmpAttrName )) ) |
|
685 { |
|
686 aList.AppendL( TPtrC( KMenuAttrTitleName ) ); |
|
687 } |
|
688 if( KErrNotFound == aList.Find( KMenuAttrShortName(), TIdentityRelation<TPtrC>( CmpAttrName )) ) |
|
689 { |
|
690 aList.AppendL( TPtrC( KMenuAttrShortName ) ); |
|
691 } |
|
692 if( KErrNotFound == aList.Find( KMenuAttrLongName(), TIdentityRelation<TPtrC>( CmpAttrName )) ) |
|
693 { |
|
694 aList.AppendL( TPtrC( KMenuAttrLongName ) ); |
|
695 } |
|
696 if( KErrNotFound == aList.Find( KMenuAttrDrmProtection(), TIdentityRelation<TPtrC>( CmpAttrName )) ) |
|
697 { |
|
698 aList.AppendL( TPtrC( KMenuAttrDrmProtection ) ); |
|
699 } |
|
700 } |
|
701 else if ( KErrNone == aType.Compare( KMenuTypeFolder ) ) |
|
702 { |
|
703 if( KErrNotFound == aList.Find( KMenuAttrTitleName(), TIdentityRelation<TPtrC>( CmpAttrName )) ) |
|
704 { |
|
705 aList.AppendL( TPtrC( KMenuAttrTitleName ) ); |
|
706 } |
|
707 if( KErrNotFound == aList.Find( KMenuAttrShortName(), TIdentityRelation<TPtrC>( CmpAttrName )) ) |
|
708 { |
|
709 aList.AppendL( TPtrC( KMenuAttrShortName ) ); |
|
710 } |
|
711 if( KErrNotFound == aList.Find( KMenuAttrLongName(), TIdentityRelation<TPtrC>( CmpAttrName )) ) |
|
712 { |
|
713 aList.AppendL( TPtrC( KMenuAttrLongName ) ); |
|
714 } |
|
715 if( KErrNotFound == aList.Find( KChildrenCount(), TIdentityRelation<TPtrC>( CmpAttrName )) ) |
|
716 { |
|
717 aList.AppendL( TPtrC( KChildrenCount ) ); |
|
718 } |
|
719 } |
|
720 } |
|
721 |
|
722 |
|
723 // End of File |