bluetooth/btstack/rfcomm/rfcomm.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 //
       
    15 
       
    16 #ifndef RFCOMM_H
       
    17 #define RFCOMM_H
       
    18 
       
    19 #include <es_prot.h>
       
    20 
       
    21 #include <bttypes.h>
       
    22 #include "secman.h"
       
    23 #include "bt.h"
       
    24 #include <es_prot_internal.h>
       
    25 
       
    26 const TUint KRFCOMMStreamServiceInfo = 
       
    27   KSIReliable|KSIInOrder|KSIStreamBased|KSIGracefulClose|KSICanReconnect;
       
    28 
       
    29 class CBTProtocolFamily;
       
    30 class CRfcommMuxer;
       
    31 class CMuxChannelStateFactory;
       
    32 class CRfcommStateFactory;
       
    33 class CRfcommFlowStrategyFactory;
       
    34 class CRfcommPortAllocator;
       
    35 class CRfcommSAP;
       
    36 class TBTSockAddr;
       
    37 class CRfcommIncomingConnectionListener;
       
    38 
       
    39 /**
       
    40    The RFCOMM Protocol class.
       
    41    
       
    42    This is the singleton object created by ESOCK to provide access to all
       
    43    the RFCOMM services.
       
    44 */
       
    45 
       
    46 NONSHARABLE_CLASS(CRfcommProtocol) : public CBluetoothProtocolBase
       
    47 	{
       
    48 public:
       
    49 	// Create ourselves
       
    50 	static CRfcommProtocol* NewL(CBTSecMan& aSecMan, RBTControlPlane& aControlPlane, CBTCodServiceMan& aCodMan);
       
    51 	
       
    52 	// From CProtocolBase
       
    53 	// Factories
       
    54 	CServProviderBase* NewSAPL(TUint aSockType);
       
    55 	
       
    56 	void Close();
       
    57 	void Open();
       
    58 	void CloseNow();
       
    59 
       
    60 	// From ProtocolManager before all binding.
       
    61 	void InitL(TDesC &aTag);
       
    62 	// From Protocol Manager - after all binding
       
    63 	void StartL();	
       
    64 	// From Protocol Manager
       
    65 	void BindToL(CProtocolBase* protocol);
       
    66 
       
    67 	// Query functions
       
    68 	void Identify(TServerProtocolDesc* aProtocolDesc)const;	
       
    69 	static void ProtocolIdentity(TServerProtocolDesc* aDesc);	
       
    70 
       
    71 	// Rfcomm specific functions
       
    72 	CRfcommStateFactory* StateFactory() const;
       
    73 	CRfcommFlowStrategyFactory* FlowStrategyFactory() const;
       
    74 
       
    75 	// Get our local address
       
    76 	const TBTDevAddr& LocalBTAddr() const;
       
    77 
       
    78 	//	Two flavours of GetMux to provide pointers to CRfcommMuxers on demand.
       
    79 
       
    80 	//	First function - called when attempting to create an outgoing connection
       
    81 	TInt GetMux(TBTSockAddr& aRemoteAddr, CRfcommMuxer*& aMuxer);
       
    82 
       
    83 	// From BluetoothProtocolBase
       
    84 	virtual TInt BearerConnectComplete(const TBTDevAddr& aAddr, CServProviderBase* aSSP);
       
    85 
       
    86 	void MuxDown(CRfcommMuxer& aMux);
       
    87 
       
    88 	// Functions to manipulate and query the list of listening RFCOMM SAPs
       
    89 	void AddIdleSAP(CRfcommSAP& aSAP);
       
    90 	void RemoveIdleSAP(CRfcommSAP& aSAP);
       
    91 	CRfcommSAP* FindIdleSAP(const TBTSockAddr& aSockAddr);
       
    92 	TInt FindFreeServerChannel();
       
    93 
       
    94 	void DisallowCBFC();
       
    95 	void AllowCBFC();
       
    96 	TBool CBFCDisallowed();
       
    97 
       
    98 	void AddBoundSAP(CRfcommSAP& aSAP);
       
    99 	void RemoveBoundSAP(CRfcommSAP& aSAP);
       
   100 	CRfcommSAP* FindBoundSAP(const TBTSockAddr& aSockAddr);
       
   101 	TBool SAPIsBound(const CRfcommSAP& aSAP);
       
   102 
       
   103 	CRfcommSAP* FindInboundConnectedSAP(const TBTSockAddr& aSockAddr);
       
   104 
       
   105 	void SetL2CapConfig(TL2CapConfigPkg& aConfigPkg);
       
   106 
       
   107 private:
       
   108 	// Functions
       
   109 	CRfcommProtocol(CBTSecMan& aSecMan, RBTControlPlane& aControlPlane, CBTCodServiceMan& aCodMan);
       
   110 	void ConstructL();
       
   111 	~CRfcommProtocol();
       
   112 
       
   113 	CRfcommMuxer* FindMux(const TBTDevAddr& aAddr);
       
   114 	TBool CheckForClose();
       
   115 	static TInt TryToClose(TAny* aProtocol);
       
   116 	void RemoveIdleTimerEntry();
       
   117 	void QueIdleTimerEntry();
       
   118 	
       
   119 	//	Called when responding to an incoming connection request
       
   120 	TInt GetMux(const TBTDevAddr& aRemoteAddr, CServProviderBase* aL2CAPConSAP, CRfcommMuxer*& aMuxer);
       
   121 	virtual TInt StartProtocolListening();
       
   122 
       
   123 private:
       
   124 	// Data members
       
   125 	CRfcommStateFactory*		iStateFactory;
       
   126 	CRfcommFlowStrategyFactory*	iFlowStrategyFactory;
       
   127 	CMuxChannelStateFactory*	iMuxChannelStateFactory;
       
   128 
       
   129 	TBool   iClosePending;
       
   130 	TDblQue<CRfcommMuxer> iMuxes;   // All the muxes
       
   131 	TDblQue<CRfcommSAP> iListeningSAPs;	// SAPS which are listening
       
   132 	TDblQue<CRfcommSAP> iBoundSAPs;		// SAPS which are bound
       
   133 	TDeltaTimerEntry  iIdleTimerEntry;
       
   134 	TBool             iIdleEntryQueued;
       
   135 	TBool			  iCBFCDisallowed; //"Etrue" => a SetOpt has switched CBFC off
       
   136 	};
       
   137 
       
   138 
       
   139 #endif