menucontentsrv/srvsrc/mcsrunningappshiddenattrscanner.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2008 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 
       
    19 #include <e32cmn.h> 
       
    20 
       
    21 #include "mcsrunningappshiddenattrscanner.h"
       
    22 #include "mcsrunningappshandler.h"
       
    23 #include "menueng.h"
       
    24 #include "mcsmenuitem.h"
       
    25 
       
    26 const TInt KMaxUidLength = 10; 
       
    27 // ---------------------------------------------------------
       
    28 // CMcsRunningAppsHiddenAttrScanner::NewL
       
    29 // ---------------------------------------------------------
       
    30 //
       
    31 CMcsRunningAppsHiddenAttrScanner* CMcsRunningAppsHiddenAttrScanner::NewL(
       
    32     CMenuEng& aEng, MMcsRunningAppsHandler* aRunningAppsHandler )
       
    33 	{
       
    34 	CMcsRunningAppsHiddenAttrScanner* self = 
       
    35 		new ( ELeave ) CMcsRunningAppsHiddenAttrScanner( aEng, 
       
    36 		aRunningAppsHandler );
       
    37 	CleanupStack::PushL( self );
       
    38 	self->ConstructL();
       
    39 	CleanupStack::Pop( self );
       
    40 	return self;
       
    41 	}
       
    42 
       
    43 // ---------------------------------------------------------
       
    44 // CMcsRunningAppsHiddenAttrScanner::~CMcsRunningAppsHiddenAttrScanner
       
    45 // ---------------------------------------------------------
       
    46 //
       
    47 CMcsRunningAppsHiddenAttrScanner::~CMcsRunningAppsHiddenAttrScanner()
       
    48     {
       
    49     iEng.DequeueOperation( *this );
       
    50     iHiddenApps.Close();
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CMcsRunningAppsHiddenAttrScanner::CMcsRunningAppsHiddenAttrScanner
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CMcsRunningAppsHiddenAttrScanner::CMcsRunningAppsHiddenAttrScanner(
       
    58     CMenuEng& aEng, MMcsRunningAppsHandler* aRunningAppsHandler):
       
    59     iEng(aEng),
       
    60     iRunningAppsHandler(aRunningAppsHandler)
       
    61     {
       
    62     iOperationInProgress = EFalse;
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------
       
    66 // CMcsRunningAppsHiddenAttrScanner::ScanL
       
    67 // ---------------------------------------------------------
       
    68 //
       
    69 void CMcsRunningAppsHiddenAttrScanner::ScanL()
       
    70     {
       
    71     if( !iOperationInProgress )
       
    72     	{
       
    73     	iEng.QueueOperationL( *this );
       
    74     	iOperationInProgress = ETrue;
       
    75     	}
       
    76     }    
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CMcsRunningAppsHiddenAttrScanner::IsFswHidden
       
    80 // ---------------------------------------------------------
       
    81 //
       
    82 TBool CMcsRunningAppsHiddenAttrScanner::IsHidden( TUid aUid )   
       
    83 	{
       
    84 	TBool result(EFalse);
       
    85 	if( KErrNotFound != iHiddenApps.Find( aUid ) )
       
    86 		{
       
    87 		result = ETrue;
       
    88 		}
       
    89 	return result;
       
    90     } 
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CMcsRunningAppsHiddenAttrScanner::ConstructL
       
    94 // ---------------------------------------------------------
       
    95 //
       
    96 void CMcsRunningAppsHiddenAttrScanner::ConstructL()
       
    97 	{
       
    98 	UpdateHiddenApplicationsL();
       
    99 	}
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CMcsRunningAppsHiddenAttrScanner::RunMenuEngOperationL
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 void CMcsRunningAppsHiddenAttrScanner::RunMenuEngOperationL()
       
   106     {
       
   107     UpdateHiddenApplicationsL();
       
   108     iOperationInProgress = EFalse;
       
   109     } 
       
   110        
       
   111 // ---------------------------------------------------------
       
   112 // CMcsRunningAppsHiddenAttrScanner::CompletedMenuEngOperation
       
   113 // ---------------------------------------------------------
       
   114 //
       
   115 void CMcsRunningAppsHiddenAttrScanner::CompletedMenuEngOperation( TInt /*aErr*/ )
       
   116     {
       
   117     // If there was error, ignore it (what else could we do?).
       
   118     // When next AppArc update occurs, we will run again.
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------
       
   122 // CMcsRunningAppsHiddenAttrScanner::UpdateHiddenApplicationsL
       
   123 // ---------------------------------------------------------
       
   124 //
       
   125 void CMcsRunningAppsHiddenAttrScanner::UpdateHiddenApplicationsL()
       
   126     {
       
   127     iHiddenApps.Reset();
       
   128 
       
   129     TInt root;
       
   130     iEng.RootFolderL( root );
       
   131     TMenuSrvHiddenAppFilter filter;
       
   132     
       
   133     RArray<TMenuItem> items;
       
   134     CleanupClosePushL( items );
       
   135     iEng.GetItemsL( items, root, &filter, ETrue );
       
   136        
       
   137     for (TInt i=0; i < items.Count(); i++)
       
   138         {        
       
   139         const CMenuEngObject& object = iEng.ObjectL( items[i].Id() );
       
   140         TBool tmp;
       
   141         TPtrC uidDesC(KNullDesC);
       
   142         object.FindAttribute( KMenuAttrUid(), uidDesC, tmp);        
       
   143 
       
   144         TBuf< KMaxUidLength > appUidDesC;
       
   145         TRadix radix;
       
   146         if ( KErrNotFound == uidDesC.Find( KHex ) )
       
   147         	{
       
   148         	radix = EDecimal;
       
   149         	appUidDesC = uidDesC;
       
   150         	}
       
   151         else
       
   152         	{
       
   153         	radix= EHex;
       
   154         	appUidDesC = uidDesC.Right( uidDesC.Length() - KHex().Length());
       
   155         	}
       
   156         
       
   157         TLex uidLex( appUidDesC );
       
   158         TUint uidInt ( NULL );
       
   159         uidLex.Val( uidInt, radix );
       
   160         TUid appUid (TUid::Uid( uidInt ));
       
   161         iHiddenApps.AppendL( appUid );
       
   162         }        
       
   163 	iRunningAppsHandler->HandleListUpdateL( iHiddenApps, 
       
   164 			MMcsRunningAppsHandler::EHiddenApps );
       
   165     CleanupStack::PopAndDestroy(&items);
       
   166     }
       
   167 
       
   168 
       
   169 //  End of File