Creating a Vibra instance to control the vibra

A CHWRMVibra instance can be created by using NewL() or NewLC() methods. After this, vibra can be directly controlled via the provided class methods.

Without notify handling

The user has to create an instance of the CHWRMVibra implementation class using the NewL() or NewLC() constructor without a parameter. The following code snippet demonstrates how to create an instance without notify handling to control the device vibra:

       CHWRMVibra* vibra = CHWRMVibra::NewLC(); // No callbacks
      

With notify handling

The client must derive a class from the MHWRMVibraObserver interface and implement the VibraModeChanged() and VibraStatusChanged() methods.

The following code snippet gives an example of the header of the class implemented by the client:

       // INCLUDES
#include HWRMVibra.h // Link against HWRMVibraClient.lib.
class CVibraStatusObserver : public CBase,
                             public MHWRMVibraObserver
    {
    public:
        CVibraStatusObserver();
        ~CVibraStatusObserver();
        void ConstructL();
        static CVibraStatusObserver* NewL(); 
        // from MHWRMVibraObserver
        virtual void VibraModeChanged( CHWRMVibra::TVibraModeState aStatus );
        virtual void VibraStatusChanged( CHWRMVibra::TVibraStatus aStatus );
    private:
        CHWRMVibra* iVibra;
    };
      

Create an instance of the CHWRMVibra implementation class using the NewL() or NewLC() constructor with a parameter. This parameter is a pointer to an object that is derived from MHWRMVibraObserver . Every vibra user setting profile change causes the notification using MHWRMVibraObserver::VibraModeChanged() . Every vibra status change causes the notification using MHWRMVibraObserver::VibraStatusChanged() .

The following code snippet demonstrates how to create an instance with notify handling to control the device vibra:

       void CVibraStatusObserver::ConstructL()
    {
    iVibra = CHWRMVibra::NewL( this )
    }