|
1 /* |
|
2 * Copyright (c) 2006-2008 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: Incoming request establishing state for hold state machine. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "mcesession.h" |
|
20 #include "mcemediastream.h" |
|
21 #include "mceaudiostream.h" |
|
22 #include "svpholdinestablishingstate.h" |
|
23 #include "svpholdcontroller.h" |
|
24 #include "svpholdattributehandler.h" |
|
25 #include "svplogger.h" |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CSVPHoldInEstablishingState::CSVPHoldInEstablishingState |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CSVPHoldInEstablishingState::CSVPHoldInEstablishingState() |
|
33 { |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CSVPHoldInEstablishingState::NewL |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CSVPHoldInEstablishingState* CSVPHoldInEstablishingState::NewLC() |
|
41 { |
|
42 CSVPHoldInEstablishingState* self = |
|
43 new ( ELeave ) CSVPHoldInEstablishingState; |
|
44 |
|
45 CleanupStack::PushL( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CSVPHoldInEstablishingState::~CSVPHoldInEstablishingState |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CSVPHoldInEstablishingState::~CSVPHoldInEstablishingState() |
|
54 { |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CSVPHoldInEstablishingState::DoApplyL |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 void CSVPHoldInEstablishingState::DoApplyL( CSVPHoldContext& aContext ) |
|
62 { |
|
63 SVPDEBUG1( "CSVPHoldInEstablishingState::DoApply" ); |
|
64 |
|
65 TSVPHoldStateIndex nextState = KSVPHoldEstablishingStateIndex; |
|
66 |
|
67 const RPointerArray< CMceMediaStream >& streams = |
|
68 aContext.SessionObject()->Streams(); |
|
69 |
|
70 const TInt streamCount = streams.Count(); |
|
71 |
|
72 if ( !aContext.SpecialResponseHandling( nextState ) ) |
|
73 { |
|
74 for ( TInt i = 0; i < streamCount; i++ ) |
|
75 { |
|
76 CMceMediaStream* mediaStream = streams[ i ]; |
|
77 if ( KMceAudio == mediaStream->Type() ) |
|
78 { |
|
79 // This media is audio stream. Handling depends on the request |
|
80 switch ( aContext.HoldRequest() ) |
|
81 { |
|
82 case ESVPRemoteHold: |
|
83 { |
|
84 // From Connected state |
|
85 HandleRemoteHolding( nextState ); |
|
86 break; |
|
87 } |
|
88 |
|
89 case ESVPRemoteResume: |
|
90 { |
|
91 // From In state |
|
92 HandleRemoteResuming( nextState ); |
|
93 break; |
|
94 } |
|
95 |
|
96 case ESVPRemoteDoubleHold: |
|
97 { |
|
98 // From Out state |
|
99 HandleRemoteHolding( nextState, |
|
100 KSVPHoldDHStateIndex ); |
|
101 break; |
|
102 } |
|
103 |
|
104 case ESVPRemoteDoubleHoldResume: |
|
105 { |
|
106 // From Doublehold state |
|
107 HandleRemoteResuming( nextState, |
|
108 KSVPHoldOutStateIndex ); |
|
109 break; |
|
110 } |
|
111 |
|
112 case ESVPLocalHold: |
|
113 case ESVPLocalResume: |
|
114 case ESVPLocalDoubleHold: |
|
115 case ESVPLocalDoubleHoldResume: |
|
116 { |
|
117 SVPDEBUG1( |
|
118 "CSVPHoldInEstablishingState::DoApply\ |
|
119 - Local action - State Error" ); |
|
120 User::Leave( KErrSVPHoldStateError ); |
|
121 break; |
|
122 } |
|
123 |
|
124 default: |
|
125 { |
|
126 // Error in request solving |
|
127 SVPDEBUG2( |
|
128 "CSVPHoldInEstablishingState::DoApply - Error, request %i", |
|
129 aContext.HoldRequest() ); |
|
130 break; |
|
131 } |
|
132 } |
|
133 } |
|
134 } |
|
135 } |
|
136 |
|
137 aContext.SetCurrentStateL( aContext, nextState ); |
|
138 SVPDEBUG1( "CSVPHoldInEstablishingState::DoApply - Handled" ); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CSVPHoldInEstablishingState::DoEnter |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 void CSVPHoldInEstablishingState::DoEnter( CSVPHoldContext& /*aContext*/ ) |
|
146 { |
|
147 // Nothing to do. |
|
148 SVPDEBUG1( "CSVPHoldInEstablishingState::DoEnter" ); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CSVPHoldInEstablishingState::IsOutEstablishingStateActive |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 TBool CSVPHoldInEstablishingState::IsOutEstablishingStateActive() |
|
156 { |
|
157 return EFalse; |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // CSVPHoldInEstablishingState::HandleRemoteHoldingL |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CSVPHoldInEstablishingState:: |
|
165 HandleRemoteHolding( TSVPHoldStateIndex& aNextState, |
|
166 TSVPHoldStateIndex aState ) |
|
167 { |
|
168 SVPDEBUG1( |
|
169 "CSVPHoldInEstablishingState::HandleRemoteHoldingL" ); |
|
170 |
|
171 if ( KSVPHoldDHStateIndex == aState ) |
|
172 { |
|
173 SVPDEBUG1( |
|
174 "CSVPHoldOutEstablishingState::HandleLocalHoldingL\ |
|
175 - Next KSVPHoldDHStateIndex" ); |
|
176 aNextState = KSVPHoldDHStateIndex; |
|
177 } |
|
178 else |
|
179 { |
|
180 aNextState = KSVPHoldInStateIndex; |
|
181 } |
|
182 |
|
183 SVPDEBUG1( |
|
184 "CSVPHoldInEstablishingState::HandleRemoteHoldingL - Done" ); |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CSVPHoldInEstablishingState::HandleRemoteResumingL |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CSVPHoldInEstablishingState:: |
|
192 HandleRemoteResuming( TSVPHoldStateIndex& aNextState, |
|
193 TSVPHoldStateIndex aState ) |
|
194 { |
|
195 if ( KSVPHoldOutStateIndex == aState ) |
|
196 { |
|
197 SVPDEBUG1( |
|
198 "CSVPHoldInEstablishingState::HandleRemoteResumingL KSVPHoldOutStateIndex" ) |
|
199 |
|
200 aNextState = KSVPHoldOutStateIndex; |
|
201 } |
|
202 else |
|
203 { |
|
204 SVPDEBUG1( |
|
205 "CSVPHoldInEstablishingState::HandleRemoteResumingL KSVPHoldConnectedStateIndex" ) |
|
206 |
|
207 aNextState = KSVPHoldConnectedStateIndex; |
|
208 } |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // CSVPHoldInEstablishingState::CheckAttribute |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 TInt CSVPHoldInEstablishingState:: |
|
216 CheckAttribute( MDesC8Array* aAttributeLines, |
|
217 KSVPHoldAttributeIndex aNeededAttribute, |
|
218 TSVPHoldStateIndex& aNextState, |
|
219 CSVPHoldContext& aContext ) |
|
220 { |
|
221 // Checks direction attribute from request whether it is acceptable or not. |
|
222 SVPDEBUG1( "CSVPHoldInEstablishingState::CheckAttribute" ); |
|
223 |
|
224 KSVPHoldAttributeIndex requestAttribute = |
|
225 aContext.AttributeHandler().FindDirectionAttribute( aAttributeLines ); |
|
226 |
|
227 if ( aNeededAttribute == requestAttribute ) |
|
228 { |
|
229 return DefineDefaultCaseStateChange( aContext, aNextState ); |
|
230 } |
|
231 |
|
232 else if ( KSVPHoldSendrecvIndex == aNeededAttribute && |
|
233 KErrNotFound == requestAttribute ) |
|
234 { |
|
235 // If there is no direction attribute at all, default is sendrecv |
|
236 SVPDEBUG1( |
|
237 "CSVPHoldInEstablishingState::CheckAttributeL - No attribute" ); |
|
238 aNextState = KSVPHoldConnectedStateIndex; |
|
239 return KErrNone; |
|
240 } |
|
241 |
|
242 else if ( KSVPHoldSendonlyIndex == aNeededAttribute && |
|
243 KErrNotFound == requestAttribute ) |
|
244 { |
|
245 // no-op request received |
|
246 SVPDEBUG1( |
|
247 "CSVPHoldInEstablishingState::CheckAttributeL - No-op" ); |
|
248 aNextState = KSVPHoldConnectedStateIndex; |
|
249 return KErrNone; |
|
250 } |
|
251 |
|
252 else |
|
253 { |
|
254 // Do not change the aNextState |
|
255 SVPDEBUG1( |
|
256 "CSVPHoldInEstablishingState::CheckAttributeL - else" ); |
|
257 return KErrSVPHoldUnacceptableResponseAttribute; |
|
258 } |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // CSVPHoldInEstablishingState::DefineDefaultCaseStateChange |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 TInt CSVPHoldInEstablishingState:: |
|
266 DefineDefaultCaseStateChange( CSVPHoldContext& aContext, |
|
267 TSVPHoldStateIndex& aNextState ) |
|
268 { |
|
269 switch ( aContext.HoldRequest() ) |
|
270 { |
|
271 case ESVPRemoteHold: |
|
272 { |
|
273 aNextState = KSVPHoldInStateIndex; |
|
274 return KErrNone; |
|
275 } |
|
276 |
|
277 case ESVPRemoteResume: |
|
278 { |
|
279 aNextState = KSVPHoldConnectedStateIndex; |
|
280 return KErrNone; |
|
281 } |
|
282 |
|
283 case ESVPRemoteDoubleHold: |
|
284 { |
|
285 aNextState = KSVPHoldDHStateIndex; |
|
286 return KErrNone; |
|
287 } |
|
288 |
|
289 case ESVPRemoteDoubleHoldResume: |
|
290 { |
|
291 aNextState = KSVPHoldOutStateIndex; |
|
292 return KErrNone; |
|
293 } |
|
294 |
|
295 default: |
|
296 { |
|
297 SVPDEBUG1( |
|
298 "CSVPHoldInEstablishingState::CheckAttributeL - Default" ); |
|
299 return KErrSVPHoldUnacceptableResponseAttribute; |
|
300 } |
|
301 } |
|
302 } |
|
303 |
|
304 |