ipsservices/tsrc/profiletester/src/popimapprofiletester.cpp
branchRCL_3
changeset 80 726fba06891a
parent 73 c8382f7b54ef
equal deleted inserted replaced
73:c8382f7b54ef 80:726fba06891a
     1 /* ============================================================================
     1 /* ============================================================================
     2  *  Name        :  popimapprofiletester.cpp
     2  *  Name        :  popimapprofiletester.cpp
     3  *  Part of     :  ipsservices / ipsprofiletester 
     3  *  Part of     :  ipsservices / ipsprofiletester 
     4  *  Description :: STIF test cases
     4  *  Description :: STIF test cases
     5  *  Version     : %version: 2 % << Don't touch! Updated by Synergy at check-out.
     5  *  Version     : %version: 3 % << Don't touch! Updated by Synergy at check-out.
     6  *
     6  *
     7  *  Copyright © 2010-2010 Nokia and/or its subsidiary(-ies).  All rights reserved.
     7  *  Copyright © 2010-2010 Nokia and/or its subsidiary(-ies).  All rights reserved.
     8  *  This material, including documentation and any related computer
     8  *  This material, including documentation and any related computer
     9  *  programs, is protected by copyright controlled by Nokia.  All
     9  *  programs, is protected by copyright controlled by Nokia.  All
    10  *  rights are reserved.  Copying, including reproducing, storing,
    10  *  rights are reserved.  Copying, including reproducing, storing,
    13  *  confidential information which may not be disclosed to others
    13  *  confidential information which may not be disclosed to others
    14  *  without the prior written consent of Nokia.
    14  *  without the prior written consent of Nokia.
    15  * ============================================================================
    15  * ============================================================================
    16  */
    16  */
    17 
    17 
       
    18 // MACROS
       
    19 #define TEST_CLASS_VERSION_MAJOR 0
       
    20 #define TEST_CLASS_VERSION_MINOR 0
       
    21 #define TEST_CLASS_VERSION_BUILD 0
       
    22 
    18 // INCLUDE FILES
    23 // INCLUDE FILES
    19 #include <StifTestInterface.h>
    24 #include <StifTestInterface.h>
    20 #include "popimapprofiletester.h"
    25 #include "popimapprofiletester.h"
    21 #include <SettingServerClient.h>
    26 #include <SettingServerClient.h>
       
    27 
       
    28 //const numbers
       
    29 const TInt KTimeUnits = 1000000; 
    22 /*
    30 /*
    23  * define flag in ctg file
    31  * define flag in ctg file
    24  */
    32  */
    25 _LIT( KSetupWizAccountType,"AccountType" );
    33 _LIT( KSetupWizAccountType,"AccountType" );
    26 _LIT( KSetupWizAccountsConfigured,"AccountsConfigured" );
    34 _LIT( KSetupWizAccountsConfigured,"AccountsConfigured" );
   221         RPointerArray<CFSMailMessage> messages;
   229         RPointerArray<CFSMailMessage> messages;
   222         TInt gotMsgs = GetMessagesFromFolderL(messages, folder,
   230         TInt gotMsgs = GetMessagesFromFolderL(messages, folder,
   223                 EFSMsgDataSubject, EFSMailSortByDate, msgCount);
   231                 EFSMsgDataSubject, EFSMailSortByDate, msgCount);
   224 
   232 
   225         // Step 03: to find to be deleted msgs 
   233         // Step 03: to find to be deleted msgs 
   226         for (TInt i = 0; i < messages.Count(); i++)
   234 		TInt mssagesCount = messages.Count();
       
   235         for (TInt i = 0; i < mssagesCount; i++)
   227             {
   236             {
   228             //deleted msgs with STIF
   237             //deleted msgs with STIF
   229             if (messages[i]->GetSubject().Find(_L("STIF" )) != KErrNotFound)
   238             if (messages[i]->GetSubject().Find(_L("STIF" )) != KErrNotFound)
   230                 {
   239                 {
   231                 iLog->Log(_L("Found: %d. %S"), i + 1,
   240                 iLog->Log(_L("Found: %d. %S"), i + 1,
   271     {
   280     {
   272     CFSMailFolder* folder(NULL);
   281     CFSMailFolder* folder(NULL);
   273     RPointerArray<CFSMailFolder>& allFolders = iIPSMailbox->ListFolders();
   282     RPointerArray<CFSMailFolder>& allFolders = iIPSMailbox->ListFolders();
   274 
   283 
   275     TFSMailMsgId folderId = GetFolderIdFromName(aFolderName);
   284     TFSMailMsgId folderId = GetFolderIdFromName(aFolderName);
   276     for (TInt i = 0; i < allFolders.Count(); ++i)
   285 	TInt allFoldersCount = allFolders.Count();
       
   286     for (TInt i = 0; i < allFoldersCount; ++i)
   277         {
   287         {
   278         if (allFolders[i]->GetFolderId() == folderId)
   288         if (allFolders[i]->GetFolderId() == folderId)
   279             {
   289             {
   280             iLog->Log(_L("Found: %S folder"), &allFolders[i]->GetFolderName());
   290             iLog->Log(_L("Found: %S folder"), &allFolders[i]->GetFolderName());
   281             folder = allFolders[i];
   291             folder = allFolders[i];
   335         TFSMailMsgId /*aMailbox*/, TAny* aParam1, TAny* aParam2, TAny* aParam3)
   345         TFSMailMsgId /*aMailbox*/, TAny* aParam1, TAny* aParam2, TAny* aParam3)
   336     {
   346     {
   337     LogEvent(_L("Receive Event->"), aEvent, aParam1, aParam2, aParam3);
   347     LogEvent(_L("Receive Event->"), aEvent, aParam1, aParam2, aParam3);
   338     if ((aEvent == iCurrWaitedEvent) && (iWait->IsStarted()) && (iWaitingState
   348     if ((aEvent == iCurrWaitedEvent) && (iWait->IsStarted()) && (iWaitingState
   339             == EWaitingEvent) && ParseEventParams(aParam1, aParam2))
   349             == EWaitingEvent) && ParseEventParams(aParam1, aParam2))
   340         OpComplete();
   350 		{
       
   351          OpComplete();
       
   352 		}
   341     }
   353     }
   342 
   354 
   343 // -----------------------------------------------------------------------------
   355 // -----------------------------------------------------------------------------
   344 // CPopImapProfileTester::RequestResponseL
   356 // CPopImapProfileTester::RequestResponseL
   345 // from MFSMailRequestObserver
   357 // from MFSMailRequestObserver
   351         TInt aRequestId)
   363         TInt aRequestId)
   352     {
   364     {
   353     LogTFSProgress(_L("Receive Response->"), aEvent.iProgressStatus, aRequestId);
   365     LogTFSProgress(_L("Receive Response->"), aEvent.iProgressStatus, aRequestId);
   354     if ((aEvent.iProgressStatus == iCurrWaitedResponse) && (iWaitingState
   366     if ((aEvent.iProgressStatus == iCurrWaitedResponse) && (iWaitingState
   355             == EWaitingResponse) && (iWait->IsStarted()))
   367             == EWaitingResponse) && (iWait->IsStarted()))
   356         OpComplete();
   368         {
       
   369          OpComplete();
       
   370 		}
   357     }
   371     }
   358 
   372 
   359 // -----------------------------------------------------------------------------
   373 // -----------------------------------------------------------------------------
   360 // CPopImapProfileTester::MatchFoundL
   374 // CPopImapProfileTester::MatchFoundL
   361 // from MFSMailBoxSearchObserver
   375 // from MFSMailBoxSearchObserver
   362 // -----------------------------------------------------------------------------
   376 // -----------------------------------------------------------------------------
   363 //
   377 //
   364 void CPopImapProfileTester::MatchFoundL(CFSMailMessage* aMatchMessage)
   378 void CPopImapProfileTester::MatchFoundL(CFSMailMessage* aMatchMessage)
   365     {
   379     {
   366     TBuf<20> tempFolderName;
   380     TFolderName tempFolderName;
   367     GetFolderNameFromId(aMatchMessage->GetFolderId(), tempFolderName);
   381     GetFolderNameFromId(aMatchMessage->GetFolderId(), tempFolderName);
   368     TPtrC folderName = tempFolderName.Mid(0);
   382     TPtrC folderName = tempFolderName.Mid(0);
   369     iLog->Log(_L("  MatchFound %S in %S"), &aMatchMessage->GetSubject(),
   383     iLog->Log(_L("  MatchFound %S in %S"), &aMatchMessage->GetSubject(),
   370             &folderName);
   384             &folderName);
   371     if (iSearchOngoing)
   385     if (iSearchOngoing)
   429         {
   443         {
   430         //Wait for email to be sent
   444         //Wait for email to be sent
   431         TFSMailMsgId folderId = iIPSMailbox->GetStandardFolderId(EFSSentFolder);
   445         TFSMailMsgId folderId = iIPSMailbox->GetStandardFolderId(EFSSentFolder);
   432         iIPSMailbox->RefreshNowL();
   446         iIPSMailbox->RefreshNowL();
   433         err = WaitForEvent(TFSEventMailMoved, NULL, &folderId);
   447         err = WaitForEvent(TFSEventMailMoved, NULL, &folderId);
   434         iIPSMailbox->GoOfflineL();
   448 		if ( KErrNone == err )
   435         WaitForEvent(TFSEventMailboxOffline);
   449 		{
   436         iIPSMailbox->RefreshNowL(*this);
   450          iIPSMailbox->GoOfflineL();
   437         WaitForResponse(TFSProgress::EFSStatus_RequestComplete);
   451          WaitForEvent(TFSEventMailboxOffline);
   438 
   452          iIPSMailbox->RefreshNowL(*this);
   439         if (KErrNone == err)
   453          WaitForResponse(TFSProgress::EFSStatus_RequestComplete);
   440             {
   454        
   441             // Step04: To check 'Inbox' folder to sure message sent
   455             // Step04: To check 'Inbox' folder to sure message sent
   442             TFSMailMsgId folderId = iIPSMailbox->GetStandardFolderId(EFSInbox);
   456             TFSMailMsgId folderId = iIPSMailbox->GetStandardFolderId(EFSInbox);
   443             CFSMailFolder* folder = iMailClient->GetFolderByUidL(
   457             CFSMailFolder* folder = iMailClient->GetFolderByUidL(
   444                     iIPSMailbox->GetId(), folderId);
   458                     iIPSMailbox->GetId(), folderId);
   445             CleanupStack::PushL(folder);
   459             CleanupStack::PushL(folder);
   449                 TInt gotMsgs = GetMessagesFromFolderL(messages, folder,
   463                 TInt gotMsgs = GetMessagesFromFolderL(messages, folder,
   450                         EFSMsgDataSubject, EFSMailSortByDate, msgCount);
   464                         EFSMsgDataSubject, EFSMailSortByDate, msgCount);
   451                 if (gotMsgs > 0)
   465                 if (gotMsgs > 0)
   452                     {
   466                     {
   453                     iLog->Log(_L("  Listing first %d emails:"), gotMsgs);
   467                     iLog->Log(_L("  Listing first %d emails:"), gotMsgs);
   454                     for (TInt i = 0; i < messages.Count(); i++)
   468 					TInt messagesCount = messages.Count();
       
   469                     for (TInt i = 0; i < messagesCount; i++)
   455                         {
   470                         {
   456                         iLog->Log(_L("Found: %S"), &messages[i]->GetSubject());
   471                         iLog->Log(_L("Found: %S"), &messages[i]->GetSubject());
   457 
   472 
   458                         if (messages[i]->GetSubject().Compare(aSubject) == 0)
   473                         if (messages[i]->GetSubject().Compare(aSubject) == 0)
   459                             {
   474                             {
   516             }
   531             }
   517         else
   532         else
   518             {
   533             {
   519             iLog->Log(_L("  Searching for '%S':"), aSearchStrings[0]);
   534             iLog->Log(_L("  Searching for '%S':"), aSearchStrings[0]);
   520             iSearchOngoing = ETrue;
   535             iSearchOngoing = ETrue;
   521             iTimeoutTimer->Start(aTimeout * 1000000);
   536             iTimeoutTimer->Start(aTimeout * KTimeUnits);
   522             iWait->Start();
   537             iWait->Start();
   523             if (iTimeout)
   538             if (iTimeout)
   524                 {
   539                 {
   525                 iLog->Log(_L("  Error: Search not completed within %d sec"),
   540                 iLog->Log(_L("  Error: Search not completed within %d sec"),
   526                         aTimeout);
   541                         aTimeout);
   549             aEventParam2, NULL);
   564             aEventParam2, NULL);
   550     iWaitingState = EWaitingEvent;
   565     iWaitingState = EWaitingEvent;
   551     iCurrWaitedEvent = aWaitedEvent;
   566     iCurrWaitedEvent = aWaitedEvent;
   552     iEventParam1 = aEventParam1;
   567     iEventParam1 = aEventParam1;
   553     iEventParam2 = aEventParam2;
   568     iEventParam2 = aEventParam2;
   554     iTimeoutTimer->Start(aTimeout * 1000000);
   569     iTimeoutTimer->Start(aTimeout * KTimeUnits);
   555     if (iWait->IsStarted() == EFalse)
   570     if (iWait->IsStarted() == EFalse)
   556         {
   571         {
   557         iWait->Start();
   572         iWait->Start();
   558         iWaitingState = EWaitingNothing;
   573         iWaitingState = EWaitingNothing;
   559         iEventParam1 = NULL;
   574         iEventParam1 = NULL;
   568             {
   583             {
   569             iTimeoutTimer->Stop();
   584             iTimeoutTimer->Stop();
   570             return KErrNone;
   585             return KErrNone;
   571             }
   586             }
   572         }
   587         }
   573     else
   588 
   574         {
   589      iLog->Log(_L(" Stop the wait before start it"));
   575         iLog->Log(_L(" Stop the wait before start it"));
   590      return KErrGeneral;
   576         return KErrGeneral;
   591 
   577         }
       
   578     }
   592     }
   579 // -----------------------------------------------------------------------------
   593 // -----------------------------------------------------------------------------
   580 // CPopImapProfileTester::WaitForResponse
   594 // CPopImapProfileTester::WaitForResponse
   581 // Method used to wait response from observer
   595 // Method used to wait response from observer
   582 // -----------------------------------------------------------------------------
   596 // -----------------------------------------------------------------------------
   585         TFSProgress::TFSProgressStatus aWaitedResponse, TInt aTimeout)
   599         TFSProgress::TFSProgressStatus aWaitedResponse, TInt aTimeout)
   586     {
   600     {
   587     LogTFSProgress(_L("Waiting for Response->"), aWaitedResponse, 0);
   601     LogTFSProgress(_L("Waiting for Response->"), aWaitedResponse, 0);
   588     iWaitingState = EWaitingResponse;
   602     iWaitingState = EWaitingResponse;
   589     iCurrWaitedResponse = aWaitedResponse;
   603     iCurrWaitedResponse = aWaitedResponse;
   590     iTimeoutTimer->Start(aTimeout * 1000000);
   604     iTimeoutTimer->Start(aTimeout * KTimeUnits);
   591     if (iWait->IsStarted() == EFalse)
   605     if (iWait->IsStarted() == EFalse)
   592         {
   606         {
   593         iWait->Start();
   607         iWait->Start();
   594         iWaitingState = EWaitingNothing;
   608         iWaitingState = EWaitingNothing;
   595         if (iTimeout)
   609         if (iTimeout)
   602             {
   616             {
   603             iTimeoutTimer->Stop();
   617             iTimeoutTimer->Stop();
   604             return KErrNone;
   618             return KErrNone;
   605             }
   619             }
   606         }
   620         }
   607     else
   621       return KErrGeneral;
   608         return KErrGeneral;
       
   609     }
   622     }
   610 
   623 
   611 void CPopImapProfileTester::OpComplete()
   624 void CPopImapProfileTester::OpComplete()
   612     {
   625     {
   613     if (iWait)
   626     if (iWait)
       
   627 	  {
   614         iWait->AsyncStop();
   628         iWait->AsyncStop();
       
   629 	  }
   615     if (iTimeoutTimer)
   630     if (iTimeoutTimer)
       
   631 	  {
   616         iTimeoutTimer->Stop();
   632         iTimeoutTimer->Stop();
       
   633 	  }
   617     }
   634     }
   618 // -----------------------------------------------------------------------------
   635 // -----------------------------------------------------------------------------
   619 // CPopImapProfileTester::InitMailbox()
   636 // CPopImapProfileTester::InitMailbox()
   620 // Method to initiate mailbxo, depends on type of account in .cfg file
   637 // Method to initiate mailbox, depends on type of account in .cfg file
   621 // -----------------------------------------------------------------------------
   638 // -----------------------------------------------------------------------------
   622 //
   639 //
   623 TInt CPopImapProfileTester::InitMailboxL()
   640 TInt CPopImapProfileTester::InitMailboxL()
   624     {
   641     {
   625     if (NULL != iIPSMailbox)
   642     if (NULL != iIPSMailbox)
       
   643 	  {
   626         return KErrNone;
   644         return KErrNone;
       
   645 	  }
   627 
   646 
   628     TBuf<10> accountType;
   647     TBuf<10> accountType;
   629 
   648 
   630     //to separate type of mailbox: 'imap or pop' 
   649     //to separate type of mailbox: 'imap or pop' 
   631     GetConstantValue(KAccountType, accountType);
   650     GetConstantValue(KAccountType, accountType);
   632     accountType.TrimAll();
   651     accountType.TrimAll();
   633     accountType.LowerCase();
   652     accountType.LowerCase();
   634     if (accountType.Compare(KIMAPAccount) == 0)
   653     if (accountType.Compare(KIMAPAccount) == 0)
       
   654 	    {
   635         iPluginId.SetPluginId(TUid::Uid(KIPSSosImap4PluginUid));
   655         iPluginId.SetPluginId(TUid::Uid(KIPSSosImap4PluginUid));
       
   656 		}
   636     else if (accountType.Compare(KPOPAccount) == 0)
   657     else if (accountType.Compare(KPOPAccount) == 0)
   637         {
   658         {
   638         iPluginId.SetPluginId(TUid::Uid(KIPSSosPop3PluginUid));
   659         iPluginId.SetPluginId(TUid::Uid(KIPSSosPop3PluginUid));
   639         }
   660         }
   640     else
   661     else
   733                         KFSMailContentTypeTextPlain);
   754                         KFSMailContentTypeTextPlain);
   734                 }
   755                 }
   735             if (NULL != newMsgPart)
   756             if (NULL != newMsgPart)
   736                 {
   757                 {
   737                 CleanupStack::PushL(newMsgPart);
   758                 CleanupStack::PushL(newMsgPart);
   738                 TBuf<256> buf(aMsgBodyText);
   759                 TBuf<KMaxBufLen> buf(aMsgBodyText);
   739                 newMsgPart->SetContent(buf);
   760                 newMsgPart->SetContent(buf);
   740                 newMsgPart->SetContentSize(buf.Length());
   761                 newMsgPart->SetContentSize(buf.Length());
   741                 newMsgPart->SetFetchedContentSize(buf.Length());
   762                 newMsgPart->SetFetchedContentSize(buf.Length());
   742                 newMsgPart->SaveL();
   763                 newMsgPart->SaveL();
   743                 CleanupStack::PopAndDestroy(newMsgPart);
   764                 CleanupStack::PopAndDestroy(newMsgPart);
   744                 }
   765                 }
   745             else
   766             else
   746                 {
   767                 {
   747                 iLog->Log(_L( "Error: Failed to create msg part" ));
   768 				err = KErrNoMemory;
   748                 err = KErrNoMemory;
   769                 iLog->Log(_L( "Error: Failed to create msg part(%d)" ),err);
   749                 }
   770                 }
   750             }//end if 'KErrNone == err'
   771             }//end if 'KErrNone == err'
   751         else
   772         else
   752             {
   773             {
   753             iLog->Log(_L( "Error: Failed to move new msg to Drafts folder" ));
   774             iLog->Log(_L( "Error: Failed to move new msg to Drafts folder" ));
   754             }
   775             }
   755         CleanupStack::Pop(newMsg);
   776         CleanupStack::Pop(newMsg);
   756         }//end if 'NULL != newMsg'
   777         }//end if 'NULL != newMsg'
   757     else
   778     else
   758         {
   779         {
   759         iLog->Log(_L( "   Error: Failed to create new msg" ));
   780 		err = KErrNoMemory;
   760         err = KErrNoMemory;
   781         iLog->Log(_L( "Error: Failed to create new msg(%d)" ),err);
   761         }
   782         }
   762     return newMsg;
   783     return newMsg;
   763     }
   784     }
   764 
   785 
   765 // -----------------------------------------------------------------------------
   786 // -----------------------------------------------------------------------------
   769 //
   790 //
   770 TInt CPopImapProfileTester::ReadAccountSettings(
   791 TInt CPopImapProfileTester::ReadAccountSettings(
   771         TAccountSetting& aAccountSetting)
   792         TAccountSetting& aAccountSetting)
   772     {
   793     {
   773     TInt err(KErrNone);
   794     TInt err(KErrNone);
       
   795 	TInt errInside(KErrNone);
   774     err = GetConstantValue(KSetupWizAccountType, aAccountSetting.iAccountType);
   796     err = GetConstantValue(KSetupWizAccountType, aAccountSetting.iAccountType);
   775     aAccountSetting.iAccountType.TrimAll();
   797     aAccountSetting.iAccountType.TrimAll();
   776     aAccountSetting.iAccountType.LowerCase();
   798     aAccountSetting.iAccountType.LowerCase();
   777     if (aAccountSetting.iAccountType.Compare(KIMAPAccount) == 0)
   799     if (aAccountSetting.iAccountType.Compare(KIMAPAccount) == 0)
   778         {
   800         {
   785     else
   807     else
   786         {
   808         {
   787         iLog->Log(_L("Wrong Account Type %S, "), &aAccountSetting.iAccountType);
   809         iLog->Log(_L("Wrong Account Type %S, "), &aAccountSetting.iAccountType);
   788         return KErrNotFound;
   810         return KErrNotFound;
   789         }
   811         }
   790     err = GetConstantValue(KSetupWizAccountsConfigured,
   812     errInside = GetConstantValue(KSetupWizAccountsConfigured,
   791             aAccountSetting.iAccountsConfigured);
   813             aAccountSetting.iAccountsConfigured);
   792     err = GetConstantValue(KSetupWizMaxAccountsReached,
   814 	iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   815 	
       
   816     errInside = GetConstantValue(KSetupWizMaxAccountsReached,
   793             aAccountSetting.iMaxAccountsReached);
   817             aAccountSetting.iMaxAccountsReached);
   794     err
   818     iLog->Log(_L( "Information: GetConstantValue with error (%d)" ),errInside);
       
   819     
       
   820 	errInside
   795             = GetConstantValue(KSetupWizEmailAddress,
   821             = GetConstantValue(KSetupWizEmailAddress,
   796                     aAccountSetting.iEmailAddress);
   822                     aAccountSetting.iEmailAddress);
   797     err = GetConstantValue(KSetupWizUsername, aAccountSetting.iUserName);
   823 	iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
   798     err = GetConstantValue(KSetupWizPassword, aAccountSetting.iPassWord);
   824 	
   799     err = GetConstantValue(KSetupWizMailboxName, aAccountSetting.iMailboxName);
   825     errInside = GetConstantValue(KSetupWizUsername, aAccountSetting.iUserName);
   800     err = GetConstantValue(KSetupWizIncomingServer,
   826     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   827 	
       
   828 	errInside = GetConstantValue(KSetupWizPassword, aAccountSetting.iPassWord);
       
   829     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   830 	
       
   831 	errInside = GetConstantValue(KSetupWizMailboxName, aAccountSetting.iMailboxName);
       
   832     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   833 	
       
   834 	errInside = GetConstantValue(KSetupWizIncomingServer,
   801             aAccountSetting.iIncomingServer);
   835             aAccountSetting.iIncomingServer);
   802     err = GetConstantValue(KSetupWizOutgoingServer,
   836     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   837 	
       
   838 	errInside = GetConstantValue(KSetupWizOutgoingServer,
   803             aAccountSetting.iOutgoingServer);
   839             aAccountSetting.iOutgoingServer);
   804     err
   840     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   841 	
       
   842 	errInside
   805             = GetConstantValue(KSetupWizIncomingPort,
   843             = GetConstantValue(KSetupWizIncomingPort,
   806                     aAccountSetting.iIncomingPort);
   844                     aAccountSetting.iIncomingPort);
   807     err
   845     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   846 	
       
   847 	errInside
   808             = GetConstantValue(KSetupWizOutgoingPort,
   848             = GetConstantValue(KSetupWizOutgoingPort,
   809                     aAccountSetting.iOutgoingPort);
   849                     aAccountSetting.iOutgoingPort);
   810 
   850     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
   811     err = GetConstantValue(KSetupWizIncomingSecurityAuth,
   851     errInside = GetConstantValue(KSetupWizIncomingSecurityAuth,
   812             aAccountSetting.iIncomingSecurityAuth);
   852             aAccountSetting.iIncomingSecurityAuth);
   813     err = GetConstantValue(KSetupWizOutgoingSecurityAuth,
   853     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   854 	
       
   855 	errInside = GetConstantValue(KSetupWizOutgoingSecurityAuth,
   814             aAccountSetting.iOutgoingSecurityAuth);
   856             aAccountSetting.iOutgoingSecurityAuth);
   815     err = GetConstantValue(KSetupWizIncomingSecurityProtocol,
   857     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   858 	
       
   859 	errInside = GetConstantValue(KSetupWizIncomingSecurityProtocol,
   816             aAccountSetting.iIncomingSecurityProtocol);
   860             aAccountSetting.iIncomingSecurityProtocol);
   817     err = GetConstantValue(KSetupWizOutgoingSecurityProtocol,
   861     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   862 	
       
   863 	errInside = GetConstantValue(KSetupWizOutgoingSecurityProtocol,
   818             aAccountSetting.iOutgoingSecurityProtocol);
   864             aAccountSetting.iOutgoingSecurityProtocol);
   819     err = GetConstantValue(KSetupWizOperatorSecurityAuth,
   865     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   866 	
       
   867 	errInside = GetConstantValue(KSetupWizOperatorSecurityAuth,
   820             aAccountSetting.iOperatorSecurityAuth);
   868             aAccountSetting.iOperatorSecurityAuth);
   821     err = GetConstantValue(KSetupWizOperatorSecurityProtocol,
   869     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   870 	
       
   871 	errInside = GetConstantValue(KSetupWizOperatorSecurityProtocol,
   822             aAccountSetting.iOperatorSecurityProtocol);
   872             aAccountSetting.iOperatorSecurityProtocol);
   823     err
   873     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   874 	
       
   875 	errInside
   824             = GetConstantValue(KSetupWizOperatorPort,
   876             = GetConstantValue(KSetupWizOperatorPort,
   825                     aAccountSetting.iOperatorPort);
   877                     aAccountSetting.iOperatorPort);
   826 
   878     iLog->Log(_L( "Information: GetConstantValue with error(%d)" ),errInside);
       
   879 	
       
   880 	if (KErrNone != errInside )
       
   881 	{
       
   882 	    err = KErrGeneral;
       
   883 		iLog->Log(_L( "Error: Failed to get constant value with error(%d)" ),err);
       
   884 	}
       
   885 	
   827     aAccountSetting.iWizardAccountType = KWizAccountTypeDefault;
   886     aAccountSetting.iWizardAccountType = KWizAccountTypeDefault;
   828     aAccountSetting.iOperatorOutgoingServer = KNullDesC;
   887     aAccountSetting.iOperatorOutgoingServer = KNullDesC;
   829     aAccountSetting.iHideUserNameInSetting = ETrue;
   888     aAccountSetting.iHideUserNameInSetting = ETrue;
   830     aAccountSetting.iAccessPoint = KNullDesC;
   889     aAccountSetting.iAccessPoint = KNullDesC;
   831 
   890 
   847     iLog->Log(_L( "== Start a transaction in SetupAccount ==" ));
   906     iLog->Log(_L( "== Start a transaction in SetupAccount ==" ));
   848     if (KErrNone == err)
   907     if (KErrNone == err)
   849         {
   908         {
   850         err = rep->Set(ECRKSetupWizAccountType,
   909         err = rep->Set(ECRKSetupWizAccountType,
   851                 aAccountSetting.iWizardAccountType);
   910                 aAccountSetting.iWizardAccountType);
       
   911 		iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   912 		
   852         err = rep->Set(ECRKAccountsConfigured,
   913         err = rep->Set(ECRKAccountsConfigured,
   853                 aAccountSetting.iAccountsConfigured);
   914                 aAccountSetting.iAccountsConfigured);
   854         err = rep->Set(ECRKMaxAccountsReached,
   915         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   916 		
       
   917 		err = rep->Set(ECRKMaxAccountsReached,
   855                 aAccountSetting.iMaxAccountsReached);
   918                 aAccountSetting.iMaxAccountsReached);
   856         err = rep->Set(ECRKPopImapEmailAddressId,
   919         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   920 		
       
   921 		err = rep->Set(ECRKPopImapEmailAddressId,
   857                 aAccountSetting.iEmailAddress);
   922                 aAccountSetting.iEmailAddress);
   858         err = rep->Set(ECRKPopImapUsernameId, aAccountSetting.iUserName);
   923         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
   859         err = rep->Set(ECRKPopImapPasswordId, aAccountSetting.iPassWord);
   924 		
   860         err = rep->Set(ECRKPopImapIncomingServerId,
   925 		err = rep->Set(ECRKPopImapUsernameId, aAccountSetting.iUserName);
       
   926         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   927 		
       
   928 		err = rep->Set(ECRKPopImapPasswordId, aAccountSetting.iPassWord);
       
   929         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   930 		
       
   931 		err = rep->Set(ECRKPopImapIncomingServerId,
   861                 aAccountSetting.iIncomingServer);
   932                 aAccountSetting.iIncomingServer);
   862         err = rep->Set(ECRKPopImapOutgoingServerId,
   933         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   934 		
       
   935 		err = rep->Set(ECRKPopImapOutgoingServerId,
   863                 aAccountSetting.iOutgoingServer);
   936                 aAccountSetting.iOutgoingServer);
   864         err = rep->Set(ECRKPopImapProtocolIndicatorId,
   937         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   938 		
       
   939 		err = rep->Set(ECRKPopImapProtocolIndicatorId,
   865                 aAccountSetting.iProtocolIndicator);
   940                 aAccountSetting.iProtocolIndicator);
   866         err = rep->Set(ECRKPopImapIncomingPortId,
   941         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   942 		
       
   943 		err = rep->Set(ECRKPopImapIncomingPortId,
   867                 aAccountSetting.iIncomingPort);
   944                 aAccountSetting.iIncomingPort);
   868         err = rep->Set(ECRKPopImapOutgoingPortId,
   945         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   946 		
       
   947 		err = rep->Set(ECRKPopImapOutgoingPortId,
   869                 aAccountSetting.iOutgoingPort);
   948                 aAccountSetting.iOutgoingPort);
   870         err = rep->Set(ECRKPopImapIncomingSecurityAuthId,
   949         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   950 		
       
   951 		err = rep->Set(ECRKPopImapIncomingSecurityAuthId,
   871                 aAccountSetting.iIncomingSecurityAuth);
   952                 aAccountSetting.iIncomingSecurityAuth);
   872         err = rep->Set(ECRKPopImapIncomingSecurityProtocolId,
   953         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   954 		
       
   955 		err = rep->Set(ECRKPopImapIncomingSecurityProtocolId,
   873                 aAccountSetting.iIncomingSecurityProtocol);
   956                 aAccountSetting.iIncomingSecurityProtocol);
   874         err = rep->Set(ECRKPopImapOutgoingSecurityAuthId,
   957         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   958 		
       
   959 		err = rep->Set(ECRKPopImapOutgoingSecurityAuthId,
   875                 aAccountSetting.iOutgoingSecurityAuth);
   960                 aAccountSetting.iOutgoingSecurityAuth);
   876         err = rep->Set(ECRKPopImapOutgoingSecurityProtocolId,
   961         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   962 		
       
   963 		err = rep->Set(ECRKPopImapOutgoingSecurityProtocolId,
   877                 aAccountSetting.iOutgoingSecurityProtocol);
   964                 aAccountSetting.iOutgoingSecurityProtocol);
   878         err = rep->Set(ECRKPopImapOperatorOutgoingServerId,
   965         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   966 		
       
   967 		err = rep->Set(ECRKPopImapOperatorOutgoingServerId,
   879                 aAccountSetting.iOperatorOutgoingServer);
   968                 aAccountSetting.iOperatorOutgoingServer);
   880         err = rep->Set(ECRKPopImapOperatorSecurityAuthId,
   969         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   970 		
       
   971 		err = rep->Set(ECRKPopImapOperatorSecurityAuthId,
   881                 aAccountSetting.iOperatorSecurityAuth);
   972                 aAccountSetting.iOperatorSecurityAuth);
   882         err = rep->Set(ECRKPopImapOperatorSecurityProtocolId,
   973         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   974 		
       
   975 		err = rep->Set(ECRKPopImapOperatorSecurityProtocolId,
   883                 aAccountSetting.iOperatorSecurityProtocol);
   976                 aAccountSetting.iOperatorSecurityProtocol);
   884         err = rep->Set(ECRKPopImapOperatorPortId,
   977         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   978 		
       
   979 		err = rep->Set(ECRKPopImapOperatorPortId,
   885                 aAccountSetting.iOperatorPort);
   980                 aAccountSetting.iOperatorPort);
   886         err = rep->Set(ECRKHideUsernameInSettings,
   981         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   982 		
       
   983 		err = rep->Set(ECRKHideUsernameInSettings,
   887                 aAccountSetting.iHideUserNameInSetting); // 1 = ETrue if there are some field that should be hidden from ui
   984                 aAccountSetting.iHideUserNameInSetting); // 1 = ETrue if there are some field that should be hidden from ui
   888         err = rep->Set(ECRKPopImapAccessPointId, aAccountSetting.iAccessPoint);
   985         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
   889         err = rep->Set(ECRKPopImapMailboxName, aAccountSetting.iMailboxName);
   986 		
   890         iLog->Log(_L( "==Error:=%d" ), err);
   987 		err = rep->Set(ECRKPopImapAccessPointId, aAccountSetting.iAccessPoint);
       
   988         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   989 		
       
   990 		err = rep->Set(ECRKPopImapMailboxName, aAccountSetting.iMailboxName);
       
   991         iLog->Log(_L( "Information: repository set value with error(%d)" ),err);
       
   992 		
       
   993 		iLog->Log(_L( "==Error:=%d" ), err);
   891 
   994 
   892         err = rep->CommitTransaction(keyInfo);
   995         err = rep->CommitTransaction(keyInfo);
   893         if (KErrLocked == err || KErrAbort == err || KErrNone != err)
   996         if (KErrLocked == err || KErrAbort == err || KErrNone != err)
   894             {
   997             {
   895             rep->CancelTransaction();
   998             rep->CancelTransaction();
   907     CleanupStack::PopAndDestroy(rep);
  1010     CleanupStack::PopAndDestroy(rep);
   908     return err;
  1011     return err;
   909     }
  1012     }
   910 
  1013 
   911 // -----------------------------------------------------------------------------
  1014 // -----------------------------------------------------------------------------
       
  1015 // CPopImapProfileTester::LogNewEntriesCount
       
  1016 // Method used to print log about count of new entries
       
  1017 // -----------------------------------------------------------------------------
       
  1018 //
       
  1019 void CPopImapProfileTester::LogNewEntriesCount(TDes& aLog,TAny* aParam)
       
  1020 	{
       
  1021 	RArray<TFSMailMsgId>* newEntries =
       
  1022 			static_cast<RArray<TFSMailMsgId>*> (aParam);
       
  1023 	TInt newEntriesCount = newEntries->Count();
       
  1024 	aLog.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1025 	}
       
  1026 // -----------------------------------------------------------------------------
       
  1027 // CPopImapProfileTester::LogFolderName
       
  1028 // Method used to print log about name of folder
       
  1029 // -----------------------------------------------------------------------------
       
  1030 //
       
  1031 void CPopImapProfileTester::LogFolderName(TDes& aLog,TAny* aParam)
       
  1032 	{
       
  1033 	TFSMailMsgId* parentFolder = static_cast<TFSMailMsgId*> (aParam);
       
  1034 	TFolderName folderName;
       
  1035 	if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1036 		{
       
  1037 		aLog.Append(folderName);
       
  1038 		}
       
  1039 	}
       
  1040  
       
  1041 // -----------------------------------------------------------------------------
   912 // CPopImapProfileTester::LogEvent
  1042 // CPopImapProfileTester::LogEvent
   913 // Method used to print log about event
  1043 // Method used to print log about event
   914 // -----------------------------------------------------------------------------
  1044 // -----------------------------------------------------------------------------
   915 //
  1045 //
   916 void CPopImapProfileTester::LogEvent(const TDesC& aLogText,
  1046 void CPopImapProfileTester::LogEvent(const TDesC& aLogText,
   917         TFSMailEvent aEvent, TAny* aParam1, TAny* aParam2, TAny* aParam3)
  1047         TFSMailEvent aEvent, TAny* aParam1, TAny* aParam2, TAny* aParam3)
   918     {
  1048     {
   919     TBuf<256> log(aLogText);
  1049     TBuf<KMaxBufLen> log(aLogText);
   920 
  1050 
   921     switch (aEvent)
  1051     switch (aEvent)
   922         {
  1052         {
   923         // Mailbox is unavailable
  1053         // Mailbox is unavailable
   924         // params NULL
  1054         // params NULL
  1075             // aParam3: NULL
  1205             // aParam3: NULL
  1076         case TFSEventNewMail:
  1206         case TFSEventNewMail:
  1077             log.Append(_L( "NewEmail" ));
  1207             log.Append(_L( "NewEmail" ));
  1078             if (aParam1)
  1208             if (aParam1)
  1079                 {
  1209                 {
  1080                 RArray<TFSMailMsgId>* newEntries = static_cast<RArray<
  1210                   LogNewEntriesCount(log,aParam1);
  1081                         TFSMailMsgId>*> (aParam1);
       
  1082                 TInt newEntriesCount = newEntries->Count();
       
  1083                 log.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1084                 }
  1211                 }
  1085             if (aParam2)
  1212             if (aParam2)
  1086                 {
  1213                 {
  1087                 TFSMailMsgId* parentFolder =
  1214                   LogFolderName(log,aParam2);
  1088                         static_cast<TFSMailMsgId*> (aParam2);
       
  1089                 TBuf<20> folderName;
       
  1090                 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1091                     {
       
  1092                     log.Append(folderName);
       
  1093                     }
       
  1094                 }
  1215                 }
  1095             break;
  1216             break;
  1096 
  1217 
  1097             // Mails changed
  1218             // Mails changed
  1098             // aParam1: RArray<TFSMailMsgId>* aEntries
  1219             // aParam1: RArray<TFSMailMsgId>* aEntries
  1100             // aParam3: NULL
  1221             // aParam3: NULL
  1101         case TFSEventMailChanged:
  1222         case TFSEventMailChanged:
  1102             log.Append(_L( "MailChanged" ));
  1223             log.Append(_L( "MailChanged" ));
  1103             if (aParam1)
  1224             if (aParam1)
  1104                 {
  1225                 {
  1105                 RArray<TFSMailMsgId>* newEntries = static_cast<RArray<
  1226                   LogNewEntriesCount(log,aParam1);
  1106                         TFSMailMsgId>*> (aParam1);
       
  1107                 TInt newEntriesCount = newEntries->Count();
       
  1108                 log.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1109                 }
  1227                 }
  1110             if (aParam2)
  1228             if (aParam2)
  1111                 {
  1229                 {
  1112                 TFSMailMsgId* parentFolder =
  1230                   LogFolderName(log,aParam2);
  1113                         static_cast<TFSMailMsgId*> (aParam2);
       
  1114                 TBuf<20> folderName;
       
  1115                 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1116                     {
       
  1117                     log.Append(folderName);
       
  1118                     }
       
  1119                 }
  1231                 }
  1120             break;
  1232             break;
  1121 
  1233 
  1122             // Mails deleted
  1234             // Mails deleted
  1123             // aParam1: RArray<TFSMailMsgId>* aEntries
  1235             // aParam1: RArray<TFSMailMsgId>* aEntries
  1125             // aParam3: NULL
  1237             // aParam3: NULL
  1126         case TFSEventMailDeleted:
  1238         case TFSEventMailDeleted:
  1127             log.Append(_L( "MailDeleted" ));
  1239             log.Append(_L( "MailDeleted" ));
  1128             if (aParam1)
  1240             if (aParam1)
  1129                 {
  1241                 {
  1130                 RArray<TFSMailMsgId>* newEntries = static_cast<RArray<
  1242                   LogNewEntriesCount(log,aParam1);
  1131                         TFSMailMsgId>*> (aParam1);
       
  1132                 TInt newEntriesCount = newEntries->Count();
       
  1133                 log.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1134                 }
  1243                 }
  1135             if (aParam2)
  1244             if (aParam2)
  1136                 {
  1245                 {
  1137                 TFSMailMsgId* parentFolder =
  1246                   LogFolderName(log,aParam2);
  1138                         static_cast<TFSMailMsgId*> (aParam2);
       
  1139                 TBuf<20> folderName;
       
  1140                 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1141                     {
       
  1142                     log.Append(folderName);
       
  1143                     }
       
  1144                 }
  1247                 }
  1145             break;
  1248             break;
  1146 
  1249 
  1147             // Mails moved
  1250             // Mails moved
  1148             // aParam1: RArray<TFSMailMsgId>* aEntries
  1251             // aParam1: RArray<TFSMailMsgId>* aEntries
  1150             // aParam3: TFSMailMsgId* aOldParentFolder
  1253             // aParam3: TFSMailMsgId* aOldParentFolder
  1151         case TFSEventMailMoved:
  1254         case TFSEventMailMoved:
  1152             log.Append(_L( "MailMoved" ));
  1255             log.Append(_L( "MailMoved" ));
  1153             if (aParam1)
  1256             if (aParam1)
  1154                 {
  1257                 {
  1155                 RArray<TFSMailMsgId>* newEntries = static_cast<RArray<
  1258                  LogNewEntriesCount(log,aParam1);
  1156                         TFSMailMsgId>*> (aParam1);
       
  1157                 TInt newEntriesCount = newEntries->Count();
       
  1158                 log.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1159                 }
  1259                 }
  1160             if (aParam2)
  1260             if (aParam2)
  1161                 {
  1261                 {
  1162                 TFSMailMsgId* parentFolder =
  1262                  LogFolderName(log,aParam2);
  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                 }
  1263                 }
  1171             if (aParam3)
  1264             if (aParam3)
  1172                 {
  1265                 {
  1173                 TFSMailMsgId* parentFolder =
  1266                  LogFolderName(log,aParam3);
  1174                         static_cast<TFSMailMsgId*> (aParam3);
       
  1175                 TBuf<20> folderName;
       
  1176                 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1177                     {
       
  1178                     log.Append(folderName);
       
  1179                     }
       
  1180                 }
  1267                 }
  1181             break;
  1268             break;
  1182 
  1269 
  1183             // Mails copied
  1270             // Mails copied
  1184             // aParam1: RArray<TFSMailMsgId>* aNewEntries
  1271             // aParam1: RArray<TFSMailMsgId>* aNewEntries
  1194             // aParam3: NULL 
  1281             // aParam3: NULL 
  1195         case TFSEventNewFolder:
  1282         case TFSEventNewFolder:
  1196             log.Append(_L( "NewFolder" ));
  1283             log.Append(_L( "NewFolder" ));
  1197             if (aParam1)
  1284             if (aParam1)
  1198                 {
  1285                 {
  1199                 RArray<TFSMailMsgId>* newEntries = static_cast<RArray<
  1286                   LogNewEntriesCount(log,aParam1);
  1200                         TFSMailMsgId>*> (aParam1);
       
  1201                 TInt newEntriesCount = newEntries->Count();
       
  1202                 log.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1203                 }
  1287                 }
  1204             if (aParam2)
  1288             if (aParam2)
  1205                 {
  1289                 {
  1206                 TFSMailMsgId* parentFolder =
  1290                   LogFolderName(log,aParam2);
  1207                         static_cast<TFSMailMsgId*> (aParam2);
       
  1208                 TBuf<20> folderName;
       
  1209                 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1210                     {
       
  1211                     log.Append(folderName);
       
  1212                     }
       
  1213                 }
  1291                 }
  1214             break;
  1292             break;
  1215 
  1293 
  1216             // Folders changed
  1294             // Folders changed
  1217             // aParam1: RArray<TFSMailMsgId>* aEntries
  1295             // aParam1: RArray<TFSMailMsgId>* aEntries
  1219             // aParam3: NULL
  1297             // aParam3: NULL
  1220         case TFSEventFolderChanged:
  1298         case TFSEventFolderChanged:
  1221             log.Append(_L( "FolderChanged" ));
  1299             log.Append(_L( "FolderChanged" ));
  1222             if (aParam1)
  1300             if (aParam1)
  1223                 {
  1301                 {
  1224                 RArray<TFSMailMsgId>* newEntries = static_cast<RArray<
  1302                   LogNewEntriesCount(log,aParam1);
  1225                         TFSMailMsgId>*> (aParam1);
       
  1226                 TInt newEntriesCount = newEntries->Count();
       
  1227                 log.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1228                 }
  1303                 }
  1229             if (aParam2)
  1304             if (aParam2)
  1230                 {
  1305                 {
  1231                 TFSMailMsgId* parentFolder =
  1306                   LogFolderName(log,aParam2);
  1232                         static_cast<TFSMailMsgId*> (aParam2);
       
  1233                 TBuf<20> folderName;
       
  1234                 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1235                     {
       
  1236                     log.Append(folderName);
       
  1237                     }
       
  1238                 }
  1307                 }
  1239             break;
  1308             break;
  1240 
  1309 
  1241             // Folders deleted
  1310             // Folders deleted
  1242             // aParam1: RArray<TFSMailMsgId>* aEntries
  1311             // aParam1: RArray<TFSMailMsgId>* aEntries
  1244             // aParam3: NULL
  1313             // aParam3: NULL
  1245         case TFSEventFoldersDeleted:
  1314         case TFSEventFoldersDeleted:
  1246             log.Append(_L( "FoldersDeleted" ));
  1315             log.Append(_L( "FoldersDeleted" ));
  1247             if (aParam1)
  1316             if (aParam1)
  1248                 {
  1317                 {
  1249                 RArray<TFSMailMsgId>* newEntries = static_cast<RArray<
  1318                   LogNewEntriesCount(log,aParam1);
  1250                         TFSMailMsgId>*> (aParam1);
       
  1251                 TInt newEntriesCount = newEntries->Count();
       
  1252                 log.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1253                 }
  1319                 }
  1254             if (aParam2)
  1320             if (aParam2)
  1255                 {
  1321                 {
  1256                 TFSMailMsgId* parentFolder =
  1322                   LogFolderName(log,aParam2);
  1257                         static_cast<TFSMailMsgId*> (aParam2);
       
  1258                 TBuf<20> folderName;
       
  1259                 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1260                     {
       
  1261                     log.Append(folderName);
       
  1262                     }
       
  1263                 }
  1323                 }
  1264             break;
  1324             break;
  1265 
  1325 
  1266             // Folders moved
  1326             // Folders moved
  1267             // aParam1: RArray<TFSMailMsgId>* aEntries
  1327             // aParam1: RArray<TFSMailMsgId>* aEntries
  1287             // aParam3: NULL
  1347             // aParam3: NULL
  1288         case TFSEventMailDeletedFromViewer:
  1348         case TFSEventMailDeletedFromViewer:
  1289             log.Append(_L( "MailDeletedFromViewer" ));
  1349             log.Append(_L( "MailDeletedFromViewer" ));
  1290             if (aParam1)
  1350             if (aParam1)
  1291                 {
  1351                 {
  1292                 RArray<TFSMailMsgId>* newEntries = static_cast<RArray<
  1352                   LogNewEntriesCount(log,aParam1);
  1293                         TFSMailMsgId>*> (aParam1);
       
  1294                 TInt newEntriesCount = newEntries->Count();
       
  1295                 log.AppendFormat(_L("(%d)"), newEntriesCount);
       
  1296                 }
  1353                 }
  1297             if (aParam2)
  1354             if (aParam2)
  1298                 {
  1355                 {
  1299                 TFSMailMsgId* parentFolder =
  1356                   LogFolderName(log,aParam2);
  1300                         static_cast<TFSMailMsgId*> (aParam2);
       
  1301                 TBuf<20> folderName;
       
  1302                 if (KErrNone == GetFolderNameFromId(*parentFolder, folderName))
       
  1303                     {
       
  1304                     log.Append(folderName);
       
  1305                     }
       
  1306                 }
  1357                 }
  1307             break;
  1358             break;
  1308 
  1359 
  1309         default:
  1360         default:
  1310             log.Append(_L( "Unknown" ));
  1361             log.Append(_L( "Unknown" ));
  1319 // -----------------------------------------------------------------------------
  1370 // -----------------------------------------------------------------------------
  1320 //
  1371 //
  1321 void CPopImapProfileTester::LogTFSProgress(const TDesC& aLogText,
  1372 void CPopImapProfileTester::LogTFSProgress(const TDesC& aLogText,
  1322         const TFSProgress::TFSProgressStatus aProgress, TInt aReqId)
  1373         const TFSProgress::TFSProgressStatus aProgress, TInt aReqId)
  1323     {
  1374     {
  1324     TBuf<100> log(aLogText);
  1375     TBuf<KMaxBufLen> log(aLogText);
  1325     if (aReqId >= 0)
  1376     if (aReqId >= 0)
  1326         {
  1377         {
  1327         log.AppendFormat(_L("%d-"), aReqId);
  1378         log.AppendFormat(_L("%d-"), aReqId);
  1328         }
  1379         }
  1329 
  1380 
  1377 // -----------------------------------------------------------------------------
  1428 // -----------------------------------------------------------------------------
  1378 //
  1429 //
  1379 void CPopImapProfileTester::LogTSSMailSyncState(const TDesC& aLogText,
  1430 void CPopImapProfileTester::LogTSSMailSyncState(const TDesC& aLogText,
  1380         const TSSMailSyncState aState)
  1431         const TSSMailSyncState aState)
  1381     {
  1432     {
  1382     TBuf<100> log(aLogText);
  1433     TBuf<KMaxBufLen> log(aLogText);
  1383     switch (aState)
  1434     switch (aState)
  1384         {
  1435         {
  1385         case Idle:
  1436         case Idle:
  1386             log.Append(_L("Idle"));
  1437             log.Append(_L("Idle"));
  1387             break;
  1438             break;
  1485 TInt CPopImapProfileTester::GetFolderNameFromId(TFSMailMsgId aFolderId,
  1536 TInt CPopImapProfileTester::GetFolderNameFromId(TFSMailMsgId aFolderId,
  1486         TDes& aFolderName)
  1537         TDes& aFolderName)
  1487     {
  1538     {
  1488     RPointerArray<CFSMailFolder>& folders = iIPSMailbox->ListFolders();
  1539     RPointerArray<CFSMailFolder>& folders = iIPSMailbox->ListFolders();
  1489     TInt err(KErrNotFound);
  1540     TInt err(KErrNotFound);
  1490     for (TInt i = 0; i < folders.Count(); i++)
  1541 	TInt foldersCount = folders.Count();
       
  1542     for (TInt i = 0; i < foldersCount; i++)
  1491         {
  1543         {
  1492         if (folders[i]->GetFolderId() == aFolderId)
  1544         if (folders[i]->GetFolderId() == aFolderId)
  1493             {
  1545             {
  1494             aFolderName = folders[i]->GetFolderName();
  1546             aFolderName = folders[i]->GetFolderName();
  1495             err = KErrNone;
  1547             err = KErrNone;