23
|
1 |
/*
|
|
2 |
* Copyright (c) 2009-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: Pairing manager header definition
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef BTENGPAIRMANAGER_H_
|
|
19 |
#define BTENGPAIRMANAGER_H_
|
|
20 |
|
|
21 |
#include <bttypes.h>
|
|
22 |
#include <bt_sock.h>
|
|
23 |
#include <bluetooth/pairing.h>
|
|
24 |
#include "btengactive.h"
|
|
25 |
#include "btengconstants.h"
|
|
26 |
|
|
27 |
class CBTEngPairBase;
|
|
28 |
class CBTEngServer;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* Class CBTEngPairMan
|
|
32 |
*
|
|
33 |
* This class manages pairing with BT devices.
|
|
34 |
* The responsibility of handling incoming and outgoing pairings is
|
|
35 |
* delegated to CBTEngIncPair and CBTEngOtgPair respectively.
|
|
36 |
*
|
|
37 |
* @since S60 S60 v5.1
|
|
38 |
*/
|
|
39 |
NONSHARABLE_CLASS( CBTEngPairMan ) : public CBase, public MBTEngActiveObserver
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Two-phase constructor
|
|
45 |
*/
|
|
46 |
static CBTEngPairMan* NewL( CBTEngServer& aServer );
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Destructor
|
|
50 |
*/
|
|
51 |
~CBTEngPairMan();
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Cancels an outstanding pairing request.
|
|
55 |
*/
|
|
56 |
void CancelOutgoingPair();
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Process commands relevant to pairing
|
|
60 |
*/
|
|
61 |
void ProcessCommandL( const RMessage2& aMessage );
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Handle a change in BTRegistry remote device table.
|
|
65 |
*
|
|
66 |
* @since S60 v5.1
|
|
67 |
*/
|
|
68 |
void RemoteRegistryChangeDetected();
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Gets the instance of pairing server.
|
|
72 |
* @return the server instance. NULL if dedicated bonding is unavailable.
|
|
73 |
*/
|
|
74 |
RBluetoothPairingServer* PairingServer();
|
|
75 |
|
|
76 |
/**
|
|
77 |
* gets the reference of socket server session
|
|
78 |
*/
|
|
79 |
RSocketServ& SocketServ();
|
|
80 |
|
|
81 |
/**
|
|
82 |
* gets the reference of registry session.
|
|
83 |
*/
|
|
84 |
RBTRegServ& BTRegServ();
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Transfer responsiblity to the specified object.
|
|
88 |
* @param aPairer the object to which the responsibility is transfered.
|
|
89 |
*/
|
|
90 |
void RenewPairer( CBTEngPairBase* aPairer );
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Be notified when handling of an outgoing pair has been completed.
|
|
94 |
* @param aErr the result of pairing
|
|
95 |
*
|
|
96 |
*/
|
|
97 |
void OutgoingPairCompleted( TInt aErr );
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Be informed that a session will be closed.
|
|
101 |
*
|
|
102 |
* @since Symbian^3
|
|
103 |
* @param aSession the session to be cloased.
|
|
104 |
*/
|
|
105 |
void SessionClosed(CSession2* aSession );
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Unpair a device via registry
|
|
109 |
*/
|
|
110 |
void UnpairDevice( const TBTDevAddr& aAddr );
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Add the bit indicating the device is user-aware Just worked paired to
|
|
114 |
* UI cookie.
|
|
115 |
*/
|
|
116 |
TInt AddUiCookieJustWorksPaired( const TBTNamelessDevice& aDev );
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Update a nameless device in registry
|
|
120 |
*/
|
|
121 |
TInt UpdateRegDevice( const TBTNamelessDevice& aDev );
|
|
122 |
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Returns the service (limited to services managed in bteng scope)
|
|
126 |
* level connection status of the specified device.
|
|
127 |
*
|
|
128 |
* @param aAddr the address of the device
|
|
129 |
* @return one of TBTEngConnectionStatus enums
|
|
130 |
*/
|
|
131 |
TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr );
|
|
132 |
|
|
133 |
private: // from base class MBTEngActiveObserver
|
|
134 |
|
|
135 |
/**
|
|
136 |
* From MBTEngActiveObserver.
|
|
137 |
* Callback to notify that an outstanding request has completed.
|
|
138 |
*
|
|
139 |
* @since S60 v5.1
|
|
140 |
* @param aActive Pointer to the active object that completed.
|
|
141 |
* @param aId The ID that identifies the outstanding request.
|
|
142 |
* @param aStatus The status of the completed request.
|
|
143 |
*/
|
|
144 |
virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus );
|
|
145 |
|
|
146 |
/**
|
|
147 |
* From MBTEngActiveObserver.
|
|
148 |
* Callback to notify that an error has occurred in RunL.
|
|
149 |
*
|
|
150 |
* @since S60 v5.1
|
|
151 |
* @param aActive Pointer to the active object that completed.
|
|
152 |
* @param aId The ID that identifies the outstanding request.
|
|
153 |
* @param aStatus The status of the completed request.
|
|
154 |
*/
|
|
155 |
virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError );
|
|
156 |
|
|
157 |
private:
|
|
158 |
|
|
159 |
/**
|
|
160 |
* C++ default constructor
|
|
161 |
*/
|
|
162 |
CBTEngPairMan( CBTEngServer& aServer );
|
|
163 |
|
|
164 |
/**
|
|
165 |
* Symbian 2nd-phase constructor
|
|
166 |
*/
|
|
167 |
void ConstructL();
|
|
168 |
|
|
169 |
/**
|
|
170 |
* Initialiases the paired devices list
|
|
171 |
*/
|
|
172 |
void InitPairedDevicesList();
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Initialises the paired devices list (second stage)
|
|
176 |
*/
|
|
177 |
void DoInitPairedDevicesList();
|
|
178 |
|
|
179 |
/**
|
|
180 |
* Activate / deactivate a pair observer
|
|
181 |
*/
|
|
182 |
TInt SetPairObserver(const TBTDevAddr& aAddr, TBool aActivate);
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Pair a BT device.
|
|
186 |
*/
|
|
187 |
void PairDeviceL( const TBTDevAddr& aAddr, TUint32 aCod );
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Cancel all subscribes to pairng server
|
|
191 |
*/
|
|
192 |
void CancelSubscribe();
|
|
193 |
|
|
194 |
/**
|
|
195 |
* subscribe to receive SSP pairing result from pairing server
|
|
196 |
*/
|
|
197 |
void SubscribeSspPairingResult();
|
|
198 |
|
|
199 |
/**
|
|
200 |
* Subscribe to receive authentication result from pairing server
|
|
201 |
*/
|
|
202 |
void SubscribeAuthenticateResult();
|
|
203 |
|
|
204 |
/**
|
|
205 |
* Handle a pairing result from the pairing server.
|
|
206 |
*
|
|
207 |
* @since S60 v5.1
|
|
208 |
* @param aResult The status code of the authentication result.
|
|
209 |
*/
|
|
210 |
void HandlePairingResultL( const TBTDevAddr& aAddr, TInt aResult );
|
|
211 |
|
|
212 |
/**
|
|
213 |
* Creates a registry view which shall contain all paired devices.
|
|
214 |
*/
|
|
215 |
void CreatePairedDevicesView( TInt aReqId );
|
|
216 |
|
|
217 |
/**
|
|
218 |
* retrieves paired devices from registry.
|
|
219 |
*/
|
|
220 |
void GetPairedDevices( TInt aReqId );
|
|
221 |
|
|
222 |
/**
|
|
223 |
* handles the completion of paired device view creation
|
|
224 |
*/
|
|
225 |
void HandleCreatePairedDevicesViewCompletedL( TInt aStatus, TInt aReqId );
|
|
226 |
|
|
227 |
/**
|
|
228 |
* handles the completion of getting paired devices
|
|
229 |
*/
|
|
230 |
void HandleGetPairedDevicesCompletedL( TInt aStatus, TInt aReqId );
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Copy the paired devices to internal array storage.
|
|
234 |
*/
|
|
235 |
void UpdatePairedDeviceListL();
|
|
236 |
|
|
237 |
/**
|
|
238 |
* Checks if any devices have been paired or unpaired. For each new paired device,
|
|
239 |
* the pair event will be delegated to corresponding pair observer if it exists;
|
|
240 |
* otherwise create a new pair observer for this pair event.
|
|
241 |
*/
|
|
242 |
void CheckPairEventL();
|
|
243 |
|
|
244 |
private:
|
|
245 |
|
|
246 |
/**
|
|
247 |
* Owner of this class.
|
|
248 |
* Not owned.
|
|
249 |
*/
|
|
250 |
CBTEngServer& iServer;
|
|
251 |
|
|
252 |
/**
|
|
253 |
* Registry sub session for remote device db
|
|
254 |
*/
|
|
255 |
RBTRegistry iBTRegistry;
|
|
256 |
|
|
257 |
/**
|
|
258 |
* contains the list of all paired devices.
|
|
259 |
* Using heap here to make efficient array swap.
|
|
260 |
*/
|
|
261 |
RArray<TBTNamelessDevice>* iPairedDevices;
|
|
262 |
|
|
263 |
/**
|
|
264 |
* temporary instance to retrieve paired devices.
|
|
265 |
*/
|
|
266 |
CBTRegistryResponse* iPairedDevicesResp;
|
|
267 |
|
|
268 |
/**
|
|
269 |
* the counter of not handled registry events.
|
|
270 |
*/
|
|
271 |
TInt iNotHandledRegEventCounter;
|
|
272 |
|
|
273 |
/**
|
|
274 |
* Session with the pairing server.
|
|
275 |
* Allocate it in heap to ease the handling for
|
|
276 |
* situation of unavailable dedicated pairing service.
|
|
277 |
*
|
|
278 |
* own.
|
|
279 |
*/
|
|
280 |
RBluetoothPairingServer* iPairingServ;
|
|
281 |
|
|
282 |
/**
|
|
283 |
* Subsession with the pairing server for
|
|
284 |
* getting the simple pairing result.
|
|
285 |
* own
|
|
286 |
*/
|
|
287 |
RBluetoothPairingResult iPairingResult;
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Subsession with the pairing server for
|
|
291 |
* getting the authentication result.
|
|
292 |
* own
|
|
293 |
*/
|
|
294 |
RBluetoothAuthenticationResult iAuthenResult;
|
|
295 |
|
|
296 |
/**
|
|
297 |
* the address with which a simple pairing has been performed
|
|
298 |
*/
|
|
299 |
TBTDevAddr iSimplePairingRemote;
|
|
300 |
|
|
301 |
/**
|
|
302 |
* the address with which an authentication has been performed
|
|
303 |
*/
|
|
304 |
TBTDevAddr iAuthenticateRemote;
|
|
305 |
|
|
306 |
/**
|
|
307 |
* Active object helper for receiving simple pairing results.
|
|
308 |
* Own.
|
|
309 |
*/
|
|
310 |
CBTEngActive* iSSPResultActive;
|
|
311 |
|
|
312 |
/**
|
|
313 |
* Active object helper for receiving authentication results.
|
|
314 |
* Own.
|
|
315 |
*/
|
|
316 |
CBTEngActive* iAuthenResultActive;
|
|
317 |
|
|
318 |
/**
|
|
319 |
* AO for registry operations
|
|
320 |
*/
|
|
321 |
CBTEngActive* iRegistryActive;
|
|
322 |
|
|
323 |
/**
|
|
324 |
* pair hanlder at the time.
|
|
325 |
* Own.
|
|
326 |
*/
|
|
327 |
CBTEngPairBase* iPairer;
|
|
328 |
|
|
329 |
/**
|
|
330 |
* Client-server message for power change requests.
|
|
331 |
*/
|
|
332 |
RMessage2 iMessage;
|
|
333 |
|
|
334 |
/**
|
|
335 |
* AO for local address updates.
|
|
336 |
*/
|
|
337 |
CBTEngActive* iLocalAddrActive;
|
|
338 |
|
|
339 |
/**
|
|
340 |
* Provides access to the BT local device address.
|
|
341 |
*/
|
|
342 |
RProperty iPropertyLocalAddr;
|
|
343 |
|
|
344 |
/**
|
|
345 |
* Records whether or not this CBTEngPairMan has ever been involed in a pairing operaton.
|
|
346 |
*/
|
|
347 |
TBool iPairingOperationAttempted;
|
|
348 |
|
|
349 |
/**
|
|
350 |
* Counter of unhandled paired device view initialisation requests.
|
|
351 |
*/
|
|
352 |
TInt iNotHandledInitEventCounter;
|
|
353 |
};
|
|
354 |
|
|
355 |
#endif /*BTENGPAIRMANAGER_H_*/
|