telephonyserverplugins/common_tsy/commontsy/inc/mmtsy/BatteryInfoObserver.h
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 /*
       
     2 * Copyright (c) 2007-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 
       
    19 #ifndef BATTERY_INFO_OBSERVER
       
    20 #define BATTERY_INFO_OBSERVER
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <hwrmpower.h>
       
    25 
       
    26 // CONSTANTS
       
    27 const TInt KHalfSecond = 500000;
       
    28 const TInt KTwoMins = 120000000;
       
    29 
       
    30 // CLASS DECLARATION
       
    31 
       
    32 /**
       
    33 * MBatteryInfoNotifier
       
    34 * Interface class for NotifyBatteryInfo()
       
    35 */
       
    36 class MBatteryInfoNotifier
       
    37     {
       
    38     public:
       
    39     
       
    40         /**
       
    41         * Notifier for battery info changes
       
    42         *
       
    43         * @param aError error code
       
    44         * @param aBatteryData data structure to battery data
       
    45         */
       
    46         virtual void NotifyBatteryInfo( TInt aError,
       
    47             CHWRMPower::TBatteryConsumptionData aBatteryData ) = 0;
       
    48     };
       
    49 
       
    50 // CLASS DECLARATION
       
    51 
       
    52 /**
       
    53 * CBatteryInfoObserver is used to provide battery information from HWRM to CTSY
       
    54 */
       
    55 NONSHARABLE_CLASS( CBatteryInfoObserver ) : public CActive
       
    56 	{
       
    57     public:
       
    58 
       
    59         /**
       
    60         * Two-phased constructor
       
    61         *
       
    62         * @param aPower reference to CHWRMPower instance
       
    63         * @param aBatteryInfoNotifier reference to interface class
       
    64         *  MBatteryInfoNotifier
       
    65         * @return Pointer to the created object
       
    66         */
       
    67     	static CBatteryInfoObserver* NewL( CHWRMPower& aPower,
       
    68     	    MBatteryInfoNotifier& aBatteryInfoNotifier );
       
    69     	
       
    70     	/**
       
    71     	* Two-phased constructor
       
    72     	*
       
    73     	* @param aPower reference to CHWRMPower instance
       
    74     	* @param aBatteryInfoNotifier reference to interface class
       
    75     	*  MBatteryInfoNotifier
       
    76     	* @return Pointer to the created object
       
    77     	*/
       
    78     	static CBatteryInfoObserver* NewLC( CHWRMPower& aPower,
       
    79     	    MBatteryInfoNotifier& aBatteryInfoNotifier );
       
    80     	
       
    81     	/**
       
    82         * Destructor
       
    83         */
       
    84     	~CBatteryInfoObserver();
       
    85     	
       
    86     	/**
       
    87     	* Handles GetBatteryInfo request completion event
       
    88     	*/
       
    89     	void RunL();
       
    90         
       
    91         /**
       
    92     	* Cancellation of an outstanding request
       
    93     	*/
       
    94     	void DoCancel();
       
    95     	
       
    96     	/**
       
    97     	* Get battery info
       
    98     	*/
       
    99     	void GetBatteryInfo();
       
   100     	
       
   101     	/**
       
   102     	* Run timer 
       
   103     	*
       
   104     	* @param aObject pointer to object which start timer
       
   105         * @return TInt KErrNone because callback function is intended to be
       
   106         * called again
       
   107     	*/
       
   108     	static TInt RunTimer(TAny* aObject);
       
   109     	
       
   110     private:
       
   111 
       
   112         /**
       
   113         * By default Symbian 2nd phase constructor is private
       
   114         */
       
   115     	void ConstructL();
       
   116     	
       
   117     	/**
       
   118         * Constructor
       
   119         *
       
   120         * @param aPower reference to CHWRMPower instance
       
   121         * @param aBatteryInfoNotifier reference to interface class 
       
   122         * MBatteryInfoNotifier
       
   123         */
       
   124     	CBatteryInfoObserver( CHWRMPower& aPower,
       
   125     	    MBatteryInfoNotifier& aBatteryInfoNotifier );
       
   126     	
       
   127     private:
       
   128 
       
   129     	/**
       
   130     	* Reference to CHWRMPower instance
       
   131     	*/
       
   132         CHWRMPower& iPower;
       
   133         
       
   134         /**
       
   135         * Data structure used to retrieve data from a call to GetBatteryInfo
       
   136         */
       
   137         CHWRMPower::TBatteryConsumptionData iBatteryData;
       
   138         
       
   139         /**
       
   140         * Reference to BatteryInfoNotifier object
       
   141         */
       
   142         MBatteryInfoNotifier& iBatteryInfoNotifier;
       
   143         
       
   144         /**
       
   145         * Periodic timer
       
   146         */
       
   147         CPeriodic* iPeriodic;
       
   148 	};
       
   149 	
       
   150 	
       
   151 #endif /*BATTERY_INFO_OBSERVER*/
       
   152 
       
   153 //  End of File