CCenRepNotifyHandler Class Reference

class CCenRepNotifyHandler : public CActive

Active object wrapper for Central Repository one-shot notification handling. Central Repository Notification Handler API provides an easy-to-use implementation of a CActive-based wrapper for Central Repository single-shot notifications. In most cases Central Repository Notification Handler can automatically resubscribe to notifications and fetch the modified value from Central Repository. The API consists of the classes CCenRepNotifyHandler and MCenRepNotifyHandlerCallback . The user of this class needs to implement relevant MCenRepNotifyHandlerCallback interface methods to receive notifications. The user of Central Repository Notification Handler API needs access to Central Repository (centralrepository.h).

Usage:

Initialization example (from a class that implements MCenRepNotifyHandlerCallback interface):
        iSession = CRepository::NewL(KTestUid);
 iNotifyHandler = CCenRepNotifyHandler::NewL(*this, *iSession, CCenRepNotifyHandler::EStringKey, KKey1);
 iNotifyHandler->StartListeningL();
       
Uninitialization example:
        iNotifyHandler->StopListening(); 
 delete iNotifyHandler;
       
Handler method implementation example:
        void CMyCenRepNotifyTest::HandleNotifyString(TUint32 aId, const TDesC16&  aNewValue)
    {
    // Print out the notified value
    RDebug::Print(_L("Key %d changed, new value: %S"), aId, &aNewValue);
    }
       

Inherits from

