bluetooth/gavdp/source/gavdpHelpers.cpp
branchRCL_3
changeset 56 015fa7494bd2
parent 41 786b94c6f0a4
equal deleted inserted replaced
49:10183c6d2913 56:015fa7494bd2
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2009 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, TBool aPassive)
   476 CGavdpConnector* CGavdpConnector::NewL(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr)
   477 	{
   477 	{
   478 	return new (ELeave) CGavdpConnector(aGavdp, aUser, aAddr, aPassive);
   478 	return new (ELeave) CGavdpConnector(aGavdp, aUser, aAddr);
   479 	}
   479 	}
   480 
   480 	
   481 CGavdpConnector::CGavdpConnector(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr, TBool aPassive)
   481 CGavdpConnector::CGavdpConnector(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr)
   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;
       
   487 	}
   486 	}
   488 
   487 
   489 CGavdpConnector::~CGavdpConnector()
   488 CGavdpConnector::~CGavdpConnector()
   490 	{
   489 	{
   491 	Cancel();
   490 	Cancel();
   492 	}
   491 	}
   493 
   492 
   494 void CGavdpConnector::DoCancel()
   493 void CGavdpConnector::DoCancel()
   495 	{
   494 	{
   496 	//don't call cancel on the socket for passive connectors to prevent cancelling a listening socket
   495 	AvdtpRequester().CancelAll(); // ESOCK has better semantics to SAP than CancelConnect.
   497 	if (!iIsPassiveConnector)
   496 	}
   498 		{
   497 
   499 		AvdtpRequester().CancelAll(); // ESOCK has better semantics to SAP than CancelConnect.
       
   500 		}
       
   501 	}
       
   502 
   498 
   503 void CGavdpConnector::Begin()
   499 void CGavdpConnector::Begin()
   504 	{
   500 	{
   505 	// Ensure that once this is completed the RunL is scheduled
   501 	// Ensure that once this is completed the RunL is scheduled
   506 	// before handling completion of the indication ioctl.
   502 	// before handling completion of the indication ioctl.
   509 	SetActive();
   505 	SetActive();
   510 	}
   506 	}
   511 
   507 
   512 void CGavdpConnector::RunL()
   508 void CGavdpConnector::RunL()
   513 	{
   509 	{
       
   510 		
   514 	// Do not call CGavdpHelper::CheckFailedL() here - avdtp will indicate a failure to connect, 
   511 	// Do not call CGavdpHelper::CheckFailedL() here - avdtp will indicate a failure to connect, 
   515 	// and GAVDP is informed via CGavdpIndicator::RunL().
   512 	// and GAVDP is informed via CGavdpIndicator::RunL().
   516 	
   513 	
   517 	TInt error = iStatus.Int();
   514 	TInt error = iStatus.Int();
   518 	DetachFromGavdp(error);	
   515 	DetachFromGavdp(error);	
   752 			default:
   749 			default:
   753 				{
   750 				{
   754 				}
   751 				}
   755 			};
   752 			};
   756 		}
   753 		}
   757 	
   754 
   758 	// This service is never complete, reissue ioctl.  We do this once we have finished using
   755 		// This service is never complete, reissue ioctl.  We do this once we have finished using
   759 	// the iIndication data as once the ioctl has been issued the data may be overwritten.
   756 		// the iIndication data as once the ioctl has been issued the data may be overwritten.
   760 	// If AVDTP has an indication to pass to us and an ioctl has not been issued the
   757 		// If AVDTP has an indication to pass to us and an ioctl has not been issued the
   761 	// indication will be queued within AVDTP until we have issued the ioctl again.
   758 		// indication will be queued within AVDTP until we have issued the ioctl again.
   762 	Begin();
   759 		Begin();
   763 	}
   760 	}
   764 
   761 	
   765 /**
   762 /**
   766 RunError overriden for CGavdpIndicator only. This GAVDP helper is used in its own right by GAVDP.
   763 RunError overriden for CGavdpIndicator only. This GAVDP helper is used in its own right by GAVDP.
   767 It is not treated as a 'general' GAVDP helper, and, unlike a 'general' GAVDP helper,
   764 It is not treated as a 'general' GAVDP helper, and, unlike a 'general' GAVDP helper,
   768 should live for the duration of GAVDP.
   765 should live for the duration of GAVDP.
   769 Note, however that hitting this RunError is deemed fatal, and so we kill GAVDP completely. The 
   766 Note, however that hitting this RunError is deemed fatal, and so we kill GAVDP completely. The