idlefw/inc/framework/aipluginstatemanager.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Plugin state manager
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_AIPLUGINSTATEMANAGER_H
       
    20 #define C_AIPLUGINSTATEMANAGER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "aistatemanager.h"
       
    24 #include "aipluginstatemachine.h"
       
    25 #include "aipluginlifecycleobserver.h"
       
    26 
       
    27 #include "aistatealive.h"
       
    28 #include "aistatesuspended.h"
       
    29 #include "aistateidle.h"
       
    30 #include "aifwdefs.h"
       
    31 
       
    32 class MAiPSPropertyObserver;
       
    33 class MAiDeviceStatusObserver;
       
    34 class CAiPluginStateManager;
       
    35 class CAiContentPluginManager;
       
    36 class CAiPluginStateMachine;
       
    37 class CAiUiFrameworkObserverImpl;
       
    38 class MAiUiFrameworkObserver;
       
    39 
       
    40 /**
       
    41  *  Plugin state manager implementation.
       
    42  *
       
    43  *  @lib aifw
       
    44  *  @since S60 3.2
       
    45  */
       
    46 NONSHARABLE_CLASS( CAiPluginStateManager ) : public CBase,
       
    47                                              public MAiStateManager,
       
    48                                              public MAiPluginStateResources,
       
    49                                              public MAiPluginLifecycleObserver
       
    50     {
       
    51     
       
    52 public: // Constructor and destructor
       
    53 
       
    54     static CAiPluginStateManager* NewL();
       
    55 
       
    56     virtual ~CAiPluginStateManager();
       
    57 
       
    58 public: // From MAiStateManager
       
    59 
       
    60     void ReportStateChange( TAiStateChanges aState );
       
    61 
       
    62 public: // From MAiPluginStateMachine
       
    63 
       
    64     TBool StateVariable( TAiStateVariable aStateVariable );
       
    65 
       
    66     TAiTransitionReason TranslateReason( TAiStateChanges aStateChange );
       
    67 
       
    68     void RestartSuspendTimer();
       
    69 
       
    70 public: // From MAiPluginLifecycleObserver
       
    71 
       
    72     void PluginCreatedL( CAiContentPublisher& aPlugin );
       
    73 
       
    74     void PluginDestroyed( CAiContentPublisher& aPlugin );
       
    75     
       
    76     void AllPluginsCreated();
       
    77 
       
    78     void AllPluginsDestroyed();
       
    79               
       
    80 public: // new methods
       
    81 
       
    82     /**
       
    83      * Create system status observers (lights/backup/restore etc.).
       
    84      */
       
    85     void CreateSystemStateObserversL();
       
    86 
       
    87     /**
       
    88      * Destroy system status observers.
       
    89      */
       
    90     void DestroySystemStateObservers();
       
    91 
       
    92     /**
       
    93      * Provide accessor for fw observer.
       
    94      * @return MAiUiFrameworkObserver pointer to fw observer.
       
    95      */
       
    96     MAiUiFrameworkObserver* UiFwObserver() const;
       
    97     
       
    98     /**
       
    99      * Process online state change for a plugin
       
   100      * @param aPlugin plugin     
       
   101      */
       
   102     void ProcessOnlineState( CAiContentPublisher& aPlugin ); 
       
   103 
       
   104     /**
       
   105      * Process offline state change for a plugin
       
   106      * @param aPlugin plugin     
       
   107      */    
       
   108     void ProcessOfflineState( CAiContentPublisher& aPlugin );
       
   109     
       
   110 private: // Constructors
       
   111 
       
   112     CAiPluginStateManager();
       
   113 
       
   114     void ConstructL();
       
   115 
       
   116 private: // New functions
       
   117     
       
   118     /**
       
   119      * Handles Statemachine event event and error array update.
       
   120      * @param aState new state.
       
   121      * @param aMachine reference to single state machine.
       
   122      */
       
   123     void ProcessStateChange( TAiStateChanges aState,
       
   124                              CAiPluginStateMachine& aMachine );
       
   125 
       
   126     /**
       
   127      * Handles Statemachine event event and error array update
       
   128      * for all state machines.
       
   129      * @param aState new state.
       
   130      */
       
   131     void ProcessStateChangeForAll( TAiStateChanges aState );
       
   132 
       
   133     /**
       
   134      * Helper to check idle focus status.
       
   135      * @return ETrue if idle is focused / foreground app.
       
   136      */
       
   137     TBool IdleFocused() const;
       
   138 
       
   139     /**
       
   140      * Helper to check backup (or restore) status.
       
   141      * @return ETrue if backup (or restore) is ongoing.
       
   142      */
       
   143     TBool BackupOngoing() const;
       
   144 
       
   145     /**
       
   146      * Helper to check phone lights status.
       
   147      * @return ETrue if lights are on.
       
   148      */
       
   149     TBool LightsOn() const;
       
   150 
       
   151     /**
       
   152      * Helper to check phone call status.
       
   153      * @return ETrue if call is ongoing.
       
   154      */
       
   155     TBool CallOngoing() const;
       
   156 
       
   157     /**
       
   158      * Standard callback for CPeriodic ie. T1 timer.
       
   159      */
       
   160     static TInt T1TimerCallback( TAny* aPtr );
       
   161         
       
   162 private:     // Data
       
   163 
       
   164     /**
       
   165      * Backup operation state observer.
       
   166      * Own.
       
   167      */
       
   168     MAiDeviceStatusObserver* iBackupOperationObserver;
       
   169 
       
   170     /**
       
   171      * Call state observer.
       
   172      * Own.
       
   173      */
       
   174     MAiDeviceStatusObserver* iCallStateObserver;
       
   175 
       
   176     /**
       
   177      * Light state observer.
       
   178      * Own.
       
   179      */
       
   180     MAiDeviceStatusObserver* iLightStateObserver;
       
   181 
       
   182     /**
       
   183      * Enviroment change observer.
       
   184      * Own.
       
   185      */
       
   186     MAiDeviceStatusObserver* iEnvironmentObserver;
       
   187 
       
   188     /**
       
   189      * Focus change observer. Using telephony idle visiblity PS.
       
   190      * Own.
       
   191      */
       
   192     MAiDeviceStatusObserver* iFocusObserver;
       
   193 
       
   194     /**
       
   195      * Keylock observer.
       
   196      * Own.
       
   197      */
       
   198     MAiDeviceStatusObserver* iKeylockObserver;
       
   199 
       
   200     /**
       
   201      * Enviroment change observer. Full class type is used because
       
   202      * we need to provide accessor for implemented type MAiUiFrameworkObserver.
       
   203      * Own.
       
   204      */
       
   205     CAiUiFrameworkObserverImpl* iFrameworkObserver;
       
   206 
       
   207     /**
       
   208      * Timer for suspend, screensaver timout + light fadeout.
       
   209      * Own.
       
   210      */
       
   211     CPeriodic* iT1Timer;
       
   212 
       
   213     /**
       
   214      * Timer for suspend, screensaver timout + light fadeout.
       
   215      */
       
   216     TInt iT1Delay;
       
   217 
       
   218     /**
       
   219      * New state to be timed.
       
   220      */
       
   221     TAiState iTimedState;
       
   222 
       
   223     /**
       
   224      * Reason for timers activity.
       
   225      */
       
   226     TAiTransitionReason iTimedReason;
       
   227 
       
   228     /**
       
   229      * Indicates whether the device has been properly started.
       
   230      */
       
   231     TBool iIsDeviceStarted;
       
   232 
       
   233     /**
       
   234      * State machines for plugins.
       
   235      * Own.
       
   236      */
       
   237     RPointerArray<CAiPluginStateMachine> iStateMachines;
       
   238     };
       
   239 
       
   240 #endif // C_AIPLUGINSTATEMANAGER_H
       
   241 
       
   242 // End of File.