Symbian3/PDK/Source/GUID-F892D93D-0B59-592A-9DA5-AD4243F607E3.dita
author Graeme Price <GRAEME.PRICE@NOKIA.COM>
Fri, 15 Oct 2010 14:32:18 +0100
changeset 15 307f4279f433
parent 14 578be2adaf3e
permissions -rw-r--r--
Initial contribution of the Adaptation Documentation.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-F892D93D-0B59-592A-9DA5-AD4243F607E3" xml:lang="en"><title>Monitoring
a System-Wide Property</title><shortdesc>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. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<context id="GUID-E7C7C660-A8C9-48AD-AB5A-115A45E6A4C3"><p>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. </p><p>Follow the steps given below to monitor a system-wide
property:</p></context>
<steps id="GUID-B84F605D-60D2-5C56-B301-CE94210044F6">
<step id="GUID-FDF1FD82-C7F0-5652-879C-1FB760B9FDBD"><cmd/>
<info>Connect to the specified system-wide property that must be monitored. </info>
<info> <codeph> RSsmSystemWideProperty</codeph> class is used to monitor a
system-wide property as shown in the code snippet. </info>
<stepxmp><codeblock id="GUID-7150B164-7CF9-529F-8FB5-B9AAD7374F55" xml:space="preserve">
RSsmSystemWideProperty diskStatus;    

User::LeaveIfError( diskStatus.Connect ( ESystemDriveSpace ) );</codeblock> </stepxmp>
</step>
<step id="GUID-DC57F89E-CE90-59D7-AAD5-691223EA9032"><cmd/>
<info>Subscribe for change notifications, when the value of the connected
system-wide property changes as shown in the code snippet. </info>
<stepxmp><codeblock id="GUID-623FC9D1-CCD0-5195-9B2F-5AE4E7AE8A5B" xml:space="preserve">
TRequestStatus status;
diskStatus.Subscribe( status );</codeblock> </stepxmp>
</step>
<step id="GUID-C78A5888-E4DC-514D-8467-30B03B843214"><cmd/>
<info>Depending on the value of the property, user defines certain actions
that must be performed. </info>
</step>
<step id="GUID-558ACA06-AED0-5095-B841-B2DAC12A197E"><cmd/>
<info>Close the system-wide property that is handled. </info>
</step>
</steps>
<result id="GUID-CDE75920-1DF0-459D-B721-E939B23E11F8"><p>The system-wide property is monitored. </p> </result>
<example><title> Example</title> <p>The following example code shows how a
while loop is used to remove cache files from disk when the <codeph>ESystemDriveSpace</codeph> (one
of the system-wide property) property becomes <codeph>ELow</codeph> or <codeph>ECritical</codeph>. </p> <p> <b>Note:</b> The <codeph>ESystemDriveSpace</codeph> 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 </p> <codeblock id="GUID-AE3F2B3D-7705-5718-9103-AFFFF5DCCAB9" xml:space="preserve">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;
            }
         }
      }
</codeblock> </example>
</taskbody><related-links>
<link href="GUID-DA68ED44-4BF4-54EF-8090-821F73F7904D.dita"><linktext>System-wide
Properties</linktext></link>
<link href="GUID-95FA6DDA-E1C2-5148-9F18-4171BF06C9AC.dita"><linktext>Creating
a System-wide Property Policy Plug-in</linktext></link>
</related-links></task>