bluetoothappprofiles/avrcp/remconbeareravrcp/src/passthroughhelper.cpp
changeset 40 997690c3397a
parent 0 f63038272f30
equal deleted inserted replaced
37:91746b151f97 40:997690c3397a
    19 #include "controlcommand.h"
    19 #include "controlcommand.h"
    20 #include "passthroughhelper.h"
    20 #include "passthroughhelper.h"
    21 #include "controlbearer.h"
    21 #include "controlbearer.h"
    22 
    22 
    23 
    23 
    24 CPassthroughHelper* CPassthroughHelper::NewL(CRcpRouter& aRouter, CRemConBearerAvrcp& aBearer, CDeltaTimer& aTimer)
    24 CPassthroughHelper* CPassthroughHelper::NewL(CRcpRouter& aRouter, MRemConControlCommandInterface& aCommandInterface, CDeltaTimer& aTimer)
    25 	{
    25 	{
    26 	CPassthroughHelper* helper = new(ELeave)CPassthroughHelper(aRouter, aBearer, aTimer);
    26 	CPassthroughHelper* helper = new(ELeave)CPassthroughHelper(aRouter, aCommandInterface, aTimer);
    27 	CleanupStack::PushL(helper);
    27 	CleanupStack::PushL(helper);
    28 	helper->ConstructL();
    28 	helper->ConstructL();
    29 	CleanupStack::Pop(helper);
    29 	CleanupStack::Pop(helper);
    30 	return helper;
    30 	return helper;
    31 	}
    31 	}
    32 
    32 
    33 CPassthroughHelper::~CPassthroughHelper()
    33 CPassthroughHelper::~CPassthroughHelper()
    34 	{
    34 	{
    35 	}
    35 	}
    36 	
    36 	
    37 CPassthroughHelper::CPassthroughHelper(CRcpRouter& aRouter, CRemConBearerAvrcp& aBearer, CDeltaTimer& aTimer)
    37 CPassthroughHelper::CPassthroughHelper(CRcpRouter& aRouter, MRemConControlCommandInterface& aCommandInterface, CDeltaTimer& aTimer)
    38 	: iRouter(aRouter)
    38 	: iRouter(aRouter)
    39 	, iBearer(aBearer)
    39 	, iCommandInterface(aCommandInterface)
    40 	, iTimer(aTimer)
    40 	, iTimer(aTimer)
    41 	{
    41 	{
    42 	}
    42 	}
    43 
    43 
    44 void CPassthroughHelper::ConstructL()
    44 void CPassthroughHelper::ConstructL()
   162 				// of the press yet - so do it now.
   162 				// of the press yet - so do it now.
   163 				if(iPreviousPassthrough->Click())
   163 				if(iPreviousPassthrough->Click())
   164 					{
   164 					{
   165 					iPreviousPassthrough->SetClick(EFalse);
   165 					iPreviousPassthrough->SetClick(EFalse);
   166 					iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonPress, ETrue);
   166 					iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonPress, ETrue);
   167 					iBearer.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId());
   167 					iCommandInterface.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId());
   168 					}
   168 					}
   169 				StartReleaseTimer(*iPreviousPassthrough);
   169 				StartReleaseTimer(*iPreviousPassthrough);
   170 				}
   170 				}
   171 			else if(iPreviousPassthrough->Click())
   171 			else if(iPreviousPassthrough->Click())
   172 				{
   172 				{
   173 				// prevCommand is click, Hold timer not expired.  Generate click
   173 				// prevCommand is click, Hold timer not expired.  Generate click
   174 				// to RemCon then start waiting for click.
   174 				// to RemCon then start waiting for click.
   175 				iPreviousPassthrough->CancelTimer(iTimer);
   175 				iPreviousPassthrough->CancelTimer(iTimer);
   176 				iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonClick, ETrue);
   176 				iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonClick, ETrue);
   177 				iBearer.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId());
   177 				iCommandInterface.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId());
   178 				
   178 				
   179 				HandledCommand(*iPreviousPassthrough);
   179 				HandledCommand(*iPreviousPassthrough);
   180 									
   180 									
   181 				// Start waiting for click (core api) or release (vendor unique)
   181 				// Start waiting for click (core api) or release (vendor unique)
   182 				NewPress(aCommand);
   182 				NewPress(aCommand);
   212 				aCommand.DecrementUsers(); // Drop this command.
   212 				aCommand.DecrementUsers(); // Drop this command.
   213 				
   213 				
   214 				// Cancel hold timer and send the previous command as a click.
   214 				// Cancel hold timer and send the previous command as a click.
   215 				iPreviousPassthrough->CancelTimer(iTimer); 
   215 				iPreviousPassthrough->CancelTimer(iTimer); 
   216 				iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonClick, ETrue);
   216 				iPreviousPassthrough->SetCoreButtonAction(ERemConCoreApiButtonClick, ETrue);
   217 				iBearer.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId());
   217 				iCommandInterface.MrcciNewCommand(*iPreviousPassthrough, iPreviousPassthrough->ClientId());
   218 				
   218 				
   219 				HandledCommand(*iPreviousPassthrough);
   219 				HandledCommand(*iPreviousPassthrough);
   220 				}
   220 				}
   221 			else
   221 			else
   222 				{
   222 				{
   226 				
   226 				
   227 				if(aCommand.IsAvrcpPassthrough())
   227 				if(aCommand.IsAvrcpPassthrough())
   228 					{
   228 					{
   229 					aCommand.SetCoreButtonAction(ERemConCoreApiButtonRelease, ETrue);
   229 					aCommand.SetCoreButtonAction(ERemConCoreApiButtonRelease, ETrue);
   230 					}
   230 					}
   231 				iBearer.MrcciNewCommand(aCommand, aCommand.ClientId());
   231 				iCommandInterface.MrcciNewCommand(aCommand, aCommand.ClientId());
   232 				aCommand.DecrementUsers();
   232 				aCommand.DecrementUsers();
   233 				}
   233 				}
   234 			}
   234 			}
   235 		else
   235 		else
   236 			{
   236 			{
   265 		{
   265 		{
   266 		StartHoldTimer(aCommand);
   266 		StartHoldTimer(aCommand);
   267 		}
   267 		}
   268 	else
   268 	else
   269 		{
   269 		{
   270 		iBearer.MrcciNewCommand(aCommand, aCommand.ClientId());
   270 		iCommandInterface.MrcciNewCommand(aCommand, aCommand.ClientId());
   271 		StartReleaseTimer(aCommand);
   271 		StartReleaseTimer(aCommand);
   272 		}
   272 		}
   273 	}
   273 	}
   274 
   274 
   275 /** To be called on completion of command handling for an unbalanced press.
   275 /** To be called on completion of command handling for an unbalanced press.
   301 			{
   301 			{
   302 			// FIXME I think we might need a new transaction id here?
   302 			// FIXME I think we might need a new transaction id here?
   303 			TRAPD(err, aCommand.ReSetCoreButtonActionL(ERemConCoreApiButtonRelease, ETrue));
   303 			TRAPD(err, aCommand.ReSetCoreButtonActionL(ERemConCoreApiButtonRelease, ETrue));
   304 			if (err == KErrNone)
   304 			if (err == KErrNone)
   305 				{
   305 				{
   306 				iBearer.MrcciNewCommand(aCommand, aCommand.ClientId());
   306 				iCommandInterface.MrcciNewCommand(aCommand, aCommand.ClientId());
   307 				}
   307 				}
   308 				else
   308 				else
   309 				{
   309 				{
   310 				// just silently drop this command, do not send command to remconserv
   310 				// just silently drop this command, do not send command to remconserv
   311 				}
   311 				}
   384 	// CancelTimer also frees the timer entries, so needs to be called
   384 	// CancelTimer also frees the timer entries, so needs to be called
   385 	// here even though there's no pending entry.
   385 	// here even though there's no pending entry.
   386 	aCommand.CancelTimer(iTimer);
   386 	aCommand.CancelTimer(iTimer);
   387 	aCommand.SetClick(EFalse);
   387 	aCommand.SetClick(EFalse);
   388 	aCommand.SetCoreButtonAction(ERemConCoreApiButtonPress, ETrue);
   388 	aCommand.SetCoreButtonAction(ERemConCoreApiButtonPress, ETrue);
   389 	iBearer.MrcciNewCommand(aCommand, aCommand.ClientId());
   389 	iCommandInterface.MrcciNewCommand(aCommand, aCommand.ClientId());
   390 	StartReleaseTimer(aCommand);
   390 	StartReleaseTimer(aCommand);
   391 	}
   391 	}
   392 
   392 
   393 /** Starts the release timer (only applicable to press commands).
   393 /** Starts the release timer (only applicable to press commands).
   394 
   394