diff -r 19bd632b5100 -r b72428996822 bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.cpp --- a/bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.cpp Fri May 28 17:03:06 2010 +0300 +++ b/bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.cpp Mon Jul 12 18:51:05 2010 +0300 @@ -17,16 +17,18 @@ #include +#include "btqtconstants.h" #include "btdelegatedevsecurity.h" #include #include +#include #include BtDelegateDevSecurity::BtDelegateDevSecurity( BtSettingModel* settingModel, BtDeviceModel* deviceModel, QObject *parent) : - BtAbstractDelegate(settingModel, deviceModel, parent), mBtEngDevMan(0) + BtAbstractDelegate(settingModel, deviceModel, parent), mBtEngDevMan(0), mBtengConnMan(0), mDisconnectDelegate(0) { } @@ -34,6 +36,8 @@ BtDelegateDevSecurity::~BtDelegateDevSecurity() { delete mBtEngDevMan; + delete mBtengConnMan; + delete mDisconnectDelegate; } @@ -50,7 +54,35 @@ TBTDevAddr symaddr; TBuf buffer(strBtAddr.utf16()); symaddr.SetReadable( buffer ); + + // Disconnect if paired device was connected + if ( ! mBtengConnMan ){ + TRAP( error, mBtengConnMan = CBTEngConnMan::NewL(this) ); + } + TBTEngConnectionStatus connstatus; + if ( !error && mBtengConnMan->IsConnected(symaddr, connstatus ) == KErrNone) { + if ( connstatus == EBTEngConnected) { + if (! mDisconnectDelegate){ + mDisconnectDelegate = BtDelegateFactory::newDelegate( + BtDelegate::Disconnect, getSettingModel(), getDeviceModel()); + connect( mDisconnectDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectDelegateCompleted(int)) ); + + } + QListlist; + QVariant paramFirst; + paramFirst.setValue(index); + QVariant paramSecond; + DisconnectOption discoOpt = ServiceLevel; + paramSecond.setValue((int)discoOpt); + list.append(paramFirst); + list.append(paramSecond); + QVariant paramsList; + paramsList.setValue(list); + mDisconnectDelegate->exec(paramsList); + } + } + // Set device as unpaired CBTDevice *symBtDevice = 0; TRAP( error, { symBtDevice = CBTDevice::NewL( symaddr ); @@ -78,6 +110,11 @@ } +void BtDelegateDevSecurity::disconnectDelegateCompleted( int err ) +{ + Q_UNUSED(err); +} + void BtDelegateDevSecurity::HandleDevManComplete( TInt aErr ) { emitCommandComplete(aErr); @@ -91,20 +128,26 @@ void BtDelegateDevSecurity::emitCommandComplete(int error) { - QString str(hbTrId("Unpaired to %1")); - QString err(hbTrId("Unpairing with %1 Failed")); + // no dialogs here since stack provides "unpaired to %1" dialog + // and failures are not reported - if(error != KErrNone) { - HbNotificationDialog::launchDialog(err.arg(mdeviceName)); - } - else { - HbNotificationDialog::launchDialog(str.arg(mdeviceName)); - } + emit commandCompleted(error); +} - emit commandCompleted(error); +void BtDelegateDevSecurity::ConnectComplete( TBTDevAddr& aAddr, TInt aErr, + RBTDevAddrArray* aConflicts ) +{ + Q_UNUSED(aAddr); + Q_UNUSED(aErr); + Q_UNUSED(aConflicts); +} + +void BtDelegateDevSecurity::DisconnectComplete( TBTDevAddr& aAddr, TInt aErr ) +{ + Q_UNUSED(aAddr); + Q_UNUSED(aErr); } -