|
1 // Copyright (c) 1998-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 // Test harness for Internet Access Configuration Parser |
|
15 // |
|
16 // |
|
17 |
|
18 // |
|
19 #include "biotestutils.h" |
|
20 #include <smtpset.h> |
|
21 #include <pop3set.h> |
|
22 #include <iapprefs.h> |
|
23 #include <imapset.h> |
|
24 #include <smutset.h> |
|
25 // |
|
26 #include "IACPERR.H" |
|
27 #include "IACPDEF.H" |
|
28 |
|
29 #include <cemailaccounts.h> |
|
30 #include <csmsaccount.h> |
|
31 #include "tmsvbioinfo.h" |
|
32 |
|
33 #define BIO_MSG_ENTRY_PARSED 1 // Set entry .iMtmData3 to 1 to indicate that the entry has store i.e parsed,externalised |
|
34 #define BIO_MSG_ENTRY_PROCESSED 2 // Set TMsvEntry iMtmData3 to 2 to indicate that a message has been processed |
|
35 |
|
36 //SMS configuration file paths |
|
37 _LIT(SMS_MAIL_FILE, "c:\\test\\bio\\iacp\\sms_mail.txt"); |
|
38 |
|
39 //forward reference |
|
40 class CExampleScheduler; |
|
41 |
|
42 //global declarations |
|
43 LOCAL_D CExampleScheduler *exampleScheduler; |
|
44 LOCAL_D RTest test(_L("IACP Test Harness")); |
|
45 |
|
46 |
|
47 // |
|
48 //-- CExampleScheduler -- |
|
49 // |
|
50 class CExampleScheduler : public CActiveScheduler |
|
51 { |
|
52 public: |
|
53 void Error (TInt aError) const; |
|
54 }; |
|
55 |
|
56 |
|
57 void CExampleScheduler::Error(TInt anError) const |
|
58 { |
|
59 CActiveScheduler::Stop(); |
|
60 test.Printf(_L("\nLeave signalled, reason=%d\n"),anError); |
|
61 } |
|
62 |
|
63 |
|
64 LOCAL_C void DisplayErrorReason(TInt& aReason, CBioTestUtils& aBioTestUtils) |
|
65 { |
|
66 if(aReason==KErrNone) |
|
67 { |
|
68 aBioTestUtils.TestHarnessCompleted(); |
|
69 return; |
|
70 } |
|
71 |
|
72 TBuf<256> tempBuf; |
|
73 switch (aReason) |
|
74 { |
|
75 case KErrCancel: |
|
76 tempBuf= _L("\r\n-->Session cancelled"); |
|
77 break; |
|
78 case KErrEof: |
|
79 tempBuf= _L("\r\n-->KErrEof"); |
|
80 break; |
|
81 case KErrNoMemory: |
|
82 tempBuf= _L("\r\n-->KErrNoMemory"); |
|
83 break; |
|
84 case KErrDisconnected: |
|
85 tempBuf= _L("\r\n-->KErrDisconnected"); |
|
86 break; |
|
87 case KErrAccessDenied: |
|
88 tempBuf= _L("\r\n-->KErrAccessDenied"); |
|
89 break; |
|
90 case KBspInvalidMessage: |
|
91 tempBuf= _L("\r\n-->Error: Invalid SMS Message. For Internet Access Configuration,\r\nSMS Header Field should be //SIAP11 "); |
|
92 break; |
|
93 case KIacpUnknownSmsType: |
|
94 tempBuf=_L("\r\n-->Error:SMS 1st Left Token does not start with niether M nor I "); |
|
95 break; |
|
96 case KIacpBIOMsgTypeNotSupported: |
|
97 tempBuf= _L("\r\n-->this Bio msg is not suppported"); |
|
98 break; |
|
99 case KIacpMandatoryDataNotSet: |
|
100 tempBuf= _L("\r\n-->Error: Mandatory data missing in SMS message."); |
|
101 break; |
|
102 case KIacpUnknownMailProtocol: |
|
103 tempBuf= _L("\r\n-->Error: Unknown Mail Protocol Not a Pop3/Imap4"); |
|
104 break; |
|
105 case KIacpErrRightToken: |
|
106 tempBuf= _L("\r\n-->Error: improper right token i.e not equal t/f (True/False)"); |
|
107 break; |
|
108 case KIacpErrLeftToken: |
|
109 tempBuf=_L("\r\n-->Error:SMS Left Tokens should start with 'M' for Mailbox account configuration\r\n and with 'I' for Internet service configuration"); |
|
110 break; |
|
111 case KIacpErrSmsDataNotParsed: |
|
112 tempBuf= _L("\r\n-->sms data should be parsed before processing"); |
|
113 break; |
|
114 case KIacpErrSmsDataNotRestored: |
|
115 tempBuf= _L("\r\n-->Error: sms data should be parsed before commiting (KIacpErrSmsDataNotRestored)"); |
|
116 break; |
|
117 case KIacpScriptErrISPNotFound: |
|
118 tempBuf= _L("\r\n-->Internet Service not found in Dial Out DB"); |
|
119 break; |
|
120 case KIacpErrScriptNotDefined: |
|
121 tempBuf= _L("\r\n-->Sript not included in sms"); |
|
122 break; |
|
123 case KIacpErrScriptNotFoundInDB: |
|
124 tempBuf= _L("\r\n-->There is no script in DB to append to."); |
|
125 break; |
|
126 case KIacpErrScriptAlreadyAdd: |
|
127 tempBuf= _L("\r\n-->Script cannot be add more than ounce for each Bio Msg"); |
|
128 break; |
|
129 default: |
|
130 tempBuf.Format(_L("\r\n-->Error !!!= %dview"), aReason ); |
|
131 break; |
|
132 } |
|
133 |
|
134 aBioTestUtils.Printf(tempBuf); |
|
135 aBioTestUtils.TestHarnessFailed(aReason); |
|
136 } |
|
137 |
|
138 //-------------------------------------- |
|
139 // |
|
140 //-- CTestIacp -- |
|
141 // |
|
142 |
|
143 enum TSessionState |
|
144 { |
|
145 EParse, // parsing is done at ParseL() stage. and data are externalised. |
|
146 EProcess, //parsed data are internalised, then commited |
|
147 EDisplay, //Display entry data |
|
148 EDisplayMailService, //Display mail service entry created |
|
149 }; |
|
150 |
|
151 class CTestIacp : public CActive |
|
152 { |
|
153 public: |
|
154 ~CTestIacp(); |
|
155 static CTestIacp * NewL(CBioTestUtils* aBioTestUtils); |
|
156 void StartL(TInt aCmd); |
|
157 public: |
|
158 CTestIacp(CBioTestUtils* aBioTestUtils); |
|
159 void ConstructL(); |
|
160 void GetMessageBodyL(); |
|
161 void DisplayEntryDataL(); |
|
162 void DisplayMailServiceL(); |
|
163 void ReadSmtpServiceL(); |
|
164 void ReadPop3ServiceL(); |
|
165 void ReadImap4ServiceL(); |
|
166 void ReadSmsServiceL(); |
|
167 void PrintSmtpSettings(CImSmtpSettings* aSmtpSettings); |
|
168 void PrintPop3Settings(CImPop3Settings* aSmtpSettings); |
|
169 void PrintImap4Settings(CImImap4Settings* aImap4Settings); |
|
170 void PrintSmsSettings(CSmsSettings* aSmsSettings); |
|
171 |
|
172 void RequestComplete(TRequestStatus& aStatus,TInt aCompletion); |
|
173 void DoCancel(); |
|
174 void RunL(); |
|
175 |
|
176 private: |
|
177 TInt iState; |
|
178 CBaseScriptParser2* iParser; |
|
179 CBioTestUtils* iBioTestUtils; |
|
180 TBuf<64> iIspName; |
|
181 TMsvId iEntryId; //ID of sms entry |
|
182 HBufC* iSmsMsg; //sms body build dependent |
|
183 TInt iParseFailCount;//heap testing (Parsing state) |
|
184 TInt iProcessFailCount;//heap testing (processing state) |
|
185 CEmailAccounts* iEmailAccounts; |
|
186 CSmsAccount* iSmsAccount; |
|
187 }; |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 CTestIacp::CTestIacp(CBioTestUtils* aBioTestUtils) |
|
193 :CActive(EPriorityStandard),iBioTestUtils(aBioTestUtils) |
|
194 { |
|
195 } |
|
196 |
|
197 CTestIacp* CTestIacp::NewL(CBioTestUtils* aBioTestUtils) |
|
198 { |
|
199 CTestIacp* self = new(ELeave) CTestIacp(aBioTestUtils); |
|
200 CleanupStack::PushL(self); |
|
201 self->ConstructL(); |
|
202 CleanupStack::Pop(); //self |
|
203 return self; |
|
204 } |
|
205 |
|
206 void CTestIacp::ConstructL() |
|
207 { |
|
208 iBioTestUtils->WriteComment(_L("CTestIacp::ConstructL().")); |
|
209 |
|
210 iEmailAccounts = CEmailAccounts::NewL(); |
|
211 iSmsAccount = CSmsAccount::NewL(); |
|
212 |
|
213 TInt error = KErrNone; |
|
214 TBool finished = EFalse; |
|
215 #ifdef _DEBUG |
|
216 TInt failCount = 0; |
|
217 #endif |
|
218 while(!finished) |
|
219 { |
|
220 __UHEAP_FAILNEXT(failCount++); |
|
221 TRAPD(error,(iParser = iBioTestUtils->CreateParserTypeL(KUidBIOInternetAccessPointMsg))); |
|
222 if (error == KErrNone) |
|
223 { |
|
224 __UHEAP_RESET; |
|
225 iBioTestUtils->WriteComment(_L("Created IACP Parser object")); |
|
226 finished = ETrue; |
|
227 __UHEAP_RESET; |
|
228 } |
|
229 // Handle error |
|
230 else |
|
231 { |
|
232 test(error == KErrNoMemory); |
|
233 __UHEAP_RESET; |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 TRAP(error,(iEntryId= iBioTestUtils->CreateBIOEntryFromFileL(SMS_MAIL_FILE, EBioIapSettingsMessage))); |
|
239 if(error) |
|
240 { |
|
241 iBioTestUtils->Printf(_L("Failed to Create Bio entry from %S\n"), &SMS_MAIL_FILE); |
|
242 iBioTestUtils->Printf(_L("error= %d\n"), error); |
|
243 User::Leave(error); |
|
244 } |
|
245 else |
|
246 iBioTestUtils->Printf(_L("Created Bio entry with ID=0x%x from %S"),iEntryId, &SMS_MAIL_FILE); |
|
247 /* |
|
248 error = KErrNone; |
|
249 finished = EFalse; |
|
250 failCount = 0; |
|
251 while(!finished) |
|
252 { |
|
253 __UHEAP_FAILNEXT(failCount++); |
|
254 |
|
255 TRAP(error,(iEntryId= iBioTestUtils->CreateBIOEntryFromFileL(SMS_MAIL_FILE, EBioIapSettingsMessage))); |
|
256 if (error == KErrNone) |
|
257 { |
|
258 __UHEAP_RESET; |
|
259 iBioTestUtils->Printf(_L("Created Bio entry with ID=0x%x from %S"),iEntryId, &SMS_MAIL_FILE); |
|
260 finished = ETrue; |
|
261 __UHEAP_RESET; |
|
262 } |
|
263 // Handle error |
|
264 else |
|
265 { |
|
266 // Check if error is out of memory or a specific fax rendering error |
|
267 test(error == KErrNoMemory); |
|
268 __UHEAP_RESET; |
|
269 } |
|
270 } |
|
271 */ |
|
272 CActiveScheduler::Add(this); |
|
273 } |
|
274 |
|
275 CTestIacp::~CTestIacp() |
|
276 { |
|
277 Cancel(); |
|
278 delete iSmsMsg; |
|
279 delete iParser; // The order of these two deletes is important. |
|
280 |
|
281 delete iEmailAccounts; |
|
282 delete iSmsAccount; |
|
283 } |
|
284 |
|
285 void CTestIacp::GetMessageBodyL() |
|
286 { |
|
287 delete iSmsMsg; |
|
288 iSmsMsg = NULL; |
|
289 iSmsMsg= iBioTestUtils->MessageBodyL(iEntryId).AllocL(); |
|
290 } |
|
291 |
|
292 void CTestIacp::StartL(TInt aCmd) |
|
293 { |
|
294 TInt error = KErrNone; |
|
295 TBool finished = EFalse; |
|
296 iState=aCmd; |
|
297 |
|
298 switch (iState) |
|
299 { |
|
300 case EParse: |
|
301 iBioTestUtils->Printf(_L("Parsing...\n")); |
|
302 iBioTestUtils->SetEntryL(iEntryId); //clients have to set the right context before calling ParseL() |
|
303 GetMessageBodyL(); |
|
304 |
|
305 while(!finished) |
|
306 { |
|
307 __UHEAP_FAILNEXT(iParseFailCount++); |
|
308 // |
|
309 TRAP(error, iParser->ParseL(iStatus,iSmsMsg->Des())); |
|
310 if (error == KErrNone) |
|
311 { |
|
312 __UHEAP_RESET; |
|
313 finished = ETrue; |
|
314 SetActive(); |
|
315 } |
|
316 else |
|
317 { |
|
318 test(error == KErrNoMemory); |
|
319 __UHEAP_RESET; |
|
320 } |
|
321 } |
|
322 |
|
323 break; |
|
324 |
|
325 case EProcess: |
|
326 iBioTestUtils->Printf(_L("Processing...\n")); |
|
327 iBioTestUtils->SetEntryL(iEntryId); //clients have to set the right context before calling ProcessL() |
|
328 while(!finished) |
|
329 { |
|
330 __UHEAP_FAILNEXT(iProcessFailCount++); |
|
331 // |
|
332 TRAP(error, iParser->ProcessL(iStatus)); //internalise and process |
|
333 if (error == KErrNone) |
|
334 { |
|
335 __UHEAP_RESET; |
|
336 finished = ETrue; |
|
337 SetActive(); |
|
338 } |
|
339 else |
|
340 { |
|
341 test(error == KErrNoMemory); |
|
342 __UHEAP_RESET; |
|
343 } |
|
344 } |
|
345 break; |
|
346 |
|
347 case EDisplay: |
|
348 DisplayEntryDataL(); |
|
349 RequestComplete(iStatus,KErrNone); |
|
350 SetActive(); |
|
351 break; |
|
352 |
|
353 case EDisplayMailService: |
|
354 DisplayMailServiceL(); |
|
355 RequestComplete(iStatus,KErrNone); |
|
356 SetActive(); |
|
357 break; |
|
358 default: |
|
359 break; |
|
360 } |
|
361 } |
|
362 |
|
363 void CTestIacp::DoCancel() |
|
364 { |
|
365 } |
|
366 |
|
367 void CTestIacp::RequestComplete(TRequestStatus& aStatus,TInt aCompletion) |
|
368 { |
|
369 TRequestStatus* statusPtr=&aStatus; |
|
370 User::RequestComplete(statusPtr,aCompletion); |
|
371 } |
|
372 |
|
373 void CTestIacp::RunL() |
|
374 { |
|
375 TInt result=iStatus.Int(); |
|
376 |
|
377 //heap test failure |
|
378 if( result == KErrNoMemory) |
|
379 { |
|
380 if(iState==EParse) |
|
381 { |
|
382 iParseFailCount++; |
|
383 StartL(EParse); |
|
384 return; |
|
385 } |
|
386 else if(iState==EProcess) |
|
387 { |
|
388 iProcessFailCount++; |
|
389 StartL(EProcess); |
|
390 return; |
|
391 } |
|
392 } |
|
393 |
|
394 if ( result!=KErrNone && result!=KIacpErrSmsDataNotRestored) |
|
395 { |
|
396 iBioTestUtils->ClearScreen(); |
|
397 //test.Console()->SetPos(0,0); |
|
398 DisplayErrorReason(result, *iBioTestUtils); |
|
399 CActiveScheduler::Stop(); |
|
400 return; |
|
401 } |
|
402 |
|
403 switch (iState) |
|
404 { |
|
405 case EParse: |
|
406 iBioTestUtils->WriteComment(_L("Parsed Ok.")); |
|
407 StartL(EProcess); |
|
408 break; |
|
409 case EProcess: |
|
410 iBioTestUtils->WriteComment(_L("Processed Ok.")); |
|
411 StartL(EDisplay); |
|
412 break; |
|
413 case EDisplay: |
|
414 StartL(EDisplayMailService); |
|
415 break; |
|
416 case EDisplayMailService: |
|
417 DisplayErrorReason(result, *iBioTestUtils); |
|
418 iParser->Cancel(); |
|
419 CActiveScheduler::Stop(); |
|
420 break; |
|
421 default: |
|
422 break; |
|
423 } |
|
424 } |
|
425 |
|
426 void CTestIacp::DisplayEntryDataL() |
|
427 { |
|
428 iBioTestUtils->SetEntryL(iEntryId); |
|
429 iBioTestUtils->ClearScreen(); |
|
430 //test.Console()->SetPos(0,0); |
|
431 |
|
432 TMsvEntry entry = iBioTestUtils->Entry(); |
|
433 iBioTestUtils->Printf(_L("===== MESSAGE DETAILS =====\n")); |
|
434 iBioTestUtils->Printf(_L("Entry Id: 0x%x\n"), iEntryId); |
|
435 iBioTestUtils->Printf(_L("iServiceId: 0x%x\n"), entry.iServiceId); |
|
436 iBioTestUtils->Printf(_L("iRelatedId: 0x%x\n"), entry.iRelatedId); |
|
437 iBioTestUtils->Printf(_L("iType: 0x%x\n"), entry.iType); |
|
438 iBioTestUtils->Printf(_L("iMtm: 0x%x\n"), entry.iMtm); |
|
439 TBuf<128> dateStr; |
|
440 entry.iDate.FormatL(dateStr, (_L("%D%M%Y%/0%1%/1%2%/2%3%/3"))); |
|
441 iBioTestUtils->Printf(_L("iDate: %S\n"),&dateStr); |
|
442 |
|
443 iBioTestUtils->Printf(_L("iSize: %d\n"), entry.iSize); |
|
444 iBioTestUtils->Printf(_L("iError: %d\n"), entry.iError); |
|
445 iBioTestUtils->Printf(_L("iBioType: 0x%x\n"), entry.iBioType); |
|
446 iBioTestUtils->Printf(_L("iMtmData1: %d\n"), entry.MtmData1()); |
|
447 iBioTestUtils->Printf(_L("iMtmData2: %d\n"), entry.MtmData2()); |
|
448 iBioTestUtils->Printf(_L("iMtmData3: %d\n"), entry.MtmData3()); |
|
449 iBioTestUtils->Printf(_L("iDescription: %S\n"),&entry.iDescription); |
|
450 iBioTestUtils->Printf(_L("iDetails: %S\n"),&entry.iDetails); |
|
451 |
|
452 iBioTestUtils->ClearScreen(); |
|
453 |
|
454 if (iBioTestUtils->Entry().MtmData3() != BIO_MSG_ENTRY_PARSED && |
|
455 iBioTestUtils->Entry().MtmData3() != BIO_MSG_ENTRY_PROCESSED) |
|
456 { |
|
457 iBioTestUtils->WriteComment(_L("BioMg has not been parsed")); |
|
458 User::Leave(KErrGeneral); |
|
459 } |
|
460 |
|
461 iBioTestUtils->Printf(_L("===== Extracted Fields =====\n")); |
|
462 iBioTestUtils->LogExtractedFieldsL(iEntryId); |
|
463 } |
|
464 |
|
465 void CTestIacp::DisplayMailServiceL() |
|
466 { |
|
467 TMsvId smtpEntryId= KMsvNullIndexEntryId; |
|
468 TMsvId smtpRelatedId= KMsvNullIndexEntryId; |
|
469 TMsvId pop3EntryId= KMsvNullIndexEntryId; |
|
470 TMsvId pop3RelatedId= KMsvNullIndexEntryId; |
|
471 TMsvId imap4EntryId= KMsvNullIndexEntryId; |
|
472 TMsvId imap4RelatedId= KMsvNullIndexEntryId; |
|
473 TMsvId smsEntryId = KMsvNullIndexEntryId; |
|
474 |
|
475 //Get Isp Name from parsed fields |
|
476 CArrayPtrSeg<CParsedField>* parsedFieldArray= &(iBioTestUtils->ParsedFieldArray()); |
|
477 |
|
478 //first set iIspName |
|
479 for (TInt i = 0; i < parsedFieldArray->Count(); i++) |
|
480 if(parsedFieldArray->At(i)->FieldName().CompareF(SMS_ISP_M_NAME)==0) |
|
481 iIspName = parsedFieldArray->At(i)->FieldValue(); |
|
482 |
|
483 // Get list of children IDs |
|
484 iBioTestUtils->SetEntryL(KMsvRootIndexEntryId); |
|
485 CMsvEntrySelection *msvSelection=iBioTestUtils->ChildrenWithTypeLC(KUidMsvServiceEntry); |
|
486 |
|
487 TMsvEntry entry; |
|
488 TInt count = msvSelection->Count(); |
|
489 for (TInt j = 0; j < count; j++) |
|
490 { |
|
491 // set context to service entry |
|
492 iBioTestUtils->SetEntryL((*msvSelection)[j]); |
|
493 entry = iBioTestUtils->Entry(); |
|
494 if (entry.iType == KUidMsvServiceEntry) |
|
495 if(entry.iDetails.Length() == iIspName.Length()) |
|
496 if(entry.iDetails.CompareF(iIspName)==0 ) |
|
497 { |
|
498 if(entry.iMtm == KUidMsgTypeSMTP) |
|
499 { |
|
500 smtpEntryId= entry.Id(); |
|
501 smtpRelatedId= entry.iRelatedId; |
|
502 ReadSmtpServiceL(); |
|
503 } |
|
504 else if(entry.iMtm == KUidMsgTypePOP3) |
|
505 { |
|
506 pop3EntryId= entry.Id(); |
|
507 pop3RelatedId= entry.iRelatedId; |
|
508 ReadPop3ServiceL(); |
|
509 } |
|
510 else if(entry.iMtm == KUidMsgTypeIMAP4) |
|
511 { |
|
512 imap4EntryId= entry.Id(); |
|
513 imap4RelatedId= entry.iRelatedId; |
|
514 ReadImap4ServiceL(); |
|
515 } |
|
516 else if(entry.iMtm == KUidMsgTypeSMS) |
|
517 { |
|
518 imap4EntryId= entry.Id(); |
|
519 ReadSmsServiceL(); |
|
520 } |
|
521 } |
|
522 } |
|
523 CleanupStack::PopAndDestroy();//msvSelection |
|
524 |
|
525 iBioTestUtils->WriteComment(_L("\r\n================ Service Entry IDs and Related IDs ================")); |
|
526 TBuf<64> tempBuf; |
|
527 tempBuf.Format(_L("Smtp service entry Id:\t%d"), smtpEntryId); |
|
528 iBioTestUtils->WriteComment(tempBuf); |
|
529 tempBuf.Format(_L("Smtp service entry Related Id:\t%d"), smtpRelatedId); |
|
530 iBioTestUtils->WriteComment(tempBuf); |
|
531 |
|
532 tempBuf.Format(_L("Pop3 service entry Id:\t%d"), pop3EntryId); |
|
533 iBioTestUtils->WriteComment(tempBuf); |
|
534 tempBuf.Format(_L("Pop3 service entry Related Id:\t%d"), pop3RelatedId); |
|
535 iBioTestUtils->WriteComment(tempBuf); |
|
536 |
|
537 tempBuf.Format(_L("Imap4 service entry Id:\t%d"), imap4EntryId); |
|
538 iBioTestUtils->WriteComment(tempBuf); |
|
539 tempBuf.Format(_L("Imap4 service entry Related Id:\t%d"), imap4RelatedId); |
|
540 iBioTestUtils->WriteComment(tempBuf); |
|
541 |
|
542 tempBuf.Format(_L("Sms service entry Id:\t%d"), smsEntryId); |
|
543 iBioTestUtils->WriteComment(tempBuf); |
|
544 } |
|
545 |
|
546 void CTestIacp::ReadSmtpServiceL() |
|
547 { |
|
548 //iEntry should point to smtp service entry |
|
549 CImSmtpSettings* smtpSettings=new(ELeave) CImSmtpSettings(); |
|
550 CleanupStack::PushL(smtpSettings); |
|
551 |
|
552 CImIAPPreferences* smtpIapPreferences = CImIAPPreferences::NewLC(); |
|
553 |
|
554 TSmtpAccount smtpAccount; |
|
555 iEmailAccounts->GetSmtpAccountL(iBioTestUtils->iMsvEntry->EntryId(), smtpAccount); |
|
556 iEmailAccounts->LoadSmtpSettingsL(smtpAccount, *smtpSettings); |
|
557 iEmailAccounts->LoadSmtpIapSettingsL(smtpAccount, *smtpIapPreferences); |
|
558 |
|
559 PrintSmtpSettings(smtpSettings); |
|
560 CleanupStack::PopAndDestroy(2, smtpSettings); // smtpIapPreferences, smtpSettings |
|
561 } |
|
562 |
|
563 void CTestIacp::ReadPop3ServiceL() |
|
564 { |
|
565 //iEntry should point to po3 service entry |
|
566 CImPop3Settings* pop3Settings=new(ELeave) CImPop3Settings(); |
|
567 CleanupStack::PushL(pop3Settings); |
|
568 |
|
569 CImIAPPreferences* pop3IapPreferences = CImIAPPreferences::NewLC(); |
|
570 |
|
571 TPopAccount popAccount; |
|
572 iEmailAccounts->GetPopAccountL(iBioTestUtils->iMsvEntry->EntryId(), popAccount); |
|
573 iEmailAccounts->LoadPopSettingsL(popAccount, *pop3Settings); |
|
574 iEmailAccounts->LoadPopIapSettingsL(popAccount, *pop3IapPreferences); |
|
575 |
|
576 PrintPop3Settings(pop3Settings); |
|
577 CleanupStack::PopAndDestroy(2, pop3Settings); // pop3IapPreferences, smtpSettings |
|
578 } |
|
579 |
|
580 void CTestIacp::ReadImap4ServiceL() |
|
581 { |
|
582 //iEntry should point to imap4 service entry |
|
583 CImImap4Settings* imap4Settings=new(ELeave) CImImap4Settings(); |
|
584 CleanupStack::PushL(imap4Settings); |
|
585 |
|
586 CImIAPPreferences* imap4IapPreferences = CImIAPPreferences::NewLC(); |
|
587 |
|
588 TImapAccount imapAccount; |
|
589 iEmailAccounts->GetImapAccountL(iBioTestUtils->iMsvEntry->EntryId(), imapAccount); |
|
590 iEmailAccounts->LoadImapSettingsL(imapAccount, *imap4Settings); |
|
591 iEmailAccounts->LoadImapIapSettingsL(imapAccount, *imap4IapPreferences); |
|
592 |
|
593 PrintImap4Settings(imap4Settings); |
|
594 CleanupStack::PopAndDestroy(2, imap4Settings); // imap4IapPreferences, smtpSettings |
|
595 } |
|
596 |
|
597 void CTestIacp::ReadSmsServiceL() |
|
598 { |
|
599 //iEntry should point to imap4 service entry |
|
600 CSmsSettings* smsSettings=CSmsSettings::NewL(); |
|
601 CleanupStack::PushL(smsSettings); |
|
602 iSmsAccount->LoadSettingsL(*smsSettings); |
|
603 PrintSmsSettings(smsSettings); |
|
604 CleanupStack::PopAndDestroy(smsSettings); |
|
605 } |
|
606 |
|
607 void CTestIacp::PrintSmtpSettings(CImSmtpSettings* aSmtpSettings) |
|
608 { |
|
609 iBioTestUtils->ClearScreen(); |
|
610 //test.Console()->SetPos(0,0); |
|
611 |
|
612 iBioTestUtils->Printf(_L("====== SMTP Service entry=====\n")); |
|
613 TBuf<256> tempBuf; // temp logging buffer |
|
614 tempBuf = aSmtpSettings->ServerAddress(); |
|
615 iBioTestUtils->Printf(_L("ServerAddress: %S\n"), &tempBuf); |
|
616 tempBuf = aSmtpSettings->EmailAddress(); |
|
617 iBioTestUtils->Printf(_L("EmailAddress: %S\n"), &tempBuf); |
|
618 iBioTestUtils->Printf(_L("Port: %d\n"), aSmtpSettings->Port()); |
|
619 tempBuf=aSmtpSettings->EmailAlias(); |
|
620 iBioTestUtils->Printf(_L("EmailAlias: %S\n"), &tempBuf); |
|
621 tempBuf=aSmtpSettings->ReplyToAddress(); |
|
622 iBioTestUtils->Printf(_L("ReplyToAddress: %S\n"), &tempBuf); |
|
623 tempBuf=aSmtpSettings->ReceiptAddress(); |
|
624 iBioTestUtils->Printf(_L("ReceiptAddress: %S\n"), &tempBuf); |
|
625 iBioTestUtils->Printf(_L("BodyEncoding: %d\n"), aSmtpSettings->BodyEncoding()); |
|
626 } |
|
627 |
|
628 void CTestIacp::PrintPop3Settings(CImPop3Settings* aSmtpSettings) |
|
629 { |
|
630 iBioTestUtils->ClearScreen(); |
|
631 //test.Console()->SetPos(0,0); |
|
632 |
|
633 iBioTestUtils->Printf(_L("====== POP3 Service entry=====\n")); |
|
634 TBuf<256> tempBuf; // temp logging buffer |
|
635 //LoginName and Password are stored as 8 bit Descriptors so we need to convert them |
|
636 // into 16 bit Unicode to be able to display them on the console |
|
637 tempBuf.Copy(aSmtpSettings->LoginName()); |
|
638 iBioTestUtils->Printf(_L("LoginName: %S\n"), &tempBuf); |
|
639 tempBuf.Copy(aSmtpSettings->Password()); |
|
640 iBioTestUtils->Printf(_L("Password: %S\n"), &tempBuf); |
|
641 tempBuf = aSmtpSettings->ServerAddress(); |
|
642 iBioTestUtils->Printf(_L("ServerAddress: %S\n"), &tempBuf); |
|
643 iBioTestUtils->Printf(_L("Port: %d\n"), aSmtpSettings->Port()); |
|
644 iBioTestUtils->Printf(_L("Apop: %d\n"), aSmtpSettings->Apop()); |
|
645 iBioTestUtils->Printf(_L("AutoSendOnConnect: %d\n"), aSmtpSettings->AutoSendOnConnect()); |
|
646 } |
|
647 |
|
648 void CTestIacp::PrintImap4Settings( CImImap4Settings* aSmtpSettings) |
|
649 { |
|
650 iBioTestUtils->ClearScreen(); |
|
651 |
|
652 iBioTestUtils->Printf(_L("====== IMAP4 Service entry=====\n")); |
|
653 TBuf<256> tempBuf; // temp logging buffer |
|
654 //LoginName and Password are stored as 8 bit Descriptors so we need to convert them |
|
655 // into 16 bit Unicode to be able to display them on the console |
|
656 tempBuf.Copy(aSmtpSettings->LoginName()); |
|
657 iBioTestUtils->Printf(_L("LoginName: %S\n"), &tempBuf); |
|
658 tempBuf.Copy(aSmtpSettings->Password()); |
|
659 iBioTestUtils->Printf(_L("Password: %S\n"), &tempBuf); |
|
660 tempBuf=aSmtpSettings->ServerAddress(); |
|
661 iBioTestUtils->Printf(_L("ServerAddress: %S\n"), &tempBuf); |
|
662 iBioTestUtils->Printf(_L("Port: %d\n"), aSmtpSettings->Port()); |
|
663 tempBuf.Copy(aSmtpSettings->FolderPath()); |
|
664 iBioTestUtils->Printf(_L("FolderPath: %S\n"), &tempBuf); |
|
665 |
|
666 iBioTestUtils->Printf(_L("PathSeparator: %c\n"), aSmtpSettings->PathSeparator()); |
|
667 iBioTestUtils->Printf(_L("Synchronise: %d\n"), aSmtpSettings->Synchronise()); |
|
668 iBioTestUtils->Printf(_L("Subscribe: %d\n"), aSmtpSettings->Subscribe()); |
|
669 iBioTestUtils->Printf(_L("AutoSendOnConnect: %d\n"), aSmtpSettings->AutoSendOnConnect()); |
|
670 iBioTestUtils->Printf(_L("DisconnectedUserMode: %d\n"), aSmtpSettings->DisconnectedUserMode()); |
|
671 } |
|
672 |
|
673 void CTestIacp::PrintSmsSettings( CSmsSettings* aSmsSettings) |
|
674 { |
|
675 iBioTestUtils->ClearScreen(); |
|
676 |
|
677 iBioTestUtils->Printf(_L("====== Sms Service entry=====\n")); |
|
678 //LoginName and Password are stored as 8 bit Descriptors so we need to convert them |
|
679 // into 16 bit Unicode to be able to display them on the console |
|
680 iBioTestUtils->Printf(_L("Number of service centre addresses: %d\n"), aSmsSettings->ServiceCenterCount()); |
|
681 for(TInt i = 0; i < aSmsSettings->ServiceCenterCount();i++) |
|
682 { |
|
683 CSmsServiceCenter& number = aSmsSettings->GetServiceCenter(i); |
|
684 iBioTestUtils->Printf(_L(" Address %d\n"),i); |
|
685 TPtrC ptr; |
|
686 ptr.Set(number.Name()); |
|
687 iBioTestUtils->Printf(_L(" Name %S\n"), &ptr); |
|
688 ptr.Set(number.Address()); |
|
689 iBioTestUtils->Printf(_L(" Address %S\n"), &ptr); |
|
690 } |
|
691 } |
|
692 |
|
693 LOCAL_C void doMainL() |
|
694 { |
|
695 //create a scheduler |
|
696 exampleScheduler = new (ELeave) CExampleScheduler; |
|
697 CleanupStack::PushL( exampleScheduler ); |
|
698 CActiveScheduler::Install( exampleScheduler ); |
|
699 |
|
700 CBioTestUtils* BioTestUtils= CBioTestUtils::NewL(test, ETuGoClientSide | ETuDeleteService | ETuCreateService); |
|
701 BioTestUtils->WriteComment(_L("Msv Client Side Created")); |
|
702 CleanupStack::PushL(BioTestUtils); |
|
703 |
|
704 CTestIacp* testParser = CTestIacp::NewL(BioTestUtils); |
|
705 CleanupStack::PushL( testParser ); |
|
706 BioTestUtils->WriteComment(_L("CTestIacp Object Created.")); |
|
707 |
|
708 testParser->StartL(EParse); |
|
709 CActiveScheduler::Start(); |
|
710 |
|
711 CleanupStack::PopAndDestroy(3); // testParser, BioTestUtils, exampleScheduler |
|
712 |
|
713 testParser=NULL; |
|
714 BioTestUtils=NULL; |
|
715 exampleScheduler = NULL; |
|
716 } |
|
717 |
|
718 GLDEF_C TInt E32Main() |
|
719 { |
|
720 test.Title(); |
|
721 test.Start(_L("IACP Test Harness")); |
|
722 __UHEAP_MARK; |
|
723 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
724 test(cleanup!=NULL); |
|
725 TRAPD(error,doMainL()); |
|
726 if (error) test.Printf(_L("Completed with return code %d"),error); |
|
727 delete cleanup; |
|
728 __UHEAP_MARKEND; |
|
729 test.Close(); |
|
730 test.End(); |
|
731 return KErrNone; |
|
732 } |