45 const TInt KBTEngEmergencyWatcher = 21; |
46 const TInt KBTEngEmergencyWatcher = 21; |
46 /** Identification for active object */ |
47 /** Identification for active object */ |
47 const TInt KBTEngSapWatcher = 22; |
48 const TInt KBTEngSapWatcher = 22; |
48 /** Identification for active object */ |
49 /** Identification for active object */ |
49 const TInt KBTEngAddrWatcher = 23; |
50 const TInt KBTEngAddrWatcher = 23; |
50 |
51 /** Identification for active object */ |
|
52 const TInt KBTEngRegistryWatcher = 24; |
51 /** Identification for active object */ |
53 /** Identification for active object */ |
52 const TInt KBTEngSspDebugWatcher = 25; |
54 const TInt KBTEngSspDebugWatcher = 25; |
53 /** Buffer size for BT device address as stored in CenRep */ |
55 /** Buffer size for BT device address as stored in CenRep */ |
54 const TInt KCenRepAddrBufSize = 2 * KBTDevAddrSize; |
56 const TInt KCenRepAddrBufSize = 2 * KBTDevAddrSize; |
55 |
57 |
125 iEmergencyCallWatcher = CBTEngActive::NewL( *this, KBTEngEmergencyWatcher, |
127 iEmergencyCallWatcher = CBTEngActive::NewL( *this, KBTEngEmergencyWatcher, |
126 CActive::EPriorityStandard ); |
128 CActive::EPriorityStandard ); |
127 iEmergencyCallKey.Subscribe( iEmergencyCallWatcher->RequestStatus() ); |
129 iEmergencyCallKey.Subscribe( iEmergencyCallWatcher->RequestStatus() ); |
128 iEmergencyCallWatcher->GoActive(); |
130 iEmergencyCallWatcher->GoActive(); |
129 } |
131 } |
|
132 |
|
133 err = iBtRegistryKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetRegistryTableChange ); |
|
134 if( !err ) |
|
135 { |
|
136 iBtRegistryWatcher = CBTEngActive::NewL( *this, KBTEngRegistryWatcher, |
|
137 CActive::EPriorityStandard ); |
|
138 iBtRegistryKey.Subscribe( iBtRegistryWatcher->RequestStatus() ); |
|
139 iBtRegistryWatcher->GoActive(); |
|
140 } |
|
141 |
130 err = iSspDebugModeKey.Attach( KPSUidBluetoothTestingMode, KBTSspDebugmode ); |
142 err = iSspDebugModeKey.Attach( KPSUidBluetoothTestingMode, KBTSspDebugmode ); |
131 if( !err ) |
143 if( !err ) |
132 { |
144 { |
133 iSspDebugModeWatcher = CBTEngActive::NewL( *this, KBTEngSspDebugWatcher, |
145 iSspDebugModeWatcher = CBTEngActive::NewL( *this, KBTEngSspDebugWatcher, |
134 CActive::EPriorityStandard ); |
146 CActive::EPriorityStandard ); |
178 // Destructor |
190 // Destructor |
179 // --------------------------------------------------------------------------- |
191 // --------------------------------------------------------------------------- |
180 // |
192 // |
181 CBTEngSrvKeyWatcher::~CBTEngSrvKeyWatcher() |
193 CBTEngSrvKeyWatcher::~CBTEngSrvKeyWatcher() |
182 { |
194 { |
|
195 if( iDutModeKey.Handle() ) |
|
196 { |
|
197 iDutModeKey.Cancel(); |
|
198 } |
183 delete iDutModeWatcher; |
199 delete iDutModeWatcher; |
184 iDutModeKey.Close(); |
200 iDutModeKey.Close(); |
185 |
201 |
186 #ifdef RD_REMOTELOCK |
202 #ifdef RD_REMOTELOCK |
|
203 if( iPhoneLockKey.Handle() ) |
|
204 { |
|
205 iPhoneLockKey.Cancel(); |
|
206 } |
187 delete iPhoneLockWatcher; |
207 delete iPhoneLockWatcher; |
188 iPhoneLockKey.Close(); |
208 iPhoneLockKey.Close(); |
189 #endif //RD_REMOTELOCK |
209 #endif //RD_REMOTELOCK |
190 |
210 |
|
211 if( iSystemStateKey.Handle() ) |
|
212 { |
|
213 iSystemStateKey.Cancel(); |
|
214 } |
191 delete iSystemStateWatcher; |
215 delete iSystemStateWatcher; |
192 iSystemStateKey.Close(); |
216 iSystemStateKey.Close(); |
193 |
217 |
|
218 if( iBtConnectionKey.Handle() ) |
|
219 { |
|
220 iBtConnectionKey.Cancel(); |
|
221 } |
194 delete iBtConnectionWatcher; |
222 delete iBtConnectionWatcher; |
195 iBtConnectionKey.Close(); |
223 iBtConnectionKey.Close(); |
196 |
224 |
|
225 if( iBtScanningKey.Handle() ) |
|
226 { |
|
227 iBtScanningKey.Cancel(); |
|
228 } |
197 delete iBtScanningWatcher; |
229 delete iBtScanningWatcher; |
198 iBtScanningKey.Close(); |
230 iBtScanningKey.Close(); |
199 |
231 |
|
232 if( iEmergencyCallKey.Handle() ) |
|
233 { |
|
234 iEmergencyCallKey.Cancel(); |
|
235 } |
200 delete iEmergencyCallWatcher; |
236 delete iEmergencyCallWatcher; |
201 iEmergencyCallKey.Close(); |
237 iEmergencyCallKey.Close(); |
202 |
238 |
|
239 if( iSspDebugModeKey.Handle() ) |
|
240 { |
|
241 iSspDebugModeKey.Cancel(); |
|
242 } |
203 delete iSspDebugModeWatcher; |
243 delete iSspDebugModeWatcher; |
204 iSspDebugModeKey.Close(); |
244 iSspDebugModeKey.Close(); |
205 |
245 |
|
246 if( iBtRegistryKey.Handle() ) |
|
247 { |
|
248 iBtRegistryKey.Cancel(); |
|
249 } |
|
250 delete iBtRegistryWatcher; |
|
251 iBtRegistryKey.Close(); |
|
252 |
|
253 if( iSapKeyCenRep ) |
|
254 { |
|
255 iSapKeyCenRep->NotifyCancel( KBTSapEnabled ); |
|
256 } |
206 delete iSapModeWatcher; |
257 delete iSapModeWatcher; |
207 delete iSapKeyCenRep; |
258 delete iSapKeyCenRep; |
208 |
259 |
|
260 if( iBdaddrKey.Handle() ) |
|
261 { |
|
262 iBdaddrKey.Cancel(); |
|
263 } |
209 delete iBdaddrWatcher; |
264 delete iBdaddrWatcher; |
210 iBdaddrKey.Close(); |
265 iBdaddrKey.Close(); |
211 } |
266 } |
212 |
267 |
213 |
268 |
214 // --------------------------------------------------------------------------- |
269 // --------------------------------------------------------------------------- |
215 // From class MBTEngActiveObserver. |
270 // From class MBTEngActiveObserver. |
216 // Processes a changed key value. |
271 // Processes a changed key value. |
217 // --------------------------------------------------------------------------- |
272 // --------------------------------------------------------------------------- |
218 // |
273 // |
219 void CBTEngSrvKeyWatcher::RequestCompletedL( CBTEngActive* aActive, |
274 void CBTEngSrvKeyWatcher::RequestCompletedL( CBTEngActive* aActive, TInt aId, |
220 TInt aStatus ) |
275 TInt aStatus ) |
221 { |
276 { |
222 TRACE_FUNC_ARG( ( _L( "status %d" ), aStatus ) ) |
277 TRACE_FUNC_ARG( ( _L( "status %d" ), aStatus ) ) |
223 ASSERT( aStatus != KErrPermissionDenied ); |
278 ASSERT( aStatus != KErrPermissionDenied ); |
224 TInt val = 0; |
279 TInt val = 0; |
225 switch( aActive->RequestId() ) |
280 switch( aId ) |
226 { |
281 { |
227 case KBTEngDutWatcher: |
282 case KBTEngDutWatcher: |
228 { |
283 { |
229 TRACE_INFO( ( _L( "DUT mode key changed" ) ) ) |
284 TRACE_INFO( ( _L( "DUT mode key changed" ) ) ) |
230 iDutModeKey.Subscribe( aActive->RequestStatus() ); |
285 iDutModeKey.Subscribe( aActive->RequestStatus() ); |
303 { |
358 { |
304 iServer->SettingsManager()->CheckSspDebugModeL( (TBool) val ); |
359 iServer->SettingsManager()->CheckSspDebugModeL( (TBool) val ); |
305 } |
360 } |
306 break; |
361 break; |
307 } |
362 } |
|
363 case KBTEngRegistryWatcher: |
|
364 { |
|
365 TRACE_INFO( ( _L( "BT Registry key changed" ) ) ) |
|
366 TInt myChangedTable; |
|
367 |
|
368 iBtRegistryKey.Subscribe( aActive->RequestStatus() ); |
|
369 aActive->GoActive(); |
|
370 |
|
371 TInt err = iBtRegistryKey.Get( myChangedTable ); |
|
372 if( !err && myChangedTable == KRegistryChangeRemoteTable ) |
|
373 { |
|
374 TRACE_INFO( ( _L("BT Remote registry key changed") ) ) |
|
375 iServer->PairManager()->RemoteRegistryChangeDetected(); |
|
376 } |
|
377 break; |
|
378 } |
308 case KBTEngSapWatcher: |
379 case KBTEngSapWatcher: |
309 { |
380 { |
310 TRACE_INFO( ( _L( "SAP mode key changed" ) ) ) |
381 TRACE_INFO( ( _L( "SAP mode key changed" ) ) ) |
311 iSapKeyCenRep->NotifyRequest( KBTSapEnabled, aActive->RequestStatus() ); |
382 iSapKeyCenRep->NotifyRequest( KBTSapEnabled, aActive->RequestStatus() ); |
312 aActive->GoActive(); |
383 aActive->GoActive(); |
355 } |
426 } |
356 } |
427 } |
357 break; |
428 break; |
358 default: |
429 default: |
359 { |
430 { |
360 TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aActive->RequestId() ) ) |
431 TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aId ) ) |
361 } |
432 } |
362 break; |
433 break; |
363 |
434 |
364 } |
435 } |
365 TRACE_FUNC_EXIT |
436 TRACE_FUNC_EXIT |
366 } |
437 } |
367 |
438 |
368 // --------------------------------------------------------------------------- |
|
369 // From class MBTEngActiveObserver. |
|
370 // Handles cancelation of an outstanding request |
|
371 // --------------------------------------------------------------------------- |
|
372 // |
|
373 void CBTEngSrvKeyWatcher::CancelRequest( TInt aRequestId ) |
|
374 { |
|
375 TRACE_FUNC_ARG( ( _L( "reqID %d" ), aRequestId ) ) |
|
376 switch( aRequestId ) |
|
377 { |
|
378 case KBTEngDutWatcher: |
|
379 { |
|
380 iDutModeKey.Cancel(); |
|
381 break; |
|
382 } |
|
383 case KBTEngLockWatcher: |
|
384 { |
|
385 iPhoneLockKey.Cancel(); |
|
386 break; |
|
387 } |
|
388 case KBTEngSysWatcher: |
|
389 { |
|
390 iSystemStateKey.Cancel(); |
|
391 break; |
|
392 } |
|
393 case KBTEngBtConnectionWatcher: |
|
394 { |
|
395 iBtConnectionKey.Cancel(); |
|
396 break; |
|
397 } |
|
398 |
|
399 case KBTEngScanningWatcher: |
|
400 { |
|
401 iBtScanningKey.Cancel(); |
|
402 break; |
|
403 } |
|
404 |
|
405 case KBTEngEmergencyWatcher: |
|
406 { |
|
407 iEmergencyCallKey.Cancel(); |
|
408 break; |
|
409 } |
|
410 |
|
411 case KBTEngSspDebugWatcher: |
|
412 { |
|
413 iSspDebugModeKey.Cancel(); |
|
414 break; |
|
415 } |
|
416 case KBTEngSapWatcher: |
|
417 { |
|
418 iSapKeyCenRep->NotifyCancel( KBTSapEnabled ); |
|
419 break; |
|
420 } |
|
421 |
|
422 case KBTEngAddrWatcher: |
|
423 { |
|
424 iBdaddrKey.Cancel(); |
|
425 break; |
|
426 } |
|
427 default: |
|
428 { |
|
429 TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aRequestId ) ) |
|
430 break; |
|
431 } |
|
432 } |
|
433 TRACE_FUNC_EXIT |
|
434 } |
|
435 |
439 |
436 // --------------------------------------------------------------------------- |
440 // --------------------------------------------------------------------------- |
437 // From class MBTEngActiveObserver. |
441 // From class MBTEngActiveObserver. |
438 // Handles a leave in RunL/RequestCompletedL by checking that all |
442 // Handles a leave in RunL/RequestCompletedL by checking that all |
439 // the subscriptions are active. |
443 // the subscriptions are active. |
440 // --------------------------------------------------------------------------- |
444 // --------------------------------------------------------------------------- |
441 // |
445 // |
442 void CBTEngSrvKeyWatcher::HandleError( CBTEngActive* aActive, |
446 void CBTEngSrvKeyWatcher::HandleError( CBTEngActive* aActive, TInt aId, |
443 TInt aError ) |
447 TInt aError ) |
444 { |
448 { |
445 TRACE_FUNC_ARG( ( _L( "status %d" ), aError ) ) |
449 TRACE_FUNC_ARG( ( _L( "status %d" ), aError ) ) |
446 (void) aError; |
450 (void) aError; |
447 if( !aActive->IsActive() ) |
451 if( !aActive->IsActive() ) |
448 { |
452 { |
449 switch( aActive->RequestId() ) |
453 switch( aId ) |
450 { |
454 { |
451 case KBTEngDutWatcher: |
455 case KBTEngDutWatcher: |
452 { |
456 { |
453 iDutModeKey.Subscribe( aActive->RequestStatus() ); |
457 iDutModeKey.Subscribe( aActive->RequestStatus() ); |
454 } |
458 } |