|
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 #include "mcesession.h" |
|
20 //#include "mceinsession.h" |
|
21 #include "mcemanager.h" |
|
22 #include "mcestreambundle.h" |
|
23 #include "mcemediastream.h" |
|
24 #include "mceinsessionobserver.h" |
|
25 #include "mcesessionobserver.h" |
|
26 #include "mcestreamobserver.h" |
|
27 #include "mcertpobserver.h" |
|
28 #include "mcetransactiondatacontainer.h" |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CMceSession::~CMceSession |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 EXPORT_C CMceSession::~CMceSession() |
|
39 { |
|
40 delete iHeaders; |
|
41 delete iSessionSDPLines; |
|
42 |
|
43 delete iOriginator; |
|
44 delete iRecipient; |
|
45 iMediaStreams.ResetAndDestroy(); |
|
46 iBundles.ResetAndDestroy(); |
|
47 |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CMceSession::State |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C CMceSession::TState CMceSession::State() const |
|
56 { |
|
57 return iState; |
|
58 } |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMceSession::ConnectionActive |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C TBool CMceSession::ConnectionActive() const |
|
66 { |
|
67 return iIsConnectionActive; |
|
68 } |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CMceSession::RemoveStreamL |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C void CMceSession::RemoveStreamL( CMceMediaStream& aMediaStream ) |
|
76 { |
|
77 for ( TInt i = 0; i < iMediaStreams.Count(); ++i ) |
|
78 { |
|
79 if ( &aMediaStream == iMediaStreams[i] ) |
|
80 { |
|
81 delete iMediaStreams[i]; |
|
82 iMediaStreams.Remove( i ); |
|
83 return; |
|
84 } |
|
85 } |
|
86 |
|
87 User::Leave( KErrNotFound ); |
|
88 } |
|
89 |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CMceSession::AddStreamL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C void CMceSession::AddStreamL( CMceMediaStream* aMediaStream ) |
|
96 { |
|
97 User::LeaveIfError( iMediaStreams.Find( aMediaStream ) != KErrNotFound ? |
|
98 KErrArgument : KErrNone ); |
|
99 |
|
100 aMediaStream->InitializeL( *this ); // Initialize before taking ownership |
|
101 |
|
102 iMediaStreams.AppendL( aMediaStream ); |
|
103 |
|
104 } |
|
105 |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CMceSession::UpdateL |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C void CMceSession::UpdateL( |
|
112 TUint32 aTimeout, |
|
113 CDesC8Array* aHeaders, |
|
114 HBufC8* aContentType, |
|
115 HBufC8* aContent, |
|
116 CDesC8Array* aContentHeaders ) |
|
117 { |
|
118 User::LeaveIfError( iState != EIdle ? KErrNone : KErrNotReady ); |
|
119 User::LeaveIfError( |
|
120 ( aContentType && aContent ) || |
|
121 !( aContentType || aContent || aContentHeaders ) ? |
|
122 KErrNone : KErrArgument ); |
|
123 |
|
124 // Leave if in incoming state givem too small timeout value |
|
125 User::LeaveIfError( !( aTimeout > 0 && State() == CMceSession::EIncoming ) || |
|
126 aTimeout <= SessionTimer() ? KErrNone : KErrArgument ); |
|
127 |
|
128 InitializeL(); |
|
129 |
|
130 iTimeout = aTimeout; |
|
131 |
|
132 delete iHeaders; |
|
133 iHeaders = aHeaders; |
|
134 delete aContentType; |
|
135 delete aContentHeaders; |
|
136 |
|
137 if ( iState == EIncoming ) |
|
138 { |
|
139 iState = EReserving; |
|
140 } |
|
141 else |
|
142 { |
|
143 iState = EOffering; |
|
144 } |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CMceSession::InitializeL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 /* |
|
152 void CMceSession::InitializeL() |
|
153 { |
|
154 for(int i=0; i<iMediaStreams.Count();i++) |
|
155 { |
|
156 iMediaStreams[i]->InitializeL( *this ); |
|
157 } |
|
158 } |
|
159 */ |
|
160 |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CMceSession::TerminateL |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C void CMceSession::TerminateL( CDesC8Array* aHeaders, |
|
167 HBufC8* aContentType, |
|
168 HBufC8* aContent ) |
|
169 { |
|
170 __ASSERT_ALWAYS( iState != CMceSession::EIdle, User::Leave( KErrNotReady ) ); |
|
171 |
|
172 delete iHeaders; |
|
173 iHeaders = aHeaders; |
|
174 delete aContentType; |
|
175 delete aContent; |
|
176 |
|
177 iState = CMceSession::ETerminating; |
|
178 } |
|
179 |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CMceSession::Streams |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 EXPORT_C const RPointerArray<CMceMediaStream>& CMceSession::Streams() const |
|
186 { |
|
187 return iMediaStreams; |
|
188 } |
|
189 |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CMceSession::Recipient |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 EXPORT_C const TDesC8& CMceSession::Recipient() const |
|
196 { |
|
197 return *iRecipient; |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CMceSession::Originator |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 EXPORT_C const TDesC8& CMceSession::Originator() const |
|
205 { |
|
206 return *iOriginator; |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 EXPORT_C void CMceSession::SetSessionSDPLinesL( CDesC8Array* aSessionSDPLines ) |
|
214 { |
|
215 delete iSessionSDPLines; |
|
216 iSessionSDPLines = aSessionSDPLines; |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 EXPORT_C MDesC8Array* CMceSession::SessionSDPLinesL() |
|
224 { |
|
225 if ( iSessionSDPLines ) |
|
226 { |
|
227 CDesC8Array* array = new ( ELeave ) CDesC8ArrayFlat( 1 ); |
|
228 CleanupStack::PushL( array ); |
|
229 for ( TInt i = 0; i < iSessionSDPLines->Count(); ++i ) |
|
230 { |
|
231 array->AppendL( iSessionSDPLines->MdcaPoint(i) ); |
|
232 } |
|
233 CleanupStack::Pop( array ); |
|
234 return array; |
|
235 } |
|
236 |
|
237 return NULL; |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 EXPORT_C TUint32 CMceSession::SessionTimer() const |
|
245 { |
|
246 return iTimeout; |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CMceSession::AddBundleL |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 EXPORT_C void CMceSession::AddBundleL( CMceStreamBundle* aBundle ) |
|
254 { |
|
255 iBundles.AppendL( aBundle ); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CMceSession::RemoveBundleL |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 EXPORT_C void CMceSession::RemoveBundleL( CMceStreamBundle& aBundle ) |
|
263 { |
|
264 TInt index = iBundles.Find( &aBundle ); |
|
265 User::LeaveIfError( index ); |
|
266 iBundles.Remove( index ); |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CMceSession::Bundles |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C const RPointerArray< CMceStreamBundle >& CMceSession::Bundles() const |
|
274 { |
|
275 return iBundles; |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CMceSession::GetModifierL |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 EXPORT_C void CMceSession::GetModifierL( TMceSessionModifier aModifier, |
|
283 TUint& aValue ) const |
|
284 { |
|
285 if ( aModifier == KMcePreconditions ) |
|
286 { |
|
287 if ( iForceInternetSignaling ) |
|
288 { |
|
289 aValue = KMcePreconditionsNotUsed; |
|
290 } |
|
291 else |
|
292 { |
|
293 aValue = KMcePreconditionsSupported; |
|
294 } |
|
295 return; |
|
296 } |
|
297 User::Leave( KErrNotFound ); |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CMceSession::SetModifierL |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 EXPORT_C void CMceSession::SetModifierL( TMceSessionModifier aModifier, |
|
305 TUint aValue ) |
|
306 { |
|
307 if ( aModifier == KMcePreconditions ) |
|
308 { |
|
309 if ( aValue == KMcePreconditionsNotUsed ) |
|
310 { |
|
311 iForceInternetSignaling = ETrue; |
|
312 } |
|
313 else |
|
314 { |
|
315 iForceInternetSignaling = EFalse; |
|
316 } |
|
317 return; |
|
318 } |
|
319 else if ( aModifier == KMce100Rel ) |
|
320 { |
|
321 if ( aValue >= 0 && aValue <= 2 ) |
|
322 { |
|
323 i100RelUsage = aValue; |
|
324 return; |
|
325 } |
|
326 } |
|
327 User::LeaveIfError( KErrNotSupported ); |
|
328 } |
|
329 |
|
330 // ----------------------------------------------------------------------------- |
|
331 // CMceSession::Profile |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 EXPORT_C TUint32 CMceSession::Profile() const |
|
335 { |
|
336 return iProfileId; |
|
337 } |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CMceSession::CMceSession |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 CMceSession::CMceSession( CMceManager* aManager, TUint32 aProfileId ) |
|
344 : iProfileId( aProfileId ), |
|
345 iManager( aManager ), |
|
346 iState( CMceSession::EIdle), |
|
347 iIsConnectionActive( ETrue ), |
|
348 iForceInternetSignaling( EFalse ), |
|
349 i100RelUsage( 1 ), // MCE default |
|
350 iFailWithCode( KErrNone ), |
|
351 iReasonPhrase( KNullDesC8() ), |
|
352 iReasonCode( 0 ) |
|
353 { |
|
354 } |
|
355 |
|
356 |
|
357 // ----------------------------------------------------------------------------- |
|
358 // CMceSession::Manager |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 CMceManager& CMceSession::Manager() const |
|
362 { |
|
363 return *iManager; |
|
364 } |
|
365 |
|
366 |
|
367 // ----------------------------------------------------------------------------- |
|
368 // CMceSession::ConstructL |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 void CMceSession::ConstructL() |
|
372 { |
|
373 |
|
374 |
|
375 } |
|
376 |
|
377 // ----------------------------------------------------------------------------- |
|
378 // CMceSession::InitializeL |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 void CMceSession::InitializeL() |
|
382 { |
|
383 for (int i=0; i<iMediaStreams.Count();i++) |
|
384 { |
|
385 iMediaStreams[i]->InitializeL( *this ); |
|
386 } |
|
387 |
|
388 /* |
|
389 for(int i=0; i<iBundles.Count();i++) |
|
390 { |
|
391 iBundles[i]->InitializeL( *this ); |
|
392 } |
|
393 */ |
|
394 } |
|
395 |
|
396 |
|
397 |