CCenRepNotifyHandler Class Reference

API published in: S60 3rd Ed FP 1

Link against: cenrepnotifhandler.lib

Capability Information

Required Capabilities

None

Exceptions

Capability required depends on platform security of the repository.


#include <cenrepnotifyhandler.h>

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

Public Types

enum   TCenRepKeyType { EIntKey, ERealKey, EStringKey, EBinaryKey }
  Defines different key types. More...

Public Member Functions

IMPORT_C void  StartListeningL ()
  When this method is called, the CCenRepNotifyHandler starts listening for notifications.
IMPORT_C void  StopListening ()
  When this method is called, the CCenRepNotifyHandler stops listening for notifications.
virtual IMPORT_C  ~CCenRepNotifyHandler ()
  Destructor.

Static Public Member Functions

static IMPORT_C CCenRepNotifyHandler NewL (MCenRepNotifyHandlerCallback &aCallback, CRepository &aSession, TCenRepKeyType aKeyType, TUint32 aId)
  This is a two-phase constructor method that is used to create a new instance for listening to the changes in a single key.
static IMPORT_C CCenRepNotifyHandler NewL (MCenRepNotifyHandlerCallback &aCallback, CRepository &aSession)
  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.
static IMPORT_C CCenRepNotifyHandler NewLC (MCenRepNotifyHandlerCallback &aCallback, CRepository &aSession, TCenRepKeyType aKeyType, TUint32 aId)
  This is a two-phase constructor method that is used to create a new instance for listening to the changes in a single key.
static IMPORT_C CCenRepNotifyHandler NewLC (MCenRepNotifyHandlerCallback &aCallback, CRepository &aSession)
  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.

Protected Member Functions

void  RunL ()
  Implements CActive.
TInt  RunError (TInt aError)
  Implements CActive.
void  DoCancel ()
  Implements CActive.

Member Enumeration Documentation

enum CCenRepNotifyHandler::TCenRepKeyType
 

Defines different key types.

Enumeration is used to indicate the key type that is listened to.

Enumerator:
EIntKey  Key holds a TInt value.
ERealKey  Key holds a TReal value.
EStringKey  Key holds a TDesC16 value.
EBinaryKey  Key holds a TDesC8 value.

Constructor & Destructor Documentation

virtual IMPORT_C CCenRepNotifyHandler::~CCenRepNotifyHandler  )  [virtual]
 

Destructor.


Member Function Documentation

void CCenRepNotifyHandler::DoCancel  )  [protected]
 

Implements CActive.

Parameters:
none 
Returns:
none
static IMPORT_C CCenRepNotifyHandler* 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:
aCallback  Reference to a callback instance.
aSession  Reference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
Returns:
A pointer to a new instance of the CCenRepNotifyHandler class.
static IMPORT_C CCenRepNotifyHandler* 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.

Parameters:
aCallback  Reference to a callback instance.
aSession  Reference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
aKeyType  Type of the key identified by aId parameter.
aId  Id of the key that change notifications are needed for.
Returns:
A pointer to a new instance of the CCenRepNotifyHandler class.
Leave:
KErrArgument if invalid key type is passed as a parameter.
static IMPORT_C CCenRepNotifyHandler* 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:
aCallback  Reference to a callback instance.
aSession  Reference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
Returns:
A pointer to a new instance of the CCenRepNotifyHandler class.
static IMPORT_C CCenRepNotifyHandler* 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.

Parameters:
aCallback  Reference to a callback instance.
aSession  Reference to an existing repository session. Do not close this session until all CCenRepNotifyHandler instances referring to it have been deleted.
aKeyType  Type of the key identified by aId parameter.
aId  Id of the key that change notifications are needed for.
Returns:
A pointer to a new instance of the CCenRepNotifyHandler class.
Leave:
KErrArgument if invalid key type is passed as a parameter.
TInt CCenRepNotifyHandler::RunError TInt  aError  )  [protected]
 

Implements CActive.

Parameters:
aError  the error returned
Returns:
error
void CCenRepNotifyHandler::RunL  )  [protected]
 

Implements CActive.

Parameters:
none 
Returns:
none
IMPORT_C void CCenRepNotifyHandler::StartListeningL  ) 
 

When this method is called, the CCenRepNotifyHandler starts listening for notifications.

If it is already listening, nothing happens.

Leave:
KErrAlreadyExists if there is already a notification on same CRepository for this setting, or an error from IPC or server side resource allocation failure.
IMPORT_C void CCenRepNotifyHandler::StopListening  ) 
 

When this method is called, the CCenRepNotifyHandler stops listening for notifications.

If it is already stopped, nothing happens.


The documentation for this class was generated from the following file:

Copyright © Nokia Corporation 2001-2008
Back to top