bluetooth/gavdp/source/gavdpHelpers.cpp
branchRCL_3
changeset 22 786b94c6f0a4
parent 0 29b1cd4cb562
equal deleted inserted replaced
21:14e240312f6f 22:786b94c6f0a4
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   471 	delete this;
   471 	delete this;
   472 	}
   472 	}
   473 
   473 
   474 	
   474 	
   475 
   475 
   476 CGavdpConnector* CGavdpConnector::NewL(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr)
   476 CGavdpConnector* CGavdpConnector::NewL(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr, TBool aPassive)
   477 	{
   477 	{
   478 	return new (ELeave) CGavdpConnector(aGavdp, aUser, aAddr);
   478 	return new (ELeave) CGavdpConnector(aGavdp, aUser, aAddr, aPassive);
   479 	}
   479 	}
   480 	
   480 
   481 CGavdpConnector::CGavdpConnector(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr)
   481 CGavdpConnector::CGavdpConnector(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr, TBool aPassive)
   482 : CGavdpHelper(aGavdp, aUser)
   482 : CGavdpHelper(aGavdp, aUser)
   483 	{
   483 	{
   484 	iSocketAddress.SetBTAddr(aAddr);
   484 	iSocketAddress.SetBTAddr(aAddr);
   485 	iSocketAddress.SetSession(ESignalling);
   485 	iSocketAddress.SetSession(ESignalling);
       
   486 	iIsPassiveConnector = aPassive;
   486 	}
   487 	}
   487 
   488 
   488 CGavdpConnector::~CGavdpConnector()
   489 CGavdpConnector::~CGavdpConnector()
   489 	{
   490 	{
   490 	Cancel();
   491 	Cancel();
   491 	}
   492 	}
   492 
   493 
   493 void CGavdpConnector::DoCancel()
   494 void CGavdpConnector::DoCancel()
   494 	{
   495 	{
   495 	AvdtpRequester().CancelAll(); // ESOCK has better semantics to SAP than CancelConnect.
   496 	//don't call cancel on the socket for passive connectors to prevent cancelling a listening socket
   496 	}
   497 	if (!iIsPassiveConnector)
   497 
   498 		{
       
   499 		AvdtpRequester().CancelAll(); // ESOCK has better semantics to SAP than CancelConnect.
       
   500 		}
       
   501 	}
   498 
   502 
   499 void CGavdpConnector::Begin()
   503 void CGavdpConnector::Begin()
   500 	{
   504 	{
   501 	// Ensure that once this is completed the RunL is scheduled
   505 	// Ensure that once this is completed the RunL is scheduled
   502 	// before handling completion of the indication ioctl.
   506 	// before handling completion of the indication ioctl.
   505 	SetActive();
   509 	SetActive();
   506 	}
   510 	}
   507 
   511 
   508 void CGavdpConnector::RunL()
   512 void CGavdpConnector::RunL()
   509 	{
   513 	{
   510 		
       
   511 	// Do not call CGavdpHelper::CheckFailedL() here - avdtp will indicate a failure to connect, 
   514 	// Do not call CGavdpHelper::CheckFailedL() here - avdtp will indicate a failure to connect, 
   512 	// and GAVDP is informed via CGavdpIndicator::RunL().
   515 	// and GAVDP is informed via CGavdpIndicator::RunL().
   513 	
   516 	
   514 	TInt error = iStatus.Int();
   517 	TInt error = iStatus.Int();
   515 	DetachFromGavdp(error);	
   518 	DetachFromGavdp(error);	
   749 			default:
   752 			default:
   750 				{
   753 				{
   751 				}
   754 				}
   752 			};
   755 			};
   753 		}
   756 		}
   754 
   757 	
   755 		// This service is never complete, reissue ioctl.  We do this once we have finished using
   758 	// This service is never complete, reissue ioctl.  We do this once we have finished using
   756 		// the iIndication data as once the ioctl has been issued the data may be overwritten.
   759 	// the iIndication data as once the ioctl has been issued the data may be overwritten.
   757 		// If AVDTP has an indication to pass to us and an ioctl has not been issued the
   760 	// If AVDTP has an indication to pass to us and an ioctl has not been issued the
   758 		// indication will be queued within AVDTP until we have issued the ioctl again.
   761 	// indication will be queued within AVDTP until we have issued the ioctl again.
   759 		Begin();
   762 	Begin();
   760 	}
   763 	}
   761 	
   764 
   762 /**
   765 /**
   763 RunError overriden for CGavdpIndicator only. This GAVDP helper is used in its own right by GAVDP.
   766 RunError overriden for CGavdpIndicator only. This GAVDP helper is used in its own right by GAVDP.
   764 It is not treated as a 'general' GAVDP helper, and, unlike a 'general' GAVDP helper,
   767 It is not treated as a 'general' GAVDP helper, and, unlike a 'general' GAVDP helper,
   765 should live for the duration of GAVDP.
   768 should live for the duration of GAVDP.
   766 Note, however that hitting this RunError is deemed fatal, and so we kill GAVDP completely. The 
   769 Note, however that hitting this RunError is deemed fatal, and so we kill GAVDP completely. The