Symbian3/SDK/Source/GUID-09E44FE5-6BEE-49FF-8BBF-CBB3C066EE10.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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-09E44FE5-6BEE-49FF-8BBF-CBB3C066EE10" xml:lang="en"><title>Listening
for Channel Changes</title><shortdesc>The sensor channel APIs enable you to receive notifications when
a sensor channel is added or removed. This ensures that you are informed of
changes to sensor channels whenever there is a change. For example, you can
receive notifications when a specific proximity sensor channel is added.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<prereq id="GUID-03B31784-B731-43C4-B2DC-38DD4898AE22">       <p>Before listening
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
the sensor channel</xref>.</p>     </prereq>
<steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-10-1-9-1-1-6-1-4-1-4-1-9-1-3-2">
<step id="GUID-B454B117-4FC5-4B19-B512-7B4A213E4C51"><cmd>Create a channel
listener implementation for the <parmname>MSensrvChannelListener</parmname> interface.</cmd>
<stepxmp><codeblock xml:space="preserve">class ChannelListener:public MSensrvChannelListener
    {
    public:    
    void ChannelChangeDetected(const TSensrvChannelInfo &amp;aDetectedChannel, TSensrvChannelChangeType aChangeType)
        {
        ...
         //Implementation
        }
    void ChannelDetectionError(CSensrvChannelFinder aChannelFinder, TSensrvErrorSeverity aError)
        {
        ...
         //Implementation
        }
    void GetChannelListenerInterfaceL(TUid aInterfaceUid, TAny *aInterface)
        {
        ...
         //Implementation
        }
    };</codeblock></stepxmp>
</step>
<step id="GUID-CB0E18F1-21C3-4B51-88C8-ABCBD083304D"><cmd>Start channel listening
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>
<stepxmp><codeblock xml:space="preserve">//Instance of the channel listener implementation
ChannelListener channelListener;
//Channel search parameters
TSensrvChannelInfo &amp;searchParameters
...
CSensrvChannelFinder* finder = CSensrvChannelFinder::NewLC();
...
channel-&gt;SetChannelListenerL(channelListener, searchParameters);
...</codeblock></stepxmp>
<info><p>This listens for channels that meet the supplied search parameters.
When a channel change occurs, a <parmname>ChannelChangeDetected</parmname> notification
is delivered through the <parmname>MSensrvChannelListener</parmname> interface.</p></info>
</step>
<step id="GUID-E9FF2158-0E82-4AB8-A9C0-8FE5A2651FE8"><cmd>Stop channel listening
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>
<stepxmp><codeblock xml:space="preserve">ChannelListener channelListener=NULL;
finder-&gt;SetChannelListenerL(channelListener, searchParameters);</codeblock></stepxmp>
</step>
</steps>
</taskbody></task>