taskswitcher/contextengine/hgctxutils/inc/hgcenreplistener.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 18 Jan 2010 20:10:36 +0200
changeset 2 08c6ee43b396
permissions -rw-r--r--
Revision: 201001 Kit: 201003

/*
* ===========================================================================
*  Name        : HgCenrepListener.h
*  Part of     : Hg
*  Description : Class to get notifications about changes to a cenrep key
*
*  Copyright © 2008 Nokia Corporation.
*  This material, including documentation and any related 
*  computer programs, is protected by copyright controlled by 
*  Nokia Corporation. All rights are reserved. Copying, 
*  including reproducing, storing, adapting or translating, any 
*  or all of this material requires the prior written consent of 
*  Nokia Corporation. This material also contains confidential 
*  information which may not be disclosed to others without the 
*  prior written consent of Nokia Corporation.
* ===========================================================================
*/

#ifndef __CENREPLISTENER_H__
#define __CENREPLISTENER_H__

#include <e32base.h>

class CRepository;

/**
 * Observer interface for getting notifications about a cenrep key change.
 */
class MHgCenrepChangeObserver
    {
public:
    virtual void CenrepChanged( TUint32 aKey, TInt aNewValue ) = 0;
    };

/**
 * Class to get notifications about changes to a cenrep key.
 */
NONSHARABLE_CLASS( CHgCenrepListener ) : public CActive
    {
public:
    /**
     * Fist step constructor
     */
    IMPORT_C static CHgCenrepListener* NewL(const TUid& aRep, TUint32 aKey,
                                            MHgCenrepChangeObserver& aObserver);
    
    /**
     * Fist step constructor
     */
    IMPORT_C static CHgCenrepListener* NewLC(const TUid& aRep, TUint32 aKey,
                                             MHgCenrepChangeObserver& aObserver);
    
    /**
     * Destructor.
     */
    IMPORT_C ~CHgCenrepListener();
    
    /**
     * Returns the current value of the watched key.
     */
    IMPORT_C TInt Value();
    
private:
    /**
     * Constructor.
     * Starts listening for the key.
     */
    CHgCenrepListener(TUint32 aKey,
        MHgCenrepChangeObserver& aObserver );
    
    /**
     * Second step constructor 
     */
    void ConstructL(const TUid& aRep);
    
    void DoCancel();
    void RunL(); 
    TInt RunError( TInt aError );
    
    MHgCenrepChangeObserver& iObserver;
    CRepository* iRep;
    TUint32 iKey;
    };
    
#endif