Monitoring a System-Wide Property

A component with appropriate platform security capabilities can request a change to a system-wide property value. The SSM distributes notifications of the changing of system-wide property values to components that have requested notifications.

System-wide properties are attributes of a device that have system-wide significance. It allows components to be aware of the device state. They are defined by system-wide property policies within a SSM plug-in that can be customized by licensees. These policies determine the set of properties, their permissible values and transitions, and the tasks that are performed when each value changes.

Follow the steps given below to monitor a system-wide property:


  1. Connect to the specified system-wide property that must be monitored. RSsmSystemWideProperty class is used to monitor a system-wide property as shown in the code snippet.
    
    RSsmSystemWideProperty diskStatus;    
    
    User::LeaveIfError( diskStatus.Connect ( ESystemDriveSpace ) );

  2. Subscribe for change notifications, when the value of the connected system-wide property changes as shown in the code snippet.
    
    TRequestStatus status;
    diskStatus.Subscribe( status );

  3. Depending on the value of the property, user defines certain actions that must be performed.

  4. Close the system-wide property that is handled.

The system-wide property is monitored.

Example

The following example code shows how a while loop is used to remove cache files from disk when the ESystemDriveSpace (one of the system-wide property) property becomes ELow or ECritical.

Note: The ESystemDriveSpace property is an example property and is not part of a defined API to be delivered by the Symbian platform as part of the System State Management Architecture

void RunCacheLoopL()
    {
    RSsmSystemWideProperty diskStatus;
    User::LeaveIfError( diskStatus.Connect( ESystemDriveSpace ) );
    TRequestStatus status;
    diskStatus.Subscribe( status );
    while( ETrue )
        {
        User::WaitForRequest( status );
        if( status != KErrNone )
            {
            // Handle error
            }

        // Re-subscribe before you read so that you do not miss any notifications
        diskStatus.Subscribe( status );
        TInt value = diskStatus.GetValue();
        switch ( value )
            {    
            case ENormal:
                 EnableDiskCache();
            break;
            case ELow: // Fall through
            case ECritical:
                 DisableDiskCache();
                 RemoveDiskCache();
            break;
            }
         }
      }
Related concepts
System-wide Properties