|
1 /* |
|
2 * Copyright (c) 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mcestateserverestablishing.h" |
|
22 #include "mceactionset.h" |
|
23 #include "mcefcactionset.h" |
|
24 #include "mcenatmacros.h" |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CMceStateServerEstablishing::CMceStateServerEstablishing |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CMceStateServerEstablishing::CMceStateServerEstablishing () |
|
31 : CMceState( KMceStateServerEstablishing ) |
|
32 { |
|
33 } |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CMceStateServerEstablishing::~CMceStateServerEstablishing |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CMceStateServerEstablishing::~CMceStateServerEstablishing() |
|
40 { |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CMceStateServerEstablishing::DoAcceptL |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 TBool CMceStateServerEstablishing::DoAcceptL( TMceStateTransitionEvent& aEvent ) |
|
48 { |
|
49 //not accepted |
|
50 User::LeaveIfError( aEvent.EventSource() == EMceSip ? |
|
51 KErrTotalLossOfPrecision : |
|
52 KErrNone ); |
|
53 |
|
54 User::LeaveIfError( |
|
55 aEvent.Code() == EMceItcUpdate || |
|
56 aEvent.Code() == EMceItcRejectSession || |
|
57 aEvent.Code() == EMceItcEnable || |
|
58 aEvent.Code() == EMceItcDisable || |
|
59 IsExtensionRequestEvent( aEvent ) |
|
60 |
|
61 ? KErrNone : KErrTotalLossOfPrecision ); |
|
62 |
|
63 return ETrue; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMceStateServerEstablishing::EntryL |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CMceStateServerEstablishing::EntryL( TMceStateTransitionEvent& aEvent ) |
|
71 { |
|
72 |
|
73 if ( IsExtensionRequestEvent( aEvent )) |
|
74 { |
|
75 HandleExtensionRequestEventL( aEvent ); |
|
76 } |
|
77 |
|
78 else |
|
79 { |
|
80 CMceSipSession& session = aEvent.Session(); |
|
81 CSIPServerTransaction& request = session.Request(); |
|
82 CMceSipSession::TSubState subState = session.SubState(); |
|
83 |
|
84 switch( aEvent.Code() ) |
|
85 { |
|
86 case EMceItcUpdate: |
|
87 { |
|
88 EntryUpdateL( aEvent ); |
|
89 break; |
|
90 } |
|
91 case EMceItcRejectSession: |
|
92 { |
|
93 CDesC8Array* tempHeaders = session.Body()->iSIPHeaders; |
|
94 CleanupStack::PushL( tempHeaders ); |
|
95 session.Body()->iSIPHeaders = 0; |
|
96 session.Actions().SendDeclineL( request, aEvent.ParamClientMessage() ); |
|
97 |
|
98 if ( !session.Body()->iSIPHeaders ) |
|
99 { |
|
100 session.Body()->iSIPHeaders = tempHeaders; |
|
101 CleanupStack::Pop( tempHeaders ); |
|
102 } |
|
103 else |
|
104 { |
|
105 CleanupStack::PopAndDestroy( tempHeaders ); |
|
106 } |
|
107 |
|
108 if ( subState == CMceSipSession::EOffering ) |
|
109 { |
|
110 session.Actions().StopMedia(); |
|
111 session.FCActions().ReleaseFC(); |
|
112 } |
|
113 else if ( subState == CMceSipSession::EUpdating ) |
|
114 { |
|
115 session.Actions().UpdateFailed(); |
|
116 } |
|
117 break; |
|
118 } |
|
119 case EMceItcEnable: |
|
120 case EMceItcDisable: |
|
121 { |
|
122 session.Actions().ControlMediaL( aEvent.ParamIDs(), |
|
123 (TMceItcFunctions)aEvent.Code() ); |
|
124 break; |
|
125 } |
|
126 default: |
|
127 { |
|
128 //NOP |
|
129 break; |
|
130 } |
|
131 } |
|
132 } |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CMceStateServerEstablishing::EntryUpdateL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void |
|
140 CMceStateServerEstablishing::EntryUpdateL( TMceStateTransitionEvent& aEvent ) |
|
141 { |
|
142 CMceSipSession& session = aEvent.Session(); |
|
143 CSIPServerTransaction& request = session.Request(); |
|
144 CMceSipSession::TSubState subState = session.SubState(); |
|
145 TMceReturnStatus status = KErrNone; |
|
146 |
|
147 //update body |
|
148 session.Actions().UpdateBodyL( aEvent.ParamIDs(), |
|
149 aEvent.ParamClientMessage() ); |
|
150 //update MM |
|
151 status = session.Actions().Update(); |
|
152 |
|
153 if ( status == KMceReady ) |
|
154 { |
|
155 // Send 183 with SDP if needed |
|
156 if ( MCE_NEED_TO_RECEIVE( session ) && |
|
157 session.Extensions().Local( CMceSipExtensions::E100rel ) |
|
158 != CMceSipExtensions::ENotSupported && |
|
159 session.Extensions().Remote( CMceSipExtensions::E100rel ) |
|
160 != CMceSipExtensions::ENotSupported ) |
|
161 { |
|
162 // encode |
|
163 NAT_WAIT_NO_EXEC( session, session.Actions().EncodeL() ) |
|
164 |
|
165 session.FCActions().UpdateFCAnswerL( *session.Offer() ); |
|
166 session.Actions().SendResponseL( |
|
167 request, |
|
168 KMceSipSessionProgress, |
|
169 SipStrConsts::EPhraseSessionProgress ); |
|
170 //For Long Sesion after this no need to updated key until session |
|
171 //established |
|
172 if ( session.ActiveBody().SecureSession() ) |
|
173 { |
|
174 session.ActiveBody().SecureSession()->iKeyNeedUpdated = EFalse; |
|
175 } |
|
176 // start reserving |
|
177 session.Actions().ReserveL(); |
|
178 // change state |
|
179 session.Actions().StateChanged( |
|
180 KMceStateAcknowledgementRequired ); |
|
181 } |
|
182 else |
|
183 { |
|
184 if ( subState != CMceSipSession::EAnswering ) |
|
185 { |
|
186 // directly send 200 OK |
|
187 // encode body |
|
188 NAT_WAIT_NO_EXEC( session, session.Actions().EncodeL() ) |
|
189 |
|
190 session.Actions().UpdateSucceed(); //no affect if answering |
|
191 session.FCActions().UpdateFCAnswerL( *session.Offer() ); |
|
192 session.Actions().SendAnswerL( request ); |
|
193 } |
|
194 } |
|
195 } |
|
196 else if ( MCE_IS_ERROR( status ) ) |
|
197 { |
|
198 MceSip::DiscardRequest( request, KMceSipServerInternalError ); |
|
199 |
|
200 if ( subState == CMceSipSession::EAnswering ) |
|
201 { |
|
202 session.Actions().StopMedia(); |
|
203 session.FCActions().ReleaseFC(); |
|
204 //exit same as if client rejects |
|
205 aEvent.Code() = EMceItcRejectSession; |
|
206 } |
|
207 else if ( subState == CMceSipSession::EUpdating ) |
|
208 { |
|
209 session.Actions().UpdateFailed(); |
|
210 } |
|
211 else |
|
212 { |
|
213 //NOP |
|
214 } |
|
215 } |
|
216 |
|
217 aEvent.ParamStatus() = status; |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CMceStateServerEstablishing::ExitL |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 void CMceStateServerEstablishing::ExitL( TMceStateTransitionEvent& aEvent ) |
|
225 { |
|
226 |
|
227 if ( IsExtensionRequestEvent( aEvent )) |
|
228 { |
|
229 //Do Nothing; |
|
230 } |
|
231 |
|
232 else |
|
233 { |
|
234 CMceSipSession& session = aEvent.Session(); |
|
235 TInt status = aEvent.ParamStatus(); |
|
236 CMceSipSession::TSubState subState = session.SubState(); |
|
237 |
|
238 switch ( aEvent.Code() ) |
|
239 { |
|
240 case EMceItcUpdate: |
|
241 { |
|
242 if ( status < KErrNone ) //only in updating |
|
243 { |
|
244 //Client must use get session function get the original |
|
245 session.Actions().StateChanged( KMceStateEstablished ); |
|
246 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
247 CMceSession::EEstablished, |
|
248 status ); |
|
249 } |
|
250 else if ( status == KMceAsync ) //both first and update |
|
251 { |
|
252 session.Actions().StateChanged( KMceStateUpdating ); |
|
253 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
254 CMceSession::EReserving ); |
|
255 } |
|
256 else //KReady |
|
257 { |
|
258 if ( subState == CMceSipSession::EAnswering ) |
|
259 { |
|
260 // first INVITE, need to wait client to accept |
|
261 |
|
262 session.Actions().StateChanged( KMceStateUpdated ); |
|
263 |
|
264 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
265 CMceSession::EReserving ); |
|
266 |
|
267 session.Actions().ClientStateChangedL( CMceSession::EProceeding ); |
|
268 |
|
269 } |
|
270 else |
|
271 { |
|
272 if ( session.Request().Type() == SIPStrings::StringF( SipStrConsts::EUpdate ) ) |
|
273 { |
|
274 // UPDATE, not refreshing |
|
275 session.Actions().StateChanged( KMceStateEstablished ); |
|
276 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
277 CMceSession::EEstablished, |
|
278 status ); |
|
279 session.Actions().ClientStateChangedL( CMceSession::EEstablished, session.Request() ); |
|
280 } |
|
281 else |
|
282 { |
|
283 // re-INVITE, answer sent |
|
284 session.Actions().StateChanged( KMceStateAnswering ); |
|
285 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
286 CMceSession::EAnswering ); |
|
287 } |
|
288 } |
|
289 } |
|
290 break; |
|
291 } |
|
292 case EMceItcRejectSession: |
|
293 { |
|
294 if ( subState == CMceSipSession::EAnswering ) |
|
295 { // original session rejected |
|
296 session.Actions().StateChanged( KMceStateTerminated ); |
|
297 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
298 CMceSession::ETerminated, |
|
299 status ); |
|
300 } |
|
301 else |
|
302 { // update rejected |
|
303 session.Actions().StateChanged( KMceStateEstablished ); |
|
304 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
305 CMceSession::EEstablished ); |
|
306 } |
|
307 break; |
|
308 } |
|
309 default: |
|
310 { |
|
311 //NOP |
|
312 break; |
|
313 } |
|
314 } |
|
315 } |
|
316 } |
|
317 |
|
318 |
|
319 // End of file |
|
320 |