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