144 // Simply deny the request as this is handing outgoing pairing |
144 // Simply deny the request as this is handing outgoing pairing |
145 // --------------------------------------------------------------------------- |
145 // --------------------------------------------------------------------------- |
146 // |
146 // |
147 TInt CBTNotifOutgoingPairingHandler::ObserveIncomingPair( const TBTDevAddr& aAddr ) |
147 TInt CBTNotifOutgoingPairingHandler::ObserveIncomingPair( const TBTDevAddr& aAddr ) |
148 { |
148 { |
149 (void)aAddr; |
149 if(iAddr == aAddr) |
150 return KErrServerBusy; |
150 { |
|
151 return KErrNone; |
|
152 } |
|
153 else |
|
154 { |
|
155 return KErrServerBusy; |
|
156 } |
151 } |
157 } |
152 |
158 |
153 // --------------------------------------------------------------------------- |
159 // --------------------------------------------------------------------------- |
154 // Accept the request only this device is not busy with another pairing request. |
160 // Accept the request only this device is not busy with another pairing request. |
155 // --------------------------------------------------------------------------- |
161 // --------------------------------------------------------------------------- |
156 // |
162 // |
157 void CBTNotifOutgoingPairingHandler::HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ) |
163 void CBTNotifOutgoingPairingHandler::HandleOutgoingPairL( const TBTDevAddr& aAddr, TUint aCod ) |
158 { |
164 { |
159 BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST," cod 0x%08x", aCod ); |
165 BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,_L(" cod 0x%08x"), aCod ); |
160 if ( iActive->IsActive() || aAddr != iAddr ) |
166 if ( iActive->IsActive() || aAddr != iAddr ) |
161 { |
167 { |
162 // we don't allow another pairing request. |
168 // we don't allow another pairing request. |
163 User::Leave( KErrServerBusy ); |
169 User::Leave( KErrServerBusy ); |
164 } |
170 } |
262 // UICookie to indicate that the device is successfully |
268 // UICookie to indicate that the device is successfully |
263 // bonded so that this device will be listed in paired device view of |
269 // bonded so that this device will be listed in paired device view of |
264 // bluetooth application: |
270 // bluetooth application: |
265 if ( aDev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable ) |
271 if ( aDev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable ) |
266 { |
272 { |
267 BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,"[BTNOTIF] Outgoing Pairing, Just Works pairing"); |
273 BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,_L("[BTNOTIF] Outgoing Pairing, Just Works pairing")); |
268 err = iParent.AddUiCookieJustWorksPaired( aDev ); |
274 err = iParent.AddUiCookieJustWorksPaired( aDev ); |
269 } |
275 } |
270 iActive->Cancel(); |
276 iActive->Cancel(); |
271 SetPairResult( err ? err : KErrNone ); |
277 SetPairResult( err ? err : KErrNone ); |
272 if(err == KErrNone) |
278 if(err == KErrNone) |
290 // |
296 // |
291 void CBTNotifOutgoingPairingHandler::RequestCompletedL( |
297 void CBTNotifOutgoingPairingHandler::RequestCompletedL( |
292 CBtSimpleActive* aActive, TInt aStatus ) |
298 CBtSimpleActive* aActive, TInt aStatus ) |
293 { |
299 { |
294 BOstraceFunctionEntry0( DUMMY_DEVLIST ); |
300 BOstraceFunctionEntry0( DUMMY_DEVLIST ); |
295 BOstraceExt3(TRACE_DEBUG,DUMMY_DEVLIST,"reqid %d, status: %d, pair mode %d ", aActive->RequestId(), |
301 BOstraceExt3(TRACE_DEBUG,DUMMY_DEVLIST,_L("reqid %d, status: %d, pair mode %d "), aActive->RequestId(), |
296 aStatus, iPairMode); |
302 aStatus, iPairMode); |
297 if( aActive->RequestId() == EDedicatedBonding && |
303 if( aActive->RequestId() == EDedicatedBonding && |
298 ( aStatus == KErrRemoteDeviceIndicatedNoBonding || |
304 ( aStatus == KErrRemoteDeviceIndicatedNoBonding || |
299 ( aStatus && iPairMode != EBTOutgoingNoneHeadsetPairing && iPairMode != EBTOutgoingPairNone ) ) ) |
305 ( aStatus && iPairMode != EBTOutgoingNoneHeadsetPairing && iPairMode != EBTOutgoingPairNone ) ) ) |
300 { |
306 { |
304 } |
310 } |
305 else if ( aStatus && iPairMode == EBTOutgoingHeadsetAutoPairing ) |
311 else if ( aStatus && iPairMode == EBTOutgoingHeadsetAutoPairing ) |
306 { |
312 { |
307 iPairMode = EBTOutgoingHeadsetManualPairing; |
313 iPairMode = EBTOutgoingHeadsetManualPairing; |
308 // auto pairing with headset failed, try to pair again with manual pin: |
314 // auto pairing with headset failed, try to pair again with manual pin: |
309 BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST," auto pairing failed, switch to manual pairing"); |
315 BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,_L(" auto pairing failed, switch to manual pairing")); |
310 DoPairingL(); |
316 DoPairingL(); |
311 } |
317 } |
312 else if ( aStatus && aActive->RequestId() == EGeneralBonding && |
318 else if ( aStatus && aActive->RequestId() == EGeneralBonding && |
313 iPairMode == EBTOutgoingHeadsetManualPairing ) |
319 iPairMode == EBTOutgoingHeadsetManualPairing ) |
314 { |
320 { |
396 // --------------------------------------------------------------------------- |
402 // --------------------------------------------------------------------------- |
397 // |
403 // |
398 void CBTNotifOutgoingPairingHandler::HandleError( |
404 void CBTNotifOutgoingPairingHandler::HandleError( |
399 CBtSimpleActive* aActive, TInt aError ) |
405 CBtSimpleActive* aActive, TInt aError ) |
400 { |
406 { |
401 BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"error: %d", aError ); |
407 BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,_L("error: %d"), aError ); |
402 // Our RunL can actually not leave, so we should never reach here. |
408 // Our RunL can actually not leave, so we should never reach here. |
403 (void) aActive; |
409 (void) aActive; |
404 iParent.OutgoingPairCompleted( aError ); |
410 iParent.OutgoingPairCompleted( aError ); |
405 iParent.RenewPairingHandler( NULL ); |
411 iParent.RenewPairingHandler( NULL ); |
406 } |
412 } |
425 else if(currentMode == EGeneralBondingRetryTimer) |
431 else if(currentMode == EGeneralBondingRetryTimer) |
426 { |
432 { |
427 nextMode = EGeneralBondingRetry; |
433 nextMode = EGeneralBondingRetry; |
428 } |
434 } |
429 |
435 |
430 BOstraceExt2(TRACE_DEBUG,DUMMY_DEVLIST,"[BTENG] CBTEngOtgPair::DoPairingL: bonding mode: pre %d, next %d", currentMode, nextMode); |
436 BOstraceExt2(TRACE_DEBUG,DUMMY_DEVLIST,_L("[BTNOTIF] CBTEngOtgPair::DoPairingL: bonding mode: pre %d, next %d"), currentMode, nextMode); |
431 |
437 |
432 iActive->SetRequestId( nextMode ); |
438 iActive->SetRequestId( nextMode ); |
433 if ( nextMode == EDedicatedBonding ) |
439 if ( nextMode == EDedicatedBonding ) |
434 { |
440 { |
435 iBondingSession.Start( *iParent.PairingServer(), iAddr, iActive->RequestStatus() ); |
441 iBondingSession.Start( *iParent.PairingServer(), iAddr, iActive->RequestStatus() ); |
511 // --------------------------------------------------------------------------- |
517 // --------------------------------------------------------------------------- |
512 // |
518 // |
513 void CBTNotifOutgoingPairingHandler::NotificationClosedL( TInt aError, const TDesC8& aData ) |
519 void CBTNotifOutgoingPairingHandler::NotificationClosedL( TInt aError, const TDesC8& aData ) |
514 { |
520 { |
515 BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aError ); |
521 BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aError ); |
|
522 (void)aError; |
516 // Read the result. |
523 // Read the result. |
517 TPckgC<TBool> result( EFalse ); |
524 TPckgC<TBool> result( EFalse ); |
518 result.Set( aData.Ptr(), result.Length() ); // Read the part containing the result |
525 result.Set( aData.Ptr(), result.Length() ); // Read the part containing the result |
519 // Set a pointer descriptor to capture the remaining data, if any. |
526 // Set a pointer descriptor to capture the remaining data, if any. |
520 TPtrC8 dataPtr( aData.Mid( result.Length() ) ); |
527 TPtrC8 dataPtr( aData.Mid( result.Length() ) ); |