bluetoothengine/btui/btuidelegate/btdelegatepower.cpp
changeset 41 0b2439c3e397
parent 40 997690c3397a
child 52 4545c04e61e1
--- a/bluetoothengine/btui/btuidelegate/btdelegatepower.cpp	Wed Jun 23 18:23:52 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatepower.cpp	Tue Jul 06 14:27:09 2010 +0300
@@ -67,6 +67,7 @@
     if ( mReqPowerState == curPowerState ) {
         // no need to do anything
         emit commandCompleted( KErrNone );
+        return;
     }
     
     // perform power on/off operation
@@ -150,27 +151,30 @@
     Q_CHECK_PTR( btengConnMan );
     RBTDevAddrArray devAddrArray;
     err = btengConnMan->GetConnectedAddresses(devAddrArray);
+    if ( err != KErrNone) {
+       //TODO: handle the error here
+       emit commandCompleted(err);
+       return;
+    }
     int count = devAddrArray.Count();
-    //int count =3;
     devAddrArray.Close();
     delete btengConnMan;
-    if( !err &&  count> 0 ){
-            HbMessageBox::question( hbTrId("Turn Bluetooth off? There is an active connection." ),this, 
-                        SLOT(btOffDialogClose(HbAction*)));
-            
+    if( count> 0 ){
+        mActiveHandling = true;
+        disconnectOngoingConnections(); 
+    }
+    else{
+        mActiveHandling = true;
+        err = mBtengSettings->SetPowerState(EBTPowerOff);
+        
+        if ( err ) {
+           //TODO: handle the error here
+           emit commandCompleted(KErrGeneral);
         }
-        else{
-            mActiveHandling = true;
-            err = mBtengSettings->SetPowerState(EBTPowerOff);
-            
-            if ( err ) {
-               //TODO: handle the error here
-               emit commandCompleted(KErrGeneral);
-            }
         
-        }    
+    }    
 }
-
+/*
 void BtDelegatePower::btOffDialogClose(HbAction *action)
 {
     HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
@@ -188,7 +192,7 @@
     }     
     
 }
-
+*/
 void BtDelegatePower::disconnectOngoingConnections(){
     if (! mDisconnectDelegate){
         mDisconnectDelegate = BtDelegateFactory::newDelegate(