|
1 /* ============================================================================ |
|
2 * Name : popimapprofiletester.cpp |
|
3 * Part of : ipsservices / ipsprofiletester |
|
4 * Description :: STIF test cases |
|
5 * Version : %version: 1 % << Don't touch! Updated by Synergy at check-out. |
|
6 * |
|
7 * Copyright © 2010-2010 Nokia and/or its subsidiary(-ies). All rights reserved. |
|
8 * This material, including documentation and any related computer |
|
9 * programs, is protected by copyright controlled by Nokia. All |
|
10 * rights are reserved. Copying, including reproducing, storing, |
|
11 * adapting or translating, any or all of this material requires the |
|
12 * prior written consent of Nokia. This material also contains |
|
13 * confidential information which may not be disclosed to others |
|
14 * without the prior written consent of Nokia. |
|
15 * ============================================================================ |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <StifTestInterface.h> |
|
20 #include "popimapprofiletester.h" |
|
21 #include <SettingServerClient.h> |
|
22 /* |
|
23 * define flag in ctg file |
|
24 */ |
|
25 _LIT( KSetupWizAccountType,"AccountType" ); |
|
26 _LIT( KSetupWizAccountsConfigured,"AccountsConfigured" ); |
|
27 _LIT( KSetupWizMaxAccountsReached,"MaxAccountsReached" ); |
|
28 _LIT( KSetupWizEmailAddress,"EmailAddress" ); |
|
29 _LIT( KSetupWizUsername,"Username" ); |
|
30 _LIT( KSetupWizPassword,"Password" ); |
|
31 _LIT( KSetupWizMailboxName,"MailboxName" ); |
|
32 _LIT( KSetupWizIncomingServer,"IncomingServer" ); |
|
33 _LIT( KSetupWizIncomingPort,"IncomingPort" ); |
|
34 _LIT( KSetupWizOutgoingServer,"OutgoingServer" ); |
|
35 _LIT( KSetupWizOutgoingPort,"OutgoingPort" ); |
|
36 _LIT( KSetupWizIncomingSecurityAuth,"IncomingSecurityAuth" ); |
|
37 _LIT( KSetupWizIncomingSecurityProtocol,"IncomingSecurityProtocol" ); |
|
38 _LIT( KSetupWizOutgoingSecurityAuth,"OutgoingSecurityAuth" ); |
|
39 _LIT( KSetupWizOutgoingSecurityProtocol,"OutgoingSecurityProtocol" ); |
|
40 _LIT( KSetupWizOperatorSecurityAuth,"OperatorSecurityAuth" ); |
|
41 _LIT( KSetupWizOperatorSecurityProtocol,"OperatorSecurityProtocol" ); |
|
42 _LIT( KSetupWizOperatorPort,"OperatorPort" ); |
|
43 _LIT(KProfileTesterDLL,"popimapprofiletester.dll"); |
|
44 _LIT(KAccountType,"AccountType"); |
|
45 _LIT(KIMAPAccount,"imap"); |
|
46 _LIT(KPOPAccount,"pop"); |
|
47 _LIT(KInboxType,"inbox"); |
|
48 _LIT(KOutboxType,"outbox"); |
|
49 _LIT(KDraftsType,"drafts"); |
|
50 _LIT(KSentType,"sent"); |
|
51 // Logging path |
|
52 _LIT( KpopimapprofiletesterLogPath, "\\logs\\testframework\\popimapprofiletester\\" ); |
|
53 // Log file |
|
54 _LIT( KpopimapprofiletesterLogFile, "popimapprofiletester.txt" ); |
|
55 _LIT( KpopimapprofiletesterLogFileWithTitle, "popimapprofiletester_[%S].txt" ); |
|
56 /* |
|
57 * default value for settings |
|
58 */ |
|
59 _LIT( KWizAccountTypeDefault,"fsp" ); |
|
60 |
|
61 // ============================ MEMBER FUNCTIONS =============================== |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CPopImapProfileTester::CPopImapProfileTester |
|
65 // C++ default constructor can NOT contain any code, that |
|
66 // might leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CPopImapProfileTester::CPopImapProfileTester(CTestModuleIf& aTestModuleIf) : |
|
70 CScriptBase(aTestModuleIf), iTimeoutTimer(NULL), iMailClient(NULL), |
|
71 iIPSMailbox(NULL), iTimeout(EFalse), iEventParam1(NULL), |
|
72 iEventParam2(NULL), iEventSynchronousCall(EFalse), iErr(KErrNone), |
|
73 iWaitingState(EWaitingNothing), iPluginId(TFSMailMsgId()), |
|
74 iSearchOngoing(EFalse), iSearchMatches(NULL) |
|
75 { |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CPopImapProfileTester::ConstructL |
|
80 // Symbian 2nd phase constructor can leave. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CPopImapProfileTester::ConstructL() |
|
84 { |
|
85 //Read logger settings to check whether test case name is to be |
|
86 //appended to log file name. |
|
87 RSettingServer settingServer; |
|
88 TInt ret = settingServer.Connect(); |
|
89 if (ret != KErrNone) |
|
90 { |
|
91 User::Leave(ret); |
|
92 } |
|
93 // Struct to StifLogger settigs. |
|
94 TLoggerSettings loggerSettings; |
|
95 // Parse StifLogger defaults from STIF initialization file. |
|
96 ret = settingServer.GetLoggerSettings(loggerSettings); |
|
97 if (ret != KErrNone) |
|
98 { |
|
99 User::Leave(ret); |
|
100 } |
|
101 // Close Setting server session |
|
102 settingServer.Close(); |
|
103 |
|
104 TFileName logFileName; |
|
105 |
|
106 if (loggerSettings.iAddTestCaseTitle) |
|
107 { |
|
108 TName title; |
|
109 TestModuleIf().GetTestCaseTitleL(title); |
|
110 logFileName.Format(KpopimapprofiletesterLogFileWithTitle, &title); |
|
111 } |
|
112 else |
|
113 { |
|
114 logFileName.Copy(KpopimapprofiletesterLogFile); |
|
115 } |
|
116 |
|
117 iLog = CStifLogger::NewL(KpopimapprofiletesterLogPath, logFileName, |
|
118 CStifLogger::ETxt, CStifLogger::EFile, EFalse); |
|
119 |
|
120 SendTestClassVersion(); |
|
121 |
|
122 iWait = new (ELeave) CActiveSchedulerWait(); |
|
123 iTimeoutTimer = CTimeoutTimer::NewL(*this); |
|
124 |
|
125 // create a mail client |
|
126 iMailClient = CFSMailClient::NewL(); |
|
127 if (iMailClient) |
|
128 { |
|
129 iMailClient->AddObserverL(*this); |
|
130 iLog->Log(_L( "Mail Client was created" )); |
|
131 } |
|
132 else |
|
133 { |
|
134 iLog->Log(_L( "ERROR: Mail Client not created" )); |
|
135 } |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CPopImapProfileTester::NewL |
|
140 // Two-phased constructor. |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 CPopImapProfileTester* CPopImapProfileTester::NewL(CTestModuleIf& aTestModuleIf) |
|
144 { |
|
145 CPopImapProfileTester* self = new (ELeave) CPopImapProfileTester( |
|
146 aTestModuleIf); |
|
147 |
|
148 CleanupStack::PushL(self); |
|
149 self->ConstructL(); |
|
150 CleanupStack::Pop(); |
|
151 |
|
152 return self; |
|
153 |
|
154 } |
|
155 |
|
156 // Destructor |
|
157 CPopImapProfileTester::~CPopImapProfileTester() |
|
158 { |
|
159 // Delete resources allocated from test methods |
|
160 Delete(); |
|
161 if (iMailClient) |
|
162 { |
|
163 if (NULL != iIPSMailbox) |
|
164 { |
|
165 iMailClient->UnsubscribeMailboxEvents(iIPSMailbox->GetId(), *this); |
|
166 delete iIPSMailbox; |
|
167 iIPSMailbox = NULL; |
|
168 } |
|
169 iMailClient->Close(); |
|
170 } |
|
171 DELANDNULL(iTimeoutTimer); |
|
172 |
|
173 // Delete logger |
|
174 DELANDNULL(iLog); |
|
175 |
|
176 //Delete waiter |
|
177 if (NULL != iWait && iWait->IsStarted()) |
|
178 { |
|
179 iWait->AsyncStop(); |
|
180 } |
|
181 DELANDNULL(iWait); |
|
182 } |
|
183 |
|
184 //----------------------------------------------------------------------------- |
|
185 // CPopImapProfileTester::SendTestClassVersion |
|
186 // Method used to send version of test class |
|
187 //----------------------------------------------------------------------------- |
|
188 // |
|
189 void CPopImapProfileTester::SendTestClassVersion() |
|
190 { |
|
191 TVersion moduleVersion; |
|
192 moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
193 moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
194 moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
195 |
|
196 TFileName moduleName; |
|
197 moduleName = KProfileTesterDLL; |
|
198 |
|
199 TBool newVersionOfMethod = ETrue; |
|
200 TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, |
|
201 newVersionOfMethod); |
|
202 } |
|
203 //----------------------------------------------------------------------------- |
|
204 // CPopImapProfileTester::DeleteTestMsgL |
|
205 // Method used to delete msgs in a specific folder |
|
206 //----------------------------------------------------------------------------- |
|
207 // |
|
208 TInt CPopImapProfileTester::DeleteTestMsgL(TDesC& aFolderName) |
|
209 { |
|
210 TInt err(KErrNone); |
|
211 TInt msgCount(0); //number of messages in folder |
|
212 |
|
213 // Step 01: to find a folder |
|
214 CFSMailFolder* folder = FindFolder(aFolderName); |
|
215 RArray<TFSMailMsgId> msgsToBeDeleted; |
|
216 CleanupClosePushL(msgsToBeDeleted); |
|
217 |
|
218 if (NULL != folder) |
|
219 { |
|
220 // Step 02: to list all test messages to be deleted from this folder |
|
221 RPointerArray<CFSMailMessage> messages; |
|
222 TInt gotMsgs = GetMessagesFromFolderL(messages, folder, |
|
223 EFSMsgDataSubject, EFSMailSortByDate, msgCount); |
|
224 |
|
225 // Step 03: to find to be deleted msgs |
|
226 for (TInt i = 0; i < messages.Count(); i++) |
|
227 { |
|
228 //deleted msgs with STIF |
|
229 if (messages[i]->GetSubject().Find(_L("STIF" )) != KErrNotFound) |
|
230 { |
|
231 iLog->Log(_L("Found: %d. %S"), i + 1, |
|
232 &messages[i]->GetSubject()); |
|
233 msgsToBeDeleted.Append(messages[i]->GetMessageId()); |
|
234 } |
|
235 }//end loop: 'for' |
|
236 |
|
237 if (msgsToBeDeleted.Count() > 0) |
|
238 { |
|
239 iLog->Log(_L(" -Deleting %d message(s)"), msgsToBeDeleted.Count()); |
|
240 iMailClient->DeleteMessagesByUidL(iIPSMailbox->GetId(), |
|
241 folder->GetFolderId(), msgsToBeDeleted); |
|
242 err = WaitForEvent(TFSEventMailDeleted, NULL, NULL, KOneMinuteTime); |
|
243 iIPSMailbox->RefreshNowL(*this); |
|
244 if (KErrNone == WaitForEvent(TFSEventMailboxOnline)) |
|
245 { |
|
246 WaitForResponse(TFSProgress::EFSStatus_RequestComplete, |
|
247 KHalfMinuteTime); |
|
248 } |
|
249 }//end if: 'count()>0' |
|
250 else |
|
251 { |
|
252 iLog->Log(_L("Not find messages(STIF) to delete")); |
|
253 err = KErrNotFound; |
|
254 } |
|
255 messages.ResetAndDestroy(); |
|
256 }// end if 'inboxFolder' |
|
257 else |
|
258 { |
|
259 err = KErrNotFound; |
|
260 iLog->Log(_L(" %S is NOT found.(Error's ID:%d)"), &aFolderName, err); |
|
261 } |
|
262 CleanupStack::PopAndDestroy(&msgsToBeDeleted); |
|
263 return err; |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CPopImapProfileTester::FindFoler |
|
268 // Method used to find a folder with folder's name |
|
269 // ----------------------------------------------------------------------------- |
|
270 CFSMailFolder* CPopImapProfileTester::FindFolder(const TDesC& aFolderName) |
|
271 { |
|
272 CFSMailFolder* folder(NULL); |
|
273 RPointerArray<CFSMailFolder>& allFolders = iIPSMailbox->ListFolders(); |
|
274 |
|
275 TFSMailMsgId folderId = GetFolderIdFromName(aFolderName); |
|
276 for (TInt i = 0; i < allFolders.Count(); ++i) |
|
277 { |
|
278 if (allFolders[i]->GetFolderId() == folderId) |
|
279 { |
|
280 iLog->Log(_L("Found: %S folder"), &allFolders[i]->GetFolderName()); |
|
281 folder = allFolders[i]; |
|
282 break; |
|
283 } |
|
284 } |
|
285 return folder; |
|
286 } |
|
287 // ----------------------------------------------------------------------------- |
|
288 // CPopImapProfileTester::GetMessagesFromFolderL |
|
289 // Method used to get messages from specific folder |
|
290 // ----------------------------------------------------------------------------- |
|
291 TInt CPopImapProfileTester::GetMessagesFromFolderL( |
|
292 RPointerArray<CFSMailMessage>& aMessages, CFSMailFolder* aFolder, |
|
293 TFSMailDetails aDet, TFSMailSortField aSort, TUint aCount) |
|
294 { |
|
295 TFSMailSortCriteria sortCriteria; |
|
296 sortCriteria.iField = aSort; |
|
297 sortCriteria.iOrder = EFSMailDescending; // default sort order: Descending |
|
298 |
|
299 RArray<TFSMailSortCriteria> sorting; |
|
300 CleanupClosePushL(sorting); |
|
301 |
|
302 // append primary criteria |
|
303 sorting.Append(sortCriteria); |
|
304 |
|
305 MFSMailIterator* iterator = aFolder->ListMessagesL(aDet, sorting); |
|
306 CleanupStack::PopAndDestroy(&sorting); |
|
307 CleanupDeletePushL(iterator); |
|
308 |
|
309 TInt messageCount = aFolder->GetMessageCount(); |
|
310 iLog->Log(_L(" %d message(s) in '%S'"), messageCount, |
|
311 &aFolder->GetFolderName()); |
|
312 |
|
313 if (aCount > 0) |
|
314 { |
|
315 if (messageCount < aCount) |
|
316 { |
|
317 aCount = messageCount; |
|
318 } |
|
319 } |
|
320 else |
|
321 { |
|
322 aCount = messageCount; |
|
323 } |
|
324 |
|
325 iterator->NextL(TFSMailMsgId(), aCount, aMessages); |
|
326 CleanupStack::PopAndDestroy(iterator); |
|
327 return aCount; |
|
328 } |
|
329 // ----------------------------------------------------------------------------- |
|
330 // CPopImapProfileTester::EventL |
|
331 // from MFSMailEventObserver |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 void CPopImapProfileTester::EventL(TFSMailEvent aEvent, |
|
335 TFSMailMsgId /*aMailbox*/, TAny* aParam1, TAny* aParam2, TAny* aParam3) |
|
336 { |
|
337 LogEvent(_L("Receive Event->"), aEvent, aParam1, aParam2, aParam3); |
|
338 if ((aEvent == iCurrWaitedEvent) && (iWait->IsStarted()) && (iWaitingState |
|
339 == EWaitingEvent) && ParseEventParams(aParam1, aParam2)) |
|
340 OpComplete(); |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CPopImapProfileTester::RequestResponseL |
|
345 // from MFSMailRequestObserver |
|
346 // It proivdes progress/status information of requested functions |
|
347 // i.e. DeleteMailBoxByUidL, RefreshNowL |
|
348 // ----------------------------------------------------------------------------- |
|
349 // |
|
350 void CPopImapProfileTester::RequestResponseL(TFSProgress aEvent, |
|
351 TInt aRequestId) |
|
352 { |
|
353 LogTFSProgress(_L("Receive Response->"), aEvent.iProgressStatus, aRequestId); |
|
354 if ((aEvent.iProgressStatus == iCurrWaitedResponse) && (iWaitingState |
|
355 == EWaitingResponse) && (iWait->IsStarted())) |
|
356 OpComplete(); |
|
357 } |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // CPopImapProfileTester::MatchFoundL |
|
361 // from MFSMailBoxSearchObserver |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 void CPopImapProfileTester::MatchFoundL(CFSMailMessage* aMatchMessage) |
|
365 { |
|
366 TBuf<20> tempFolderName; |
|
367 GetFolderNameFromId(aMatchMessage->GetFolderId(), tempFolderName); |
|
368 TPtrC folderName = tempFolderName.Mid(0); |
|
369 iLog->Log(_L(" MatchFound %S in %S"), &aMatchMessage->GetSubject(), |
|
370 &folderName); |
|
371 if (iSearchOngoing) |
|
372 { |
|
373 iSearchMatches++; |
|
374 } |
|
375 delete aMatchMessage; |
|
376 } |
|
377 |
|
378 // ----------------------------------------------------------------------------- |
|
379 // CPopImapProfileTester::SearchCompletedL |
|
380 // from MFSMailBoxSearchObserver |
|
381 // ----------------------------------------------------------------------------- |
|
382 // |
|
383 void CPopImapProfileTester::SearchCompletedL() |
|
384 { |
|
385 if (iWait->IsStarted()) |
|
386 { |
|
387 OpComplete(); |
|
388 iLog->Log(_L(" SearchCompleted")); |
|
389 } |
|
390 else |
|
391 { |
|
392 iLog->Log(_L("Error: SearchCompleted callback")); |
|
393 } |
|
394 |
|
395 } |
|
396 |
|
397 // ----------------------------------------------------------------------------- |
|
398 // CPopImapProfileTester::ClientRequiredSearchPriority |
|
399 // from MFSMailBoxSearchObserver |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 void CPopImapProfileTester::ClientRequiredSearchPriority(TInt* /*apRequiredSearchPriority*/) |
|
403 { |
|
404 iLog->Log(_L(" ClientRequiredSearchPriority")); |
|
405 } |
|
406 |
|
407 void CPopImapProfileTester::TimeoutNotify() |
|
408 { |
|
409 iTimeout = ETrue; |
|
410 OpComplete(); |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CPopImapProfileTester::SendMsgL |
|
415 // Method is a actual sending message function. |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 TInt CPopImapProfileTester::SendMsgL(CFSMailMessage& aMsg, |
|
419 const TDesC &aSubject, TFSMailMsgId& aGotMsgId) |
|
420 { |
|
421 TInt err(KErrNone); |
|
422 TInt msgCount(0); |
|
423 |
|
424 //to call actual function to send message |
|
425 TRAP( err, iIPSMailbox->SendMessageL( aMsg ) ); |
|
426 |
|
427 //second asynchronous when moving msg from Outbox to Sent Items ( this actually tells msg was sent ) |
|
428 if (KErrNone == err) |
|
429 { |
|
430 //Wait for email to be sent |
|
431 TFSMailMsgId folderId = iIPSMailbox->GetStandardFolderId(EFSSentFolder); |
|
432 iIPSMailbox->RefreshNowL(); |
|
433 err = WaitForEvent(TFSEventMailMoved, NULL, &folderId); |
|
434 iIPSMailbox->GoOfflineL(); |
|
435 WaitForEvent(TFSEventMailboxOffline); |
|
436 iIPSMailbox->RefreshNowL(*this); |
|
437 WaitForResponse(TFSProgress::EFSStatus_RequestComplete); |
|
438 |
|
439 if (KErrNone == err) |
|
440 { |
|
441 // Step04: To check 'Inbox' folder to sure message sent |
|
442 TFSMailMsgId folderId = iIPSMailbox->GetStandardFolderId(EFSInbox); |
|
443 CFSMailFolder* folder = iMailClient->GetFolderByUidL( |
|
444 iIPSMailbox->GetId(), folderId); |
|
445 CleanupStack::PushL(folder); |
|
446 if (NULL != folder) |
|
447 { |
|
448 RPointerArray<CFSMailMessage> messages; |
|
449 TInt gotMsgs = GetMessagesFromFolderL(messages, folder, |
|
450 EFSMsgDataSubject, EFSMailSortByDate, msgCount); |
|
451 if (gotMsgs > 0) |
|
452 { |
|
453 iLog->Log(_L(" Listing first %d emails:"), gotMsgs); |
|
454 for (TInt i = 0; i < messages.Count(); i++) |
|
455 { |
|
456 iLog->Log(_L("Found: %S"), &messages[i]->GetSubject()); |
|
457 |
|
458 if (messages[i]->GetSubject().Compare(aSubject) == 0) |
|
459 { |
|
460 iLog->Log( |
|
461 _L("Success:Email '%S' sent to own mail address"), |
|
462 &messages[i]->GetSubject()); |
|
463 aGotMsgId.SetPluginId( |
|
464 messages[i]->GetMessageId().PluginId()); |
|
465 aGotMsgId.SetId(messages[i]->GetMessageId().Id()); |
|
466 err = KErrNone; |
|
467 break; |
|
468 } |
|
469 else |
|
470 { |
|
471 err = KErrNotFound; |
|
472 } |
|
473 }//end loop: 'for' |
|
474 }//end if 'msgCount' |
|
475 else |
|
476 { |
|
477 err = KErrNotFound; |
|
478 iLog->Log(_L("No message in %S folder"), |
|
479 &folder->GetFolderName()); |
|
480 } |
|
481 messages.ResetAndDestroy(); |
|
482 }//end if 'folder' |
|
483 else |
|
484 { |
|
485 err = KErrNotFound; |
|
486 iLog->Log(_L("Folder is NOT found.(Error's ID:%d)"), err); |
|
487 } |
|
488 CleanupStack::PopAndDestroy(folder); |
|
489 }//end if: checking whether 'msg' sent or not |
|
490 }//end if 'KErrNone == err' |
|
491 return err; |
|
492 } |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CPopImapProfileTester::DoSearch |
|
495 // Method used to launches SearchL and waits for completion |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 TInt CPopImapProfileTester::DoSearch( |
|
499 const RPointerArray<TDesC>& aSearchStrings, |
|
500 const TFSMailSortCriteria& aSortCriteria, TInt aTimeout) |
|
501 { |
|
502 TInt err(KErrNone); |
|
503 if (iSearchOngoing) |
|
504 { |
|
505 iLog->Log(_L(" Error: Search in progress")); |
|
506 err = KErrInUse; |
|
507 } |
|
508 else |
|
509 { |
|
510 iIPSMailbox->ClearSearchResultCache(); |
|
511 iSearchMatches = EFalse; |
|
512 TRAP( err, iIPSMailbox->SearchL( aSearchStrings, aSortCriteria, *this ) ); |
|
513 if (KErrNone != err) |
|
514 { |
|
515 iLog->Log(_L(" Error: SearchL leaves with %d"), err); |
|
516 } |
|
517 else |
|
518 { |
|
519 iLog->Log(_L(" Searching for '%S':"), aSearchStrings[0]); |
|
520 iSearchOngoing = ETrue; |
|
521 iTimeoutTimer->Start(aTimeout * 1000000); |
|
522 iWait->Start(); |
|
523 if (iTimeout) |
|
524 { |
|
525 iLog->Log(_L(" Error: Search not completed within %d sec"), |
|
526 aTimeout); |
|
527 err = KErrTimedOut; |
|
528 } |
|
529 else |
|
530 { |
|
531 iLog->Log(_L(" Search completed with %d result(s)"), |
|
532 iSearchMatches); |
|
533 err = KErrNone; |
|
534 } |
|
535 iSearchOngoing = EFalse; |
|
536 } |
|
537 } |
|
538 return err; |
|
539 } |
|
540 // ----------------------------------------------------------------------------- |
|
541 // CPopImapProfileTester::WaitForEvent |
|
542 // Method used to wait incoming events from obsever |
|
543 // ----------------------------------------------------------------------------- |
|
544 // |
|
545 TInt CPopImapProfileTester::WaitForEvent(TFSMailEvent aWaitedEvent, |
|
546 TAny *aEventParam1, TAny *aEventParam2, TInt aTimeout) |
|
547 { |
|
548 LogEvent(_L("Waiting for Event->"), aWaitedEvent, aEventParam1, |
|
549 aEventParam2, NULL); |
|
550 iWaitingState = EWaitingEvent; |
|
551 iCurrWaitedEvent = aWaitedEvent; |
|
552 iEventParam1 = aEventParam1; |
|
553 iEventParam2 = aEventParam2; |
|
554 iTimeoutTimer->Start(aTimeout * 1000000); |
|
555 if (iWait->IsStarted() == EFalse) |
|
556 { |
|
557 iWait->Start(); |
|
558 iWaitingState = EWaitingNothing; |
|
559 iEventParam1 = NULL; |
|
560 iEventParam2 = NULL; |
|
561 if (iTimeout) |
|
562 { |
|
563 iLog->Log(_L(" Operation is timeout over %d"), aTimeout); |
|
564 iTimeout = EFalse; |
|
565 return KErrTimedOut; |
|
566 } |
|
567 else |
|
568 { |
|
569 iTimeoutTimer->Stop(); |
|
570 return KErrNone; |
|
571 } |
|
572 } |
|
573 else |
|
574 { |
|
575 iLog->Log(_L(" Stop the wait before start it")); |
|
576 return KErrGeneral; |
|
577 } |
|
578 } |
|
579 // ----------------------------------------------------------------------------- |
|
580 // CPopImapProfileTester::WaitForResponse |
|
581 // Method used to wait response from observer |
|
582 // ----------------------------------------------------------------------------- |
|
583 // |
|
584 TInt CPopImapProfileTester::WaitForResponse( |
|
585 TFSProgress::TFSProgressStatus aWaitedResponse, TInt aTimeout) |
|
586 { |
|
587 LogTFSProgress(_L("Waiting for Response->"), aWaitedResponse, 0); |
|
588 iWaitingState = EWaitingResponse; |
|
589 iCurrWaitedResponse = aWaitedResponse; |
|
590 iTimeoutTimer->Start(aTimeout * 1000000); |
|
591 if (iWait->IsStarted() == EFalse) |
|
592 { |
|
593 iWait->Start(); |
|
594 iWaitingState = EWaitingNothing; |
|
595 if (iTimeout) |
|
596 { |
|
597 iLog->Log(_L(" Operation is timeout over %d"), aTimeout); |
|
598 iTimeout = EFalse; |
|
599 return KErrTimedOut; |
|
600 } |
|
601 else |
|
602 { |
|
603 iTimeoutTimer->Stop(); |
|
604 return KErrNone; |
|
605 } |
|
606 } |
|
607 else |
|
608 return KErrGeneral; |
|
609 } |
|
610 |
|
611 void CPopImapProfileTester::OpComplete() |
|
612 { |
|
613 if (iWait) |
|
614 iWait->AsyncStop(); |
|
615 if (iTimeoutTimer) |
|
616 iTimeoutTimer->Stop(); |
|
617 } |
|
618 // ----------------------------------------------------------------------------- |
|
619 // CPopImapProfileTester::InitMailbox() |
|
620 // Method to initiate mailbxo, depends on type of account in .cfg file |
|
621 // ----------------------------------------------------------------------------- |
|
622 // |
|
623 TInt CPopImapProfileTester::InitMailboxL() |
|
624 { |
|
625 if (NULL != iIPSMailbox) |
|
626 return KErrNone; |
|
627 |
|
628 TBuf<10> accountType; |
|
629 |
|
630 //to separate type of mailbox: 'imap or pop' |
|
631 GetConstantValue(KAccountType, accountType); |
|
632 accountType.TrimAll(); |
|
633 accountType.LowerCase(); |
|
634 if (accountType.Compare(KIMAPAccount) == 0) |
|
635 iPluginId.SetPluginId(TUid::Uid(KIPSSosImap4PluginUid)); |
|
636 else if (accountType.Compare(KPOPAccount) == 0) |
|
637 { |
|
638 iPluginId.SetPluginId(TUid::Uid(KIPSSosPop3PluginUid)); |
|
639 } |
|
640 else |
|
641 { |
|
642 iLog->Log(_L("Wrong mailbox type %S"), &accountType); |
|
643 return KErrGeneral; |
|
644 } |
|
645 |
|
646 //to create mail |
|
647 RPointerArray<CFSMailBox> mailboxes; |
|
648 iMailClient->ListMailBoxes(iPluginId, mailboxes); |
|
649 if (mailboxes.Count() > 0) |
|
650 { |
|
651 iIPSMailbox = iMailClient->GetMailBoxByUidL(mailboxes[0]->GetId()); |
|
652 //to subscribe mailbox's event,remember to unsubscribe |
|
653 iMailClient->SubscribeMailboxEventsL(iIPSMailbox->GetId(), *this); |
|
654 iLog->Log(_L("%S mailbox was found"), &accountType); |
|
655 } |
|
656 else |
|
657 { |
|
658 iLog->Log(_L("%S mailbox was not found"), &accountType); |
|
659 } |
|
660 mailboxes.ResetAndDestroy(); |
|
661 |
|
662 return KErrNone; |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // CPopImapProfileTester::MoveMessageToFolderL |
|
667 // Method used to move messages to a specific folder |
|
668 // ----------------------------------------------------------------------------- |
|
669 // |
|
670 TInt CPopImapProfileTester::MoveMessageToFolderL(CFSMailMessage& aMsg, |
|
671 TFSFolderType aFolderType) |
|
672 { |
|
673 // check if msg is not in given folder already |
|
674 TInt err(KErrNone); |
|
675 TFSMailMsgId folderId = iIPSMailbox->GetStandardFolderId(aFolderType); |
|
676 TFSMailMsgId msgFolderId = aMsg.GetFolderId(); |
|
677 if (folderId != msgFolderId) |
|
678 { |
|
679 // move message |
|
680 RArray<TFSMailMsgId> msgs; |
|
681 CleanupClosePushL(msgs); |
|
682 msgs.Append(aMsg.GetMessageId()); |
|
683 TRAP(err, iIPSMailbox->MoveMessagesL( msgs, msgFolderId, folderId )); |
|
684 msgs.Reset(); |
|
685 CleanupStack::PopAndDestroy(&msgs); |
|
686 } |
|
687 return err; |
|
688 } |
|
689 // ----------------------------------------------------------------------------- |
|
690 // CPopImapProfileTester::CreatePlainTextMsgL |
|
691 // Info: Creates defalult msg with plain text body part in 'Drafts' folder |
|
692 // with own mail address in 'To' recipient |
|
693 // Params: DesC& aSubject, subject text |
|
694 // TDesC& aMsgBodyText, message body text ( max. 256 chars ) |
|
695 // ----------------------------------------------------------------------------- |
|
696 // |
|
697 CFSMailMessage* CPopImapProfileTester::CreatePlainTextMsgL( |
|
698 const TDesC& aSubject, const TDesC& aMsgBodyText) |
|
699 { |
|
700 TInt err(KErrNone); |
|
701 CFSMailMessage* newMsg(NULL); |
|
702 CFSMailMessagePart* newMsgPart(NULL); |
|
703 |
|
704 newMsg = iIPSMailbox->CreateMessageToSend(); |
|
705 if (NULL != newMsg) |
|
706 { |
|
707 CleanupStack::PushL(newMsg); |
|
708 // add subject |
|
709 newMsg->SetSubject(aSubject); |
|
710 |
|
711 // add default sender address |
|
712 CFSMailAddress* senderAddr = CFSMailAddress::NewL(); |
|
713 senderAddr->SetEmailAddress(_L("stif.testcase@stif.com")); |
|
714 newMsg->SetSender(senderAddr); |
|
715 // senderAddr - do not delete it, ownership transferred from user |
|
716 |
|
717 // add default To recipient ( own mail address ) |
|
718 CFSMailAddress* toAddr = CFSMailAddress::NewL(); |
|
719 toAddr->SetEmailAddress(iIPSMailbox->OwnMailAddress().GetEmailAddress()); |
|
720 newMsg->AppendToRecipient(toAddr); |
|
721 // toAddr - do not delete it, ownership transferred from user |
|
722 |
|
723 // assert: move message to Drafts ( it should be already in Drafts ) |
|
724 err = MoveMessageToFolderL(*newMsg, EFSDraftsFolder); |
|
725 if (KErrNone == err) |
|
726 { |
|
727 newMsg->SetContentType(KFSMailContentTypeMultipartMixed); |
|
728 newMsg->SaveMessageL(); |
|
729 newMsgPart = newMsg->PlainTextBodyPartL(); |
|
730 if (NULL == newMsgPart) |
|
731 { |
|
732 newMsgPart = newMsg->NewChildPartL(TFSMailMsgId(), |
|
733 KFSMailContentTypeTextPlain); |
|
734 } |
|
735 if (NULL != newMsgPart) |
|
736 { |
|
737 CleanupStack::PushL(newMsgPart); |
|
738 TBuf<256> buf(aMsgBodyText); |
|
739 newMsgPart->SetContent(buf); |
|
740 newMsgPart->SetContentSize(buf.Length()); |
|
741 newMsgPart->SetFetchedContentSize(buf.Length()); |
|
742 newMsgPart->SaveL(); |
|
743 CleanupStack::PopAndDestroy(newMsgPart); |
|
744 } |
|
745 else |
|
746 { |
|
747 iLog->Log(_L( "Error: Failed to create msg part" )); |
|
748 err = KErrNoMemory; |
|
749 } |
|
750 }//end if 'KErrNone == err' |
|
751 else |
|
752 { |
|
753 iLog->Log(_L( "Error: Failed to move new msg to Drafts folder" )); |
|
754 } |
|
755 CleanupStack::Pop(newMsg); |
|
756 }//end if 'NULL != newMsg' |
|
757 else |
|
758 { |
|
759 iLog->Log(_L( " Error: Failed to create new msg" )); |
|
760 err = KErrNoMemory; |
|
761 } |
|
762 return newMsg; |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // CPopImapProfileTester::ReadAccountSettings() |
|
767 // Method used to read setting data from .cfg file |
|
768 // ----------------------------------------------------------------------------- |
|
769 // |
|
770 TInt CPopImapProfileTester::ReadAccountSettings( |
|
771 TAccountSetting& aAccountSetting) |
|
772 { |
|
773 TInt err(KErrNone); |
|
774 err = GetConstantValue(KSetupWizAccountType, aAccountSetting.iAccountType); |
|
775 aAccountSetting.iAccountType.TrimAll(); |
|
776 aAccountSetting.iAccountType.LowerCase(); |
|
777 if (aAccountSetting.iAccountType.Compare(KIMAPAccount) == 0) |
|
778 { |
|
779 aAccountSetting.iProtocolIndicator = 1; |
|
780 } |
|
781 else if (aAccountSetting.iAccountType.Compare(KPOPAccount) == 0) |
|
782 { |
|
783 aAccountSetting.iProtocolIndicator = 0; |
|
784 } |
|
785 else |
|
786 { |
|
787 iLog->Log(_L("Wrong Account Type %S, "), &aAccountSetting.iAccountType); |
|
788 return KErrNotFound; |
|
789 } |
|
790 err = GetConstantValue(KSetupWizAccountsConfigured, |
|
791 aAccountSetting.iAccountsConfigured); |
|
792 err = GetConstantValue(KSetupWizMaxAccountsReached, |
|
793 aAccountSetting.iMaxAccountsReached); |
|
794 err |
|
795 = GetConstantValue(KSetupWizEmailAddress, |
|
796 aAccountSetting.iEmailAddress); |
|
797 err = GetConstantValue(KSetupWizUsername, aAccountSetting.iUserName); |
|
798 err = GetConstantValue(KSetupWizPassword, aAccountSetting.iPassWord); |
|
799 err = GetConstantValue(KSetupWizMailboxName, aAccountSetting.iMailboxName); |
|
800 err = GetConstantValue(KSetupWizIncomingServer, |
|
801 aAccountSetting.iIncomingServer); |
|
802 err = GetConstantValue(KSetupWizOutgoingServer, |
|
803 aAccountSetting.iOutgoingServer); |
|
804 err |
|
805 = GetConstantValue(KSetupWizIncomingPort, |
|
806 aAccountSetting.iIncomingPort); |
|
807 err |
|
808 = GetConstantValue(KSetupWizOutgoingPort, |
|
809 aAccountSetting.iOutgoingPort); |
|
810 |
|
811 err = GetConstantValue(KSetupWizIncomingSecurityAuth, |
|
812 aAccountSetting.iIncomingSecurityAuth); |
|
813 err = GetConstantValue(KSetupWizOutgoingSecurityAuth, |
|
814 aAccountSetting.iOutgoingSecurityAuth); |
|
815 err = GetConstantValue(KSetupWizIncomingSecurityProtocol, |
|
816 aAccountSetting.iIncomingSecurityProtocol); |
|
817 err = GetConstantValue(KSetupWizOutgoingSecurityProtocol, |
|
818 aAccountSetting.iOutgoingSecurityProtocol); |
|
819 err = GetConstantValue(KSetupWizOperatorSecurityAuth, |
|
820 aAccountSetting.iOperatorSecurityAuth); |
|
821 err = GetConstantValue(KSetupWizOperatorSecurityProtocol, |
|
822 aAccountSetting.iOperatorSecurityProtocol); |
|
823 err |
|
824 = GetConstantValue(KSetupWizOperatorPort, |
|
825 aAccountSetting.iOperatorPort); |
|
826 |
|
827 aAccountSetting.iWizardAccountType = KWizAccountTypeDefault; |
|
828 aAccountSetting.iOperatorOutgoingServer = KNullDesC; |
|
829 aAccountSetting.iHideUserNameInSetting = ETrue; |
|
830 aAccountSetting.iAccessPoint = KNullDesC; |
|
831 |
|
832 return err; |
|
833 } |
|
834 |
|
835 // ----------------------------------------------------------------------------- |
|
836 // CPopImapProfileTester::WriteToWizardCRL |
|
837 // Prepare data for profile settings |
|
838 // write configuration settings to cenrep, just like SW6 would do |
|
839 // ----------------------------------------------------------------------------- |
|
840 // |
|
841 TInt CPopImapProfileTester::WriteToWizardCRL(TAccountSetting aAccountSetting) |
|
842 { |
|
843 TInt err(KErrNone); |
|
844 TUint32 keyInfo; |
|
845 CRepository* rep = CRepository::NewLC(KCRUidWizardSettings); |
|
846 err = rep->StartTransaction(CRepository::EConcurrentReadWriteTransaction); |
|
847 iLog->Log(_L( "== Start a transaction in SetupAccount ==" )); |
|
848 if (KErrNone == err) |
|
849 { |
|
850 err = rep->Set(ECRKSetupWizAccountType, |
|
851 aAccountSetting.iWizardAccountType); |
|
852 err = rep->Set(ECRKAccountsConfigured, |
|
853 aAccountSetting.iAccountsConfigured); |
|
854 err = rep->Set(ECRKMaxAccountsReached, |
|
855 aAccountSetting.iMaxAccountsReached); |
|
856 err = rep->Set(ECRKPopImapEmailAddressId, |
|
857 aAccountSetting.iEmailAddress); |
|
858 err = rep->Set(ECRKPopImapUsernameId, aAccountSetting.iUserName); |
|
859 err = rep->Set(ECRKPopImapPasswordId, aAccountSetting.iPassWord); |
|
860 err = rep->Set(ECRKPopImapIncomingServerId, |
|
861 aAccountSetting.iIncomingServer); |
|
862 err = rep->Set(ECRKPopImapOutgoingServerId, |
|
863 aAccountSetting.iOutgoingServer); |
|
864 err = rep->Set(ECRKPopImapProtocolIndicatorId, |
|
865 aAccountSetting.iProtocolIndicator); |
|
866 err = rep->Set(ECRKPopImapIncomingPortId, |
|
867 aAccountSetting.iIncomingPort); |
|
868 err = rep->Set(ECRKPopImapOutgoingPortId, |
|
869 aAccountSetting.iOutgoingPort); |
|
870 err = rep->Set(ECRKPopImapIncomingSecurityAuthId, |
|
871 aAccountSetting.iIncomingSecurityAuth); |
|
872 err = rep->Set(ECRKPopImapIncomingSecurityProtocolId, |
|
873 aAccountSetting.iIncomingSecurityProtocol); |
|
874 err = rep->Set(ECRKPopImapOutgoingSecurityAuthId, |
|
875 aAccountSetting.iOutgoingSecurityAuth); |
|
876 err = rep->Set(ECRKPopImapOutgoingSecurityProtocolId, |
|
877 aAccountSetting.iOutgoingSecurityProtocol); |
|
878 err = rep->Set(ECRKPopImapOperatorOutgoingServerId, |
|
879 aAccountSetting.iOperatorOutgoingServer); |
|
880 err = rep->Set(ECRKPopImapOperatorSecurityAuthId, |
|
881 aAccountSetting.iOperatorSecurityAuth); |
|
882 err = rep->Set(ECRKPopImapOperatorSecurityProtocolId, |
|
883 aAccountSetting.iOperatorSecurityProtocol); |
|
884 err = rep->Set(ECRKPopImapOperatorPortId, |
|
885 aAccountSetting.iOperatorPort); |
|
886 err = rep->Set(ECRKHideUsernameInSettings, |
|
887 aAccountSetting.iHideUserNameInSetting); // 1 = ETrue if there are some field that should be hidden from ui |
|
888 err = rep->Set(ECRKPopImapAccessPointId, aAccountSetting.iAccessPoint); |
|
889 err = rep->Set(ECRKPopImapMailboxName, aAccountSetting.iMailboxName); |
|
890 iLog->Log(_L( "==Error:=%d" ), err); |
|
891 |
|
892 err = rep->CommitTransaction(keyInfo); |
|
893 if (KErrLocked == err || KErrAbort == err || KErrNone != err) |
|
894 { |
|
895 rep->CancelTransaction(); |
|
896 iLog->Log( |
|
897 _L( "== Error occurs in transaction processed in SetupAccount=%d" ), |
|
898 err); |
|
899 } |
|
900 } |
|
901 else |
|
902 { |
|
903 rep->CancelTransaction(); |
|
904 iLog->Log(_L( "== The transaction was canceled in SetupAccount=%d" ), |
|
905 err); |
|
906 } |
|
907 CleanupStack::PopAndDestroy(rep); |
|
908 return err; |
|
909 } |
|
910 |
|
911 // ----------------------------------------------------------------------------- |
|
912 // CPopImapProfileTester::LogEvent |
|
913 // Method used to print log about event |
|
914 // ----------------------------------------------------------------------------- |
|
915 // |
|
916 void CPopImapProfileTester::LogEvent(const TDesC& aLogText, |
|
917 TFSMailEvent aEvent, TAny* aParam1, TAny* aParam2, TAny* aParam3) |
|
918 { |
|
919 TBuf<256> log(aLogText); |
|
920 |
|
921 switch (aEvent) |
|
922 { |
|
923 // Mailbox is unavailable |
|
924 // params NULL |
|
925 case TFSMailboxUnavailable: |
|
926 log.Append(_L("MailboxUnavailable")); |
|
927 break; |
|
928 |
|
929 // Mailbox is available |
|
930 // params NULL |
|
931 case TFSMailboxAvailable: |
|
932 log.Append(_L( "MailboxAvailable" )); |
|
933 break; |
|
934 |
|
935 // New mailbox created |
|
936 // params NULL |
|
937 case TFSEventNewMailbox: |
|
938 log.Append(_L( "NewMailbox" )); |
|
939 break; |
|
940 |
|
941 // New mailbox creation failure |
|
942 // params NULL |
|
943 case TFSEventMailboxCreationFailure: |
|
944 log.Append(_L( "MailboxCreationFailure" )); |
|
945 break; |
|
946 |
|
947 // Mailbox renamed |
|
948 // params NULL |
|
949 case TFSEventMailboxRenamed: |
|
950 log.Append(_L( "MailboxRenamed" )); |
|
951 break; |
|
952 |
|
953 // Mailbox deleted |
|
954 // params NULL |
|
955 case TFSEventMailboxDeleted: |
|
956 log.Append(_L( "MailboxDeleted" )); |
|
957 break; |
|
958 |
|
959 // |
|
960 // Following events need to be subscribed per mailbox |
|
961 // |
|
962 |
|
963 // Mailbox capability changed |
|
964 // params NULL |
|
965 case TFSEventMailboxCapabilityChanged: |
|
966 log.Append(_L( "MailboxCapabilityChanged" )); |
|
967 break; |
|
968 |
|
969 // Mailbox settings changed |
|
970 // params NULL |
|
971 case TFSEventMailboxSettingsChanged: |
|
972 log.Append(_L( "MailboxSettingsChanged" )); |
|
973 break; |
|
974 |
|
975 // Mailbox went online |
|
976 // params NULL |
|
977 case TFSEventMailboxOnline: |
|
978 log.Append(_L( "MailboxOnline" )); |
|
979 break; |
|
980 |
|
981 // Mailbox went offline |
|
982 // params NULL |
|
983 case TFSEventMailboxOffline: |
|
984 log.Append(_L( "MailboxOffline" )); |
|
985 break; |
|
986 |
|
987 // Mailbox sync state changed |
|
988 // aParam1: TSSMailSyncState* newState |
|
989 // aParam2: NULL |
|
990 // aParam3: NULL |
|
991 case TFSEventMailboxSyncStateChanged: |
|
992 { |
|
993 TSSMailSyncState state = *((TSSMailSyncState*) aParam1); |
|
994 log.Append(_L( "SyncStateChanged" )); |
|
995 switch (state) |
|
996 { |
|
997 case Idle: |
|
998 log.Append(_L("(Idle)")); |
|
999 break; |
|
1000 case StartingSync: |
|
1001 log.Append(_L("(StartingSync)")); |
|
1002 break; |
|
1003 case DataSyncStarting: |
|
1004 log.Append(_L("(DataSyncStarting)")); |
|
1005 break; |
|
1006 case EmailSyncing: |
|
1007 log.Append(_L("(EmailSyncing)")); |
|
1008 break; |
|
1009 case InboxSyncing: |
|
1010 log.Append(_L("(InboxSyncing)")); |
|
1011 break; |
|
1012 case OutboxSyncing: |
|
1013 log.Append(_L("(OutboxSyncing)")); |
|
1014 break; |
|
1015 case SentItemsSyncing: |
|
1016 log.Append(_L("(SentItemsSyncing)")); |
|
1017 break; |
|
1018 case DraftsSyncing: |
|
1019 log.Append(_L("(DraftsSyncing)")); |
|
1020 break; |
|
1021 case CalendarSyncing: |
|
1022 log.Append(_L("(CalendarSyncing)")); |
|
1023 break; |
|
1024 case ContactsSyncing: |
|
1025 log.Append(_L("(ContactsSyncing)")); |
|
1026 break; |
|
1027 case TasksSyncing: |
|
1028 log.Append(_L("(TasksSyncing)")); |
|
1029 break; |
|
1030 case NotesSyncing: |
|
1031 log.Append(_L("(NotesSyncing)")); |
|
1032 break; |
|
1033 case FilesSyncing: |
|
1034 log.Append(_L("(FilesSyncing)")); |
|
1035 break; |
|
1036 case FinishedSuccessfully: |
|
1037 log.Append(_L("(FinishedSuccessfully)")); |
|
1038 break; |
|
1039 case SyncError: |
|
1040 log.Append(_L("(SyncError)")); |
|
1041 break; |
|
1042 case SyncCancelled: |
|
1043 log.Append(_L("(SyncCancelled)")); |
|
1044 break; |
|
1045 case PasswordExpiredError: |
|
1046 log.Append(_L("(PasswordExpiredError)")); |
|
1047 break; |
|
1048 case PasswordVerified: |
|
1049 log.Append(_L("(PasswordVerified)")); |
|
1050 break; |
|
1051 case PasswordNotVerified: |
|
1052 log.Append(_L("(PasswordNotVerified)")); |
|
1053 break; |
|
1054 case PushChannelOff: |
|
1055 log.Append(_L("(PushChannelOff)")); |
|
1056 break; |
|
1057 case PushChannelEstablished: |
|
1058 log.Append(_L("(PushChannelEstablished)")); |
|
1059 break; |
|
1060 case PushChannelOffBecauseBatteryIsLow: |
|
1061 log.Append(_L("(PushChannelOffBecauseBatteryIsLow)")); |
|
1062 break; |
|
1063 case OutOfDiskSpace: |
|
1064 log.Append(_L("(OutOfDiskSpace)")); |
|
1065 break; |
|
1066 default: |
|
1067 log.Append(_L("( no description )")); |
|
1068 } |
|
1069 } |
|
1070 break; |
|
1071 |
|
1072 // New mails created |
|
1073 // aParam1: RArray<TFSMailMsgId>* aNewEntries |
|
1074 // aParam2: TFSMailMsgId* aParentFolder |
|
1075 // aParam3: NULL |
|
1076 case TFSEventNewMail: |
|
1077 log.Append(_L( "NewEmail" )); |
|
1078 if (aParam1) |
|
1079 { |
|
1080 RArray<TFSMailMsgId>* newEntries = static_cast<RArray< |
|
1081 TFSMailMsgId>*> (aParam1); |
|
1082 TInt newEntriesCount = newEntries->Count(); |
|
1083 log.AppendFormat(_L("(%d)"), newEntriesCount); |
|
1084 } |
|
1085 if (aParam2) |
|
1086 { |
|
1087 TFSMailMsgId* parentFolder = |
|
1088 static_cast<TFSMailMsgId*> (aParam2); |
|
1089 TBuf<20> folderName; |
|
1090 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1091 { |
|
1092 log.Append(folderName); |
|
1093 } |
|
1094 } |
|
1095 break; |
|
1096 |
|
1097 // Mails changed |
|
1098 // aParam1: RArray<TFSMailMsgId>* aEntries |
|
1099 // aParam2: TFSMailMsgId* aParentFolder |
|
1100 // aParam3: NULL |
|
1101 case TFSEventMailChanged: |
|
1102 log.Append(_L( "MailChanged" )); |
|
1103 if (aParam1) |
|
1104 { |
|
1105 RArray<TFSMailMsgId>* newEntries = static_cast<RArray< |
|
1106 TFSMailMsgId>*> (aParam1); |
|
1107 TInt newEntriesCount = newEntries->Count(); |
|
1108 log.AppendFormat(_L("(%d)"), newEntriesCount); |
|
1109 } |
|
1110 if (aParam2) |
|
1111 { |
|
1112 TFSMailMsgId* parentFolder = |
|
1113 static_cast<TFSMailMsgId*> (aParam2); |
|
1114 TBuf<20> folderName; |
|
1115 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1116 { |
|
1117 log.Append(folderName); |
|
1118 } |
|
1119 } |
|
1120 break; |
|
1121 |
|
1122 // Mails deleted |
|
1123 // aParam1: RArray<TFSMailMsgId>* aEntries |
|
1124 // aParam2: TFSMailMsgId* aParentFolder |
|
1125 // aParam3: NULL |
|
1126 case TFSEventMailDeleted: |
|
1127 log.Append(_L( "MailDeleted" )); |
|
1128 if (aParam1) |
|
1129 { |
|
1130 RArray<TFSMailMsgId>* newEntries = static_cast<RArray< |
|
1131 TFSMailMsgId>*> (aParam1); |
|
1132 TInt newEntriesCount = newEntries->Count(); |
|
1133 log.AppendFormat(_L("(%d)"), newEntriesCount); |
|
1134 } |
|
1135 if (aParam2) |
|
1136 { |
|
1137 TFSMailMsgId* parentFolder = |
|
1138 static_cast<TFSMailMsgId*> (aParam2); |
|
1139 TBuf<20> folderName; |
|
1140 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1141 { |
|
1142 log.Append(folderName); |
|
1143 } |
|
1144 } |
|
1145 break; |
|
1146 |
|
1147 // Mails moved |
|
1148 // aParam1: RArray<TFSMailMsgId>* aEntries |
|
1149 // aParam2: TFSMailMsgId* aNewParentFolder |
|
1150 // aParam3: TFSMailMsgId* aOldParentFolder |
|
1151 case TFSEventMailMoved: |
|
1152 log.Append(_L( "MailMoved" )); |
|
1153 if (aParam1) |
|
1154 { |
|
1155 RArray<TFSMailMsgId>* newEntries = static_cast<RArray< |
|
1156 TFSMailMsgId>*> (aParam1); |
|
1157 TInt newEntriesCount = newEntries->Count(); |
|
1158 log.AppendFormat(_L("(%d)"), newEntriesCount); |
|
1159 } |
|
1160 if (aParam2) |
|
1161 { |
|
1162 TFSMailMsgId* parentFolder = |
|
1163 static_cast<TFSMailMsgId*> (aParam2); |
|
1164 TBuf<20> folderName; |
|
1165 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1166 { |
|
1167 log.Append(_L("---")); |
|
1168 log.Append(folderName); |
|
1169 } |
|
1170 } |
|
1171 if (aParam3) |
|
1172 { |
|
1173 TFSMailMsgId* parentFolder = |
|
1174 static_cast<TFSMailMsgId*> (aParam3); |
|
1175 TBuf<20> folderName; |
|
1176 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1177 { |
|
1178 log.Append(folderName); |
|
1179 } |
|
1180 } |
|
1181 break; |
|
1182 |
|
1183 // Mails copied |
|
1184 // aParam1: RArray<TFSMailMsgId>* aNewEntries |
|
1185 // aParam2: TFSMailMsgId* aNewParentFolder |
|
1186 // aParam3: TFSMailMsgId* aOldParentFolder |
|
1187 case TFSEventMailCopied: |
|
1188 log.Append(_L( "MailCopied" )); |
|
1189 break; |
|
1190 |
|
1191 // New folders created |
|
1192 // aParam1: RArray<TFSMailMsgId>* aNewEntries |
|
1193 // aParam2: TFSMailMsgId* aParentFolder |
|
1194 // aParam3: NULL |
|
1195 case TFSEventNewFolder: |
|
1196 log.Append(_L( "NewFolder" )); |
|
1197 if (aParam1) |
|
1198 { |
|
1199 RArray<TFSMailMsgId>* newEntries = static_cast<RArray< |
|
1200 TFSMailMsgId>*> (aParam1); |
|
1201 TInt newEntriesCount = newEntries->Count(); |
|
1202 log.AppendFormat(_L("(%d)"), newEntriesCount); |
|
1203 } |
|
1204 if (aParam2) |
|
1205 { |
|
1206 TFSMailMsgId* parentFolder = |
|
1207 static_cast<TFSMailMsgId*> (aParam2); |
|
1208 TBuf<20> folderName; |
|
1209 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1210 { |
|
1211 log.Append(folderName); |
|
1212 } |
|
1213 } |
|
1214 break; |
|
1215 |
|
1216 // Folders changed |
|
1217 // aParam1: RArray<TFSMailMsgId>* aEntries |
|
1218 // aParam2: TFSMailMsgId* aParentFolder |
|
1219 // aParam3: NULL |
|
1220 case TFSEventFolderChanged: |
|
1221 log.Append(_L( "FolderChanged" )); |
|
1222 if (aParam1) |
|
1223 { |
|
1224 RArray<TFSMailMsgId>* newEntries = static_cast<RArray< |
|
1225 TFSMailMsgId>*> (aParam1); |
|
1226 TInt newEntriesCount = newEntries->Count(); |
|
1227 log.AppendFormat(_L("(%d)"), newEntriesCount); |
|
1228 } |
|
1229 if (aParam2) |
|
1230 { |
|
1231 TFSMailMsgId* parentFolder = |
|
1232 static_cast<TFSMailMsgId*> (aParam2); |
|
1233 TBuf<20> folderName; |
|
1234 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1235 { |
|
1236 log.Append(folderName); |
|
1237 } |
|
1238 } |
|
1239 break; |
|
1240 |
|
1241 // Folders deleted |
|
1242 // aParam1: RArray<TFSMailMsgId>* aEntries |
|
1243 // aParam2: TFSMailMsgId* aParentFolder |
|
1244 // aParam3: NULL |
|
1245 case TFSEventFoldersDeleted: |
|
1246 log.Append(_L( "FoldersDeleted" )); |
|
1247 if (aParam1) |
|
1248 { |
|
1249 RArray<TFSMailMsgId>* newEntries = static_cast<RArray< |
|
1250 TFSMailMsgId>*> (aParam1); |
|
1251 TInt newEntriesCount = newEntries->Count(); |
|
1252 log.AppendFormat(_L("(%d)"), newEntriesCount); |
|
1253 } |
|
1254 if (aParam2) |
|
1255 { |
|
1256 TFSMailMsgId* parentFolder = |
|
1257 static_cast<TFSMailMsgId*> (aParam2); |
|
1258 TBuf<20> folderName; |
|
1259 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1260 { |
|
1261 log.Append(folderName); |
|
1262 } |
|
1263 } |
|
1264 break; |
|
1265 |
|
1266 // Folders moved |
|
1267 // aParam1: RArray<TFSMailMsgId>* aEntries |
|
1268 // aParam2: TFSMailMsgId* aNewParentFolder |
|
1269 // aParam3: TFSMailMsgId* aOldParentFolder |
|
1270 case TFSEventFoldersMoved: |
|
1271 log.Append(_L( "FoldersMoved" )); |
|
1272 break; |
|
1273 |
|
1274 // exception / error happened |
|
1275 // aParam1: TInt (TFsEmailNotifierSystemMessageType) aEventType |
|
1276 // aParam2: TDesC* aCustomMessage or NULL (optional) |
|
1277 // aParam3: MFSMailExceptionEventCallback* aCallback or NULL(optional) |
|
1278 case TFSEventException: |
|
1279 { |
|
1280 log.Append(_L( "Exception " )); |
|
1281 } |
|
1282 break; |
|
1283 |
|
1284 // Mail deleted from viewer |
|
1285 // aParam1: RArray<TFSMailMsgId>* aEntries |
|
1286 // aParam2: TFSMailMsgId* aParentFolder |
|
1287 // aParam3: NULL |
|
1288 case TFSEventMailDeletedFromViewer: |
|
1289 log.Append(_L( "MailDeletedFromViewer" )); |
|
1290 if (aParam1) |
|
1291 { |
|
1292 RArray<TFSMailMsgId>* newEntries = static_cast<RArray< |
|
1293 TFSMailMsgId>*> (aParam1); |
|
1294 TInt newEntriesCount = newEntries->Count(); |
|
1295 log.AppendFormat(_L("(%d)"), newEntriesCount); |
|
1296 } |
|
1297 if (aParam2) |
|
1298 { |
|
1299 TFSMailMsgId* parentFolder = |
|
1300 static_cast<TFSMailMsgId*> (aParam2); |
|
1301 TBuf<20> folderName; |
|
1302 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName)) |
|
1303 { |
|
1304 log.Append(folderName); |
|
1305 } |
|
1306 } |
|
1307 break; |
|
1308 |
|
1309 default: |
|
1310 log.Append(_L( "Unknown" )); |
|
1311 break; |
|
1312 } |
|
1313 iLog->Log(log); |
|
1314 } |
|
1315 |
|
1316 // ----------------------------------------------------------------------------- |
|
1317 // CPopImapProfileTester::LogTFSProgress |
|
1318 // Method used to print logs about TFSProgress state |
|
1319 // ----------------------------------------------------------------------------- |
|
1320 // |
|
1321 void CPopImapProfileTester::LogTFSProgress(const TDesC& aLogText, |
|
1322 const TFSProgress::TFSProgressStatus aProgress, TInt aReqId) |
|
1323 { |
|
1324 TBuf<100> log(aLogText); |
|
1325 if (aReqId >= 0) |
|
1326 { |
|
1327 log.AppendFormat(_L("%d-"), aReqId); |
|
1328 } |
|
1329 |
|
1330 switch (aProgress) |
|
1331 { |
|
1332 case TFSProgress::EFSStatus_Waiting: |
|
1333 log.Append(_L("Waiting")); |
|
1334 break; |
|
1335 |
|
1336 case TFSProgress::EFSStatus_Started: |
|
1337 log.Append(_L("Started")); |
|
1338 break; |
|
1339 |
|
1340 case TFSProgress::EFSStatus_Connecting: |
|
1341 log.Append(_L("Connecting")); |
|
1342 break; |
|
1343 |
|
1344 case TFSProgress::EFSStatus_Connected: |
|
1345 log.Append(_L("Connected")); |
|
1346 break; |
|
1347 |
|
1348 case TFSProgress::EFSStatus_Authenticating: |
|
1349 log.Append(_L("Authenticating")); |
|
1350 break; |
|
1351 |
|
1352 case TFSProgress::EFSStatus_Authenticated: |
|
1353 log.Append(_L("Authenticated")); |
|
1354 break; |
|
1355 |
|
1356 case TFSProgress::EFSStatus_Status: |
|
1357 log.Append(_L("Status")); |
|
1358 break; |
|
1359 |
|
1360 case TFSProgress::EFSStatus_RequestComplete: |
|
1361 log.Append(_L("Complete")); |
|
1362 break; |
|
1363 |
|
1364 case TFSProgress::EFSStatus_RequestCancelled: |
|
1365 log.Append(_L("Cancelled")); |
|
1366 break; |
|
1367 |
|
1368 default: |
|
1369 log.Append(_L("UnknownStatus")); |
|
1370 } |
|
1371 iLog->Log(log); |
|
1372 } |
|
1373 |
|
1374 // ----------------------------------------------------------------------------- |
|
1375 // CPopImapProfileTester::LogTSSMailSyncState |
|
1376 // Method used to print logs about TSSMailSyncState state |
|
1377 // ----------------------------------------------------------------------------- |
|
1378 // |
|
1379 void CPopImapProfileTester::LogTSSMailSyncState(const TDesC& aLogText, |
|
1380 const TSSMailSyncState aState) |
|
1381 { |
|
1382 TBuf<100> log(aLogText); |
|
1383 switch (aState) |
|
1384 { |
|
1385 case Idle: |
|
1386 log.Append(_L("Idle")); |
|
1387 break; |
|
1388 |
|
1389 case StartingSync: |
|
1390 log.Append(_L("StartingSync")); |
|
1391 break; |
|
1392 |
|
1393 case DataSyncStarting: |
|
1394 log.Append(_L("DataSyncStarting")); |
|
1395 break; |
|
1396 |
|
1397 case EmailSyncing: |
|
1398 log.Append(_L("EmailSyncing")); |
|
1399 break; |
|
1400 |
|
1401 case InboxSyncing: |
|
1402 log.Append(_L("InboxSyncing")); |
|
1403 break; |
|
1404 |
|
1405 case OutboxSyncing: |
|
1406 log.Append(_L("OutboxSyncing")); |
|
1407 break; |
|
1408 |
|
1409 case SentItemsSyncing: |
|
1410 log.Append(_L("SentItemsSyncing")); |
|
1411 break; |
|
1412 |
|
1413 case DraftsSyncing: |
|
1414 log.Append(_L("DraftsSyncing")); |
|
1415 break; |
|
1416 |
|
1417 case CalendarSyncing: |
|
1418 log.Append(_L("CalendarSyncing")); |
|
1419 break; |
|
1420 |
|
1421 case ContactsSyncing: |
|
1422 log.Append(_L("ContactsSyncing")); |
|
1423 break; |
|
1424 |
|
1425 case TasksSyncing: |
|
1426 log.Append(_L("TasksSyncing")); |
|
1427 break; |
|
1428 |
|
1429 case NotesSyncing: |
|
1430 log.Append(_L("NotesSyncing")); |
|
1431 break; |
|
1432 |
|
1433 case FilesSyncing: |
|
1434 log.Append(_L("FilesSyncing")); |
|
1435 break; |
|
1436 |
|
1437 case FinishedSuccessfully: |
|
1438 log.Append(_L("FinishedSuccessfully")); |
|
1439 break; |
|
1440 |
|
1441 case SyncError: |
|
1442 log.Append(_L("SyncError")); |
|
1443 break; |
|
1444 |
|
1445 case SyncCancelled: |
|
1446 log.Append(_L("SyncCancelled")); |
|
1447 break; |
|
1448 |
|
1449 case PasswordExpiredError: |
|
1450 log.Append(_L("PasswordExpiredError")); |
|
1451 break; |
|
1452 |
|
1453 case PasswordVerified: |
|
1454 log.Append(_L("PasswordVerified")); |
|
1455 break; |
|
1456 |
|
1457 case PasswordNotVerified: |
|
1458 log.Append(_L("PasswordNotVerified")); |
|
1459 break; |
|
1460 |
|
1461 case PushChannelOff: |
|
1462 log.Append(_L("PushChannelOff")); |
|
1463 break; |
|
1464 |
|
1465 case PushChannelEstablished: |
|
1466 log.Append(_L("PushChannelEstablished")); |
|
1467 break; |
|
1468 |
|
1469 case PushChannelOffBecauseBatteryIsLow: |
|
1470 log.Append(_L("PushChannelOffBecauseBatteryIsLow")); |
|
1471 break; |
|
1472 |
|
1473 case OutOfDiskSpace: |
|
1474 log.Append(_L("OutOfDiskSpace")); |
|
1475 break; |
|
1476 } |
|
1477 iLog->Log(log); |
|
1478 } |
|
1479 |
|
1480 // ----------------------------------------------------------------------------- |
|
1481 // CPopImapProfileTester::GetFolderNameFromId |
|
1482 // Method used to get name of folder with given ID |
|
1483 // ----------------------------------------------------------------------------- |
|
1484 // |
|
1485 TInt CPopImapProfileTester::GetFolderNameFromId(TFSMailMsgId aFolderId, |
|
1486 TDes& aFolderName) |
|
1487 { |
|
1488 RPointerArray<CFSMailFolder>& folders = iIPSMailbox->ListFolders(); |
|
1489 TInt err(KErrNotFound); |
|
1490 for (TInt i = 0; i < folders.Count(); i++) |
|
1491 { |
|
1492 if (folders[i]->GetFolderId() == aFolderId) |
|
1493 { |
|
1494 aFolderName = folders[i]->GetFolderName(); |
|
1495 err = KErrNone; |
|
1496 break; |
|
1497 } |
|
1498 } |
|
1499 return err; |
|
1500 } |
|
1501 |
|
1502 // ----------------------------------------------------------------------------- |
|
1503 // CPopImapProfileTester::GetFolderIdFromName |
|
1504 // Method used to get ID of folder with given name |
|
1505 // ----------------------------------------------------------------------------- |
|
1506 // |
|
1507 TFSMailMsgId CPopImapProfileTester::GetFolderIdFromName( |
|
1508 const TDesC& aFolderName) |
|
1509 { |
|
1510 TBuf<10> bufFolderName(aFolderName); |
|
1511 TFSMailMsgId folderId; |
|
1512 |
|
1513 bufFolderName.TrimAll(); |
|
1514 bufFolderName.LowerCase(); |
|
1515 |
|
1516 if (bufFolderName.Compare(KInboxType) == 0) |
|
1517 { |
|
1518 folderId = iIPSMailbox->GetStandardFolderId(EFSInbox); |
|
1519 } |
|
1520 else if (bufFolderName.Compare(KOutboxType) == 0) |
|
1521 { |
|
1522 folderId = iIPSMailbox->GetStandardFolderId(EFSOutbox); |
|
1523 } |
|
1524 else if (bufFolderName.Compare(KDraftsType) == 0) |
|
1525 { |
|
1526 folderId = iIPSMailbox->GetStandardFolderId(EFSDraftsFolder); |
|
1527 } |
|
1528 else if (bufFolderName.Compare(KSentType) == 0) |
|
1529 { |
|
1530 folderId = iIPSMailbox->GetStandardFolderId(EFSSentFolder); |
|
1531 } |
|
1532 else |
|
1533 { |
|
1534 folderId = iIPSMailbox->GetStandardFolderId(EFSOther); |
|
1535 } |
|
1536 return folderId; |
|
1537 } |
|
1538 |
|
1539 // ----------------------------------------------------------------------------- |
|
1540 // CPopImapProfileTester::ParseEventParams |
|
1541 // Method used to parese params from event |
|
1542 // ----------------------------------------------------------------------------- |
|
1543 // |
|
1544 TBool CPopImapProfileTester::ParseEventParams(TAny *aEventParam1, |
|
1545 TAny *aEventParam2) |
|
1546 { |
|
1547 TBool ret(EFalse); |
|
1548 switch (iCurrWaitedEvent) |
|
1549 { |
|
1550 case TFSEventMailboxSyncStateChanged: |
|
1551 if (NULL == iEventParam1) |
|
1552 { |
|
1553 ret = ETrue; |
|
1554 } |
|
1555 else if (NULL == aEventParam1) |
|
1556 { |
|
1557 ret = EFalse; |
|
1558 } |
|
1559 else if (*((TSSMailSyncState*) aEventParam1) |
|
1560 == *((TSSMailSyncState*) iEventParam1)) |
|
1561 { |
|
1562 ret = ETrue; |
|
1563 } |
|
1564 else |
|
1565 { |
|
1566 ret = EFalse; |
|
1567 } |
|
1568 break; |
|
1569 |
|
1570 case TFSEventMailMoved: |
|
1571 if (NULL == iEventParam1) |
|
1572 { |
|
1573 ret = ETrue; |
|
1574 } |
|
1575 else if (NULL == aEventParam2) |
|
1576 { |
|
1577 ret = EFalse; |
|
1578 } |
|
1579 else if (*((TFSMailMsgId*) aEventParam2) |
|
1580 == *((TFSMailMsgId*) iEventParam2)) |
|
1581 { |
|
1582 ret = ETrue; |
|
1583 } |
|
1584 else |
|
1585 { |
|
1586 ret = EFalse; |
|
1587 } |
|
1588 break; |
|
1589 |
|
1590 default: |
|
1591 ret = ETrue; |
|
1592 break; |
|
1593 } |
|
1594 return ret; |
|
1595 } |
|
1596 |
|
1597 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1598 |
|
1599 // ----------------------------------------------------------------------------- |
|
1600 // LibEntryL is a polymorphic Dll entry point. |
|
1601 // Returns: CScriptBase: New CScriptBase derived object |
|
1602 // ----------------------------------------------------------------------------- |
|
1603 // |
|
1604 EXPORT_C CScriptBase* LibEntryL(CTestModuleIf& aTestModuleIf) // Backpointer to STIF Test Framework |
|
1605 { |
|
1606 |
|
1607 return (CScriptBase*) CPopImapProfileTester::NewL(aTestModuleIf); |
|
1608 |
|
1609 } |
|
1610 |
|
1611 // End of File |