filemanager/schbkup/inc/fmsystemstatemonitor.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 25 May 2010 12:28:34 +0300
branchRCL_3
changeset 14 efe289f793e7
permissions -rw-r--r--
Revision: 201019 Kit: 2010121

/*
* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0""
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  system State monitor
*
*/

#ifndef __FM_SYSTEMSTATE_MONITOR__
#define __FM_SYSTEMSTATE_MONITOR__

#include <e32base.h>
#include <ssm/ssmstateawaresession.h>

/**
 * MFmSystemStateMonitorObserver
 * 
 * Monitor component observer.
 * 
 * @since S60 5.2
 */
class MFmSystemStateMonitorObserver
    {    
    public:
        /**
         * Called when the system State changed  
         */
        virtual void SystemStateChangedEvent() = 0;
    };

/**
 * CFmSystemStateMonitor
 * 
 * Component for monitoring system state
 * 
 * @since S60 5.2
 */  
class CFmSystemStateMonitor : public CActive
    {
    public:
        /**
         * Create new monitor
         * 
         * @param aObserver monitor observer
         * @since S60 5.2     
         */    
        static CFmSystemStateMonitor* NewL(
            MFmSystemStateMonitorObserver& aObserver );   
        
        /**
         * Destructor
         * 
         * @since S60 5.2     
         */    
        ~CFmSystemStateMonitor();
    
        /**
         * Start monitor
         * 
         * @param aStateToMonitor the state needs monitored
         * @since S60 5.2
         */        
        void StartMonitor( TUint aStateToMonitor );    
        
        /**
         * Indicate system state is normal or not
		 *       
         * @since S60 5.2
		 * @return ETrue if system state is normal, EFalse if not
         */ 
        TBool IsSystemStateNormal();

    private:
        /** 
         * C++ constructor
         *
         * @param aObserver monitor observer.   
         * @since S60 5.2      
         */        
        CFmSystemStateMonitor( MFmSystemStateMonitorObserver& aObserver );    

        /**
         * Symbian 2nd phase constructor
         * 
         * @since S60 5.2
         */        
        void ConstructL();

    private: // From CActive
        /**
         * From CActive
         */        
        void RunL();

        /**
         * From CActive         
         * @since S60 5.2
         */        
        void DoCancel(); 

        /**
         * From CActive         
         * @since S60 5.2
         */        
        TInt RunError( TInt aError );

    private:	
        // observer used to inform try schedule backup again when system state become normal
        MFmSystemStateMonitorObserver& iObserver;

        // State aware session.
        RSsmStateAwareSession iSAS;
        
        // State to monitor
        TUint iStateToMonitor;
    };

#endif // __FM_SYSTEMSTATE_MONITOR__