20 #include <bt_subscribe_partner.h> |
20 #include <bt_subscribe_partner.h> |
21 #include <btnotif.h> |
21 #include <btnotif.h> |
22 #include <btengdomainpskeys.h> |
22 #include <btengdomainpskeys.h> |
23 #include <centralrepository.h> |
23 #include <centralrepository.h> |
24 #include <featmgr.h> |
24 #include <featmgr.h> |
|
25 #include <AknSmallIndicator.h> |
|
26 #include <avkon.hrh> |
|
27 |
25 #include "btengserver.h" |
28 #include "btengserver.h" |
26 #include "btengsrvpluginmgr.h" |
29 #include "btengsrvpluginmgr.h" |
27 #include "btengsrvbbconnectionmgr.h" |
30 #include "btengsrvbbconnectionmgr.h" |
28 #include "btengsrvstate.h" |
31 #include "btengsrvstate.h" |
29 #include "debug.h" |
32 #include "debug.h" |
30 #include <btindicatorconstants.h> |
|
31 #include <hbindicatorsymbian.h> |
|
32 #include <hbsymbianvariant.h> |
|
33 |
33 |
34 /** ID of active object helper */ |
34 /** ID of active object helper */ |
35 const TInt KBTEngSettingsActive = 30; |
35 const TInt KBTEngSettingsActive = 30; |
36 /** Constant for converting minutes to microseconds */ |
36 /** Constant for converting minutes to microseconds */ |
37 //const TInt64 KMinutesInMicroSecs = 60000000; |
37 //const TInt64 KMinutesInMicroSecs = 60000000; |
179 // We don't return an error here, as there is no error situation. |
182 // We don't return an error here, as there is no error situation. |
180 TRACE_INFO( ( _L( "SetPowerStateL: nothing to do" ) ) ) |
183 TRACE_INFO( ( _L( "SetPowerStateL: nothing to do" ) ) ) |
181 if ( currentState == aState ) |
184 if ( currentState == aState ) |
182 { |
185 { |
183 // Make sure that the CenRep key is in sync. |
186 // Make sure that the CenRep key is in sync. |
184 // During boot-up, the power is set from the CenRep key, so we could |
187 // During boot-up, the pwoer is set from the CenRep key, so we could |
185 // end up out-of-sync. |
188 // end up out-of-sync. |
186 TRACE_INFO( ( _L( "SetPowerStateL: currentState == aState" ) ) ) |
189 TRACE_INFO( ( _L( "SetPowerStateL: currentState == aState" ) ) ) |
187 HandleHwPowerChangeL( aState ); |
190 UpdateCenRepPowerKeyL( aState ); |
188 } |
191 } |
189 return; |
192 return; |
190 } |
193 } |
191 if ( aState == EBTOn ) |
194 if ( aState == EBTOn ) |
192 { |
195 { |
193 // Hardware power on is the first step. |
196 // Hardware power on is the first step. |
313 TRACE_FUNC_EXIT |
316 TRACE_FUNC_EXIT |
314 } |
317 } |
315 |
318 |
316 |
319 |
317 // --------------------------------------------------------------------------- |
320 // --------------------------------------------------------------------------- |
318 // Update the power state CenRep key, and start BTNotif server if BT is on. |
321 // Update the power state CenRep key. |
319 // --------------------------------------------------------------------------- |
322 // --------------------------------------------------------------------------- |
320 // |
323 // |
321 void CBTEngSrvSettingsMgr::HandleHwPowerChangeL( TBTPowerState aState ) |
324 void CBTEngSrvSettingsMgr::UpdateCenRepPowerKeyL( TBTPowerState aState ) |
322 { |
325 { |
323 TRACE_FUNC_ENTRY |
326 TRACE_FUNC_ENTRY |
324 CRepository* cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); |
327 CRepository* cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); |
325 // TBTPowerState power state type is inverted from TBTPowerStateValue... |
328 // TBTPowerState power state type is inverted from TBTPowerStateValue... |
326 TBTPowerStateValue power = ( aState == EBTOn ) ? EBTPowerOn : EBTPowerOff; |
329 TBTPowerStateValue power = (TBTPowerStateValue) !aState; |
327 User::LeaveIfError( cenrep->Set( KBTPowerState, (TInt) power ) ); |
330 User::LeaveIfError( cenrep->Set( KBTPowerState, (TInt) power ) ); |
328 CleanupStack::PopAndDestroy( cenrep ); |
331 CleanupStack::PopAndDestroy( cenrep ); |
329 TRACE_FUNC_EXIT |
332 TRACE_FUNC_EXIT |
330 } |
333 } |
|
334 |
331 |
335 |
332 // --------------------------------------------------------------------------- |
336 // --------------------------------------------------------------------------- |
333 // ?implementation_description |
337 // ?implementation_description |
334 // --------------------------------------------------------------------------- |
338 // --------------------------------------------------------------------------- |
335 // |
339 // |
648 // --------------------------------------------------------------------------- |
652 // --------------------------------------------------------------------------- |
649 // From class MBTEngActiveObserver. |
653 // From class MBTEngActiveObserver. |
650 // Callback to notify that an outstanding request has completed. |
654 // Callback to notify that an outstanding request has completed. |
651 // --------------------------------------------------------------------------- |
655 // --------------------------------------------------------------------------- |
652 // |
656 // |
653 void CBTEngSrvSettingsMgr::RequestCompletedL( CBTEngActive* aActive, TInt aStatus ) |
657 void CBTEngSrvSettingsMgr::RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ) |
654 { |
658 { |
655 __ASSERT_ALWAYS( aActive->RequestId() == KBTEngSettingsActive, PanicServer( EBTEngPanicCorrupt ) ); |
659 __ASSERT_ALWAYS( aId == KBTEngSettingsActive, PanicServer( EBTEngPanicCorrupt ) ); |
656 TRACE_FUNC_ENTRY |
660 TRACE_FUNC_ENTRY |
657 (void) aActive; |
661 (void) aActive; |
658 if ( aStatus != KErrNone && aStatus != KErrAlreadyExists && aStatus != KErrCancel ) |
662 if ( aStatus != KErrNone && aStatus != KErrAlreadyExists && aStatus != KErrCancel ) |
659 { |
663 { |
660 // Something went wrong, so we turn BT off again. |
664 // Something went wrong, so we turn BT off again. |
661 SetPowerStateL( EBTOff, EFalse ); |
665 SetPowerStateL( EBTOff, EFalse ); |
662 } |
666 } |
|
667 |
663 if ( !iMessage.IsNull()) |
668 if ( !iMessage.IsNull()) |
664 { |
669 { |
665 iMessage.Complete( aStatus ); |
670 iMessage.Complete( aStatus ); |
666 } |
671 } |
667 TRACE_FUNC_EXIT |
672 TRACE_FUNC_EXIT |
668 } |
673 } |
669 |
674 |
670 // --------------------------------------------------------------------------- |
|
671 // From class MBTEngActiveObserver. |
|
672 // Handles cancelation of an outstanding request |
|
673 // --------------------------------------------------------------------------- |
|
674 // |
|
675 void CBTEngSrvSettingsMgr::CancelRequest( TInt aRequestId ) |
|
676 { |
|
677 TRACE_FUNC_ARG( ( _L( "reqID %d" ), aRequestId ) ); |
|
678 if ( aRequestId == KBTEngSettingsActive ) |
|
679 { |
|
680 iPowerMgr.Cancel(); |
|
681 } |
|
682 TRACE_FUNC_EXIT |
|
683 } |
|
684 |
675 |
685 // --------------------------------------------------------------------------- |
676 // --------------------------------------------------------------------------- |
686 // From class MBTEngActiveObserver. |
677 // From class MBTEngActiveObserver. |
687 // Callback to notify that an error has occurred in RunL. |
678 // Callback to notify that an error has occurred in RunL. |
688 // --------------------------------------------------------------------------- |
679 // --------------------------------------------------------------------------- |
689 // |
680 // |
690 void CBTEngSrvSettingsMgr::HandleError( CBTEngActive* aActive, TInt aError ) |
681 void CBTEngSrvSettingsMgr::HandleError( CBTEngActive* aActive, TInt aId, TInt aError ) |
691 { |
682 { |
692 (void) aActive; |
683 (void) aActive; |
|
684 (void) aId; |
693 if ( !iMessage.IsNull()) |
685 if ( !iMessage.IsNull()) |
694 { |
686 { |
695 iMessage.Complete( aError ); |
687 iMessage.Complete( aError ); |
696 } |
688 } |
697 } |
689 } |
728 TRACE_FUNC_ENTRY |
721 TRACE_FUNC_ENTRY |
729 TBTPowerStateValue powerState = EBTPowerOff; |
722 TBTPowerStateValue powerState = EBTPowerOff; |
730 TBTVisibilityMode visibilityMode = EBTVisibilityModeHidden; |
723 TBTVisibilityMode visibilityMode = EBTVisibilityModeHidden; |
731 CRepository* cenrep = NULL; |
724 CRepository* cenrep = NULL; |
732 TInt phys = 0; |
725 TInt phys = 0; |
733 // TInt connecting = 0; |
726 TInt connecting = 0; |
734 |
727 |
735 cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); |
728 cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); |
736 User::LeaveIfError( cenrep->Get( KBTPowerState, (TInt&) powerState ) ); |
729 User::LeaveIfError( cenrep->Get( KBTPowerState, (TInt&) powerState ) ); |
737 CleanupStack::PopAndDestroy( cenrep ); |
730 CleanupStack::PopAndDestroy( cenrep ); |
738 |
731 |
739 if( powerState == EBTPowerOff ) |
732 if( powerState == EBTPowerOff ) |
740 { |
733 { |
741 SetIndicatorStateL(EBTIndicatorOff); |
734 SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); |
|
735 SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); |
|
736 SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); |
|
737 SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); |
742 } |
738 } |
743 else |
739 else |
744 { |
740 { |
745 // Power is on. |
741 // Power is on. |
746 RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, phys ); |
742 RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, phys ); |
747 // RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting, connecting ); |
743 RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting, connecting ); |
748 |
744 |
749 cenrep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); |
745 cenrep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); |
750 User::LeaveIfError( cenrep->Get( KBTDiscoverable, (TInt&) visibilityMode ) ); |
746 User::LeaveIfError( cenrep->Get( KBTDiscoverable, (TInt&) visibilityMode ) ); |
751 CleanupStack::PopAndDestroy( cenrep ); |
747 CleanupStack::PopAndDestroy( cenrep ); |
752 |
748 |
753 if( visibilityMode == EBTVisibilityModeHidden ) |
749 if( visibilityMode == EBTVisibilityModeHidden ) |
754 { |
750 { |
755 if ( phys > 0 ) // BT connection active and hidden |
751 if ( connecting ) // BT connecting and hidden |
756 { |
752 { |
757 SetIndicatorStateL(EBTIndicatorHiddenConnected); |
753 SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); |
|
754 SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateAnimate ); |
|
755 } |
|
756 else if ( phys > 0 ) // BT connection active and hidden |
|
757 { |
|
758 SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); |
|
759 SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOn ); |
758 } |
760 } |
759 else // BT connection not active and hidden |
761 else // BT connection not active and hidden |
760 { |
762 { |
761 SetIndicatorStateL(EBTIndicatorOnHidden); |
763 SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOn ); |
762 } |
764 SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); |
|
765 } |
|
766 SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); |
|
767 SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); |
763 } |
768 } |
764 else if( visibilityMode == EBTVisibilityModeGeneral || visibilityMode == EBTVisibilityModeTemporary ) |
769 else if( visibilityMode == EBTVisibilityModeGeneral || visibilityMode == EBTVisibilityModeTemporary ) |
765 { |
770 { |
766 if ( phys > 0 ) // BT connection active and visible |
771 if ( connecting ) // BT connecting and visible |
767 { |
772 { |
768 SetIndicatorStateL(EBTIndicatorVisibleConnected); |
773 SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); |
|
774 SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateAnimate ); |
|
775 } |
|
776 else if ( phys > 0 ) // BT connection active and visible |
|
777 { |
|
778 SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); |
|
779 SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOn ); |
769 } |
780 } |
770 else // BT connection not active and visible |
781 else // BT connection not active and visible |
771 { |
782 { |
772 SetIndicatorStateL(EBTIndicatorOnVisible); |
783 SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOn ); |
773 } |
784 SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); |
774 } |
785 } |
775 } |
786 SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); |
776 TRACE_FUNC_EXIT |
787 SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); |
777 } |
788 } |
778 |
789 } |
779 void CBTEngSrvSettingsMgr::SetIndicatorStateL( const TInt aState ) |
790 TRACE_FUNC_EXIT |
780 { |
791 } |
781 TBool success = EFalse; |
792 |
782 if(iIndicatorState != aState) |
793 |
783 { |
794 // --------------------------------------------------------------------------- |
784 CHbSymbianVariant* parameters = CHbSymbianVariant::NewL(&aState,CHbSymbianVariant::EInt ); |
795 // ?implementation_description |
785 success = iBTIndicator->Activate(KIndicatorType(),parameters); |
796 // --------------------------------------------------------------------------- |
786 delete parameters; |
797 // |
787 if(!success) |
798 void CBTEngSrvSettingsMgr::SetIndicatorStateL( const TInt aIndicator, const TInt aState ) |
788 { |
799 { |
789 User::Leave(iBTIndicator->Error()); |
800 CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC( TUid::Uid( aIndicator ) ); |
790 } |
801 indicator->SetIndicatorStateL( aState ); |
791 iIndicatorState = aState; |
802 CleanupStack::PopAndDestroy( indicator ); //indicator |
792 } |
|
793 } |
803 } |
794 |
804 |
795 |
805 |
796 // --------------------------------------------------------------------------- |
806 // --------------------------------------------------------------------------- |
797 // Gets the current HW power state. |
807 // Gets the current HW power state. |