|
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 "mcestateclientreserving.h" |
|
23 #include "mcesipsession.h" |
|
24 #include "mceactionset.h" |
|
25 #include "mceclientserver.h" |
|
26 #include "mcefcactionset.h" |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CMceStateClientReserving::CMceStateClientReserving |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CMceStateClientReserving::CMceStateClientReserving() |
|
33 : CMceState( KMceStateClientReserving ) |
|
34 { |
|
35 } |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CMceStateClientReserving::~CMceStateClientReserving |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CMceStateClientReserving::~CMceStateClientReserving() |
|
43 { |
|
44 } |
|
45 |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMceStateClientReserving::DoAcceptL |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 TBool CMceStateClientReserving::DoAcceptL( TMceStateTransitionEvent& aEvent ) |
|
52 { |
|
53 User::LeaveIfError( |
|
54 aEvent.Code() == EMceItcCancel || |
|
55 aEvent.Code() == EMceMediaReserved || |
|
56 aEvent.Code() == EMceItcEnable || |
|
57 aEvent.Code() == EMceItcDisable || |
|
58 IsExtensionRequestEvent( aEvent ) |
|
59 |
|
60 ? KErrNone : KErrTotalLossOfPrecision ); |
|
61 |
|
62 return ETrue; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CMceStateClientReserving::EntryL |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CMceStateClientReserving::EntryL( TMceStateTransitionEvent& aEvent ) |
|
70 { |
|
71 if ( IsExtensionRequestEvent( aEvent )) |
|
72 { |
|
73 HandleExtensionRequestEventL( aEvent ); |
|
74 } |
|
75 |
|
76 else |
|
77 { |
|
78 switch( aEvent.Code() ) |
|
79 { |
|
80 case EMceMediaReserved: |
|
81 { |
|
82 EntryMediaReservedL( aEvent ); |
|
83 break; |
|
84 } |
|
85 case EMceItcCancel: |
|
86 { |
|
87 EntryCancelL( aEvent ); |
|
88 break; |
|
89 } |
|
90 case EMceItcEnable: |
|
91 case EMceItcDisable: |
|
92 { |
|
93 aEvent.Session().Actions().ControlMediaL( aEvent.ParamIDs(), |
|
94 (TMceItcFunctions)aEvent.Code() ); |
|
95 break; |
|
96 } |
|
97 default: |
|
98 { |
|
99 break; |
|
100 } |
|
101 } |
|
102 } |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CMceStateClientReserving::EntryMediaReservedL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CMceStateClientReserving::EntryMediaReservedL( |
|
110 TMceStateTransitionEvent& aEvent ) |
|
111 { |
|
112 CMceSipSession& session = aEvent.Session(); |
|
113 CSIPClientTransaction* invite = session.PendingTransaction( |
|
114 SIPStrings::StringF( SipStrConsts::EInvite ) ); |
|
115 User::LeaveIfError( invite ? KErrNone : KErrTotalLossOfPrecision ); |
|
116 |
|
117 if ( invite->StateL() == CSIPTransactionBase::ETerminated ) |
|
118 { |
|
119 if ( MCE_NEED_TO_SEND( session, NULL ) ) |
|
120 { |
|
121 // create the SDP |
|
122 session.Actions().EncodeL(); |
|
123 // update FC |
|
124 session.FCActions().UpdateFCOfferL( *session.Offer() ); |
|
125 // send re-INVITE |
|
126 session.Actions().SendInviteL(); |
|
127 } |
|
128 else |
|
129 { |
|
130 // Just go to established state |
|
131 session.Actions().ClientStateChangedL( CMceSession::EEstablished ); |
|
132 session.Actions().StateChanged( KMceStateEstablished ); |
|
133 } |
|
134 } |
|
135 else |
|
136 { |
|
137 // create SDP |
|
138 session.Actions().EncodeL(); |
|
139 // update FC |
|
140 session.FCActions().UpdateFCOfferL( *session.Offer() ); |
|
141 // send update |
|
142 session.Actions().SendUpdateRequestL(); |
|
143 } |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CMceStateClientReserving::EntryCancelL |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CMceStateClientReserving::EntryCancelL( TMceStateTransitionEvent& aEvent ) |
|
151 { |
|
152 CMceSipSession& session = aEvent.Session(); |
|
153 CMceSipSession::TSubState subState = session.SubState(); |
|
154 |
|
155 //(try) send CANCEL |
|
156 session.Actions().SendCancelL(); |
|
157 |
|
158 if ( subState == CMceSipSession::EOffering ) |
|
159 { |
|
160 session.Actions().StopMedia(); |
|
161 session.FCActions().ReleaseFC(); |
|
162 } |
|
163 else if ( subState == CMceSipSession::EUpdating ) |
|
164 { |
|
165 session.Actions().UpdateFailed(); |
|
166 } |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CMceStateClientReserving::ExitL |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CMceStateClientReserving::ExitL( TMceStateTransitionEvent& aEvent ) |
|
174 { |
|
175 |
|
176 if ( IsExtensionRequestEvent( aEvent )) |
|
177 { |
|
178 //Do Nothing; |
|
179 } |
|
180 |
|
181 else |
|
182 { |
|
183 CMceSipSession& session = aEvent.Session(); |
|
184 |
|
185 switch( aEvent.Code() ) |
|
186 { |
|
187 case EMceItcCancel: |
|
188 { |
|
189 session.Actions().StateChanged( KMceStateCanceled ); |
|
190 session.Actions().ClientStateChanged( aEvent.ParamIDs(), |
|
191 CMceSession::ECancelling ); |
|
192 |
|
193 break; |
|
194 } |
|
195 case EMceMediaReserved: |
|
196 { |
|
197 CSIPClientTransaction* update = session.PendingTransaction( |
|
198 SIPStrings::StringF( SipStrConsts::EUpdate ) ); |
|
199 if ( update ) |
|
200 { |
|
201 // just sent UPDATE |
|
202 session.Actions().StateChanged( KMceStateConfirming ); |
|
203 } |
|
204 else |
|
205 { |
|
206 session.Actions().StateChanged( KMceStateOffering ); |
|
207 } |
|
208 break; |
|
209 } |
|
210 default: |
|
211 { |
|
212 break; |
|
213 } |
|
214 } |
|
215 } |
|
216 } |
|
217 |
|
218 // End of file |