46 const TInt KBTEngEmergencyWatcher = 21; |
45 const TInt KBTEngEmergencyWatcher = 21; |
47 /** Identification for active object */ |
46 /** Identification for active object */ |
48 const TInt KBTEngSapWatcher = 22; |
47 const TInt KBTEngSapWatcher = 22; |
49 /** Identification for active object */ |
48 /** Identification for active object */ |
50 const TInt KBTEngAddrWatcher = 23; |
49 const TInt KBTEngAddrWatcher = 23; |
51 /** Identification for active object */ |
50 |
52 const TInt KBTEngRegistryWatcher = 24; |
|
53 /** Identification for active object */ |
51 /** Identification for active object */ |
54 const TInt KBTEngSspDebugWatcher = 25; |
52 const TInt KBTEngSspDebugWatcher = 25; |
55 /** Buffer size for BT device address as stored in CenRep */ |
53 /** Buffer size for BT device address as stored in CenRep */ |
56 const TInt KCenRepAddrBufSize = 2 * KBTDevAddrSize; |
54 const TInt KCenRepAddrBufSize = 2 * KBTDevAddrSize; |
57 |
55 |
127 iEmergencyCallWatcher = CBTEngActive::NewL( *this, KBTEngEmergencyWatcher, |
125 iEmergencyCallWatcher = CBTEngActive::NewL( *this, KBTEngEmergencyWatcher, |
128 CActive::EPriorityStandard ); |
126 CActive::EPriorityStandard ); |
129 iEmergencyCallKey.Subscribe( iEmergencyCallWatcher->RequestStatus() ); |
127 iEmergencyCallKey.Subscribe( iEmergencyCallWatcher->RequestStatus() ); |
130 iEmergencyCallWatcher->GoActive(); |
128 iEmergencyCallWatcher->GoActive(); |
131 } |
129 } |
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 |
|
142 err = iSspDebugModeKey.Attach( KPSUidBluetoothTestingMode, KBTSspDebugmode ); |
130 err = iSspDebugModeKey.Attach( KPSUidBluetoothTestingMode, KBTSspDebugmode ); |
143 if( !err ) |
131 if( !err ) |
144 { |
132 { |
145 iSspDebugModeWatcher = CBTEngActive::NewL( *this, KBTEngSspDebugWatcher, |
133 iSspDebugModeWatcher = CBTEngActive::NewL( *this, KBTEngSspDebugWatcher, |
146 CActive::EPriorityStandard ); |
134 CActive::EPriorityStandard ); |
190 // Destructor |
178 // Destructor |
191 // --------------------------------------------------------------------------- |
179 // --------------------------------------------------------------------------- |
192 // |
180 // |
193 CBTEngSrvKeyWatcher::~CBTEngSrvKeyWatcher() |
181 CBTEngSrvKeyWatcher::~CBTEngSrvKeyWatcher() |
194 { |
182 { |
195 if( iDutModeKey.Handle() ) |
|
196 { |
|
197 iDutModeKey.Cancel(); |
|
198 } |
|
199 delete iDutModeWatcher; |
183 delete iDutModeWatcher; |
200 iDutModeKey.Close(); |
184 iDutModeKey.Close(); |
201 |
185 |
202 #ifdef RD_REMOTELOCK |
186 #ifdef RD_REMOTELOCK |
203 if( iPhoneLockKey.Handle() ) |
|
204 { |
|
205 iPhoneLockKey.Cancel(); |
|
206 } |
|
207 delete iPhoneLockWatcher; |
187 delete iPhoneLockWatcher; |
208 iPhoneLockKey.Close(); |
188 iPhoneLockKey.Close(); |
209 #endif //RD_REMOTELOCK |
189 #endif //RD_REMOTELOCK |
210 |
190 |
211 if( iSystemStateKey.Handle() ) |
|
212 { |
|
213 iSystemStateKey.Cancel(); |
|
214 } |
|
215 delete iSystemStateWatcher; |
191 delete iSystemStateWatcher; |
216 iSystemStateKey.Close(); |
192 iSystemStateKey.Close(); |
217 |
193 |
218 if( iBtConnectionKey.Handle() ) |
|
219 { |
|
220 iBtConnectionKey.Cancel(); |
|
221 } |
|
222 delete iBtConnectionWatcher; |
194 delete iBtConnectionWatcher; |
223 iBtConnectionKey.Close(); |
195 iBtConnectionKey.Close(); |
224 |
196 |
225 if( iBtScanningKey.Handle() ) |
|
226 { |
|
227 iBtScanningKey.Cancel(); |
|
228 } |
|
229 delete iBtScanningWatcher; |
197 delete iBtScanningWatcher; |
230 iBtScanningKey.Close(); |
198 iBtScanningKey.Close(); |
231 |
199 |
232 if( iEmergencyCallKey.Handle() ) |
|
233 { |
|
234 iEmergencyCallKey.Cancel(); |
|
235 } |
|
236 delete iEmergencyCallWatcher; |
200 delete iEmergencyCallWatcher; |
237 iEmergencyCallKey.Close(); |
201 iEmergencyCallKey.Close(); |
238 |
202 |
239 if( iSspDebugModeKey.Handle() ) |
|
240 { |
|
241 iSspDebugModeKey.Cancel(); |
|
242 } |
|
243 delete iSspDebugModeWatcher; |
203 delete iSspDebugModeWatcher; |
244 iSspDebugModeKey.Close(); |
204 iSspDebugModeKey.Close(); |
245 |
205 |
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 } |
|
257 delete iSapModeWatcher; |
206 delete iSapModeWatcher; |
258 delete iSapKeyCenRep; |
207 delete iSapKeyCenRep; |
259 |
208 |
260 if( iBdaddrKey.Handle() ) |
|
261 { |
|
262 iBdaddrKey.Cancel(); |
|
263 } |
|
264 delete iBdaddrWatcher; |
209 delete iBdaddrWatcher; |
265 iBdaddrKey.Close(); |
210 iBdaddrKey.Close(); |
266 } |
211 } |
267 |
212 |
268 |
213 |
269 // --------------------------------------------------------------------------- |
214 // --------------------------------------------------------------------------- |
270 // From class MBTEngActiveObserver. |
215 // From class MBTEngActiveObserver. |
271 // Processes a changed key value. |
216 // Processes a changed key value. |
272 // --------------------------------------------------------------------------- |
217 // --------------------------------------------------------------------------- |
273 // |
218 // |
274 void CBTEngSrvKeyWatcher::RequestCompletedL( CBTEngActive* aActive, TInt aId, |
219 void CBTEngSrvKeyWatcher::RequestCompletedL( CBTEngActive* aActive, |
275 TInt aStatus ) |
220 TInt aStatus ) |
276 { |
221 { |
277 TRACE_FUNC_ARG( ( _L( "status %d" ), aStatus ) ) |
222 TRACE_FUNC_ARG( ( _L( "status %d" ), aStatus ) ) |
278 ASSERT( aStatus != KErrPermissionDenied ); |
223 ASSERT( aStatus != KErrPermissionDenied ); |
279 TInt val = 0; |
224 TInt val = 0; |
280 switch( aId ) |
225 switch( aActive->RequestId() ) |
281 { |
226 { |
282 case KBTEngDutWatcher: |
227 case KBTEngDutWatcher: |
283 { |
228 { |
284 TRACE_INFO( ( _L( "DUT mode key changed" ) ) ) |
229 TRACE_INFO( ( _L( "DUT mode key changed" ) ) ) |
285 iDutModeKey.Subscribe( aActive->RequestStatus() ); |
230 iDutModeKey.Subscribe( aActive->RequestStatus() ); |
358 { |
303 { |
359 iServer->SettingsManager()->CheckSspDebugModeL( (TBool) val ); |
304 iServer->SettingsManager()->CheckSspDebugModeL( (TBool) val ); |
360 } |
305 } |
361 break; |
306 break; |
362 } |
307 } |
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 } |
|
379 case KBTEngSapWatcher: |
308 case KBTEngSapWatcher: |
380 { |
309 { |
381 TRACE_INFO( ( _L( "SAP mode key changed" ) ) ) |
310 TRACE_INFO( ( _L( "SAP mode key changed" ) ) ) |
382 iSapKeyCenRep->NotifyRequest( KBTSapEnabled, aActive->RequestStatus() ); |
311 iSapKeyCenRep->NotifyRequest( KBTSapEnabled, aActive->RequestStatus() ); |
383 aActive->GoActive(); |
312 aActive->GoActive(); |
426 } |
355 } |
427 } |
356 } |
428 break; |
357 break; |
429 default: |
358 default: |
430 { |
359 { |
431 TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aId ) ) |
360 TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aActive->RequestId() ) ) |
432 } |
361 } |
433 break; |
362 break; |
434 |
363 |
435 } |
364 } |
436 TRACE_FUNC_EXIT |
365 TRACE_FUNC_EXIT |
437 } |
366 } |
438 |
367 |
|
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 } |
439 |
435 |
440 // --------------------------------------------------------------------------- |
436 // --------------------------------------------------------------------------- |
441 // From class MBTEngActiveObserver. |
437 // From class MBTEngActiveObserver. |
442 // Handles a leave in RunL/RequestCompletedL by checking that all |
438 // Handles a leave in RunL/RequestCompletedL by checking that all |
443 // the subscriptions are active. |
439 // the subscriptions are active. |
444 // --------------------------------------------------------------------------- |
440 // --------------------------------------------------------------------------- |
445 // |
441 // |
446 void CBTEngSrvKeyWatcher::HandleError( CBTEngActive* aActive, TInt aId, |
442 void CBTEngSrvKeyWatcher::HandleError( CBTEngActive* aActive, |
447 TInt aError ) |
443 TInt aError ) |
448 { |
444 { |
449 TRACE_FUNC_ARG( ( _L( "status %d" ), aError ) ) |
445 TRACE_FUNC_ARG( ( _L( "status %d" ), aError ) ) |
450 (void) aError; |
446 (void) aError; |
451 if( !aActive->IsActive() ) |
447 if( !aActive->IsActive() ) |
452 { |
448 { |
453 switch( aId ) |
449 switch( aActive->RequestId() ) |
454 { |
450 { |
455 case KBTEngDutWatcher: |
451 case KBTEngDutWatcher: |
456 { |
452 { |
457 iDutModeKey.Subscribe( aActive->RequestStatus() ); |
453 iDutModeKey.Subscribe( aActive->RequestStatus() ); |
458 } |
454 } |