|
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-09E44FE5-6BEE-49FF-8BBF-CBB3C066EE10" xml:lang="en"><title>Listening |
|
13 for Channel Changes</title><shortdesc>The sensor channel APIs enable you to receive notifications when |
|
14 a sensor channel is added or removed. This ensures that you are informed of |
|
15 changes to sensor channels whenever there is a change. For example, you can |
|
16 receive notifications when a specific proximity sensor channel is added.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
17 <prereq id="GUID-03B31784-B731-43C4-B2DC-38DD4898AE22"> <p>Before listening |
|
18 for channel changes, you must <xref href="GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B.dita#GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B/GUID-FBBD3A8B-F240-4DC0-B516-3A51FDD86A88">open |
|
19 the sensor channel</xref>.</p> </prereq> |
|
20 <steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-7-1-8-1-1-8-1-4-1-5-1-9-1-3-2"> |
|
21 <step id="GUID-B454B117-4FC5-4B19-B512-7B4A213E4C51"><cmd>Create a channel |
|
22 listener implementation for the <parmname>MSensrvChannelListener</parmname> interface.</cmd> |
|
23 <stepxmp><codeblock xml:space="preserve">class ChannelListener:public MSensrvChannelListener |
|
24 { |
|
25 public: |
|
26 void ChannelChangeDetected(const TSensrvChannelInfo &aDetectedChannel, TSensrvChannelChangeType aChangeType) |
|
27 { |
|
28 ... |
|
29 //Implementation |
|
30 } |
|
31 void ChannelDetectionError(CSensrvChannelFinder aChannelFinder, TSensrvErrorSeverity aError) |
|
32 { |
|
33 ... |
|
34 //Implementation |
|
35 } |
|
36 void GetChannelListenerInterfaceL(TUid aInterfaceUid, TAny *aInterface) |
|
37 { |
|
38 ... |
|
39 //Implementation |
|
40 } |
|
41 };</codeblock></stepxmp> |
|
42 </step> |
|
43 <step id="GUID-CB0E18F1-21C3-4B51-88C8-ABCBD083304D"><cmd>Start channel listening |
|
44 by passing an instance of the channel listener implementation, using <xref href="GUID-5F108D03-C8A6-3EF9-B103-2E8916633602.dita#GUID-5F108D03-C8A6-3EF9-B103-2E8916633602/GUID-FFB9A53F-CAD2-3CC7-9FAD-D254E15F83CF"><apiname>CSensrvChannelFinder::SetChannelListenerL()</apiname></xref> function.</cmd> |
|
45 <stepxmp><codeblock xml:space="preserve">//Instance of the channel listener implementation |
|
46 ChannelListener channelListener; |
|
47 //Channel search parameters |
|
48 TSensrvChannelInfo &searchParameters |
|
49 ... |
|
50 CSensrvChannelFinder* finder = CSensrvChannelFinder::NewLC(); |
|
51 ... |
|
52 channel->SetChannelListenerL(channelListener, searchParameters); |
|
53 ...</codeblock></stepxmp> |
|
54 <info><p>This listens for channels that meet the supplied search parameters. |
|
55 When a channel change occurs, a <parmname>ChannelChangeDetected</parmname> notification |
|
56 is delivered through the <parmname>MSensrvChannelListener</parmname> interface.</p></info> |
|
57 </step> |
|
58 <step id="GUID-E9FF2158-0E82-4AB8-A9C0-8FE5A2651FE8"><cmd>Stop channel listening |
|
59 by passing a NULL parameter to the <xref href="GUID-5F108D03-C8A6-3EF9-B103-2E8916633602.dita#GUID-5F108D03-C8A6-3EF9-B103-2E8916633602/GUID-FFB9A53F-CAD2-3CC7-9FAD-D254E15F83CF"><apiname>CSensrvChannelFinder::SetChannelListenerL()</apiname></xref> function.</cmd> |
|
60 <stepxmp><codeblock xml:space="preserve">ChannelListener channelListener=NULL; |
|
61 finder->SetChannelListenerL(channelListener, searchParameters);</codeblock></stepxmp> |
|
62 </step> |
|
63 </steps> |
|
64 </taskbody></task> |