|
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-E93EE459-8CF4-42A1-B06C-E78E56FD25A0" xml:lang="en"><title>Listening |
|
13 for Property Changes</title><shortdesc>The sensor channel APIs enable the client applications to be notified |
|
14 about the changes to properties associated with a sensor channel.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
15 <prereq id="GUID-D1D22060-E453-4046-953D-10486D45885F"> Before listening for |
|
16 the property changes of a sensor channel, you must <xref href="GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B.dita#GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B/GUID-FBBD3A8B-F240-4DC0-B516-3A51FDD86A88">open the sensor channel</xref>. </prereq> |
|
17 <context id="GUID-0D960123-7430-42B5-A84D-B63F2852DD7C"><p>The client applications |
|
18 can use the property listener to monitor the property changes made by other |
|
19 clients.</p></context> |
|
20 <steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-6-1-8-1-1-6-1-4-1-4-1-8-1-3-3"> |
|
21 <step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-6-1-8-1-1-6-1-4-1-4-1-8-1-3-3-1"><cmd>Create a property |
|
22 listener implementation for the <parmname>MSensrvPropertyListener</parmname> interface.</cmd> |
|
23 <stepxmp><codeblock xml:space="preserve">class PropertyListener:public MSensrvPropertyListener |
|
24 { |
|
25 public: |
|
26 void PropertyChanged(CSensrvChannel &aChannel, const TSensrvProperty &aChangedProperty) |
|
27 { |
|
28 ... |
|
29 //Implementation |
|
30 } |
|
31 void PropertyError(CSensrvChannel &aChannel, TSensrvErrorSeverity aError) |
|
32 { |
|
33 ... |
|
34 //Implementation |
|
35 } |
|
36 void SetPropertySuccessIndicationChanged(TSetPropertySuccessIndicator aIndication) |
|
37 { |
|
38 ... |
|
39 //Implementation |
|
40 } |
|
41 void GetPropertyListenerInterfaceL(TUid aInterfaceUid, TAny *&aInterface) |
|
42 { |
|
43 ... |
|
44 //Implementation |
|
45 } |
|
46 };</codeblock></stepxmp> |
|
47 </step> |
|
48 <step id="GUID-6AB619B9-0259-493A-BC40-CAF5BF337E04"><cmd>Start property listening |
|
49 by passing an instance of property listener implementation using <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-4552066A-4FC1-3876-89AA-DC9B081B3814"><apiname>CSensrvChannel::SetPropertyListenerL()</apiname></xref>.</cmd> |
|
50 <stepxmp><codeblock xml:space="preserve">//Instance of the property listener implementation |
|
51 PropertyListener propListener; |
|
52 ... |
|
53 CSensrvChannel* channel; |
|
54 ... |
|
55 channel->SetPropertyListenerL(&propListener); |
|
56 ...</codeblock></stepxmp> |
|
57 <info>When a property change occurs, a <parmname>PropertyChanged()</parmname> notification |
|
58 is delivered through the <parmname>MSensrvPropertyListener</parmname> callback |
|
59 interface to the clients that are listening for property changes.<note> The |
|
60 client that set the property is not notified.</note></info> |
|
61 </step> |
|
62 <step id="GUID-8AD85E3B-EBBC-41E4-A32C-AF2A52B018E6"><cmd>Once you get the |
|
63 required property changes associated with the sensor channel, you can stop |
|
64 property listening by passing a NULL parameter to the <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-4552066A-4FC1-3876-89AA-DC9B081B3814"><apiname>CSensrvChannel::SetPropertyListenerL()</apiname></xref> function.</cmd> |
|
65 <stepxmp><codeblock xml:space="preserve">channel->SetPropertyListenerL();</codeblock></stepxmp> |
|
66 </step> |
|
67 </steps> |
|
68 </taskbody></task> |