|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "pushtests.h" |
|
17 |
|
18 #include "dummywapstack.h" |
|
19 #include "pushcpoint.h" |
|
20 |
|
21 |
|
22 //---------------------------------------------------------------------------------------- |
|
23 // CTestTimer |
|
24 //---------------------------------------------------------------------------------------- |
|
25 |
|
26 |
|
27 _LIT(KTextFinished,"All finished"); |
|
28 |
|
29 void CWapPushR3Test::RunL() |
|
30 { |
|
31 switch (iState) |
|
32 { |
|
33 case EInitialisation: |
|
34 { |
|
35 iSiaMsgPushed=EFalse; |
|
36 //Create Hard coded Sia Push Msg Body and Header |
|
37 CreateClSecureSiaPushMsgL(); |
|
38 |
|
39 // Create WAP Stack passing MDummyWapStackObserverderived instance |
|
40 // Create Connection Manager, once WAP stack setup |
|
41 iWapStack = CDummyWapStack::NewL(*this); |
|
42 iConnMan = CConnectionManager::NewL(*this); |
|
43 iTimer = CTestTimer::NewL(this); |
|
44 MoveToNextState(); |
|
45 return; |
|
46 } |
|
47 |
|
48 case EDWSOGetEventInitialisation: |
|
49 { |
|
50 iResponseState=ESessionConfirm; |
|
51 iAck = EFalse; |
|
52 MoveToNextState(); |
|
53 return; |
|
54 } |
|
55 |
|
56 case EWaitForAcknowledge: |
|
57 { |
|
58 if (iAck) |
|
59 { |
|
60 iTimer->Cancel(); |
|
61 } |
|
62 else |
|
63 { |
|
64 TInt KTimeOut = 500000; |
|
65 // If nothing happens after KTimeOut... get out of here. |
|
66 iTimer->After(KTimeOut); |
|
67 } |
|
68 MoveToNextState(); |
|
69 return; |
|
70 } |
|
71 case EFinished: |
|
72 { |
|
73 Printf(KTextFinished); |
|
74 SetPriority(EPriorityIdle); |
|
75 MoveToNextState(); |
|
76 return; |
|
77 } |
|
78 default: |
|
79 // Finished |
|
80 iEngine->TestCompleted(iStatus.Int()); |
|
81 return; |
|
82 } |
|
83 }; |
|
84 |
|
85 void CWapPushR3Test::Timeout() |
|
86 { |
|
87 iState = EFinished; |
|
88 CompleteOwnRequest(); |
|
89 } |
|
90 |
|
91 |
|
92 CWapPushR3Test::~CWapPushR3Test() |
|
93 { |
|
94 delete iConnMan; |
|
95 delete iWapStack; |
|
96 delete iTimer; |
|
97 } |
|
98 |
|
99 void CWapPushR3Test::DoCancel() |
|
100 { |
|
101 delete iConnMan; |
|
102 delete iWapStack; |
|
103 iEngine->TestCompleted(KErrCancel); |
|
104 } |
|
105 |
|
106 void CWapPushR3Test::MoveToNextState() |
|
107 { |
|
108 iState = (TState)(iState+1); |
|
109 CompleteOwnRequest(); |
|
110 } |
|
111 |
|
112 void CWapPushR3Test::CompleteOwnRequest() |
|
113 { |
|
114 if(!IsActive()) |
|
115 { |
|
116 TRequestStatus* stat = &iStatus; |
|
117 User::RequestComplete(stat,KErrNone); |
|
118 SetActive(); |
|
119 } |
|
120 } |
|
121 |
|
122 const TDesC& CWapPushR3Test::TestName() |
|
123 { |
|
124 _LIT(KTextSLMessageTest,"Release Three"); |
|
125 return KTextSLMessageTest; |
|
126 } |
|
127 |
|
128 |
|
129 /** |
|
130 Called by DummyWapStack and returns the push message body |
|
131 and header. |
|
132 -Push msg is pushed to the DummyWapStack only for the |
|
133 case CL Secure, and it is pushed only once. |
|
134 -For the case of CL Unsecure no push msg is returned. |
|
135 |
|
136 @param aDummyCLConn |
|
137 @return iBodyBuf |
|
138 @return iHeadersBuf |
|
139 */ |
|
140 void CWapPushR3Test::DWSOUnitWaitPushL(CDummyWSPCLConn& aDummyCLConn) |
|
141 { |
|
142 //if unsecure CL then No Push Message is returned |
|
143 if(aDummyCLConn.LocalPort()== KPushPortSecure) |
|
144 if(!iSiaMsgPushed) |
|
145 { |
|
146 aDummyCLConn.CompleteUnitWaitPushL(iBodyBuf,iHeadersBuf); |
|
147 iSiaMsgPushed=ETrue; |
|
148 } |
|
149 } |
|
150 |
|
151 /** |
|
152 display error message |
|
153 @param string |
|
154 @param line number |
|
155 */ |
|
156 void CWapPushR3Test::DWSOError(const TDesC& aDes, TInt /*aLineNum*/) |
|
157 { |
|
158 iEngine->Printf(TestName(),aDes); |
|
159 } |
|
160 |
|
161 /** |
|
162 Wap Stack Server closing... |
|
163 */ |
|
164 void CWapPushR3Test::DWSOServerShutDown() |
|
165 { |
|
166 // TO DO: |
|
167 iEngine->Printf(TestName(), _L(" ServerShutDown called")); |
|
168 } |
|
169 |
|
170 /** |
|
171 Cancel pushwait operation |
|
172 */ |
|
173 void CWapPushR3Test::DWSOCancelUnitWaitPush(CDummyWSPCLConn& /*aDummyCLConn */) |
|
174 { |
|
175 iEngine->Printf(TestName(), _L(" DWSOCancelUnitWaitPush called")); |
|
176 } |
|
177 |
|
178 void CWapPushR3Test::DWSOConnect(CDummyWSPCOConn& /*aDummyCOConn*/) |
|
179 { |
|
180 } |
|
181 |
|
182 void CWapPushR3Test::DWSOGetEventL(CDummyWSPCOConn& aDummyCOConn) |
|
183 { |
|
184 // only go through once |
|
185 if (!iAck) |
|
186 { |
|
187 iTimer->Cancel(); |
|
188 RWSPCOConn::TEvent event; |
|
189 CDummyWSPCOTrans* dummyTransaction=NULL; |
|
190 switch (iResponseState) |
|
191 { |
|
192 case CWapPushR3Test::ESessionConfirm: |
|
193 dummyTransaction = new (ELeave) CDummyWSPCOTrans(aDummyCOConn); |
|
194 event=RWSPCOConn::EConnect_cnf_s; |
|
195 iResponseState=CWapPushR3Test::ETransaction; |
|
196 aDummyCOConn.CompleteGetEventL(event,*dummyTransaction); |
|
197 break; |
|
198 case CWapPushR3Test::ETransaction: |
|
199 CreateMultiPartRelatedPushMsg();//Creates a New Push Msg |
|
200 //CreateSLPushMsg(); //Test |
|
201 dummyTransaction = new (ELeave) CDummyWSPCOTrans(aDummyCOConn); |
|
202 dummyTransaction->SetData(iHeadersBuf, RWSPCOTrans::EPushHeaders); |
|
203 dummyTransaction->SetData(iBodyBuf, RWSPCOTrans::EPushBody); |
|
204 |
|
205 event=RWSPCOConn::EConfirmedPush_ind_t; |
|
206 aDummyCOConn.CompleteGetEventL(event,*dummyTransaction); |
|
207 break; |
|
208 default: |
|
209 dummyTransaction = new (ELeave) CDummyWSPCOTrans(aDummyCOConn); |
|
210 event=RWSPCOConn::EConfirmedPush_ind_t; |
|
211 aDummyCOConn.CompleteGetEventL(event,*dummyTransaction); |
|
212 break; |
|
213 } |
|
214 } |
|
215 |
|
216 } |
|
217 |
|
218 void CWapPushR3Test::DWSOCancelGetEvent(CDummyWSPCOConn& /*aDummyCOConn*/) |
|
219 { |
|
220 } |
|
221 |
|
222 void CWapPushR3Test::DWSOAckTransaction(CDummyWSPCOTrans& /*aDummyCOTrans*/) |
|
223 { |
|
224 // only go through once |
|
225 if (!iAck) |
|
226 { |
|
227 iAck = ETrue; |
|
228 CompleteOwnRequest(); |
|
229 } |
|
230 } |
|
231 |
|
232 /** |
|
233 * Hardcoded Creation of an SL Test Push Message |
|
234 */ |
|
235 void CWapPushR3Test::CreateSLPushMsg() |
|
236 { |
|
237 |
|
238 // create hardcoded SL test message (Julia's code) |
|
239 const TUint8 KMessageHeader2[] = |
|
240 { |
|
241 0xAF, //Content type "application/vnd.wap.sl" |
|
242 0x92, // Date |
|
243 0x04, // length of field |
|
244 0x39, // Monday 15 August 2000 10:41:37 GMT |
|
245 0x90, |
|
246 0x6a, |
|
247 0xd0, |
|
248 0x94, // Expires |
|
249 0x04, // length of field |
|
250 0x39, // Monday 15 August 2000 10:41:37 GMT |
|
251 0x9a, |
|
252 0x6a, |
|
253 0xd0, |
|
254 0xAF, //X-Wap-Application-ID |
|
255 0x82 // Short int - 0x02 represent x-wap-application:push.ua |
|
256 }; |
|
257 |
|
258 |
|
259 TBuf8<40> tempBuf; |
|
260 TUint8 value; |
|
261 |
|
262 for (TInt i = 0; i < 15; i++) |
|
263 { |
|
264 value = KMessageHeader2[i]; |
|
265 tempBuf.Append(value); |
|
266 } |
|
267 |
|
268 iHeadersBuf.Copy(tempBuf); |
|
269 tempBuf.Copy(_L8("")); |
|
270 |
|
271 |
|
272 _LIT(LF, "\n"); |
|
273 //Hard coded SL Text Msg |
|
274 _LIT(KSL1stLine,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); |
|
275 _LIT(KSL2ndLine,"<!DOCTYPE sl PUBLIC \"-//WAPFORUM//DTD SL 1.0//EN\""); |
|
276 _LIT(KSL3rdLine,"\"http://www.wapforum.org/DTD/sl.dtd\">"); |
|
277 _LIT(KSL4thLine,"<sl"); |
|
278 _LIT(KSL5thLine,"href=\"http://www.xyz.com/ppaid/123/abc.wml\""); |
|
279 _LIT(KSL6thLine,"action=\"execute-high\">"); |
|
280 _LIT(KSL7thLine,"</sl>"); |
|
281 |
|
282 iBodyBuf.Delete(0,KBufferSize); |
|
283 iBodyBuf.Append(KSL1stLine); |
|
284 iBodyBuf.Append(LF); |
|
285 iBodyBuf.Append(KSL2ndLine); |
|
286 iBodyBuf.Append(LF); |
|
287 iBodyBuf.Append(KSL3rdLine); |
|
288 iBodyBuf.Append(LF); |
|
289 iBodyBuf.Append(KSL4thLine); |
|
290 iBodyBuf.Append(LF); |
|
291 iBodyBuf.Append(KSL5thLine); |
|
292 iBodyBuf.Append(LF); |
|
293 iBodyBuf.Append(KSL6thLine); |
|
294 iBodyBuf.Append(LF); |
|
295 iBodyBuf.Append(KSL7thLine); |
|
296 |
|
297 } |
|
298 |
|
299 /* Create a hard coded Mulipart Related Push message. |
|
300 * The Multipart Push Message Contains: |
|
301 * - 1. Si |
|
302 * - 2. vCard |
|
303 * - 3. JPEG |
|
304 */ |
|
305 void CWapPushR3Test::CreateMultiPartRelatedPushMsg() |
|
306 { |
|
307 // The Multipart Header |
|
308 const TUint8 KMessageHeaderMultipart[]= |
|
309 { |
|
310 0xB3, //Content type "application/vnd.wap.multipart.related" |
|
311 0x94, // Date |
|
312 0x04, // length of field |
|
313 0x35, // Thur 23 Apr 1998 13:41:37 GMT |
|
314 0x3F, |
|
315 0x45, |
|
316 0x11, |
|
317 0xAF, //X-Wap-Application-ID |
|
318 0x82, // Short int - 0x02 represent x-wap-application:push.ua |
|
319 }; |
|
320 |
|
321 iHeadersBuf.Copy(KMessageHeaderMultipart, sizeof(KMessageHeaderMultipart)); |
|
322 |
|
323 // Number of parts |
|
324 const TUint8 KNumParts[] = {0x03}; |
|
325 iBodyBuf.Copy(KNumParts, sizeof(KNumParts)); |
|
326 |
|
327 |
|
328 //----- Push Message Part No.1 --------- |
|
329 // Si Message with Multipart Code |
|
330 const TUint8 KSIMultiHeader1[]= |
|
331 { |
|
332 0x0A, // part 3 header size |
|
333 0x82 , // part 3 body size (334) UintVar 10000010 |
|
334 0x4E, // 01001110 |
|
335 0xAD, // content type application/vnd.wap.si ... the headers: |
|
336 0x94, // Date |
|
337 0x04, // length of field |
|
338 0x35, // Thur 23 Apr 1998 13:41:37 GMT |
|
339 0x3F, |
|
340 0x45, |
|
341 0x11, |
|
342 0x3F, |
|
343 0x45, |
|
344 0x11 |
|
345 }; |
|
346 |
|
347 // Si Body |
|
348 const TUint8 KSIMultiBody1[] = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" \ |
|
349 "<!DOCTYPE si PUBLIC \"-//WAPFORUM//DTD SI 1.0//EN\"\n" \ |
|
350 "\"http://www.wapforum.org/DTD/si.dtd\">\n" \ |
|
351 " <si>\n" \ |
|
352 " <indication\n" \ |
|
353 " action=\"signal-none\"\n" \ |
|
354 " href=\"http://mmm.ppp.qqq/\"\n" \ |
|
355 " si-id=\"123123\"\n" \ |
|
356 " created=\"2000-08-29T16:46:03Z\"\n" \ |
|
357 " si-expires=\"2000-08-30T16:46:03Z\"\n" \ |
|
358 " >\n" \ |
|
359 " This is displayed text.\n" \ |
|
360 " </indication>\n" \ |
|
361 "</si> \n"; |
|
362 |
|
363 |
|
364 iBodyBuf.Append(KSIMultiHeader1, sizeof(KSIMultiHeader1)); |
|
365 iBodyBuf.Append(KSIMultiBody1, sizeof(KSIMultiBody1)-1); |
|
366 |
|
367 //----- Push Message Part No.2 --------- |
|
368 // vCard Message |
|
369 const TUint8 KvCardMultiHeader2[]= |
|
370 { |
|
371 0x0A, // part 3 header size |
|
372 0x83, // part 3 body size (496) UintVar 10000011 |
|
373 0x70, // 0111000 |
|
374 0x87, // content type "text/x-vCard" |
|
375 0x94, // Date |
|
376 0x04, // length of field |
|
377 0x35, // Thur 23 Apr 1998 13:41:37 GMT |
|
378 0x3F, |
|
379 0x45, |
|
380 0x11, |
|
381 0x3F, |
|
382 0x45, |
|
383 0x11 |
|
384 }; |
|
385 |
|
386 // vCard Body |
|
387 const TUint8 KvCardMultiBody2[] = "BEGIN:VCARD\r\n" \ |
|
388 "VERSION:2.1\r\n" \ |
|
389 "N:Wibble;Barney\r\n" \ |
|
390 "FN:Barney Wibble\r\n" \ |
|
391 "ORG:WibCo\r\n" \ |
|
392 "TITLE:Wib Monitor\r\n" \ |
|
393 "TEL;WORK;VOICE:+44 012345345\r\n" \ |
|
394 "TEL;HOME;VOICE:+44 12143234\r\n" \ |
|
395 "ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;23 The Wibble=0D=0AWibble Street;WibbleHampton;Wibbleshire;;United Kingdom\r\n" \ |
|
396 "LABEL;WORK;ENCODING=QUOTED-PRINTABLE:23 The Wibble=0D=0AWibble Street=0D=0AWibbleHampton, Wibbleshire=0D=0AUnited=Kingdom\r\n" \ |
|
397 "URL:http://www.wibbleweb.wib\r\n" \ |
|
398 "EMAIL;PREF;INTERNET:barney.wibble@wibco.co.uk\r\n" \ |
|
399 "REV:20000322T104543Z\r\n" \ |
|
400 "END:VCARD\r\n"; |
|
401 |
|
402 |
|
403 iBodyBuf.Append(KvCardMultiHeader2, sizeof(KvCardMultiHeader2)); |
|
404 iBodyBuf.Append(KvCardMultiBody2, sizeof(KvCardMultiBody2)-1); |
|
405 |
|
406 |
|
407 |
|
408 //----- Push Message Part No.3 --------- |
|
409 // JPEG Message Part |
|
410 const TUint8 KJpegCMultipart3[]= |
|
411 { |
|
412 0x0A, // part 2 header size |
|
413 0x64, // part 2 body size |
|
414 0x9E, // content type "image/jpeg" |
|
415 0x94, // Date |
|
416 0x04, // length of field |
|
417 0x35, // Thur 23 Apr 1998 13:41:37 GMT |
|
418 0x3F, |
|
419 0x45, |
|
420 0x11, |
|
421 0x3F, |
|
422 0x45, |
|
423 0x11, |
|
424 0x01, 0x05, 0x6A, 0x12, 0x65, 0x6D, 0x61, 0x69, 0x6C, 0x2F, 0x31, 0x32, 0x33, 0x2F, 0x61, 0x62, |
|
425 0x63, 0x2E, 0x77, 0x6D, 0x6C, 0x00, 0x45, 0xC6, 0x05, 0x0D, 0x03, 0x78, 0x79, 0x7A, 0x00, 0x85, |
|
426 0x83, 0x00, 0x11, 0x03, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x78, |
|
427 0x79, 0x7A, 0x00, 0x85, 0x83, 0x00, 0x0A, 0xC3, 0x07, 0x19, 0x99, 0x06, 0x25, 0x15, 0x23, 0x15, |
|
428 0x10, 0xC3, 0x04, 0x19, 0x99, 0x06, 0x30, 0x01, 0x03, 0x20, 0x59, 0x6F, 0x75, 0x20, 0x68, 0x61, |
|
429 0x76, 0x65, 0x20, 0x34, 0x20, 0x6E, 0x65, 0x77, 0x20, 0x65, 0x6D, 0x61, 0x69, 0x6C, 0x73, 0x2E, |
|
430 0x20, 0x00, 0x01, 0x01}; |
|
431 |
|
432 iBodyBuf.Append(KJpegCMultipart3, sizeof(KJpegCMultipart3)); |
|
433 |
|
434 //-- end of Mulitipart Related Push Message --- |
|
435 } |
|
436 |
|
437 |
|
438 /** |
|
439 * Creates a ConnectionLess Secure SIA Push Message. |
|
440 */ |
|
441 void CWapPushR3Test::CreateClSecureSiaPushMsgL() |
|
442 { |
|
443 // SetupAddressL(); |
|
444 |
|
445 const TUint8 KSIAMessageHeader[] = |
|
446 { |
|
447 0xB4, //Content type "application/vnd.wap.sia" |
|
448 0x92, // Date |
|
449 0x04, // length of field |
|
450 0x39, // Monday 15 August 2000 10:41:37 GMT |
|
451 0x90, |
|
452 0x6a, |
|
453 0xd0, |
|
454 0x94, // Expires |
|
455 0x04, // length of field |
|
456 0x39, // Monday 15 August 2000 10:41:37 GMT |
|
457 0x9a, |
|
458 0x6a, |
|
459 0xd0, |
|
460 0xAF, //X-Wap-Application-ID |
|
461 0x82 // Short int - 0x02 represent x-wap-application:push.ua |
|
462 }; |
|
463 iHeadersBuf.Append(KSIAMessageHeader, sizeof(KSIAMessageHeader)); |
|
464 |
|
465 iBodyBuf.Delete(0,KBufferSize); |
|
466 |
|
467 const TUint8 SIA[]= |
|
468 { |
|
469 0x00, // version |
|
470 0x02, // AppIdListLen |
|
471 0x44, // Application Id List |
|
472 0x44, |
|
473 0x1B, // ContactPointsLen |
|
474 // Contact Points |
|
475 0xD7, // bearer flag and port flag and address len |
|
476 0x0A, // bearer Type (CSD) |
|
477 0x0B, // port number |
|
478 0x84, // = 2948 |
|
479 0x68, // address - "http://www.symbian.com/" (as text) |
|
480 0x74, |
|
481 0x74, |
|
482 0x70, |
|
483 0x3A, |
|
484 0x2F, |
|
485 0x2F, |
|
486 0x77, |
|
487 0x77, |
|
488 0x77, |
|
489 0x2E, |
|
490 0x73, |
|
491 0x79, |
|
492 0x6D, |
|
493 0x62, |
|
494 0x69, |
|
495 0x61, |
|
496 0x6E, |
|
497 0x2E, |
|
498 0x63, |
|
499 0x6F, |
|
500 0x6D, |
|
501 0x2F |
|
502 }; |
|
503 iBodyBuf.Append(SIA, sizeof(SIA)); |
|
504 } |
|
505 |
|
506 |
|
507 /** |
|
508 * Prime the commdb with address and security port settings. |
|
509 * |
|
510 */ |
|
511 void CWapPushR3Test::SetupAddressL() |
|
512 { |
|
513 } |