42
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "btnotifsecuritymanager.h"
|
|
19 |
#include "btnotifoutgoingpairinghandler.h"
|
|
20 |
#include "btnotifincomingpairinghandler.h"
|
|
21 |
#include "btnotifpairnotifier.h"
|
|
22 |
#include "btnotifclientserver.h"
|
|
23 |
#include <e32property.h>
|
|
24 |
#include "btnotifconnectiontracker.h"
|
|
25 |
#include "btnotifserviceauthorizer.h"
|
|
26 |
|
|
27 |
/** Identification for active object */
|
|
28 |
enum TPairManActiveRequestId
|
|
29 |
{
|
|
30 |
ESimplePairingResult,
|
|
31 |
EAuthenticationResult,
|
|
32 |
ERegistryGetLocalAddress,
|
|
33 |
};
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// Tells if two TBTNamelessDevice instances are for the same remote device
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
TBool CompareDeviceByAddress( const TBTNamelessDevice& aDevA, const TBTNamelessDevice& aDevB )
|
|
40 |
{
|
|
41 |
return aDevA.Address() == aDevB.Address();
|
|
42 |
}
|
|
43 |
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
// Tells if these two instances are for the same remote device
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
TBool MatchDeviceAddress(const TBTDevAddr* aAddr, const TBTNamelessDevice& aDev)
|
|
49 |
{
|
|
50 |
return *aAddr == aDev.Address();
|
|
51 |
}
|
|
52 |
|
|
53 |
// ======== MEMBER FUNCTIONS ========
|
|
54 |
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
// C++ default constructor
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CBTNotifSecurityManager::CBTNotifSecurityManager(
|
|
60 |
CBTNotifConnectionTracker& aParent,
|
|
61 |
CBtDevRepository& aDevRepository)
|
|
62 |
: iParent( aParent ), iDevRepository( aDevRepository )
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// Symbian 2nd-phase constructor
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
void CBTNotifSecurityManager::ConstructL()
|
|
71 |
{
|
57
|
72 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
73 |
// Connect to pairing server for authentication & simple pairing
|
|
74 |
// results directly from the BT stack.
|
|
75 |
// Pairing server doesn't exist if we run BT 2.0 stack:
|
|
76 |
iPairingServ = new (ELeave) RBluetoothPairingServer;
|
|
77 |
TInt err = iPairingServ->Connect();
|
|
78 |
if ( err)
|
|
79 |
{
|
|
80 |
delete iPairingServ;
|
|
81 |
iPairingServ = NULL;
|
|
82 |
}
|
|
83 |
else
|
|
84 |
{
|
|
85 |
User::LeaveIfError( iPairingResult.Open( *iPairingServ ) );
|
|
86 |
User::LeaveIfError( iAuthenResult.Open( *iPairingServ ) );
|
|
87 |
iSSPResultActive = CBtSimpleActive::NewL( *this, ESimplePairingResult );
|
|
88 |
iAuthenResultActive = CBtSimpleActive::NewL( *this, EAuthenticationResult );
|
|
89 |
SubscribeSspPairingResult();
|
|
90 |
SubscribeAuthenticateResult();
|
|
91 |
}
|
|
92 |
User::LeaveIfError( iRegistry.Open( iParent.RegistryServerSession() ) );
|
|
93 |
// RProperty for accessing the local device address
|
|
94 |
User::LeaveIfError( iPropertyLocalAddr.Attach(
|
|
95 |
KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetLocalDeviceAddress) );
|
|
96 |
// Initialise paired devices list
|
|
97 |
iLocalAddrActive = CBtSimpleActive::NewL( *this, ERegistryGetLocalAddress );
|
|
98 |
SubscribeLocalAddress();
|
|
99 |
iPairNotifier = CBTNotifPairNotifier::NewL( *this );
|
|
100 |
iDevRepository.AddObserverL( this );
|
|
101 |
iServiceAuthorizer = CBTNotifServiceAuthorizer::NewL(*this);
|
57
|
102 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
103 |
}
|
|
104 |
|
|
105 |
// ---------------------------------------------------------------------------
|
|
106 |
// NewL
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
CBTNotifSecurityManager* CBTNotifSecurityManager::NewL(
|
|
110 |
CBTNotifConnectionTracker& aParent,
|
|
111 |
CBtDevRepository& aDevRepository )
|
|
112 |
{
|
|
113 |
CBTNotifSecurityManager* self = NULL;
|
|
114 |
self = new CBTNotifSecurityManager( aParent, aDevRepository );
|
|
115 |
CleanupStack::PushL( self );
|
|
116 |
self->ConstructL();
|
|
117 |
CleanupStack::Pop( self );
|
|
118 |
return self;
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
// Destructor
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
CBTNotifSecurityManager::~CBTNotifSecurityManager()
|
|
126 |
{
|
57
|
127 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
128 |
delete iSSPResultActive;
|
|
129 |
delete iAuthenResultActive;
|
|
130 |
delete iPairNotifier;
|
|
131 |
delete iPairingHandler;
|
|
132 |
iPairedDevices.Close();
|
|
133 |
iPairingResult.Close();
|
|
134 |
iAuthenResult.Close();
|
|
135 |
if ( iPairingServ )
|
|
136 |
{
|
|
137 |
iPairingServ->Close();
|
|
138 |
delete iPairingServ;
|
|
139 |
}
|
|
140 |
iRegistry.Close();
|
|
141 |
delete iLocalAddrActive;
|
|
142 |
iPropertyLocalAddr.Close();
|
|
143 |
if ( !iMessage.IsNull() )
|
|
144 |
{
|
|
145 |
iMessage.Complete( KErrCancel );
|
|
146 |
}
|
|
147 |
delete iServiceAuthorizer;
|
57
|
148 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
149 |
}
|
|
150 |
|
|
151 |
// ---------------------------------------------------------------------------
|
|
152 |
// Initialises the paired devices list.
|
|
153 |
// If the local address is not available from the P&S key
|
|
154 |
// KPropertyKeyBluetoothGetLocalDeviceAddress, then the list may need to be
|
|
155 |
// updated once the H/W is switched on. This is so that any registry update
|
|
156 |
// from a restore operation can be included in the list, without mistaking the
|
|
157 |
// new devices for new pairings.
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
//
|
|
160 |
void CBTNotifSecurityManager::SubscribeLocalAddress()
|
|
161 |
{
|
57
|
162 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
163 |
// Check that we have the Bluetooth local address. If we don't then initialise anyway, but subscribe for an update.
|
|
164 |
// This allows us to refresh our paired devices list to include updates made to the remote devices table of the
|
|
165 |
// Bluetooth registry from a restore operation. We need to include these devices without mistaking them for new
|
|
166 |
// pairings. We look solely at the P&S key for the address to avoid the condition whereby the address has been
|
|
167 |
// entered into the reigstry but the Bluetooth Manager server has not begun the restore process yet. The signalling
|
|
168 |
// of the P&S key will cause Bluetooth Manager to update the registry with any restored devices before fulfilling
|
|
169 |
// any further requests.
|
|
170 |
|
|
171 |
// Subscribe to local address property in case we need an update.
|
|
172 |
iPropertyLocalAddr.Subscribe( iLocalAddrActive->iStatus );
|
|
173 |
iLocalAddrActive->SetRequestId( ERegistryGetLocalAddress );
|
|
174 |
iLocalAddrActive->GoActive();
|
57
|
175 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
176 |
}
|
|
177 |
|
|
178 |
// ---------------------------------------------------------------------------
|
|
179 |
// Tells whether the local address is available from the P&S key
|
|
180 |
// KPropertyKeyBluetoothGetLocalDeviceAddress.
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
TBool CBTNotifSecurityManager::IsLocalAddressAvailable()
|
|
184 |
{
|
|
185 |
// Attempt to read address from P&S key.
|
|
186 |
TBuf8<KBTDevAddrSize> btAddrDes;
|
|
187 |
TInt err = iPropertyLocalAddr.Get( btAddrDes );
|
|
188 |
|
|
189 |
// Is the P&S key defined yet? (if not, stack not up yet)
|
|
190 |
if ( err == KErrNone )
|
|
191 |
{
|
|
192 |
// P&S key defined, is local address set? (if not, H/W not initialised yet)
|
|
193 |
if ( btAddrDes.Length() == KBTDevAddrSize )
|
|
194 |
{
|
|
195 |
TBTDevAddr btAddr = btAddrDes;
|
|
196 |
if ( btAddr != TBTDevAddr() )
|
|
197 |
{
|
|
198 |
return ETrue;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
}
|
|
202 |
return EFalse;
|
|
203 |
}
|
|
204 |
|
|
205 |
// ---------------------------------------------------------------------------
|
|
206 |
// Handles pairing related requests from BTNotif clients.
|
|
207 |
// ---------------------------------------------------------------------------
|
|
208 |
//
|
|
209 |
void CBTNotifSecurityManager::HandleBondingRequestL( const RMessage2& aMessage )
|
|
210 |
{
|
57
|
211 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
212 |
TInt opcode = aMessage.Function();
|
|
213 |
switch( opcode )
|
|
214 |
{
|
|
215 |
case EBTNotifPairDevice:
|
|
216 |
{
|
|
217 |
if ( !iMessage.IsNull() )
|
|
218 |
{
|
|
219 |
User::Leave( KErrServerBusy );
|
|
220 |
}
|
|
221 |
TBTDevAddrPckgBuf addrPkg;
|
|
222 |
aMessage.ReadL( EBTNotifSrvParamSlot, addrPkg );
|
|
223 |
BlockDevice(addrPkg(),EFalse);
|
|
224 |
UnpairDevice( addrPkg() );
|
|
225 |
PairDeviceL( addrPkg(), aMessage.Int2() );
|
|
226 |
iMessage = RMessage2( aMessage );
|
|
227 |
break;
|
|
228 |
}
|
|
229 |
case EBTNotifCancelPairDevice:
|
|
230 |
{
|
|
231 |
// Only the client who requested pairing can cancel it:
|
|
232 |
if ( !iMessage.IsNull() && aMessage.Session() == iMessage.Session() )
|
|
233 |
{
|
|
234 |
iPairingHandler->CancelOutgoingPair();
|
|
235 |
iMessage.Complete( KErrCancel );
|
|
236 |
}
|
|
237 |
aMessage.Complete( KErrNone );
|
|
238 |
break;
|
|
239 |
}
|
|
240 |
default:
|
|
241 |
{
|
|
242 |
User::Leave( KErrArgument );
|
|
243 |
}
|
|
244 |
}
|
57
|
245 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
246 |
}
|
|
247 |
|
|
248 |
// ---------------------------------------------------------------------------
|
|
249 |
// Process a client message related to notifiers.
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
//
|
|
252 |
void CBTNotifSecurityManager::HandleNotifierRequestL( const RMessage2& aMessage )
|
|
253 |
{
|
57
|
254 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
255 |
if(aMessage.Int0() == KBTManAuthNotifierUid.iUid)
|
|
256 |
{
|
|
257 |
iServiceAuthorizer->StartNotifierL( aMessage );
|
|
258 |
}
|
|
259 |
else
|
|
260 |
{
|
|
261 |
iPairNotifier->StartPairingNotifierL( aMessage );
|
|
262 |
}
|
|
263 |
|
|
264 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
|
265 |
}
|
|
266 |
|
|
267 |
// ---------------------------------------------------------------------------
|
|
268 |
// Returns the RBluetoothPairingServer instance.
|
|
269 |
// ---------------------------------------------------------------------------
|
|
270 |
//
|
|
271 |
RBluetoothPairingServer* CBTNotifSecurityManager::PairingServer()
|
|
272 |
{
|
|
273 |
return iPairingServ;
|
|
274 |
}
|
|
275 |
|
|
276 |
// ---------------------------------------------------------------------------
|
|
277 |
// Access the reference of RSockServ
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
RSocketServ& CBTNotifSecurityManager::SocketServ()
|
|
281 |
{
|
|
282 |
return iParent.SocketServerSession();
|
|
283 |
}
|
|
284 |
|
|
285 |
// ---------------------------------------------------------------------------
|
|
286 |
// Access the reference of RBTRegSrv
|
|
287 |
// ---------------------------------------------------------------------------
|
|
288 |
//
|
|
289 |
CBtDevRepository& CBTNotifSecurityManager::BTDevRepository()
|
|
290 |
{
|
|
291 |
return iDevRepository;
|
|
292 |
}
|
|
293 |
|
|
294 |
// ---------------------------------------------------------------------------
|
|
295 |
// Access the reference of CBTNotifConnectionTracker
|
|
296 |
// ---------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
CBTNotifConnectionTracker& CBTNotifSecurityManager::ConnectionTracker()
|
|
299 |
{
|
|
300 |
return iParent;
|
|
301 |
}
|
|
302 |
|
|
303 |
// ---------------------------------------------------------------------------
|
|
304 |
// Deletes the current pairing handler and transfer the responsibility
|
|
305 |
// to the specified.
|
|
306 |
// ---------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
void CBTNotifSecurityManager::RenewPairingHandler(
|
|
309 |
CBTNotifBasePairingHandler* aPairingHandler )
|
|
310 |
{
|
57
|
311 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
312 |
delete iPairingHandler;
|
|
313 |
iPairingHandler = aPairingHandler;
|
57
|
314 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
315 |
}
|
|
316 |
|
|
317 |
// ---------------------------------------------------------------------------
|
|
318 |
// Find the session who requested this and completes its request.
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
void CBTNotifSecurityManager::OutgoingPairCompleted( TInt aErr )
|
|
322 |
{
|
57
|
323 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
324 |
// the meaning of KHCIErrorBase equals KErrNone. Hide this specific BT stack
|
|
325 |
// detail from clients:
|
|
326 |
if ( !iMessage.IsNull() )
|
|
327 |
{
|
|
328 |
iMessage.Complete( (aErr == KHCIErrorBase) ? KErrNone : aErr );
|
|
329 |
}
|
57
|
330 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
331 |
}
|
|
332 |
|
|
333 |
// ---------------------------------------------------------------------------
|
|
334 |
// A session will be ended, completes the pending request for this session.
|
|
335 |
// ---------------------------------------------------------------------------
|
|
336 |
//
|
|
337 |
void CBTNotifSecurityManager::SessionClosed( CSession2* aSession )
|
|
338 |
{
|
57
|
339 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
340 |
BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST," session %x", aSession);
|
|
341 |
if ( !iMessage.IsNull() && iMessage.Session() == aSession )
|
|
342 |
{
|
|
343 |
iMessage.Complete( KErrCancel );
|
|
344 |
}
|
57
|
345 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
346 |
}
|
|
347 |
|
|
348 |
// ---------------------------------------------------------------------------
|
|
349 |
// Unpair the device from registry
|
|
350 |
// ---------------------------------------------------------------------------
|
|
351 |
//
|
|
352 |
void CBTNotifSecurityManager::UnpairDevice( const TBTDevAddr& aAddr )
|
|
353 |
{
|
57
|
354 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
355 |
TIdentityRelation<TBTNamelessDevice> addrComp( CompareDeviceByAddress );
|
|
356 |
TBTNamelessDevice dev;
|
|
357 |
dev.SetAddress( aAddr );
|
|
358 |
// only do unpairing if the we have a link key with it.
|
|
359 |
TInt index = iPairedDevices.Find( dev, addrComp );
|
|
360 |
if ( index > KErrNotFound )
|
|
361 |
{
|
|
362 |
dev = iPairedDevices[index];
|
|
363 |
TRequestStatus status( KRequestPending );
|
|
364 |
// Unpair the device in registry (synchronously)
|
|
365 |
iRegistry.UnpairDevice( dev.Address(), status );
|
|
366 |
User::WaitForRequest( status );
|
|
367 |
BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"Delete link key, res %d", status.Int());
|
|
368 |
if ( status == KErrNone )
|
|
369 |
{
|
|
370 |
TBTDeviceSecurity security = dev.GlobalSecurity();
|
|
371 |
// Clear trust setting so that correct icon will be shown in ui applications.
|
|
372 |
security.SetNoAuthenticate(EFalse );
|
|
373 |
security.SetNoAuthorise(EFalse );
|
|
374 |
dev.SetGlobalSecurity(security);
|
|
375 |
dev.DeleteLinkKey();
|
|
376 |
if ( dev.IsValidUiCookie() &&
|
|
377 |
( dev.UiCookie() & EBTUiCookieJustWorksPaired ) )
|
|
378 |
{
|
|
379 |
// Remove the UI cookie bit for Just Works pairing.
|
|
380 |
TInt32 cookie = dev.UiCookie() & ~EBTUiCookieJustWorksPaired;
|
|
381 |
dev.SetUiCookie( cookie );
|
|
382 |
BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"UI cookie %x cleared", EBTUiCookieJustWorksPaired );
|
|
383 |
}
|
|
384 |
// modify the device in registry synchronously
|
|
385 |
// status.Int() could be -1 if the device is not in registry
|
|
386 |
// which is totally fine for us.
|
|
387 |
(void) UpdateRegDevice( dev );
|
|
388 |
}
|
|
389 |
}
|
57
|
390 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
391 |
}
|
|
392 |
|
|
393 |
void CBTNotifSecurityManager::BlockDevice( const TBTDevAddr& aAddr , TBool aBanned)
|
|
394 |
{
|
57
|
395 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
396 |
TIdentityRelation<TBTNamelessDevice> addrComp( CompareDeviceByAddress );
|
|
397 |
TBTNamelessDevice dev;
|
|
398 |
dev.SetAddress( aAddr );
|
|
399 |
TRequestStatus status( KRequestPending );
|
|
400 |
// Unpair the device in registry (synchronously)
|
|
401 |
iRegistry.GetDevice(dev,status);
|
|
402 |
User::WaitForRequest( status );
|
|
403 |
if(status == KErrNone)
|
|
404 |
{
|
|
405 |
TBTDeviceSecurity security = dev.GlobalSecurity();
|
|
406 |
security.SetBanned(aBanned);
|
|
407 |
if ( aBanned )
|
|
408 |
{
|
|
409 |
security.SetNoAuthorise(EFalse);
|
|
410 |
}
|
|
411 |
dev.SetGlobalSecurity(security);
|
|
412 |
(void)UpdateRegDevice(dev);
|
|
413 |
}
|
57
|
414 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
415 |
}
|
|
416 |
|
|
417 |
TInt CBTNotifSecurityManager::AddUiCookieJustWorksPaired( const TBTNamelessDevice& aDev )
|
|
418 |
{
|
57
|
419 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
420 |
TInt err( KErrNone );
|
|
421 |
// There might be UI cookies used by other applications,
|
|
422 |
// we should not overwrite them.
|
|
423 |
TInt32 cookie = aDev.IsValidUiCookie() ? aDev.UiCookie() : EBTUiCookieUndefined;
|
|
424 |
if ( !( cookie & EBTUiCookieJustWorksPaired ) )
|
|
425 |
{
|
|
426 |
// Only update the cookie if the wanted one is not in registry yet
|
|
427 |
// to keep minimal operations with registry.
|
|
428 |
TBTNamelessDevice dev = aDev;
|
|
429 |
cookie |= EBTUiCookieJustWorksPaired;
|
|
430 |
dev.SetUiCookie( cookie );
|
|
431 |
err = UpdateRegDevice( dev );
|
|
432 |
BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"Outgoing Pairing write Ui cookie ret %d", err );
|
|
433 |
}
|
57
|
434 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
435 |
return err;
|
|
436 |
}
|
|
437 |
|
|
438 |
// ---------------------------------------------------------------------------
|
|
439 |
// update a nameless device in registry
|
|
440 |
// ---------------------------------------------------------------------------
|
|
441 |
//
|
|
442 |
TInt CBTNotifSecurityManager::UpdateRegDevice( const TBTNamelessDevice& aDev )
|
|
443 |
{
|
57
|
444 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
445 |
TRequestStatus status( KRequestPending );
|
|
446 |
// update the device in registry synchronously
|
|
447 |
iRegistry.ModifyDevice( aDev, status );
|
|
448 |
User::WaitForRequest( status );
|
|
449 |
BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"UpdateRegDevice, ret %d", status.Int());
|
57
|
450 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
451 |
return status.Int();
|
|
452 |
}
|
|
453 |
|
|
454 |
// ---------------------------------------------------------------------------
|
|
455 |
// 0000 for outgoing pairing with a headset.
|
|
456 |
// The placeholder for future extension (pin code passed in for pairing)
|
|
457 |
// ---------------------------------------------------------------------------
|
|
458 |
//
|
|
459 |
void CBTNotifSecurityManager::GetPinCode(
|
|
460 |
TBTPinCode& aPin, const TBTDevAddr& aAddr, TInt aMinPinLength )
|
|
461 |
{
|
57
|
462 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
463 |
if ( iPairingHandler )
|
|
464 |
{
|
|
465 |
iPairingHandler->GetPinCode( aPin, aAddr, aMinPinLength );
|
|
466 |
}
|
|
467 |
else
|
|
468 |
{
|
|
469 |
// make sure not to leave any text as PIN.
|
|
470 |
aPin.Zero();
|
47
|
471 |
aPin().iLength = 0;
|
42
|
472 |
}
|
57
|
473 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
474 |
}
|
|
475 |
|
|
476 |
// ---------------------------------------------------------------------------
|
|
477 |
// Ask server class the connection status of the specified device
|
|
478 |
// ---------------------------------------------------------------------------
|
|
479 |
//
|
|
480 |
TBTEngConnectionStatus CBTNotifSecurityManager::ConnectStatus( const TBTDevAddr& aAddr )
|
|
481 |
{
|
57
|
482 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
483 |
const CBtDevExtension* devExt = iDevRepository.Device(aAddr);
|
|
484 |
TBTEngConnectionStatus status = EBTEngNotConnected;
|
|
485 |
if ( devExt )
|
|
486 |
{
|
|
487 |
status = devExt->ServiceConnectionStatus();
|
|
488 |
}
|
57
|
489 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
490 |
return status;
|
|
491 |
}
|
|
492 |
|
|
493 |
// ---------------------------------------------------------------------------
|
|
494 |
// From class MBTNotifPairingAOObserver.
|
|
495 |
// Checks if there is an authentication result.
|
|
496 |
// ---------------------------------------------------------------------------
|
|
497 |
//
|
|
498 |
void CBTNotifSecurityManager::RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus )
|
|
499 |
{
|
57
|
500 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
501 |
BOstraceExt2(TRACE_DEBUG,DUMMY_DEVLIST,"aId: %d, aStatus: %d", aActive->RequestId(), aStatus);
|
|
502 |
// Check which request is completed.
|
|
503 |
switch( aActive->RequestId() )
|
|
504 |
{
|
|
505 |
case ESimplePairingResult:
|
|
506 |
{
|
|
507 |
TBTDevAddr tmpAddr = iSimplePairingRemote;
|
|
508 |
if (aStatus != KErrServerTerminated)
|
|
509 |
{
|
|
510 |
SubscribeSspPairingResult();
|
|
511 |
}
|
|
512 |
HandlePairingResultL( tmpAddr, aStatus );
|
|
513 |
break;
|
|
514 |
}
|
|
515 |
case EAuthenticationResult:
|
|
516 |
{
|
|
517 |
TBTDevAddr tmpAddr = iAuthenticateRemote;
|
|
518 |
if (aStatus != KErrServerTerminated)
|
|
519 |
{
|
|
520 |
SubscribeAuthenticateResult();
|
|
521 |
}
|
|
522 |
HandlePairingResultL( tmpAddr, aStatus );
|
|
523 |
break;
|
|
524 |
}
|
|
525 |
case ERegistryGetLocalAddress:
|
|
526 |
{
|
|
527 |
TBool value = IsLocalAddressAvailable();
|
|
528 |
SubscribeLocalAddress();
|
|
529 |
if ( value )
|
|
530 |
{
|
|
531 |
// Refresh paired devices list to include any restored devices.
|
|
532 |
iDevRepository.ReInitialize();
|
|
533 |
}
|
|
534 |
break;
|
|
535 |
}
|
|
536 |
default:
|
|
537 |
// Should not be possible, but no need for handling.
|
|
538 |
break;
|
|
539 |
}
|
57
|
540 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
541 |
}
|
|
542 |
|
|
543 |
// ---------------------------------------------------------------------------
|
|
544 |
// From class MBTEngActiveObserver.
|
|
545 |
// cancels an outstanding request according to the given id.
|
|
546 |
// ---------------------------------------------------------------------------
|
|
547 |
//
|
|
548 |
void CBTNotifSecurityManager::CancelRequest( TInt aRequestId )
|
|
549 |
{
|
57
|
550 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
551 |
switch ( aRequestId )
|
|
552 |
{
|
|
553 |
case ESimplePairingResult:
|
|
554 |
{
|
|
555 |
// Cancel listening Simple pairing result
|
|
556 |
iPairingResult.CancelSimplePairingResult();
|
|
557 |
break;
|
|
558 |
}
|
|
559 |
case EAuthenticationResult:
|
|
560 |
{
|
|
561 |
// Cancel listening authentication result
|
|
562 |
iAuthenResult.CancelAuthenticationResult();
|
|
563 |
break;
|
|
564 |
}
|
|
565 |
case ERegistryGetLocalAddress:
|
|
566 |
{
|
|
567 |
// cancel listening local address status change
|
|
568 |
iPropertyLocalAddr.Cancel();
|
|
569 |
break;
|
|
570 |
}
|
|
571 |
}
|
57
|
572 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
573 |
}
|
|
574 |
|
|
575 |
// ---------------------------------------------------------------------------
|
|
576 |
// From class MBtSimpleActiveObserver.
|
|
577 |
// ---------------------------------------------------------------------------
|
|
578 |
//
|
|
579 |
void CBTNotifSecurityManager::HandleError( CBtSimpleActive* aActive, TInt aError )
|
|
580 |
{
|
57
|
581 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
582 |
BOstraceExt2(TRACE_DEBUG,DUMMY_DEVLIST,"request id: %d, error: %d", aActive->RequestId(), aError);
|
|
583 |
(void) aActive;
|
|
584 |
(void) aError;
|
57
|
585 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
586 |
}
|
|
587 |
|
|
588 |
// ---------------------------------------------------------------------------
|
|
589 |
// From class MBtDevRepositoryObserver.
|
|
590 |
// ---------------------------------------------------------------------------
|
|
591 |
//
|
|
592 |
void CBTNotifSecurityManager::RepositoryInitialized()
|
|
593 |
{
|
57
|
594 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
595 |
TRAPD(err, UpdatePairedDeviceListL() );
|
|
596 |
if ( !err && iPairingHandler )
|
|
597 |
{
|
|
598 |
// non-null pairing handler means we are involved in a
|
|
599 |
// pairing operation already.
|
|
600 |
// todo: is some handling for above case needed?
|
|
601 |
}
|
57
|
602 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
603 |
}
|
|
604 |
|
|
605 |
// ---------------------------------------------------------------------------
|
|
606 |
// From class MBtDevRepositoryObserver.
|
|
607 |
// ---------------------------------------------------------------------------
|
|
608 |
//
|
|
609 |
void CBTNotifSecurityManager::DeletedFromRegistry( const TBTDevAddr& aAddr )
|
|
610 |
{
|
57
|
611 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
612 |
// We are only interested in the removal of a paired device.
|
|
613 |
// thus check whether it is in our local paired list:
|
|
614 |
TInt i = iPairedDevices.Find( aAddr, MatchDeviceAddress);
|
|
615 |
if ( i > KErrNotFound )
|
|
616 |
{
|
|
617 |
iPairedDevices.Remove( i );
|
|
618 |
}
|
57
|
619 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
620 |
}
|
|
621 |
|
|
622 |
// ---------------------------------------------------------------------------
|
|
623 |
// From class MBtDevRepositoryObserver.
|
|
624 |
// ---------------------------------------------------------------------------
|
|
625 |
//
|
|
626 |
void CBTNotifSecurityManager::AddedToRegistry( const CBtDevExtension& aDevice )
|
|
627 |
{
|
57
|
628 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
629 |
// We are only interested in paired device.
|
|
630 |
if ( CBtDevExtension::IsBonded( aDevice.Device().AsNamelessDevice() ) )
|
|
631 |
{
|
|
632 |
TRAP_IGNORE(
|
|
633 |
HandleRegistryBondingL( aDevice.Device().AsNamelessDevice() ) );
|
|
634 |
}
|
57
|
635 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
636 |
}
|
|
637 |
|
|
638 |
|
|
639 |
// ---------------------------------------------------------------------------
|
|
640 |
// From class MBtDevRepositoryObserver.
|
|
641 |
// ---------------------------------------------------------------------------
|
|
642 |
//
|
|
643 |
void CBTNotifSecurityManager::ChangedInRegistry(
|
|
644 |
const CBtDevExtension& aDevice, TUint aSimilarity )
|
|
645 |
{
|
57
|
646 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
647 |
// We are only interested in paired device.
|
|
648 |
// thus check whether it is in our local paired list:
|
|
649 |
TInt i = iPairedDevices.Find( aDevice.Addr(), MatchDeviceAddress);
|
|
650 |
TBool bonded = CBtDevExtension::IsBonded( aDevice.Device().AsNamelessDevice() );
|
|
651 |
if ( i == KErrNotFound )
|
|
652 |
{
|
57
|
653 |
BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,"Not found");
|
42
|
654 |
if ( bonded )
|
|
655 |
{
|
57
|
656 |
BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,"Not found but bonded");
|
42
|
657 |
TRAP_IGNORE(
|
|
658 |
HandleRegistryBondingL(
|
|
659 |
aDevice.Device().AsNamelessDevice() ) );
|
|
660 |
}
|
57
|
661 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
662 |
return;
|
|
663 |
}
|
|
664 |
// Device was inregistry before, but we need to evaluate its bonding
|
|
665 |
// status.
|
|
666 |
// The given similarity will tell if the linkkey and paired is changed
|
|
667 |
// or not.
|
|
668 |
TInt pairingProperty = TBTNamelessDevice::EIsPaired
|
|
669 |
| TBTNamelessDevice::ELinkKey;
|
|
670 |
if ( ( pairingProperty & aSimilarity) == pairingProperty )
|
|
671 |
{
|
|
672 |
// no pairing or linkkey change. Nothing to do for pairing handling.
|
|
673 |
// but we'd better update local copy just in case other data
|
|
674 |
// of this device is needed by someone:
|
57
|
675 |
BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,"No pairing or link key change");
|
42
|
676 |
iPairedDevices[i] = aDevice.Device().AsNamelessDevice();
|
57
|
677 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
678 |
return;
|
|
679 |
}
|
57
|
680 |
if ( !bonded )
|
42
|
681 |
{
|
|
682 |
// device is not user-bonded.
|
57
|
683 |
UnTrustDevice(iPairedDevices[i].Address());
|
42
|
684 |
iPairedDevices.Remove( i );
|
57
|
685 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
686 |
return;
|
|
687 |
}
|
|
688 |
// it is a new paired device if its link-key has been upgraded
|
|
689 |
if ( aDevice.Device().LinkKeyType() != ELinkKeyUnauthenticatedUpgradable )
|
|
690 |
{
|
|
691 |
iPairedDevices.Remove( i );
|
|
692 |
TRAP_IGNORE(
|
|
693 |
HandleRegistryBondingL(
|
|
694 |
aDevice.Device().AsNamelessDevice() ) );
|
|
695 |
}
|
57
|
696 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
697 |
}
|
|
698 |
|
|
699 |
// ---------------------------------------------------------------------------
|
|
700 |
// From class MBtDevRepositoryObserver.
|
|
701 |
// This class is not interested in such events.
|
|
702 |
// ---------------------------------------------------------------------------
|
|
703 |
//
|
|
704 |
void CBTNotifSecurityManager::ServiceConnectionChanged(
|
|
705 |
const CBtDevExtension& aDevice, TBool aConnected )
|
|
706 |
{
|
57
|
707 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
708 |
(void) aDevice;
|
|
709 |
(void) aConnected;
|
57
|
710 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
711 |
}
|
|
712 |
|
|
713 |
// ---------------------------------------------------------------------------
|
|
714 |
// Activate or deactivate a pairing handler
|
|
715 |
// ---------------------------------------------------------------------------
|
|
716 |
//
|
|
717 |
TInt CBTNotifSecurityManager::SetPairObserver(const TBTDevAddr& aAddr, TBool aActivate)
|
|
718 |
{
|
57
|
719 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
720 |
BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"%d", aActivate);
|
|
721 |
BtTraceBtAddr0(TRACE_DEBUG,DUMMY_DEVLIST, aAddr );
|
|
722 |
TInt err( KErrNone );
|
|
723 |
if ( !aActivate )
|
|
724 |
{
|
|
725 |
if ( iPairingHandler )
|
|
726 |
{
|
|
727 |
iPairingHandler->StopPairHandling( aAddr );
|
|
728 |
}
|
57
|
729 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
730 |
return err;
|
|
731 |
}
|
|
732 |
|
|
733 |
if ( !iPairingHandler)
|
|
734 |
{
|
|
735 |
// This is an incoming pair, unpair it from registry and
|
|
736 |
// create the handler:
|
|
737 |
UnpairDevice( aAddr );
|
|
738 |
TRAP( err, iPairingHandler = CBTNotifIncomingPairingHandler::NewL( *this, aAddr ));
|
|
739 |
}
|
|
740 |
if ( iPairingHandler)
|
|
741 |
{
|
|
742 |
// let the handler decide what to do:
|
|
743 |
err = iPairingHandler->ObserveIncomingPair( aAddr );
|
|
744 |
}
|
57
|
745 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
746 |
return err;
|
|
747 |
}
|
|
748 |
|
|
749 |
// ---------------------------------------------------------------------------
|
|
750 |
// Delegates the request to current pair handler
|
|
751 |
// ---------------------------------------------------------------------------
|
|
752 |
//
|
|
753 |
void CBTNotifSecurityManager::PairDeviceL( const TBTDevAddr& aAddr, TUint32 aCod )
|
|
754 |
{
|
57
|
755 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
756 |
if ( !iPairingHandler)
|
|
757 |
{
|
|
758 |
// no existing pair handling, create one:
|
|
759 |
iPairingHandler = CBTNotifOutgoingPairingHandler::NewL( *this, aAddr );
|
|
760 |
}
|
|
761 |
// let pair handler decide what to do:
|
|
762 |
iPairingHandler->HandleOutgoingPairL( aAddr, aCod );
|
57
|
763 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
764 |
}
|
|
765 |
|
|
766 |
// ---------------------------------------------------------------------------
|
|
767 |
// cancel Subscribings to simple pairing result and authentication result from
|
|
768 |
// Pairing Server
|
|
769 |
// ---------------------------------------------------------------------------
|
|
770 |
//
|
|
771 |
void CBTNotifSecurityManager::CancelSubscribePairingAuthenticate()
|
|
772 |
{
|
57
|
773 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
774 |
if( iSSPResultActive )
|
|
775 |
{
|
|
776 |
// Cancel listening Simple pairing result
|
|
777 |
iSSPResultActive->Cancel();
|
|
778 |
}
|
|
779 |
if( iAuthenResultActive )
|
|
780 |
{
|
|
781 |
iAuthenResultActive->Cancel();
|
|
782 |
}
|
57
|
783 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
784 |
}
|
|
785 |
|
|
786 |
// ---------------------------------------------------------------------------
|
|
787 |
// Subscribes to simple pairing result from Pairing Server (if not already
|
|
788 |
// subscribed).
|
|
789 |
// ---------------------------------------------------------------------------
|
|
790 |
//
|
|
791 |
void CBTNotifSecurityManager::SubscribeSspPairingResult()
|
|
792 |
{
|
57
|
793 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
794 |
if ( !iSSPResultActive->IsActive() )
|
|
795 |
{
|
|
796 |
iPairingResult.SimplePairingResult( iSimplePairingRemote, iSSPResultActive->RequestStatus() );
|
|
797 |
iSSPResultActive->GoActive();
|
|
798 |
}
|
57
|
799 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
800 |
}
|
|
801 |
|
|
802 |
// ---------------------------------------------------------------------------
|
|
803 |
// Subscribes to authentication result from Pairing Server (if not already
|
|
804 |
// subscribed).
|
|
805 |
// ---------------------------------------------------------------------------
|
|
806 |
//
|
|
807 |
void CBTNotifSecurityManager::SubscribeAuthenticateResult()
|
|
808 |
{
|
57
|
809 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
810 |
if ( !iAuthenResultActive->IsActive() )
|
|
811 |
{
|
|
812 |
// Subscribe authentication result (which requires pairing for unpaired devices)
|
|
813 |
iAuthenResult.AuthenticationResult( iAuthenticateRemote, iAuthenResultActive->RequestStatus() );
|
|
814 |
iAuthenResultActive->GoActive();
|
|
815 |
}
|
57
|
816 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
817 |
}
|
|
818 |
|
|
819 |
// ---------------------------------------------------------------------------
|
|
820 |
// Handle a pairing result from the pairing server.
|
|
821 |
// ---------------------------------------------------------------------------
|
|
822 |
//
|
|
823 |
void CBTNotifSecurityManager::HandlePairingResultL( const TBTDevAddr& aAddr, TInt aResult )
|
|
824 |
{
|
57
|
825 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
826 |
BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"result %d", aResult);
|
|
827 |
BtTraceBtAddr0(TRACE_DEBUG,DUMMY_DEVLIST, aAddr );
|
|
828 |
|
|
829 |
if ( !iPairingHandler && ( aResult == KErrNone || aResult == KHCIErrorBase ) )
|
|
830 |
{
|
|
831 |
// we only create new handler if incoming pairing succeeds.
|
|
832 |
// Pairing failure could be caused by user local cancellation, as the
|
|
833 |
// result, the handler was destroyed by notifier. We shall not
|
|
834 |
// instantiate the handler again.
|
|
835 |
// If a pairing failed due to other reasons than user local cancelling,
|
|
836 |
// it will be catched by the already started handler
|
|
837 |
// (except Just Works pairing - no handler for it at all until we receive
|
|
838 |
// registry change event. Thus if incoming JWs pairing failed, no user
|
|
839 |
// notification will be shown.)
|
|
840 |
iPairedDevices.Find( aAddr, MatchDeviceAddress);
|
|
841 |
TInt index = iPairedDevices.Find( aAddr, MatchDeviceAddress);
|
|
842 |
// If the device is not found in the old paired device list, it is a new
|
|
843 |
// paired device:
|
|
844 |
if ( index == KErrNotFound)
|
|
845 |
{
|
|
846 |
// No handler yet, create incoming pairing handler:
|
|
847 |
iPairingHandler = CBTNotifIncomingPairingHandler::NewL( *this, aAddr );
|
|
848 |
}
|
|
849 |
}
|
57
|
850 |
|
42
|
851 |
if ( iPairingHandler )
|
|
852 |
{
|
|
853 |
iPairingHandler->HandlePairServerResult( aAddr, aResult );
|
|
854 |
}
|
57
|
855 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
856 |
}
|
|
857 |
|
|
858 |
// ---------------------------------------------------------------------------
|
|
859 |
// copy the nameless devices to local array
|
|
860 |
// ---------------------------------------------------------------------------
|
|
861 |
//
|
|
862 |
void CBTNotifSecurityManager::UpdatePairedDeviceListL()
|
|
863 |
{
|
57
|
864 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
865 |
iPairedDevices.Reset();
|
|
866 |
const RDevExtensionArray& alldevs = iDevRepository.AllDevices();
|
|
867 |
for ( TInt i = 0; i < alldevs.Count(); i++ )
|
|
868 |
{
|
|
869 |
if ( CBtDevExtension::IsBonded( alldevs[i]->Device().AsNamelessDevice() ) )
|
|
870 |
{
|
|
871 |
iPairedDevices.AppendL( alldevs[i]->Device().AsNamelessDevice() );
|
|
872 |
}
|
|
873 |
}
|
57
|
874 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
875 |
}
|
|
876 |
|
|
877 |
// ---------------------------------------------------------------------------
|
|
878 |
// Create incoming pairing handler if no one exists yet.
|
|
879 |
// ---------------------------------------------------------------------------
|
|
880 |
//
|
|
881 |
void CBTNotifSecurityManager::HandleRegistryBondingL(
|
|
882 |
const TBTNamelessDevice& aNameless)
|
|
883 |
{
|
57
|
884 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
885 |
TInt err = iPairedDevices.Append( aNameless );
|
|
886 |
if ( !err && !iPairingHandler)
|
|
887 |
{
|
|
888 |
// New paired device, but no pairing handler yet.
|
|
889 |
// this means an incoming pairing has occured:
|
|
890 |
TRAP( err, iPairingHandler =
|
|
891 |
CBTNotifIncomingPairingHandler::NewL( *this, aNameless.Address() ) );
|
|
892 |
}
|
|
893 |
if ( !err )
|
|
894 |
{
|
|
895 |
// We have a pairing handler now.
|
|
896 |
// Ask pair handler to decide what to do:
|
|
897 |
iPairingHandler->HandleRegistryNewPairedEvent(
|
|
898 |
aNameless );
|
|
899 |
}
|
|
900 |
else if ( iPairingHandler )
|
|
901 |
{
|
|
902 |
// error could occur due to no memory,
|
|
903 |
// let us try aborting pairing handling
|
|
904 |
iPairingHandler->StopPairHandling( aNameless.Address() );
|
|
905 |
}
|
57
|
906 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
907 |
}
|
|
908 |
|
|
909 |
void CBTNotifSecurityManager::TrustDevice( const TBTDevAddr& aAddr )
|
|
910 |
{
|
57
|
911 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
912 |
TIdentityRelation<TBTNamelessDevice> addrComp( CompareDeviceByAddress );
|
|
913 |
TBTNamelessDevice dev;
|
|
914 |
dev.SetAddress( aAddr );
|
|
915 |
TRequestStatus status( KRequestPending );
|
|
916 |
|
|
917 |
iRegistry.GetDevice(dev,status);
|
|
918 |
User::WaitForRequest( status );
|
|
919 |
if(status == KErrNone)
|
|
920 |
{
|
|
921 |
TBTDeviceSecurity security = dev.GlobalSecurity();
|
|
922 |
security.SetNoAuthorise(ETrue);
|
|
923 |
security.SetBanned(EFalse);
|
|
924 |
dev.SetGlobalSecurity(security);
|
|
925 |
(void)UpdateRegDevice(dev);
|
|
926 |
}
|
57
|
927 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
42
|
928 |
}
|
|
929 |
|
57
|
930 |
void CBTNotifSecurityManager::UnTrustDevice( const TBTDevAddr& aAddr )
|
|
931 |
{
|
|
932 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
|
933 |
TIdentityRelation<TBTNamelessDevice> addrComp( CompareDeviceByAddress );
|
|
934 |
TBTNamelessDevice dev;
|
|
935 |
dev.SetAddress( aAddr );
|
|
936 |
TRequestStatus status( KRequestPending );
|
|
937 |
|
|
938 |
iRegistry.GetDevice(dev,status);
|
|
939 |
User::WaitForRequest( status );
|
|
940 |
if(status == KErrNone)
|
|
941 |
{
|
|
942 |
TBTDeviceSecurity security = dev.GlobalSecurity();
|
|
943 |
security.SetNoAuthorise(EFalse);
|
|
944 |
dev.SetGlobalSecurity(security);
|
|
945 |
(void)UpdateRegDevice(dev);
|
|
946 |
}
|
|
947 |
BOstraceFunctionExit0( DUMMY_DEVLIST);
|
|
948 |
}
|
|
949 |
|
|
950 |
CBTNotifBasePairingHandler* CBTNotifSecurityManager::PairingHandler()
|
|
951 |
{
|
|
952 |
return iPairingHandler;
|
|
953 |
}
|
|
954 |
|
|
955 |
|