bluetooth/gavdp/source/gavdpImp.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".
   443 		}
   443 		}
   444 	}
   444 	}
   445 	
   445 	
   446 void CGavdp::Error(TInt aError)
   446 void CGavdp::Error(TInt aError)
   447 	{
   447 	{
   448 	// helper tells user - here we do whatever we need to tidy ourselves
   448 	//here we do whatever we need to tidy ourselves
   449 	delete iRequesterHelper;
   449 	delete iRequesterHelper;
   450 	iRequesterHelper = NULL;
   450 	iRequesterHelper = NULL;
   451 	iState = EIdle;
   451 	
   452 	// and tell the user
   452 	if (iState == EListening)
   453 	iServiceUser.GAVDP_Error(aError, KNullDesC8);
   453 		{
       
   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 		}
   454 	}
   479 	}
   455 
   480 
   456 void CGavdp::FatalError()
   481 void CGavdp::FatalError()
   457 	{
   482 	{
   458 	//Unbind from the body before informing the user
   483 	//Unbind from the body before informing the user
   474 		// the client has just issued another command
   499 		// the client has just issued another command
   475 		// this is likely to be something that renders the connections invalid anyway
   500 		// this is likely to be something that renders the connections invalid anyway
   476 		// eg Abort, Config
   501 		// eg Abort, Config
   477 		User::Leave(KErrInUse);
   502 		User::Leave(KErrInUse);
   478 		}
   503 		}
   479 	iRequesterHelper = CGavdpConnector::NewL(*this, iServiceUser, aRemoteAddress);
   504 	
       
   505 	//create a passive connector helper
       
   506 	iRequesterHelper = CGavdpConnector::NewL(*this, iServiceUser, aRemoteAddress, ETrue);
   480 	iRequesterHelper->Begin();
   507 	iRequesterHelper->Begin();
   481 	}
   508 	}
   482 	
   509 
   483 /*
   510 /*
   484 Forms the binding between passively created transport sessions and sockets
   511 Forms the binding between passively created transport sessions and sockets
   485 */
   512 */
   486 void CGavdp::BindBearersL(TSEID aSEID, TBool aRequireReporting, TBool aRequireRecovery)
   513 void CGavdp::BindBearersL(TSEID aSEID, TBool aRequireReporting, TBool aRequireRecovery)
   487 	{
   514 	{