menucontentsrv/srvsrc/mcschildrenhandler.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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 <e32base.h>
       
    19 
       
    20 #include "mcschildrenhandler.h"
       
    21 
       
    22 #include "mcsdef.h"
       
    23 #include "mcsmenunotifier.h"
       
    24 #include "menueng.h"
       
    25 #include "mcscachehandler.h"
       
    26 #include "menusrveng.h"
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 // -----------------------------------------------------------------------------
       
    30 // CMcsChildrenHandler::NewL
       
    31 // Two-phased constructor.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 
       
    35 CMcsChildrenHandler* CMcsChildrenHandler::NewL( 
       
    36     CMenuSrvEng& aSrvEng,
       
    37     CMcsCacheHandler& aCacheHandler )
       
    38 	{
       
    39 	CMcsChildrenHandler* self = new( ELeave ) 
       
    40 				CMcsChildrenHandler( aSrvEng, aCacheHandler );
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45 	}
       
    46 
       
    47 // -----------------------------------------------------------------------------    
       
    48 // Destructor
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CMcsChildrenHandler::~CMcsChildrenHandler()
       
    52 	{
       
    53 	delete iScanner;
       
    54 	}
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CMcsChildrenHandler::CMcsChildrenHandler
       
    58 // C++ default constructor can NOT contain any code, that
       
    59 // might leave.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CMcsChildrenHandler::CMcsChildrenHandler( 
       
    63     CMenuSrvEng& aSrvEng,
       
    64     CMcsCacheHandler& aCacheHandler  ) :
       
    65     iSrvEng( aSrvEng ),
       
    66     iCacheHandler( aCacheHandler )
       
    67 	{
       
    68 
       
    69 	}
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CMcsDrmHandler::ConstructL
       
    73 // Symbian 2nd phase constructor can leave.
       
    74 // -----------------------------------------------------------------------------
       
    75 void CMcsChildrenHandler::ConstructL()
       
    76 	{
       
    77 	iScanner = CMcsChildrenScanner::NewL(*this, iSrvEng);
       
    78 	}
       
    79 
       
    80 // -----------------------------------------------------------------------------    
       
    81 // 
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CMcsChildrenHandler::HandleChildrenEvent(TInt aId, TUint aOldCount, TUint aNewCount)
       
    85 	{
       
    86 	if (aOldCount != aNewCount)
       
    87 		{
       
    88 		iCacheHandler.HandleRemoveAttribute(aId, KChildrenCount);
       
    89 
       
    90 		// Send Notification
       
    91 		if (aOldCount == 0 || aNewCount == 0)
       
    92 			{
       
    93 			TRAP_IGNORE( iSrvEng.Engine().ModifiableObjectL( 
       
    94 					aId, RMenuNotifier::EItemAttributeChanged ));
       
    95 			}
       
    96 		}
       
    97 	}
       
    98 
       
    99 
       
   100 // -----------------------------------------------------------------------------    
       
   101 // 
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 void CMcsChildrenHandler::EngineEvents( TInt aFolder, TInt aEvents )
       
   105 	{
       
   106     if ( aEvents & ( RMenuNotifier::EItemsAddedRemoved 
       
   107                    | RMenuNotifier::EItemAttributeChanged ) )
       
   108         {
       
   109         iScanner->Scan(aFolder);
       
   110         }    
       
   111 	}
       
   112 
       
   113 //  End of File  
       
   114