idlefw/inc/framework/aistatemanager.h
branchRCL_3
changeset 9 d0529222e3f0
parent 0 79c6a41cd166
child 51 15e4dd19031c
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     1 /*
     1 /*
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  State manager base class
    14 * Description:  State Manager
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #ifndef M_AISTATEMANAGER_H
    19 #ifndef _AISTATEMANAGER_H
    20 #define M_AISTATEMANAGER_H
    20 #define _AISTATEMANAGER_H
    21 
    21 
    22 #include "aipluginstatemachine.h"
    22 // System includes
       
    23 #include <e32base.h>
       
    24 #include <babitflags.h>
       
    25 
       
    26 // User includes
       
    27 #include <aifwdefs.h>
       
    28 #include "aistateobserver.h"
       
    29 
       
    30 // Forward declarations
       
    31 class CAiPluginFactory;
       
    32 class CHsContentPublisher;
       
    33 class THsPublisherInfo;
    23 
    34 
    24 /**
    35 /**
    25  *  description
    36  * State Manager
    26  * 
    37  * 
    27  *  @lib aifw
    38  * @ingroup group_aifw
    28  *  @since S60 3.2
    39  * @lib aifw.lib
       
    40  * @since S60 5.0
    29  */
    41  */
    30 class MAiStateManager
    42 NONSHARABLE_CLASS( CAiStateManager ) : public CBase,
       
    43     public MAiStateObserver
    31     {
    44     {
    32     
    45 private:
    33     public:
    46     // Data types
    34     
    47     enum TState
    35         /**
    48         {
    36          * System status observers use this method to report status variable 
    49         ESuspended = 0,        
    37          * changes to state manager.
    50         EAlive,                
    38          *
    51         };
    39          * @param TAiStateChanges aState the state that has changed.
    52     
    40          */
    53     enum TFlags
    41         virtual void ReportStateChange( TAiStateChanges aState ) = 0;
    54         {
    42     
    55         EIsForeground = 0,
    43     protected:
    56         EIsLightsOn,        
    44     
    57         EIsOnline,
    45         ~MAiStateManager(){}
    58         EShutdown
    46     
    59         };
       
    60     
       
    61 public:    
       
    62     // Constructors and destructor
       
    63     
       
    64     /**
       
    65      * Two-phased constructor.
       
    66      */
       
    67     static CAiStateManager* NewL( CAiPluginFactory& aFactory );
       
    68 
       
    69     /**
       
    70      * Two-phased constructor. Leaving on stack
       
    71      */
       
    72     static CAiStateManager* NewLC( CAiPluginFactory& aFactory );
       
    73 
       
    74     /**
       
    75      * Destructor
       
    76      */
       
    77     ~CAiStateManager();
       
    78 
       
    79 private:
       
    80     // private constructors
       
    81 
       
    82     /**
       
    83      * Leaving constructor
       
    84      */
       
    85     void ConstructL();
       
    86     
       
    87     /**
       
    88      * C++ default constructor
       
    89      */
       
    90     CAiStateManager( CAiPluginFactory& aFactory );
       
    91 
       
    92 private:
       
    93     // from MAiStateObserver
       
    94     
       
    95     /**
       
    96      * @see MAiStateObserver
       
    97      */
       
    98     void NotifyStateChange( 
       
    99         TAiFwState aReason );
       
   100 
       
   101     /**
       
   102      * @see MAiStateObserver
       
   103      */    
       
   104     TInt NotifyLoadPlugin( const THsPublisherInfo& aInfo, 
       
   105         TAiFwLoadReason aReason );
       
   106     
       
   107     /**
       
   108      * @see MAiStateObserver
       
   109      */    
       
   110     void NotifyDestroyPlugin( const THsPublisherInfo& aInfo,
       
   111         TAiFwDestroyReason aReason );
       
   112 
       
   113     /**
       
   114      * @see MAiStateObserver
       
   115      */        
       
   116     void NotifyUpdatePlugins();
       
   117     
       
   118     /**
       
   119      * @see MAiStateObserver
       
   120      */            
       
   121     TBool OnlineStateInUse() const;
       
   122             
       
   123 private:
       
   124     // new functions
       
   125         
       
   126     /**
       
   127      * Evaluates next state 
       
   128      * 
       
   129      * @since S60 5.2
       
   130      * @return Next state
       
   131      */
       
   132     TState EvaluateNextState() const;
       
   133     
       
   134     /**
       
   135      * Process state change for all plugins
       
   136      * 
       
   137      * @since S60 5.2
       
   138      * @param aNextState Next state where plugins are driven
       
   139      */
       
   140     void ProcessStateChange( TState aNextState );
       
   141     
       
   142     /**
       
   143      * Process general theme state change for all plugins
       
   144      * 
       
   145      * @since S60 5.2     
       
   146      */    
       
   147     void ProcessGeneralThemeChange();
       
   148 
       
   149     /**
       
   150      * Process backup/restore state change for all plugins
       
   151      * 
       
   152      * @since S60 5.2     
       
   153      * @param aStarted ETrue when backup started
       
   154      */        
       
   155     void ProcessBackupRestore( TBool aStarted );
       
   156 
       
   157     /**
       
   158      * Process online / offline state change for all plugins
       
   159      * 
       
   160      * @since S60 5.2
       
   161      */
       
   162     void ProcessOnlineStateChange();
       
   163     
       
   164     /** 
       
   165      * Runs plugin startup sequence
       
   166      * 
       
   167      * @since S60 5.2     
       
   168      * @param aPlugin Plugin to start
       
   169      * @param aReason Start reason
       
   170      */
       
   171     void StartPlugin( CHsContentPublisher& aPlugin, 
       
   172         CHsContentPublisher::TStartReason aReason );
       
   173 
       
   174     /** 
       
   175      * Runs plugin shutdown sequence
       
   176      * 
       
   177      * @since S60 5.2     
       
   178      * @param aPlugin Plugin to stop
       
   179      * @param aReason Stop reason
       
   180      */    
       
   181     void StopPlugin( CHsContentPublisher& aPlugin,
       
   182         CHsContentPublisher::TStopReason aReason );
       
   183         
       
   184     /**
       
   185      * Destroys all plugins from plugin factory
       
   186      * 
       
   187      * @since S60 5.2
       
   188      */
       
   189     void DestroyPlugins();
       
   190                            
       
   191 private:
       
   192     // data
       
   193     
       
   194     /** Plugin Factory, Not owned */
       
   195     CAiPluginFactory& iFactory;
       
   196     /** Current state */
       
   197     TState iCurrentState;    
       
   198     /** Flags */
       
   199     TBitFlags32 iFlags;
       
   200     /** Halted flag */
       
   201     TBool iHalt;
       
   202     
       
   203 private:
       
   204     // friend classes
       
   205     
       
   206 #ifdef _AIFW_UNIT_TEST
       
   207     friend class UT_AiStateManager;
       
   208 #endif        
    47     };
   209     };
    48  
   210 
    49 #endif // M_AISTATEMANAGER_H
   211 #endif // _AISTATEMANAGER_H
    50 
   212 
    51 // End of File.
   213 // End of file
       
   214