|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef EXCHANGE_H |
|
17 #define EXCHANGE_H |
|
18 |
|
19 #include <bt_sock.h> |
|
20 #include <btsdp.h> |
|
21 |
|
22 class CExchanger : public CBase |
|
23 /** |
|
24 Abstract base class for protocols that can locate compatible devices. |
|
25 @internalComponent |
|
26 */ |
|
27 { |
|
28 public: |
|
29 /** |
|
30 @internalComponent |
|
31 Begins a search for compatible devices. Until successful |
|
32 completion, no other function should be called as the data |
|
33 may be invalid. |
|
34 @param aStatus |
|
35 A TRequestStatus object that is signalled when the search |
|
36 completes. It should be used from within an active object |
|
37 */ |
|
38 virtual void LookForPeersL(TRequestStatus& aStatus) = 0; |
|
39 /** |
|
40 @internalComponent |
|
41 @return The number of compatible peer devices found |
|
42 */ |
|
43 virtual TInt Count() = 0; |
|
44 /** |
|
45 @internalComponent |
|
46 Selects the first compatible device that was found |
|
47 */ |
|
48 virtual void First() = 0; |
|
49 /** |
|
50 @internalComponent |
|
51 Retrieves the selected device, and selects the next device |
|
52 that was found. |
|
53 @param aPtr |
|
54 A reference to a TNameEntry* pointer. On success, it is filled |
|
55 in with a pointer to a device that was found. |
|
56 @return KErrNotFound on failure, KErrNone on success. |
|
57 */ |
|
58 virtual TInt Next(TNameEntry*& aPtr) = 0; |
|
59 protected: |
|
60 RSocketServ iSockSession; |
|
61 private: |
|
62 }; |
|
63 |
|
64 class CBluetoothSeeker; |
|
65 class CBluetoothExchanger : public CExchanger |
|
66 /** |
|
67 @internalComponent |
|
68 Implementation of CExchanger for bluetooth. Uses inquiry and the SDP |
|
69 protocol to retrieve a filtered list of all devices in range that support |
|
70 the service, as defined by UUID |
|
71 */ |
|
72 { |
|
73 public: |
|
74 IMPORT_C static CBluetoothExchanger* NewL(const TUUID &aUUID); |
|
75 IMPORT_C static CBluetoothExchanger* NewLC(const TUUID &aUUID); |
|
76 ~CBluetoothExchanger(); |
|
77 //virtual implementations |
|
78 IMPORT_C virtual void LookForPeersL(TRequestStatus& aStatus); |
|
79 IMPORT_C virtual TInt Count(); |
|
80 IMPORT_C virtual void First(); |
|
81 IMPORT_C virtual TInt Next(TNameEntry*& aPtr); |
|
82 private: |
|
83 void ConstructL(const TUUID &aUUID); |
|
84 RSdp iSdpSession; |
|
85 RSdpDatabase iSdpDb; |
|
86 CBluetoothSeeker *iSeeker; |
|
87 TInt iDeviceIndex; |
|
88 }; |
|
89 |
|
90 #endif //EXCHANGE_H |