SystemStateManager: The System State Manager example

This example demonstrates the System State Manager (SSM) API. It consists of System State Manager example executable (ssmanager.exe), two system state policy plugins (ssm.state.policy.0004.dll and ssm.state.policy.0005.dll), a system-wide property policy plugin (ssm.swp.policy.dummy.diskstatus.dll), an example Normal State policy (ssm.state.policy.0001.dll) and a dummy back-up application (dummybackup.exe).

Purpose

This example demonstrates following SSM features

  • How to write a System Wide Property (SWP) policy.

  • How to write a System State policy.

  • How to request a change to an SWP, with and without notification

  • How to request a change to a system state, with and without notification

Download

Click on the following link to download the example: ssmanager.zip

Click: browse to view the example code.

Design and implementation

The example consists of several components: a System State Manager example executable (ssmanager.exe), two system state policy plugins (ssm.state.policy.0004.dll and ssm.state.policy.0005.dll), a system-wide property policy plugin (ssm.swp.policy.dummy.diskstatus.dll), an example Normal State policy (ssm.state.policy.0001.dll) and a dummy back-up application (dummybackup.exe).

This section describes the components in the example:

  • ssmanager.exe: The main process which presents the menu to the user, receives the input from the user . It has the following functions:

    • RequestSwpChange(). This demonstrates changing the value of a system wide property without notifying any clients. When the disk status changes, the dummy backup application is launched to simulate a disk backup. RequestSwpChangeWithNotificationL() is similar to RequestSwpChange(), but it notifies its clients when a value of a system wide property changes.

    • RequestSsChange(). This demonstrates changing the system state without notifying any clients. When the system state changes from 'Normal' to 'Restore' state, the dummy backup application is launched. RequestSsChangeWithNotification() is similar to RequestSwpChange(), but it notifies its clients when a value of a system wide property changes.

  • ssm.state.policy.0004.dll:The dummy backup system state policy with custom commands listed in a resource file (ssm_cmdlist_state_dummy_backup.rss). The command list is prepared in the dummy backup policy using the CSsmCommandListResourceReader class.

  • ssm.state.policy.0005.dll: The dummy restore system state policy with custom commands defined using the command factory classes MSsmCommand and SsmCommandFactory.

  • ssm.swp.policy.dummy.diskstatus.dll: The dummy disk status system-wide property with custom commands listed in a resource file (ssm_cmdlist_swp_dummy_diskstatus.rss). The command list is prepared by using the CSsmCommandListResourceReader class.

  • ssm.state.policy.0001.dll: the dummy back up and restore states need to be supported by the Normal state inorder to allow transition from one state to another. Hence, the existing Normal state policy file is updated with the changes required to support these transitions.

  • dummybackup.exe: The dummy application which is launched when the system state changes to 'backup'. It just prints a series of statements to the console.

Building and configuring

To build the example:

  • The example builds the following binaries

    ssmanager.exe

    ssm.state.policy.0004.dll

    ssm.state.policy.0005.dll

    ssm.swp.policy.dummy.diskstatus.dll

    ssm.state.policy.0001.dll

    dummybackup.exe

  • You can build the example from your IDE or the command line.

    If you use an IDE, import the bld.inf file of the example into your IDE, and use the build command of the IDE.

    If you use the command line, open a command prompt, and set the current directory to the source code directory of the example. You can then build the example with the SBSv1 build tools with the following commands:

    bldmake bldfiles

    abld build

  • For the emulator, the example builds ssmanager.exe in the epoc32\release\winscw\<udeb or urel>\ folder.