Public Member Functions
~CCenRepNotifyHandler ()
IMPORT_C CCenRepNotifyHandler * NewL ( MCenRepNotifyHandlerCallback &, CRepository &, TCenRepKeyType , TUint32 )
IMPORT_C CCenRepNotifyHandler * NewL ( MCenRepNotifyHandlerCallback &, CRepository &)
IMPORT_C CCenRepNotifyHandler * NewLC ( MCenRepNotifyHandlerCallback &, CRepository &, TCenRepKeyType , TUint32 )
IMPORT_C CCenRepNotifyHandler * NewLC ( MCenRepNotifyHandlerCallback &, CRepository &)
IMPORT_C void StartListeningL ()
IMPORT_C void StopListening ()
Protected Member Functions
void DoCancel ()
TInt RunError ( TInt )
void RunL ()
Private Member Functions
CCenRepNotifyHandler ( MCenRepNotifyHandlerCallback &, CRepository &, TCenRepKeyType , TUint32 )
CCenRepNotifyHandler ( MCenRepNotifyHandlerCallback &, CRepository &)
TInt OrderNotification ()
Inherited Functions
CActive::CActive(TInt)
CActive::Cancel()
CActive::Deque()
CActive::Extension_(TUint,TAny *&,TAny *)
CActive::IsActive()const
CActive::IsAdded()const
CActive::Priority()const
CActive::SetActive()
CActive::SetPriority(TInt)
CActive::~CActive()
CBase::CBase()
CBase::Delete(CBase *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enum TCenRepKeyType { EIntKey , ERealKey , EStringKey , EBinaryKey }
Inherited Enumerations
CActive:TPriority
Private Attributes
MCenRepNotifyHandlerCallback & iCallback
TUint32 iId
TCenRepKeyType iKeyType
CRepository & iSession
TBool iWholeRepository
Inherited Attributes
CActive::iStatus

Constructor & Destructor Documentation

CCenRepNotifyHandler(MCenRepNotifyHandlerCallback &, CRepository &, TCenRepKeyType, TUint32)

CCenRepNotifyHandler ( MCenRepNotifyHandlerCallback & aCallback,
CRepository & aSession,
TCenRepKeyType aKeyType,
TUint32 aId
) [private]

Constructor used for single key listening.

capability
None

Parameters

MCenRepNotifyHandlerCallback & aCallback Reference to a callback instance.
CRepository & aSession Reference to an existing repository session.
TCenRepKeyType aKeyType Type of the key identified by aId parameter.
TUint32 aId Id of the key that change notifications are needed for.

CCenRepNotifyHandler(MCenRepNotifyHandlerCallback &, CRepository &)

CCenRepNotifyHandler ( MCenRepNotifyHandlerCallback & aCallback,
CRepository & aSession
) [private]

Constructor used for whole repository listening.

capability
None

Parameters

MCenRepNotifyHandlerCallback & aCallback Reference to a callback instance.
CRepository & aSession Reference to an existing repository session.

~CCenRepNotifyHandler()

IMPORT_C ~CCenRepNotifyHandler ( ) [virtual]

Destructor.

Member Functions Documentation

DoCancel()

void DoCancel ( ) [protected, virtual]

Implements CActive

NewL(MCenRepNotifyHandlerCallback &, CRepository &, TCenRepKeyType, TUint32)

IMPORT_C CCenRepNotifyHandler * NewL ( MCenRepNotifyHandlerCallback & aCallback,
CRepository & aSession,
TCenRepKeyType aKeyType,
TUint32 aId
) [static]

This is a two-phase constructor method that is used to create a new instance for listening to the changes in a single key.

leave
KErrArgument if invalid key type is passed as a parameter.
capability
None

Parameters

MCenRepNotifyHandlerCallback & aCallback Reference to a callback instance.
CRepository & aSession Reference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
TCenRepKeyType aKeyType Type of the key identified by aId parameter.
TUint32 aId Id of the key that change notifications are needed for.

NewL(MCenRepNotifyHandlerCallback &, CRepository &)

IMPORT_C CCenRepNotifyHandler * NewL ( MCenRepNotifyHandlerCallback & aCallback,
CRepository & aSession
) [static]

This is a two-phase constructor method that is used to create a new instance for listening to the changes in all keys in the repository.

Type specific callback methods of MCenRepNotifyHandlerCallback will not be used when notifying about changes in this case, only HandleNotifyGeneric() is used.

capability
None

Parameters

MCenRepNotifyHandlerCallback & aCallback Reference to a callback instance.
CRepository & aSession Reference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.

NewLC(MCenRepNotifyHandlerCallback &, CRepository &, TCenRepKeyType, TUint32)

IMPORT_C CCenRepNotifyHandler * NewLC ( MCenRepNotifyHandlerCallback & aCallback,
CRepository & aSession,
TCenRepKeyType aKeyType,
TUint32 aId
) [static]

This is a two-phase constructor method that is used to create a new instance for listening to the changes in a single key. Leaves the constructed instance to cleanup stack.

leave
KErrArgument if invalid key type is passed as a parameter.
capability
None

Parameters

MCenRepNotifyHandlerCallback & aCallback Reference to a callback instance.
CRepository & aSession Reference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
TCenRepKeyType aKeyType Type of the key identified by aId parameter.
TUint32 aId Id of the key that change notifications are needed for.

NewLC(MCenRepNotifyHandlerCallback &, CRepository &)

IMPORT_C CCenRepNotifyHandler * NewLC ( MCenRepNotifyHandlerCallback & aCallback,
CRepository & aSession
) [static]

This is a two-phase constructor method that is used to create a new instance for listening to the changes in all keys in the repository. Leaves the constructed instance to cleanup stack.

Type specific callback methods of MCenRepNotifyHandlerCallback will not be used when notifying about changes in this case, only HandleNotifyGeneric() is used.

capability
None

Parameters

MCenRepNotifyHandlerCallback & aCallback Reference to a callback instance.
CRepository & aSession Reference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.

OrderNotification()

TInt OrderNotification ( ) [private]

RunError(TInt)

TInt RunError ( TInt aError ) [protected, virtual]

Implements CActive

Parameters

TInt aError the error returned

RunL()

void RunL ( ) [protected, virtual]

Implements CActive

StartListeningL()

IMPORT_C void StartListeningL ( )

When this method is called, the CCenRepNotifyHandler starts listening for notifications. If it is already listening, nothing happens.

For single setting handler when there is already an existing notification on the same setting and session,the HandleNotifyError will be trigerred with KErrAlreadyExists error
leave
KErrNotFound if setting does not exist KErrPermissionDenied if client does not have the necessary capability plus other system-wide error codes. For whole settings handler, the HandleNotifyError will be trigerred with the error code
capability
Dependent Capability required depends on platform security of keyspace.

StopListening()

IMPORT_C void StopListening ( )
When this method is called, the CCenRepNotifyHandler stops listening for notifications. If it is already stopped, nothing happens.
capability
None

Member Enumerations Documentation

Enum TCenRepKeyType

Defines different key types. Enumeration is used to indicate the key type that is listened to.

Enumerators

EIntKey
ERealKey
EStringKey
EBinaryKey

Member Data Documentation

MCenRepNotifyHandlerCallback & iCallback

MCenRepNotifyHandlerCallback & iCallback [private]

TUint32 iId

TUint32 iId [private]

TCenRepKeyType iKeyType

TCenRepKeyType iKeyType [private]

CRepository & iSession

CRepository & iSession [private]

TBool iWholeRepository

TBool iWholeRepository [private]