psmservices/psmserver/inc/engine/psmmanager.h
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2007 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:  PSM Manager class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PSMMANAGER_H
       
    20 #define PSMMANAGER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 // FORWARD DECLARATIONS
       
    25 class CPsmPluginLoader;
       
    26 class CPsmSettingsHandler;
       
    27 class MPsmModeChangeObserver;
       
    28 class MPsmSettingsProvider; // Interface for Settings handler
       
    29 
       
    30 /**
       
    31  *  PSM Manager class
       
    32  *
       
    33  *  Main class in PSM server. Controls the power save mode change chain
       
    34  *
       
    35  *  @since S60 5.0
       
    36  */
       
    37 class CPsmManager : public CActive
       
    38     {
       
    39     public:  // Constructors and destructor
       
    40 
       
    41         /**
       
    42          * Creates a new PSM manager.
       
    43          *
       
    44          * @return A pointer to the created object.
       
    45          */
       
    46         static CPsmManager* NewL();
       
    47 
       
    48         /**
       
    49          * Creates a new PSM manager. Newly created instance is left in the cleanup stack.
       
    50          *
       
    51          * @return A pointer to the created object.
       
    52          */
       
    53         static CPsmManager* NewLC();
       
    54 
       
    55         /**
       
    56          * Destructor.
       
    57          */
       
    58         virtual ~CPsmManager();
       
    59 
       
    60         /**
       
    61          * Starts the mode change actions
       
    62          *
       
    63          * @param aPsmMode Mode to switch to.
       
    64          */
       
    65         void NotifyPowerSaveModeChangeL( TInt aPsmMode );
       
    66 
       
    67         /**
       
    68          * Cancels the mode change actions and restores previous mode.
       
    69          */
       
    70         void CancelPowerSaveModeChangeL();
       
    71 
       
    72         /**
       
    73          * Register new PSM observer. Adds observer to the list of registered observers
       
    74          */
       
    75         void RegisterObserver( MPsmModeChangeObserver* aObserver );
       
    76 
       
    77         /**
       
    78          * Unreqister observer. Removes observer from the list of registered observers
       
    79          */
       
    80         void UnregisterObserver( MPsmModeChangeObserver* aObserver );
       
    81 
       
    82         /**
       
    83          * Returns reference to settings handler
       
    84          */
       
    85         MPsmSettingsProvider& SettingsProvider();
       
    86 
       
    87         /**
       
    88          * Makes NotifyPowerSaveModeChangeL to asynchronous
       
    89          */
       
    90         void IssueRequest();
       
    91 
       
    92     protected: // From CActive
       
    93 
       
    94         /**
       
    95          * From CActive.
       
    96          */
       
    97         void RunL();
       
    98 
       
    99         /**
       
   100          * From CActive.
       
   101          */
       
   102         void DoCancel();
       
   103 
       
   104         /**
       
   105          * From CActive.
       
   106          */
       
   107         TInt RunError( TInt aError );
       
   108 
       
   109     private:
       
   110 
       
   111         /**
       
   112         * C++ constructor.
       
   113         */
       
   114         CPsmManager();
       
   115 
       
   116         /**
       
   117         * By default Symbian 2nd phase constructor is private.
       
   118         */
       
   119         void ConstructL();
       
   120 
       
   121         /**
       
   122          * Notifies PSM mode change observers
       
   123          */
       
   124         void NotifyObservers( const TInt aError ) const;
       
   125 
       
   126     private:    // Data
       
   127 
       
   128         /**
       
   129          * Plugin loader
       
   130          */
       
   131         CPsmPluginLoader* iPluginLoader;
       
   132 
       
   133         /**
       
   134          * Settings handler
       
   135          */
       
   136         CPsmSettingsHandler* iSettingsHandler;
       
   137 
       
   138         /**
       
   139          * Array of registered PSM mode observers
       
   140          */
       
   141         RArray<MPsmModeChangeObserver*> iModeObservers;
       
   142 
       
   143         /**
       
   144          * Indicates is mode change active
       
   145          */
       
   146         TBool iModeChangeCancel;
       
   147 
       
   148         /**
       
   149          * indicates that power save mode change is ongoing
       
   150          */
       
   151         TBool iPowerSaveModeChangeActive;
       
   152     };
       
   153 
       
   154 #endif // PSMMANAGER_H