CCenRepNotifyHandler Class Reference

#include <cenrepnotifyhandler.h>

Link against: cenrepnotifhandler.lib

class CCenRepNotifyHandler : public CActive

Inherits from

Detailed Description

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);
    }

Member Enumeration Documentation

Enum TCenRepKeyType

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

EnumeratorValueDescription
EIntKeyKey holds a TInt value.
ERealKeyKey holds a TReal value.
EStringKeyKey holds a TDesC16 value.
EBinaryKeyKey holds a TDesC8 value.

Constructor & Destructor Documentation

~CCenRepNotifyHandler ( )

IMPORT_C~CCenRepNotifyHandler()[virtual]

Destructor.

Member Function Documentation

DoCancel ( )

voidDoCancel()[protected, virtual]

Reimplemented from CActive::DoCancel()

Implements CActive

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

IMPORT_C CCenRepNotifyHandler *NewL(MCenRepNotifyHandlerCallback &aCallback,
CRepository &aSession,
TCenRepKeyTypeaKeyType,
TUint32aId
)[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.

Parameters
aCallbackReference to a callback instance.
aSessionReference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
aKeyTypeType of the key identified by aId parameter.
aIdId of the key that change notifications are needed for.
Return Value
A pointer to a new instance of the CCenRepNotifyHandler class.
Leave Codes
KErrArgumentif invalid key type is passed as a parameter.
Capability
None

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.

Parameters
aCallbackReference to a callback instance.
aSessionReference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
Return Value
A pointer to a new instance of the CCenRepNotifyHandler class.
Capability
None

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

IMPORT_C CCenRepNotifyHandler *NewLC(MCenRepNotifyHandlerCallback &aCallback,
CRepository &aSession,
TCenRepKeyTypeaKeyType,
TUint32aId
)[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.

Parameters
aCallbackReference to a callback instance.
aSessionReference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
aKeyTypeType of the key identified by aId parameter.
aIdId of the key that change notifications are needed for.
Return Value
A pointer to a new instance of the CCenRepNotifyHandler class.
Leave Codes
KErrArgumentif invalid key type is passed as a parameter.
Capability
None

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.

Parameters
aCallbackReference to a callback instance.
aSessionReference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
Return Value
A pointer to a new instance of the CCenRepNotifyHandler class.
Capability
None

RunError ( TInt )

TInt RunError(TIntaError)[protected, virtual]

Reimplemented from CActive::RunError(TInt)

Implements CActive

Parameters
aErrorthe error returned
Return Value
error

RunL ( )

voidRunL()[protected, virtual]

Reimplemented from CActive::RunL()

Implements CActive

StartListeningL ( )

IMPORT_C voidStartListeningL()

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 Codes
KErrNotFoundif 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
DependentCapability required depends on platform security of keyspace.

StopListening ( )

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