# HG changeset patch # User hgs # Date 1272056080 -10800 # Node ID 8930e1d1d530e069305b08c7ac03d63880b02597 # Parent 988cddd6adbd6877380fa6c5f05d1dd484654d67 201009 diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btaudioman/src/BTAccSession.cpp --- a/bluetoothengine/btaudioman/src/BTAccSession.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btaudioman/src/BTAccSession.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -253,6 +253,11 @@ //finished with the accessory info array infos.Close(); + if(buf.Length() <= 0) + { + ret = KErrNotFound; + } + //if there is no error and the buffer has something in, //write the buffer to the message if (ret == KErrNone) diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btaudioman/src/basrvaccstatequery.cpp --- a/bluetoothengine/btaudioman/src/basrvaccstatequery.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btaudioman/src/basrvaccstatequery.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -133,7 +133,7 @@ if ( ( AccInfo().iConnProfiles & EHFP ) && AccInfo().iSupportedFeatures[TAccInfo::EHFPIndex] == 0 ) { - CBTAccPlugin* plugin = Parent().AccMan().PluginMan().Plugin(EHFP);; + CBTAccPlugin* plugin = Parent().AccMan().PluginMan().Plugin(EHFP); AccInfo().SetSupportedFeature((TUint16)plugin->GetRemoteSupportedFeature(), TAccInfo::EHFPIndex); } diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btaudioman/src/btaudiomanplugin.cpp --- a/bluetoothengine/btaudioman/src/btaudiomanplugin.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btaudioman/src/btaudiomanplugin.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -129,6 +129,7 @@ void CBtAudioManPlugin::GetConnections( RBTDevAddrArray& aAddrArray, TBTProfile aConnectedProfile ) { + TRACE_FUNC aAddrArray.Reset(); TProfiles profile = EUnknownProfile; @@ -149,7 +150,6 @@ TInt numAddresses = 2; TInt count = numAddresses; RBuf8 addrbuf; - TPtrC8 ptr(addrbuf); do { @@ -187,6 +187,8 @@ //maybe another connection was established while this was taking place while (count > numAddresses); + TPtrC8 ptr(addrbuf); + //iterate through the addresses buffer while (ptr.Length() >= KBTDevAddrSize) { diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bteng/data/btrfs.txt Binary file bluetoothengine/bteng/data/btrfs.txt has changed diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bteng/group/backup_registration.xml --- a/bluetoothengine/bteng/group/backup_registration.xml Fri Apr 23 23:38:44 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bteng/group/bld.inf --- a/bluetoothengine/bteng/group/bld.inf Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bteng/group/bld.inf Fri Apr 23 23:54:40 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" @@ -39,11 +39,6 @@ ../conf/bteng_10204DAB.crml MW_LAYER_CRML(bteng_10204DAB.crml) ../conf/bteng_10204DAC.crml MW_LAYER_CRML(bteng_10204DAC.crml) - -// Backup registration file -backup_registration.xml /epoc32/data/z/private/10005950/backup_registration.xml -backup_registration.xml /epoc32/release/winscw/udeb/z/private/10005950/backup_registration.xml -backup_registration.xml /epoc32/release/winscw/urel/z/private/10005950/backup_registration.xml ../data/btrfs.txt /epoc32/data/z/resource/btrfs.txt ../data/btrfs.txt /epoc32/release/winscw/udeb/z/resource/btrfs.txt ../data/btrfs.txt /epoc32/release/winscw/urel/z/resource/btrfs.txt diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bteng/inc/btengpairman.h --- a/bluetoothengine/bteng/inc/btengpairman.h Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bteng/inc/btengpairman.h Fri Apr 23 23:54:40 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-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" @@ -167,6 +167,16 @@ void ConstructL(); /** + * Initialiases the paired devices list + */ + void InitPairedDevicesList(); + + /** + * Initialises the paired devices list (second stage) + */ + void DoInitPairedDevicesList(); + + /** * Activate / deactivate a pair observer */ TInt SetPairObserver(const TBTDevAddr& aAddr, TBool aActivate); @@ -320,6 +330,26 @@ * Client-server message for power change requests. */ RMessage2 iMessage; + + /** + * AO for local address updates. + */ + CBTEngActive* iLocalAddrActive; + + /** + * Provides access to the BT local device address. + */ + RProperty iPropertyLocalAddr; + + /** + * Records whether or not this CBTEngPairMan has ever been involed in a pairing operaton. + */ + TBool iPairingOperationAttempted; + + /** + * Counter of unhandled paired device view initialisation requests. + */ + TInt iNotHandledInitEventCounter; }; #endif /*BTENGPAIRMANAGER_H_*/ diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bteng/rom/bteng.iby --- a/bluetoothengine/bteng/rom/bteng.iby Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bteng/rom/bteng.iby Fri Apr 23 23:54:40 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2003-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" @@ -29,7 +29,6 @@ file=ABI_DIR\BUILD_DIR\btengdiscovery.dll SHARED_LIB_DIR\btengdiscovery.dll file=ABI_DIR\BUILD_DIR\btfeatures.dll SHARED_LIB_DIR\btfeatures.dll file=ABI_DIR\BUILD_DIR\btengsettings.dll SHARED_LIB_DIR\btengsettings.dll -data=ZPRIVATE\10005950\backup_registration.xml private\10005950\backup_registration.xml data=ZPRIVATE\10003A3F\APPS\bttoggle_reg.rsc Private\10003a3f\apps\bttoggle_reg.rsc data=DATAZ_\RESOURCE_FILES_DIR\btengsdp.rsc RESOURCE_FILES_DIR\btengsdp.rsc data=DATAZ_\RESOURCE_FILES_DIR\btrfs.txt RESOURCE_FILES_DIR\btrfs.txt diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bteng/src/btengpairman.cpp --- a/bluetoothengine/bteng/src/btengpairman.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bteng/src/btengpairman.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-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" @@ -33,6 +33,7 @@ ERegistryPairedDevicesNewView, ERegistryInitiatePairedDevicesList, ERegistryGetPairedDevices, + ERegistryGetLocalAddress, }; /** The message argument which holds the Bluetooth address. */ @@ -81,16 +82,20 @@ User::LeaveIfError( iAuthenResult.Open( *iPairingServ ) ); iSSPResultActive = CBTEngActive::NewL( *this, ESimplePairingResult, CActive::EPriorityStandard ); iAuthenResultActive = CBTEngActive::NewL( *this, EAuthenticationResult, CActive::EPriorityStandard ); - SubscribeSspPairingResult(); - SubscribeAuthenticateResult(); } + // RProperty for accessing the local device address + User::LeaveIfError( iPropertyLocalAddr.Attach(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetLocalDeviceAddress) ); + // connect to registry User::LeaveIfError( iBTRegistry.Open( BTRegServ() ) ); iRegistryActive = CBTEngActive::NewL( *this, ERegistryInitiatePairedDevicesView, CActive::EPriorityStandard ); - // Start to get the list of all paired devices. - CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); - iPairedDevices = new (ELeave) RArray; + iPairedDevices = new (ELeave) RArray; + + // Initialise paired devices list + iLocalAddrActive = CBTEngActive::NewL( *this, ERegistryGetLocalAddress, CActive::EPriorityStandard ); + InitPairedDevicesList(); + TRACE_FUNC_EXIT } @@ -138,6 +143,85 @@ { iMessage.Complete( KErrCancel ); } + iPropertyLocalAddr.Cancel(); + iPropertyLocalAddr.Close(); + delete iLocalAddrActive; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Initialises the paired devices list. +// If the local address is not available from the P&S key +// KPropertyKeyBluetoothGetLocalDeviceAddress, then the list may need to be +// updated once the H/W is switched on. This is so that any registry update +// from a restore operation can be included in the list, without mistaking the +// new devices for new pairings. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::InitPairedDevicesList() + { + TRACE_FUNC_ENTRY + + // Check that we have the Bluetooth local address. If we don't then initialise anyway, but subscribe for an update. + // This allows us to refresh our paired devices list to include updates made to the remote devices table of the + // Bluetooth registry from a restore operation. We need to include these devices without mistaking them for new + // pairings. We look solely at the P&S key for the address to avoid the condition whereby the address has been + // entered into the reigstry but the Bluetooth Manager server has not begun the restore process yet. The signalling + // of the P&S key will cause Bluetooth Manager to update the registry with any restored devices before fulfilling + // any further requests. + + // Subscribe to local address property in case we need an update. + iPropertyLocalAddr.Subscribe( iLocalAddrActive->iStatus ); + iLocalAddrActive->SetRequestId( ERegistryGetLocalAddress ); + iLocalAddrActive->GoActive(); + + // Attempt to read address from P&S key. + TBuf8 btAddrDes; + TInt err = iPropertyLocalAddr.Get( btAddrDes ); + + // Is the P&S key defined yet? (if not, stack not up yet) + if ( err == KErrNone ) + { + // P&S key defined, is local address set? (if not, H/W not initialised yet) + if ( btAddrDes.Length() == KBTDevAddrSize ) + { + TBTDevAddr btAddr = btAddrDes; + + if ( btAddr != TBTDevAddr() ) + { + // Non-zero local address is available. + iPropertyLocalAddr.Cancel(); + iLocalAddrActive->CancelRequest(); + } + } + } + + // Perform initialisation of the paired devices list. + DoInitPairedDevicesList(); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Initialises the paired devices list (second stage) +// This method performs the actual initialisation, now that the local BT H/W +// address had been made available. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::DoInitPairedDevicesList() + { + TRACE_FUNC_ENTRY + + if ( !iRegistryActive->IsActive() ) + { + // Start to get the list of all paired devices. + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + else + { + iNotHandledInitEventCounter++; + } + TRACE_FUNC_EXIT } @@ -294,24 +378,34 @@ if ( index > KErrNotFound ) { dev = (*iPairedDevices)[index]; - TBTDeviceSecurity security = dev.GlobalSecurity(); - // Clear trust setting so that correct icon will be shown in ui applications. - security.SetNoAuthenticate(EFalse ); - security.SetNoAuthorise(EFalse ); - dev.SetGlobalSecurity(security); - dev.DeleteLinkKey(); - if ( dev.IsValidUiCookie() && - ( dev.UiCookie() & EBTUiCookieJustWorksPaired ) ) + + TRequestStatus status( KRequestPending ); + // Unpair the device in registry (synchronously) + iBTRegistry.UnpairDevice( dev.Address(), status ); + User::WaitForRequest( status ); + TRACE_INFO( ( _L( "Delete link key, res %d"), status.Int() ) ) + + if ( status == KErrNone ) { - // Remove the UI cookie bit for Just Works pairing. - TInt32 cookie = dev.UiCookie() & ~EBTUiCookieJustWorksPaired; - dev.SetUiCookie( cookie ); - TRACE_INFO( ( _L( "UI cookie %x cleared"), EBTUiCookieJustWorksPaired ) ); + TBTDeviceSecurity security = dev.GlobalSecurity(); + // Clear trust setting so that correct icon will be shown in ui applications. + security.SetNoAuthenticate(EFalse ); + security.SetNoAuthorise(EFalse ); + dev.SetGlobalSecurity(security); + dev.DeleteLinkKey(); + if ( dev.IsValidUiCookie() && + ( dev.UiCookie() & EBTUiCookieJustWorksPaired ) ) + { + // Remove the UI cookie bit for Just Works pairing. + TInt32 cookie = dev.UiCookie() & ~EBTUiCookieJustWorksPaired; + dev.SetUiCookie( cookie ); + TRACE_INFO( ( _L( "UI cookie %x cleared"), EBTUiCookieJustWorksPaired ) ); + } + // modify the device in registry synchronously + // status.Int() could be -1 if the device is not in registry + // which is totally fine for us. + (void) UpdateRegDevice( dev ); } - // modify the device in registry synchronously - // status.Int() could be -1 if the device is not in registry - // which is totally fine for us. - (void) UpdateRegDevice( dev ); } TRACE_FUNC_EXIT } @@ -396,11 +490,26 @@ break; } case ERegistryInitiatePairedDevicesList: + { + if (iSSPResultActive && iAuthenResultActive) + { + SubscribeSspPairingResult(); + SubscribeAuthenticateResult(); + } + HandleGetPairedDevicesCompletedL( aStatus, aId ); + break; + } case ERegistryGetPairedDevices: { HandleGetPairedDevicesCompletedL( aStatus, aId ); break; } + case ERegistryGetLocalAddress: + { + // Refresh paired devices list to include any restored devices. + DoInitPairedDevicesList(); + break; + } default: // Should not be possible, but no need for handling. TRACE_INFO( (_L("[BTEng]: CBTEngPairMan::RequestCompletedL unhandled event!!") ) ) @@ -434,6 +543,7 @@ { TRACE_FUNC_ARG( ( _L( "%d" ), aActivate ) ) TRACE_BDADDR( aAddr ) + iPairingOperationAttempted = ETrue; TInt err( KErrNone ); if ( !aActivate ) { @@ -466,6 +576,7 @@ // void CBTEngPairMan::PairDeviceL( const TBTDevAddr& aAddr, TUint32 aCod ) { + iPairingOperationAttempted = ETrue; if ( !iPairer) { // no existing pair handling, create one: @@ -499,27 +610,35 @@ } // --------------------------------------------------------------------------- -// Subscribes to simple pairing result from Pairing Server +// Subscribes to simple pairing result from Pairing Server (if not already +// subscribed). // --------------------------------------------------------------------------- // void CBTEngPairMan::SubscribeSspPairingResult() { TRACE_FUNC_ENTRY - iPairingResult.SimplePairingResult( iSimplePairingRemote, iSSPResultActive->RequestStatus() ); - iSSPResultActive->GoActive(); + if ( !iSSPResultActive->IsActive() ) + { + iPairingResult.SimplePairingResult( iSimplePairingRemote, iSSPResultActive->RequestStatus() ); + iSSPResultActive->GoActive(); + } TRACE_FUNC_EXIT } // --------------------------------------------------------------------------- -// Subscribes to authentication result from Pairing Server +// Subscribes to authentication result from Pairing Server (if not already +// subscribed). // --------------------------------------------------------------------------- // void CBTEngPairMan::SubscribeAuthenticateResult() { TRACE_FUNC_ENTRY - // Subscribe authentication result (which requires pairing for unpaired devices) - iAuthenResult.AuthenticationResult( iAuthenticateRemote, iAuthenResultActive->RequestStatus() ); - iAuthenResultActive->GoActive(); + if ( !iAuthenResultActive->IsActive() ) + { + // Subscribe authentication result (which requires pairing for unpaired devices) + iAuthenResult.AuthenticationResult( iAuthenticateRemote, iAuthenResultActive->RequestStatus() ); + iAuthenResultActive->GoActive(); + } TRACE_FUNC_EXIT } @@ -570,7 +689,14 @@ void CBTEngPairMan::CreatePairedDevicesView( TInt aReqId ) { TRACE_FUNC_ENTRY - iNotHandledRegEventCounter = 0; + if ( aReqId == ERegistryInitiatePairedDevicesView ) + { + iNotHandledInitEventCounter = 0; + } + else + { + iNotHandledRegEventCounter = 0; + } TBTRegistrySearch searchPattern; searchPattern.FindBonded(); iRegistryActive->SetRequestId( aReqId ); @@ -608,8 +734,14 @@ TRACE_FUNC_ENTRY if ( aReqId == ERegistryInitiatePairedDevicesView ) - {// Initialization phase, list paired devices if there are. - if ( aStatus > KErrNone ) + {// Initialization phase, list paired devices if there are any. + if ( iNotHandledInitEventCounter ) + { + // Reinitialisaton detected, create paired device view again: + (void) iBTRegistry.CloseView(); + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + else if ( aStatus > KErrNone ) { GetPairedDevices( ERegistryInitiatePairedDevicesList ); } @@ -620,7 +752,25 @@ } else { - if (iNotHandledRegEventCounter) + if ( iNotHandledInitEventCounter ) + { + // We need to reinitialise but we may be pairing. + // This situation is not expected to arise, as reinitialisation means + // that the H/W was only just switched on. + // If we have ever started to take part in a pairing, then prioritise that + // pairing. + (void) iBTRegistry.CloseView(); + if ( iPairingOperationAttempted ) + { + iNotHandledInitEventCounter = 0; + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else + { + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + } + else if (iNotHandledRegEventCounter) { // more registry change detected, create paired device view again: (void) iBTRegistry.CloseView(); CreatePairedDevicesView( ERegistryPairedDevicesNewView ); @@ -650,19 +800,46 @@ (void) iBTRegistry.CloseView(); if ( aReqId == ERegistryInitiatePairedDevicesList ) { - // We completed the initialization of paired device list, - // move all paired devices to the array: - UpdatePairedDeviceListL(); + if ( iNotHandledInitEventCounter ) + { + // Reinitialisation required, create paired device view again: + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + else + { + // We completed the initialisation of paired device list, + // move all paired devices to the array: + UpdatePairedDeviceListL(); + } } - - if (iNotHandledRegEventCounter) - { // more registry change detected, create paired device view again: - CreatePairedDevicesView( ERegistryPairedDevicesNewView ); - } - else if ( aReqId == ERegistryGetPairedDevices) + else { - // no more registry change detected, find new pairings: - CheckPairEventL(); + if (iNotHandledInitEventCounter) + { + // We need to reinitialise but we may be pairing. + // This situation is not expected to arise, as reinitialisation means + // that the H/W was only just switched on. + // If we have ever started to take part in a pairing, then prioritise that + // pairing. + if ( iPairingOperationAttempted ) + { + iNotHandledInitEventCounter = 0; + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else + { + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + } + else if (iNotHandledRegEventCounter) + { // more registry change detected, create paired device view again: + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else if ( aReqId == ERegistryGetPairedDevices) + { + // no more registry change detected, find new pairings: + CheckPairEventL(); + } } TRACE_FUNC_EXIT @@ -721,9 +898,10 @@ TRACE_BDADDR( dev.Address() ); if ( newPaired && !iPairer) { + iPairingOperationAttempted = ETrue; iPairer = CBTEngIncPair::NewL( *this, dev.Address() ); } - if ( iPairer ) + if ( newPaired && iPairer ) { // Ask pair handler to decide what to do: iPairer->HandleRegistryNewPairedEvent( dev ); diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp --- a/bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -632,7 +632,7 @@ return; } - if (powerState == EBTOn) + if (powerState == EBTPowerOn) { #ifndef __WINS__ diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/bthidclient/inc/bthidclient.h --- a/bluetoothengine/bthid/bthidclient/inc/bthidclient.h Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/bthidclient/inc/bthidclient.h Fri Apr 23 23:54:40 2010 +0300 @@ -31,6 +31,7 @@ enum TBTHidConnState { EBTDeviceConnected, /*!< Device connected */ + EBTDeviceConnectedFromRemote, /*!< Device connected from remote HID device */ EBTDeviceLinkLost, /*!< Device link lost */ EBTDeviceLinkRestored, /*!< Device link restored */ EBTDeviceDisconnected, /*!< Device disconnected */ diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/bthidengplugin/src/bthidengplugin.cpp --- a/bluetoothengine/bthid/bthidengplugin/src/bthidengplugin.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/bthidengplugin/src/bthidengplugin.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -137,7 +137,8 @@ THIDStateUpdate& HIDStateUpdate = iHIDStateUpdatePckg(); if (HIDStateUpdate.iState == EBTDeviceConnected - || HIDStateUpdate.iState == EBTDeviceLinkRestored) + || HIDStateUpdate.iState == EBTDeviceLinkRestored + || HIDStateUpdate.iState == EBTDeviceConnectedFromRemote) { retStatus = ETrue; ReportProfileConnectionEvents(HIDStateUpdate.iDeviceAddress, diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/bthidserver/inc/btconnectionobserver.h --- a/bluetoothengine/bthid/bthidserver/inc/btconnectionobserver.h Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/bthidserver/inc/btconnectionobserver.h Fri Apr 23 23:54:40 2010 +0300 @@ -56,6 +56,19 @@ @param aStatus KErrNone, or system error code. */ virtual void FirstTimeConnectionComplete(TInt aConnID, TInt aStatus) = 0; + + /*! + Report a change in the connection status + @param aConnID connection id + @param aStatus KErrNone, or system error code. + */ + virtual void FirstTimeConnectionCompleteFromRemote(TInt aConnID, TInt aStatus) = 0; + + /*! + Start SDP on remote HID device + @param aConnID connection id + */ + virtual void StartSDPSearch(TInt aConnID) = 0; /*! Reports that a connection has entered the link loss state diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/bthidserver/inc/bthidconnection.h --- a/bluetoothengine/bthid/bthidserver/inc/bthidconnection.h Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidconnection.h Fri Apr 23 23:54:40 2010 +0300 @@ -57,7 +57,8 @@ EHostReconnecting, /*!< Host is reconnecting to the device */ EHIDReconnecting, /*!< The device is reconnection to the host */ EDisconnecting, /*!< The connection is being closed */ - EConnecting + EConnecting, /*!< The connection is being set up from phone side */ + EHIDInitConnecting /*!< The connection is being set up from remote HID */ }; /*! diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/bthidserver/inc/bthidserver.h --- a/bluetoothengine/bthid/bthidserver/inc/bthidserver.h Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidserver.h Fri Apr 23 23:54:40 2010 +0300 @@ -37,12 +37,15 @@ #include "genericserver.h" #include "hidlayoutids.h" #include "genericactive.h" +#include "hidsdpobserver.h" +#include "bthidconnection.h" class CBTConnection; class CSocketListener; class CBTHidConnection; class CBTHidDevice; class CGenericHid; +class CHidSdpClient; class CBTHidNotifierHelper; /** @@ -53,7 +56,8 @@ class CBTHidServer : public CGenericServer, public MBTConnectionObserver, public MListenerObserver, - public MTransportLayer + public MTransportLayer, + public MHidSdpObserver { public: @@ -117,7 +121,7 @@ Asks the server to create a new connection object. @result ID for the connection */ - TInt NewConnectionL(); + TInt NewConnectionL(TBTConnectionState aConnectionState); /*! Asks the server to do a first-time connection to a device. @@ -151,7 +155,15 @@ @result TBTEngConnectionStatus */ TBTEngConnectionStatus ConnectStatus(const TBTDevAddr& aAddress); - + + /*! + Finds out the connection status for a given Bluetooth address connected with HID profile + @param aBDAddr reference to TBTAddr that is checked from Bluetooth registry + @result ETrue device is found from Container + EFalse device is not found from Container + */ + TBool DeviceExistInContainer(const TBTDevAddr& aAddress); + /*! Panic the server. @param aPanic panic code @@ -177,6 +189,8 @@ void HandleInterruptData(TInt aConnID, const TDesC8& aBuffer); void FirstTimeConnectionComplete(TInt aConnID, TInt aStatus); + + void FirstTimeConnectionCompleteFromRemote(TInt aConnID, TInt aStatus); void LinkLost(TInt aConnID); @@ -185,10 +199,17 @@ void Disconnected(TInt aConnID); void Unplugged(TInt aConnID); + + void StartSDPSearch(TInt aConnID); public: //from MListenerObserver void SocketAccepted(TUint aPort, TInt aErrorCode); + +public: + // from MHidSdpObserver + + void HidSdpSearchComplete(TInt aResult); public: //from MTransportLayer @@ -363,7 +384,12 @@ RNotifier iNotifier; RPointerArray iReqs; - + + /*! The ID given to this connection */ + TInt iConnID; + + /*! A hid sdp client */ + CHidSdpClient* iHidSdpClient; }; diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/bthidserver/src/bthidconnection.cpp --- a/bluetoothengine/bthid/bthidserver/src/bthidconnection.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/bthidserver/src/bthidconnection.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -103,7 +103,9 @@ { // We shouldn't be trying to set the id for this connection // after it is connected. - __ASSERT_DEBUG(iConnectionState == ENotConnected || iConnectionState == EConnecting, + __ASSERT_DEBUG(iConnectionState == ENotConnected || + iConnectionState == EConnecting || + iConnectionState == EHIDInitConnecting , User::Panic(KPanicBTConnection, ESocketsBadState)); iConnID = aConnID; @@ -214,7 +216,7 @@ (_L("[BTHID]\tCBTHidConnection::OfferControlSocket")); if (aAddress == iDevice->iAddress) { - __ASSERT_DEBUG((iConnectionState == ELinkLost) || + __ASSERT_DEBUG((iConnectionState == ELinkLost) || (iConnectionState == EHIDInitConnecting) || (iConnectionState == EHIDReconnecting), User::Panic(KPanicBTConnection, ESocketsBadState)); @@ -223,8 +225,11 @@ iControlSocket = aSocket; aSocket = 0; - // Mark that the HID Device is reconnecting to us. - ChangeState(EHIDReconnecting); + // Mark that the HID Device is reconnecting to us. Skip the state change if an initial connection from HID device. + if (iConnectionState != EHIDInitConnecting) + { + ChangeState(EHIDReconnecting); + } } } @@ -236,7 +241,7 @@ if (aAddress == iDevice->iAddress) { - __ASSERT_DEBUG((iConnectionState == EHIDReconnecting), //||(iConnectionState == ELinkLost) , + __ASSERT_DEBUG((iConnectionState == EHIDReconnecting) ||(iConnectionState == EHIDInitConnecting) , User::Panic(KPanicBTConnection, ESocketsBadState)); // Take ownership of this socket @@ -248,18 +253,35 @@ if (KErrNone == error) { // Mark that we are now reconnected. - + TBTConnectionState prevState = iConnectionState; ChangeState(EConnected); - // Inform the observer that the connection has been restored. - iObserver.LinkRestored(iConnID); - + if (prevState == EHIDInitConnecting) + { + // If this was an remote HID initial connection, start the SDP Search. + iObserver.StartSDPSearch(iConnID); + } + else + { + // Inform the observer that the connection has been restored. + iObserver.LinkRestored(iConnID); + } } else { // Close the sockets as they can't be used CloseChannels(); - ChangeState(ELinkLost); + + if (iConnectionState == EHIDInitConnecting) + { + ChangeState(ENotConnected); + // If this was an remote HID initial connection inform the observer + iObserver.FirstTimeConnectionCompleteFromRemote(iConnID, error); + } + else + { + ChangeState(ELinkLost); + } } } } diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/bthidserver/src/bthidserver.cpp --- a/bluetoothengine/bthid/bthidserver/src/bthidserver.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/bthidserver/src/bthidserver.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -38,6 +38,7 @@ #include "hidgeneric.h" #include "hidlayoutids.h" #include "bthidPsKey.h" +#include "hidsdpclient.h" #ifndef DBG @@ -98,6 +99,8 @@ delete iGenHID; + delete iHidSdpClient; + RProperty::Delete( KPSUidBthidSrv, KBTMouseCursorState ); } @@ -241,8 +244,11 @@ const CBTHidDevice& aDeviceDetails, TBTHidConnState aState) { TRACE_INFO( (_L("[BTHID]\tCBTHidServer::InformClientsOfStatusChange, state=%d"),aState) ); - if (aState == EBTDeviceConnected || aState == EBTDeviceLinkRestored - || aState == EBTDeviceLinkLost || aState == EBTDeviceDisconnected) + if (aState == EBTDeviceConnected || + aState == EBTDeviceLinkRestored || + aState == EBTDeviceLinkLost || + aState == EBTDeviceDisconnected || + aState == EBTDeviceConnectedFromRemote) { iLastUsedAddr = aDeviceDetails.iAddress; iActiveState = ETrue; @@ -286,6 +292,7 @@ switch (aState) { case EBTDeviceLinkRestored: + case EBTDeviceConnectedFromRemote: { HandleAsyncRequest(aDeviceAddr, EBTConnected); break; @@ -484,10 +491,11 @@ foundItem = ETrue; TBTConnectionState HidConnectionStatus = connection->ConnectStatus(); - if (EFirstConnection == HidConnectionStatus || EConnecting - == HidConnectionStatus || EHIDReconnecting - == HidConnectionStatus || EHostReconnecting - == HidConnectionStatus) + if ( (EFirstConnection == HidConnectionStatus) || + (EConnecting == HidConnectionStatus) || + (EHIDReconnecting == HidConnectionStatus) || + (EHostReconnecting == HidConnectionStatus) || + (EHIDInitConnecting == HidConnectionStatus) ) { retVal = EBTEngConnecting; } @@ -504,6 +512,33 @@ return retVal; } +TBool CBTHidServer::DeviceExistInContainer(const TBTDevAddr& aAddress) + { + TInt i = 0; + TBool foundItem = EFalse; + TInt BTConnectionObjCount = iBTConnContainer->Count(); + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::DeviceExistInContainer()")); + while ((i < BTConnectionObjCount) && (!foundItem)) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + + if (devDetails.iAddress == aAddress) + { + foundItem = ETrue; + } + } + i++; + } + + return foundItem; + } + TBool CBTHidServer::GetConnectionAddress(TDes8& aAddressBuf) { TInt i = 0; @@ -549,8 +584,9 @@ CBTHidDevice& devDetails = connection->DeviceDetails(); TBTConnectionState HidConnectionStatus = connection->ConnectStatus(); - if (connection->IsConnected() || HidConnectionStatus - == EHIDReconnecting) + if (connection->IsConnected() || + HidConnectionStatus == EHIDReconnecting || + HidConnectionStatus == EHIDInitConnecting) { if ((IsKeyboard(aDeviceSubClass) && IsKeyboard( devDetails.iDeviceSubClass)) || (IsPointer( @@ -597,7 +633,7 @@ TInt BTConnectionObjCount = iBTConnContainer->Count(); TUint deviceSubClass = GetDeviceSubClass(aDevAddr); - TRACE_INFO(_L("[BTHID]\tCBTHidServer::IsAllowToConnectFromClientSide()")); + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::IsAllowToConnectFromClientSide() BTConnectionObjCount = %d"), BTConnectionObjCount) ); while ((i < BTConnectionObjCount) && retVal) { CBTHidConnection *connection = @@ -608,16 +644,18 @@ CBTHidDevice& devDetails = connection->DeviceDetails(); TBTConnectionState HidConnectionStatus = connection->ConnectStatus(); - if (connection->IsConnected() || HidConnectionStatus - == EConnecting) + if (connection->IsConnected() || + HidConnectionStatus == EConnecting || + HidConnectionStatus == EHIDInitConnecting) { if (devDetails.iAddress != aDevAddr) - { + { if ((IsKeyboard(deviceSubClass) && IsKeyboard( devDetails.iDeviceSubClass)) || (IsPointer( deviceSubClass) && IsPointer( devDetails.iDeviceSubClass))) { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::() NO connection allowed, connection exist already!")); retVal = EFalse; iConflictAddr = devDetails.iAddress; } @@ -699,11 +737,14 @@ return; } -TInt CBTHidServer::NewConnectionL() +TInt CBTHidServer::NewConnectionL(TBTConnectionState aConnectionStatus) { TRACE_INFO(_L("[BTHID]\tCBTHidServer::NewConnectionL")); + __ASSERT_DEBUG( aConnectionStatus == EConnecting || aConnectionStatus == EHIDInitConnecting , + CBTHidServer::PanicServer(EBadState)); + CBTHidConnection *connection = CBTHidConnection::NewLC(iSocketServ, - *this, EConnecting); + *this, aConnectionStatus); // Add to the connection container object. iBTConnContainer->AddL(connection); CleanupStack::Pop(); // connection @@ -1012,6 +1053,132 @@ } } +void CBTHidServer::FirstTimeConnectionCompleteFromRemote(TInt aConnID, TInt aStatus) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::FirstTimeConnectionCompleteFromRemote(%d)"), aStatus)); + TInt error = aStatus; + + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(aConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + if (error == KErrNone) + { + TBool genHidConnected = EFalse; + + TRAP( error, + // Inform the Generic HID of the Connection + GenericHIDConnectL(connection, ETrue); + + // Record that we got as far as informing the Generic HID. + genHidConnected = ETrue; + + // Try to start monitoring the channels. + connection->StartMonitoringChannelsL(); + ) + + if (error != KErrNone) + { + // If we informed the Generic HID of the connection, then + // we must also disconnect. + if (genHidConnected) + { + iGenHID->Disconnected(aConnID); + } + + // Delete the connection object. + //Quietly refuse the remote initialized connection in case of error. + //No need to bother user. + iBTConnIndex->Remove(aConnID); + } + else + { + // Update the stored devices, as we could have power off + // and no clean shutdown. + // Use the non-leaving version. + CleanOldConnection(aConnID); + StoreVirtuallyCabledDevices(KFileStore); + InformClientsOfStatusChange(connection->DeviceDetails(), + EBTDeviceConnectedFromRemote); + } + } + else + { + //Quietly refuse the remote initialized connection in case of error. + //No need to bother user. + iBTConnIndex->Remove(aConnID); + } + } + +void CBTHidServer::StartSDPSearch(TInt aConnID) + { + iConnID = aConnID; + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::StartSDPSearch aConnID= (%d)"), aConnID)); + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(iConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + TRAPD( res, + // Retrieve the hid device object for this new connection + CBTHidDevice &devDetails = + ConnectionDetailsL(iConnID); + + // Create a new HID Sdp Client + // Its only used here so it doesn't matter if we leave. + delete iHidSdpClient; + iHidSdpClient = 0; + //Create a new hid sdp client using the hid device object. + iHidSdpClient = CHidSdpClient::NewL(devDetails, *this); + + // Start the hid sdp client + iHidSdpClient->StartL(); + ) + + if (res != KErrNone) + { + // Get the server to delete the new connection object + DeleteNewConnection(iConnID); + } + } + +void CBTHidServer::HidSdpSearchComplete(TInt aResult) + { + TRACE_FUNC(_L("[BTHID]\tCBTHidServer::HidSdpSearchComplete")); + // This is a callback from the Hid SDP client so we can't delete it here + // Get it to destroy itself when its convenient. + iHidSdpClient->Kill(); + // Deleted outside destructor. + iHidSdpClient = 0; + + // If the SDP search was a success + if (aResult == KErrNone) + { + // Try to connect to the device as a HID + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(iConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + + //Only after SDP search complete, do we know the CoD which is needed + //to tell if the incoming connection is allowed or not. + //ETrue , establish the connection. + //EFalse, refuse the remote connecion sliently + if (IsAllowToConnectFromClientSide(devDetails.iAddress)) + { + FirstTimeConnectionCompleteFromRemote(iConnID, aResult); + } + else + { + FirstTimeConnectionCompleteFromRemote(iConnID, KErrAlreadyExists); + } + } + + } + } + + void CBTHidServer::LinkLost(TInt aConnID) { TRACE_INFO( (_L("[BTHID]\tCBTHidServer::LinkLost(%d)"), aConnID)); @@ -1126,9 +1293,10 @@ else { TInt i = 0; - TInt count = iBTConnContainer->Count(); + TInt err = KErrNone; + TInt connectingID = 0; // Check which port has accepted a connection switch (aPort) { @@ -1137,8 +1305,32 @@ // Get the BT address of the device that has connected iTempControl->RemoteName(sockAddr); devAddr = sockAddr.BTAddr(); + // incoming HID connection is allowed + if (!DeviceExistInContainer(devAddr)) + { + TRAPD( res, + // to be created as New if device not yet listed in container + connectingID = NewConnectionL(EHIDInitConnecting); + + // Retrieve the hid device object for this new connection + CBTHidDevice &devDetails = + ConnectionDetailsL(connectingID); + + // Fill in the information we got from the client + devDetails.iAddress = devAddr; + devDetails.iUseSecurity = ETrue; + ) + + if (res != KErrNone && connectingID != 0) + { + // Get the server to delete the new connection object + DeleteNewConnection(connectingID); + } + } + if (IsAllowToConnectFromClientSide(devAddr)) { + TInt count = iBTConnContainer->Count(); while ((i < count) && (iTempControl)) { CBTHidConnection @@ -1184,7 +1376,7 @@ TRACE_INFO(_L("[BTHID]\tCBTHidServer::SocketAccepted, control channel failed, shutdown listener")); ShutdownListeners(err); } - + break; // The HID Interrupt Channel @@ -1194,6 +1386,7 @@ devAddr = sockAddr.BTAddr(); if (IsAllowToConnectFromClientSide(devAddr)) { + TInt count = iBTConnContainer->Count(); while ((i < count) && (iTempInterrupt)) { CBTHidConnection diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/bthidserver/src/bthidsession.cpp --- a/bluetoothengine/bthid/bthidserver/src/bthidsession.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/bthidserver/src/bthidsession.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -19,6 +19,7 @@ #include #include #include "bthidsession.h" +#include "bthidconnection.h" #include "bthidserver.h" #include "bthidclientsrv.h" #include "hidsdpclient.h" @@ -193,10 +194,10 @@ TPckg addrPack(addr); iConnectionMessage.ReadL(0, addrPack); + // Ask the server to create a new connection object - - - iConnectingID = iServer.NewConnectionL(); + iConnectingID = iServer.NewConnectionL(EConnecting); + TRAPD( res, // Retrieve the hid device object for this new connection CBTHidDevice &devDetails = diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h --- a/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h Fri Apr 23 23:54:40 2010 +0300 @@ -33,7 +33,8 @@ /*! An instance of the CPaintCursorAppView View object for PaintCursor application */ -class CPaintCursorAppView : public CCoeControl +class CPaintCursorAppView : public CCoeControl, public MCoeControlObserver + { public: @@ -55,17 +56,28 @@ Destroy the object and release all memory objects */ ~CPaintCursorAppView(); + + void HideCursor(); + void ShowCursor(); + public: // from CCoeControl void SizeChanged(); void Draw(const TRect& aRect) const; + +public: + /** + * From MCoeControlObserver, HandleControlEventL. + */ + // event handling section + // e.g Listbox events + void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); - void HideCursor(); + void HandleResourceChange( TInt aType ); - void ShowCursor(); private: /*! diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp --- a/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -15,7 +15,7 @@ * */ - +#include #include "paintcursorappview.h" #include "pointmsgqueue.h" #include "debug.h" @@ -155,3 +155,21 @@ iMouseInitialized = ETrue; } +void CPaintCursorAppView::HandleResourceChange( TInt aType ) + { + CCoeControl::HandleResourceChange( aType ); + if ( aType == KEikDynamicLayoutVariantSwitch ) + { + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); + SetRect( mainPaneRect ); + DrawNow(); + } + } + +void CPaintCursorAppView::HandleControlEventL( + CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/ ) + { + } + + diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/bthid/mouse/Sesame_server/group/animation_server.mmp --- a/bluetoothengine/bthid/mouse/Sesame_server/group/animation_server.mmp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/bthid/mouse/Sesame_server/group/animation_server.mmp Fri Apr 23 23:54:40 2010 +0300 @@ -26,8 +26,6 @@ CAPABILITY CAP_CLIENT_DLL VENDORID VID_DEFAULT -DEFFILE btcursor_server.def - SECUREID 0xA000022E EPOCSTACKSIZE 0x5000 diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp --- a/bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -27,6 +27,10 @@ #endif #include // notifier id for power mode setting +// @todo remove this declaration once both stack and UI layers are in codeline +const TUid KBTUserConfirmationNotifierUidCopyForWrapper={0x2002E224}; + + const TInt KMaxSynchReplyBufLength = 256; //what should be? const TUid KBTInquiryChannel = {0x00000601}; // Channel for inquiry notifier @@ -45,6 +49,7 @@ const TInt KBTGenericQueryNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityHigh; const TInt KBTNumericComparisonPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; // for SSP const TInt KBTPasskeyEntryNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; // for SSP +const TInt KBTUserConfirmationNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; // for SSP const TInt KBTPairedDeviceSettingPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; const TInt KBTEnterpriseItSecurityInfoNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityHigh; @@ -78,64 +83,109 @@ KBTInquiryPriority, _L("BTNotif.dll"), KMaxSynchReplyBufLength); - + + CleanupStack::PushL( master ); subjects->AppendL( master ); - - // Notifiers using masters session - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTManAuthNotifierUid, - KBTAuthorisationChannel, - KBTAuthorisationPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTPinCodeEntryNotifierUid, - KBTAuthenticationChannel, - KBTAuthenticationPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTObexPasskeyQueryNotifierUid, - KBTObexPINChannel, - KBTObexPinPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KPowerModeSettingNotifierUid, - KBTPowerModeChannel, - KBTPowerModePriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTGenericInfoNotifierUid, - KBTGenericInfoNotifierUid, - KBTGenericInfoNotifierPriority)); + CleanupStack::Pop( master ); + + // Notifiers using masters session + CAknNotifierWrapperLight* notif = NULL; + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTManAuthNotifierUid, + KBTAuthorisationChannel, + KBTAuthorisationPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTPinCodeEntryNotifierUid, + KBTAuthenticationChannel, + KBTAuthenticationPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTObexPasskeyQueryNotifierUid, + KBTObexPINChannel, + KBTObexPinPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KPowerModeSettingNotifierUid, + KBTPowerModeChannel, + KBTPowerModePriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTGenericInfoNotifierUid, + KBTGenericInfoNotifierUid, + KBTGenericInfoNotifierPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTGenericQueryNotifierUid, - KBTGenericQueryNotifierUid, - KBTGenericQueryNotifierPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KPbapAuthNotifierUid, - KBTObexPINChannel, - KBTObexPinPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTPairedDeviceSettingNotifierUid, - KBTPairedDeviceSettingChannel, - KBTPairedDeviceSettingPriority)); + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTGenericQueryNotifierUid, + KBTGenericQueryNotifierUid, + KBTGenericQueryNotifierPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KPbapAuthNotifierUid, + KBTObexPINChannel, + KBTObexPinPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTPairedDeviceSettingNotifierUid, + KBTPairedDeviceSettingChannel, + KBTPairedDeviceSettingPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTNumericComparisonNotifierUid, - KBTNumericComparisonNotifierUid, - KBTNumericComparisonPriority)); + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTNumericComparisonNotifierUid, + KBTNumericComparisonNotifierUid, + KBTNumericComparisonPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTPasskeyDisplayNotifierUid, + KBTPasskeyDisplayNotifierUid, + KBTPasskeyEntryNotifierPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTUserConfirmationNotifierUidCopyForWrapper, + KBTUserConfirmationNotifierUidCopyForWrapper, + KBTUserConfirmationNotifierPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTPasskeyDisplayNotifierUid, - KBTPasskeyDisplayNotifierUid, - KBTPasskeyEntryNotifierPriority)); + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTEnterpriseItSecurityInfoNotifierUid, + KBTEnterpriseItSecurityInfoNotifierUid, + KBTEnterpriseItSecurityInfoNotifierPriority); - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTEnterpriseItSecurityInfoNotifierUid, - KBTEnterpriseItSecurityInfoNotifierUid, - KBTEnterpriseItSecurityInfoNotifierPriority)); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); CleanupStack::Pop(); // array cleanup return(subjects); diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btnotif/group/BTNotif.mmp --- a/bluetoothengine/btnotif/group/BTNotif.mmp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btnotif/group/BTNotif.mmp Fri Apr 23 23:54:40 2010 +0300 @@ -40,6 +40,7 @@ SOURCE btnpaireddevsettnotifier.cpp SOURCE btnssppasskeyentrynotifier.cpp SOURCE btnumcmpnotifier.cpp +SOURCE btuserconfnotifier.cpp SOURCE btnotifuiutil.cpp SOURCE btnotifactive.cpp SOURCE btnpairnotifier.cpp diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btnotif/inc/btuserconfnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btuserconfnotifier.h Fri Apr 23 23:54:40 2010 +0300 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 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" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Declares User confirmation notifier for Secure Simle Pairing +* +*/ + + +#ifndef BTUSERCONFNOTIFIER_H +#define BTUSERCONFNOTIFIER_H + +// INCLUDES + +#include "btnpairnotifier.h" // Base class + +// These declarations are here temporarily so the submission of the notifiers and the stack do not have to be synchronised. +// Should be removed once all submissions are in. + +const TUid KBTUserConfirmationNotifierUidCopy={0x2002E224}; + +NONSHARABLE_CLASS(TBTNotifierParams2Copy) + { +public: + inline TBTDevAddr DeviceAddress() const { return iBDAddr; }; + inline TPtrC DeviceName() const { return iName; }; +private: + TBTDevAddr iBDAddr; + TBTDeviceName iName; + + // This data padding has been added to help prevent future binary compatibility breaks + // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used + TUint32 iPadding1; + TUint32 iPadding2; + }; + +NONSHARABLE_CLASS(TBTUserConfirmationParamsCopy) + : public TBTNotifierParams2Copy + { +public: + inline TBool LocallyInitiated() const { return iLocallyInitiated; }; +private: + TBool iLocallyInitiated; + + // This data padding has been added to help prevent future binary compatibility breaks + // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used + TUint32 iPadding1; + TUint32 iPadding2; + }; + +typedef TPckgBuf TBTUserConfirmationParamsPckgCopy; + +// CLASS DECLARATION +/** +* This class is used to ask user to compare passcode in two devices. +*/ + + +NONSHARABLE_CLASS(CBTUserConfNotifier): public CBTNPairNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTUserConfNotifier* NewL(); // Constructor (public) + + /** + * Destructor. + */ + virtual ~CBTUserConfNotifier(); // Destructor + + private: + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); // Get input parameters + + /** + * From CBTNotifierBase + * Show notes to ask user response and return to Notifier caller by completing message. + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + private: + + /** + * C++ default constructor. + */ + CBTUserConfNotifier(); // Default constructor + }; + +#endif + +// End of File diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btnotif/src/BTNMain.cpp --- a/bluetoothengine/btnotif/src/BTNMain.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btnotif/src/BTNMain.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -32,6 +32,7 @@ #include "btnpaireddevsettnotifier.h" #include "btnssppasskeyentrynotifier.h" #include "btnumcmpnotifier.h" +#include "btuserconfnotifier.h" #include "btnenterpriseitsecurityinfonotifier.h" // CONSTANTS @@ -105,6 +106,12 @@ aNotifiers->AppendL( numCmpNotifier ); CleanupStack::Pop( numCmpNotifier ); + CBTUserConfNotifier* userConfNotifier = CBTUserConfNotifier::NewL(); + CleanupStack::PushL(userConfNotifier); + aNotifiers->AppendL( userConfNotifier ); + CleanupStack::Pop( userConfNotifier ); + + CBTEnterpriseItSecurityInfoNotifier* enterpriseItSecurityNotifier = CBTEnterpriseItSecurityInfoNotifier::NewL(); CleanupStack::PushL(enterpriseItSecurityNotifier); aNotifiers->AppendL(enterpriseItSecurityNotifier); diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btnotif/src/btuserconfnotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btuserconfnotifier.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -0,0 +1,153 @@ +/* +* Copyright (c) 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" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Declares User confirmation notifier for Secure Simle Pairing +* +*/ + + +// INCLUDE FILES +#include // Localisation stringloader +#include // Unicode character conversion utilities +#include +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#else +#include +#include +#endif +#include // Own resources +#include "btnotif.hrh" // Own resource header +#include "btuserconfnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include +#include +#include +#include +#include "btnotifnameutils.h" + +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTUserConfNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTUserConfNotifier* CBTUserConfNotifier::NewL() + { + CBTUserConfNotifier* self=new (ELeave) CBTUserConfNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------- +// CBTUserConfNotifier::CBTUserConfNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTUserConfNotifier::CBTUserConfNotifier() + { + + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTUserConfNotifier::~CBTUserConfNotifier() + { + } + +// ---------------------------------------------------------- +// CBTUserConfNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTUserConfNotifier::TNotifierInfo CBTUserConfNotifier::RegisterL() + { + iInfo.iUid = KBTUserConfirmationNotifierUidCopy; + iInfo.iChannel = KBTUserConfirmationNotifierUidCopy; + iInfo.iPriority=ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTUserConfNotifier::GetParamsL +// Initialize parameters and check if device is already +// in registry. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTUserConfNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::GetParamsL()")); + + CBTNPairNotifierBase::GetParamsL( aBuffer, aReplySlot, aMessage ); + + TBTUserConfirmationParamsPckgCopy pckg; + pckg.Copy(aBuffer); + iBTAddr = pckg().DeviceAddress(); + if ( OtherOutgoPairing( iBTAddr) ) + { + // We won't allow incoming pairing during outgoing pairing: + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier: outgoing pair in progress, reject incoming pair")); + CompleteMessage(KErrCancel); + return; + } + + iLocallyInitiated = pckg().LocallyInitiated(); + + // base class + ProcessParamsGetDeviceL( iBTAddr, pckg().DeviceName() ); + + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::GetParamsL() completed")); + } + +// ---------------------------------------------------------- +// CBTUserConfNotifier::HandleGetDeviceCompletedL +// Ask user response and return it to caller. +// Store device into registry if user has accepted pairing. +// ---------------------------------------------------------- +// +void CBTUserConfNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) + { + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL()")); + + // Check if blocked device. + if( CheckBlockedDeviceL() ) + return; + + // Turn lights on and deactivate apps -key + iNotifUiUtil->TurnLightsOn(); + + // For incoming pairing request + TBool answer = AuthoriseIncomingPairingL(); + if( !answer ) + { + //User rejects the incoming pairing, complete message in QueryBlockDevice. + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL() <<")); + return; + } + CompleteMessage(answer, KErrNone); + + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL() completed")); + } + +// End of File diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btsac/btrcc/inc/btrccLinker.h --- a/bluetoothengine/btsac/btrcc/inc/btrccLinker.h Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btsac/btrcc/inc/btrccLinker.h Fri Apr 23 23:54:40 2010 +0300 @@ -319,7 +319,6 @@ CBTRCCVolumeLevelControllerBase* iVolController; CBTRCCVolumeLevelControllerBase* iAbsoluteVolController; - CBTRCCVolumeLevelControllerBase* iLegacyVolController; TInt iRegisterVolumeChangeNotificationCounter;//Counter for re-register for remote volume control notification }; diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h --- a/bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h Fri Apr 23 23:54:40 2010 +0300 @@ -125,6 +125,11 @@ TBool IsMusicPlayerRunning(); /** + * Tells if Video player is running or not. + */ + TBool IsVideoPlayerRunning(); + + /** * Launch MPX player. */ void LaunchMusicPlayerL(); diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btsac/btrcc/src/btrccLinker.cpp --- a/bluetoothengine/btsac/btrcc/src/btrccLinker.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btsac/btrcc/src/btrccLinker.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -25,7 +25,6 @@ #include #include #include "btaudioremconpskeys.h" -#include "btrccLegacyVolumeLevelController.h" #include "btrccAbsoluteVolumeLevelController.h" #include "btrccLinker.h" #include "btrccplayerstarter.h" @@ -87,7 +86,6 @@ if (iAccObserver.IsAvrcpVolCTSupported()) { iAbsoluteVolController = CBTRCCAbsoluteVolumeLevelController::NewL(*iInterfaceSelector, *this); - iLegacyVolController = CBTRCCLegacyVolumeLevelController::NewL(*iInterfaceSelector, *this); } else { @@ -101,8 +99,6 @@ iRemConBatteryTgt = CRemConBatteryApiTarget::NewL(*iInterfaceSelector, *this); -// iBrowsingAdapter = CBTRCCBrowsingAdapter::NewL(*iInterfaceSelector); - if (iAccObserver.IsAvrcpVolCTSupported()) { iInterfaceSelector->OpenControllerL(); @@ -129,7 +125,6 @@ User::RequestComplete(iClientRequest, KErrAbort); delete iAbsoluteVolController; - delete iLegacyVolController; delete iPlayerStarter; Cancel(); iStateArray.ResetAndDestroy(); @@ -437,17 +432,18 @@ if (iAccObserver.IsAvrcpVolCTSupported()) { // Choose based on SDP result whether to create - // absolute controller or legacy controller. + // absolute controller or not. if(!iVolController) { if (iAccObserver.IsAbsoluteVolumeSupported(iRemoteAddr)) { iVolController = iAbsoluteVolController; + TRACE_INFO(_L("Absolute volume supported, taking it into use.")) } else - { - iVolController = iLegacyVolController; - } + { + TRACE_INFO(_L("No absolute volume supported, so no volume control.")) + } } } if (iVolController) @@ -466,6 +462,7 @@ if (iVolController) { iVolController->Stop(); + iVolController = NULL; } } diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp --- a/bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -33,6 +33,7 @@ _LIT(KMpxPlayerExeName, "mpx.exe"); _LIT(KMpxPlayerSearchPatternBySID, "*102072c3*"); +_LIT(KVideoPlayerSearchPatternBySID, "*200159B2*"); static const TInt KPlayCmdToPlayerDelay = 6000000; // value will be tuned later @@ -243,7 +244,7 @@ { return; } - if (!IsMusicPlayerRunning()) + if (!IsMusicPlayerRunning() && !IsVideoPlayerRunning()) { TRAPD(err, LaunchMusicPlayerL()); // Send the response of play command to remote device @@ -269,6 +270,22 @@ return running; } +TBool CPlayerStarter::IsVideoPlayerRunning() + { + TRACE_FUNC + // Video player is running if we can find a thread whose name contains + // Video Player's SID. + TFindThread findt(KVideoPlayerSearchPatternBySID); + TFullName result; + TBool running(EFalse); + if (!findt.Next(result)) + { + TRACE_INFO((_L("Thread '%S'is found"), &result)); + running = ETrue; + } + return running; + } + void CPlayerStarter::LaunchMusicPlayerL() { RApaLsSession ls; diff -r 988cddd6adbd -r 8930e1d1d530 bluetoothengine/btui/devmodel/src/btpairedmodel.cpp --- a/bluetoothengine/btui/devmodel/src/btpairedmodel.cpp Fri Apr 23 23:38:44 2010 +0300 +++ b/bluetoothengine/btui/devmodel/src/btpairedmodel.cpp Fri Apr 23 23:54:40 2010 +0300 @@ -419,12 +419,35 @@ if(di >=0 ) { nameArray.Append(&iDeviceArray[di]->iName); - } + } } - if(iObserver ) - { - iObserver->NotifyChangeDeviceComplete(aErr, connectedDevice, &nameArray); - } + + // we will unset the connect status of the device if connection failed & + // it is found in paired devices. + if( index >= 0 ) + { + // add EStatusBtuiConnected status if the device has a profile connection + TBTEngConnectionStatus connStatus; + iConnMan->IsConnected(connectedDevice.iAddr, connStatus); + + if (connStatus != EBTEngConnecting && connStatus != EBTEngConnected) + { + TRACE_INFO(_L("Unset EStatusBtuiConnected")) + UnsetStatusFlags(iDeviceArray[index]->iStatus,EStatusBtuiConnected ); + } + } + + if(iObserver) + { + //Show only phone issued request complete notes + //Do not show notes for device issued request when BTUI is active + if ( requestIssuedFromPhone ) + { + iObserver->NotifyChangeDeviceComplete(aErr, connectedDevice, &nameArray); + } + + SendRefreshIfNoError(aErr); + } nameArray.Reset(); } else