bluetoothengine/btsap/inc/BTSapSecurityHandler.h
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     This class handles SAP security checking
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef BT_SAP_SECURITY_HANDLER_H
       
    20 #define BT_SAP_SECURITY_HANDLER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <bt_sock.h>
       
    24 #include <hciproxy.h>
       
    25 #include <btengdevman.h>
       
    26 
       
    27 // Vendor specific
       
    28 const TUint8 KCmdInfo[] = {0xFC, 0x00, 0x00, 0x00, 0xFC, 0x04, 0xF0, 0x07, 0x00, 0x00};
       
    29 const TInt KExtCmdLen = 10;
       
    30 
       
    31 // Security settings
       
    32 const TInt KRequiredPassKeyLen       = 16;
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CBTEngDevMan;
       
    36 class CBTHciExtensionMan;
       
    37     
       
    38 enum TBTSapSecurityCheckResult
       
    39     {
       
    40     ESecurityOK,
       
    41     EGetEncryptionKeyFail,
       
    42     EEncryptionKeyTooShort,
       
    43     EPassKeyTooShort
       
    44     };
       
    45 
       
    46 class CBTSapSecurityHandler : public CActive, MBTEngDevManObserver
       
    47     {
       
    48 public:
       
    49     // Constructors
       
    50     static CBTSapSecurityHandler* NewL();
       
    51 
       
    52     // Destructor
       
    53 	~CBTSapSecurityHandler();
       
    54 
       
    55 private:     // From CActive
       
    56    
       
    57     /**
       
    58     * DoCancel() has to be implemented by all the classes deriving CActive.
       
    59     * Request cancellation routine.
       
    60     * @param none
       
    61     * @return none 
       
    62     */
       
    63     void DoCancel();
       
    64     
       
    65     /**
       
    66     * RunL is called by framework after request is being completed.
       
    67     * @param nones
       
    68     * @return none 
       
    69     */
       
    70 	void RunL();
       
    71 	
       
    72 	/**
       
    73 	* RunError is used for handling leaves that occure inside RunL
       
    74 	*/
       
    75 	TInt RunError(TInt aError);
       
    76 
       
    77 public:
       
    78 
       
    79     void CheckSapSecurity(RSocket& aSocket, TRequestStatus& aStatus);
       
    80 
       
    81 private:
       
    82 
       
    83     // Two-phase constructor
       
    84     void ConstructL();
       
    85 
       
    86     // Default constructor
       
    87     CBTSapSecurityHandler();
       
    88     
       
    89     // from MBTEngDevManObserver
       
    90     void HandleGetDevicesComplete(TInt aErr,CBTDeviceArray* aDeviceArray);
       
    91     
       
    92 private:
       
    93 
       
    94     enum TState
       
    95         {
       
    96         EEncryptionKeyLength,
       
    97         EPassKeyLength
       
    98         };
       
    99 
       
   100 private:
       
   101 
       
   102     TRequestStatus *iSecurityStatus;
       
   103     RSocket        *iSocket;
       
   104     CBTHciExtensionMan* iBtHci;
       
   105     
       
   106     CBTEngDevMan* iBtDevMan;
       
   107     CBTDeviceArray* iBtDeviceArray;
       
   108     TState iState;
       
   109 
       
   110     THCIConnHandle iHCIConnHandle;
       
   111     TPckgBuf<THCIConnHandle> iHCIHandleBuf;
       
   112     TBuf8<KExtCmdLen> iExtCmd;
       
   113 
       
   114     TUint8 iEncryptionKeyLength;
       
   115     };
       
   116 
       
   117 #endif // BT_SAP_SECURITY_HANDLER_H