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