29
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Declares Bluetooth device inquiry helper class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef ADVANCEDEVDISCOVERERIMPL_H
|
|
19 |
#define ADVANCEDEVDISCOVERERIMPL_H
|
|
20 |
|
|
21 |
#include <btservices/devdiscoveryobserver.h>
|
|
22 |
|
|
23 |
#include <btservices/btsimpleactive.h>
|
|
24 |
#include <btservices/advancedevdiscoverer.h>
|
|
25 |
|
|
26 |
class CBasicDevDiscoverer;
|
|
27 |
class CBtDevRepository;
|
|
28 |
class CBtDevExtension;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* A helper class for searching nearby Bluetooth devices.
|
|
32 |
*/
|
|
33 |
NONSHARABLE_CLASS(CAdvanceDevDiscovererImpl) : public CBase,
|
|
34 |
public MDevDiscoveryObserver,
|
|
35 |
public MBtSimpleActiveObserver
|
|
36 |
{
|
|
37 |
public:
|
|
38 |
/**
|
|
39 |
* instantiator
|
|
40 |
*/
|
|
41 |
static CAdvanceDevDiscovererImpl* NewL(
|
|
42 |
CBtDevRepository& aDevRep,
|
|
43 |
MDevDiscoveryObserver& aObserver );
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Destructor.
|
|
47 |
*/
|
|
48 |
virtual ~CAdvanceDevDiscovererImpl();
|
|
49 |
|
|
50 |
/**
|
|
51 |
* sets the inquiry result observer.
|
|
52 |
*
|
|
53 |
* @param aObserver the new observer to receive inquiry results
|
|
54 |
*/
|
|
55 |
void SetObserver( MDevDiscoveryObserver& aObserver );
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Cancels all inquiry activity.
|
|
59 |
*/
|
|
60 |
void Cancel();
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Discover currently in-range devices that matches the given major device class type.
|
|
64 |
* Found devices will be informed by
|
|
65 |
* MBtAdvanceDevDiscoveryObserver::HandleNextDiscoveryResult().
|
|
66 |
*
|
|
67 |
* When no more device can be found,
|
|
68 |
* MBtAdvanceDevDiscoveryObserver::HandleDiscoveryCompleted() will be issued.
|
|
69 |
*
|
|
70 |
* @param aFilter the filter that shall be applied when a device
|
|
71 |
* is discovered. If this is specified, only a device passing
|
|
72 |
* the filter will be informed to client.
|
|
73 |
*
|
|
74 |
* @param aDeviceClass the major device class which a found device
|
|
75 |
* must match.
|
|
76 |
*/
|
|
77 |
void DiscoverDeviceL(
|
|
78 |
CAdvanceDevDiscoverer::TDevDiscoveryFilter aFilter,
|
|
79 |
TBTMajorDeviceClass aDeviceClass );
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Discover currently in-range devices that match the given major device class.
|
|
83 |
* The devices in the given priority list have higher priority to
|
|
84 |
* be discovered, i.e., inquiry on these devices will take place first.
|
|
85 |
*
|
|
86 |
* Found devices will be informed by
|
|
87 |
* MDevDiscoveryObserver::HandleNextDiscoveryResult().
|
|
88 |
*
|
|
89 |
* When no more device can be found,
|
|
90 |
* MDevDiscoveryObserver::HandleDiscoveryCompleted() will be issued.
|
|
91 |
*
|
|
92 |
* @param aPriorityList contains the devices to be discovered first
|
|
93 |
*/
|
|
94 |
void DiscoverDeviceL(
|
|
95 |
const RBTDevAddrArray& aPriorityList );
|
|
96 |
|
|
97 |
private:
|
|
98 |
|
|
99 |
// from MDevDiscoveryObserver
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Callback to notify that a device has been found.
|
|
103 |
*
|
|
104 |
* @param aAddr the inquiry address that contains the inquiry information
|
|
105 |
* of the found device.
|
|
106 |
* @param aName the Bluetooth device name of the found device
|
|
107 |
*/
|
|
108 |
void HandleNextDiscoveryResultL(
|
|
109 |
const TInquirySockAddr& aAddr, const TDesC& aName );
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Callback to notify that the device search has completed.
|
|
113 |
*
|
|
114 |
* @param aErr the error code of device search result.
|
|
115 |
*/
|
|
116 |
void HandleDiscoveryCompleted( TInt aErr );
|
|
117 |
|
|
118 |
// from MBtSimpleActiveObserver
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Callback to notify that an outstanding request has completed.
|
|
122 |
*
|
|
123 |
* @param aActive Pointer to the active object that completed.
|
|
124 |
* @param aStatus The status of the completed request.
|
|
125 |
*/
|
|
126 |
void RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus );
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Callback for handling cancelation of an outstanding request.
|
|
130 |
*
|
|
131 |
* @param aId The ID that identifies the outstanding request.
|
|
132 |
*/
|
|
133 |
void CancelRequest( TInt aId );
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Callback to notify that an error has occurred in RunL.
|
|
137 |
*
|
|
138 |
* @param aActive Pointer to the active object that completed.
|
|
139 |
* @param aError The error occurred in RunL.
|
|
140 |
*/
|
|
141 |
void HandleError( CBtSimpleActive* aActive, TInt aError );
|
|
142 |
|
|
143 |
private:
|
|
144 |
|
|
145 |
/**
|
|
146 |
* C++ default constructor.
|
|
147 |
*/
|
|
148 |
CAdvanceDevDiscovererImpl(
|
|
149 |
CBtDevRepository& aDevRep,
|
|
150 |
MDevDiscoveryObserver& aObserver );
|
|
151 |
|
|
152 |
/**
|
|
153 |
* The 2nd phase constructor
|
|
154 |
*/
|
|
155 |
void ConstructL();
|
|
156 |
|
|
157 |
private: // Data
|
|
158 |
|
|
159 |
// for retrieving device properties
|
|
160 |
// Not own
|
|
161 |
CBtDevRepository& iDevRep;
|
|
162 |
|
|
163 |
// our client
|
|
164 |
// Not own
|
|
165 |
MDevDiscoveryObserver& iObserver;
|
|
166 |
|
|
167 |
// The class doing actual inquirying
|
|
168 |
CBasicDevDiscoverer* iBasicDiscoverer;
|
|
169 |
|
|
170 |
// filters from CAdvanceDevDiscoverer::TDevDiscoveryFilter
|
|
171 |
TInt iFilter;
|
|
172 |
};
|
|
173 |
|
|
174 |
#endif
|
|
175 |
|
|
176 |
// End of File
|