28 #include "BTSapSimCardStatusNotifier.h" |
28 #include "BTSapSimCardStatusNotifier.h" |
29 #include "debug.h" |
29 #include "debug.h" |
30 |
30 |
31 |
31 |
32 CBTSapServerState::TStateConnect::TStateConnect(CBTSapServerState& aServerState) |
32 CBTSapServerState::TStateConnect::TStateConnect(CBTSapServerState& aServerState) |
33 : TStateIdle(aServerState), iConnectRequestOK(EFalse), iCardStatus(ECardStatusReserved) |
33 : TStateIdle(aServerState), iConnectRequestOK(EFalse), iCardStatus(ECardStatusReserved), iSendRespMessageDone(EFalse), iMessageSizeNegotiationDone(EFalse) |
34 { |
34 { |
35 } |
35 } |
36 |
36 |
37 // --------------------------------------------------------- |
37 // --------------------------------------------------------- |
38 // Enter |
38 // Enter |
41 { |
41 { |
42 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: Enter"))); |
42 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: Enter"))); |
43 |
43 |
44 iStatus = &aStatus; |
44 iStatus = &aStatus; |
45 TConnectionStatus connectionStatus = EConnectionErrReject; |
45 TConnectionStatus connectionStatus = EConnectionErrReject; |
46 if(!IsCallOngoing()) |
46 if (!iMessageSizeNegotiationDone) |
47 { // SAP cannot be accepted if a call is ongoing or if no SIM is present |
|
48 connectionStatus = EConnectionOK; |
|
49 } |
|
50 |
|
51 if (connectionStatus == EConnectionOK) |
|
52 { |
47 { |
53 CheckMaxMsgSize(connectionStatus); |
48 CheckMaxMsgSize(connectionStatus); |
|
49 } |
|
50 |
|
51 if (connectionStatus == EConnectionOK || iMessageSizeNegotiationDone) |
|
52 { |
|
53 iMessageSizeNegotiationDone = ETrue; |
|
54 if(IsCallOngoing()) |
|
55 { // SAP cannot be accepted if a call is ongoing or if no SIM is present |
|
56 connectionStatus = EConnectionOKOngoingCall; |
|
57 } |
|
58 else |
|
59 { |
|
60 connectionStatus = EConnectionOK; |
|
61 } |
|
62 } |
|
63 else |
|
64 { |
|
65 iMessageSizeNegotiationDone = EFalse; |
54 } |
66 } |
55 |
67 |
56 if (connectionStatus == EConnectionOK) |
68 if (connectionStatus == EConnectionOK) |
57 { |
69 { |
58 iConnectRequestOK = ETrue; |
70 iConnectRequestOK = ETrue; |
82 User::RequestComplete(iStatus, EUserAccepted); |
94 User::RequestComplete(iStatus, EUserAccepted); |
83 |
95 |
84 #endif //__WINS__ |
96 #endif //__WINS__ |
85 |
97 |
86 } |
98 } |
|
99 else if (connectionStatus == EConnectionOKOngoingCall) |
|
100 { |
|
101 iConnectRequestOK = EFalse; |
|
102 aStatus = KRequestPending; |
|
103 if (iSendRespMessageDone) |
|
104 { |
|
105 //start subscribe to CallStatusChange |
|
106 iServerState.SubscribeCallStatusL(); |
|
107 } |
|
108 else |
|
109 { |
|
110 User::RequestComplete(iStatus, EConnectionWithActiveCall); |
|
111 } |
|
112 } |
87 else |
113 else |
88 { |
114 { |
89 iConnectRequestOK = EFalse; |
115 iConnectRequestOK = EFalse; |
90 |
|
91 iResponseMessage.SetMsgID(EConnectResponse); |
116 iResponseMessage.SetMsgID(EConnectResponse); |
92 iResponseMessage.AddParameter(EParaConnectionStatus, connectionStatus); |
117 iResponseMessage.AddParameter(EParaConnectionStatus, connectionStatus); |
93 |
118 |
94 if (connectionStatus == EConnectionErrNotSupported) |
119 if (connectionStatus == EConnectionErrNotSupported) |
95 { |
120 { |
119 TBTSapServerState CBTSapServerState::TStateConnect::Complete(TInt aReason) |
144 TBTSapServerState CBTSapServerState::TStateConnect::Complete(TInt aReason) |
120 { |
145 { |
121 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: Complete"))); |
146 BTSAP_TRACE_OPT(KBTSAP_TRACE_STM, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: Complete"))); |
122 |
147 |
123 TBTSapServerState nextState = EStateNotConnected; |
148 TBTSapServerState nextState = EStateNotConnected; |
124 |
149 if (aReason == EConnectionWithActiveCall) |
125 if (aReason == EUserAccepted || aReason == EUserRejected) |
150 { |
|
151 if (!iSendRespMessageDone) |
|
152 { |
|
153 TInt connectionStatus = EConnectionOKOngoingCall; |
|
154 iResponseMessage.SetMsgID(EConnectResponse); |
|
155 iResponseMessage.AddParameter(EParaConnectionStatus, connectionStatus); |
|
156 iServerState.BTSapSocketHandler().Send(iResponseMessage.Data()); |
|
157 iSendRespMessageDone = ETrue; |
|
158 } |
|
159 //wait in TStateConnect state, until call is released |
|
160 nextState = EStateConnect; |
|
161 } |
|
162 else if (aReason == EConnectionWithoutActiveCall) |
|
163 { |
|
164 //Enter TStateConnect state one last time, make a SAP connection |
|
165 nextState = EStateConnect; |
|
166 } |
|
167 else if (aReason == EUserAccepted || aReason == EUserRejected) |
126 { |
168 { |
127 TInt connectionStatus = (aReason == EUserAccepted) ? EConnectionOK : EConnectionErrReject; |
169 TInt connectionStatus = (aReason == EUserAccepted) ? EConnectionOK : EConnectionErrReject; |
128 |
170 |
129 iResponseMessage.SetMsgID(EConnectResponse); |
171 iResponseMessage.SetMsgID(EConnectResponse); |
130 iResponseMessage.AddParameter(EParaConnectionStatus, connectionStatus); |
172 iResponseMessage.AddParameter(EParaConnectionStatus, connectionStatus); |
145 // There is no SIM, so the connection will be disconnected by the client. |
187 // There is no SIM, so the connection will be disconnected by the client. |
146 // We therefore do not signal a connection complete. |
188 // We therefore do not signal a connection complete. |
147 NotifySapState(ESapConnected); |
189 NotifySapState(ESapConnected); |
148 } |
190 } |
149 nextState = EStateIdle; |
191 nextState = EStateIdle; |
|
192 iSendRespMessageDone = EFalse; |
|
193 iMessageSizeNegotiationDone = EFalse; |
150 } |
194 } |
151 } |
195 } |
152 |
196 |
153 return nextState; |
197 return nextState; |
154 } |
198 } |
155 |
199 |
156 void CBTSapServerState::TStateConnect::Cancel() |
200 void CBTSapServerState::TStateConnect::Cancel() |
157 { |
201 { |
158 NotifySapState(ESapNotConnected); |
202 NotifySapState(ESapNotConnected); |
|
203 iSendRespMessageDone = EFalse; |
|
204 iMessageSizeNegotiationDone = EFalse; |
|
205 iServerState.CancelSubscribeCallStatusL(); |
159 User::RequestComplete(iStatus, KErrCancel); |
206 User::RequestComplete(iStatus, KErrCancel); |
160 } |
207 } |
161 |
208 |
162 TBool CBTSapServerState::TStateConnect::IsCallOngoing() |
209 TBool CBTSapServerState::TStateConnect::IsCallOngoing() |
163 { |
210 { |
180 if(err == KErrNone) |
227 if(err == KErrNone) |
181 { |
228 { |
182 BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TStateConnect: callState: %d"), callState)); |
229 BTSAP_TRACE_OPT(KBTSAP_TRACE_INFO, BTSapPrintTrace(_L("[BTSap] TStateConnect: callState: %d"), callState)); |
183 |
230 |
184 // If callState is EPSTelephonyCallStateNone or EPSTelephonyCallStateUninitialized, there's no ongoing call |
231 // If callState is EPSTelephonyCallStateNone or EPSTelephonyCallStateUninitialized, there's no ongoing call |
185 retVal = (callState != EPSCTsyCallStateNone) && (callState != EPSCTsyCallStateUninitialized); |
232 // should EPSCTsyCallStateDisconnecting be treated as non active call status ??? |
|
233 // added it here for testing with SAP 1.0 supported carkit. Since there is delay for call status changes from EPSCTsyCallStateDisconnecting |
|
234 // to EPSCTsyCallStateNone or EPSCTsyCallStateUninitialized. If we do not treat EPSCTsyCallStateDisconnecting as |
|
235 // Call Inactive status, SAP connection will be dropped and client connects to HFP profile instead. |
|
236 // could be removed and try if it works with SAP 1.1 clients. |
|
237 retVal = (callState != EPSCTsyCallStateNone) && (callState != EPSCTsyCallStateUninitialized) && (callState != EPSCTsyCallStateDisconnecting); |
186 } |
238 } |
187 else |
239 else |
188 { |
240 { |
189 // Couldn't retrieve call state property |
241 // Couldn't retrieve call state property |
190 BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] TStateConnect: Couldn't get callState!!! (err = %d)"), err)); |
242 BTSAP_TRACE_OPT(KBTSAP_TRACE_ERROR, BTSapPrintTrace(_L("[BTSap] TStateConnect: Couldn't get callState!!! (err = %d)"), err)); |
262 void CBTSapServerState::TStateConnect::SimCardStatusChanged(TCardStatus aCardStatus) |
314 void CBTSapServerState::TStateConnect::SimCardStatusChanged(TCardStatus aCardStatus) |
263 { |
315 { |
264 iCardStatus = aCardStatus; |
316 iCardStatus = aCardStatus; |
265 } |
317 } |
266 |
318 |
|
319 TInt CBTSapServerState::TStateConnect::CallInactive() |
|
320 { |
|
321 BTSAP_TRACE_OPT(KBTSAP_TRACE_FUNCTIONS, BTSapPrintTrace(_L("[BTSap] SM: TStateConnect: CallInactive"))); |
|
322 |
|
323 if (*iStatus == KRequestPending) |
|
324 { |
|
325 User::RequestComplete(iStatus, EConnectionWithoutActiveCall); |
|
326 } |
|
327 return KErrNone; |
|
328 } |
|
329 |
267 // End of File |
330 // End of File |