--- a/bluetoothengine/bteng/btbearer/src/btpluginnotifier.cpp Thu Aug 19 10:05:41 2010 +0300
+++ b/bluetoothengine/bteng/btbearer/src/btpluginnotifier.cpp Tue Aug 31 15:25:10 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -23,6 +23,9 @@
#include "btpluginnotifier.h"
#include "debug.h"
#include <btfeaturescfg.h>
+#include <btnotifclient.h>
+#include "btindicatorconstants.h"
+#include <hbsymbianvariant.h>
// ======== MEMBER FUNCTIONS ========
@@ -59,6 +62,7 @@
delete repository;
CBTEngSettings* settings = CBTEngSettings::NewL();
+ iBTIndicator = CHbIndicatorSymbian::NewL();
BluetoothFeatures::TEnterpriseEnablementMode mode = BluetoothFeatures::EnterpriseEnablementL();
TRACE_INFO( ( _L( "mode = %d" ), mode) )
@@ -68,15 +72,23 @@
TRACE_INFO( ( _L( "Turning BT on" ) ) )
TInt err = settings->SetPowerState( EBTPowerOn );
TRACE_INFO( ( _L( "SetPowerState returned %d" ), err ) )
- if( !err )
+ if ( !err )
{
- iHandler.NotifyBearerStatus( ELocodBearerBT, power );
+ HandleBtPowerChanged( EBTPowerOn );
}
}
else
{
TRACE_INFO( ( _L( "Turning BT off" ) ) )
(void) settings->SetPowerState( EBTPowerOff ); // Result is not important here
+ TInt state = EBTIndicatorOff;
+ CHbSymbianVariant* parameters = CHbSymbianVariant::NewL(&state,CHbSymbianVariant::EInt );
+ TBool success = iBTIndicator->Activate(KIndicatorType(),parameters);
+ delete parameters;
+ if(!success)
+ {
+ User::Leave(iBTIndicator->Error());
+ }
}
delete settings;
if ( mode != BluetoothFeatures::EDisabled ) // only subscribe if there's any point (NB changing Enterprise Disabling mode requires a reboot)
@@ -111,6 +123,7 @@
TRACE_FUNC_ENTRY
Cancel();
delete iSession;
+ delete iBTIndicator;
}
@@ -129,6 +142,30 @@
SetActive();
}
+// ---------------------------------------------------------------------------
+// Handles power state change. Inform Locod. In addition, if BT is on, start
+// btnotifier server.
+// ---------------------------------------------------------------------------
+//
+void CBTPluginNotifier::HandleBtPowerChanged( TBTPowerStateValue aPower )
+ {
+ TRACE_FUNC_ARG( ( _L( " to %d" ), aPower ) )
+ TInt err (KErrNone );
+ if ( aPower == EBTPowerOn )
+ {
+ // Start BT notifier server by creating a session with it:
+ RBTNotifier btnotif;
+ err = btnotif.Connect();
+ TRACE_INFO( ( _L( "start bt notifier server %d" ), err ) )
+ // btnotif server manages its lifecycle. no need
+ // to keep this session:
+ btnotif.Close();
+ }
+ if ( !err )
+ {
+ iHandler.NotifyBearerStatus( ELocodBearerBT, aPower );
+ }
+ }
// ---------------------------------------------------------------------------
// From class CActive.
@@ -162,9 +199,12 @@
case EKeyInt:
{
TRACE_INFO( ( _L( "[CBTPluginNotifier::RunL2 %d]" ), status ) )
- TInt newValue = 1;
- iSession->Get( iId, newValue );
- iHandler.NotifyBearerStatus( ELocodBearerBT, newValue );
+ TInt newValue = EBTPowerOff;
+ TInt err = iSession->Get( iId, newValue );
+ if ( !err )
+ {
+ HandleBtPowerChanged( static_cast<TBTPowerStateValue>( newValue ) );
+ }
}
break;
default: