bluetooth/btstack/l2cap/l2capMuxController.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 1999-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 // Holds a list of all Muxers and listening SAP signal handlers.
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef L2CAPMUXCONTROLLER_H
       
    19 #define L2CAPMUXCONTROLLER_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <e32std.h>
       
    23 
       
    24 class CL2CAPMux;
       
    25 class CL2CapSAPSignalHandler;
       
    26 class CServProviderBase;
       
    27 class TBTDevAddr;
       
    28 class CL2CAPProtocol;
       
    29 
       
    30 NONSHARABLE_CLASS(CL2CAPMuxController) : public CBase
       
    31 	{
       
    32 public:
       
    33 	 CL2CAPMuxController(CL2CAPProtocol& aProtocol);
       
    34 	~CL2CAPMuxController();
       
    35 	
       
    36 	TInt BearerConnectComplete(const TBTDevAddr& aAddr, CServProviderBase* aSAP);
       
    37 	TInt AttachPassiveSignalHandler(CL2CapSAPSignalHandler& aSAPSignalHandler,const TBTDevAddr& aAddr);
       
    38 	void AttachListeningSignalHandler(CL2CapSAPSignalHandler& aSAPSignalHandler);
       
    39 	void AttachBoundSignalHandler(CL2CapSAPSignalHandler& aSAPSignalHandler);
       
    40 	TInt AttachActiveSignalHandler(CL2CapSAPSignalHandler& aSAPSignalHandler,const TBTDevAddr& aAddr);
       
    41 	CL2CapSAPSignalHandler* FindListeningSignalHandler(TL2CAPPort aPort);
       
    42 	CL2CapSAPSignalHandler* FindIdleSignalHandler(TL2CAPPort aPort);
       
    43 	inline CL2CAPProtocol& Protocol() const;
       
    44 
       
    45 	void UpdateMuxerPriorities();
       
    46 	TInt FindFreeUserPSM(TL2CAPPort& aPSM);
       
    47 
       
    48 	inline TBool CanProtocolClose() const;
       
    49 
       
    50 private:
       
    51 	CL2CAPMux* FindMuxer(const TBTDevAddr& aAddr);
       
    52 	CL2CAPMux* CreateMuxerL(const TBTDevAddr& aAddr);
       
    53 
       
    54 protected:
       
    55 
       
    56 private:
       
    57 	enum
       
    58 		{
       
    59 		EBaseMuxerPriority	= CActive::EPriorityStandard,
       
    60 		};
       
    61 
       
    62 	// Dbl link list of Muxers
       
    63 	TDblQue<CL2CAPMux> iMuxers;
       
    64 
       
    65 	// Dbl link list of sap signal handlers that are only bound as yet
       
    66 	TDblQue<CL2CapSAPSignalHandler> iBoundSapSignalHandlers;
       
    67 	
       
    68 	// Dbl link list of listening sap signal handlers
       
    69 	TDblQue<CL2CapSAPSignalHandler> iListeningSapSignalHandlers;
       
    70 
       
    71 	CL2CAPProtocol& iProtocol;
       
    72 
       
    73 	};
       
    74 
       
    75 inline CL2CAPProtocol& CL2CAPMuxController::Protocol() const
       
    76 	{
       
    77 	return iProtocol;
       
    78 	}
       
    79 
       
    80 inline TBool CL2CAPMuxController::CanProtocolClose() const
       
    81 	{
       
    82 	// Only close if all of the containers are empty.
       
    83 	return (iMuxers.IsEmpty() && iBoundSapSignalHandlers.IsEmpty() && iListeningSapSignalHandlers.IsEmpty());
       
    84 	}
       
    85 
       
    86 #endif