bluetooth/gavdp/source/gavdpImp.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".
   443 		}
   443 		}
   444 	}
   444 	}
   445 	
   445 	
   446 void CGavdp::Error(TInt aError)
   446 void CGavdp::Error(TInt aError)
   447 	{
   447 	{
   448 	//here we do whatever we need to tidy ourselves
   448 	// helper tells user - here we do whatever we need to tidy ourselves
   449 	delete iRequesterHelper;
   449 	delete iRequesterHelper;
   450 	iRequesterHelper = NULL;
   450 	iRequesterHelper = NULL;
   451 	
   451 	iState = EIdle;
   452 	if (iState == EListening)
   452 	// and tell the user
   453 		{
   453 	iServiceUser.GAVDP_Error(aError, KNullDesC8);
   454 		//if we're in the listening state and we get a KErrDisconnected error, this is
       
   455 		//because a connection completed and was disconnected straight away before we got
       
   456 		//the chance to pickup the connection indicator. We need to re-listen and throw
       
   457 		//away this error. Let's replace the error with the result of the re-listen.
       
   458 		if (aError == KErrDisconnected)
       
   459 			{
       
   460 			aError = Listen();
       
   461 			}
       
   462 		
       
   463 		//when listening, it doesn't make sense to pass this error to the user
       
   464 		if (aError == KErrCouldNotConnect)
       
   465 			{
       
   466 			aError = KErrNone;
       
   467 			}
       
   468 		}
       
   469 	
       
   470 	//the error might have been replaced due to the condition mentioned above so
       
   471 	//this needs to be checked.
       
   472 	if (aError != KErrNone)
       
   473 		{
       
   474 		iServiceUser.GAVDP_Error(aError, KNullDesC8);
       
   475 		
       
   476 		//update the state because an error did occur
       
   477 		iState = EIdle;
       
   478 		}
       
   479 	}
   454 	}
   480 
   455 
   481 void CGavdp::FatalError()
   456 void CGavdp::FatalError()
   482 	{
   457 	{
   483 	//Unbind from the body before informing the user
   458 	//Unbind from the body before informing the user
   499 		// the client has just issued another command
   474 		// the client has just issued another command
   500 		// this is likely to be something that renders the connections invalid anyway
   475 		// this is likely to be something that renders the connections invalid anyway
   501 		// eg Abort, Config
   476 		// eg Abort, Config
   502 		User::Leave(KErrInUse);
   477 		User::Leave(KErrInUse);
   503 		}
   478 		}
   504 	
   479 	iRequesterHelper = CGavdpConnector::NewL(*this, iServiceUser, aRemoteAddress);
   505 	//create a passive connector helper
       
   506 	iRequesterHelper = CGavdpConnector::NewL(*this, iServiceUser, aRemoteAddress, ETrue);
       
   507 	iRequesterHelper->Begin();
   480 	iRequesterHelper->Begin();
   508 	}
   481 	}
   509 
   482 	
   510 /*
   483 /*
   511 Forms the binding between passively created transport sessions and sockets
   484 Forms the binding between passively created transport sessions and sockets
   512 */
   485 */
   513 void CGavdp::BindBearersL(TSEID aSEID, TBool aRequireReporting, TBool aRequireRecovery)
   486 void CGavdp::BindBearersL(TSEID aSEID, TBool aRequireReporting, TBool aRequireRecovery)
   514 	{
   487 	{