sysstatemgmt/ssmcustcmds/ssmsystemcmds/inc/ssmpskeyobserver.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 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 * Declaration of CSsmPsKeyObserver class.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef SSMPSKEYOBSERVER_H
       
    20 #define SSMPSKEYOBSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32property.h>
       
    24 
       
    25 /**
       
    26 *  An active object which waits until a P&S key value changes to a predefined
       
    27 *  value and then signals a request status.
       
    28 */
       
    29 NONSHARABLE_CLASS( CSsmPsKeyObserver ) : public CActive
       
    30     {
       
    31 
       
    32 public:
       
    33 
       
    34     /**
       
    35     * First phase constructor.
       
    36     *
       
    37     * @param aCategory The UID that identifies the property category.
       
    38     * @param aKey The property sub-key, i.e. the key that identifies the
       
    39     *             specific property within the category.
       
    40     */
       
    41     CSsmPsKeyObserver( TUid aCategory, TUint aKey );
       
    42 
       
    43     /**
       
    44     * Destructor.
       
    45     */
       
    46     virtual ~CSsmPsKeyObserver();
       
    47 
       
    48     /**
       
    49     * Start observing the key value.
       
    50     *
       
    51     * @param aStatus Request status to be completed when the property reaches
       
    52     *        the target value.
       
    53     */
       
    54     void StartObserving( TRequestStatus& aStatus );
       
    55 
       
    56 private:
       
    57 
       
    58     /**
       
    59     * From CActive.
       
    60     * Implements cancellation of an outstanding request.
       
    61     */
       
    62     virtual void DoCancel();
       
    63 
       
    64     /**
       
    65     * From CActive.
       
    66     * Handles an active object’s request completion event.
       
    67     */
       
    68     virtual void RunL();
       
    69 
       
    70 protected:
       
    71 
       
    72     virtual TBool IsMatch( const TInt aKeyValue ) const = 0;
       
    73 
       
    74 private:
       
    75 
       
    76     /**
       
    77     * Check the key value fron P&S and subscribe to listen to changes
       
    78     * in the P&S key if the value is not the same as the target value.
       
    79     */
       
    80     void CheckKeyValue();
       
    81 
       
    82     /**
       
    83     * Complete client request with the given error code.
       
    84     *
       
    85     * @param aErrorCode The error code to complete the request with.
       
    86     */
       
    87     void Complete( const TInt aErrorCode );
       
    88 
       
    89 private: // data
       
    90 
       
    91     /** P&S variable to listen to. */
       
    92     RProperty iProperty;
       
    93 
       
    94     /** The UID that identifies the property category. */
       
    95     TUid iCategory;
       
    96 
       
    97     /**
       
    98     * The property sub-key, i.e. the key that identifies the specific property
       
    99     * within the category.
       
   100     */
       
   101     TUint iKey;
       
   102 
       
   103     /**
       
   104     * Request status to be completed when the property reaches the target value.
       
   105     */
       
   106     TRequestStatus* iClientStatus;
       
   107 
       
   108     };
       
   109 
       
   110 #endif // SSMPSKEYOBSERVER_H