messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfTestActionConnectAndSyncImap4Server.cpp
changeset 0 8e480a14352b
child 58 6c34d0baa0b1
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2003-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 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // ConnectImap4Server
       
    17 // [Action Parameters]
       
    18 // ServiceId  <input>: Value of the Imap4 service id.
       
    19 // Mtm        <input>: Reference to Imap4 client MTM.
       
    20 // [Action Description]
       
    21 // Connects to the Imap4 server.
       
    22 // [APIs Used]
       
    23 // CMsvEntry::SetEntryL
       
    24 // CMsvEntrySelection::AppendL
       
    25 // CImap4ClientMtm::InvokeAsyncFunctionL
       
    26 // __ACTION_INFO_END__
       
    27 // 
       
    28 //
       
    29 
       
    30 /**
       
    31  @file
       
    32 */
       
    33 
       
    34 
       
    35 #include "CMtfTestActionConnectAndSyncImap4Server.h"
       
    36 #include "CMtfTestCase.h"
       
    37 #include "CMtfTestActionParameters.h"
       
    38 #include "MtfTestActionUtilsUser.h"
       
    39 
       
    40 #include <impcmtm.h>
       
    41 
       
    42 
       
    43 CMtfTestAction* CMtfTestActionConnectAndSyncImap4Server::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    44 	{
       
    45 	CMtfTestActionConnectAndSyncImap4Server* self = new (ELeave) CMtfTestActionConnectAndSyncImap4Server(aTestCase);
       
    46 	CleanupStack::PushL(self);
       
    47 	self->ConstructL(aActionParameters);
       
    48 	CleanupStack::Pop();
       
    49 	return self;
       
    50 	}
       
    51 	
       
    52 
       
    53 CMtfTestActionConnectAndSyncImap4Server::CMtfTestActionConnectAndSyncImap4Server(CMtfTestCase& aTestCase)
       
    54 	: CMtfTestAction(aTestCase)
       
    55 	{
       
    56 	}
       
    57 
       
    58 
       
    59 CMtfTestActionConnectAndSyncImap4Server::~CMtfTestActionConnectAndSyncImap4Server()
       
    60 	{
       
    61 	}
       
    62 
       
    63 
       
    64 void CMtfTestActionConnectAndSyncImap4Server::ExecuteActionL()
       
    65 	{
       
    66 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionConnectAndSyncImap4Server);
       
    67 	TMsvId paramServiceId     = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0));
       
    68 	CImap4ClientMtm* paramMtm = ObtainParameterReferenceL<CImap4ClientMtm>(TestCase(),ActionParameters().Parameter(1));
       
    69 
       
    70 	paramMtm->SwitchCurrentEntryL(paramServiceId);
       
    71 	
       
    72 	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
       
    73 	CleanupStack::PushL(selection);
       
    74 	selection->AppendL(paramServiceId);
       
    75 	TBuf8<1> param;
       
    76 	iOperation = paramMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndSynchronise,*selection,param,iStatus);
       
    77 	CleanupStack::PopAndDestroy(selection);
       
    78 	CActiveScheduler::Add(this);
       
    79 	SetActive();
       
    80 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionConnectAndSyncImap4Server);
       
    81 	}
       
    82 
       
    83 
       
    84 void CMtfTestActionConnectAndSyncImap4Server::DoCancel()
       
    85 	{
       
    86 	iOperation->Cancel();
       
    87 	}
       
    88 
       
    89 
       
    90 void CMtfTestActionConnectAndSyncImap4Server::RunL()
       
    91 	{
       
    92 	TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus);
       
    93 
       
    94 	delete iOperation;
       
    95 
       
    96 	User::LeaveIfError(err);
       
    97 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionConnectAndSyncImap4Server);
       
    98 	TestCase().ActionCompletedL(*this);
       
    99 	}
       
   100