|
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: Implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 |
|
23 #include "TMCETestUIEngineCmdEstablish.h" |
|
24 #include "CMCETestUIQuestionSingleSelection.h" |
|
25 #include "CMCETestUIQuestionDataQuery.h" |
|
26 #include "CMCETestUIEngineOutSession.h" |
|
27 #include <MCEOutSession.h> |
|
28 #include "CMCETestUIEngineCodec.h" |
|
29 #include "CMCETestUIEngineAudioStream.h" |
|
30 #include "CMCETestUIEngineVideoCodec.h" |
|
31 #include "CMCETestUIEngineVideoStream.h" |
|
32 #include <MCESession.h> |
|
33 #include <MceAudioStream.h> |
|
34 #include <MCEAudioCodec.h> |
|
35 #include <MceVideoStream.h> |
|
36 #include <MCEVideoCodec.h> |
|
37 |
|
38 |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // TMCETestUIEngineCmdEstablish::TMCETestUIEngineCmdEstablish |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 TMCETestUIEngineCmdEstablish::TMCETestUIEngineCmdEstablish( |
|
45 CMCETestUIEngine& aEngine, |
|
46 CMCETestUIEngineOutSession& aOutSession ) |
|
47 : TMCETestUIEngineCmdBase( aEngine ), |
|
48 iOutSession( aOutSession ) |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // TMCETestUIEngineCmdEstablish::ExecuteL |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C void TMCETestUIEngineCmdEstablish::ExecuteL() |
|
57 { |
|
58 if(iEngine.iMultiCodecSupport == EFalse) |
|
59 { |
|
60 DeleteCodecs(); |
|
61 } |
|
62 if(iOutSession.iSessionType == EPoCSession) |
|
63 { |
|
64 TInt num = 36000; |
|
65 HBufC8* content_type = NULL; |
|
66 CDesC8ArrayFlat* headers = NULL; |
|
67 HBufC8* content = NULL; |
|
68 headers = new (ELeave) CDesC8ArrayFlat(1); |
|
69 CleanupStack::PushL( headers ); |
|
70 headers->AppendL(_L8("User-Agent: PoC-client/OMA1.0 Nokia-S60/v1.0")); |
|
71 headers->AppendL(_L8("Accept-Contact: *;+mckoppa")); |
|
72 // headers->AppendL(_L8("Accept-Contact: *;+g.poc.talkburst;require;explicit")); |
|
73 headers->AppendL(_L8("Privacy: id;user;header")); |
|
74 headers->AppendL(_L8("P-Preferred-Identity: \"Joku\" <sip:joku@jossain.com>")); |
|
75 if(iOutSession.iSessionParams.iPoCAdhocSessionType) |
|
76 { |
|
77 content_type = _L8("application/resource-lists+xml").AllocLC(); |
|
78 _LIT8(KNewLine, "\r\n"); |
|
79 _LIT8(KAhListXmlVersionLine,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
|
80 _LIT8(KAhListXmlResourceLists,"<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"); |
|
81 _LIT8(KAhListXmlListTag,"<list>"); |
|
82 _LIT8(KAhListXmlListEndTag,"</list>"); |
|
83 _LIT8(KAhListXmlResourceListsEndTag ,"</resource-lists>"); |
|
84 _LIT8(KAhListXmlEntryUriStartTag ,"<entry uri=\""); |
|
85 _LIT8(KAhListXmlEntryUriEndTag ,"\" />"); |
|
86 _LIT8(KAhUri,"sip:joku@jossain.com"); |
|
87 /* content = _L8("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\ |
|
88 <resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n\ |
|
89 <list>\r\n\ |
|
90 <entry uri=\"sip:g_heikki2@poc.wirelessfuture.com\" />\r\n\ |
|
91 \r\n\ |
|
92 </resource-lists>\r\n").AllocL(); |
|
93 |
|
94 */ |
|
95 |
|
96 |
|
97 |
|
98 content = HBufC8::NewLC( KAhListXmlVersionLine().Length() |
|
99 + KAhListXmlResourceLists().Length() |
|
100 + KAhListXmlListTag().Length() |
|
101 + KNewLine().Length() |
|
102 + KNewLine().Length() |
|
103 + KNewLine().Length() |
|
104 + KAhListXmlEntryUriStartTag().Length() |
|
105 + KAhUri().Length() |
|
106 + KAhListXmlEntryUriEndTag().Length() |
|
107 + KNewLine().Length() |
|
108 + KAhListXmlListEndTag().Length() |
|
109 + KAhListXmlResourceListsEndTag().Length() |
|
110 + KNewLine().Length() |
|
111 + KNewLine().Length() ); |
|
112 |
|
113 content->Des().Append( KAhListXmlVersionLine ); // <?xml version="1.0" encoding="UTF-8"?> |
|
114 content->Des().Append( KNewLine ); |
|
115 content->Des().Append( KAhListXmlResourceLists ); // <resource-lists xmlns="urn:ietf:params:xml.... |
|
116 content->Des().Append( KNewLine ); |
|
117 content->Des().Append( KAhListXmlListTag ); // <list> |
|
118 content->Des().Append( KNewLine ); |
|
119 |
|
120 content->Des().Append( KAhListXmlEntryUriStartTag ); // <entry uri=" |
|
121 content->Des().Append( KAhUri ); // sip:joku@jossain.com |
|
122 content->Des().Append( KAhListXmlEntryUriEndTag ); // " /> |
|
123 content->Des().Append( KNewLine ); |
|
124 |
|
125 content->Des().Append( KAhListXmlListEndTag ); // </list> |
|
126 content->Des().Append( KNewLine ); |
|
127 content->Des().Append( KAhListXmlResourceListsEndTag ); // </resource-lists> |
|
128 content->Des().Append( KNewLine ); // /r/n |
|
129 |
|
130 |
|
131 |
|
132 CleanupStack::Pop( content ); |
|
133 CleanupStack::Pop( content_type ); |
|
134 } |
|
135 |
|
136 CleanupStack::Pop( headers ); |
|
137 iOutSession.OutSession().EstablishL(num,headers,content_type,content); |
|
138 } |
|
139 |
|
140 else |
|
141 { |
|
142 TInt num = 36000; |
|
143 HBufC8* content_type = NULL; |
|
144 CDesC8ArrayFlat* headers = NULL; |
|
145 HBufC8* content = NULL; |
|
146 headers = new (ELeave) CDesC8ArrayFlat(1); |
|
147 CleanupStack::PushL( headers ); |
|
148 if(iEngine.iKoppaFlag) |
|
149 { |
|
150 headers->AppendL(_L8("Accept-Contact: *;+mckoppa")); |
|
151 } |
|
152 CleanupStack::Pop( headers ); |
|
153 iOutSession.OutSession().EstablishL(num,headers,content_type,content); |
|
154 } |
|
155 iEngine.EngineStateChangedL(); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // TMCETestUIEngineCmdEstablish::DeleteCodecs |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C void TMCETestUIEngineCmdEstablish:: DeleteCodecs() |
|
163 { |
|
164 const RPointerArray<CMCETestUIEngineAudioStream>& audioStreams = |
|
165 iOutSession.AudioStreamsL(); |
|
166 |
|
167 for ( TInt i = 0; i < audioStreams.Count(); ++i ) |
|
168 { |
|
169 RPointerArray<CMCETestUIEngineCodec>& codecs = |
|
170 audioStreams[i]->CodecsL(); |
|
171 TInt count = codecs.Count(); |
|
172 //delete all codecs except first one |
|
173 for ( TInt j = count-1; j > 0; --j ) |
|
174 { |
|
175 audioStreams[i]->AudioStream().RemoveCodecL(codecs[j]->Codec()); |
|
176 delete codecs[j]; |
|
177 codecs.Remove( j ); |
|
178 codecs.Compress(); |
|
179 iEngine.EngineStateChangedL(); |
|
180 } |
|
181 } |
|
182 const RPointerArray<CMCETestUIEngineVideoStream>& videoStreams = |
|
183 iOutSession.VideoStreamsL(); |
|
184 |
|
185 for ( TInt i = 0; i < videoStreams.Count(); ++i ) |
|
186 { |
|
187 RPointerArray<CMCETestUIEngineVideoCodec>& codecs = |
|
188 videoStreams[i]->CodecsL(); |
|
189 TInt count = codecs.Count(); |
|
190 //delete all codecs except first one |
|
191 for ( TInt j = count-1; j > 0; --j ) |
|
192 { |
|
193 videoStreams[i]->VideoStream().RemoveCodecL(codecs[j]->Codec()); |
|
194 delete codecs[j]; |
|
195 codecs.Remove( j ); |
|
196 codecs.Compress(); |
|
197 iEngine.EngineStateChangedL(); |
|
198 } |
|
199 } |
|
200 } |
|
201 // ----------------------------------------------------------------------------- |
|
202 // TMCETestUIEngineCmdEstablish::Caption |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 EXPORT_C const TDesC& TMCETestUIEngineCmdEstablish::Caption() const |
|
206 { |
|
207 return KCommandCaptionEstablish; |
|
208 } |
|
209 |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // TMCETestUIEngineCmdEstablishWithValues::TMCETestUIEngineCmdEstablishWithValues |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TMCETestUIEngineCmdEstablishWithValues::TMCETestUIEngineCmdEstablishWithValues( |
|
216 CMCETestUIEngine& aEngine, |
|
217 CMCETestUIEngineOutSession& aOutSession ) |
|
218 : TMCETestUIEngineCmdBase( aEngine ), |
|
219 iOutSession( aOutSession ) |
|
220 { |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // TMCETestUIEngineCmdEstablishWithValues::ExecuteL |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 EXPORT_C void TMCETestUIEngineCmdEstablishWithValues::ExecuteL() |
|
228 { |
|
229 if(iEngine.iMultiCodecSupport == EFalse) |
|
230 { |
|
231 DeleteCodecs(); |
|
232 } |
|
233 TSessionEstablishValues sessionValues; |
|
234 if(iEngine.SessionEstablishValues( sessionValues)) |
|
235 { |
|
236 // change the values to the format needed by api |
|
237 CDesC8Array* headers; |
|
238 headers = new (ELeave) CDesC8ArrayFlat( 1 ); |
|
239 CleanupStack::PushL( headers ); |
|
240 // if(sessionValues.headers.Compare(KNone)) |
|
241 // { |
|
242 CMCETestUIQuestionDataQuery* question = |
|
243 CMCETestUIQuestionDataQuery::NewLC(); |
|
244 question->SetCaptionL( KUserQuestionInputRecipient ); |
|
245 question->SetDefaultValueL(sessionValues.headers ); |
|
246 question->SetAnswerL( sessionValues.headers ); |
|
247 TBufC8<100> headersbuffer( question->Answer8() ); |
|
248 CleanupStack::PopAndDestroy( question ); |
|
249 headers->AppendL( headersbuffer ); |
|
250 // } |
|
251 // else |
|
252 // { |
|
253 // headers = new (ELeave) CDesC8ArrayFlat( 1 ); |
|
254 // CleanupStack::PushL( headers ); |
|
255 //headers->AppendL( KAcceptContactMCETestUI ); |
|
256 // } |
|
257 /* HBufC8* contentType; |
|
258 HBufC8* content; |
|
259 CDesC8Array* contentHeaders; |
|
260 if(sessionValues.headers.Compare(KNone)) |
|
261 { |
|
262 CMCETestUIQuestionDataQuery* question = |
|
263 CMCETestUIQuestionDataQuery::NewLC(); |
|
264 question->SetCaptionL( KUserQuestionInputRecipient ); |
|
265 question->SetDefaultValueL(sessionValues.headers ); |
|
266 question->SetAnswerL( sessionValues.headers ); |
|
267 TBufC8<100> headersbuffer( question->Answer8() ); |
|
268 CleanupStack::PopAndDestroy( question ); |
|
269 headers = new (ELeave) CDesC8ArrayFlat( 1 ); |
|
270 CleanupStack::PushL( headers ); |
|
271 headers->AppendL( headersbuffer ); |
|
272 } |
|
273 else |
|
274 { |
|
275 headers = new (ELeave) CDesC8ArrayFlat( 1 ); |
|
276 CleanupStack::PushL( headers ); |
|
277 headers->AppendL( KAcceptContactMCETestUI ); |
|
278 } |
|
279 if(sessionValues.contentType.Compare(KNone) ) |
|
280 { |
|
281 contentType = HBufC8::NewLC(sessionValues.contentType.Length()); |
|
282 TPtr8 ptr8 = contentType->Des(); |
|
283 ptr8.Copy(sessionValues.contentType); |
|
284 } |
|
285 else |
|
286 { |
|
287 contentType = KNullDesC8().AllocLC(); |
|
288 } |
|
289 if(sessionValues.content.Compare(KNone)) |
|
290 { |
|
291 content = HBufC8::NewLC(sessionValues.content.Length()); |
|
292 TPtr8 ptr8 = content->Des(); |
|
293 ptr8.Copy(sessionValues.content); |
|
294 } |
|
295 else |
|
296 { |
|
297 content = KNullDesC8().AllocLC(); |
|
298 } |
|
299 |
|
300 if(sessionValues.contentHeaders.Compare(KNone)) |
|
301 { |
|
302 CMCETestUIQuestionDataQuery* question = |
|
303 CMCETestUIQuestionDataQuery::NewLC(); |
|
304 question->SetCaptionL( KUserQuestionInputRecipient ); |
|
305 question->SetDefaultValueL(sessionValues.contentHeaders ); |
|
306 question->SetAnswerL( sessionValues.contentHeaders ); |
|
307 TBufC8<100> headersbuffer( question->Answer8() ); |
|
308 CleanupStack::PopAndDestroy( question ); |
|
309 contentHeaders = new (ELeave) CDesC8ArrayFlat( 1 ); |
|
310 CleanupStack::PushL( contentHeaders ); |
|
311 contentHeaders->AppendL( headersbuffer ); |
|
312 } |
|
313 else |
|
314 { |
|
315 contentHeaders = new (ELeave) CDesC8ArrayFlat( 1 ); |
|
316 CleanupStack::PushL( contentHeaders ); |
|
317 contentHeaders->AppendL( KAcceptContactMCETestUI ); |
|
318 } |
|
319 |
|
320 iOutSession.OutSession().EstablishL(sessionValues.timeOut, headers, contentType, content, contentHeaders ); |
|
321 CleanupStack::Pop( contentHeaders ); |
|
322 CleanupStack::Pop( content ); |
|
323 CleanupStack::Pop( contentType ); |
|
324 |
|
325 */ |
|
326 |
|
327 |
|
328 |
|
329 // --------------------------------------- |
|
330 // Next is to find a way around MMCE's bug |
|
331 |
|
332 HBufC8* contentType = KNullDesC8().AllocLC(); |
|
333 HBufC8* content = KNullDesC8().AllocLC(); |
|
334 |
|
335 /// -------------------------------------- |
|
336 CleanupStack::Pop( content ); |
|
337 CleanupStack::Pop( contentType ); |
|
338 CleanupStack::Pop( headers ); |
|
339 iOutSession.OutSession().EstablishL( sessionValues.timeOut, headers, contentType, content, NULL ); |
|
340 |
|
341 iEngine.EngineStateChangedL(); |
|
342 } |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // TMCETestUIEngineCmdEstablishWithValues::DeleteCodecs |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 |
|
350 EXPORT_C void TMCETestUIEngineCmdEstablishWithValues:: DeleteCodecs() |
|
351 { |
|
352 const RPointerArray<CMCETestUIEngineAudioStream>& audioStreams = |
|
353 iOutSession.AudioStreamsL(); |
|
354 |
|
355 for ( TInt i = 0; i < audioStreams.Count(); ++i ) |
|
356 { |
|
357 RPointerArray<CMCETestUIEngineCodec>& codecs = |
|
358 audioStreams[i]->CodecsL(); |
|
359 TInt count = codecs.Count(); |
|
360 //delete all codecs except first one |
|
361 for ( TInt j = count-1; j > 0; --j ) |
|
362 { |
|
363 audioStreams[i]->AudioStream().RemoveCodecL(codecs[j]->Codec()); |
|
364 delete codecs[j]; |
|
365 codecs.Remove( j ); |
|
366 codecs.Compress(); |
|
367 iEngine.EngineStateChangedL(); |
|
368 } |
|
369 } |
|
370 const RPointerArray<CMCETestUIEngineVideoStream>& videoStreams = |
|
371 iOutSession.VideoStreamsL(); |
|
372 |
|
373 for ( TInt i = 0; i < videoStreams.Count(); ++i ) |
|
374 { |
|
375 RPointerArray<CMCETestUIEngineVideoCodec>& codecs = |
|
376 videoStreams[i]->CodecsL(); |
|
377 TInt count = codecs.Count(); |
|
378 //delete all codecs except first one |
|
379 for ( TInt j = count-1; j > 0; --j ) |
|
380 { |
|
381 videoStreams[i]->VideoStream().RemoveCodecL(codecs[j]->Codec()); |
|
382 delete codecs[j]; |
|
383 codecs.Remove( j ); |
|
384 codecs.Compress(); |
|
385 iEngine.EngineStateChangedL(); |
|
386 } |
|
387 } |
|
388 } |
|
389 // ----------------------------------------------------------------------------- |
|
390 // TMCETestUIEngineCmdEstablishWithValues::Caption |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 EXPORT_C const TDesC& TMCETestUIEngineCmdEstablishWithValues::Caption() const |
|
394 { |
|
395 return KUserQuestionOptionEstalishWithValues; |
|
396 } |
|
397 |
|
398 |
|
399 // End of File |