messagingfw/msgtestfw/TestActions/Email/Common/src/CMtfTestActionPruneMessages.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 // PruneMessage
       
    17 // [Action Parameters]
       
    18 // Session   <input>: Reference to the session.
       
    19 // Selection <input>: Selection of messages to prune
       
    20 // [Action Description]
       
    21 // Unpopulates all the email messages under a service
       
    22 // [APIs Used]
       
    23 // CImCacheManager
       
    24 // __ACTION_INFO_END__
       
    25 // 
       
    26 //
       
    27 
       
    28 /**
       
    29  @file
       
    30 */
       
    31 
       
    32 #include "CMtfTestActionPruneMessages.h"
       
    33 #include "CMtfTestCase.h"
       
    34 #include "CMtfTestActionParameters.h"
       
    35 
       
    36 #include <cacheman.h>
       
    37 
       
    38 
       
    39 class CPruneTester: public CImCacheManager
       
    40 	{
       
    41 	public:
       
    42 		static CPruneTester* NewL(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
       
    43 
       
    44 	private:
       
    45 		CPruneTester(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
       
    46 		TBool Filter() const;
       
    47 	};
       
    48 
       
    49 CPruneTester::CPruneTester(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus) : CImCacheManager(aSession, aObserverRequestStatus)
       
    50 	{
       
    51 	}
       
    52 
       
    53 CPruneTester* CPruneTester::NewL(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus)
       
    54 	{
       
    55 	CPruneTester* self = new (ELeave) CPruneTester(aSession, aObserverRequestStatus);
       
    56 	CleanupStack::PushL(self);
       
    57 	self->ConstructL();
       
    58 	CleanupStack::Pop(); // self
       
    59 	return self;
       
    60 	}
       
    61 
       
    62 TBool CPruneTester::Filter() const
       
    63 	{
       
    64 	return ETrue;
       
    65 	}
       
    66 
       
    67 
       
    68 
       
    69 CMtfTestAction* CMtfTestActionPruneMessages::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    70 	{
       
    71 	CMtfTestActionPruneMessages* self = new (ELeave) CMtfTestActionPruneMessages(aTestCase);
       
    72 	CleanupStack::PushL(self);
       
    73 	self->ConstructL(aActionParameters);
       
    74 	CleanupStack::Pop();
       
    75 	return self;
       
    76 	}
       
    77 	
       
    78 CMtfTestActionPruneMessages::CMtfTestActionPruneMessages(CMtfTestCase& aTestCase)
       
    79 	: CMtfTestAction(aTestCase)
       
    80 	{
       
    81 	}
       
    82 
       
    83 CMtfTestActionPruneMessages::~CMtfTestActionPruneMessages()
       
    84 	{
       
    85 	}
       
    86 
       
    87 
       
    88 void CMtfTestActionPruneMessages::ExecuteActionL()
       
    89 	{
       
    90 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionPruneMessages);
       
    91 	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
       
    92 	CMsvEntrySelection* selection = ObtainParameterReferenceL<CMsvEntrySelection> (TestCase(), ActionParameters().Parameter(1)); 
       
    93 
       
    94 
       
    95 	TRequestStatus observerStatus;
       
    96 	iPruneTester = CPruneTester::NewL(*paramSession, observerStatus);	
       
    97 	iPruneTester->StartL(*selection, iStatus);
       
    98 	CActiveScheduler::Add(this);
       
    99 	SetActive();
       
   100 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionPruneMessages);
       
   101 	}
       
   102 
       
   103 
       
   104 void CMtfTestActionPruneMessages::DoCancel()
       
   105 	{
       
   106 	iPruneTester->Cancel();
       
   107 	}
       
   108 
       
   109 
       
   110 void CMtfTestActionPruneMessages::RunL()
       
   111 	{
       
   112 	User::LeaveIfError(iStatus.Int());
       
   113 	delete iPruneTester;
       
   114 	iPruneTester=NULL;
       
   115 	TestCase().ActionCompletedL(*this);
       
   116 	}