email/pop3andsmtpmtm/clientmtms/test/src/T_impc01.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name of test harness: T_IMPC01
       
    15 // Component: IMCM
       
    16 // Owner: KP
       
    17 // Brief description of test harness:
       
    18 // Tests CImImap4GetMail - tests combination of copy/move/populate 
       
    19 // new/all/selection when the user is already connected; connects, does 
       
    20 // operation, disconnects; connects, does operation and stays online.
       
    21 // Detailed description of test harness:
       
    22 // As above.
       
    23 // Input files required to run test harness:
       
    24 // None
       
    25 // Output files produced by running test harness:
       
    26 // <DRIVE>:\msglogs\T_IMPC01.<PLATFORM>.<VARIANT>.LOG.txt
       
    27 // Description of how to build test harness:
       
    28 // cd \msg\imcm\
       
    29 // bldmake bldfiles
       
    30 // abld test build
       
    31 // Description of how to run test harness:
       
    32 // The following instructions are the same for all platforms:
       
    33 // 1. Build T_DB test harness from COMMDB component:
       
    34 // cd \commdb\group
       
    35 // bldmake bldfiles
       
    36 // abld test build t_db
       
    37 // 2. Build the test utilities:
       
    38 // cd \msg\testutils\group\
       
    39 // bldmake bldfiles
       
    40 // abld build
       
    41 // WINS running instructions:
       
    42 // 1. \epoc32\release\wins\<VARIANT>\T_IMPC01.exe can be used at the command prompt
       
    43 // or executable can be run from Windows Explorer.
       
    44 // All other platform running instructions:
       
    45 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_IMPC01.exe onto the other platform
       
    46 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into 
       
    47 // <DRIVE>:\system\libs on the other platform
       
    48 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into 
       
    49 // <DRIVE>:\system\libs on the other platform
       
    50 // 4. Run T_IMPC01.exe on the other platform
       
    51 // 
       
    52 //
       
    53 
       
    54 #include "emailtestutils.h"
       
    55 #include <txtrich.h>
       
    56 #include <commdb.h>
       
    57 #include "TESTENV.h"
       
    58 #include <imapconnectionobserver.h>
       
    59 #include <bacline.h>
       
    60 #include <cemailaccounts.h>
       
    61 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    62 #include "cimmessagepart.h"
       
    63 #endif
       
    64 
       
    65 // For loading the serial comms device drivers 
       
    66 #if defined (__WINS__)
       
    67 	#define PDD_NAME		_L("ECDRV")
       
    68 	#define LDD_NAME		_L("ECOMM")
       
    69 #else
       
    70 	#define PDD_NAME		_L("EUART1")
       
    71 	#define LDD_NAME		_L("ECOMM")
       
    72 #endif
       
    73 
       
    74 // local variables etc //
       
    75 
       
    76 class CDummyConnectionObserver : public MMsvImapConnectionObserver
       
    77 	{
       
    78 		void HandleImapConnectionEvent(TImapConnectionEvent aConnectionEvent);
       
    79 	};
       
    80 
       
    81 void CDummyConnectionObserver::HandleImapConnectionEvent(TImapConnectionEvent)
       
    82 	{
       
    83 	}
       
    84 
       
    85 
       
    86 
       
    87 _LIT(KImcmTest, "T_IMPC - Testing CImImap4GetMail");
       
    88 RTest test(KImcmTest);
       
    89 
       
    90 _LIT(KTestParams,"-testparams");
       
    91 enum TCmdLineArgs
       
    92 	{
       
    93 	EArgProgramName,
       
    94 	EArgTestParams,
       
    95 	EArgServerAddress,
       
    96 	EArgLogin,
       
    97 	EArgPassword,
       
    98 	EArgFolderPath,
       
    99 	EArgEnd
       
   100 	};
       
   101 
       
   102 
       
   103 LOCAL_D TMsvId imap4Service;
       
   104 LOCAL_D TMsvId smtpService;
       
   105 LOCAL_D TInt globalError;
       
   106 
       
   107 LOCAL_D CTrapCleanup* theCleanup;
       
   108 LOCAL_D CEmailTestUtils* testUtils;
       
   109 
       
   110 LOCAL_D CMsvOperation* msvOperation;
       
   111 LOCAL_D CMsvEntrySelection* msvSelection;
       
   112 LOCAL_D CConsoleBase* console;
       
   113 
       
   114 LOCAL_D CDummyConnectionObserver* dummyObserver;
       
   115 
       
   116 class COperationActive;
       
   117 LOCAL_D COperationActive* opActive;
       
   118 
       
   119 
       
   120 LOCAL_D CMsvEntrySelection* messageSelection;
       
   121 
       
   122 // Constants
       
   123 //For the IR use this account
       
   124 //_LIT(KImapServer, "mail.totalise.co.uk");
       
   125 //_LIT8(KLoginName, "n.kothuri");
       
   126 //_LIT8(KPassword, "mechoes");
       
   127 //_LIT8(KFolderPath, "");
       
   128 
       
   129 
       
   130 #if 1
       
   131 _LIT(KImapServer, "msexchange01.closedtest.intra");
       
   132 _LIT8(KFolderPath, "");
       
   133 
       
   134 #else
       
   135 _LIT(KImapServer, "msexchange01.closedtest.intra");
       
   136 _LIT8(KLoginName, "test");
       
   137 _LIT8(KPassword, "testtest");
       
   138 _LIT8(KFolderPath, "~/mail");
       
   139 #endif
       
   140 
       
   141 
       
   142 
       
   143 //
       
   144 class TestUiTimer : public CTimer
       
   145 	{
       
   146 public:
       
   147 	static TestUiTimer* NewLC(CConsoleBase* aConsole);
       
   148 	~TestUiTimer();
       
   149 
       
   150 	void RunL();
       
   151 	void DoCancel();
       
   152 	void ConstructL();
       
   153 	void IssueRequest();
       
   154 	void SetOperation(CMsvOperation* aOperation);
       
   155 	TTimeIntervalMicroSeconds32 period;
       
   156 	TPtrC Progress(TInt progressNumber);
       
   157 	void SetCancelState(TInt aState);
       
   158 protected:
       
   159 	TestUiTimer(CConsoleBase* aConsole);
       
   160 	
       
   161 	CConsoleBase*		iConsole;
       
   162 public:
       
   163 	CMsvOperation*		iOperation;
       
   164 private:
       
   165 	TInt	iCancelState;
       
   166 	};
       
   167 
       
   168 //
       
   169 TestUiTimer* TestUiTimer::NewLC(CConsoleBase* aConsole)
       
   170 	{
       
   171 	TestUiTimer* self = new(ELeave) TestUiTimer(aConsole);
       
   172 	CleanupStack::PushL(self);
       
   173 	self->ConstructL();
       
   174 	return self;
       
   175 	}
       
   176 
       
   177 TestUiTimer::TestUiTimer(CConsoleBase* aConsole)
       
   178 	: CTimer(1), iCancelState(KMaxTInt)
       
   179 	{
       
   180 	iConsole = aConsole;
       
   181 	period = 10000;
       
   182 	}
       
   183 
       
   184 TestUiTimer::~TestUiTimer()
       
   185 	{
       
   186 	delete iOperation;
       
   187 	}
       
   188 
       
   189 void TestUiTimer::ConstructL()
       
   190 	{
       
   191 	CTimer::ConstructL();
       
   192 	CActiveScheduler::Add(this);
       
   193 	}
       
   194 
       
   195 void TestUiTimer::IssueRequest()
       
   196 	{
       
   197 	After(period);
       
   198 	}
       
   199 
       
   200 void TestUiTimer::SetOperation(CMsvOperation* aOperation)
       
   201 	{
       
   202 	if(iOperation)
       
   203 		{
       
   204 		delete iOperation;
       
   205 		iOperation=NULL;
       
   206 		}
       
   207 	iOperation = aOperation;
       
   208 	}
       
   209 
       
   210 void TestUiTimer::DoCancel()
       
   211 	{
       
   212 	CTimer::DoCancel();
       
   213 	}
       
   214 
       
   215 TPtrC TestUiTimer::Progress(TInt progressNumber)
       
   216 	{
       
   217 	switch (progressNumber)
       
   218 		{
       
   219 		case 0:
       
   220 			return _L("Disconnected              ");
       
   221 		case 1:
       
   222 			return _L("Connecting                ");
       
   223 		case 2:
       
   224 			return _L("Idle                      ");
       
   225 		case 3:
       
   226 			return _L("Selecting                 ");
       
   227 		case 4:
       
   228 			return _L("Fetching                  ");
       
   229 		case 5:
       
   230 			return _L("Appending                 ");
       
   231 		case 6:
       
   232 			return _L("Copying                   ");
       
   233 		case 7:
       
   234 			return _L("Deleting                  ");
       
   235 		case 8:
       
   236 			return _L("Syncing                   ");
       
   237 		case 9:
       
   238 			return _L("Disconnecting             ");
       
   239 		case 10:
       
   240 			return _L("Busy                      ");
       
   241 		case 11:
       
   242 			return _L("Moving                    ");
       
   243 		case 12:
       
   244 			return _L("Copying New Mail          ");
       
   245 		case 13:
       
   246 			return _L("Moving New Mail           ");
       
   247 		case 14:
       
   248 			return _L("Copying Mail Selection    ");
       
   249 		case 15:
       
   250 			return _L("Moving Mail Selection     ");
       
   251 		case 16:
       
   252 			return _L("Copying All Mail          ");
       
   253 		case 17:
       
   254 			return _L("Moving All Mail           ");
       
   255 		case 18:
       
   256 			return _L("Populating New Mail       ");
       
   257 		case 19:
       
   258 			return _L("Populating All Mail       ");
       
   259 		case 20:
       
   260 			return _L("Populating Mail Selection ");
       
   261 		default:
       
   262 			return _L("Unknown Progress          ");
       
   263 		}
       
   264 	}
       
   265 
       
   266 void TestUiTimer::SetCancelState(TInt aState)
       
   267 	{
       
   268 	iCancelState = aState;
       
   269 	}
       
   270 
       
   271 void TestUiTimer::RunL()
       
   272 	{
       
   273 	// display the current progress
       
   274 	if(iOperation!=NULL)
       
   275 		{
       
   276 		TImap4GenericProgress temp;	
       
   277 		TPckgC<TImap4GenericProgress> paramPack(temp);
       
   278 		paramPack.Set(iOperation->ProgressL());
       
   279 		TImap4GenericProgress progress=paramPack();	
       
   280 
       
   281 		if (iCancelState == progress.iImap4SubStateProgress)
       
   282 			{
       
   283 			iConsole->Printf(_L("	Calling Cancel\n"));
       
   284 			iOperation->Cancel();
       
   285 			}
       
   286 
       
   287 		iConsole->SetPos(0, 12);
       
   288 		TBuf<80> progressBuf = Progress(progress.iState);
       
   289 		iConsole->Printf(TRefByValue<const TDesC>_L("   Super Operation Progress: %S           "), &progressBuf);
       
   290 		iConsole->SetPos(0, 13);
       
   291 		progressBuf = Progress(progress.iImap4SubStateProgress);
       
   292 		iConsole->Printf(TRefByValue<const TDesC>_L("   Sub Operation Progress  : %S           "), &progressBuf);
       
   293 		iConsole->SetPos(0, 14);
       
   294 		iConsole->Printf(TRefByValue<const TDesC>_L("   Progress:  %d/%d %d/%d Total:%d             \n"),
       
   295 					progress.iMsgsDone,
       
   296 					progress.iMsgsToDo,
       
   297 					progress.iBytesDone,
       
   298 					progress.iBytesToDo,
       
   299 					progress.iTotalSize);
       
   300 
       
   301 		iConsole->SetPos(0, 15);
       
   302 		iConsole->Printf(TRefByValue<const TDesC>_L("   Error: %d                             \n"), progress.iErrorCode);
       
   303 		if (!globalError && progress.iErrorCode)
       
   304 			globalError=progress.iErrorCode;
       
   305 		}
       
   306 	IssueRequest();
       
   307 	};
       
   308 
       
   309 //
       
   310 
       
   311 
       
   312 
       
   313 
       
   314 
       
   315 class COperationActive : public CActive
       
   316 	{
       
   317 public:
       
   318 	COperationActive();
       
   319 	~COperationActive();
       
   320 	static COperationActive* NewL();
       
   321 	void StartL();
       
   322 	void SetOperation(CMsvOperation*);
       
   323 	void SetCancelState(TInt aCancelState);
       
   324 	
       
   325 protected:
       
   326 	void DoCancel();
       
   327 	void RunL();
       
   328 public:	
       
   329 	TestUiTimer* iTimer;
       
   330 private:
       
   331 	TBool iSetActive;
       
   332 	};
       
   333 
       
   334 //
       
   335 COperationActive::COperationActive()
       
   336 : CActive(0)
       
   337 	{
       
   338 	}
       
   339 
       
   340 COperationActive::~COperationActive()
       
   341 	{
       
   342 	Cancel();
       
   343 	delete iTimer;
       
   344 	}
       
   345 
       
   346 COperationActive* COperationActive::NewL()
       
   347 	{
       
   348 	COperationActive* self = new (ELeave) COperationActive;
       
   349 	CActiveScheduler::Add(self);
       
   350 
       
   351 	self->iSetActive = ETrue;
       
   352 	self->iTimer = TestUiTimer::NewLC(test.Console());
       
   353 	CleanupStack::Pop();
       
   354 	return self;
       
   355 	}
       
   356 
       
   357 void COperationActive::DoCancel()
       
   358 	{
       
   359 	iTimer->DoCancel();
       
   360 	}
       
   361 
       
   362 void COperationActive::StartL()
       
   363 	{
       
   364 	globalError=0;
       
   365 	iTimer->IssueRequest();	// Start the connect observation timer
       
   366 	SetActive();
       
   367 	test.Console()->SetPos(0, 17);
       
   368 	test.Printf(TRefByValue<const TDesC>_L("Operation TRequestStatus %d"), iStatus);
       
   369 	}
       
   370 
       
   371 void COperationActive::SetOperation(CMsvOperation *aOperation)
       
   372 	{
       
   373 	iTimer->SetOperation(aOperation);
       
   374 	}
       
   375 
       
   376 void COperationActive::SetCancelState(TInt aCancelState)
       
   377 	{
       
   378 	iTimer->SetCancelState(aCancelState);
       
   379 	}
       
   380 
       
   381 void COperationActive::RunL() 
       
   382 	{
       
   383 	iTimer->Cancel();
       
   384 	test.Console()->SetPos(25, 17);
       
   385 	test.Printf(_L("                "));
       
   386 	test.Console()->SetPos(0, 17);
       
   387 	test.Printf(TRefByValue<const TDesC>_L("Operation TRequestStatus %d"), iStatus);
       
   388 	CActiveScheduler::Stop();
       
   389 	}
       
   390 
       
   391 //
       
   392 
       
   393 LOCAL_C void ConnectAndSyncCompleteL()
       
   394 	{
       
   395 	testUtils->WriteComment(_L("Inside ConnectAndSyncCompleteL "));
       
   396 
       
   397 	testUtils->WriteComment(_L("Connecting to the IMAP4 server"));
       
   398 
       
   399 	//CleanupStack::PushL(dummyObserver);
       
   400 
       
   401 	TPckg<MMsvImapConnectionObserver*> aParameter(dummyObserver);
       
   402 
       
   403 	msvSelection->ResizeL(0);
       
   404 	msvSelection->AppendL(imap4Service);
       
   405 
       
   406 	opActive->iStatus = KRequestPending;
       
   407 	
       
   408 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndSyncCompleteAfterDisconnect, *msvSelection, aParameter, opActive->iStatus);
       
   409 	opActive->SetOperation(msvOperation);
       
   410 	opActive->StartL();	// Start the connect active object
       
   411 	testUtils->WriteComment(_L("End of  ConnectAndSyncCompleteL "));
       
   412 	}
       
   413 
       
   414 
       
   415 LOCAL_C void ConnectAndSyncCompleteAfterConnect()
       
   416 	{
       
   417 	testUtils->WriteComment(_L("Connect And Sync Complete After Connect"));
       
   418 	msvSelection->ResizeL(0);
       
   419 	
       
   420 	TPckg<MMsvImapConnectionObserver*> aParameter(dummyObserver);
       
   421 	
       
   422 	msvSelection->AppendL(imap4Service);
       
   423 	opActive->iStatus = KRequestPending;
       
   424 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndSyncCompleteAfterConnect, *msvSelection, aParameter, opActive->iStatus);
       
   425 	
       
   426 	//start the operationh 
       
   427 	opActive->SetOperation(msvOperation);
       
   428 	opActive->StartL();	
       
   429 	}
       
   430 
       
   431 LOCAL_C void ConnectToServerL()
       
   432 	{
       
   433 	testUtils->WriteComment(_L("Connecting to the IMAP4 server"));
       
   434 	TBuf8<1> aParameter;
       
   435 	msvSelection->ResizeL(0);
       
   436 	msvSelection->AppendL(imap4Service);
       
   437 	
       
   438 	opActive->iStatus = KRequestPending;
       
   439 	
       
   440 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnect, *msvSelection, aParameter, opActive->iStatus);
       
   441 	opActive->SetOperation(msvOperation);
       
   442 	opActive->StartL();	// Start the connect active object
       
   443 	}
       
   444 
       
   445 LOCAL_C void SynchronizeRemoteInboxL()
       
   446 	{
       
   447 	testUtils->WriteComment(_L("Synchronizing Remote Inbox")); 
       
   448 
       
   449 	msvSelection->ResizeL(0);
       
   450 	msvSelection->AppendL(imap4Service);
       
   451 
       
   452 	TImImap4GetMailInfo imap4GetMailInfo;
       
   453 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   454 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   455 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   456 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   457 
       
   458 	opActive->iStatus = KRequestPending;
       
   459 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMFullSync, *msvSelection, package, opActive->iStatus);
       
   460 	opActive->SetOperation(msvOperation);
       
   461 	opActive->StartL();	// Start the active object
       
   462 	}
       
   463 
       
   464 LOCAL_C void DisconnectFromServerL()
       
   465 	{
       
   466 	testUtils->WriteComment(_L("Disconnecting from the IMAP4 server"));
       
   467 	TBuf8<1> aParameter;
       
   468 	msvSelection->ResizeL(0);
       
   469 	msvSelection->AppendL(imap4Service);
       
   470 	
       
   471 	opActive->iStatus = KRequestPending;
       
   472 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMDisconnect, *msvSelection, aParameter, opActive->iStatus);
       
   473 	opActive->SetOperation(msvOperation);
       
   474 	opActive->StartL();	// Start the disconnect active object
       
   475 	}
       
   476 
       
   477 //
       
   478 // Get Mail when already Connected tests
       
   479 //
       
   480 
       
   481 LOCAL_C void CopyNewMailWhenAlreadyConnectedL()
       
   482 	{
       
   483 	testUtils->WriteComment(_L("Copying New Mail when already connected")); 
       
   484 
       
   485 	msvSelection->ResizeL(0);
       
   486 	msvSelection->AppendL(imap4Service);
       
   487 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   488 	
       
   489 	TImImap4GetMailInfo imap4GetMailInfo;
       
   490 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   491 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   492 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   493 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   494 	
       
   495 	opActive->iStatus = KRequestPending;
       
   496 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMCopyNewMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   497 	opActive->SetOperation(msvOperation);
       
   498 	opActive->StartL();	// Start the copy new mail active object
       
   499 	}
       
   500 
       
   501 LOCAL_C void CopyAllMailWhenAlreadyConnectedL()
       
   502 	{
       
   503 	testUtils->WriteComment(_L("Copying All Mail when already connected")); 
       
   504 
       
   505 	msvSelection->ResizeL(0);
       
   506 	msvSelection->AppendL(imap4Service);
       
   507 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   508 	
       
   509 	TImImap4GetMailInfo imap4GetMailInfo;
       
   510 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   511 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   512 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   513 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   514 	
       
   515 	opActive->iStatus = KRequestPending;
       
   516 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMCopyAllMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   517 	opActive->SetOperation(msvOperation);
       
   518 	opActive->StartL();	// Start the copy all mail active object
       
   519 	}
       
   520 
       
   521 LOCAL_C void CopyMailSelectionWhenAlreadyConnectedL()
       
   522 	{
       
   523 	testUtils->WriteComment(_L("Copying Mail Selection when already connected")); 
       
   524 
       
   525 	msvSelection->ResizeL(0);
       
   526 	msvSelection->AppendL(imap4Service);
       
   527 	msvSelection->AppendL(imap4Service+2); // message in remote inbox
       
   528 	
       
   529 	TImImap4GetMailInfo imap4GetMailInfo;
       
   530 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   531 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   532 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   533 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   534 	
       
   535 	opActive->iStatus = KRequestPending;
       
   536 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMCopyMailSelectionWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   537 	opActive->SetOperation(msvOperation);
       
   538 	opActive->StartL();	// Start the copy mail selection active object
       
   539 	}
       
   540 
       
   541 LOCAL_C void PopulateNewMessagesWhenAlreadyConnectedL()
       
   542 	{
       
   543 	testUtils->WriteComment(_L("Populating new messages when already connected")); 
       
   544 
       
   545 	msvSelection->ResizeL(0);
       
   546 	msvSelection->AppendL(imap4Service);
       
   547 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   548 
       
   549 	TImImap4GetMailInfo imap4GetMailInfo;
       
   550 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   551 	imap4GetMailInfo.iDestinationFolder = imap4Service+1; // remote inbox
       
   552 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   553 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   554 	
       
   555 	opActive->iStatus = KRequestPending;
       
   556 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMPopulateNewMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   557 	opActive->SetOperation(msvOperation);
       
   558 	opActive->StartL();	// Start the populate new mail active object
       
   559 	}
       
   560 
       
   561 LOCAL_C void PopulateAllMessagesWhenAlreadyConnectedL()
       
   562 	{
       
   563 	testUtils->WriteComment(_L("Populating all messages when already connected")); 
       
   564 
       
   565 	msvSelection->ResizeL(0);
       
   566 	msvSelection->AppendL(imap4Service);
       
   567 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   568 	
       
   569 	TImImap4GetMailInfo imap4GetMailInfo;
       
   570 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   571 	imap4GetMailInfo.iDestinationFolder = imap4Service+1; // remote inbox
       
   572 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   573 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   574 	
       
   575 	opActive->iStatus = KRequestPending;
       
   576 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMPopulateAllMailWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   577 	opActive->SetOperation(msvOperation);
       
   578 	opActive->StartL();	// Start the populate all mail active object
       
   579 	}
       
   580 
       
   581 LOCAL_C void PopulateMessageSelectionWhenAlreadyConnectedL()
       
   582 	{
       
   583 	testUtils->WriteComment(_L("Populating remote msg when already connected")); 
       
   584 
       
   585 	msvSelection->ResizeL(0);
       
   586 	msvSelection->AppendL(imap4Service);
       
   587 	msvSelection->AppendL(imap4Service+2); // message in the remote inbox (to populate)
       
   588 	
       
   589 	TImImap4GetMailInfo imap4GetMailInfo;
       
   590 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   591 	imap4GetMailInfo.iDestinationFolder = imap4Service; // service
       
   592 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   593 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   594 	
       
   595 	opActive->iStatus = KRequestPending;
       
   596 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMPopulateMailSelectionWhenAlreadyConnected, *msvSelection, package, opActive->iStatus);
       
   597 	opActive->SetOperation(msvOperation);
       
   598 	opActive->StartL();	// Start the populate message selection active object
       
   599 	}
       
   600 
       
   601 //
       
   602 // Connect, Get Mail and Disconnect tests
       
   603 //
       
   604 
       
   605 LOCAL_C void ConnectAndCopyNewMailAndDisconnectL()
       
   606 	{
       
   607 	testUtils->WriteComment(_L("Connect, Copying New Mail, Disconnect")); 
       
   608 
       
   609 	msvSelection->ResizeL(0);
       
   610 	msvSelection->AppendL(imap4Service);
       
   611 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   612 	
       
   613 	TImImap4GetMailInfo imap4GetMailInfo;
       
   614 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   615 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   616 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   617 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   618 	
       
   619 	opActive->iStatus = KRequestPending;
       
   620 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndCopyNewMailAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   621 	opActive->SetOperation(msvOperation);
       
   622 	opActive->StartL();	// Start the copy new mail active object
       
   623 	}
       
   624 
       
   625 LOCAL_C void ConnectAndCopyAllMailAndDisconnectL()
       
   626 	{
       
   627 	testUtils->WriteComment(_L("Connect, Copying All Mail, Disconnect")); 
       
   628 
       
   629 	msvSelection->ResizeL(0);
       
   630 	msvSelection->AppendL(imap4Service);
       
   631 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   632 	
       
   633 	TImImap4GetMailInfo imap4GetMailInfo;
       
   634 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   635 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   636 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   637 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   638 	
       
   639 	opActive->iStatus = KRequestPending;
       
   640 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndCopyAllMailAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   641 	opActive->SetOperation(msvOperation);
       
   642 	opActive->StartL();	// Start the copy all mail active object
       
   643 	}
       
   644 
       
   645 LOCAL_C void ConnectAndCopyMailSelectionAndDisconnectL(TBool aEmptyMessageSelection = EFalse)
       
   646 	{
       
   647 	testUtils->WriteComment(_L("Connect, Copying Mail Selection, Disconnect")); 
       
   648 
       
   649 	msvSelection->ResizeL(0);
       
   650 	msvSelection->AppendL(imap4Service);
       
   651 
       
   652 	if (!aEmptyMessageSelection)
       
   653 		msvSelection->AppendL(imap4Service+2); // message in remote inbox
       
   654 	
       
   655 	TImImap4GetMailInfo imap4GetMailInfo;
       
   656 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   657 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   658 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   659 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   660 	
       
   661 	opActive->iStatus = KRequestPending;
       
   662 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndCopyMailSelectionAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   663 	opActive->SetOperation(msvOperation);
       
   664 	opActive->StartL();	// Start the copy all mail active object
       
   665 	}
       
   666 
       
   667 LOCAL_C void ConnectAndPopulateNewMailAndDisconnectL()
       
   668 	{
       
   669 	testUtils->WriteComment(_L("Connect, Populate New Mail, Disconnect")); 
       
   670 
       
   671 	msvSelection->ResizeL(0);
       
   672 	msvSelection->AppendL(imap4Service);
       
   673 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   674 	
       
   675 	TImImap4GetMailInfo imap4GetMailInfo;
       
   676 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   677 	imap4GetMailInfo.iDestinationFolder = imap4Service; // service
       
   678 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   679 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   680 	
       
   681 	opActive->iStatus = KRequestPending;
       
   682 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateNewMailAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   683 	opActive->SetOperation(msvOperation);
       
   684 	opActive->StartL();	// Start the Populate new mail active object
       
   685 	}
       
   686 
       
   687 LOCAL_C void ConnectAndPopulateAllMailAndDisconnectL()
       
   688 	{
       
   689 	testUtils->WriteComment(_L("Connect, Populate All Mail, Disconnect")); 
       
   690 
       
   691 	msvSelection->ResizeL(0);
       
   692 	msvSelection->AppendL(imap4Service);
       
   693 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   694 	
       
   695 	TImImap4GetMailInfo imap4GetMailInfo;
       
   696 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   697 	imap4GetMailInfo.iDestinationFolder = imap4Service; // service
       
   698 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   699 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   700 	
       
   701 	opActive->iStatus = KRequestPending;
       
   702 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateAllMailAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   703 	opActive->SetOperation(msvOperation);
       
   704 	opActive->StartL();	// Start the Populate all mail active object
       
   705 	}
       
   706 
       
   707 LOCAL_C void ConnectAndPopulateMailSelectionAndDisconnectL()
       
   708 	{
       
   709 	testUtils->WriteComment(_L("Connect, Populating remote msg, Disconnect")); 
       
   710 
       
   711 	msvSelection->ResizeL(0);
       
   712 	msvSelection->AppendL(imap4Service);
       
   713 	msvSelection->AppendL(imap4Service+2); // message in the remote inbox (to populate)
       
   714 	
       
   715 	TImImap4GetMailInfo imap4GetMailInfo;
       
   716 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   717 	imap4GetMailInfo.iDestinationFolder = imap4Service; // service
       
   718 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   719 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   720 	
       
   721 	opActive->iStatus = KRequestPending;
       
   722 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateMailSelectionAndDisconnect, *msvSelection, package, opActive->iStatus);
       
   723 	opActive->SetOperation(msvOperation);
       
   724 	opActive->StartL();	// Start the populate message selection active object
       
   725 	}
       
   726 
       
   727 //
       
   728 // Connect, Get Mail and Stay Online tests
       
   729 //
       
   730 
       
   731 LOCAL_C void ConnectAndCopyNewMailAndStayOnlineL()
       
   732 	{
       
   733 	testUtils->WriteComment(_L("Connect, Copying New Mail, Stay Online")); 
       
   734 
       
   735 	msvSelection->ResizeL(0);
       
   736 	msvSelection->AppendL(imap4Service);
       
   737 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   738 	
       
   739 	TImImap4GetMailInfo imap4GetMailInfo;
       
   740 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   741 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   742 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   743 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   744 	
       
   745 	opActive->iStatus = KRequestPending;
       
   746 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndCopyNewMailAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   747 	opActive->SetOperation(msvOperation);
       
   748 	opActive->StartL();	// Start the copy new mail active object
       
   749 	}
       
   750 
       
   751 LOCAL_C void ConnectAndCopyAllMailAndStayOnlineL()
       
   752 	{
       
   753 	testUtils->WriteComment(_L("Connect, Copying All Mail, Stay Online")); 
       
   754 
       
   755 	msvSelection->ResizeL(0);
       
   756 	msvSelection->AppendL(imap4Service);
       
   757 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   758 	
       
   759 	TImImap4GetMailInfo imap4GetMailInfo;
       
   760 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   761 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   762 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   763 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   764 	
       
   765 	opActive->iStatus = KRequestPending;
       
   766 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndCopyAllMailAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   767 	opActive->SetOperation(msvOperation);
       
   768 	opActive->StartL();	// Start the copy all mail active object
       
   769 	}
       
   770 
       
   771 LOCAL_C void ConnectAndCopyMailSelectionAndStayOnlineL()
       
   772 	{
       
   773 	testUtils->WriteComment(_L("Connect, Copying Mail Selection, Stay Online")); 
       
   774 
       
   775 	msvSelection->ResizeL(0);
       
   776 	msvSelection->AppendL(imap4Service);
       
   777 	msvSelection->AppendL(imap4Service+2); // message in remote inbox
       
   778 	
       
   779 	TImImap4GetMailInfo imap4GetMailInfo;
       
   780 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   781 	imap4GetMailInfo.iDestinationFolder = KMsvGlobalInBoxIndexEntryIdValue;
       
   782 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   783 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   784 	
       
   785 	opActive->iStatus = KRequestPending;
       
   786 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndCopyMailSelectionAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   787 	opActive->SetOperation(msvOperation);
       
   788 	opActive->StartL();	// Start the copy message selection active object
       
   789 	}
       
   790 
       
   791 LOCAL_C void ConnectAndPopulateNewMailAndStayOnlineL()
       
   792 	{
       
   793 	testUtils->WriteComment(_L("Connect, Populate New Mail, Stay Online")); 
       
   794 
       
   795 	msvSelection->ResizeL(0);
       
   796 	msvSelection->AppendL(imap4Service);
       
   797 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   798 	
       
   799 	TImImap4GetMailInfo imap4GetMailInfo;
       
   800 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   801 	imap4GetMailInfo.iDestinationFolder = imap4Service; // service
       
   802 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   803 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   804 	
       
   805 	opActive->iStatus = KRequestPending;
       
   806 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateNewMailAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   807 	opActive->SetOperation(msvOperation);
       
   808 	opActive->StartL();	// Start the Populate new mail active object
       
   809 	}
       
   810 
       
   811 LOCAL_C void ConnectAndPopulateAllMailAndStayOnlineL()
       
   812 	{
       
   813 	testUtils->WriteComment(_L("Connect, Populate All Mail, Stay Online")); 
       
   814 
       
   815 	msvSelection->ResizeL(0);
       
   816 	msvSelection->AppendL(imap4Service);
       
   817 	msvSelection->AppendL(imap4Service+1); // remote inbox
       
   818 	
       
   819 	TImImap4GetMailInfo imap4GetMailInfo;
       
   820 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   821 	imap4GetMailInfo.iDestinationFolder = imap4Service; // service
       
   822 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   823 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   824 	
       
   825 	opActive->iStatus = KRequestPending;
       
   826 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateAllMailAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   827 	opActive->SetOperation(msvOperation);
       
   828 	opActive->StartL();	// Start the Populate all mail active object
       
   829 	}
       
   830 
       
   831 LOCAL_C void ConnectAndPopulateMailSelectionAndStayOnlineL()
       
   832 	{
       
   833 	testUtils->WriteComment(_L("Connect, Populating remote msg, Stay Online")); 
       
   834 
       
   835 	msvSelection->ResizeL(0);
       
   836 	msvSelection->AppendL(imap4Service);
       
   837 	msvSelection->AppendL(imap4Service+2); // message in the remote inbox (to populate)
       
   838 	
       
   839 	TImImap4GetMailInfo imap4GetMailInfo;
       
   840 	imap4GetMailInfo.iMaxEmailSize = KMaxTInt;
       
   841 	imap4GetMailInfo.iDestinationFolder = imap4Service; // service
       
   842 	imap4GetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   843 	TPckgBuf<TImImap4GetMailInfo> package(imap4GetMailInfo);
       
   844 	
       
   845 	opActive->iStatus = KRequestPending;
       
   846 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndPopulateMailSelectionAndStayOnline, *msvSelection, package, opActive->iStatus);
       
   847 	opActive->SetOperation(msvOperation);
       
   848 	opActive->StartL();	// Start the populate message selection active object
       
   849 	}
       
   850 
       
   851 LOCAL_C void CreateReplyEmailMessage()
       
   852 	{
       
   853 	testUtils->WriteComment(_L("Creating a Reply Email Message"));
       
   854 	msvSelection->ResizeL(0);
       
   855 	
       
   856 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   857 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
   858 	CleanupStack::PushL(messageSelection);
       
   859 	msvSelection->AppendL(imap4Service); //destination id
       
   860 	msvSelection->AppendL(messageSelection->At(1)); // message id to which the reply is to be assigned
       
   861 	
       
   862 	//create an object of type TImCreateMessageOptions
       
   863 	TImCreateMessageOptions ImapCreateMessage;
       
   864 	
       
   865 	//Initialize the member variables of TImCreateMessageOptions suitably 
       
   866 	ImapCreateMessage.iMsvPartList = KMsvMessagePartBody | KMsvMessagePartAttachments;
       
   867 	ImapCreateMessage.iMsvEmailTypeList = KMsvEmailTypeListMHTMLMessage;
       
   868 	ImapCreateMessage.iMessageType = KUidMsgTypeSMTP;
       
   869 	TPckgBuf<TImCreateMessageOptions> package(ImapCreateMessage);
       
   870 	
       
   871 	//set the status
       
   872 	opActive->iStatus = KRequestPending;
       
   873 	
       
   874 	//invoke the func InvokeAsyncFunctionL()
       
   875 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMCreateReplyEmailMessage, *msvSelection, package, opActive->iStatus);
       
   876 	
       
   877 	//start the operation
       
   878 	opActive->SetOperation(msvOperation);
       
   879 	opActive->StartL();	
       
   880 	CleanupStack::PopAndDestroy();      //messageSelection
       
   881 	testUtils->iMsvEntry->SetEntryL(imap4Service);
       
   882 	}
       
   883 
       
   884 LOCAL_C void CreateForwardEmailMessage()
       
   885 	{
       
   886 	testUtils->WriteComment(_L("Creating a Forward Email Message"));
       
   887 	msvSelection->ResizeL(0);
       
   888 	
       
   889 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   890 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
   891 	msvSelection->AppendL(imap4Service); //destination id
       
   892 	msvSelection->AppendL(messageSelection->At(1)); // message id to which the reply is to be assigned
       
   893 		
       
   894 	//create an object of type TImCreateMessageOptions
       
   895 	TImCreateMessageOptions ImapCreateMessage;
       
   896 	
       
   897 	//Initialize the member variables of TImCreateMessageOptions suitably 
       
   898 	ImapCreateMessage.iMsvPartList = KMsvMessagePartBody| KMsvMessagePartAttachments;;
       
   899 	ImapCreateMessage.iMsvEmailTypeList = KMsvEmailTypeListMHTMLMessage;
       
   900 	ImapCreateMessage.iMessageType = KUidMsgTypeSMTP;
       
   901 	TPckgBuf<TImCreateMessageOptions> package(ImapCreateMessage);
       
   902 	
       
   903 	//set the status
       
   904 	opActive->iStatus = KRequestPending;
       
   905 	
       
   906 	//invoke the func InvokeAsyncFunctionL()
       
   907 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMCreateForwardEmailMessage, *msvSelection, package, opActive->iStatus);
       
   908 																	
       
   909 	//start the operationh 
       
   910 	opActive->SetOperation(msvOperation);
       
   911 	opActive->StartL();	
       
   912 	delete messageSelection;
       
   913 	}
       
   914 
       
   915 LOCAL_C void CreateNewEmailMessage()
       
   916 	{
       
   917 	testUtils->WriteComment(_L("Creating a New Email Message"));
       
   918 	
       
   919 	TMsvPartList partList = (KMsvMessagePartBody | KMsvMessagePartAttachments);
       
   920 	TMsvEmailTypeList msvEmailTypeList = 0;
       
   921 	
       
   922 	TImCreateMessageOptions msgOptions;
       
   923 	msgOptions.iMessageType = KUidMsgTypeSMTP;
       
   924 	msgOptions.iMsvPartList = partList;
       
   925 	msgOptions.iMsvEmailTypeList = msvEmailTypeList;
       
   926 	TPckgBuf<TImCreateMessageOptions> options(msgOptions);
       
   927 
       
   928 	msvSelection->ResizeL(0);
       
   929 	msvSelection->AppendL(KMsvGlobalOutBoxIndexEntryId); // destination folder is Global Outbox
       
   930 	
       
   931 	opActive->iStatus = KRequestPending;
       
   932 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMCreateNewEmailMessage, *msvSelection, options, opActive->iStatus);
       
   933 	opActive->SetOperation(msvOperation);
       
   934 	opActive->StartL();	// Start the active object
       
   935 	}
       
   936 
       
   937 LOCAL_C void CreateForwardAsAttachmentEmailMessage()
       
   938 	{
       
   939 	testUtils->WriteComment(_L("Creating Forward As Attachment Email Message"));
       
   940 	msvSelection->ResizeL(0);
       
   941 	
       
   942 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   943 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
   944 	msvSelection->AppendL(imap4Service); //destination id
       
   945 	msvSelection->AppendL(messageSelection->At(1)); // message id to which the reply is to be assigned
       
   946 		
       
   947 	//create an object of type TImCreateMessageOptions
       
   948 	TImCreateMessageOptions ImapCreateMessage;
       
   949 	
       
   950 	//Initialize the member variables of TImCreateMessageOptions suitably 
       
   951 	ImapCreateMessage.iMsvPartList = KMsvMessagePartBody | KMsvMessagePartAttachments;
       
   952 	ImapCreateMessage.iMsvEmailTypeList = KMsvEmailTypeListMHTMLMessage;
       
   953 	ImapCreateMessage.iMessageType = KUidMsgTypeSMTP;
       
   954 	TPckgBuf<TImCreateMessageOptions> package(ImapCreateMessage);
       
   955 	
       
   956 	//set the status
       
   957 	opActive->iStatus = KRequestPending;
       
   958 	
       
   959 	//invoke the func InvokeAsyncFunctionL()
       
   960 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMCreateForwardAsAttachmentEmailMessage, *msvSelection, package, opActive->iStatus);
       
   961 																	
       
   962 	//start the operationh 
       
   963 	opActive->SetOperation(msvOperation);
       
   964 	opActive->StartL();	
       
   965 	delete messageSelection;
       
   966 	}
       
   967 
       
   968 LOCAL_C void CreateReceiptEmailMessage()
       
   969 	{
       
   970 	testUtils->WriteComment(_L("Creating a Forward Email Message"));
       
   971 	msvSelection->ResizeL(0);
       
   972 	
       
   973 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   974 	messageSelection = testUtils->iMsvEntry->ChildrenWithTypeL(KUidMsvMessageEntry);
       
   975 	msvSelection->AppendL(KMsvGlobalOutBoxIndexEntryId); //destination id
       
   976 	msvSelection->AppendL(messageSelection->At(4)); // message id to which the reply is to be assigned
       
   977 		
       
   978 	//create an object of type TImCreateMessageOptions
       
   979 	TImCreateMessageOptions ImapCreateMessage;
       
   980 	
       
   981 	//Initialize the member variables of TImCreateMessageOptions suitably 
       
   982 	ImapCreateMessage.iMsvPartList = KMsvMessagePartBody;
       
   983 	ImapCreateMessage.iMsvEmailTypeList = 0;
       
   984 	ImapCreateMessage.iMessageType = KUidMsgTypeSMTP;
       
   985 	TPckgBuf<TImCreateMessageOptions> package(ImapCreateMessage);
       
   986 	
       
   987 	//set the status
       
   988 	opActive->iStatus = KRequestPending;
       
   989 	
       
   990 	//invoke the func InvokeAsyncFunctionL()
       
   991 	msvOperation = testUtils->iImapClientMtm->InvokeAsyncFunctionL(KIMAP4MTMCreateReceiptEmailMessage, *msvSelection, package, opActive->iStatus);
       
   992 																	
       
   993 	//start the operationh 
       
   994 	opActive->SetOperation(msvOperation);
       
   995 	opActive->StartL();	
       
   996 	delete messageSelection;
       
   997 	}
       
   998 
       
   999 
       
  1000 
       
  1001 //
       
  1002 
       
  1003 LOCAL_C void ConnectAndSyncRemoteInboxAndDisconnectL()
       
  1004 	{
       
  1005 	console->SetPos(0, 6);
       
  1006 	test.Printf(_L("\nPerforming Tests\n"));
       
  1007 	console->SetPos(0, 7);
       
  1008 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1009 	ConnectToServerL();
       
  1010 	CActiveScheduler::Start();
       
  1011 
       
  1012 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1013 	if (globalError)
       
  1014 		return;
       
  1015 	opActive = COperationActive::NewL();
       
  1016 	CleanupStack::PushL(opActive);
       
  1017 	console->SetPos(0, 7);
       
  1018 	test.Printf(_L("Synchronize Remote Inbox                         \n"));
       
  1019 	SynchronizeRemoteInboxL();
       
  1020 	
       
  1021 
       
  1022 	CActiveScheduler::Start();
       
  1023 
       
  1024 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1025 	if (globalError)
       
  1026 		return;
       
  1027 	opActive = COperationActive::NewL();
       
  1028 	CleanupStack::PushL(opActive);
       
  1029 	console->SetPos(0, 7);
       
  1030 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1031 	DisconnectFromServerL();
       
  1032 
       
  1033 	CActiveScheduler::Start();
       
  1034 	
       
  1035 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1036 	if (globalError)
       
  1037 		return;
       
  1038 	opActive = COperationActive::NewL();
       
  1039 	CleanupStack::PushL(opActive);
       
  1040 	console->SetPos(0, 7);
       
  1041 	test.Printf(_L("ConnectAndSyncCompletedAfterDisconnect                         \n"));
       
  1042 	ConnectToServerL();
       
  1043 	CActiveScheduler::Start();
       
  1044 
       
  1045 	ConnectAndSyncCompleteL();
       
  1046 
       
  1047 	CActiveScheduler::Start();
       
  1048 
       
  1049 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1050 	if (globalError)
       
  1051 		return;
       
  1052 	opActive = COperationActive::NewL();
       
  1053 	CleanupStack::PushL(opActive);
       
  1054 	console->SetPos(0, 7);
       
  1055 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1056 	DisconnectFromServerL();
       
  1057 
       
  1058 	CActiveScheduler::Start();
       
  1059 	if (globalError)
       
  1060 		return;
       
  1061 	}
       
  1062 
       
  1063 LOCAL_C void ConnectAndSyncRemoteInboxSyncCompleteAfterConnectAndDisconnectL()
       
  1064 	{
       
  1065 	console->SetPos(0, 6);
       
  1066 	test.Printf(_L("\nPerforming Tests\n"));
       
  1067 	console->SetPos(0, 7);
       
  1068 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1069 	ConnectToServerL();
       
  1070 	CActiveScheduler::Start();
       
  1071 
       
  1072 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1073 	if (globalError)
       
  1074 		return;
       
  1075 	opActive = COperationActive::NewL();
       
  1076 	CleanupStack::PushL(opActive);
       
  1077 	console->SetPos(0, 7);
       
  1078 	test.Printf(_L("Synchronize Remote Inbox                         \n"));
       
  1079 	SynchronizeRemoteInboxL();
       
  1080 	
       
  1081 
       
  1082 	CActiveScheduler::Start();
       
  1083 
       
  1084 /*	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1085 	if (globalError)
       
  1086 		return;
       
  1087 	opActive = COperationActive::NewL();
       
  1088 	CleanupStack::PushL(opActive);
       
  1089 	console->SetPos(0, 7);
       
  1090 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1091 	DisconnectFromServerL();
       
  1092 
       
  1093 	CActiveScheduler::Start();	*/
       
  1094 	
       
  1095 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1096 	if (globalError)
       
  1097 		return;
       
  1098 	opActive = COperationActive::NewL();
       
  1099 	CleanupStack::PushL(opActive);
       
  1100 	console->SetPos(0, 7);
       
  1101 	test.Printf(_L("ConnectAndSyncCompletedAfterDisconnect                         \n"));
       
  1102 	//ConnectToServerL();
       
  1103 	//CActiveScheduler::Start();	
       
  1104 
       
  1105 	ConnectAndSyncCompleteAfterConnect();
       
  1106 
       
  1107 	CActiveScheduler::Start();
       
  1108 
       
  1109 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1110 	if (globalError)
       
  1111 		return;
       
  1112 	opActive = COperationActive::NewL();
       
  1113 	CleanupStack::PushL(opActive);
       
  1114 	console->SetPos(0, 7);
       
  1115 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1116 	DisconnectFromServerL();
       
  1117 
       
  1118 	CActiveScheduler::Start();
       
  1119 	if (globalError)
       
  1120 		return;
       
  1121 	}
       
  1122 
       
  1123 
       
  1124 //
       
  1125 
       
  1126 LOCAL_C void DeleteAndCreateServicesL()
       
  1127 	{
       
  1128 	// Handle command line arguments
       
  1129 	CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC();
       
  1130 	TInt count = cmdLineArg->Count();
       
  1131 	TBool isCmdLine=FALSE;
       
  1132 	if (count>2)	// Command line arguments?
       
  1133 		{
       
  1134 		if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd)
       
  1135 			isCmdLine=TRUE;
       
  1136 		}	
       
  1137 
       
  1138 
       
  1139 	// delete services
       
  1140 	testUtils->iMsvEntry->SetEntryL(KMsvRootIndexEntryId);
       
  1141 	testUtils->iMsvEntry->DeleteL(imap4Service);
       
  1142 	testUtils->iMsvEntry->DeleteL(smtpService);
       
  1143 
       
  1144 	// delete all messages in the Inbox			
       
  1145 /*	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);		
       
  1146 	CMsvEntrySelection* children = testUtils->iMsvEntry->ChildrenL();
       
  1147 	CleanupStack::PushL(children);
       
  1148 	TInt total = children->Count();
       
  1149 	for (TInt i=0; i<total; i++)
       
  1150 		testUtils->iMsvEntry->DeleteL((*children)[i]);
       
  1151 	CleanupStack::PopAndDestroy(children);*/
       
  1152 
       
  1153 	// Create Services
       
  1154 	smtpService = testUtils->CreateSmtpServiceL();
       
  1155 	imap4Service = testUtils->CreateImapServiceL();
       
  1156 
       
  1157 	testUtils->iMsvEntry->SetEntryL(imap4Service);
       
  1158 
       
  1159 
       
  1160 	//overwrite the settings with test code one.  Don't want the default settings.
       
  1161 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
  1162 
       
  1163 	CImImap4Settings* settings = new(ELeave) CImImap4Settings();
       
  1164 	CleanupStack::PushL(settings);
       
  1165 	settings->Reset();
       
  1166 
       
  1167 	if (isCmdLine)
       
  1168 		{
       
  1169 		TBuf<100> buf;
       
  1170 		TLex lex(cmdLineArg->Arg(EArgServerAddress));
       
  1171 		buf=lex.NextToken();
       
  1172 		settings->SetServerAddressL(buf);
       
  1173 		}
       
  1174 	else
       
  1175 		settings->SetServerAddressL(KImapServer);
       
  1176 
       
  1177 	settings->SetDeleteEmailsWhenDisconnecting(ETrue);
       
  1178 	settings->SetAcknowledgeReceipts(ETrue);
       
  1179 	settings->SetAutoSendOnConnect(ETrue);
       
  1180 
       
  1181 	if (isCmdLine)
       
  1182 		{
       
  1183 		TBuf<100> buf;
       
  1184 		TBuf8<64> data;
       
  1185 		TLex lex(cmdLineArg->Arg(EArgLogin));
       
  1186 		buf=lex.NextToken();
       
  1187 		data.Copy(buf);
       
  1188 		settings->SetLoginNameL(data);
       
  1189 		}
       
  1190 	else
       
  1191 		settings->SetLoginNameL(testUtils->MachineName());
       
  1192 
       
  1193 	if (isCmdLine)
       
  1194 		{
       
  1195 		TBuf<100> buf;
       
  1196 		TBuf8<64> data;
       
  1197 		TLex lex(cmdLineArg->Arg(EArgPassword));
       
  1198 		buf=lex.NextToken();
       
  1199 		data.Copy(buf);
       
  1200 		settings->SetPasswordL(data);
       
  1201 		}
       
  1202 	else
       
  1203 		settings->SetPasswordL(testUtils->MachineName());
       
  1204 
       
  1205 	settings->SetPort(143);
       
  1206 
       
  1207 	if (isCmdLine)
       
  1208 		{
       
  1209 		TBuf<100> buf;
       
  1210 		TBuf8<64> data;
       
  1211 		TLex lex(cmdLineArg->Arg(EArgFolderPath));
       
  1212 		buf=lex.NextToken();
       
  1213 		data.Copy(buf);
       
  1214 		settings->SetFolderPathL(data);
       
  1215 		}
       
  1216 	else
       
  1217 		settings->SetFolderPathL(KFolderPath);
       
  1218 
       
  1219 	TImapAccount imapAccount;
       
  1220 	accounts->GetImapAccountL(imap4Service, imapAccount);
       
  1221 	accounts->SaveImapSettingsL(imapAccount, *settings);
       
  1222 
       
  1223 	CleanupStack::PopAndDestroy(2, accounts); //settings, store/accounts
       
  1224 	CleanupStack::PopAndDestroy(cmdLineArg);	// cmdLineArg
       
  1225 	}
       
  1226 
       
  1227 
       
  1228 
       
  1229 LOCAL_C void InitL()
       
  1230 	{
       
  1231 	dummyObserver = new(ELeave)CDummyConnectionObserver;
       
  1232 	CleanupStack::PushL(dummyObserver);
       
  1233 	
       
  1234 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
  1235 	CActiveScheduler::Install(scheduler);
       
  1236 	CleanupStack::PushL(scheduler);
       
  1237 
       
  1238 	testUtils = CEmailTestUtils::NewLC(test);
       
  1239 	console = test.Console();
       
  1240 	testUtils->FileSession().SetSessionPath(_L("C:\\"));
       
  1241 	testUtils->CleanMessageFolderL();
       
  1242 	testUtils->ClearEmailAccountsL();
       
  1243 	testUtils->GoClientSideL();
       
  1244 	
       
  1245 	console->SetPos(0, 3);
       
  1246 	test.Printf(_L("Create Services                        "));
       
  1247 	testUtils->WriteComment(_L("Create Services                        "));
       
  1248 	// Create Services
       
  1249 	smtpService = testUtils->CreateSmtpServiceL();
       
  1250 	imap4Service = testUtils->CreateImapServiceL();
       
  1251 
       
  1252 	testUtils->WriteComment(_L("********** T_IMPC01 Test CImImap4GetMail class **********"));
       
  1253 	}
       
  1254 	
       
  1255 LOCAL_C void Closedown()
       
  1256 	{
       
  1257 	CleanupStack::PopAndDestroy(3,dummyObserver);  //testUtils, scheduler, dummyObserver
       
  1258 	}
       
  1259 
       
  1260 //
       
  1261 
       
  1262 LOCAL_C TPtrC Progress(TInt progressNumber)
       
  1263 	{
       
  1264 	switch (progressNumber)
       
  1265 		{
       
  1266 		case 0:
       
  1267 			return _L("Disconnected              ");
       
  1268 		case 1:
       
  1269 			return _L("Connecting                ");
       
  1270 		case 2:
       
  1271 			return _L("Idle                      ");
       
  1272 		case 3:
       
  1273 			return _L("Selecting                 ");
       
  1274 		case 4:
       
  1275 			return _L("Fetching                  ");
       
  1276 		case 5:
       
  1277 			return _L("Appending                 ");
       
  1278 		case 6:
       
  1279 			return _L("Copying                   ");
       
  1280 		case 7:
       
  1281 			return _L("Deleting                  ");
       
  1282 		case 8:
       
  1283 			return _L("Syncing                   ");
       
  1284 		case 9:
       
  1285 			return _L("Disconnecting             ");
       
  1286 		case 10:
       
  1287 			return _L("Busy                      ");
       
  1288 		case 11:
       
  1289 			return _L("Moving                    ");
       
  1290 		case 12:
       
  1291 			return _L("Copying New Mail          ");
       
  1292 		case 13:
       
  1293 			return _L("Moving New Mail           ");
       
  1294 		case 14:
       
  1295 			return _L("Copying Mail Selection    ");
       
  1296 		case 15:
       
  1297 			return _L("Moving Mail Selection     ");
       
  1298 		case 16:
       
  1299 			return _L("Copying All Mail          ");
       
  1300 		case 17:
       
  1301 			return _L("Moving All Mail           ");
       
  1302 		case 18:
       
  1303 			return _L("Populating New Mail       ");
       
  1304 		case 19:
       
  1305 			return _L("Populating All Mail       ");
       
  1306 		case 20:
       
  1307 			return _L("Populating Mail Selection ");
       
  1308 		default:
       
  1309 			return _L("Unknown Progress          ");
       
  1310 		}
       
  1311 	}
       
  1312 
       
  1313 LOCAL_C void doMainL()
       
  1314 	{
       
  1315 	InitL();
       
  1316 
       
  1317 	// Load the serial comms device drivers.  If this is not done,
       
  1318 	// connecting via NT-RAS returns KErrNotFound (-1).
       
  1319 	TInt driverErr;
       
  1320 	driverErr=User::LoadPhysicalDevice(PDD_NAME);
       
  1321 	if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists)
       
  1322 		User::Leave(driverErr);
       
  1323 	driverErr=User::LoadLogicalDevice(LDD_NAME);
       
  1324 	if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists)
       
  1325 		User::Leave(driverErr);
       
  1326 
       
  1327 	testUtils->FileSession().SetSessionPath(_L("c:\\"));
       
  1328 	
       
  1329 	testUtils->GoServerSideL();
       
  1330 	testUtils->CreateMessageFilesL(imap4Service, KMsvGlobalInBoxIndexEntryId, _L("c:\\mailtest\\IMCM\\"));
       
  1331 	
       
  1332 	// Delete any *.scr files in c:\logs\email directory.
       
  1333 	testUtils->DeleteScriptFilesFromLogsDirL();
       
  1334 
       
  1335 	testUtils->GoClientSideL();
       
  1336 	testUtils->iMsvEntry->SetEntryL(imap4Service);
       
  1337 
       
  1338 /*	CCommsDatabase* db =CCommsDatabase::NewL();
       
  1339 	CleanupStack::PushL(db);
       
  1340 	TUint32 timeoutInSeconds = 30; // (30 Seconds)
       
  1341 	db->SetAgentClientTimeoutL(TPtrC(DIAL_OUT_ISP),timeoutInSeconds);
       
  1342 	db->SetAgentRouteTimeoutL(TPtrC(DIAL_OUT_ISP),timeoutInSeconds);
       
  1343 // overrides don't work but this should be changed to use an IAPPrefs class
       
  1344 	CleanupStack::PopAndDestroy(); //db*/
       
  1345 
       
  1346 	// Handle command line arguments
       
  1347 	CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC();
       
  1348 	TInt count = cmdLineArg->Count();
       
  1349 	TBool isCmdLine=FALSE;
       
  1350 	if (count>2)	// Command line arguments?
       
  1351 		{
       
  1352 		if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd)
       
  1353 			isCmdLine=TRUE;
       
  1354 		}	
       
  1355 
       
  1356 	//overwrite the settings with test code one.  Don't want the default settings.
       
  1357 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
  1358 
       
  1359 	CImImap4Settings* settings = new(ELeave) CImImap4Settings();
       
  1360 	CleanupStack::PushL(settings);
       
  1361 	settings->Reset();
       
  1362 	
       
  1363 	if (isCmdLine)
       
  1364 		{
       
  1365 		TBuf<100> buf;
       
  1366 		TLex lex(cmdLineArg->Arg(EArgServerAddress));
       
  1367 		buf=lex.NextToken();
       
  1368 		test.Printf(_L("Server address: %S\n"),&buf);
       
  1369 		settings->SetServerAddressL(buf);
       
  1370 		}
       
  1371 	else
       
  1372 		settings->SetServerAddressL(KImapServer);
       
  1373 
       
  1374 	settings->SetDeleteEmailsWhenDisconnecting(ETrue);
       
  1375 	settings->SetAcknowledgeReceipts(ETrue);
       
  1376 //	settings->SetAutoSendOnConnect(ETrue);
       
  1377 
       
  1378 	if (isCmdLine)
       
  1379 		{
       
  1380 		TBuf<100> buf;
       
  1381 		TBuf8<64> data;
       
  1382 		TLex lex(cmdLineArg->Arg(EArgLogin));
       
  1383 		buf=lex.NextToken();
       
  1384 		test.Printf(_L("Login: %S\n"),&buf);
       
  1385 		data.Copy(buf);
       
  1386 		settings->SetLoginNameL(data);
       
  1387 		}
       
  1388 	else
       
  1389 		settings->SetLoginNameL(testUtils->MachineName());
       
  1390 
       
  1391 	if (isCmdLine)
       
  1392 		{
       
  1393 		TBuf<100> buf;
       
  1394 		TBuf8<64> data;
       
  1395 		TLex lex(cmdLineArg->Arg(EArgPassword));
       
  1396 		buf=lex.NextToken();
       
  1397 		test.Printf(_L("Password: %S\n"),&buf);
       
  1398 		data.Copy(buf);
       
  1399 		settings->SetPasswordL(data);
       
  1400 		}
       
  1401 	else
       
  1402 		settings->SetPasswordL(testUtils->MachineName());
       
  1403 
       
  1404 	settings->SetPort(143);
       
  1405 
       
  1406 	if (isCmdLine)
       
  1407 		{
       
  1408 		TBuf<100> buf;
       
  1409 		TBuf8<64> data;
       
  1410 		TLex lex(cmdLineArg->Arg(EArgFolderPath));
       
  1411 		buf=lex.NextToken();
       
  1412 		test.Printf(_L("Folder Path: %S\n"),&buf);
       
  1413 		data.Copy(buf);
       
  1414 		settings->SetFolderPathL(data);
       
  1415 		}
       
  1416 	else
       
  1417 		settings->SetFolderPathL(KFolderPath);
       
  1418 
       
  1419 	TImapAccount imapAccount;
       
  1420 	accounts->GetImapAccountL(imap4Service, imapAccount);
       
  1421 	accounts->SaveImapSettingsL(imapAccount, *settings);
       
  1422 	
       
  1423 	CleanupStack::PopAndDestroy(2); //settings, store
       
  1424 	CleanupStack::PopAndDestroy();	// cmdLineArg
       
  1425 
       
  1426 	console->SetPos(0, 3);
       
  1427 	test.Printf(_L("Instantiating IMAP4 Client MTM"));
       
  1428 	testUtils->WriteComment(_L("Instantiating IMAP4 Client MTM"));
       
  1429 	testUtils->InstantiateImapClientMtmL();
       
  1430 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1431 	CleanupStack::PushL(msvSelection);
       
  1432 
       
  1433 	//opActive = COperationActive::NewL();
       
  1434 	//CleanupStack::PushL(opActive);
       
  1435 
       
  1436 		testUtils->TestStart(24);
       
  1437 		opActive = COperationActive::NewL();
       
  1438 		CleanupStack::PushL(opActive);
       
  1439 		console->SetPos(0, 7);
       
  1440 		test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1441 		ConnectToServerL();
       
  1442 		CActiveScheduler::Start();
       
  1443 
       
  1444 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1445 		if (globalError)
       
  1446 			{
       
  1447 			Closedown();
       
  1448 			return;
       
  1449 			}
       
  1450 		opActive = COperationActive::NewL();
       
  1451 		CleanupStack::PushL(opActive);
       
  1452 		console->SetPos(0, 7);
       
  1453 		test.Printf(_L("Create a Reply Email Message   \n"));
       
  1454 		CreateReplyEmailMessage();
       
  1455 		CActiveScheduler::Start();
       
  1456 
       
  1457 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1458 		if (globalError)
       
  1459 			{
       
  1460 			Closedown();
       
  1461 			return;
       
  1462 			}
       
  1463 		opActive = COperationActive::NewL();
       
  1464 		CleanupStack::PushL(opActive);
       
  1465 		console->SetPos(0, 7);
       
  1466 		test.Printf(_L("Disconnecting from the server                    \n"));
       
  1467 		DisconnectFromServerL();
       
  1468 		CActiveScheduler::Start();
       
  1469 
       
  1470 		// cleanup for next test
       
  1471 		CleanupStack::PopAndDestroy(2,msvSelection); // opActive, msvSelection
       
  1472 	//	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1473 		testUtils->TestFinish(24,globalError);
       
  1474 		if (globalError)
       
  1475 			{
       
  1476 			Closedown();
       
  1477 			return;
       
  1478 			}
       
  1479 
       
  1480 		DeleteAndCreateServicesL();
       
  1481 		testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  1482 
       
  1483 		msvSelection = new (ELeave) CMsvEntrySelection;
       
  1484 		CleanupStack::PushL(msvSelection);
       
  1485 
       
  1486 		opActive = COperationActive::NewL();
       
  1487 		CleanupStack::PushL(opActive);
       
  1488 
       
  1489 		// connect, do full sync and then disconnect so that the inbox can be synced
       
  1490 		ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1491 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1492 		if (globalError)
       
  1493 			{
       
  1494 			Closedown();
       
  1495 			return;
       
  1496 			}
       
  1497 	
       
  1498 		testUtils->TestStart(24);
       
  1499 		opActive = COperationActive::NewL();
       
  1500 		CleanupStack::PushL(opActive);
       
  1501 		console->SetPos(0, 7);
       
  1502 		test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1503 		ConnectToServerL();
       
  1504 		CActiveScheduler::Start();
       
  1505 
       
  1506 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1507 		if (globalError)
       
  1508 			{
       
  1509 			Closedown();
       
  1510 			return;
       
  1511 			}
       
  1512 		opActive = COperationActive::NewL();
       
  1513 		CleanupStack::PushL(opActive);
       
  1514 		console->SetPos(0, 7);
       
  1515 		test.Printf(_L("Create a Forward Email Message   \n"));
       
  1516 	//	testUtils->GoServerSideL();
       
  1517 	//	testUtils->CreateMessageFilesL(imap4Service, KMsvGlobalInBoxIndexEntryId, _L("c:\\mailtest\\IMCM\\"));
       
  1518 	//	testUtils->GoClientSideL();
       
  1519 	//	testUtils->iMsvEntry->SetEntryL(imap4Service);
       
  1520 		CreateForwardEmailMessage();
       
  1521 		CActiveScheduler::Start();
       
  1522 
       
  1523 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1524 		if (globalError)
       
  1525 			{
       
  1526 			Closedown();
       
  1527 			return;
       
  1528 			}
       
  1529 		opActive = COperationActive::NewL();
       
  1530 		CleanupStack::PushL(opActive);
       
  1531 		console->SetPos(0, 7);
       
  1532 		test.Printf(_L("Disconnecting from the server                    \n"));
       
  1533 		DisconnectFromServerL();
       
  1534 		CActiveScheduler::Start();
       
  1535 
       
  1536 		// cleanup for next test
       
  1537 		CleanupStack::PopAndDestroy(2,msvSelection); // opActive, msvSelection
       
  1538 	//	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1539 		testUtils->TestFinish(24,globalError);
       
  1540 		if (globalError)
       
  1541 			{
       
  1542 			Closedown();
       
  1543 			return;
       
  1544 			}
       
  1545 
       
  1546 		DeleteAndCreateServicesL();
       
  1547 		testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  1548 
       
  1549 		msvSelection = new (ELeave) CMsvEntrySelection;
       
  1550 		CleanupStack::PushL(msvSelection);
       
  1551 
       
  1552 		opActive = COperationActive::NewL();
       
  1553 		CleanupStack::PushL(opActive);
       
  1554 
       
  1555 		// connect, do full sync and then disconnect so that the inbox can be synced
       
  1556 		ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1557 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1558 		if (globalError)
       
  1559 			{
       
  1560 			Closedown();
       
  1561 			return;
       
  1562 			}
       
  1563 	
       
  1564 		testUtils->TestStart(25);
       
  1565 		opActive = COperationActive::NewL();
       
  1566 		CleanupStack::PushL(opActive);
       
  1567 		console->SetPos(0, 7);
       
  1568 		test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1569 		ConnectToServerL();
       
  1570 		CActiveScheduler::Start();
       
  1571 
       
  1572 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1573 		if (globalError)
       
  1574 			{
       
  1575 			Closedown();
       
  1576 			return;
       
  1577 			}
       
  1578 		opActive = COperationActive::NewL();
       
  1579 		CleanupStack::PushL(opActive);
       
  1580 		console->SetPos(0, 7);
       
  1581 		test.Printf(_L("Create a New Email Message   \n"));
       
  1582 		CreateNewEmailMessage();
       
  1583 		CActiveScheduler::Start();
       
  1584 
       
  1585 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1586 		if (globalError)
       
  1587 			{
       
  1588 			Closedown();
       
  1589 			return;
       
  1590 			}
       
  1591 		opActive = COperationActive::NewL();
       
  1592 		CleanupStack::PushL(opActive);
       
  1593 		console->SetPos(0, 7);
       
  1594 		test.Printf(_L("Disconnecting from the server                    \n"));
       
  1595 		DisconnectFromServerL();
       
  1596 		CActiveScheduler::Start();
       
  1597 
       
  1598 		// cleanup for next test
       
  1599 		CleanupStack::PopAndDestroy(2,msvSelection); // opActive, msvSelection
       
  1600 	//	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1601 		testUtils->TestFinish(25,globalError);
       
  1602 		if (globalError)
       
  1603 			{
       
  1604 			Closedown();
       
  1605 			return;
       
  1606 			}
       
  1607 
       
  1608 		DeleteAndCreateServicesL();
       
  1609 		testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  1610 
       
  1611 		msvSelection = new (ELeave) CMsvEntrySelection;
       
  1612 		CleanupStack::PushL(msvSelection);
       
  1613 
       
  1614 		opActive = COperationActive::NewL();
       
  1615 		CleanupStack::PushL(opActive);
       
  1616 
       
  1617 		// connect, do full sync and then disconnect so that the inbox can be synced
       
  1618 		ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1619 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1620 		if (globalError)
       
  1621 			{
       
  1622 			Closedown();
       
  1623 			return;
       
  1624 			}
       
  1625 		
       
  1626 	testUtils->TestStart(26);
       
  1627 	opActive = COperationActive::NewL();
       
  1628 	CleanupStack::PushL(opActive);
       
  1629 	console->SetPos(0, 7);
       
  1630 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1631 	ConnectToServerL();
       
  1632 	CActiveScheduler::Start();
       
  1633 
       
  1634 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1635 	if (globalError)
       
  1636 		{
       
  1637 		Closedown();
       
  1638 		return;
       
  1639 		}
       
  1640 	opActive = COperationActive::NewL();
       
  1641 	CleanupStack::PushL(opActive);
       
  1642 	console->SetPos(0, 7);
       
  1643 	test.Printf(_L("Create Forward As Attachment Email Message   \n"));
       
  1644 	CreateForwardAsAttachmentEmailMessage();
       
  1645 	CActiveScheduler::Start();
       
  1646 
       
  1647 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1648 	if (globalError)
       
  1649 		{
       
  1650 		Closedown();
       
  1651 		return;
       
  1652 		}
       
  1653 	opActive = COperationActive::NewL();
       
  1654 	CleanupStack::PushL(opActive);
       
  1655 	console->SetPos(0, 7);
       
  1656 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1657 	DisconnectFromServerL();
       
  1658 	CActiveScheduler::Start();
       
  1659 
       
  1660 	// cleanup for next test
       
  1661 	CleanupStack::PopAndDestroy(2,msvSelection); // opActive, msvSelection
       
  1662 		//	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1663 	testUtils->TestFinish(26,globalError);
       
  1664 	if (globalError)
       
  1665 		{
       
  1666 		Closedown();
       
  1667 		return;
       
  1668 		}
       
  1669 
       
  1670 	DeleteAndCreateServicesL();
       
  1671 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  1672 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1673 	CleanupStack::PushL(msvSelection);
       
  1674 
       
  1675 	opActive = COperationActive::NewL();
       
  1676 	CleanupStack::PushL(opActive);
       
  1677 
       
  1678 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  1679 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1680 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1681 	if (globalError)
       
  1682 		{
       
  1683 		Closedown();
       
  1684 		return;
       
  1685 		}
       
  1686 		
       
  1687  	testUtils->TestStart(27);
       
  1688 		opActive = COperationActive::NewL();
       
  1689 		CleanupStack::PushL(opActive);
       
  1690 		console->SetPos(0, 7);
       
  1691 		test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1692 		ConnectToServerL();
       
  1693 		CActiveScheduler::Start();
       
  1694 
       
  1695 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1696 		if (globalError)
       
  1697 			{
       
  1698 			Closedown();
       
  1699 			return;
       
  1700 			}
       
  1701 		opActive = COperationActive::NewL();
       
  1702 		CleanupStack::PushL(opActive);
       
  1703 		console->SetPos(0, 7);
       
  1704 		test.Printf(_L("Create Forward As Attachment Email Message   \n"));
       
  1705 		CreateReceiptEmailMessage();
       
  1706 		CActiveScheduler::Start();
       
  1707 
       
  1708 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1709 		if (globalError)
       
  1710 			{
       
  1711 			Closedown();
       
  1712 			return;
       
  1713 			}
       
  1714 		opActive = COperationActive::NewL();
       
  1715 		CleanupStack::PushL(opActive);
       
  1716 		console->SetPos(0, 7);
       
  1717 		test.Printf(_L("Disconnecting from the server                    \n"));
       
  1718 		DisconnectFromServerL();
       
  1719 		CActiveScheduler::Start();
       
  1720 
       
  1721 		// cleanup for next test
       
  1722 		CleanupStack::PopAndDestroy(2,msvSelection); // opActive, msvSelection
       
  1723 			//	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1724 		testUtils->TestFinish(27,globalError);
       
  1725 		if (globalError)
       
  1726 			{
       
  1727 			Closedown();
       
  1728 			return;
       
  1729 			}
       
  1730 
       
  1731 		DeleteAndCreateServicesL();
       
  1732 		testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  1733 		msvSelection = new (ELeave) CMsvEntrySelection;
       
  1734 		CleanupStack::PushL(msvSelection);
       
  1735 
       
  1736 		opActive = COperationActive::NewL();
       
  1737 		CleanupStack::PushL(opActive);
       
  1738 
       
  1739 		// connect, do full sync and then disconnect so that the inbox can be synced
       
  1740 		ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1741 		CleanupStack::PopAndDestroy(opActive); // opActive
       
  1742 		if (globalError)
       
  1743 			{
       
  1744 			Closedown();
       
  1745 			return;
       
  1746 			}
       
  1747 		
       
  1748 	
       
  1749 	//
       
  1750 	//
       
  1751 	//  Test 1
       
  1752 	//
       
  1753 	//
       
  1754 	opActive = COperationActive::NewL();
       
  1755 	CleanupStack::PushL(opActive);
       
  1756 	testUtils->TestStart(1);
       
  1757 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  1758 	//ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1759 	ConnectAndSyncRemoteInboxSyncCompleteAfterConnectAndDisconnectL();
       
  1760 	
       
  1761 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, ETrue, EFalse); // replace existing file
       
  1762 	testUtils->TestFinish(1,globalError);
       
  1763 	// Copy New Mail when already connected to server
       
  1764 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1765 	if (globalError)
       
  1766 		{
       
  1767 		Closedown();
       
  1768 		return;
       
  1769 		}
       
  1770 
       
  1771 	//
       
  1772 	//
       
  1773 	// Test 2
       
  1774 	//
       
  1775 	testUtils->TestStart(2);
       
  1776 	opActive = COperationActive::NewL();
       
  1777 	CleanupStack::PushL(opActive);
       
  1778 	console->SetPos(0, 7);
       
  1779 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1780 	ConnectToServerL();
       
  1781 	CActiveScheduler::Start();
       
  1782 
       
  1783 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1784 	if (globalError)
       
  1785 		{
       
  1786 		Closedown();
       
  1787 		return;
       
  1788 		}
       
  1789 	opActive = COperationActive::NewL();
       
  1790 	CleanupStack::PushL(opActive);
       
  1791 	console->SetPos(0, 7);
       
  1792 	test.Printf(_L("Copy New Mail when already connected to server   \n"));
       
  1793 	CopyNewMailWhenAlreadyConnectedL();
       
  1794 	CActiveScheduler::Start();
       
  1795 
       
  1796 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1797 	if (globalError)
       
  1798 		{
       
  1799 		Closedown();
       
  1800 		return;
       
  1801 		}
       
  1802 	opActive = COperationActive::NewL();
       
  1803 	CleanupStack::PushL(opActive);
       
  1804 	console->SetPos(0, 7);
       
  1805 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1806 	DisconnectFromServerL();
       
  1807 	CActiveScheduler::Start();
       
  1808 
       
  1809 	// cleanup for next test
       
  1810 	CleanupStack::PopAndDestroy(2,msvSelection); // opActive, msvSelection
       
  1811 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1812 	testUtils->TestFinish(2,globalError);
       
  1813 	if (globalError)
       
  1814 		{
       
  1815 		Closedown();
       
  1816 		return;
       
  1817 		}
       
  1818 
       
  1819 	DeleteAndCreateServicesL();
       
  1820 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  1821 
       
  1822 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1823 	CleanupStack::PushL(msvSelection);
       
  1824 
       
  1825 	opActive = COperationActive::NewL();
       
  1826 	CleanupStack::PushL(opActive);
       
  1827 
       
  1828 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  1829 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1830 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1831 	if (globalError)
       
  1832 		{
       
  1833 		Closedown();
       
  1834 		return;
       
  1835 		}
       
  1836 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1837 
       
  1838 		
       
  1839 	//
       
  1840 	//
       
  1841 	// Test 3
       
  1842 	//
       
  1843 	//
       
  1844 	testUtils->TestStart(3);
       
  1845 	// Copy All Mail when already connected to server
       
  1846 	opActive = COperationActive::NewL();
       
  1847 	CleanupStack::PushL(opActive);
       
  1848 	console->SetPos(0, 7);
       
  1849 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1850 	ConnectToServerL();
       
  1851 	CActiveScheduler::Start();
       
  1852 
       
  1853 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1854 	if (globalError)
       
  1855 		{
       
  1856 		Closedown();
       
  1857 		return;
       
  1858 		}
       
  1859 	opActive = COperationActive::NewL();
       
  1860 	CleanupStack::PushL(opActive);
       
  1861 	console->SetPos(0, 7);
       
  1862 	test.Printf(_L("Copy All Mail when already connected to server   \n"));
       
  1863 	CopyAllMailWhenAlreadyConnectedL();
       
  1864 	CActiveScheduler::Start();
       
  1865 
       
  1866 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1867 	if (globalError)
       
  1868 		{
       
  1869 		Closedown();
       
  1870 		return;
       
  1871 		}
       
  1872 	opActive = COperationActive::NewL();
       
  1873 	CleanupStack::PushL(opActive);
       
  1874 	console->SetPos(0, 7);
       
  1875 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1876 	DisconnectFromServerL();
       
  1877 	CActiveScheduler::Start();
       
  1878 
       
  1879 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1880 	testUtils->TestFinish(3,globalError);
       
  1881 
       
  1882   	// cleanup for next test
       
  1883 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  1884 	if (globalError)
       
  1885 		{
       
  1886 		Closedown();
       
  1887 		return;
       
  1888 		}
       
  1889 	DeleteAndCreateServicesL();
       
  1890 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  1891 
       
  1892 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1893 	CleanupStack::PushL(msvSelection);
       
  1894 
       
  1895 	opActive = COperationActive::NewL();
       
  1896 	CleanupStack::PushL(opActive);
       
  1897 
       
  1898 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  1899 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1900 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1901 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1902 	if (globalError)
       
  1903 		{
       
  1904 		Closedown();
       
  1905 		return;
       
  1906 		}
       
  1907 
       
  1908 
       
  1909 	//
       
  1910 	//
       
  1911 	// Test 4
       
  1912 	//
       
  1913 	//
       
  1914 	testUtils->TestStart(4);
       
  1915 	// Copy Mail Selection when already connected to server
       
  1916 	opActive = COperationActive::NewL();
       
  1917 	CleanupStack::PushL(opActive);
       
  1918 	console->SetPos(0, 7);
       
  1919 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1920 	ConnectToServerL();
       
  1921 	CActiveScheduler::Start();
       
  1922 
       
  1923 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1924 	if (globalError)
       
  1925 		{
       
  1926 		Closedown();
       
  1927 		return;
       
  1928 		}
       
  1929 	opActive = COperationActive::NewL();
       
  1930 	CleanupStack::PushL(opActive);
       
  1931 	console->SetPos(0, 7);
       
  1932 	test.Printf(_L("Copy Msg selection when already connected        \n"));
       
  1933 	CopyMailSelectionWhenAlreadyConnectedL();
       
  1934 	CActiveScheduler::Start();
       
  1935 
       
  1936 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1937 	if (globalError)
       
  1938 		{
       
  1939 		Closedown();
       
  1940 		return;
       
  1941 		}
       
  1942 	opActive = COperationActive::NewL();
       
  1943 	CleanupStack::PushL(opActive);
       
  1944 	console->SetPos(0, 7);
       
  1945 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  1946 	DisconnectFromServerL();
       
  1947 	CActiveScheduler::Start();
       
  1948 
       
  1949 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1950 	testUtils->TestFinish(4,globalError);
       
  1951 
       
  1952 	// cleanup for next test
       
  1953 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  1954 	if (globalError)
       
  1955 		{
       
  1956 		Closedown();
       
  1957 		return;
       
  1958 		}
       
  1959 	DeleteAndCreateServicesL();
       
  1960 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  1961 
       
  1962 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  1963 	CleanupStack::PushL(msvSelection);
       
  1964 
       
  1965 	opActive = COperationActive::NewL();
       
  1966 	CleanupStack::PushL(opActive);
       
  1967 
       
  1968 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  1969 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  1970 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  1971 
       
  1972 	if (globalError)
       
  1973 		{
       
  1974 		Closedown();
       
  1975 		return;
       
  1976 		}
       
  1977 	//
       
  1978 	//
       
  1979 	//  Test 5
       
  1980 	//
       
  1981 	//
       
  1982 	testUtils->TestStart(5);
       
  1983 	// Populate new mail in remote inbox when already connected to server
       
  1984 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1985 	opActive = COperationActive::NewL();
       
  1986 	CleanupStack::PushL(opActive);
       
  1987 	console->SetPos(0, 7);
       
  1988 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  1989 	ConnectToServerL();
       
  1990 	CActiveScheduler::Start();
       
  1991 
       
  1992 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  1993 	if (globalError)
       
  1994 		{
       
  1995 		Closedown();
       
  1996 		return;
       
  1997 		}
       
  1998 	opActive = COperationActive::NewL();
       
  1999 	CleanupStack::PushL(opActive);
       
  2000 	console->SetPos(0, 7);
       
  2001 	test.Printf(_L("Populating new mail when already connected       \n"));
       
  2002 	PopulateNewMessagesWhenAlreadyConnectedL();
       
  2003 	CActiveScheduler::Start();
       
  2004 
       
  2005 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2006 	if (globalError)
       
  2007 		{
       
  2008 		Closedown();
       
  2009 		return;
       
  2010 		}
       
  2011 	opActive = COperationActive::NewL();
       
  2012 	CleanupStack::PushL(opActive);
       
  2013 	console->SetPos(0, 7);
       
  2014 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2015 	DisconnectFromServerL();
       
  2016 	CActiveScheduler::Start();
       
  2017 
       
  2018 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2019 	testUtils->TestFinish(5,globalError);
       
  2020 
       
  2021 	// cleanup for next test
       
  2022 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2023 	if (globalError)
       
  2024 		{
       
  2025 		Closedown();
       
  2026 		return;
       
  2027 		}
       
  2028 	DeleteAndCreateServicesL();
       
  2029 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2030 
       
  2031 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2032 	CleanupStack::PushL(msvSelection);
       
  2033 
       
  2034 	opActive = COperationActive::NewL();
       
  2035 	CleanupStack::PushL(opActive);
       
  2036 
       
  2037 	//
       
  2038 	//
       
  2039 	//   Test 6
       
  2040 	//
       
  2041 	//
       
  2042 	testUtils->TestStart(6);
       
  2043 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2044 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2045 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2046 
       
  2047 	// Populate all mail in remote inbox when already connected to server
       
  2048 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2049 	if (globalError)
       
  2050 		{
       
  2051 		Closedown();
       
  2052 		return;
       
  2053 		}
       
  2054 	opActive = COperationActive::NewL();
       
  2055 	CleanupStack::PushL(opActive);
       
  2056 	console->SetPos(0, 7);
       
  2057 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  2058 	ConnectToServerL();
       
  2059 	CActiveScheduler::Start();
       
  2060 
       
  2061 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2062 	if (globalError)
       
  2063 		{
       
  2064 		Closedown();
       
  2065 		return;
       
  2066 		}
       
  2067 	opActive = COperationActive::NewL();
       
  2068 	CleanupStack::PushL(opActive);
       
  2069 	console->SetPos(0, 7);
       
  2070 	test.Printf(_L("Populating all mail when already connected       \n"));
       
  2071 	PopulateAllMessagesWhenAlreadyConnectedL();
       
  2072 	CActiveScheduler::Start();
       
  2073 
       
  2074 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2075 	if (globalError)
       
  2076 		{
       
  2077 		Closedown();
       
  2078 		return;
       
  2079 		}
       
  2080 	opActive = COperationActive::NewL();
       
  2081 	CleanupStack::PushL(opActive);
       
  2082 	console->SetPos(0, 7);
       
  2083 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2084 	DisconnectFromServerL();
       
  2085 	CActiveScheduler::Start();
       
  2086 
       
  2087 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2088 	testUtils->TestFinish(6,globalError);
       
  2089 
       
  2090 	// cleanup for next test
       
  2091 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2092 	if (globalError)
       
  2093 		{
       
  2094 		Closedown();
       
  2095 		return;
       
  2096 		}
       
  2097 	DeleteAndCreateServicesL();
       
  2098 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2099 
       
  2100 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2101 	CleanupStack::PushL(msvSelection);
       
  2102 
       
  2103 	opActive = COperationActive::NewL();
       
  2104 	CleanupStack::PushL(opActive);
       
  2105 
       
  2106 	//
       
  2107 	//
       
  2108 	//  Test 7
       
  2109 	//
       
  2110 	//
       
  2111 	testUtils->TestStart(7);
       
  2112 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2113 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2114 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2115 
       
  2116 	// Populate mail selection when already connected to server
       
  2117 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2118 	if (globalError)
       
  2119 		{
       
  2120 		Closedown();
       
  2121 		return;
       
  2122 		}
       
  2123 	opActive = COperationActive::NewL();
       
  2124 	CleanupStack::PushL(opActive);
       
  2125 	console->SetPos(0, 7);
       
  2126 	test.Printf(_L("Connecting to IMAP server                        \n"));
       
  2127 	ConnectToServerL();
       
  2128 	CActiveScheduler::Start();
       
  2129 
       
  2130 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2131 	if (globalError)
       
  2132 		{
       
  2133 		Closedown();
       
  2134 		return;
       
  2135 		}
       
  2136 	opActive = COperationActive::NewL();
       
  2137 	CleanupStack::PushL(opActive);
       
  2138 	console->SetPos(0, 7);
       
  2139 	test.Printf(_L("Populating msg selection when already connected  \n"));
       
  2140 	PopulateMessageSelectionWhenAlreadyConnectedL();
       
  2141 	CActiveScheduler::Start();
       
  2142 
       
  2143 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2144 	if (globalError)
       
  2145 		{
       
  2146 		Closedown();
       
  2147 		return;
       
  2148 		}
       
  2149 	opActive = COperationActive::NewL();
       
  2150 	CleanupStack::PushL(opActive);
       
  2151 	console->SetPos(0, 7);
       
  2152 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2153 	DisconnectFromServerL();
       
  2154 	CActiveScheduler::Start();
       
  2155 
       
  2156 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2157 	testUtils->TestFinish(7,globalError);
       
  2158 
       
  2159 	// cleanup for next test
       
  2160 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2161 	if (globalError)
       
  2162 		{
       
  2163 		Closedown();
       
  2164 		return;
       
  2165 		}
       
  2166 	DeleteAndCreateServicesL();
       
  2167 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2168 
       
  2169 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2170 	CleanupStack::PushL(msvSelection);
       
  2171 
       
  2172 	opActive = COperationActive::NewL();
       
  2173 	CleanupStack::PushL(opActive);
       
  2174 
       
  2175 
       
  2176 	//
       
  2177 	//
       
  2178 	//   Test 8
       
  2179 	//
       
  2180 	//
       
  2181 	testUtils->TestStart(8);
       
  2182 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2183 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2184 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2185 
       
  2186 	// Connect, Copy New Mail and then disconnect
       
  2187 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2188 	if (globalError)
       
  2189 		{
       
  2190 		Closedown();
       
  2191 		return;
       
  2192 		}
       
  2193 	opActive = COperationActive::NewL();
       
  2194 	CleanupStack::PushL(opActive);
       
  2195 	console->SetPos(0, 7);
       
  2196 	test.Printf(_L("Connect, Copy New Mail, Disconnect               \n"));
       
  2197 	ConnectAndCopyNewMailAndDisconnectL();
       
  2198 	CActiveScheduler::Start();
       
  2199 
       
  2200 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2201 	testUtils->TestFinish(8,globalError);
       
  2202 
       
  2203 	// cleanup for next test
       
  2204 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2205 	if (globalError)
       
  2206 		{
       
  2207 		Closedown();
       
  2208 		return;
       
  2209 		}
       
  2210 	DeleteAndCreateServicesL();
       
  2211 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2212 
       
  2213 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2214 	CleanupStack::PushL(msvSelection);
       
  2215 
       
  2216 	opActive = COperationActive::NewL();
       
  2217 	CleanupStack::PushL(opActive);
       
  2218 
       
  2219 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2220 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2221 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2222 
       
  2223 	testUtils->TestStart(9);
       
  2224 	// Connect, Copy All Mail and then disconnect
       
  2225 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2226 	if (globalError)
       
  2227 		{
       
  2228 		Closedown();
       
  2229 		return;
       
  2230 		}
       
  2231 	opActive = COperationActive::NewL();
       
  2232 	CleanupStack::PushL(opActive);
       
  2233 	console->SetPos(0, 7);
       
  2234 	test.Printf(_L("Connect, Copy All Mail, Disconnect               \n"));
       
  2235 	ConnectAndCopyAllMailAndDisconnectL();
       
  2236 	CActiveScheduler::Start();
       
  2237 
       
  2238 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2239 	testUtils->TestFinish(9,globalError);
       
  2240 
       
  2241 	// cleanup for next test
       
  2242 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2243 	if (globalError)
       
  2244 		{
       
  2245 		Closedown();
       
  2246 		return;
       
  2247 		}
       
  2248 	DeleteAndCreateServicesL();
       
  2249 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2250 
       
  2251 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2252 	CleanupStack::PushL(msvSelection);
       
  2253 
       
  2254 	opActive = COperationActive::NewL();
       
  2255 	CleanupStack::PushL(opActive);
       
  2256 
       
  2257 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2258 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2259 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2260 
       
  2261 	testUtils->TestStart(10);
       
  2262 	// Connect, Copy Mail Selection and then disconnect
       
  2263 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2264 	if (globalError)
       
  2265 		{
       
  2266 		Closedown();
       
  2267 		return;
       
  2268 		}
       
  2269 	opActive = COperationActive::NewL();
       
  2270 	CleanupStack::PushL(opActive);
       
  2271 	console->SetPos(0, 7);
       
  2272 	test.Printf(_L("Connect, Copy Mail Selection, Disconnect         \n"));
       
  2273 	ConnectAndCopyMailSelectionAndDisconnectL();
       
  2274 	CActiveScheduler::Start();
       
  2275 
       
  2276 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2277 	testUtils->TestFinish(10,globalError);
       
  2278 
       
  2279 	// cleanup for next test
       
  2280 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2281 	if (globalError)
       
  2282 		{
       
  2283 		Closedown();
       
  2284 		return;
       
  2285 		}
       
  2286 	DeleteAndCreateServicesL();
       
  2287 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2288 
       
  2289 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2290 	CleanupStack::PushL(msvSelection);
       
  2291 
       
  2292 	opActive = COperationActive::NewL();
       
  2293 	CleanupStack::PushL(opActive);
       
  2294 
       
  2295 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2296 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2297 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2298 
       
  2299 	testUtils->TestStart(11);
       
  2300 	// Connect, Populate New Mail and then disconnect
       
  2301 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2302 	if (globalError)
       
  2303 		{
       
  2304 		Closedown();
       
  2305 		return;
       
  2306 		}
       
  2307 	opActive = COperationActive::NewL();
       
  2308 	CleanupStack::PushL(opActive);
       
  2309 	console->SetPos(0, 7);
       
  2310 	test.Printf(_L("Connect, Populate New Mail, Disconnect           \n"));
       
  2311 	ConnectAndPopulateNewMailAndDisconnectL();
       
  2312 	CActiveScheduler::Start();
       
  2313 
       
  2314 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2315 	testUtils->TestFinish(11,globalError);
       
  2316 
       
  2317 	// cleanup for next test
       
  2318 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2319 	if (globalError)
       
  2320 		{
       
  2321 		Closedown();
       
  2322 		return;
       
  2323 		}
       
  2324 	DeleteAndCreateServicesL();
       
  2325 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2326 
       
  2327 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2328 	CleanupStack::PushL(msvSelection);
       
  2329 
       
  2330 	opActive = COperationActive::NewL();
       
  2331 	CleanupStack::PushL(opActive);
       
  2332 
       
  2333 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2334 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2335 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2336 
       
  2337 	testUtils->TestStart(12);
       
  2338 	// Connect, Populate All Mail and then disconnect
       
  2339 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2340 	if (globalError)
       
  2341 		{
       
  2342 		Closedown();
       
  2343 		return;
       
  2344 		}
       
  2345 	opActive = COperationActive::NewL();
       
  2346 	CleanupStack::PushL(opActive);
       
  2347 	console->SetPos(0, 7);
       
  2348 	test.Printf(_L("Connect, Populate All Mail, Disconnect           \n"));
       
  2349 	ConnectAndPopulateAllMailAndDisconnectL();
       
  2350 	CActiveScheduler::Start();
       
  2351 
       
  2352 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2353 	testUtils->TestFinish(12,globalError);
       
  2354 
       
  2355   	// cleanup for next test
       
  2356 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2357 	if (globalError)
       
  2358 		{
       
  2359 		Closedown();
       
  2360 		return;
       
  2361 		}
       
  2362 	DeleteAndCreateServicesL();
       
  2363 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2364 
       
  2365 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2366 	CleanupStack::PushL(msvSelection);
       
  2367 
       
  2368 	opActive = COperationActive::NewL();
       
  2369 	CleanupStack::PushL(opActive);
       
  2370 
       
  2371 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2372 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2373 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2374 
       
  2375 	testUtils->TestStart(13);
       
  2376 	// Connect, Populate Mail Selection and then disconnect
       
  2377 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2378 	if (globalError)
       
  2379 		{
       
  2380 		Closedown();
       
  2381 		return;
       
  2382 		}
       
  2383 	opActive = COperationActive::NewL();
       
  2384 	CleanupStack::PushL(opActive);
       
  2385 	console->SetPos(0, 7);
       
  2386 	test.Printf(_L("Connect, Populate Mail Selection, Disconnect     \n"));
       
  2387 	ConnectAndPopulateMailSelectionAndDisconnectL();
       
  2388 	CActiveScheduler::Start();
       
  2389 
       
  2390 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2391 	testUtils->TestFinish(13,globalError);
       
  2392 
       
  2393 	// cleanup for next test
       
  2394 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2395 	if (globalError)
       
  2396 		{
       
  2397 		Closedown();
       
  2398 		return;
       
  2399 		}
       
  2400 	DeleteAndCreateServicesL();
       
  2401 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2402 
       
  2403 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2404 	CleanupStack::PushL(msvSelection);
       
  2405 
       
  2406 	opActive = COperationActive::NewL();
       
  2407 	CleanupStack::PushL(opActive);
       
  2408 
       
  2409 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2410 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2411 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2412 
       
  2413 	testUtils->TestStart(14);
       
  2414 	// Connect, Copy New Mail and Stay Online
       
  2415 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2416 	if (globalError)
       
  2417 		{
       
  2418 		Closedown();
       
  2419 		return;
       
  2420 		}
       
  2421 	opActive = COperationActive::NewL();
       
  2422 	CleanupStack::PushL(opActive);
       
  2423 	console->SetPos(0, 7);
       
  2424 	test.Printf(_L("Connect, Copy New Mail, Stay Online              \n"));
       
  2425 	ConnectAndCopyNewMailAndStayOnlineL();
       
  2426 	CActiveScheduler::Start();
       
  2427 
       
  2428 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2429 	if (globalError)
       
  2430 		{
       
  2431 		Closedown();
       
  2432 		return;
       
  2433 		}
       
  2434 	opActive = COperationActive::NewL();
       
  2435 	CleanupStack::PushL(opActive);
       
  2436 	console->SetPos(0, 7);
       
  2437 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2438 	DisconnectFromServerL();
       
  2439 	CActiveScheduler::Start();
       
  2440 
       
  2441 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2442 	testUtils->TestFinish(14,globalError);
       
  2443 
       
  2444 	// cleanup for next test
       
  2445 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2446 	if (globalError)
       
  2447 		{
       
  2448 		Closedown();
       
  2449 		return;
       
  2450 		}
       
  2451 	DeleteAndCreateServicesL();
       
  2452 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2453 
       
  2454 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2455 	CleanupStack::PushL(msvSelection);
       
  2456 
       
  2457 	opActive = COperationActive::NewL();
       
  2458 	CleanupStack::PushL(opActive);
       
  2459 
       
  2460 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2461 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2462 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2463 
       
  2464 	testUtils->TestStart(15);
       
  2465 	// Connect, Copy All Mail and Stay Online
       
  2466 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2467 	if (globalError)
       
  2468 		{
       
  2469 		Closedown();
       
  2470 		return;
       
  2471 		}
       
  2472 	opActive = COperationActive::NewL();
       
  2473 	CleanupStack::PushL(opActive);
       
  2474 	console->SetPos(0, 7);
       
  2475 	test.Printf(_L("Connect, Copy All Mail, Stay Online              \n"));
       
  2476 	ConnectAndCopyAllMailAndStayOnlineL();
       
  2477 	CActiveScheduler::Start();
       
  2478 
       
  2479 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2480 	if (globalError)
       
  2481 		{
       
  2482 		Closedown();
       
  2483 		return;
       
  2484 		}
       
  2485 	opActive = COperationActive::NewL();
       
  2486 	CleanupStack::PushL(opActive);
       
  2487 	console->SetPos(0, 7);
       
  2488 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2489 	DisconnectFromServerL();
       
  2490 	CActiveScheduler::Start();
       
  2491 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2492 	testUtils->TestFinish(15,globalError);
       
  2493 
       
  2494 	// cleanup for next test
       
  2495 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2496 	if (globalError)
       
  2497 		{
       
  2498 		Closedown();
       
  2499 		return;
       
  2500 		}
       
  2501 	DeleteAndCreateServicesL();
       
  2502 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2503 
       
  2504 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2505 	CleanupStack::PushL(msvSelection);
       
  2506 
       
  2507 	opActive = COperationActive::NewL();
       
  2508 	CleanupStack::PushL(opActive);
       
  2509 
       
  2510 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2511 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2512 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2513 
       
  2514 	testUtils->TestStart(16);
       
  2515 	// Connect, Copy Mail Selection and Stay Online
       
  2516 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2517 	if (globalError)
       
  2518 		{
       
  2519 		Closedown();
       
  2520 		return;
       
  2521 		}
       
  2522 	opActive = COperationActive::NewL();
       
  2523 	CleanupStack::PushL(opActive);
       
  2524 	console->SetPos(0, 7);
       
  2525 	test.Printf(_L("Connect, Copy Msg Selection, Stay Online         \n"));
       
  2526 	ConnectAndCopyMailSelectionAndStayOnlineL();
       
  2527 	CActiveScheduler::Start();
       
  2528 
       
  2529 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2530 	if (globalError)
       
  2531 		{
       
  2532 		Closedown();
       
  2533 		return;
       
  2534 		}
       
  2535 	opActive = COperationActive::NewL();
       
  2536 	CleanupStack::PushL(opActive);
       
  2537 	console->SetPos(0, 7);
       
  2538 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2539 	DisconnectFromServerL();
       
  2540 	CActiveScheduler::Start();
       
  2541 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2542 	testUtils->TestFinish(16,globalError);
       
  2543 
       
  2544 	// cleanup for next test
       
  2545 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2546 	DeleteAndCreateServicesL();
       
  2547 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2548 
       
  2549 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2550 	CleanupStack::PushL(msvSelection);
       
  2551 
       
  2552 	opActive = COperationActive::NewL();
       
  2553 	CleanupStack::PushL(opActive);
       
  2554 
       
  2555 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2556 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2557 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2558 
       
  2559 	testUtils->TestStart(17);
       
  2560 	// Connect, Populate New Mail and Stay Online
       
  2561 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2562 	if (globalError)
       
  2563 		{
       
  2564 		Closedown();
       
  2565 		return;
       
  2566 		}
       
  2567 	opActive = COperationActive::NewL();
       
  2568 	CleanupStack::PushL(opActive);
       
  2569 	console->SetPos(0, 7);
       
  2570 	test.Printf(_L("Connect, Populate New Mail, Stay Online          \n"));
       
  2571 	ConnectAndPopulateNewMailAndStayOnlineL();
       
  2572 	CActiveScheduler::Start();
       
  2573 
       
  2574 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2575 	if (globalError)
       
  2576 		{
       
  2577 		Closedown();
       
  2578 		return;
       
  2579 		}
       
  2580 	opActive = COperationActive::NewL();
       
  2581 	CleanupStack::PushL(opActive);
       
  2582 	console->SetPos(0, 7);
       
  2583 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2584 	DisconnectFromServerL();
       
  2585 	CActiveScheduler::Start();
       
  2586 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2587 	testUtils->TestFinish(17,globalError);
       
  2588 
       
  2589 	// cleanup for next test
       
  2590 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2591 	if (globalError)
       
  2592 		{
       
  2593 		Closedown();
       
  2594 		return;
       
  2595 		}
       
  2596 	DeleteAndCreateServicesL();
       
  2597 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2598 
       
  2599 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2600 	CleanupStack::PushL(msvSelection);
       
  2601 
       
  2602 	opActive = COperationActive::NewL();
       
  2603 	CleanupStack::PushL(opActive);
       
  2604 
       
  2605 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2606 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2607 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2608 
       
  2609 	testUtils->TestStart(18);
       
  2610 	// Connect, Populate All Mail and Stay Online
       
  2611 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2612 	if (globalError)
       
  2613 		{
       
  2614 		Closedown();
       
  2615 		return;
       
  2616 		}
       
  2617 	opActive = COperationActive::NewL();
       
  2618 	CleanupStack::PushL(opActive);
       
  2619 	console->SetPos(0, 7);
       
  2620 	test.Printf(_L("Connect, Populate All Mail, Stay Online          \n"));
       
  2621 	ConnectAndPopulateAllMailAndStayOnlineL();
       
  2622 	CActiveScheduler::Start();
       
  2623 
       
  2624 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2625 	if (globalError)
       
  2626 		{
       
  2627 		Closedown();
       
  2628 		return;
       
  2629 		}
       
  2630 	opActive = COperationActive::NewL();
       
  2631 	CleanupStack::PushL(opActive);
       
  2632 	console->SetPos(0, 7);
       
  2633 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2634 	DisconnectFromServerL();
       
  2635 	CActiveScheduler::Start();
       
  2636 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2637 	testUtils->TestFinish(18,globalError);
       
  2638 
       
  2639 	// cleanup for next test
       
  2640 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2641 	if (globalError)
       
  2642 		{
       
  2643 		Closedown();
       
  2644 		return;
       
  2645 		}
       
  2646 	DeleteAndCreateServicesL();
       
  2647 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2648 
       
  2649 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2650 	CleanupStack::PushL(msvSelection);
       
  2651 
       
  2652 	opActive = COperationActive::NewL();
       
  2653 	CleanupStack::PushL(opActive);
       
  2654 
       
  2655 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2656 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2657 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2658 
       
  2659 	testUtils->TestStart(19);
       
  2660 	// Connect, Populate Mail Selection and Stay Online
       
  2661 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2662 	opActive = COperationActive::NewL();
       
  2663 	CleanupStack::PushL(opActive);
       
  2664 	console->SetPos(0, 7);
       
  2665 	test.Printf(_L("Connect, Populate Mail Selection, Stay Online    \n"));
       
  2666 	ConnectAndPopulateMailSelectionAndStayOnlineL();
       
  2667 	CActiveScheduler::Start();
       
  2668 
       
  2669 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2670 	if (globalError)
       
  2671 		{
       
  2672 		Closedown();
       
  2673 		return;
       
  2674 		}
       
  2675 	opActive = COperationActive::NewL();
       
  2676 	CleanupStack::PushL(opActive);
       
  2677 	console->SetPos(0, 7);
       
  2678 	test.Printf(_L("Disconnecting from the server                    \n"));
       
  2679 	DisconnectFromServerL();
       
  2680 	CActiveScheduler::Start();
       
  2681 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2682 	testUtils->TestFinish(19,globalError);
       
  2683 
       
  2684 
       
  2685 //
       
  2686 //	Test the cancelling of operations
       
  2687 //
       
  2688 	// cleanup for next test
       
  2689 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2690 	if (globalError)
       
  2691 		{
       
  2692 		Closedown();
       
  2693 		return;
       
  2694 		}
       
  2695 	DeleteAndCreateServicesL();
       
  2696 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2697 
       
  2698 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2699 	CleanupStack::PushL(msvSelection);
       
  2700 
       
  2701 	opActive = COperationActive::NewL();
       
  2702 	CleanupStack::PushL(opActive);
       
  2703 
       
  2704 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2705 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2706 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2707 
       
  2708 	testUtils->TestStart(20);
       
  2709 	// Connect, Copy All Mail and then disconnect
       
  2710 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2711 	if (globalError)
       
  2712 		{
       
  2713 		Closedown();
       
  2714 		return;
       
  2715 		}
       
  2716 	opActive = COperationActive::NewL();
       
  2717 	CleanupStack::PushL(opActive);
       
  2718 	console->SetPos(0, 7);
       
  2719 	test.Printf(_L("Connect, Copy All Mail, Disconnect               \n"));
       
  2720 //	opActive->SetCancelState(TImap4GenericProgress::EConnecting);
       
  2721 	ConnectAndCopyAllMailAndDisconnectL();
       
  2722 	CActiveScheduler::Start();
       
  2723 
       
  2724 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2725 	testUtils->TestFinish(20,globalError);
       
  2726 
       
  2727 	// cleanup for next test
       
  2728 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2729 	if (globalError)
       
  2730 		{
       
  2731 		Closedown();
       
  2732 		return;
       
  2733 		}
       
  2734 	DeleteAndCreateServicesL();
       
  2735 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2736 
       
  2737 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2738 	CleanupStack::PushL(msvSelection);
       
  2739 
       
  2740 	opActive = COperationActive::NewL();
       
  2741 	CleanupStack::PushL(opActive);
       
  2742 
       
  2743 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2744 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2745 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2746 
       
  2747 	testUtils->TestStart(21);
       
  2748 	// Connect, Copy All Mail and then disconnect
       
  2749 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2750 	if (globalError)
       
  2751 		{
       
  2752 		Closedown();
       
  2753 		return;
       
  2754 		}
       
  2755 	opActive = COperationActive::NewL();
       
  2756 	CleanupStack::PushL(opActive);
       
  2757 	console->SetPos(0, 7);
       
  2758 	test.Printf(_L("Connect, Copy All Mail, Disconnect               \n"));
       
  2759 	opActive->SetCancelState(TImap4GenericProgress::ESelecting);
       
  2760 	ConnectAndCopyAllMailAndDisconnectL();
       
  2761 	CActiveScheduler::Start();
       
  2762 
       
  2763 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2764 	testUtils->TestFinish(21,globalError);
       
  2765 
       
  2766 	// cleanup for next test
       
  2767 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2768 	if (globalError)
       
  2769 		{
       
  2770 		Closedown();
       
  2771 		return;
       
  2772 		}
       
  2773 	DeleteAndCreateServicesL();
       
  2774 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2775 
       
  2776 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2777 	CleanupStack::PushL(msvSelection);
       
  2778 
       
  2779 	opActive = COperationActive::NewL();
       
  2780 	CleanupStack::PushL(opActive);
       
  2781 
       
  2782 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2783 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2784 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2785 
       
  2786 	testUtils->TestStart(22);
       
  2787 	// Connect, Copy All Mail and then disconnect
       
  2788 	if (globalError)
       
  2789 		{
       
  2790 		Closedown();
       
  2791 		return;
       
  2792 		}
       
  2793 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2794 	opActive = COperationActive::NewL();
       
  2795 	CleanupStack::PushL(opActive);
       
  2796 	console->SetPos(0, 7);
       
  2797 	test.Printf(_L("Connect, Copy All Mail, Disconnect               \n"));
       
  2798 	opActive->SetCancelState(TImap4GenericProgress::EFetching);
       
  2799 	ConnectAndCopyAllMailAndDisconnectL();
       
  2800 	CActiveScheduler::Start();
       
  2801 
       
  2802 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2803 	testUtils->TestFinish(22,globalError);
       
  2804 	
       
  2805 	// cleanup for next test
       
  2806 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2807 	if (globalError)
       
  2808 		{
       
  2809 		Closedown();
       
  2810 		return;
       
  2811 		}
       
  2812 	DeleteAndCreateServicesL();
       
  2813 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2814 
       
  2815 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2816 	CleanupStack::PushL(msvSelection);
       
  2817 
       
  2818 	opActive = COperationActive::NewL();
       
  2819 	CleanupStack::PushL(opActive);
       
  2820 
       
  2821 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2822 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2823 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2824 
       
  2825 	testUtils->TestStart(23);
       
  2826 	// Connect, Copy All Mail and then disconnect
       
  2827 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2828 	if (globalError)
       
  2829 		{
       
  2830 		Closedown();
       
  2831 		return;
       
  2832 		}
       
  2833 	opActive = COperationActive::NewL();
       
  2834 	CleanupStack::PushL(opActive);
       
  2835 	console->SetPos(0, 7);
       
  2836 	test.Printf(_L("Connect, Copy All Mail, Disconnect               \n"));
       
  2837 //	opActive->SetCancelState(TImap4GenericProgress::EDisconnecting);
       
  2838 	ConnectAndCopyAllMailAndDisconnectL();
       
  2839 	CActiveScheduler::Start();
       
  2840 
       
  2841 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2842 	testUtils->TestFinish(23,globalError);
       
  2843 
       
  2844 //
       
  2845 //	Test an empty message selection (does not cause a panic!)
       
  2846 //
       
  2847 
       
  2848 	// cleanup for next test
       
  2849 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2850 	if (globalError)
       
  2851 		{
       
  2852 		Closedown();
       
  2853 		return;
       
  2854 		}
       
  2855 	DeleteAndCreateServicesL();
       
  2856 	testUtils->iImapClientMtm->SwitchCurrentEntryL(imap4Service);
       
  2857 
       
  2858 	msvSelection = new (ELeave) CMsvEntrySelection;
       
  2859 	CleanupStack::PushL(msvSelection);
       
  2860 
       
  2861 	opActive = COperationActive::NewL();
       
  2862 	CleanupStack::PushL(opActive);
       
  2863 
       
  2864 	// connect, do full sync and then disconnect so that the inbox can be synced
       
  2865 	ConnectAndSyncRemoteInboxAndDisconnectL();
       
  2866 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2867 
       
  2868 		
       
  2869 	testUtils->TestStart(24);
       
  2870 	// Connect, Copy All Mail and then disconnect
       
  2871 	CleanupStack::PopAndDestroy(opActive); // opActive
       
  2872 	if (globalError)
       
  2873 		{
       
  2874 		Closedown();
       
  2875 		return;
       
  2876 		}
       
  2877 	opActive = COperationActive::NewL();
       
  2878 	CleanupStack::PushL(opActive);
       
  2879 	console->SetPos(0, 7);
       
  2880 	test.Printf(_L("Connect, Copy Empty Message Selection, Disconnect\n"));
       
  2881 	ConnectAndCopyMailSelectionAndDisconnectL(ETrue);
       
  2882 	CActiveScheduler::Start();
       
  2883 
       
  2884 	// check that final progress showing the correct information
       
  2885 	TPckgBuf<TImap4GenericProgress> progress;
       
  2886 	progress.Copy(opActive->iTimer->iOperation->FinalProgress());
       
  2887 
       
  2888 	console->SetPos(0, 11);
       
  2889 	console->Printf(_L("Final Progress:                    "));
       
  2890 	console->SetPos(0, 12);
       
  2891 	TBuf<80> progressBuf = Progress(progress().iState);
       
  2892 	console->Printf(TRefByValue<const TDesC>_L("   Super Operation Progress: %S           "), &progressBuf);
       
  2893 	console->SetPos(0, 13);
       
  2894 	progressBuf = Progress(progress().iImap4SubStateProgress);
       
  2895 	console->Printf(TRefByValue<const TDesC>_L("   Sub Operation Progress  : %S           "), &progressBuf);
       
  2896 	console->SetPos(0, 14);
       
  2897 	console->Printf(TRefByValue<const TDesC>_L("   Progress:  %d/%d %d/%d  Total:%d              \n"),
       
  2898 				progress().iMsgsDone,
       
  2899 				progress().iMsgsToDo,
       
  2900 				progress().iBytesDone,
       
  2901 				progress().iBytesToDo,
       
  2902 				progress().iTotalSize);
       
  2903 	console->SetPos(0, 15);
       
  2904 	console->Printf(TRefByValue<const TDesC>_L("   Error: %d                             \n"), progress().iErrorCode);
       
  2905 
       
  2906 	// wait 5 seconds so that user can see the final progess!
       
  2907 	CTestTimer* timer = CTestTimer::NewL();
       
  2908 	timer->After(5000000);
       
  2909 	CActiveScheduler::Start();
       
  2910 	delete timer;
       
  2911 
       
  2912 	//delete all messages in inbox
       
  2913 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);		
       
  2914 		CMsvEntrySelection* children = testUtils->iMsvEntry->ChildrenL();
       
  2915 		CleanupStack::PushL(children);
       
  2916 		TInt total = children->Count();
       
  2917 		for (TInt i=0; i<total; i++)
       
  2918 			testUtils->iMsvEntry->DeleteL((*children)[i]);
       
  2919 		CleanupStack::PopAndDestroy(children);
       
  2920 		
       
  2921 //	testUtils->FindChildrenL(KMsvRootIndexEntryId, EFalse, EFalse);
       
  2922 	testUtils->TestFinish(24,globalError);
       
  2923 	if (globalError)
       
  2924 		testUtils->TestHarnessFailed(globalError);
       
  2925 	else
       
  2926 		testUtils->TestHarnessCompleted();
       
  2927 
       
  2928 	CleanupStack::PopAndDestroy(2,msvSelection); //opActive, msvSelection
       
  2929 	testUtils->Reset();
       
  2930 	Closedown();
       
  2931 	}
       
  2932 
       
  2933 GLDEF_C TInt E32Main()
       
  2934 	{	
       
  2935 	__UHEAP_MARK;
       
  2936 	test.Start(_L("T_IMPC01 Test CImImap4GetMail class"));
       
  2937 	theCleanup=CTrapCleanup::New();
       
  2938 	TRAPD(ret,doMainL());		
       
  2939 	test(ret==KErrNone);
       
  2940 	delete theCleanup;	
       
  2941 	test.End();
       
  2942 	test.Close();
       
  2943 	__UHEAP_MARKEND;
       
  2944 	User::Heap().Check();
       
  2945 	return(KErrNone);
       
  2946 	}