bluetoothengine/btsap/src/BTSapSocketStateCheckSecurity.cpp
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 is a BTSapSocketHandler's state for security checking (length of 
       
    16 *     encryption key and pass key)
       
    17 *
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "BTSapSecurityHandler.h"
       
    24 #include "BTSapSocketHandler.h"
       
    25 #include "debug.h"
       
    26 
       
    27 CBTSapSocketHandler::TStateCheckSecurity::TStateCheckSecurity(RSocket& aSocket, CBTSapSecurityHandler*& aSecurityHandler)
       
    28     : TState(aSocket), iSecurityHandler(aSecurityHandler)
       
    29     {
       
    30     }
       
    31 
       
    32 // ---------------------------------------------------------
       
    33 // Enter
       
    34 // ---------------------------------------------------------
       
    35 void CBTSapSocketHandler::TStateCheckSecurity:: Enter(TRequestStatus& aStatus)
       
    36     {
       
    37     BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap]  CBTSapSocketHandler::TStateCheckSecurity: Enter")));
       
    38 
       
    39     iSecurityHandler->CheckSapSecurity(iSocket, aStatus);
       
    40     }
       
    41 
       
    42 // --------------------------------------------------------------------------------------------
       
    43 // Complete
       
    44 // --------------------------------------------------------------------------------------------
       
    45 //
       
    46 TBTSapSocketState CBTSapSocketHandler::TStateCheckSecurity::Complete(TInt aReason)
       
    47     {
       
    48     BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap]  CBTSapSocketHandler::TStateCheckSecurity: Complete")));
       
    49 
       
    50     TBTSapSecurityCheckResult result = TBTSapSecurityCheckResult(aReason);
       
    51 
       
    52     switch (result)
       
    53         {
       
    54         case EEncryptionKeyTooShort:
       
    55             // start notifer here
       
    56             break;
       
    57 
       
    58         case EPassKeyTooShort:
       
    59             // start notifier here
       
    60             break;
       
    61 
       
    62         default:
       
    63             break;
       
    64         }
       
    65 
       
    66     return (result == ESecurityOK ? EBTSapSocketStateRecv : EBTSapSocketStateListen);
       
    67     }
       
    68 
       
    69 void CBTSapSocketHandler::TStateCheckSecurity::Cancel()
       
    70     {
       
    71     BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap]  CBTSapSocketHandler::TStateCheckSecurity: Cancel")));
       
    72 
       
    73     iSecurityHandler->Cancel();
       
    74     }
       
    75 
       
    76 //  End of File