|
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 // This test harness processes an Internet Access Configuration Message |
|
15 // and uses the resulting database entry to perform a connection to |
|
16 // the POP3 and SMTP servers. |
|
17 // The parser creates the service entries from the files iacp*.txt |
|
18 // placed into the data directory c:\biomsg\iacpcomm. If more |
|
19 // than one entry is placed into the directory the harness uses the |
|
20 // first instance as the target POP3/SMTP provider. |
|
21 // The harness contructs and sends any files of the form rfc*.txt |
|
22 // with the data directory to the SMTP service, before connecting to |
|
23 // the POP3 service to download mail. |
|
24 // The test harness does not support heap fail testing |
|
25 // Based on t_iacp.cpp amd t_pops.cpp |
|
26 // |
|
27 // |
|
28 |
|
29 #include "biotestutils.h" |
|
30 #include "emailtestutils.h" |
|
31 // |
|
32 #include "IACPERR.H" |
|
33 #include "IACPDEF.H" |
|
34 #include <commdb.h> |
|
35 #include <popsmtm.h> |
|
36 #include <etel.h> |
|
37 #include "tmsvbioinfo.h" |
|
38 // |
|
39 //SMS configuration files path |
|
40 _LIT(IACP_TEST_MSG_PATH, "c:\\test\\bio\\iacpcomm\\"); |
|
41 |
|
42 #define BIO_MSG_ENTRY_PARSED 1 // Set entry .iMtmData3 to 1 to indicate that the entry has store i.e parsed,externalised |
|
43 |
|
44 |
|
45 // forward references |
|
46 class CExampleScheduler; |
|
47 class CTestIacp; |
|
48 |
|
49 //global declarations |
|
50 LOCAL_D CExampleScheduler *exampleScheduler; |
|
51 LOCAL_D RTest test(_L("IACPCOMM Test Harness")); |
|
52 |
|
53 // Uncommment the following to provide prompting on the Windows platform |
|
54 // #if defined(_DEBUG) |
|
55 // #define PROMPTUSER test.Printf(_L("\nPress any key: ")); test.Getch(); |
|
56 // #else |
|
57 // #define PROMPTUSER |
|
58 // #endif |
|
59 #define PROMPTUSER |
|
60 |
|
61 // |
|
62 //-- CExampleScheduler -- |
|
63 // |
|
64 class CExampleScheduler : public CActiveScheduler |
|
65 { |
|
66 public: |
|
67 void Error (TInt aError) const; |
|
68 }; |
|
69 |
|
70 void CExampleScheduler::Error(TInt anError) const |
|
71 { |
|
72 CActiveScheduler::Stop(); |
|
73 test.Printf(_L("\nLeave signalled, reason=%d\n"),anError); |
|
74 PROMPTUSER |
|
75 } |
|
76 |
|
77 //-------------------------------------- |
|
78 // |
|
79 //-- CTestIacp -- |
|
80 // |
|
81 |
|
82 enum TSessionState |
|
83 { |
|
84 EParse, // parsing is done at ParseL() stage. and data are externalised. |
|
85 EProcess, // parsed data are internalised, then commited |
|
86 EInitSMTPMTM, // initialise the send test utils for SMTP |
|
87 ESendSMTP, // prep outgoing message and connect to the SMTP service |
|
88 // and send them |
|
89 EInitPOP3MTM, // initialise the send test utils for SMTP |
|
90 EConnectPOP3, // connect to the access point setup by the IACP entry |
|
91 EReceivePOP3, // pull back any messages on the service |
|
92 EDisconnectPOP3,// and disconnect |
|
93 EFinished // Time to pack up |
|
94 }; |
|
95 |
|
96 class CTestIacp : public CActive |
|
97 { |
|
98 public: |
|
99 ~CTestIacp(); |
|
100 static CTestIacp * NewL(CBioTestUtils* aBioTestUtils); |
|
101 void StartL(TSessionState aCmd); |
|
102 CTestIacp(CBioTestUtils* aBioTestUtils); |
|
103 void DoCancel(); |
|
104 void RunL(); |
|
105 TBool DisplaySummary(); |
|
106 TInt Error(); |
|
107 |
|
108 private: |
|
109 void RequestComplete(TRequestStatus& aStatus,TInt aCompletion); |
|
110 void ConstructL(); |
|
111 void CreateParserL(); //sets 'iParser' to point to the created iacp parser |
|
112 void GetMessageBodyL(); |
|
113 void DisplayEntryDataL(); |
|
114 void ParseMsgL(); |
|
115 void ProcessMsgL(); |
|
116 void InitSMTPMTML(); |
|
117 void InitPOP3MTML(); |
|
118 void SendSMTPL(); |
|
119 void ConnectPOP3L(); |
|
120 void DisconnectPOP3L(); |
|
121 void DoRunL(); |
|
122 void SetIAPL(TMsvId aService); |
|
123 void deleteParser(); |
|
124 void CheckSendStatus(); |
|
125 TBool CheckRecvStatus(); |
|
126 void LogCommsError(TInt aError); |
|
127 void LogParseError(TInt& aReason); |
|
128 void GetDefaultConnectionL(); |
|
129 void ReceivePOP3L(); |
|
130 |
|
131 private: |
|
132 TSessionState iState; |
|
133 TInt iError; |
|
134 |
|
135 // for managing the connections to the pop3 and smtp servers |
|
136 CEmailTestUtils* iSendUtils; |
|
137 TMsvId iPop3service; // IACP added entry |
|
138 TMsvId iSmtpservice; // as above |
|
139 CMsvEntrySelection* iMsvSelection; |
|
140 TUint32 iIap; // what commdb record we use for connecting out |
|
141 |
|
142 // for managing the input IACP data |
|
143 CBioTestUtils* iBioTestUtils; |
|
144 CBaseScriptParser2* iParser; |
|
145 |
|
146 HBufC* iSmsMsg; //sms body build dependent |
|
147 TMsvId iEntryId; //ID of sms entry |
|
148 CMsvEntrySelection* iIacpSelection; //the collection of iacp*.txt entries |
|
149 |
|
150 // status |
|
151 TBool iParsedMsg; |
|
152 TBool iConnectedToSMTP; |
|
153 TInt iMsgsSent; |
|
154 TBool iConnectedToPOP3; |
|
155 TInt iMsgsReceived; |
|
156 }; |
|
157 |
|
158 // |
|
159 CTestIacp::CTestIacp(CBioTestUtils* aBioTestUtils) |
|
160 :CActive(EPriorityStandard),iBioTestUtils(aBioTestUtils) |
|
161 { |
|
162 } |
|
163 |
|
164 CTestIacp* CTestIacp::NewL(CBioTestUtils* aBioTestUtils) |
|
165 { |
|
166 CTestIacp* self = new(ELeave) CTestIacp(aBioTestUtils); |
|
167 CleanupStack::PushL(self); |
|
168 self->ConstructL(); |
|
169 CleanupStack::Pop(); //self |
|
170 return self; |
|
171 } |
|
172 |
|
173 void CTestIacp::ConstructL() |
|
174 { |
|
175 iBioTestUtils->WriteComment(_L("CTestIacp::ConstructL().")); |
|
176 CreateParserL(); |
|
177 |
|
178 // for selecting message store items |
|
179 iMsvSelection = new (ELeave) CMsvEntrySelection; |
|
180 |
|
181 iIacpSelection= iBioTestUtils->GenerateMessagesL(IACP_TEST_MSG_PATH); |
|
182 |
|
183 CActiveScheduler::Add(this); |
|
184 } |
|
185 |
|
186 CTestIacp::~CTestIacp() |
|
187 { |
|
188 Cancel(); |
|
189 |
|
190 deleteParser(); |
|
191 delete iIacpSelection; |
|
192 delete iSmsMsg; |
|
193 delete iSendUtils; |
|
194 delete iMsvSelection; |
|
195 } |
|
196 |
|
197 void CTestIacp::CreateParserL() |
|
198 { |
|
199 TRAPD(error,(iParser = iBioTestUtils->CreateParserTypeL(KUidBIOInternetAccessPointMsg))); |
|
200 if (error == KErrNone) |
|
201 { |
|
202 iBioTestUtils->WriteComment(_L("Created IACP Parser object")); |
|
203 } |
|
204 else |
|
205 { |
|
206 LogParseError(error); |
|
207 User::Leave(error); |
|
208 } |
|
209 } |
|
210 |
|
211 void CTestIacp::GetMessageBodyL() |
|
212 { |
|
213 // get a memory version of the message created by the test utils |
|
214 delete iSmsMsg; |
|
215 iSmsMsg = NULL; |
|
216 iSmsMsg = iBioTestUtils->MessageBodyL(iEntryId).AllocL(); |
|
217 } |
|
218 |
|
219 TInt CTestIacp::Error() |
|
220 { |
|
221 return iError; |
|
222 } |
|
223 |
|
224 void CTestIacp::StartL(TSessionState aCmd) |
|
225 { |
|
226 iState=aCmd; |
|
227 iEntryId = (*iIacpSelection)[0]; |
|
228 |
|
229 switch (iState) |
|
230 { |
|
231 case EParse: |
|
232 test.Printf(_L("Parsing...\n")); |
|
233 iBioTestUtils->SetEntryL(iEntryId); //clients have to set the right context before calling ParseL() |
|
234 GetMessageBodyL(); |
|
235 ParseMsgL(); |
|
236 break; |
|
237 |
|
238 case EProcess: |
|
239 test.Printf(_L("Processing...\n")); |
|
240 iBioTestUtils->SetEntryL(iEntryId); //clients have to set the right context before calling CommitL() |
|
241 ProcessMsgL(); |
|
242 break; |
|
243 |
|
244 case EInitSMTPMTM: |
|
245 InitSMTPMTML(); |
|
246 RequestComplete(iStatus,KErrNone); |
|
247 SetActive(); |
|
248 break; |
|
249 |
|
250 case EInitPOP3MTM: |
|
251 InitPOP3MTML(); |
|
252 RequestComplete(iStatus,KErrNone); |
|
253 SetActive(); |
|
254 break; |
|
255 |
|
256 case ESendSMTP: |
|
257 SendSMTPL(); |
|
258 break; |
|
259 |
|
260 case EConnectPOP3: |
|
261 ConnectPOP3L(); |
|
262 break; |
|
263 |
|
264 case EReceivePOP3: |
|
265 ReceivePOP3L(); |
|
266 break; |
|
267 |
|
268 case EDisconnectPOP3: |
|
269 DisconnectPOP3L(); |
|
270 break; |
|
271 |
|
272 default: |
|
273 break; |
|
274 } |
|
275 } |
|
276 |
|
277 void CTestIacp::RunL() |
|
278 { |
|
279 TRAP(iError, DoRunL()); |
|
280 if (iError != KErrNone || iState == EFinished) |
|
281 { |
|
282 CActiveScheduler::Stop(); |
|
283 } |
|
284 } |
|
285 |
|
286 void CTestIacp::DoRunL() |
|
287 { |
|
288 TInt result=iStatus.Int(); |
|
289 |
|
290 switch (iState) |
|
291 { |
|
292 case EParse: |
|
293 if(result==KErrNone) |
|
294 { |
|
295 iBioTestUtils->WriteComment(_L("Parsed Ok")); |
|
296 StartL(EProcess); |
|
297 } |
|
298 else |
|
299 { |
|
300 LogParseError(result); |
|
301 iParser->Cancel(); |
|
302 iState=EFinished; |
|
303 } |
|
304 break; |
|
305 |
|
306 case EProcess: |
|
307 if(result==KErrNone) |
|
308 { |
|
309 iBioTestUtils->WriteComment(_L("Processed IACP Ok")); |
|
310 iParsedMsg = ETrue; |
|
311 //StartL(EInitSMTPMTM); |
|
312 StartL(EInitPOP3MTM); |
|
313 } |
|
314 else |
|
315 { |
|
316 LogParseError(result); |
|
317 iParser->Cancel(); |
|
318 iState=EFinished; |
|
319 } |
|
320 break; |
|
321 |
|
322 case EInitSMTPMTM: |
|
323 iSendUtils->WriteComment(_L("Initialised SMTP MTM Ok")); |
|
324 StartL(ESendSMTP); |
|
325 break; |
|
326 |
|
327 case ESendSMTP: |
|
328 CheckSendStatus(); |
|
329 if (iConnectedToSMTP) |
|
330 { |
|
331 StartL(EInitPOP3MTM); |
|
332 } |
|
333 else |
|
334 { |
|
335 iState=EFinished; |
|
336 } |
|
337 break; |
|
338 |
|
339 case EInitPOP3MTM: |
|
340 iSendUtils->WriteComment(_L("Initialised POP3 MTM Ok")); |
|
341 StartL(EConnectPOP3); |
|
342 break; |
|
343 |
|
344 case EConnectPOP3: |
|
345 if (CheckRecvStatus()) |
|
346 { |
|
347 iConnectedToPOP3 = ETrue; |
|
348 iSendUtils->WriteComment(_L("Connected POP3 server Ok")); |
|
349 // count number or entries in remote service |
|
350 User::LeaveIfError(iSendUtils->iServerEntry->SetEntry(iPop3service)); |
|
351 User::LeaveIfError(iSendUtils->iServerEntry->GetChildren(*iMsvSelection)); |
|
352 |
|
353 if (iMsvSelection->Count() > 0) |
|
354 { |
|
355 StartL(EReceivePOP3); |
|
356 } |
|
357 else |
|
358 { |
|
359 StartL(EDisconnectPOP3); |
|
360 } |
|
361 } |
|
362 else |
|
363 { |
|
364 iState=EFinished; |
|
365 } |
|
366 break; |
|
367 |
|
368 case EReceivePOP3: |
|
369 if (CheckRecvStatus()) |
|
370 { |
|
371 iSendUtils->WriteComment(_L("Retrieved from POP3 Ok")); |
|
372 iMsgsReceived = iMsvSelection->Count(); |
|
373 } |
|
374 StartL(EDisconnectPOP3); |
|
375 break; |
|
376 |
|
377 case EDisconnectPOP3: |
|
378 iSendUtils->WriteComment(_L("Disconnected POP3 server Ok")); |
|
379 iState = EFinished; |
|
380 break; |
|
381 |
|
382 default: |
|
383 break; |
|
384 } |
|
385 } |
|
386 |
|
387 void CTestIacp::ParseMsgL() |
|
388 { |
|
389 iBioTestUtils->WriteComment(_L("Creating IACP Parser object")); |
|
390 TRAPD(error, iParser->ParseL(iStatus,iSmsMsg->Des())); |
|
391 if (error == KErrNone) |
|
392 { |
|
393 iBioTestUtils->WriteComment(_L("Created IACP Parser object")); |
|
394 SetActive(); |
|
395 } |
|
396 else |
|
397 { |
|
398 LogParseError(error); |
|
399 User::Leave(error); |
|
400 } |
|
401 } |
|
402 |
|
403 void CTestIacp::ProcessMsgL() |
|
404 { |
|
405 iBioTestUtils->WriteComment(_L("Starting processing...")); |
|
406 |
|
407 DisplayEntryDataL(); |
|
408 |
|
409 TRAPD(error, iParser->ProcessL(iStatus)); //internalise and process |
|
410 if (error == KErrNone) |
|
411 { |
|
412 iBioTestUtils->WriteComment(_L("Process started ok")); |
|
413 SetActive(); |
|
414 } |
|
415 else |
|
416 { |
|
417 LogParseError(error); |
|
418 User::Leave(error); |
|
419 } |
|
420 } |
|
421 |
|
422 void CTestIacp::deleteParser() |
|
423 { |
|
424 delete iParser; |
|
425 iParser = 0; |
|
426 delete iBioTestUtils; |
|
427 iBioTestUtils = 0; |
|
428 } |
|
429 |
|
430 // setup the objects for connecting to the POP3 server |
|
431 void CTestIacp::InitPOP3MTML() |
|
432 { |
|
433 // close down iBioTestUtils instance since it shares a single message server |
|
434 // which causes iSendUtils creation to fail |
|
435 |
|
436 // first delete the parser to allow iBioTestUtils to be deleted |
|
437 // without panicking |
|
438 deleteParser(); |
|
439 |
|
440 delete iSendUtils; |
|
441 iSendUtils = 0; |
|
442 |
|
443 // now setup the send utils |
|
444 iSendUtils = CEmailTestUtils::NewL(test); |
|
445 iSendUtils->WriteComment(_L("Initialised POP3 Send Utils")); |
|
446 |
|
447 iSendUtils->GoServerSideL(); |
|
448 iSendUtils->CreatePopServerMtmRegL(); |
|
449 |
|
450 // Load the DLLs |
|
451 iSendUtils->CreateRegistryObjectAndControlL(); |
|
452 iSendUtils->InstallPopMtmGroupL(); |
|
453 |
|
454 iSendUtils->FindExistingServicesL(); |
|
455 iSendUtils->InstantiatePopServerMtmL(); |
|
456 |
|
457 // processing of message should have added these entries |
|
458 TRAPD(error, (iPop3service = iSendUtils->FindPopServiceL())); |
|
459 if (error != KErrNone) |
|
460 { |
|
461 iSendUtils->WriteComment(_L("Could not locate POP3 service entry")); |
|
462 User::Leave(error); |
|
463 } |
|
464 |
|
465 GetDefaultConnectionL(); |
|
466 |
|
467 SetIAPL(iPop3service); |
|
468 } |
|
469 |
|
470 // setup the objects for connecting to the SMTP server |
|
471 void CTestIacp::InitSMTPMTML() |
|
472 { |
|
473 deleteParser(); |
|
474 |
|
475 // now setup the send utils |
|
476 iSendUtils = CEmailTestUtils::NewL(test); |
|
477 iSendUtils->WriteComment(_L("Initialised SMTP Send Utils")); |
|
478 |
|
479 iSendUtils->GoServerSideL(); |
|
480 iSendUtils->CreateSmtpServerMtmRegL(); |
|
481 |
|
482 // Load the DLLs |
|
483 iSendUtils->CreateRegistryObjectAndControlL(); |
|
484 iSendUtils->InstallSmtpMtmGroupL(); |
|
485 |
|
486 iSendUtils->FindExistingServicesL(); |
|
487 iSendUtils->InstantiateSmtpServerMtmL(); |
|
488 |
|
489 // processing of message should have added these entries |
|
490 TRAPD(error, (iSmtpservice = iSendUtils->FindSmtpServiceL())); |
|
491 if (error != KErrNone) |
|
492 { |
|
493 iSendUtils->WriteComment(_L("Could not locate SMTP service entry")); |
|
494 User::Leave(error); |
|
495 } |
|
496 |
|
497 GetDefaultConnectionL(); |
|
498 |
|
499 SetIAPL(iSmtpservice); |
|
500 } |
|
501 |
|
502 void CTestIacp::ConnectPOP3L() |
|
503 { |
|
504 iMsvSelection->ResizeL(0); |
|
505 iMsvSelection->AppendL(iPop3service); |
|
506 |
|
507 iSendUtils->WriteComment(_L("Connecting to POP3 server...")); |
|
508 |
|
509 test.Printf(_L("Connecting to POP3 server...\n")); |
|
510 |
|
511 TBuf8<1> aParameter; |
|
512 |
|
513 iSendUtils->iPopServerMtm->StartCommandL(*iMsvSelection, KPOP3MTMConnect, aParameter, iStatus); |
|
514 |
|
515 SetActive(); |
|
516 } |
|
517 |
|
518 void CTestIacp::ReceivePOP3L() |
|
519 { |
|
520 TBuf<60> outputBuf; |
|
521 |
|
522 outputBuf.Format(_L("%d messages in the inbox"), iMsvSelection->Count()); |
|
523 iSendUtils->WriteComment(outputBuf); |
|
524 |
|
525 outputBuf.Format(_L("%d messages in the inbox\n"), iMsvSelection->Count()); |
|
526 test.Printf(outputBuf); |
|
527 |
|
528 iSendUtils->WriteComment(_L("Retrieving messages...")); |
|
529 |
|
530 test.Printf(_L("Retrieving messages...\n")); |
|
531 |
|
532 iSendUtils->iPopServerMtm->CopyToLocalL(*iMsvSelection, KMsvGlobalInBoxIndexEntryId, iStatus); |
|
533 |
|
534 SetActive(); |
|
535 } |
|
536 |
|
537 void CTestIacp::DisconnectPOP3L() |
|
538 { |
|
539 iSendUtils->WriteComment(_L("Disconnecting from POP3 server")); |
|
540 |
|
541 test.Printf(_L("Disconnecting from POP3 server...\n")); |
|
542 |
|
543 TBuf8<1> aParameter; |
|
544 |
|
545 iSendUtils->iPopServerMtm->StartCommandL(*iMsvSelection, KPOP3MTMDisconnect, aParameter, iStatus); |
|
546 |
|
547 SetActive(); |
|
548 } |
|
549 |
|
550 void CTestIacp::SendSMTPL() |
|
551 { |
|
552 test.Printf(_L("Creating SMTP messages...\n")); |
|
553 |
|
554 iSendUtils->CreateMessageFilesL(iSmtpservice,KMsvGlobalOutBoxIndexEntryId,IACP_TEST_MSG_PATH); |
|
555 |
|
556 // see how many we have created |
|
557 iSendUtils->iServerEntry->SetEntry(KMsvGlobalOutBoxIndexEntryId); |
|
558 User::LeaveIfError(iSendUtils->iServerEntry->GetChildren(*iMsvSelection)); |
|
559 |
|
560 TInt count=iMsvSelection->Count(); |
|
561 if (count > 0) |
|
562 { |
|
563 TBuf<60> outputBuf; |
|
564 |
|
565 outputBuf.Format(_L("%d messages in the outbox"), count); |
|
566 iSendUtils->WriteComment(outputBuf); |
|
567 |
|
568 outputBuf.Format(_L("\n%d messages in the outbox\n"), count); |
|
569 test.Printf(outputBuf); |
|
570 |
|
571 test.Printf(_L("Sending SMTP messages...\n")); |
|
572 |
|
573 // begin the send |
|
574 iSendUtils->iSmtpServerMtm->CopyFromLocalL(*iMsvSelection,iSmtpservice, iStatus); |
|
575 SetActive(); |
|
576 } |
|
577 else |
|
578 { |
|
579 iSendUtils->WriteComment(_L("No messages to send in the outbox")); |
|
580 iState=EFinished; |
|
581 } |
|
582 } |
|
583 |
|
584 // |
|
585 |
|
586 void CTestIacp::GetDefaultConnectionL() |
|
587 { |
|
588 // determine what default record has been set as the preferred |
|
589 // connection by the IACP parser when processing the message |
|
590 CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeUnspecified); |
|
591 CleanupStack::PushL(db); |
|
592 TBuf<60> outputBuf; |
|
593 |
|
594 //db->GetGlobalSettingL(TPtrC(IAP),iIap); |
|
595 |
|
596 //GetGlobalSettingL() above is now replaced by the connection preferences table below |
|
597 CCommsDbConnectionPrefTableView* view; |
|
598 view = db->OpenConnectionPrefTableViewOnRankLC(ECommDbConnectionDirectionOutgoing, 1/*rank 1 is like a default value*/ ); |
|
599 |
|
600 view->GotoFirstRecord(); //table with rank 1 only has one record |
|
601 CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref connPref; |
|
602 view->ReadConnectionPreferenceL(connPref); |
|
603 iIap = connPref.iBearer.iIapId; |
|
604 //END of retrieve setting from connection Pref Table |
|
605 |
|
606 CleanupStack::PopAndDestroy(2, db); |
|
607 |
|
608 outputBuf.Format(_L("Using IAP record %d for connection"), iIap); |
|
609 iSendUtils->WriteComment(outputBuf); |
|
610 } |
|
611 |
|
612 void CTestIacp::SetIAPL(TMsvId aService) |
|
613 { |
|
614 // set the service with the preferred IAP comms record |
|
615 iSendUtils->iServerEntry->SetEntry(aService); |
|
616 TMsvEntry entry = iSendUtils->iServerEntry->Entry(); |
|
617 entry.SetMtmData1(iIap); |
|
618 User::LeaveIfError(iSendUtils->iServerEntry->ChangeEntry(entry)); |
|
619 } |
|
620 |
|
621 void CTestIacp::DoCancel() |
|
622 { |
|
623 test.Printf(_L("DoCancel()")); |
|
624 } |
|
625 |
|
626 void CTestIacp::RequestComplete(TRequestStatus& aStatus,TInt aCompletion) |
|
627 { |
|
628 TRequestStatus* statusPtr=&aStatus; |
|
629 User::RequestComplete(statusPtr,aCompletion); |
|
630 } |
|
631 |
|
632 |
|
633 void CTestIacp::DisplayEntryDataL() |
|
634 { |
|
635 iBioTestUtils->SetEntryL(iEntryId); |
|
636 |
|
637 /* |
|
638 iBioTestUtils->ClearScreen(); |
|
639 //test.Console()->SetPos(0,0); |
|
640 |
|
641 TMsvEntry entry = iBioTestUtils->Entry(); |
|
642 iBioTestUtils->Printf(_L("===== MESSAGE DETAILS =====\n")); |
|
643 iBioTestUtils->Printf(_L("Id: 0x%x\n"), iEntryId); |
|
644 iBioTestUtils->Printf(_L("iServiceId: 0x%x\n"), entry.iServiceId); |
|
645 iBioTestUtils->Printf(_L("iRelatedId: 0x%x\n"), entry.iRelatedId); |
|
646 iBioTestUtils->Printf(_L("iType: 0x%x\n"), entry.iType); |
|
647 iBioTestUtils->Printf(_L("iMtm: 0x%x\n"), entry.iMtm); |
|
648 TBuf<128> dateStr; |
|
649 entry.iDate.FormatL(dateStr, (_L("%D%M%Y%/0%1%/1%2%/2%3%/3"))); |
|
650 iBioTestUtils->Printf(_L("iDate: %S\n"), &dateStr); |
|
651 |
|
652 iBioTestUtils->Printf(_L("iSize: %d\n"), entry.iSize); |
|
653 iBioTestUtils->Printf(_L("iError: %d\n"), entry.iError); |
|
654 iBioTestUtils->Printf(_L("iBioType: 0x%x\n"), entry.iBioType); |
|
655 iBioTestUtils->Printf(_L("iMtmData1: %d\n"), entry.iMtmData1); |
|
656 iBioTestUtils->Printf(_L("iMtmData2: %d\n"), entry.iMtmData2); |
|
657 iBioTestUtils->Printf(_L("iMtmData3: %d\n"), entry.iMtmData3); |
|
658 iBioTestUtils->Printf(_L("iDescription: %S\n"), &entry.iDescription); |
|
659 iBioTestUtils->Printf(_L("iDetails: %S\n "), &entry.iDetails); |
|
660 |
|
661 PROMPTUSER |
|
662 */ |
|
663 |
|
664 iBioTestUtils->ClearScreen(); |
|
665 //test.Console()->SetPos(0,0); |
|
666 |
|
667 if(iBioTestUtils->Entry().MtmData3() != BIO_MSG_ENTRY_PARSED) |
|
668 { |
|
669 iBioTestUtils->WriteComment(_L("BioMg has not been parsed")); |
|
670 User::Leave(KErrGeneral); |
|
671 } |
|
672 iBioTestUtils->LogExtractedFieldsL(iEntryId); |
|
673 } |
|
674 |
|
675 TBool CTestIacp::DisplaySummary() |
|
676 { |
|
677 TBuf<128> result; |
|
678 |
|
679 test.Printf(_L("\nFinal summary\n")); |
|
680 if (iBioTestUtils != 0) |
|
681 iBioTestUtils->WriteComment(_L("Final summary")); |
|
682 else |
|
683 iSendUtils->WriteComment(_L("Final summary")); |
|
684 result = iParsedMsg ? _L("TRUE") : _L("FALSE"); |
|
685 |
|
686 TBuf<120> logMsg; |
|
687 |
|
688 logMsg.Format(_L("Parsed IACP message : %S\n"), &result); |
|
689 test.Printf(logMsg); |
|
690 |
|
691 if (iBioTestUtils != 0) |
|
692 iBioTestUtils->WriteComment(logMsg); |
|
693 else |
|
694 iSendUtils->WriteComment(logMsg); |
|
695 |
|
696 result = iConnectedToSMTP ? _L("TRUE") : _L("FALSE"); |
|
697 logMsg.Format(_L("Connected to SMTP server : %S\n"), &result); |
|
698 test.Printf(logMsg); |
|
699 if (iBioTestUtils != 0) |
|
700 iBioTestUtils->WriteComment(logMsg); |
|
701 else |
|
702 iSendUtils->WriteComment(logMsg); |
|
703 |
|
704 if (iConnectedToSMTP) |
|
705 { |
|
706 logMsg.Format(_L(" Sent %d messages\n"), iMsgsSent); |
|
707 test.Printf(logMsg); |
|
708 if (iBioTestUtils != 0) |
|
709 iBioTestUtils->WriteComment(logMsg); |
|
710 else |
|
711 iSendUtils->WriteComment(logMsg); |
|
712 } |
|
713 |
|
714 result = iConnectedToPOP3 ? _L("TRUE") : _L("FALSE"); |
|
715 logMsg.Format(_L("Connected to POP3 server : %S\n"), &result); |
|
716 test.Printf(logMsg); |
|
717 if (iBioTestUtils != 0) |
|
718 iBioTestUtils->WriteComment(logMsg); |
|
719 else |
|
720 iSendUtils->WriteComment(logMsg); |
|
721 |
|
722 if (iConnectedToPOP3) |
|
723 { |
|
724 logMsg.Format(_L(" Received %d messages\n"), iMsgsReceived); |
|
725 test.Printf(logMsg); |
|
726 if (iBioTestUtils != 0) |
|
727 iBioTestUtils->WriteComment(logMsg); |
|
728 else |
|
729 iSendUtils->WriteComment(logMsg); |
|
730 } |
|
731 |
|
732 return iParsedMsg && iConnectedToSMTP && iConnectedToPOP3; |
|
733 } |
|
734 |
|
735 void CTestIacp::CheckSendStatus() |
|
736 { |
|
737 TImSmtpProgress temp; |
|
738 TPckgC<TImSmtpProgress> paramPack(temp); |
|
739 |
|
740 const TDesC8& progBuf = iSendUtils->iSmtpServerMtm->Progress(); |
|
741 paramPack.Set(progBuf); |
|
742 TImSmtpProgress progress=paramPack(); |
|
743 |
|
744 TBuf<128> logString; |
|
745 // State of Smtp session? |
|
746 TInt state = progress.Status(); |
|
747 switch(state) |
|
748 { |
|
749 case EMsgOutboxProgressWaiting: |
|
750 iSendUtils->WriteComment(_L("Waiting to start")); |
|
751 break; |
|
752 |
|
753 case EMsgOutboxProgressDone: |
|
754 if (progress.Error() == 0) |
|
755 iSendUtils->WriteComment(_L("Connection closed OK")); |
|
756 else |
|
757 LogCommsError(progress.Error()); |
|
758 |
|
759 logString.Format(_L("%d messages: Sent %d, failed to send %d, didn't attempt to send %d.\n"), |
|
760 progress.SendTotal(), |
|
761 progress.Sent(), |
|
762 progress.FailedToSend(), |
|
763 progress.NotSent()); |
|
764 iSendUtils->WriteComment(logString); |
|
765 if (progress.Sent() > 0) |
|
766 { |
|
767 iConnectedToSMTP=ETrue; |
|
768 iMsgsSent=progress.Sent(); |
|
769 } |
|
770 break; |
|
771 |
|
772 case EMsgOutboxProgressConnecting: |
|
773 logString.Format(_L("Connecting to SMTP server. Sending %d messages"), |
|
774 progress.SendTotal()); |
|
775 iSendUtils->WriteComment(logString); |
|
776 break; |
|
777 |
|
778 case EMsgOutboxProgressSending: |
|
779 logString.Format(_L("Sending message No.%d/%d. Transmitted %d bytes of %d"), |
|
780 progress.MsgNo()+1, |
|
781 progress.SendTotal(), |
|
782 progress.iSendFileProgress.iBytesSent, |
|
783 progress.iSendFileProgress.iBytesToSend); |
|
784 iSendUtils->WriteComment(logString); |
|
785 break; |
|
786 } |
|
787 } |
|
788 |
|
789 TBool CTestIacp::CheckRecvStatus() |
|
790 { |
|
791 TBool status = EFalse; |
|
792 |
|
793 // Get the progress |
|
794 TPop3Progress prog; |
|
795 TPckgC<TPop3Progress> paramPack(prog); |
|
796 paramPack.Set(iSendUtils->iPopServerMtm->Progress()); |
|
797 TPop3Progress progress=paramPack(); |
|
798 |
|
799 // Check that the reported progress is EPopConnecting |
|
800 if (progress.iPop3Progress == TPop3Progress::EPopConnecting |
|
801 || progress.iPop3Progress == TPop3Progress::EPopRefreshing) |
|
802 { |
|
803 if (progress.iErrorCode == 0) |
|
804 { |
|
805 status = ETrue; |
|
806 } |
|
807 else |
|
808 { |
|
809 LogCommsError(progress.iErrorCode); |
|
810 } |
|
811 } |
|
812 |
|
813 return status; |
|
814 } |
|
815 |
|
816 void CTestIacp::LogCommsError(TInt aError) |
|
817 { |
|
818 TBuf<100> errorMsg; |
|
819 |
|
820 switch (aError) |
|
821 { |
|
822 case KErrEtelNotCallOwner: |
|
823 errorMsg=_L("Comms error: Not call owner"); |
|
824 break; |
|
825 case KErrEtelDuplicatePhoneName: |
|
826 errorMsg=_L("Duplicate phone name"); |
|
827 break; |
|
828 |
|
829 case KErrEtelAlreadyCallOwner: |
|
830 errorMsg=_L("Already call owner"); |
|
831 break; |
|
832 |
|
833 case KErrEtelNoCarrier: |
|
834 errorMsg=_L("No carrier"); |
|
835 break; |
|
836 |
|
837 case KErrEtelBusyDetected: |
|
838 errorMsg=_L("Busy detected"); |
|
839 break; |
|
840 |
|
841 case KErrEtelNoClientInterestedInThisCall: |
|
842 errorMsg=_L("No client interested in call"); |
|
843 break; |
|
844 |
|
845 case KErrEtelInitialisationFailure: |
|
846 errorMsg=_L("Initialisation failure"); |
|
847 break; |
|
848 |
|
849 case KErrEtelCallNotActive: |
|
850 errorMsg=_L("Call not active"); |
|
851 break; |
|
852 |
|
853 case KErrEtelNoAnswer: |
|
854 errorMsg=_L("No answer"); |
|
855 break; |
|
856 |
|
857 case KErrEtelNoDialTone: |
|
858 errorMsg=_L("No dial tone"); |
|
859 break; |
|
860 |
|
861 case KErrEtelConfigPortFailure: |
|
862 errorMsg=_L("Config port failure"); |
|
863 break; |
|
864 |
|
865 case KErrEtelFaxChunkNotCreated: |
|
866 errorMsg=_L("Fax chunk not created"); |
|
867 break; |
|
868 |
|
869 case KErrEtelNotFaxOwner: |
|
870 errorMsg=_L("Not fax owner"); |
|
871 break; |
|
872 |
|
873 case KErrEtelPortNotLoanedToClient: |
|
874 errorMsg=_L("Port not loaned to client"); |
|
875 break; |
|
876 |
|
877 case KErrEtelWrongModemType: |
|
878 errorMsg=_L("Wrong modem type"); |
|
879 break; |
|
880 |
|
881 case KErrEtelUnknownModemCapability: |
|
882 errorMsg=_L("Unknown modem capability"); |
|
883 break; |
|
884 |
|
885 case KErrEtelAnswerAlreadyOutstanding: |
|
886 errorMsg=_L("Answer already outstanding"); |
|
887 break; |
|
888 case KErrEtelModemNotDetected: |
|
889 errorMsg=_L("Modem not detected"); |
|
890 break; |
|
891 |
|
892 case KErrEtelModemSettingsCorrupt: |
|
893 errorMsg=_L("Modem settings corrupt"); |
|
894 break; |
|
895 |
|
896 case KPop3InvalidUser: |
|
897 errorMsg=_L("Invalid POP3 user"); |
|
898 break; |
|
899 |
|
900 case KPop3InvalidLogin: |
|
901 errorMsg=_L("Invalid POP3 login"); |
|
902 break; |
|
903 |
|
904 case KPop3CannotConnect: |
|
905 errorMsg=_L("Cannot connect to POP3 server"); |
|
906 break; |
|
907 |
|
908 case KPop3CannotCreateApopLogonString: |
|
909 errorMsg=_L("Cannot create Apop logon string"); |
|
910 break; |
|
911 |
|
912 case KPop3ProblemWithRemotePopServer: |
|
913 errorMsg=_L("Problem with remote POP server"); |
|
914 break; |
|
915 |
|
916 case KPop3CannotOpenServiceEntry: |
|
917 errorMsg=_L("Cannot open POP3 service entry"); |
|
918 break; |
|
919 |
|
920 case KPop3CannotSetRequiredFolderContext: |
|
921 errorMsg=_L("Cannot set required folder context"); |
|
922 break; |
|
923 |
|
924 case KPop3InvalidApopLogin: |
|
925 errorMsg=_L("Invalid Apop login"); |
|
926 break; |
|
927 |
|
928 case KPopTopError: |
|
929 errorMsg=_L("POP TOP Error"); |
|
930 break; |
|
931 |
|
932 default: |
|
933 errorMsg.Format(_L("Unknown error %d"), aError); |
|
934 break; |
|
935 } |
|
936 |
|
937 TBuf<120> logMsg; |
|
938 |
|
939 logMsg.Format(_L("Connection closed with comms error (%S)"), &errorMsg); |
|
940 iSendUtils->WriteComment(logMsg); |
|
941 |
|
942 logMsg.Format(_L("Connection closed with comms error (%S)\n"), &errorMsg); |
|
943 test.Printf(logMsg); |
|
944 } |
|
945 |
|
946 void CTestIacp::LogParseError(TInt& aReason) |
|
947 { |
|
948 TBuf<256> tempBuf; |
|
949 switch (aReason) |
|
950 { |
|
951 case KErrCancel: |
|
952 tempBuf= _L("Session cancelled"); |
|
953 break; |
|
954 case KErrEof: |
|
955 tempBuf= _L("KErrEof"); |
|
956 break; |
|
957 case KErrNoMemory: |
|
958 tempBuf= _L("KErrNoMemory"); |
|
959 break; |
|
960 case KErrDisconnected: |
|
961 tempBuf= _L("KErrDisconnected"); |
|
962 break; |
|
963 case KErrAccessDenied: |
|
964 tempBuf= _L("KErrAccessDenied"); |
|
965 break; |
|
966 case KBspInvalidMessage: |
|
967 tempBuf= _L("Error: Invalid SMS Message. For Internet Access Configuration,SMS Header Field should be //SIAP11 "); |
|
968 break; |
|
969 case KIacpUnknownSmsType: |
|
970 tempBuf=_L("Error:SMS 1st Left Token does not start with niether M nor I"); |
|
971 break; |
|
972 case KIacpBIOMsgTypeNotSupported: |
|
973 tempBuf= _L("this Bio msg is not suppported"); |
|
974 break; |
|
975 case KIacpMandatoryDataNotSet: |
|
976 tempBuf= _L("Error: Mandatory data missing in SMS message"); |
|
977 break; |
|
978 case KIacpUnknownMailProtocol: |
|
979 tempBuf= _L("Error: Unknown Mail Protocol Not a Pop3/Imap4"); |
|
980 break; |
|
981 case KIacpErrRightToken: |
|
982 tempBuf= _L("Error: improper right token i.e not equal t/f (True/False)"); |
|
983 break; |
|
984 case KIacpErrLeftToken: |
|
985 tempBuf=_L("Error:SMS Left Tokens should start with 'M' for Mailbox account configuration\r\n and with 'I' for Internet service configuration"); |
|
986 break; |
|
987 case KIacpErrSmsDataNotParsed: |
|
988 tempBuf= _L("sms data should be parsed before processing"); |
|
989 break; |
|
990 case KIacpErrSmsDataNotRestored: |
|
991 tempBuf= _L("Error: sms data should be parsed before commiting (KIacpErrSmsDataNotRestored)"); |
|
992 break; |
|
993 case KIacpScriptErrISPNotFound: |
|
994 tempBuf= _L("Internet Service not found in Dial Out DB"); |
|
995 break; |
|
996 case KIacpErrScriptNotDefined: |
|
997 tempBuf= _L("Script not included in sms"); |
|
998 break; |
|
999 case KIacpErrScriptNotFoundInDB: |
|
1000 tempBuf= _L("There is no script in DB to append to"); |
|
1001 break; |
|
1002 case KIacpErrScriptAlreadyAdd: |
|
1003 tempBuf= _L("Script cannot be add more than ounce for each Bio Msg"); |
|
1004 break; |
|
1005 default: |
|
1006 tempBuf.Format(_L("Unknown error %d"), aReason); |
|
1007 break; |
|
1008 } |
|
1009 |
|
1010 TBuf<300> logMsg; |
|
1011 |
|
1012 logMsg.Format(_L("Parse error (%S)"), &tempBuf); |
|
1013 iBioTestUtils->WriteComment(logMsg); |
|
1014 |
|
1015 logMsg.Format(_L("Parse error (%S)\n"), &tempBuf); |
|
1016 test.Printf(logMsg); |
|
1017 } |
|
1018 |
|
1019 LOCAL_C void doMainL() |
|
1020 { |
|
1021 // create a scheduler |
|
1022 exampleScheduler = new (ELeave) CExampleScheduler; |
|
1023 CleanupStack::PushL(exampleScheduler); |
|
1024 CActiveScheduler::Install(exampleScheduler); |
|
1025 |
|
1026 // initialise the bio test utils |
|
1027 CBioTestUtils* BioTestUtils = CBioTestUtils::NewL(test,ETuCleanMessageFolder|ETuGoClientSide); |
|
1028 BioTestUtils->GoClientSideL(); |
|
1029 BioTestUtils->WriteComment(_L("Msv Client Side Created")); |
|
1030 |
|
1031 // create a IACP parser |
|
1032 CTestIacp* testParser = CTestIacp::NewL(BioTestUtils); |
|
1033 CleanupStack::PushL(testParser); |
|
1034 test(testParser != NULL); |
|
1035 |
|
1036 BioTestUtils->WriteComment(_L("CTestIacp Object Created.")); |
|
1037 |
|
1038 // begin the tests |
|
1039 BioTestUtils->TestStart(1); |
|
1040 testParser->StartL(EParse); |
|
1041 |
|
1042 CActiveScheduler::Start(); |
|
1043 |
|
1044 if (testParser->DisplaySummary()) |
|
1045 { |
|
1046 BioTestUtils->TestHarnessCompleted(); |
|
1047 } |
|
1048 else |
|
1049 { |
|
1050 BioTestUtils->TestHarnessFailed(testParser->Error()); |
|
1051 } |
|
1052 |
|
1053 CleanupStack::PopAndDestroy(2); // testParser, exampleScheduler |
|
1054 |
|
1055 PROMPTUSER |
|
1056 } |
|
1057 |
|
1058 GLDEF_C TInt E32Main() |
|
1059 { |
|
1060 test.Title(); |
|
1061 test.Start(_L("IACPCOMM Test Harness")); |
|
1062 __UHEAP_MARK; |
|
1063 |
|
1064 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
1065 test(cleanup!=NULL); |
|
1066 |
|
1067 TRAPD(error,doMainL()); |
|
1068 if (error) test.Printf(_L("Completed with return code %d"),error); |
|
1069 delete cleanup; |
|
1070 |
|
1071 __UHEAP_MARKEND; |
|
1072 test.Close(); |
|
1073 test.End(); |
|
1074 |
|
1075 return KErrNone; |
|
1076 } |
|
1077 |