messagingfw/msgtest/testutils/email/inc/EmailTestUtils.h
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef EMAIL_TEST_H_
       
    17 #define EMAIL_TEST_H_
       
    18 
       
    19 #include "msvtestutils.h"
       
    20 #include <e32test.h>
       
    21 #include <e32uid.h>
       
    22 #include <msvruids.h>
       
    23 #include <mtsr.h>
       
    24 #include <msvapi.h>
       
    25 #include <mtclreg.h> // CClientMtmRegistry
       
    26 #include <miutset.h>
       
    27 #include <smtpset.h>
       
    28 #include <pop3set.h>
       
    29 #include <imapset.h>
       
    30 #include <imcvrecv.h>
       
    31 #include <smtcmtm.h>
       
    32 #include <popcmtm.h>
       
    33 #include <impcmtm.h>
       
    34 
       
    35 #define KMailtestPath			_L("c:\\mailtest\\")
       
    36 #define KRfc822Dir				_L("c:\\mailtest\\rfc822\\")
       
    37 #define KEmailDataDir			_L("c:\\logs\\Email\\")
       
    38 
       
    39 #define KImcmResourceLocation	_L("z:\\system\\data\\imcm.r01")
       
    40 #define pop3DatFile				_L("c:\\system\\mtm\\pops.dat")
       
    41 #define smtpDatFile				_L("c:\\system\\mtm\\smts.dat")
       
    42 #define imap4DatFile			_L("c:\\system\\mtm\\imps.dat")
       
    43 
       
    44 // used for writing to logs
       
    45 #define KFileNameHeaders		_L("Entry_822Headers.txt")
       
    46 #define KFileNameMimeHeaders	_L("Entry_MimeHeaders.txt")
       
    47 
       
    48 #define KPeriod					10000	// period of timer
       
    49 
       
    50 const TUid KUidMsvTechnologyGroupEmail	= {0x10001671}; 
       
    51 _LIT(KPop3ServerMtmFileName, "z:\\system\\libs\\pops.dll");
       
    52 _LIT(KSmtpServerMtmFileName, "z:\\system\\libs\\smts.dll");
       
    53 _LIT(KImap4ServerMtmFileName, "z:\\system\\libs\\imps.dll");
       
    54 _LIT(KPop3ClientMtmFileName, "z:\\system\\libs\\imcm.dll");
       
    55 _LIT(KSmtpClientMtmFileName, "z:\\system\\libs\\imcm.dll");
       
    56 _LIT(KImap4ClientMtmFileName, "z:\\system\\libs\\imcm.dll");
       
    57 
       
    58 // The following are dummy ui mtm filenames - they are never instantiated.
       
    59 _LIT(KPop3DataLayerFileName, "z:\\system\\libs\\dummypop3uimtm.dll");
       
    60 _LIT(KSmtpDataLayerFileName, "z:\\system\\libs\\dummysmtpuimtm.dll");
       
    61 _LIT(KImap4DataLayerFileName, "z:\\system\\libs\\dummyimap4uimtm.dll");
       
    62 
       
    63 enum TEmailTestUtilsPanic
       
    64 	{
       
    65 	KErrNotOnClientSide
       
    66 	};
       
    67 
       
    68 class CEmailTestUtils : public CMsvTestUtils
       
    69 	{
       
    70 public:
       
    71 	IMPORT_C static CEmailTestUtils* NewL(RTest& aRTest, TUint aCreationFlags = ETuNone);
       
    72 	IMPORT_C static CEmailTestUtils* NewLC(RTest& aRTest, TUint aCreationFlags = ETuNone);
       
    73 
       
    74 	IMPORT_C void CreateAllTestDirectories();
       
    75 
       
    76 	IMPORT_C void InstallSmtpMtmGroupL();
       
    77 	IMPORT_C void InstallPopMtmGroupL();
       
    78 	IMPORT_C void InstallImapMtmGroupL();
       
    79 
       
    80 	IMPORT_C void InstantiateImapClientMtmL();
       
    81 	IMPORT_C void InstantiatePopClientMtmL();
       
    82 	IMPORT_C void InstantiateSmtpClientMtmL();
       
    83 
       
    84 	IMPORT_C void InstantiateImapServerMtmL();
       
    85 	IMPORT_C void InstantiatePopServerMtmL();
       
    86 	IMPORT_C void InstantiateSmtpServerMtmL();
       
    87 
       
    88 	IMPORT_C void CreateMessageFilesL(TMsvId aFinalServiceId, TMsvId aCreateInFolderId);
       
    89 	IMPORT_C void CreateMessageFilesL(TMsvId aFinalServiceId, TMsvId aCreateInFolderId,const TDesC& aPath);
       
    90 	IMPORT_C void CreateMessageL(const TDesC& filename, TMsvId aFinalServiceId, TMsvId aCreateInFolderId);
       
    91 
       
    92 	IMPORT_C void CreateImapServerMtmRegL();
       
    93 	IMPORT_C void CreateSmtpServerMtmRegL();
       
    94 	IMPORT_C void CreatePopServerMtmRegL();
       
    95 
       
    96 	IMPORT_C TMsvId CreateImapServiceL();
       
    97 	IMPORT_C TMsvId CreateSmtpServiceL();
       
    98 	IMPORT_C TMsvId CreatePopServiceL();
       
    99 
       
   100 	IMPORT_C void DeleteImapServiceL();
       
   101 	IMPORT_C void DeleteSmtpServiceL();
       
   102 	IMPORT_C void DeletePopServiceL();
       
   103 	IMPORT_C void DeleteScriptFilesFromLogsDirL();
       
   104 
       
   105 	IMPORT_C TMsvId FindImapServiceL();
       
   106 	IMPORT_C TMsvId FindSmtpServiceL();
       
   107 	IMPORT_C TMsvId FindPopServiceL();
       
   108 
       
   109 	IMPORT_C void CopyScriptFileL(const TDesC& aSourceFile, const TDesC& aDestDirectory, const TDesC& aPortNumber);
       
   110 	IMPORT_C void CopyScriptFileL(const TDesC& aSourceFile, const TDesC& aPortNumber);
       
   111 
       
   112 	IMPORT_C void StartConnectionL(TUint32 aIAP);
       
   113 
       
   114 	IMPORT_C void Reset();
       
   115 	IMPORT_C void ClearEmailAccountsL();
       
   116 	IMPORT_C const TDesC8& MachineName();
       
   117 	IMPORT_C ~CEmailTestUtils();
       
   118 
       
   119 	//From CMsvTestUtils
       
   120 	IMPORT_C void InstantiateClientMtmsL();
       
   121 	IMPORT_C void InstantiateServerMtmsL();
       
   122 	IMPORT_C void DeleteServicesL();
       
   123 	IMPORT_C void CreateServicesL();
       
   124 	IMPORT_C void FindExistingServicesL();
       
   125 	IMPORT_C void InstallMtmGroupsL();
       
   126 	IMPORT_C void CreateServerMtmRegsL();
       
   127 	IMPORT_C void ListChildrenL(RFile& aFile, CDir& rfcFileList, TInt& aCount, TInt& aEntryCount, TBool aReplace = ETrue, TBool aOtherFiles = ETrue);
       
   128 	void SetFolderType(TMsvEntry& aMsvEntry, TPtrC& type);
       
   129 
       
   130 private:
       
   131 	CEmailTestUtils(RTest& aRTest);
       
   132 	void DisplayLogEventData(const CLogEvent& /*aEvent*/, TBool /*aToFile*/, RFile& /*aFile*/) {};
       
   133 	void ConstructL(TUint aCreationFlags);
       
   134 	void DeleteCurrentMtm();
       
   135 
       
   136 	void DisplayMimeHeaderL(TMsvId aId, CMsvStore& fileStore, const TFileName& aFilepath, TBool aReplace);
       
   137 	void DisplayHeaderL(TMsvId aId, CMsvStore& fileStore, const TFileName& aFilepath, TBool aReplace);
       
   138 	void PrintRecipients(CDesC8Array& list, const TDesC& label, RFile file);
       
   139 	void PrintRecipientsL(CDesC16Array& list, const TDesC& label, RFile file);
       
   140 	void Panic(TInt aPanic);
       
   141 	void Panic(TEmailTestUtilsPanic aPanic);
       
   142 
       
   143 	void ReadDataL(CImRecvConvert* recvConvert, TFileName fileName);
       
   144 
       
   145 public:
       
   146 	CImap4ClientMtm*		iImapClientMtm;
       
   147 	CPop3ClientMtm*			iPopClientMtm;
       
   148 	CSmtpClientMtm*			iSmtpClientMtm;
       
   149 
       
   150 	CBaseServerMtm*			iImapServerMtm;
       
   151 	CBaseServerMtm*			iPopServerMtm;
       
   152 	CBaseServerMtm*			iSmtpServerMtm;
       
   153 
       
   154 	TMsvId					iImapServiceId;
       
   155 	TMsvId					iSmtpServiceId;
       
   156 	TMsvId					iPopServiceId;
       
   157 	
       
   158 private:
       
   159 	HBufC8*                 iMachineName;
       
   160 	};
       
   161 
       
   162 #define EmailTEST_PANIC _L("Email_Test")
       
   163 
       
   164 #endif