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 { |
356 // CBTToggle::RunError |
357 // CBTToggle::RunError |
357 // Inherited from CActive |
358 // Inherited from CActive |
358 // ========================================================== |
359 // ========================================================== |
359 // |
360 // |
360 TInt CBTToggle::RunError(TInt aError) |
361 TInt CBTToggle::RunError(TInt aError) |
361 { |
362 { |
362 TRACE_INFO((_L("[BTENG][BTTOGGLE]RunL error %d"), aError )) |
363 TRACE_INFO((_L("[BTENG][BTTOGGLE] RunError %d"), aError )) |
363 CActiveScheduler::Stop(); |
364 iActiveNotifier = ENoneQuery; |
364 return KErrNone; |
365 CActiveScheduler::Stop(); |
365 } |
366 return KErrNone; |
|
367 } |