bluetooth/btstack/inc/BtSap.h
changeset 0 29b1cd4cb562
child 48 22de2e391156
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2005-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 _BTSAP_H
       
    17 #define _BTSAP_H
       
    18 
       
    19 #include <es_prot.h>
       
    20 #include <bt_sock.h>
       
    21 #include <btdevice.h>
       
    22 #include "SecManNotifiers.h"
       
    23 
       
    24 class CBTSecMan;
       
    25 class CBTCodServiceMan;
       
    26 
       
    27 NONSHARABLE_CLASS(CBluetoothSAP) : public CServProviderBase, public MAccessRequestResponseHandler
       
    28 /**
       
    29 	Acts as the base for Bluetooth SAPs; factoring aspects common to all.
       
    30 	This should be extended in future...
       
    31 **/
       
    32 	{
       
    33 public:
       
    34 	// return reference to the security of the service represented by this SAP
       
    35 	const TBTServiceSecurity& Security() const;
       
    36 
       
    37 	// return a pointer to a possible device override to the security settings
       
    38 	// returns NULL if none
       
    39 	const TBTServiceSecurityPerDevice* Override(const TBTDevAddr& aAddress) const;
       
    40 	
       
    41 	// begin the security state machine
       
    42 	void StartAccessRequest(const CBluetoothSAP& aSAPWithSecuritySettings, TBool aSecurityModeFourOutgoing = EFalse);
       
    43 	void CancelAccessRequest();
       
    44 
       
    45 	// callback from secman with either granted or denied access
       
    46 	virtual void AccessRequestComplete(TInt aResult);
       
    47 
       
    48 	virtual void IoctlComplete(TInt aErr, TUint aLevel, TUint aName, TDesC8* aBuf);
       
    49 	inline CBTSecMan& SecMan() const;
       
    50 	inline CBTCodServiceMan& CodMan() const;
       
    51 	inline const TBTDevAddr& RemoteAddress() const;
       
    52 
       
    53 	TInt SetCodServiceBits(TUint16 aNewCodServiceBits);
       
    54 	void RegisterCodService();
       
    55 	void DeregisterCodService();
       
    56 
       
    57 	TInt SetOption(TUint aLevel,TUint aName,const TDesC8 &aOption);
       
    58 	virtual TInt SAPSetOption(TUint aLevel,TUint aName,const TDesC8 &aOption) = 0;
       
    59 	
       
    60 	//From CServProviderBase
       
    61 	TInt SecurityCheck(MProvdSecurityChecker *aSecurityChecker);
       
    62 
       
    63 	~CBluetoothSAP();
       
    64 
       
    65 protected:
       
    66 	CBluetoothSAP(CBTSecMan& aSecMan, CBTCodServiceMan& aCodMan);
       
    67 	void ConstructL();
       
    68 	TInt SetDeviceOverride(const TDesC8& aOption);
       
    69 	TInt GetDeviceOverride(TDes8& aOption) const;
       
    70 
       
    71 private:
       
    72 	static TInt AccessDeniedCallBack(TAny* aBtSap);
       
    73 
       
    74 protected:
       
    75 	TBTServiceSecurity	iSecurity;	// the security the service (on this SAP) has requested
       
    76 	RBTSecurityArray	iDeviceOverrides;	// the overrides
       
    77 	TUint				iIoctlLevel;
       
    78 	TUint				iIoctlName;
       
    79 	TBTDevAddr			iRemoteDev;
       
    80 	TUint16				iCodServiceBits;// SAP's record Services they set (see TBTMajorServiceClass), 
       
    81 										// so they can be removed from the CoD when a SAP dies.
       
    82 										// MSB is Register Flag
       
    83 										
       
    84 	//Mixin providing security checking, This is not an owned variable.
       
    85 	MProvdSecurityChecker* iSecurityChecker;
       
    86 
       
    87 private:
       
    88 	CBTSecMan&			iSecMan;
       
    89 	CBTCodServiceMan&	iCodMan;
       
    90 
       
    91 	CAsyncCallBack*		iAccessDeniedCallBack;
       
    92 	};
       
    93 
       
    94 
       
    95 inline const TBTDevAddr& CBluetoothSAP::RemoteAddress() const
       
    96 	{
       
    97 	return iRemoteDev;
       
    98 	}
       
    99 
       
   100 inline CBTSecMan& CBluetoothSAP::SecMan() const
       
   101 	{
       
   102 	return iSecMan;
       
   103 	}
       
   104 
       
   105 inline CBTCodServiceMan& CBluetoothSAP::CodMan() const
       
   106 	{
       
   107 	return iCodMan;
       
   108 	}
       
   109 
       
   110 #endif //_BTSAP_H