resourcemgmt/hwresourcesmgr/extendedlight/inc/HWRMExtendedLightStatusObserver.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006-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 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalTechnology 
       
    24 */
       
    25 
       
    26 #ifndef HWRMEXTENDEDLIGHTSTATUSOBSERVER_H
       
    27 #define HWRMEXTENDEDLIGHTSTATUSOBSERVER_H
       
    28 
       
    29 // INCLUDES
       
    30 #include <e32base.h>
       
    31 #include <hwrm/hwrmextendedlight.h>
       
    32 #include <e32property.h>
       
    33 #include "HWRMCmn.h"
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 // None
       
    37 
       
    38 /**
       
    39 * Active object wrapper for Publish and Subscribe one-shot notification handling.
       
    40 * Listens for changes in light status and notifies the client.
       
    41 *
       
    42 */
       
    43 NONSHARABLE_CLASS(CHWRMExtendedLightStatusObserver) : public CActive
       
    44     {
       
    45     public:
       
    46 
       
    47         /**
       
    48         * This is a two-phase constructor method that is used to
       
    49         * create a new instance of CHWRMExtendedLightStatusObserver.
       
    50         * A newly created instance immediately starts listening to light status changes.
       
    51         *
       
    52         * @param aCallback Pointer to a callback instance. Can be NULL.
       
    53         * @param aSupportedTargets Mask of supported targets.
       
    54         * @return A pointer to a new instance of the CHWRMExtendedLightStatusObserver class.
       
    55         */
       
    56         static CHWRMExtendedLightStatusObserver* NewL(MHWRMExtendedLightObserver* aCallback,
       
    57                                                       TInt aSupportedTargets);
       
    58 
       
    59         /**
       
    60         * Destructor.
       
    61         */
       
    62         virtual ~CHWRMExtendedLightStatusObserver();
       
    63         
       
    64         /**
       
    65         * This method retrieves the current light status. 
       
    66         *
       
    67         * @return TLightStatus indicating the current light status
       
    68         */
       
    69         CHWRMExtendedLight::TLightStatus CurrentStatus(TInt aTarget) const;
       
    70 
       
    71     protected:
       
    72 
       
    73         // From CActive
       
    74         void RunL();
       
    75         void DoCancel();
       
    76 
       
    77     private:
       
    78 
       
    79         /**
       
    80         * Constructor
       
    81         *
       
    82         * @param aCallback Pointer to a callback instance.
       
    83         * @param aSupportedTargets Mask of supported targets.
       
    84         */
       
    85         CHWRMExtendedLightStatusObserver(MHWRMExtendedLightObserver* aCallback,
       
    86                                          TInt aSupportedTargets);
       
    87                                                    
       
    88         /**
       
    89         * By default Symbian 2nd phase constructor is private.
       
    90         */
       
    91         void ConstructL();
       
    92 
       
    93         /*
       
    94         * Order notification
       
    95         */
       
    96         void OrderNotification();
       
    97 
       
    98         /**
       
    99         * Notifies the callback about value changes.
       
   100         *
       
   101         * @param aStatusList New status values obtained from P&S
       
   102         */
       
   103         void NotifyCallback( RLightStatusArray& aStatusList  );
       
   104 
       
   105         /**
       
   106         * Finds item from iLastStatusValue by target.
       
   107         */
       
   108         static TInt FindByTarget( const TInt* aTarget, 
       
   109                                   const THWRMStatusInfo& aItem );
       
   110 
       
   111         /**
       
   112         * Initializes RLightStatusArray.
       
   113         */
       
   114         TInt InitializeStatusArray( RLightStatusArray& aArray ) const;
       
   115         
       
   116     private:
       
   117         
       
   118         MHWRMExtendedLightObserver* iCallback; // Not owned by this class. Can be NULL.
       
   119         RProperty iProperty;           // P&S property
       
   120         TInt iSupportedTargets;        // Mask of supported targets
       
   121         RLightStatusArray iLastStatusValue; // Keeps track of last received status value
       
   122         RLightStatusArray iStatusUnknownList; // All targets status unknown, RunError() uses.
       
   123     };
       
   124 
       
   125 #endif      // HWRMLIGHTSTATUSOBSERVER_H
       
   126 
       
   127 // End of File