bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpincomingcommandhandler.cpp
branchRCL_3
changeset 14 2f88a7d66f50
parent 0 f63038272f30
child 22 613943a21004
equal deleted inserted replaced
12:b23265fb36da 14:2f88a7d66f50
    52 @param aRouter	A CRcpRouter to use for communication with remote devices.
    52 @param aRouter	A CRcpRouter to use for communication with remote devices.
    53 @param aTimer	CDeltaTimer to use for queuing timed events.
    53 @param aTimer	CDeltaTimer to use for queuing timed events.
    54 @return A fully constructed CRcpIncomingCommandHandler.
    54 @return A fully constructed CRcpIncomingCommandHandler.
    55 @leave System wide error codes.
    55 @leave System wide error codes.
    56 */
    56 */
    57 CRcpIncomingCommandHandler* CRcpIncomingCommandHandler::NewL(CRemConBearerAvrcp& aBearer,
    57 CRcpIncomingCommandHandler* CRcpIncomingCommandHandler::NewL(MRemConControlCommandInterface& aCommandInterface,
    58 	MRemConBearerObserver& aObserver,
    58 	MRemConBearerObserver& aObserver,
    59 	CRcpRouter& aRouter,
    59 	CRcpRouter& aRouter,
    60 	CDeltaTimer& aTimer,
    60 	CDeltaTimer& aTimer,
    61 	CAvrcpPlayerInfoManager& aPlayerInfoManager,
    61 	CAvrcpPlayerInfoManager& aPlayerInfoManager,
    62 	TBTDevAddr& aDevice) 
    62 	TBTDevAddr& aDevice) 
    63 	{
    63 	{
    64 	LOG_STATIC_FUNC
    64 	LOG_STATIC_FUNC
    65 	CRcpIncomingCommandHandler* handler = new(ELeave)CRcpIncomingCommandHandler(aBearer, aObserver, aRouter, aTimer, aPlayerInfoManager, aDevice);
    65 	CRcpIncomingCommandHandler* handler = new(ELeave)CRcpIncomingCommandHandler(aCommandInterface, aObserver, aRouter, aTimer, aPlayerInfoManager, aDevice);
    66 	CleanupStack::PushL(handler);
    66 	CleanupStack::PushL(handler);
    67 	handler->ConstructL();
    67 	handler->ConstructL();
    68 	CleanupStack::Pop(handler);
    68 	CleanupStack::Pop(handler);
    69 	return handler;
    69 	return handler;
    70 	}
    70 	}
    76 @param aRouter	A CRcpRouter to use for communication with remote devices.
    76 @param aRouter	A CRcpRouter to use for communication with remote devices.
    77 @param aTimer	CDeltaTimer to use for queuing timed events.
    77 @param aTimer	CDeltaTimer to use for queuing timed events.
    78 @return A partially constructed CRcpIncomingCommandHandler.
    78 @return A partially constructed CRcpIncomingCommandHandler.
    79 @leave System wide error codes.
    79 @leave System wide error codes.
    80 */	
    80 */	
    81 CRcpIncomingCommandHandler::CRcpIncomingCommandHandler(CRemConBearerAvrcp& aBearer, 
    81 CRcpIncomingCommandHandler::CRcpIncomingCommandHandler(MRemConControlCommandInterface& aCommandInterface, 
    82 	MRemConBearerObserver& aObserver,
    82 	MRemConBearerObserver& aObserver,
    83 	CRcpRouter& aRouter,
    83 	CRcpRouter& aRouter,
    84 	CDeltaTimer& aTimer,
    84 	CDeltaTimer& aTimer,
    85 	CAvrcpPlayerInfoManager& aPlayerInfoManager,
    85 	CAvrcpPlayerInfoManager& aPlayerInfoManager,
    86 	TBTDevAddr& aDevice) 
    86 	TBTDevAddr& aDevice) 
    87 	: iCommandQueue(_FOFF(CControlCommand, iHandlingLink))
    87 	: iCommandQueue(_FOFF(CControlCommand, iHandlingLink))
    88 	, iInternalCommandQueue(_FOFF(CControlCommand, iHandlingLink))
    88 	, iInternalCommandQueue(_FOFF(CControlCommand, iHandlingLink))
    89 	, iFragmenter(NULL)
    89 	, iFragmenter(NULL)
    90 	, iBearer(aBearer)
    90 	, iCommandInterface(aCommandInterface)
    91 	, iObserver(aObserver)
    91 	, iObserver(aObserver)
    92 	, iRouter(aRouter)
    92 	, iRouter(aRouter)
    93 	, iTimer(aTimer)
    93 	, iTimer(aTimer)
    94 	, iAddressedMode(EFalse)
    94 	, iAddressedMode(EFalse)
    95 	, iPlayerInfoManager(aPlayerInfoManager)
    95 	, iPlayerInfoManager(aPlayerInfoManager)
   119 	// if no player have yet been registered we'll set the default when the
   119 	// if no player have yet been registered we'll set the default when the
   120 	// first one is
   120 	// first one is
   121 	
   121 	
   122 	CleanupStack::PopAndDestroy(&players);
   122 	CleanupStack::PopAndDestroy(&players);
   123 	
   123 	
   124 	iPassthroughHelper = CPassthroughHelper::NewL(iRouter, iBearer, iTimer);
   124 	iPassthroughHelper = CPassthroughHelper::NewL(iRouter, iCommandInterface, iTimer);
   125 	}
   125 	}
   126 
   126 
   127 /** Destructor.
   127 /** Destructor.
   128 */	
   128 */	
   129 CRcpIncomingCommandHandler::~CRcpIncomingCommandHandler()
   129 CRcpIncomingCommandHandler::~CRcpIncomingCommandHandler()
   130 	{
   130 	{
   131 	LOG_FUNC
   131 	LOG_FUNC
   132 
   132 
       
   133 	iCommandInterface.MrccciUnregisterForLocalAddressedClientUpdates();
   133 	iPlayerInfoManager.RemoveObserver( *this );
   134 	iPlayerInfoManager.RemoveObserver( *this );
   134 	delete iFragmenter;
   135 	delete iFragmenter;
   135 	delete iPassthroughHelper;
   136 	delete iPassthroughHelper;
   136 
   137 
   137 	// All commands should have been handled by the time we reach here.
   138 	// All commands should have been handled by the time we reach here.
   205 	SymbianAvctp::TTransactionLabel aTransactionLabel, 
   206 	SymbianAvctp::TTransactionLabel aTransactionLabel, 
   206 	const TBTDevAddr& aAddr)
   207 	const TBTDevAddr& aAddr)
   207 	{
   208 	{
   208 	LOG_FUNC
   209 	LOG_FUNC
   209 		
   210 		
   210 	TUint id = iBearer.MrcciNewTransactionId();
   211 	TUint id = iCommandInterface.MrcciNewTransactionId();
   211 	
   212 	
   212 	// If there's nothing beyond a header this is bobs.  Dump it now.
   213 	// If there's nothing beyond a header this is bobs.  Dump it now.
   213 	if(aMessageInformation.Length() <= KAVCFrameHeaderLength)
   214 	if(aMessageInformation.Length() <= KAVCFrameHeaderLength)
   214 		{
   215 		{
   215 		User::Leave(KErrCorrupt);
   216 		User::Leave(KErrCorrupt);
   506 	else 
   507 	else 
   507 		{
   508 		{
   508 		// can go directly to client (unlike passthrough which may need to map 2 commands to 1 click
   509 		// can go directly to client (unlike passthrough which may need to map 2 commands to 1 click
   509 		if (aCommand.Frame().Type() == AVC::ENotify)
   510 		if (aCommand.Frame().Type() == AVC::ENotify)
   510 			{
   511 			{
   511 			iBearer.MrccciNewNotifyCommand(aCommand, aCommand.ClientId());
   512 			iCommandInterface.MrccciNewNotifyCommand(aCommand, aCommand.ClientId());
   512 			}
   513 			}
   513 		else
   514 		else
   514 			{
   515 			{
   515 			iBearer.MrcciNewCommand(aCommand, aCommand.ClientId());
   516 			iCommandInterface.MrcciNewCommand(aCommand, aCommand.ClientId());
   516 			}
   517 			}
   517 		}
   518 		}
   518 	}
   519 	}
   519 
   520 
   520 TInt CRcpIncomingCommandHandler::HandleSetAddressedPlayer(TUint aId, RBuf8& aCommandData)
   521 TInt CRcpIncomingCommandHandler::HandleSetAddressedPlayer(TUint aId, RBuf8& aCommandData)
   521 	{
   522 	{
   522 	LOG_FUNC
   523 	LOG_FUNC
   523 	
   524 	
   524 	// Once we respond to this we've told the remote that we're using a particular player
   525 	// Once we respond to this we've told the remote that we're using a particular player
   525 	iAddressedMode = ETrue;
   526 	EnterAddressedMode();
   526 	
   527 	
   527 	// SetAddressedPlayer involves not just responding to this command but
   528 	// SetAddressedPlayer involves not just responding to this command but
   528 	// also rejecting a bunch of notifies and completing the addressed player
   529 	// also rejecting a bunch of notifies and completing the addressed player
   529 	// changed notify.  We try as hard as we can to ensure our state remains
   530 	// changed notify.  We try as hard as we can to ensure our state remains
   530 	// consistent with the view of the remote.
   531 	// consistent with the view of the remote.
   566 			break;
   567 			break;
   567 			}
   568 			}
   568 			};
   569 			};
   569 	
   570 	
   570 		SendInternalResponse(aId, responseBuf);
   571 		SendInternalResponse(aId, responseBuf);
   571 		iBearer.MrccciSetAddressedClient(iClientId);
   572 		iCommandInterface.MrccciSetAddressedClient(iClientId);
   572 	
   573 	
   573 		responseBuf.Close();
   574 		responseBuf.Close();
   574 		}
   575 		}
   575 
   576 
   576 	return err;
   577 	return err;
   660 TInt CRcpIncomingCommandHandler::HandleRegisterAddressedPlayerNotification(CControlCommand& aCommand)
   661 TInt CRcpIncomingCommandHandler::HandleRegisterAddressedPlayerNotification(CControlCommand& aCommand)
   661 	{
   662 	{
   662 	LOG_FUNC
   663 	LOG_FUNC
   663 
   664 
   664 	// Once we respond to this we've told the remote that we're using a particular player
   665 	// Once we respond to this we've told the remote that we're using a particular player
   665 	iAddressedMode = ETrue;
   666 	EnterAddressedMode();
   666 	
   667 	
   667 	RBuf8 responseBuf;
   668 	RBuf8 responseBuf;
   668 	TRAPD(err, DoHandleRegisterAddressedPlayerNotificationL(responseBuf, aCommand));
   669 	TRAPD(err, DoHandleRegisterAddressedPlayerNotificationL(responseBuf, aCommand));
   669 	
   670 	
   670 	if(!err)
   671 	if(!err)
   718 	{
   719 	{
   719 	LOG_FUNC
   720 	LOG_FUNC
   720 
   721 
   721 	// Although we haven't strictly told the remote which player we're using this is 
   722 	// Although we haven't strictly told the remote which player we're using this is 
   722 	// a 1.4 command, and implies use of a specific player so switch into addressed mode
   723 	// a 1.4 command, and implies use of a specific player so switch into addressed mode
   723 	iAddressedMode = ETrue;
   724 	EnterAddressedMode();
   724 
   725 
   725 	RBuf8 responseBuf;
   726 	RBuf8 responseBuf;
   726 	TUint16 uidCounter = 0;
   727 	TUint16 uidCounter = 0;
   727 	TRAPD(err, uidCounter = iPlayerInfoManager.UidCounterL(iClientId));
   728 	TRAPD(err, uidCounter = iPlayerInfoManager.UidCounterL(iClientId));
   728 	
   729 	
   821 	// already removed from our queue.  We're telling RemCon that we dealt ok
   822 	// already removed from our queue.  We're telling RemCon that we dealt ok
   822 	// with this so we have resonsibility for tidying up the data.
   823 	// with this so we have resonsibility for tidying up the data.
   823 	aData.Close();
   824 	aData.Close();
   824 	}
   825 	}
   825 
   826 
       
   827 void CRcpIncomingCommandHandler::EnterAddressedMode()
       
   828 	{
       
   829 	iAddressedMode = ETrue;
       
   830 	iCommandInterface.MrccciRegisterForLocalAddressedClientUpdates();
       
   831 	}
       
   832 
   826 TBool CRcpIncomingCommandHandler::DuplicateNotify(TDblQue<CControlCommand>& aCommandQueue, const CControlCommand& aCommand) const
   833 TBool CRcpIncomingCommandHandler::DuplicateNotify(TDblQue<CControlCommand>& aCommandQueue, const CControlCommand& aCommand) const
   827 	{
   834 	{
   828 	TUid interfaceUid = aCommand.RemConInterfaceUid();
   835 	TUid interfaceUid = aCommand.RemConInterfaceUid();
   829 	TUint operationId = aCommand.RemConOperationId();
   836 	TUint operationId = aCommand.RemConOperationId();
   830 	
   837