messagingfw/msgtestfw/TestActions/Framework/src/CMtfTestActionDeleteAttachment.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-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 // DeleteAttachment
       
    17 // [Action Parameters]
       
    18 // EntryId			<input>: Value of the attachment entry Id to be deleted.
       
    19 // FileName			<input>: Name of the attachment file name to be deleted.
       
    20 // [Action Description]
       
    21 // Deletes an attachment associated with the specified entry Id.
       
    22 // [APIs Used]
       
    23 // RMsvServerSession::DeleteAttachment()
       
    24 // __ACTION_INFO_END__
       
    25 // 
       
    26 //
       
    27 
       
    28 /**
       
    29  @file
       
    30 */
       
    31 // 
       
    32 #include "CMtfTestActionDeleteAttachment.h"
       
    33 #include "MCLIENT.H"
       
    34 #include "CMtfTestActionParameters.h"
       
    35 #include "CMtfTestCase.h"
       
    36 
       
    37 
       
    38 CMtfTestAction* CMtfTestActionDeleteAttachment::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    39 	{
       
    40 	CMtfTestActionDeleteAttachment* self = new (ELeave) CMtfTestActionDeleteAttachment(aTestCase);
       
    41 	CleanupStack::PushL(self);
       
    42 	self->ConstructL(aActionParameters);
       
    43 	CleanupStack::Pop();
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 CMtfTestActionDeleteAttachment::CMtfTestActionDeleteAttachment(CMtfTestCase& aTestCase)
       
    48 	: CMtfSynchronousTestAction(aTestCase)
       
    49 	{
       
    50 	}
       
    51 
       
    52 CMtfTestActionDeleteAttachment::~CMtfTestActionDeleteAttachment()
       
    53 	{
       
    54 	}
       
    55 
       
    56 void CMtfTestActionDeleteAttachment::ExecuteActionL()
       
    57 	{
       
    58 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeleteAttachment);
       
    59 	// Obtain the input parameters
       
    60 	TMsvId paramEntryId  = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0));
       
    61 	HBufC* paramAttachmentFileName = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1));
       
    62 
       
    63 	// Create file session at the client side
       
    64 	RFs fs;
       
    65 	User::LeaveIfError(fs.Connect());
       
    66 	CleanupClosePushL(fs);
       
    67 	
       
    68 	RMsvServerSession serverSession;
       
    69 	serverSession.Connect(fs);
       
    70 	CleanupClosePushL(serverSession);
       
    71 
       
    72 	TInt error = serverSession.DeleteAttachment(paramEntryId,*paramAttachmentFileName);
       
    73 	
       
    74 	if(error == KErrNone)
       
    75 		{
       
    76 		TestCase().INFO_PRINTF1(_L("Attachment file deleted successfully"));
       
    77 		}
       
    78 	else
       
    79 		{
       
    80 		TestCase().ERR_PRINTF2(_L("Error  deleting attachment file , Error = %d"),error);
       
    81 		TestCase().SetTestStepResult(EFail);
       
    82 		}
       
    83 
       
    84 	//  close the handles 
       
    85 	CleanupStack::PopAndDestroy(2,&fs);
       
    86 
       
    87 	StoreParameterL<TInt>(TestCase(),error,ActionParameters().Parameter(2));
       
    88 
       
    89 	TestCase().INFO_PRINTF1(_L("Test Action DeleteAttachment completed"));
       
    90 	TestCase().ActionCompletedL(*this);
       
    91 	}
       
    92