bluetoothengine/btsap/src/BTSapStateIdle.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 BTSapServer's state for setting up connection with BTSap client
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "BTSapServerState.h"
       
    23 #include "BTSapSocketHandler.h"
       
    24 #include "debug.h"
       
    25 
       
    26 CBTSapServerState::TStateIdle::TStateIdle(CBTSapServerState& aServerState)
       
    27     : TState(aServerState)
       
    28     {
       
    29     }
       
    30 
       
    31 // ---------------------------------------------------------------------
       
    32 // Enter
       
    33 // calling NotifyCardStatus() of RMmCustomAPI
       
    34 // ----------------------------------------------------------------------
       
    35 void CBTSapServerState::TStateIdle:: Enter(TRequestStatus& aStatus)
       
    36     {
       
    37     BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap]  SM: TStateIdle: Enter")));
       
    38 
       
    39     iStatus = &aStatus;
       
    40     aStatus = KRequestPending;
       
    41     }
       
    42 
       
    43 // --------------------------------------------------------------------------------------------
       
    44 // Complete
       
    45 // set next state
       
    46 // --------------------------------------------------------------------------------------------
       
    47 //
       
    48 TBTSapServerState CBTSapServerState::TStateIdle::Complete(TInt /*aReason*/)
       
    49     {
       
    50     BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap]  SM: TStateIdle: Complete")));
       
    51 
       
    52     return EStateIdle;
       
    53     }
       
    54 
       
    55 void CBTSapServerState::TStateIdle::Cancel()
       
    56     {
       
    57     if (*iStatus == KRequestPending)
       
    58         {
       
    59         BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap]  TStateIdle: Cancel")));
       
    60         User::RequestComplete(iStatus, KErrCancel);
       
    61         }
       
    62     }
       
    63 
       
    64 TInt CBTSapServerState::TStateIdle::DisconnectSapConnection(TBTSapDisconnectType aType)
       
    65     {
       
    66     // set iResponse: disconnect_ind
       
    67     iResponseMessage.SetMsgID(EDisconnectIndication);
       
    68     iResponseMessage.AddParameter(EParaDisconnectionType, aType);
       
    69     iServerState.BTSapSocketHandler().Send(iResponseMessage.Data());
       
    70 
       
    71     return KErrNone;
       
    72     }
       
    73 
       
    74 void CBTSapServerState::TStateIdle::SimCardStatusChanged(TCardStatus aCardStatus)
       
    75     {
       
    76     // status_ind
       
    77     iResponseMessage.SetMsgID(EStatusIndication);
       
    78     iResponseMessage.AddParameter(EParaStatusChange, aCardStatus);
       
    79     iServerState.BTSapSocketHandler().Send(iResponseMessage.Data());
       
    80     }
       
    81 
       
    82 TInt CBTSapServerState::TStateIdle::ChangeState(TBTSapServerState& aNextState)
       
    83     {
       
    84     TInt retVal = KErrNone;
       
    85 
       
    86     if (aNextState == EStateIdle || aNextState == EStateConnect)
       
    87         {
       
    88         aNextState = EStateIdle;
       
    89         retVal = KErrNotSupported;
       
    90         }
       
    91 
       
    92     return retVal;
       
    93     }
       
    94 
       
    95 //  End of File