|
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 |
|
22 #include "mcestateconfirmationrequired.h" |
|
23 #include "mcesipsession.h" |
|
24 #include "mceactionset.h" |
|
25 #include "mcefcactionset.h" |
|
26 #include "mceclientserver.h" |
|
27 |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CMceStateConfirmationRequired::CMceStateConfirmationRequired |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CMceStateConfirmationRequired::CMceStateConfirmationRequired () |
|
34 : CMceState( KMceStateConfirmationRequired ) |
|
35 { |
|
36 } |
|
37 |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMceStateConfirmationRequired::~CMceStateConfirmationRequired |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CMceStateConfirmationRequired::~CMceStateConfirmationRequired() |
|
44 { |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMceStateConfirmationRequired::DoAcceptL |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 TBool CMceStateConfirmationRequired::DoAcceptL( |
|
53 TMceStateTransitionEvent& aEvent ) |
|
54 { |
|
55 User::LeaveIfError( |
|
56 aEvent.Code() == EMceUpdate || |
|
57 aEvent.Code() == EMceMediaUpdated || |
|
58 aEvent.Code() == EMceItcEnable || |
|
59 aEvent.Code() == EMceItcDisable || |
|
60 aEvent.Code() == EMceItcRejectSession || |
|
61 IsExtensionRequestEvent( aEvent ) |
|
62 |
|
63 ? KErrNone : KErrTotalLossOfPrecision ); |
|
64 |
|
65 return ETrue; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CMceStateConfirmationRequired::EntryL |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CMceStateConfirmationRequired::EntryL( TMceStateTransitionEvent& aEvent ) |
|
73 { |
|
74 |
|
75 if ( IsExtensionRequestEvent( aEvent )) |
|
76 { |
|
77 HandleExtensionRequestEventL( aEvent ); |
|
78 } |
|
79 |
|
80 else |
|
81 { |
|
82 switch ( aEvent.Code() ) |
|
83 { |
|
84 case EMceUpdate: |
|
85 { |
|
86 EntryUpdateL( aEvent ); |
|
87 break; |
|
88 } |
|
89 case EMceMediaUpdated: |
|
90 { |
|
91 EntryMediaUpdatedL( aEvent ); |
|
92 break; |
|
93 } |
|
94 case EMceItcEnable: |
|
95 case EMceItcDisable: |
|
96 { |
|
97 aEvent.Session().Actions().ControlMediaL( aEvent.ParamIDs(), |
|
98 (TMceItcFunctions)aEvent.Code() ); |
|
99 break; |
|
100 } |
|
101 case EMceItcRejectSession: |
|
102 { |
|
103 aEvent.Session().Actions().SendDeclineL( |
|
104 aEvent.Session().Request(), |
|
105 aEvent.ParamClientMessage() ); |
|
106 aEvent.Session().Actions().StopMedia(); |
|
107 aEvent.Session().FCActions().ReleaseFC(); |
|
108 break; |
|
109 } |
|
110 default: |
|
111 { |
|
112 // NOP |
|
113 break; |
|
114 } |
|
115 } |
|
116 } |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CMceStateConfirmationRequired::ExitL |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CMceStateConfirmationRequired::ExitL( TMceStateTransitionEvent& aEvent ) |
|
124 { |
|
125 |
|
126 if ( IsExtensionRequestEvent( aEvent )) |
|
127 { |
|
128 //Do Nothing; |
|
129 } |
|
130 |
|
131 else |
|
132 { |
|
133 CMceSipSession& session = aEvent.Session(); |
|
134 TInt status = aEvent.ParamStatus(); |
|
135 |
|
136 switch ( aEvent.Code() ) |
|
137 { |
|
138 case EMceUpdate: |
|
139 { |
|
140 if ( MCE_IS_ERROR( status ) ) |
|
141 { |
|
142 // TBD: update failed, change state |
|
143 } |
|
144 // if update was async, wait in this state for media |
|
145 // updated event. If update is ready, entered with media updated. |
|
146 break; |
|
147 } |
|
148 case EMceMediaUpdated: |
|
149 { |
|
150 if ( MCE_IS_ERROR( status ) ) |
|
151 { |
|
152 // TBD: reservation failed, need to change state |
|
153 } |
|
154 else if ( status == KMceAsync ) |
|
155 { |
|
156 // reserving, go to server reserving |
|
157 session.Actions().StateChanged( KMceStateServerReserving ); |
|
158 } |
|
159 else // ready |
|
160 { |
|
161 session.Actions().StateChanged( KMceStateUpdated ); |
|
162 session.Actions().ClientStateChangedL( |
|
163 CMceSession::EProceeding, |
|
164 *session.Body(), |
|
165 KErrNone ); |
|
166 } |
|
167 break; |
|
168 } |
|
169 case EMceItcRejectSession: |
|
170 { |
|
171 session.Actions().StateChanged( KMceStateTerminated ); |
|
172 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
173 CMceSession::ETerminated ); |
|
174 break; |
|
175 } |
|
176 default: |
|
177 { |
|
178 // NOP |
|
179 break; |
|
180 } |
|
181 } |
|
182 } |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CMceStateConfirmationRequired::EntryUpdateL |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CMceStateConfirmationRequired::EntryUpdateL( |
|
190 TMceStateTransitionEvent& aEvent ) |
|
191 { |
|
192 CMceSipSession& session = aEvent.Session(); |
|
193 if ( MceSip::HasContent( session.Request() ) ) |
|
194 { |
|
195 // UPDATE carries SDP |
|
196 User::LeaveIfError( session.Actions().CreateSDP( session.Request() ) ); |
|
197 |
|
198 session.Actions().DecodeL(); |
|
199 TMceReturnStatus status = session.Actions().UpdateL(); |
|
200 aEvent.ParamStatus() = status; |
|
201 if ( MCE_IS_ERROR( status ) ) |
|
202 { |
|
203 // TBD: update failed, reject |
|
204 } |
|
205 else if ( status == KMceAsync ) |
|
206 { |
|
207 // NOP |
|
208 } |
|
209 else // ready |
|
210 { |
|
211 aEvent.Code() = EMceMediaUpdated; |
|
212 EntryMediaUpdatedL( aEvent ); |
|
213 } |
|
214 } |
|
215 else |
|
216 { |
|
217 // TBD: handle UPDATE without content |
|
218 } |
|
219 |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CMceStateConfirmationRequired::EntryMediaUpdatedL |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CMceStateConfirmationRequired::EntryMediaUpdatedL( |
|
227 TMceStateTransitionEvent& aEvent ) |
|
228 { |
|
229 CMceSipSession& session = aEvent.Session(); |
|
230 |
|
231 TMceReturnStatus status = session.Actions().ReserveL(); |
|
232 aEvent.ParamStatus() = status; |
|
233 if ( MCE_IS_ERROR( status ) ) |
|
234 { |
|
235 // TBD: reservation failed |
|
236 } |
|
237 else if ( status == KMceAsync ) |
|
238 { |
|
239 // NOP |
|
240 } |
|
241 else // ready, send 2xx to update |
|
242 { |
|
243 CSIPServerTransaction* update = NULL; |
|
244 RStringF trx = session.Request().Type(); |
|
245 if ( trx == SIPStrings::StringF( SipStrConsts::EUpdate ) ) |
|
246 { |
|
247 update = &session.Request(); |
|
248 } |
|
249 |
|
250 if ( update ) |
|
251 { |
|
252 session.Actions().EncodeL(); |
|
253 session.FCActions().UpdateFCAnswerL( *session.Offer() ); |
|
254 session.Actions().SendAnswerL( *update ); |
|
255 } |
|
256 else |
|
257 { |
|
258 User::Leave( KErrTotalLossOfPrecision ); |
|
259 } |
|
260 } |
|
261 } |
|
262 // End of file |