bluetoothengine/bteng/bttoggle/src/bttoggle.cpp
branchRCL_3
changeset 10 b6f55cd40afd
parent 8 0707dd69d236
child 21 0ba996a9b75d
equal deleted inserted replaced
9:a42ed326b458 10:b6f55cd40afd
   175     TRACE_INFO((_L("[BTENG][BTTOGGLE] linkCount: %d error: %d" ), linkCount, errLinkCount))		
   175     TRACE_INFO((_L("[BTENG][BTTOGGLE] linkCount: %d error: %d" ), linkCount, errLinkCount))		
   176 
   176 
   177     //BT Connected or error obtaining link count (in the case of error, we are cautious and assume BT is connected)
   177     //BT Connected or error obtaining link count (in the case of error, we are cautious and assume BT is connected)
   178     if (errLinkCount || linkCount > 0)
   178     if (errLinkCount || linkCount > 0)
   179       {
   179       {
   180       TRACE_INFO((_L("[BTENG][BTTOGGLE]Ongoing BT connection") ))								
   180       TRACE_INFO((_L("[BTENG][BTTOGGLE]Ongoing BT connection") ))
   181       __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateCloseConnectionQuery));
   181       __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateCloseConnectionQuery));
   182 
   182 
   183       iActiveNotifier = ECloseConnectionQuery;						
   183       iActiveNotifier = ECloseConnectionQuery;
   184       iPckgGenericQuery().iMessageType = EBTSwitchOffAnyway;
   184       iPckgGenericQuery().iMessageType = EBTSwitchOffAnyway;
   185       iPckgGenericQuery().iNameExists = EFalse;
   185       iPckgGenericQuery().iNameExists = EFalse;
   186       iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericQueryNotifierUid, iPckgGenericQuery, iConnQuery );			
   186       iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericQueryNotifierUid, iPckgGenericQuery, iConnQuery );
   187       SetActive();															
   187       SetActive();
   188       }	
   188       }
   189     //No open connections
   189     //No open connections
   190     else
   190     else
   191       {
   191       {
   192       TRACE_INFO((_L("[BTENG][BTTOGGLE] No BT connections") ))
   192       TRACE_INFO((_L("[BTENG][BTTOGGLE] No BT connections") ))
   193       ChangeBtPowerMode(EBTPowerOff);
   193       ChangeBtPowerMode(EBTPowerOff);
   194       }					 
   194       }
   195     }
   195     }
   196   TRACE_FUNC_EXIT	
   196   TRACE_FUNC_EXIT	
   197   }
   197   }
   198 
   198 
   199 // ==========================================================
   199 // ==========================================================
   239 TInt CBTToggle::ChangeBtPowerMode(TBTPowerStateValue aNewPowerState)
   239 TInt CBTToggle::ChangeBtPowerMode(TBTPowerStateValue aNewPowerState)
   240   {
   240   {
   241   TRACE_FUNC_ENTRY
   241   TRACE_FUNC_ENTRY
   242   __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateChangeBtPowerMode));
   242   __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateChangeBtPowerMode));
   243 
   243 
   244   TRequestStatus *stat = &iStatus; 
   244   TInt errPower = iSettings->SetPowerState(aNewPowerState);
   245   TInt errPower = iSettings->SetPowerState(aNewPowerState);					
       
   246 
       
   247   if (KErrNone == errPower)
   245   if (KErrNone == errPower)
   248     {
   246     {
   249     ShowNotification( static_cast<TBool>(aNewPowerState) );
   247     ShowNotification( static_cast<TBool>(aNewPowerState) );
   250     }
   248     iActiveNotifier = EPowerModeChangeNote; 
   251   iActiveNotifier = EFakeNotif; 
   249     iStatus = KRequestPending;
   252   iStatus = KRequestPending;
   250     SetActive();
   253   User::RequestComplete(stat, KErrNone);
   251     }
   254   SetActive();
   252 
   255 
   253   TRACE_FUNC_EXIT
   256   TRACE_FUNC_EXIT
   254   return errPower;
   257   return errPower; 	
       
   258   }
   255   }
   259 
   256 
   260 // ==========================================================
   257 // ==========================================================
   261 // CBTToggle::ShowNotification
   258 // CBTToggle::ShowNotification
   262 // Presents generic info notification about BT on (ETrue) 
   259 // Presents generic info notification about BT on (ETrue) 
   282 
   279 
   283   //Cancel if there is any outstanding notification
   280   //Cancel if there is any outstanding notification
   284   Cancel();
   281   Cancel();
   285 
   282 
   286   //Start new notification
   283   //Start new notification
   287   iNotifier.StartNotifier(KBTGenericInfoNotifierUid, pckgGenericInfo, result);	
   284   iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericInfoNotifierUid, pckgGenericInfo, result);	
   288 
   285 
   289   TRACE_FUNC_EXIT
   286   TRACE_FUNC_EXIT
   290   }
   287   }
   291 
   288 
   292 // ==========================================================
   289 // ==========================================================
   302     iNotifier.CancelNotifier(KPowerModeSettingNotifierUid); 		
   299     iNotifier.CancelNotifier(KPowerModeSettingNotifierUid); 		
   303     }
   300     }
   304   else if ( ECloseConnectionQuery == iActiveNotifier ) 
   301   else if ( ECloseConnectionQuery == iActiveNotifier ) 
   305     {
   302     {
   306     iNotifier.CancelNotifier(KBTGenericQueryNotifierUid); 
   303     iNotifier.CancelNotifier(KBTGenericQueryNotifierUid); 
   307     }
   304     }  
       
   305   else if ( EPowerModeChangeNote == iActiveNotifier ) 
       
   306       {
       
   307       iNotifier.CancelNotifier(KBTGenericQueryNotifierUid); 
       
   308       }
   308 
   309 
   309   // For all cancels, we must reset iActiveNotifier back to ENoneQuery
   310   // For all cancels, we must reset iActiveNotifier back to ENoneQuery
   310   // to permit another request to be made.
   311   // to permit another request to be made.
   311   iActiveNotifier = ENoneQuery;
   312   iActiveNotifier = ENoneQuery;
   312 
   313 
   326 
   327 
   327   // For all completes, we must reset iActiveNotifier back to ENoneQuery
   328   // For all completes, we must reset iActiveNotifier back to ENoneQuery
   328   // to permit another request to be made.
   329   // to permit another request to be made.
   329   switch (iActiveNotifier)
   330   switch (iActiveNotifier)
   330     {							
   331     {							
   331     case EPowerModeQuery:				
   332     case EPowerModeQuery:
   332       iActiveNotifier = ENoneQuery;
   333       iActiveNotifier = ENoneQuery;
   333       ShowNotification(ETrue);
   334       ShowNotification(ETrue);    
   334       CActiveScheduler::Stop();
   335       SetActive();
   335       break; 			
   336       break; 			
   336     case ECloseConnectionQuery:							
   337     case ECloseConnectionQuery:							
   337       iActiveNotifier = ENoneQuery;
   338       iActiveNotifier = ENoneQuery;
   338       if (iConnQuery()) //user wants to stop existing connection
   339       if (iConnQuery()) //user wants to stop existing connection
   339         {
   340         {
   341         }					
   342         }					
   342       else
   343       else
   343         {
   344         {
   344         CActiveScheduler::Stop();
   345         CActiveScheduler::Stop();
   345         }																				
   346         }																				
   346       break;											
   347       break;
   347     default: //ENoneQuery or EFakeNotif
   348     default: //ENoneQuery or EPowerModeChangeNote
   348       iActiveNotifier = ENoneQuery;
   349       iActiveNotifier = ENoneQuery;
   349       CActiveScheduler::Stop();
   350       CActiveScheduler::Stop();
   350     }						
   351     }						
   351   
   352   
   352   TRACE_FUNC_EXIT	
   353   TRACE_FUNC_EXIT