bluetoothengine/bteng/bttoggle/src/bttoggle.cpp
branchRCL_3
changeset 13 b6f55cd40afd
parent 10 0707dd69d236
child 28 7e2761e776bd
child 54 0ba996a9b75d
--- a/bluetoothengine/bteng/bttoggle/src/bttoggle.cpp	Mon Mar 15 12:41:15 2010 +0200
+++ b/bluetoothengine/bteng/bttoggle/src/bttoggle.cpp	Wed Mar 31 21:51:05 2010 +0300
@@ -177,21 +177,21 @@
     //BT Connected or error obtaining link count (in the case of error, we are cautious and assume BT is connected)
     if (errLinkCount || linkCount > 0)
       {
-      TRACE_INFO((_L("[BTENG][BTTOGGLE]Ongoing BT connection") ))								
+      TRACE_INFO((_L("[BTENG][BTTOGGLE]Ongoing BT connection") ))
       __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateCloseConnectionQuery));
 
-      iActiveNotifier = ECloseConnectionQuery;						
+      iActiveNotifier = ECloseConnectionQuery;
       iPckgGenericQuery().iMessageType = EBTSwitchOffAnyway;
       iPckgGenericQuery().iNameExists = EFalse;
-      iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericQueryNotifierUid, iPckgGenericQuery, iConnQuery );			
-      SetActive();															
-      }	
+      iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericQueryNotifierUid, iPckgGenericQuery, iConnQuery );
+      SetActive();
+      }
     //No open connections
     else
       {
       TRACE_INFO((_L("[BTENG][BTTOGGLE] No BT connections") ))
       ChangeBtPowerMode(EBTPowerOff);
-      }					 
+      }
     }
   TRACE_FUNC_EXIT	
   }
@@ -241,20 +241,17 @@
   TRACE_FUNC_ENTRY
   __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateChangeBtPowerMode));
 
-  TRequestStatus *stat = &iStatus; 
-  TInt errPower = iSettings->SetPowerState(aNewPowerState);					
-
+  TInt errPower = iSettings->SetPowerState(aNewPowerState);
   if (KErrNone == errPower)
     {
     ShowNotification( static_cast<TBool>(aNewPowerState) );
+    iActiveNotifier = EPowerModeChangeNote; 
+    iStatus = KRequestPending;
+    SetActive();
     }
-  iActiveNotifier = EFakeNotif; 
-  iStatus = KRequestPending;
-  User::RequestComplete(stat, KErrNone);
-  SetActive();
 
   TRACE_FUNC_EXIT
-  return errPower; 	
+  return errPower;
   }
 
 // ==========================================================
@@ -284,7 +281,7 @@
   Cancel();
 
   //Start new notification
-  iNotifier.StartNotifier(KBTGenericInfoNotifierUid, pckgGenericInfo, result);	
+  iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericInfoNotifierUid, pckgGenericInfo, result);	
 
   TRACE_FUNC_EXIT
   }
@@ -304,7 +301,11 @@
   else if ( ECloseConnectionQuery == iActiveNotifier ) 
     {
     iNotifier.CancelNotifier(KBTGenericQueryNotifierUid); 
-    }
+    }  
+  else if ( EPowerModeChangeNote == iActiveNotifier ) 
+      {
+      iNotifier.CancelNotifier(KBTGenericQueryNotifierUid); 
+      }
 
   // For all cancels, we must reset iActiveNotifier back to ENoneQuery
   // to permit another request to be made.
@@ -328,10 +329,10 @@
   // to permit another request to be made.
   switch (iActiveNotifier)
     {							
-    case EPowerModeQuery:				
+    case EPowerModeQuery:
       iActiveNotifier = ENoneQuery;
-      ShowNotification(ETrue);
-      CActiveScheduler::Stop();
+      ShowNotification(ETrue);    
+      SetActive();
       break; 			
     case ECloseConnectionQuery:							
       iActiveNotifier = ENoneQuery;
@@ -343,8 +344,8 @@
         {
         CActiveScheduler::Stop();
         }																				
-      break;											
-    default: //ENoneQuery or EFakeNotif
+      break;
+    default: //ENoneQuery or EPowerModeChangeNote
       iActiveNotifier = ENoneQuery;
       CActiveScheduler::Stop();
     }