bluetoothengine/btsac/src/btsaController.cpp
branchRCL_3
changeset 54 0ba996a9b75d
parent 2 0b192a3a05a4
equal deleted inserted replaced
53:eede1356aa52 54:0ba996a9b75d
     1 /*
     1 /*
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   446 // -----------------------------------------------------------------------------
   446 // -----------------------------------------------------------------------------
   447 //
   447 //
   448 void CBTSAController::NewAccessory(const TBTDevAddr& aAddr)
   448 void CBTSAController::NewAccessory(const TBTDevAddr& aAddr)
   449 	{
   449 	{
   450  	TRACE_FUNC
   450  	TRACE_FUNC
   451  	TInt connectedProfiles = Observer().ConnectionStatus( aAddr );
   451 	TRACE_INFO((_L("\tiNotifiedObserverOfNewAccessory = %d"), iNotifiedObserverOfNewAccessory))
   452  	if( !(connectedProfiles & EStereo) )
   452 	if ( !iNotifiedObserverOfNewAccessory )
   453  	    {
   453 		{
   454  	    Observer().NewAccessory( aAddr, EStereo );
   454 	 	TInt connectedProfiles = Observer().ConnectionStatus( aAddr );
   455  	    } 
   455 	 	if( !(connectedProfiles & EStereo) )
       
   456 	 	    {
       
   457 	 	    Observer().NewAccessory( aAddr, EStereo );
       
   458 	 	    iNotifiedObserverOfNewAccessory = ETrue;
       
   459 	 	    } 
       
   460 		}
   456 	}
   461 	}
   457 
   462 
   458 // -----------------------------------------------------------------------------
   463 // -----------------------------------------------------------------------------
   459 // CBTSAController::DisconnectedFromRemote
   464 // CBTSAController::DisconnectedFromRemote
   460 // -----------------------------------------------------------------------------
   465 // -----------------------------------------------------------------------------
   461 //
   466 //
   462 void CBTSAController::DisconnectedFromRemote(const TBTDevAddr& aAddr, TInt /*aError*/)
   467 void CBTSAController::DisconnectedFromRemote(const TBTDevAddr& aAddr, TInt /*aError*/)
   463 	{
   468 	{
   464 	TRACE_FUNC
   469 	TRACE_FUNC
   465 	Observer().AccessoryDisconnected(aAddr, EStereo );
   470 	TRACE_INFO((_L("\tiNotifiedObserverOfNewAccessory = %d"), iNotifiedObserverOfNewAccessory))
       
   471 	if ( iNotifiedObserverOfNewAccessory )
       
   472 		{
       
   473 		Observer().AccessoryDisconnected(aAddr, EStereo );
       
   474 		iNotifiedObserverOfNewAccessory = EFalse;
       
   475 		}
   466 	}
   476 	}
   467 
   477 
   468 // -----------------------------------------------------------------------------
   478 // -----------------------------------------------------------------------------
   469 // CBTSAController::AccessoryOpenedAudio
   479 // CBTSAController::AccessoryOpenedAudio
   470 // -----------------------------------------------------------------------------
   480 // -----------------------------------------------------------------------------
   531 // CBTSAController::SetRemoteAddr
   541 // CBTSAController::SetRemoteAddr
   532 // -----------------------------------------------------------------------------
   542 // -----------------------------------------------------------------------------
   533 //
   543 //
   534 void CBTSAController::SetRemoteAddr(const TBTDevAddr& aRemoteAddr)
   544 void CBTSAController::SetRemoteAddr(const TBTDevAddr& aRemoteAddr)
   535 	{
   545 	{
       
   546 #ifdef PRJ_ENABLE_TRACE
       
   547 	TBuf<12> buf;
       
   548 	aRemoteAddr.GetReadable(buf);
       
   549 	TRACE_INFO((_L("CBTSAController::SetRemoteAddr aRemoteAddr = %S"), &buf))
       
   550 #endif
   536 	iRemoteAddr = aRemoteAddr;
   551 	iRemoteAddr = aRemoteAddr;
   537 	}
   552 	}
   538 	
   553 	
   539 // -----------------------------------------------------------------------------
   554 // -----------------------------------------------------------------------------
   540 // CBTSAController::GetRemoteAddr
   555 // CBTSAController::GetRemoteAddr
   541 // -----------------------------------------------------------------------------
   556 // -----------------------------------------------------------------------------
   542 //
   557 //
   543 TBTDevAddr CBTSAController::GetRemoteAddr() const
   558 TBTDevAddr CBTSAController::GetRemoteAddr() const
   544 	{
   559 	{
       
   560 #ifdef PRJ_ENABLE_TRACE
       
   561 	TBuf<12> buf;
       
   562 	iRemoteAddr.GetReadable(buf);
       
   563 	TRACE_INFO((_L("CBTSAController::GetRemoteAddr iRemoteAddr = %S"), &buf))
       
   564 #endif
   545 	return iRemoteAddr;
   565 	return iRemoteAddr;
   546 	}
   566 	}
   547 
   567 
   548 // -----------------------------------------------------------------------------
   568 // -----------------------------------------------------------------------------
   549 // CBTSAController::IsOpenAudioReqFromAccFWPending
   569 // CBTSAController::IsOpenAudioReqFromAccFWPending
   613 		{
   633 		{
   614 		TRAP_IGNORE(iState->CloseAudioLinkL(GetRemoteAddr()));
   634 		TRAP_IGNORE(iState->CloseAudioLinkL(GetRemoteAddr()));
   615 		}
   635 		}
   616 	else
   636 	else
   617 		{
   637 		{
   618 		TRAPD(err, ChangeStateL(CBtsacListening::NewL(*this, EGavdpResetReasonGeneral, EFalse)));
   638 		TRAPD(err, ChangeStateL(CBtsacListening::NewL(*this, EResetGavdp, KErrNone)));
   619 		if (err)
   639 		if (err)
   620 			{
   640 			{
   621 			TRACE_INFO((_L("CBTSAController::NotifyError() Couldn't change state.")))
   641 			TRACE_INFO((_L("CBTSAController::NotifyError() Couldn't change state.")))
   622 			}
   642 			}
   623 		}
   643 		}