|
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::TStatePowerOn::TStatePowerOn(CBTSapServerState& aServerState) |
|
27 : TStateIdle(aServerState), iResultCode(EResultCodeReserved), iCardStatus(ECardStatusReserved) |
|
28 { |
|
29 } |
|
30 |
|
31 // --------------------------------------------------------- |
|
32 // Enter |
|
33 // --------------------------------------------------------- |
|
34 void CBTSapServerState::TStatePowerOn:: Enter(TRequestStatus& aStatus) |
|
35 { |
|
36 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOn: Enter"))); |
|
37 |
|
38 if (iResultCode == EResultCodeReserved) |
|
39 { |
|
40 iStatus = &aStatus; |
|
41 iServerState.SubscriptionModule().PowerSimOn(aStatus); |
|
42 } |
|
43 else |
|
44 { |
|
45 aStatus = KRequestPending; |
|
46 } |
|
47 } |
|
48 |
|
49 // -------------------------------------------------------------------------------------------- |
|
50 // Complete |
|
51 // set next state |
|
52 // -------------------------------------------------------------------------------------------- |
|
53 // |
|
54 TBTSapServerState CBTSapServerState::TStatePowerOn::Complete(TInt aReason) |
|
55 { |
|
56 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOn: Complete: %d"), aReason)); |
|
57 |
|
58 TBTSapServerState state = EStatePowerOn; |
|
59 |
|
60 if (iResultCode == EResultCodeReserved) |
|
61 { |
|
62 iResultCode = iResponseMessage.ToResultCode(aReason); |
|
63 } |
|
64 |
|
65 if (iCardStatus != ECardStatusReserved || |
|
66 aReason != KErrNone) |
|
67 { |
|
68 iResponseMessage.SetMsgID(EPowerSimOnResponse); |
|
69 iResponseMessage.AddParameter(EParaResultCode, iResultCode); |
|
70 iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); |
|
71 |
|
72 iResultCode = EResultCodeReserved; |
|
73 iCardStatus = ECardStatusReserved; |
|
74 state = EStateIdle; |
|
75 } |
|
76 |
|
77 return state; |
|
78 } |
|
79 |
|
80 void CBTSapServerState::TStatePowerOn::Cancel() |
|
81 { |
|
82 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStatePowerOn: Cancel"))); |
|
83 |
|
84 if (iResultCode == EResultCodeReserved) |
|
85 { |
|
86 iServerState.SubscriptionModule().CancelAsyncRequest(ECustomPowerSimOnIPC); |
|
87 } |
|
88 else |
|
89 { |
|
90 iResultCode = EResultCodeReserved; |
|
91 iCardStatus = ECardStatusReserved; |
|
92 TStateIdle::Cancel(); |
|
93 } |
|
94 } |
|
95 |
|
96 TInt CBTSapServerState::TStatePowerOn::ChangeState(TBTSapServerState& aNextState) |
|
97 { |
|
98 TInt retVal = KErrNone; |
|
99 |
|
100 if (aNextState != EStatePowerOff && |
|
101 aNextState != EStateDisconnect) |
|
102 { |
|
103 aNextState = EStateIdle; |
|
104 retVal = KErrNotSupported; |
|
105 } |
|
106 |
|
107 return retVal; |
|
108 } |
|
109 |
|
110 void CBTSapServerState::TStatePowerOn::SimCardStatusChanged(TCardStatus aCardStatus) |
|
111 { |
|
112 iCardStatus = aCardStatus; |
|
113 User::RequestComplete(iStatus, KErrNone); |
|
114 } |
|
115 |
|
116 // End of File |