diff -r 997690c3397a -r 0b2439c3e397 bluetoothengine/btnotif/btnotifsrv/src/btnotifserviceauthorizer.cpp --- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifserviceauthorizer.cpp Wed Jun 23 18:23:52 2010 +0300 +++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifserviceauthorizer.cpp Tue Jul 06 14:27:09 2010 +0300 @@ -65,6 +65,10 @@ iNotification->Close(); // Also dequeues the notification from the queue. iNotification = NULL; } + if ( !iNotifierMessage.IsNull() ) + { + iNotifierMessage.Complete( KErrServerTerminated ); + } } CBTNotifServiceAuthorizer::CBTNotifServiceAuthorizer( @@ -92,7 +96,7 @@ User::Leave(KErrServerBusy ); } - iParams.CreateL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) ); + iParams.ReAllocL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) ); aMessage.ReadL( EBTNotifSrvParamSlot, iParams ); TBTAuthorisationParams params; @@ -130,11 +134,24 @@ TBTNotifUtil::GetDeviceUiNameL(iCurrentDeviceName, dev, paramsPckg().iName, paramsPckg().iBDAddr ); - PrepareNotificationL(TBluetoothDialogParams::EUserAuthorization, EAuthorization, iPairedDevice); - iNotification->ShowL(); - // we do not save the message until all leavable functions have executed successfully. - // This makes sure the iNotifierMessage has a valid handle. - iNotifierMessage = aMessage; + TBool autoAuthorize; + PrepareNotificationL(autoAuthorize, + TBluetoothDialogParams::EUserAuthorization, + EAuthorization, iPairedDevice); + if ( autoAuthorize ) + { + TPckgBuf answer; + answer() = ETrue; + aMessage.Write(EBTNotifSrvReplySlot, answer); + aMessage.Complete(KErrNone); + } + else + { + iNotification->ShowL(); + // we do not save the message until all leavable functions have executed successfully. + // This makes sure the iNotifierMessage has a valid handle. + iNotifierMessage = aMessage; + } } void CBTNotifServiceAuthorizer::MBRDataReceived( CHbSymbianVariantMap& aData ) @@ -173,8 +190,11 @@ iParent.BlockDevice(paramsPckg().iBDAddr,ETrue); } } - iNotifierMessage.Write(EBTNotifSrvReplySlot, answer); - iNotifierMessage.Complete(KErrNone); + if ( !iNotifierMessage.IsNull() ) + { + iNotifierMessage.Write(EBTNotifSrvReplySlot, answer); + iNotifierMessage.Complete(KErrNone); + } } else if(aData.Keys().MdcaPoint(0).Compare(_L("checkBoxState")) == 0) { @@ -182,11 +202,16 @@ } } -void CBTNotifServiceAuthorizer::MBRNotificationClosed( TInt /*aError*/, const TDesC8& /*aData*/ ) +void CBTNotifServiceAuthorizer::MBRNotificationClosed( TInt aError, const TDesC8& aData ) { + (void) aError; + (void) aData; + iNotification->RemoveObserver(); + iNotification = NULL; } -void CBTNotifServiceAuthorizer::PrepareNotificationL(TBluetoothDialogParams::TBTDialogType aType, +void CBTNotifServiceAuthorizer::PrepareNotificationL(TBool& aAutoAuthorize, + TBluetoothDialogParams::TBTDialogType aType, TBTDialogResourceId aResourceId, TBool aPaired) { iNotification = iParent.ConnectionTracker().NotificationManager()->GetNotification(); @@ -194,6 +219,7 @@ iNotification->SetObserver( this ); iNotification->SetNotificationType( aType, aResourceId ); TInt err = KErrNone; + aAutoAuthorize = EFalse; //Set the dialog title based on the service IDs switch(iServiceId) @@ -214,7 +240,8 @@ iCheckBoxState = EFalse; User::LeaveIfError(err); } - }break; + } + break; case KBTSdpFax: case KBTSdpDun: @@ -227,7 +254,8 @@ // In case of an incoming connection, the checkbox is checked by default. iCheckBoxState = ETrue; User::LeaveIfError(err); - }break; + } + break; default: { @@ -240,10 +268,7 @@ // If there is no existing connection, then we pop up a query message. if(IsExistingConnectionToAudioL(paramsPckg().iBDAddr)) { - TPckgBuf answer; - answer() = ETrue; - iNotifierMessage.Write(EBTNotifSrvReplySlot, answer); - iNotifierMessage.Complete(KErrNone); + aAutoAuthorize = ETrue; return; } else @@ -253,7 +278,8 @@ iCheckBoxState = ETrue; User::LeaveIfError(err); } - }break; + } + break; } //Add the device name @@ -262,6 +288,7 @@ //Add the device class err = iNotification->SetData( TBluetoothDeviceDialog::EDeviceClass, iDeviceClass ); User::LeaveIfError(err); + } TBool CBTNotifServiceAuthorizer::IsExistingConnectionToAudioL(const TBTDevAddr& aDevAddr)