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