Registering for Shutdown Notification

This document explains how to register for shutdown notification for a component.

Before you start, you must know:

  • the APIs for components that want to be system state aware.

  • that each state aware component must connect to the appropriate domain ID.

Register a component or an application for shutdown notification through RSsmStateAwareSession if they need to do save critical or non-critical data and perform clean-up tasks at the time of shutdown.

For example, a component or an application can free all resources or can close any connection with the servers to make the shutdown graceful. The shutdown sequence will commence once all the components acknowledge the notification they have received.

Follow the steps given below to register for shutdown notification:


  1. Create a class which is derived from CActive The following code snippet illustrates how to create a class from CActive:
    
    class CExample : public CActive
    {
        public:
              static CExample* NewL();
              ~CExample();
    
              private:
                  //from CActive
                  void RunL();
                  void DoCancel();
              private:
                  void ConstructL();
              private:
                  RSsmStateAwareSession iStateAwareSession;
                  //A state aware component, which can be used to provide APIs for components that want to be system state aware.
    };
    

  2. Connect the session and register for notification. The following code snippet illustrates how to connect the session and register for notification:
    
    CExample* CExample::NewL()
    {
        CExample* self = new( ELeave ) CExample();
              CleanupStack::PushL( self );
              self->ConstructL();
              CleanupStack::Pop( self );
              return self;
    }
    CExample:: CExample()
    CActive( CActive::EPriorityStandard )
    {
        CActiveScheduler::Add( this );
    }
    void CExample::ConstructL()
    {
        // Each state aware component must connect to the appropriate domain ID.
        //Example, this component is high up in the domain hierarchy ( in the UI Frameworks domain ).
        User::LeaveIfError( iStateAwareSession.Connect ( KUIFramework3 ));
              iStateAwareSession.RequestStateNotification( iStatus );
              SetActive();
    }

The component is registered for shutdown notification.

After registering for shutdown notification, the user needs to know how the component handles and acknowledge the shutdown notification.