equal
deleted
inserted
replaced
29 #include <btengutil.h> |
29 #include <btengutil.h> |
30 #include <StringLoader.h> // Localisation stringloader |
30 #include <StringLoader.h> // Localisation stringloader |
31 #include <BTNotif.rsg> // Own resources |
31 #include <BTNotif.rsg> // Own resources |
32 #include <featmgr.h> // Feature Manager API |
32 #include <featmgr.h> // Feature Manager API |
33 #include <utf.h> // CnvUtfConverter |
33 #include <utf.h> // CnvUtfConverter |
34 |
34 #include <bluetoothuiutil.h> |
35 #include "btnotifier.h" // Own class definition |
35 #include "btnotifier.h" // Own class definition |
36 #include "btNotifDebug.h" // Debugging macros |
36 #include "btNotifDebug.h" // Debugging macros |
37 #include "btnotiflock.h" |
37 #include "btnotiflock.h" |
38 #include "btnotif.hrh" // define MaxNameLength |
38 #include "btnotif.hrh" // define MaxNameLength |
39 #include "btnotifpanic.h" |
39 #include "btnotifpanic.h" |
83 // |
83 // |
84 void CBTNotifierBase::ConstructL() |
84 void CBTNotifierBase::ConstructL() |
85 { |
85 { |
86 // Sets up TLS, must be done before FeatureManager is used. |
86 // Sets up TLS, must be done before FeatureManager is used. |
87 FeatureManager::InitializeLibL(); |
87 FeatureManager::InitializeLibL(); |
88 TBool isCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
88 iIsCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
89 ? ETrue : EFalse; |
89 ? ETrue : EFalse; |
90 // Frees the TLS. Must be done after FeatureManager is used. |
90 // Frees the TLS. Must be done after FeatureManager is used. |
91 FeatureManager::UnInitializeLib(); |
91 FeatureManager::UnInitializeLib(); |
92 |
92 |
93 iBTEngSettings = CBTEngSettings::NewL(); |
93 iBTEngSettings = CBTEngSettings::NewL(); |
94 iDevMan = CBTEngDevMan::NewL( this ); |
94 iDevMan = CBTEngDevMan::NewL( this ); |
95 iNotifUiUtil = CBTNotifUIUtil::NewL( isCoverUI ); |
95 iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); |
96 } |
96 } |
97 |
97 |
98 // ---------------------------------------------------------- |
98 // ---------------------------------------------------------- |
99 // Destructor. |
99 // Destructor. |
100 // ---------------------------------------------------------- |
100 // ---------------------------------------------------------- |
143 // Asynchronic notifier launch. |
143 // Asynchronic notifier launch. |
144 // ---------------------------------------------------------- |
144 // ---------------------------------------------------------- |
145 // |
145 // |
146 void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) |
146 void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) |
147 { |
147 { |
|
148 if( !iNotifUiUtil ) |
|
149 { |
|
150 iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); |
|
151 } |
|
152 |
148 TRAPD(err, GetParamsL(aBuffer, aReplySlot, aMessage)); |
153 TRAPD(err, GetParamsL(aBuffer, aReplySlot, aMessage)); |
149 if (err) |
154 if (err) |
150 { |
155 { |
151 CompleteMessage(err); |
156 CompleteMessage(err); |
152 } |
157 } |
421 __ASSERT_DEBUG(iDevice, BTNOTIF_PANIC(EiDeviceNullWhenCallingGetDeviceFromRegL)); |
426 __ASSERT_DEBUG(iDevice, BTNOTIF_PANIC(EiDeviceNullWhenCallingGetDeviceFromRegL)); |
422 |
427 |
423 TBTRegistrySearch mySearch; |
428 TBTRegistrySearch mySearch; |
424 mySearch.FindAddress( aAddr ); |
429 mySearch.FindAddress( aAddr ); |
425 iDeviceArray = new (ELeave) CBTDeviceArray(1); |
430 iDeviceArray = new (ELeave) CBTDeviceArray(1); |
|
431 if( !iDevMan ) |
|
432 { |
|
433 iDevMan = CBTEngDevMan::NewL( this ); |
|
434 } |
426 TInt err = iDevMan->GetDevices( mySearch, iDeviceArray ); |
435 TInt err = iDevMan->GetDevices( mySearch, iDeviceArray ); |
427 if(err) |
436 if(err) |
428 { |
437 { |
429 FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::GetDeviceFromRegL iDevMan->GetDevices error = %d"), err)); |
438 FTRACE(FPrint(_L("[BTNOTIF]\t CBTNotifierBase::GetDeviceFromRegL iDevMan->GetDevices error = %d"), err)); |
430 DoHandleGetDevicesCompleteL(err, NULL); |
439 DoHandleGetDevicesCompleteL(err, NULL); |
447 HBufC* header= StringLoader::LoadLC( R_BT_BLOCK_DEVICE_HEADER ); |
456 HBufC* header= StringLoader::LoadLC( R_BT_BLOCK_DEVICE_HEADER ); |
448 |
457 |
449 TInt resId = IsUserAwarePaired( iDevice->AsNamelessDevice() ) ? |
458 TInt resId = IsUserAwarePaired( iDevice->AsNamelessDevice() ) ? |
450 R_BT_BLOCK_PAIRED_DEVICE_NOHELP : R_BT_BLOCK_DEVICE_NOHELP; |
459 R_BT_BLOCK_PAIRED_DEVICE_NOHELP : R_BT_BLOCK_DEVICE_NOHELP; |
451 |
460 |
452 HBufC* stringHolder = StringLoader::LoadLC( resId, bName ); |
461 RBuf stringholder; |
453 |
462 stringholder.CleanupClosePushL(); |
454 TInt keypress = iNotifUiUtil->ShowMessageQueryL( *stringHolder, *header, |
463 BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, resId, bName, 0 ); |
|
464 |
|
465 TInt keypress = iNotifUiUtil->ShowMessageQueryL( stringholder, *header, |
455 R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone ); |
466 R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone ); |
456 |
467 |
457 CleanupStack::PopAndDestroy(stringHolder); |
468 CleanupStack::PopAndDestroy(&stringholder); |
458 CleanupStack::PopAndDestroy(header); |
469 CleanupStack::PopAndDestroy(header); |
459 |
470 |
460 if( keypress )// user replied "Yes" |
471 if( keypress )// user replied "Yes" |
461 { |
472 { |
462 DoBlockDevice(); |
473 DoBlockDevice(); |
477 deviceSecurity.SetNoAuthorise(EFalse); |
488 deviceSecurity.SetNoAuthorise(EFalse); |
478 iDevice->SetGlobalSecurity(deviceSecurity); |
489 iDevice->SetGlobalSecurity(deviceSecurity); |
479 iDevice->DeleteLinkKey(); |
490 iDevice->DeleteLinkKey(); |
480 |
491 |
481 iBTRegistryQueryState = ESetDeviceBlocked; |
492 iBTRegistryQueryState = ESetDeviceBlocked; |
482 TInt devManErr = iDevMan->ModifyDevice( *iDevice ); |
493 TInt err = KErrNone; |
483 |
494 if( !iDevMan ) |
484 // if error, complete message, otherwise waiting for devman callback |
495 { |
485 // |
496 TRAP(err, iDevMan = CBTEngDevMan::NewL( this )); |
486 if(devManErr != KErrNone) |
497 } |
487 CompleteMessage(devManErr); |
498 if( !err ) |
|
499 { |
|
500 err = iDevMan->ModifyDevice( *iDevice ); |
|
501 } |
|
502 if( err ) |
|
503 { |
|
504 // if error, complete message, otherwise waiting for devman callback |
|
505 CompleteMessage(err); |
|
506 } |
488 } |
507 } |
489 |
508 |
490 void CBTNotifierBase::ChangeAuthorizeState( TBool aTrust ) |
509 void CBTNotifierBase::ChangeAuthorizeState( TBool aTrust ) |
491 { |
510 { |
492 FLOG(_L("[BTNOTIF]\t CBTNotifierBase::ChangeAuthorizeState()")); |
511 FLOG(_L("[BTNOTIF]\t CBTNotifierBase::ChangeAuthorizeState()")); |
494 sec.SetBanned(EFalse); |
513 sec.SetBanned(EFalse); |
495 sec.SetNoAuthorise( ( aTrust ) ? ETrue : EFalse ) ; |
514 sec.SetNoAuthorise( ( aTrust ) ? ETrue : EFalse ) ; |
496 iDevice->SetGlobalSecurity(sec); |
515 iDevice->SetGlobalSecurity(sec); |
497 |
516 |
498 iBTRegistryQueryState = ESetDeviceAuthorizeState; |
517 iBTRegistryQueryState = ESetDeviceAuthorizeState; |
499 TInt devManErr = iDevMan->ModifyDevice( *iDevice ); |
518 TInt err = KErrNone; |
500 |
519 if( !iDevMan ) |
501 // if error, complete message, otherwise waiting for devman callback |
520 { |
502 // |
521 TRAP(err, iDevMan = CBTEngDevMan::NewL( this )); |
503 if(devManErr != KErrNone) |
522 } |
504 { |
523 if( !err ) |
505 CompleteMessage(devManErr); |
524 { |
|
525 err = iDevMan->ModifyDevice( *iDevice ); |
|
526 } |
|
527 if( err ) |
|
528 { |
|
529 // if error, complete message, otherwise waiting for devman callback |
|
530 CompleteMessage(err); |
506 TBTNotifLockPublish::DeleteNotifLocks( |
531 TBTNotifLockPublish::DeleteNotifLocks( |
507 EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); |
532 EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); |
508 } |
533 } |
509 } |
534 } |
510 |
535 |