bluetooth/btstack/avdtp/avdtpRecoverySession.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Implements the avdtp recovery transport session
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include "avdtpRecoverySession.h"
       
    24 #include "avdtp.h"
       
    25 #include "avdtpStream.h"
       
    26 #include "avdtpsap.h"
       
    27 
       
    28 CRecoverySession* CRecoverySession::NewLC(CAvdtpProtocol& aProtocol,
       
    29 											CAvdtpSAP& aSAP, CAVStream& aStream)
       
    30 	{
       
    31 	CRecoverySession* s = new (ELeave) CRecoverySession(aProtocol, aSAP, aStream);
       
    32 	CleanupStack::PushL(s);
       
    33 	s->ConstructL();
       
    34 	return s;
       
    35 	}
       
    36 	
       
    37 CRecoverySession* CRecoverySession::NewL(CAvdtpProtocol& aProtocol,
       
    38 										   CAvdtpSAP& aSAP, CAVStream& aStream)
       
    39 	{
       
    40 	CRecoverySession* s = CRecoverySession::NewLC(aProtocol, aSAP, aStream);
       
    41 	CleanupStack::Pop();
       
    42 	return s;		
       
    43 	}
       
    44 	
       
    45 CRecoverySession::CRecoverySession(CAvdtpProtocol& aProtocol, CAvdtpSAP& aSAP, CAVStream& aStream)
       
    46 : CUserPlaneTransportSession(aProtocol, aSAP, ERecovery, aStream)
       
    47 	{
       
    48 	
       
    49 	}
       
    50 	
       
    51 void CRecoverySession::ConstructL()
       
    52 	{
       
    53 	CUserPlaneTransportSession::ConstructL();
       
    54 	
       
    55 	// Balking is set to true.  This allows the circular buffer to wrap
       
    56 	// and overwrite the oldest data.
       
    57 	User::LeaveIfError(iSendPool.Create(4, ETrue));
       
    58 	User::LeaveIfError(iReceivePool.Create(4, ETrue));
       
    59 	}
       
    60 
       
    61 TInt CRecoverySession::DoActiveOpen()
       
    62 	{
       
    63 	__ASSERT_DEBUG(iStream, Panic(EAvdtpTransportSessionBaseNotCheckStream));
       
    64 
       
    65 	TInt ret = KErrGeneral;
       
    66 		
       
    67 	// add session to the stream
       
    68 	ret = iStream->AddSession(ERecovery,*this,iTransportChannel);
       
    69 	if (ret!=KErrNone)
       
    70 		{
       
    71 		// not erroring the stream, as it's not it's fault
       
    72 		// and it may not exist anyway!
       
    73 		iStream = NULL;
       
    74 		iSAP.Error(ret);
       
    75 		}
       
    76 	
       
    77 	return ret;
       
    78 	}
       
    79 
       
    80 TInt CRecoverySession::Send(RMBufChain& aData, TUint /*aOptions*/, TSockAddr* /*aAddr*/)
       
    81 	{
       
    82 	return iTransportChannel->SendPacket(ERecovery, aData);
       
    83 	}
       
    84 	
       
    85 
       
    86 void CRecoverySession::CanSend()
       
    87 	{
       
    88 	// drain some pool? or just tell sap?
       
    89 	
       
    90 	}
       
    91