|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE task |
|
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
|
12 <task id="GUID-F892D93D-0B59-592A-9DA5-AD4243F607E3" xml:lang="en"><title>Monitoring |
|
13 a System-Wide Property</title><shortdesc>A component with appropriate platform security capabilities can |
|
14 request a change to a system-wide property value. The SSM distributes notifications |
|
15 of the changing of system-wide property values to components that have requested |
|
16 notifications. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
17 <context><p>System-wide properties are attributes of a device that have system-wide |
|
18 significance. It allows components to be aware of the device state. They are |
|
19 defined by system-wide property policies within a SSM plug-in that can be |
|
20 customized by licensees. These policies determine the set of properties, their |
|
21 permissible values and transitions, and the tasks that are performed when |
|
22 each value changes. </p><p>Follow the steps given below to monitor a system-wide |
|
23 property:</p></context> |
|
24 <steps id="GUID-B84F605D-60D2-5C56-B301-CE94210044F6"> |
|
25 <step id="GUID-FDF1FD82-C7F0-5652-879C-1FB760B9FDBD"><cmd/> |
|
26 <info>Connect to the specified system-wide property that must be monitored. </info> |
|
27 <info> <codeph> RSsmSystemWideProperty</codeph> class is used to monitor a |
|
28 system-wide property as shown in the code snippet. </info> |
|
29 <stepxmp><codeblock id="GUID-7150B164-7CF9-529F-8FB5-B9AAD7374F55" xml:space="preserve"> |
|
30 RSsmSystemWideProperty diskStatus; |
|
31 |
|
32 User::LeaveIfError( diskStatus.Connect ( ESystemDriveSpace ) );</codeblock> </stepxmp> |
|
33 </step> |
|
34 <step id="GUID-DC57F89E-CE90-59D7-AAD5-691223EA9032"><cmd/> |
|
35 <info>Subscribe for change notifications, when the value of the connected |
|
36 system-wide property changes as shown in the code snippet. </info> |
|
37 <stepxmp><codeblock id="GUID-623FC9D1-CCD0-5195-9B2F-5AE4E7AE8A5B" xml:space="preserve"> |
|
38 TRequestStatus status; |
|
39 diskStatus.Subscribe( status );</codeblock> </stepxmp> |
|
40 </step> |
|
41 <step id="GUID-C78A5888-E4DC-514D-8467-30B03B843214"><cmd/> |
|
42 <info>Depending on the value of the property, user defines certain actions |
|
43 that must be performed. </info> |
|
44 </step> |
|
45 <step id="GUID-558ACA06-AED0-5095-B841-B2DAC12A197E"><cmd/> |
|
46 <info>Close the system-wide property that is handled. </info> |
|
47 </step> |
|
48 </steps> |
|
49 <result><p>The system-wide property is monitored. </p> </result> |
|
50 <example><title> Example</title> <p>The following example code shows how a |
|
51 while loop is used to remove cache files from disk when the <codeph>ESystemDriveSpace</codeph> (one |
|
52 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 |
|
53 by Symbian platform as part of the System State Management Architecture </p> <codeblock id="GUID-AE3F2B3D-7705-5718-9103-AFFFF5DCCAB9" xml:space="preserve">void RunCacheLoopL() |
|
54 { |
|
55 RSsmSystemWideProperty diskStatus; |
|
56 User::LeaveIfError( diskStatus.Connect( ESystemDriveSpace ) ); |
|
57 TRequestStatus status; |
|
58 diskStatus.Subscribe( status ); |
|
59 while( ETrue ) |
|
60 { |
|
61 User::WaitForRequest( status ); |
|
62 if( status != KErrNone ) |
|
63 { |
|
64 // Handle error |
|
65 } |
|
66 |
|
67 // Re-subscribe before you read so that you do not miss any notifications |
|
68 diskStatus.Subscribe( status ); |
|
69 TInt value = diskStatus.GetValue(); |
|
70 switch ( value ) |
|
71 { |
|
72 case ENormal: |
|
73 EnableDiskCache(); |
|
74 break; |
|
75 case ELow: // Fall through |
|
76 case ECritical: |
|
77 DisableDiskCache(); |
|
78 RemoveDiskCache(); |
|
79 break; |
|
80 } |
|
81 } |
|
82 } |
|
83 </codeblock> </example> |
|
84 </taskbody><related-links> |
|
85 <link href="GUID-DA68ED44-4BF4-54EF-8090-821F73F7904D.dita"><linktext>System-wide |
|
86 Properties</linktext></link> |
|
87 <link href="GUID-95FA6DDA-E1C2-5148-9F18-4171BF06C9AC.dita"><linktext>Creating |
|
88 a System-wide Property Policy Plug-in</linktext></link> |
|
89 </related-links></task> |