Symbian3/SDK/Source/GUID-C49F63A4-BA9D-5C99-8C82-EB3163E30D3E.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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 concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-C49F63A4-BA9D-5C99-8C82-EB3163E30D3E"><title>How to prompt the user to select a remote device</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>When there are several suitable remote devices, you can want to prompt the user to pick the one to which a connection should be made. A dialog to do this is supplied. Note that the dialog is not provided by a standard dialog class as this would require a Bluetooth client to have its own UI, and for this to be brought to the foreground. Instead, clients request a background thread called the notifier server to create the dialog: the server can put a dialog over the UI of whatever application happens to have the foreground.</p> <p>To use the dialog:</p> <ol id="GUID-3EAFB634-327F-578B-B739-E1C689999D39"><li id="GUID-E5598C77-5F6D-5D45-84E2-60B2F2463561"><p>Create an <xref href="GUID-A6B66713-FECA-3BE7-BB81-1AE5551AD83D.dita"><apiname>RNotifier</apiname></xref> object, and connect it with <xref href="GUID-A6B66713-FECA-3BE7-BB81-1AE5551AD83D.dita#GUID-A6B66713-FECA-3BE7-BB81-1AE5551AD83D/GUID-C3191BF8-2F6F-36CC-B5CF-92AC58249E09"><apiname>RNotifier::Connect()</apiname></xref> </p> </li> <li id="GUID-9E199C38-33A9-5E49-BF21-6917D2D5110F"><p>Call <xref href="GUID-A6B66713-FECA-3BE7-BB81-1AE5551AD83D.dita#GUID-A6B66713-FECA-3BE7-BB81-1AE5551AD83D/GUID-A5E799C6-E6E4-3C58-A053-F4307179060F"><apiname>RNotifier::StartNotifierAndGetResponse()</apiname></xref> passing in:</p> <ul><li id="GUID-5B591C13-E8EC-53E6-BD26-90345D31C8BC"><p>the UID of the authorisation plug-in (<xref href="GUID-8297F7B3-980E-3E82-B30C-6AF583C8ED02.dita"><apiname>KDeviceSelectionNotifierUid</apiname></xref>)</p> </li> <li id="GUID-87019B90-CC1F-55A9-B447-03C13E86E10E"><p>the device and/or service classes by which to filter suitable remote devices; these are packaged in a <xref href="GUID-6A7B0905-3B9C-367D-AA6C-720C77465206.dita"><apiname>TBTDeviceSelectionParamsPckg</apiname></xref> </p> </li> <li id="GUID-918D02D7-46D5-513E-A31F-8E2C06452EF3"><p>a Bluetooth address object that on completion of the dialog will hold information about the device the user selected in a packaged <xref href="GUID-C6AB3507-A05F-3AC3-9C73-58529D4A106C.dita"><apiname>TBTDeviceResponseParams</apiname></xref>.</p> </li> </ul> </li> <li id="GUID-A2CF8242-B588-5463-8714-D2E59712EAB0"><p>When the <codeph>StartNotifierAndGetResponse()</codeph> calls completes, extract the device information returned from its buffer.</p> </li> <li id="GUID-B1CC149D-7EB7-5B97-9846-3940C544D643"><p>Clean up by cancelling and closing the notifier.</p> </li> </ol> <p><b>Example</b> </p> <codeblock id="GUID-7BF59FB9-4FAC-5CF9-AD47-FB50A4024642" xml:space="preserve">// 1. Create a notifier
RNotifier not;
User::LeaveIfError(not.Connect());

// 2. Start the device selection plug-in
TBTDeviceSelectionParams selectionFilter;
TUUID targetServiceClass(0x2345);
selectionFilter.SetUUID(targetServiceClass);
TBTDeviceSelectionParamsPckg pckg(selectionFilter);
TBTDeviceResponseParams result;
TBTDeviceResponseParamsPckg resultPckg(result);
TRequestStatus status;
not.StartNotifierAndGetResponse(status, KDeviceSelectionNotifierUid, pckg, resultPckg);
User::After(2000000);

// 3. Extract device name if it was returned
User::WaitForRequest(status);
TPtrC name;
if (status.Int() == KErrNone)
    {
    if (resultPckg.IsValidDeviceName())
        {
     name.Set(resultPckg().DeviceName());
        }
    }
    
// 4. Clean up
not.CancelNotifier(KDeviceSelectionNotifierUid);
not.Close();
</codeblock> </conbody></concept>