bluetoothengine/btsap/src/BTSapStateAPDU.cpp
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2004-2005 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 BTSapServer's state for setting up connection with SAP client
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "BTSapServerState.h"
       
    21 #include "BTSapSocketHandler.h"
       
    22 #include "debug.h"
       
    23 
       
    24 CBTSapServerState::TStateAPDU::TStateAPDU(CBTSapServerState& aServerState)
       
    25     : TStateIdle(aServerState)
       
    26     {
       
    27     }
       
    28 
       
    29 // ---------------------------------------------------------
       
    30 // Enter
       
    31 // ---------------------------------------------------------
       
    32 void CBTSapServerState::TStateAPDU::Enter(TRequestStatus& aStatus)
       
    33     {
       
    34     BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap]  TStateAPDU::Enter")));
       
    35 
       
    36     iStatus = &aStatus;
       
    37     TInt retValue = iServerState.BTSapRequestMessage().GetParameter(EParaCommandAPDU, iApduParameters.iCmdData);
       
    38     if(retValue == KErrNone)
       
    39         {
       
    40         BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap]  TStateAPDU:: iApduCmd %S"), &iApduParameters.iCmdData));
       
    41         }
       
    42     else
       
    43         {
       
    44         iServerState.BTSapRequestMessage().GetParameter(EParaCommandAPDU7816, iApduParameters.iCmdData);
       
    45         BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap]  TStateAPDU:: iApduCmd (7816) %S"), &iApduParameters.iCmdData));
       
    46         }
       
    47 
       
    48     iServerState.SubscriptionModule().SendAPDUReq(aStatus, iApduParameters);
       
    49 
       
    50     BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap]  TStateAPDU::Enter iApduRsp %S"), &iApduParameters.iRspData));
       
    51     }
       
    52 
       
    53 // --------------------------------------------------------------------------------------------
       
    54 // Complete
       
    55 // set next state
       
    56 // --------------------------------------------------------------------------------------------
       
    57 //
       
    58 TBTSapServerState CBTSapServerState::TStateAPDU::Complete(TInt aReason)
       
    59     {
       
    60     BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintHex(_L8("[BTSap]  TStateAPDU::Complete iApduRsp %S"), &iApduParameters.iRspData));
       
    61 
       
    62     BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L8("[BTSap]  TStateAPDU::Complete aReason %d"), aReason));
       
    63 
       
    64     iResponseMessage.SetMsgID(ETransferAPDUResponse);
       
    65     iResponseMessage.AddParameter(EParaResultCode, iResponseMessage.ToResultCode(aReason));
       
    66 
       
    67     if(iResponseMessage.ToResultCode(aReason) == EResultCodeOK)
       
    68         {
       
    69         iResponseMessage.AddParameter(EParaResponseAPDU, iApduParameters.iRspData);
       
    70         }
       
    71 
       
    72     iServerState.BTSapSocketHandler().Send(iResponseMessage.Data());
       
    73 
       
    74     return EStateIdle;
       
    75     }
       
    76 
       
    77 void CBTSapServerState::TStateAPDU::Cancel()
       
    78     {
       
    79     BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap]  TStateAPDU: Cancel")));
       
    80 
       
    81     iServerState.SubscriptionModule().CancelAsyncRequest(ECustomSendAPDUReqV2IPC);
       
    82     TStateIdle::Cancel();
       
    83     }
       
    84 
       
    85 TInt CBTSapServerState::TStateAPDU::ChangeState(TBTSapServerState& aNextState)
       
    86     {
       
    87     return TState::ChangeState(aNextState);
       
    88     }
       
    89 
       
    90 //  End of File