diff -r 613943a21004 -r 9386f31cc85b bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp --- a/bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp Tue Aug 31 15:25:10 2010 +0300 +++ b/bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp Wed Sep 01 12:20:04 2010 +0100 @@ -22,14 +22,14 @@ #include #include #include +#include +#include + #include "btengserver.h" #include "btengsrvpluginmgr.h" #include "btengsrvbbconnectionmgr.h" #include "btengsrvstate.h" #include "debug.h" -#include -#include -#include /** ID of active object helper */ const TInt KBTEngSettingsActive = 30; @@ -49,7 +49,7 @@ // --------------------------------------------------------------------------- // CBTEngSrvSettingsMgr::CBTEngSrvSettingsMgr( CBTEngServer* aServer ) -: iServer( aServer ),iIndicatorState(-1) +: iServer( aServer ) { } @@ -62,7 +62,6 @@ { TRACE_FUNC_ENTRY iActive = CBTEngActive::NewL( *this, KBTEngSettingsActive ); - iBTIndicator = CHbIndicatorSymbian::NewL(); LoadBTPowerManagerL(); iEnterpriseEnablementMode = BluetoothFeatures::EnterpriseEnablementL(); TRACE_INFO( ( _L( "iEnterpriseEnablementMode = %d" ), iEnterpriseEnablementMode) ) @@ -94,8 +93,12 @@ // CBTEngSrvSettingsMgr::~CBTEngSrvSettingsMgr() { + if( iActive && iActive->IsActive() ) + { + // Cancel the outstanding request. + iPowerMgr.Cancel(); + } delete iActive; - delete iBTIndicator; iPowerMgr.Close(); } @@ -181,11 +184,11 @@ if ( currentState == aState ) { // Make sure that the CenRep key is in sync. - // During boot-up, the power is set from the CenRep key, so we could + // During boot-up, the pwoer is set from the CenRep key, so we could // end up out-of-sync. TRACE_INFO( ( _L( "SetPowerStateL: currentState == aState" ) ) ) - HandleHwPowerChangeL( aState ); - } + UpdateCenRepPowerKeyL( aState ); + } return; } if ( aState == EBTOn ) @@ -315,20 +318,21 @@ // --------------------------------------------------------------------------- -// Update the power state CenRep key, and start BTNotif server if BT is on. +// Update the power state CenRep key. // --------------------------------------------------------------------------- // -void CBTEngSrvSettingsMgr::HandleHwPowerChangeL( TBTPowerState aState ) +void CBTEngSrvSettingsMgr::UpdateCenRepPowerKeyL( TBTPowerState aState ) { TRACE_FUNC_ENTRY CRepository* cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); // TBTPowerState power state type is inverted from TBTPowerStateValue... - TBTPowerStateValue power = ( aState == EBTOn ) ? EBTPowerOn : EBTPowerOff; + TBTPowerStateValue power = (TBTPowerStateValue) !aState; User::LeaveIfError( cenrep->Set( KBTPowerState, (TInt) power ) ); CleanupStack::PopAndDestroy( cenrep ); TRACE_FUNC_EXIT } + // --------------------------------------------------------------------------- // ?implementation_description // --------------------------------------------------------------------------- @@ -650,9 +654,9 @@ // Callback to notify that an outstanding request has completed. // --------------------------------------------------------------------------- // -void CBTEngSrvSettingsMgr::RequestCompletedL( CBTEngActive* aActive, TInt aStatus ) +void CBTEngSrvSettingsMgr::RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ) { - __ASSERT_ALWAYS( aActive->RequestId() == KBTEngSettingsActive, PanicServer( EBTEngPanicCorrupt ) ); + __ASSERT_ALWAYS( aId == KBTEngSettingsActive, PanicServer( EBTEngPanicCorrupt ) ); TRACE_FUNC_ENTRY (void) aActive; if ( aStatus != KErrNone && aStatus != KErrAlreadyExists && aStatus != KErrCancel ) @@ -660,6 +664,7 @@ // Something went wrong, so we turn BT off again. SetPowerStateL( EBTOff, EFalse ); } + if ( !iMessage.IsNull()) { iMessage.Complete( aStatus ); @@ -667,29 +672,16 @@ TRACE_FUNC_EXIT } -// --------------------------------------------------------------------------- -// From class MBTEngActiveObserver. -// Handles cancelation of an outstanding request -// --------------------------------------------------------------------------- -// -void CBTEngSrvSettingsMgr::CancelRequest( TInt aRequestId ) - { - TRACE_FUNC_ARG( ( _L( "reqID %d" ), aRequestId ) ); - if ( aRequestId == KBTEngSettingsActive ) - { - iPowerMgr.Cancel(); - } - TRACE_FUNC_EXIT - } // --------------------------------------------------------------------------- // From class MBTEngActiveObserver. // Callback to notify that an error has occurred in RunL. // --------------------------------------------------------------------------- // -void CBTEngSrvSettingsMgr::HandleError( CBTEngActive* aActive, TInt aError ) +void CBTEngSrvSettingsMgr::HandleError( CBTEngActive* aActive, TInt aId, TInt aError ) { (void) aActive; + (void) aId; if ( !iMessage.IsNull()) { iMessage.Complete( aError ); @@ -707,6 +699,7 @@ TRACE_INFO( ( _L( "[CBTEngSrvSettingsMgr]\t Using HCI API v2 power manager" ) ) ) User::LeaveIfError( iPowerMgr.Open() ); #ifndef __WINS__ + TRequestStatus reqStatus; iPowerMgr.SetPower( EBTOff, NULL, reqStatus ); User::WaitForRequest( reqStatus ); @@ -730,7 +723,7 @@ TBTVisibilityMode visibilityMode = EBTVisibilityModeHidden; CRepository* cenrep = NULL; TInt phys = 0; - // TInt connecting = 0; + TInt connecting = 0; cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); User::LeaveIfError( cenrep->Get( KBTPowerState, (TInt&) powerState ) ); @@ -738,13 +731,16 @@ if( powerState == EBTPowerOff ) { - SetIndicatorStateL(EBTIndicatorOff); + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); } else { // Power is on. RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, phys ); - // RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting, connecting ); + RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting, connecting ); cenrep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); User::LeaveIfError( cenrep->Get( KBTDiscoverable, (TInt&) visibilityMode ) ); @@ -752,44 +748,58 @@ if( visibilityMode == EBTVisibilityModeHidden ) { - if ( phys > 0 ) // BT connection active and hidden + if ( connecting ) // BT connecting and hidden { - SetIndicatorStateL(EBTIndicatorHiddenConnected); + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateAnimate ); + } + else if ( phys > 0 ) // BT connection active and hidden + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOn ); } else // BT connection not active and hidden { - SetIndicatorStateL(EBTIndicatorOnHidden); + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOn ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); } + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); } else if( visibilityMode == EBTVisibilityModeGeneral || visibilityMode == EBTVisibilityModeTemporary ) { - if ( phys > 0 ) // BT connection active and visible + if ( connecting ) // BT connecting and visible { - SetIndicatorStateL(EBTIndicatorVisibleConnected); + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateAnimate ); + } + else if ( phys > 0 ) // BT connection active and visible + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOn ); } else // BT connection not active and visible { - SetIndicatorStateL(EBTIndicatorOnVisible); + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOn ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); } + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); } } TRACE_FUNC_EXIT } -void CBTEngSrvSettingsMgr::SetIndicatorStateL( const TInt aState ) + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SetIndicatorStateL( const TInt aIndicator, const TInt aState ) { - TBool success = EFalse; - if(iIndicatorState != aState) - { - CHbSymbianVariant* parameters = CHbSymbianVariant::NewL(&aState,CHbSymbianVariant::EInt ); - success = iBTIndicator->Activate(KIndicatorType(),parameters); - delete parameters; - if(!success) - { - User::Leave(iBTIndicator->Error()); - } - iIndicatorState = aState; - } + CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC( TUid::Uid( aIndicator ) ); + indicator->SetIndicatorStateL( aState ); + CleanupStack::PopAndDestroy( indicator ); //indicator } @@ -878,4 +888,3 @@ } TRACE_FUNC_EXIT } -