messagingfw/msgtestfw/TestActions/Email/Common/src/CMtfTestActionCheckAttachmentPathFromEntrySelection.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2005-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 // CheckAttachmentPathFromEntrySelection
       
    17 // [Action Parameters]
       
    18 // Session        <input>: Reference to the session.
       
    19 // EntrySelection <input>: Reference to the entry selection
       
    20 // [Action Description]
       
    21 // Checks the attachment paths from an email message in an entry selection.
       
    22 // [APIs Used]
       
    23 // __ACTION_INFO_END__
       
    24 // 
       
    25 //
       
    26 
       
    27 
       
    28 #include "CMtfTestActionCheckAttachmentPathFromEntrySelection.h"
       
    29 #include "CMtfTestCase.h"
       
    30 #include "CMtfTestActionParameters.h"
       
    31 #include "MtfTestActionUtilsUser.h"
       
    32 
       
    33 #include <miutset.h>
       
    34 #include <mmsvattachmentmanager.h>
       
    35 #include <miutmsg.h>
       
    36 
       
    37 CMtfTestAction* CMtfTestActionCheckAttachmentPathFromEntrySelection::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    38 	{
       
    39 	CMtfTestActionCheckAttachmentPathFromEntrySelection* self = new(ELeave) CMtfTestActionCheckAttachmentPathFromEntrySelection(aTestCase);
       
    40 	CleanupStack::PushL(self);
       
    41 	self->ConstructL(aActionParameters);
       
    42 	CleanupStack::Pop();
       
    43 	return self;
       
    44 	}
       
    45 	
       
    46 CMtfTestActionCheckAttachmentPathFromEntrySelection::CMtfTestActionCheckAttachmentPathFromEntrySelection(CMtfTestCase& aTestCase)
       
    47 	: CMtfSynchronousTestAction(aTestCase)
       
    48 	{
       
    49 	}
       
    50 
       
    51 CMtfTestActionCheckAttachmentPathFromEntrySelection::~CMtfTestActionCheckAttachmentPathFromEntrySelection()
       
    52 	{
       
    53 	}
       
    54 
       
    55 void CMtfTestActionCheckAttachmentPathFromEntrySelection::ExecuteActionL()
       
    56 	{
       
    57 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCheckAttachmentPathFromEntrySelection);
       
    58 	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
       
    59 	CMsvEntrySelection* paramSelection = ObtainParameterReferenceL<CMsvEntrySelection>(TestCase(),ActionParameters().Parameter(1));
       
    60 	
       
    61 	if( paramSelection->Count()==0 )
       
    62 		{
       
    63 		User::Leave(KErrArgument);
       
    64 		}
       
    65 	
       
    66 	TMsvId entryId = (*paramSelection)[0];
       
    67 	CMsvEntry* entry = paramSession->GetEntryL(entryId);
       
    68 	CleanupStack::PushL(entry);
       
    69 	
       
    70 	CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry);
       
    71 	CleanupStack::PushL(emailMsg);
       
    72 	
       
    73 	MMsvAttachmentManager& attManager = emailMsg->AttachmentManager();
       
    74 	TInt attachmentCount = attManager.AttachmentCount();
       
    75 	if( attachmentCount==0 )
       
    76 		{
       
    77 		User::Leave(KErrArgument);
       
    78 		}
       
    79 	
       
    80 	for( TInt ii=0; ii<attachmentCount; ++ii )
       
    81 		{
       
    82 		// for each attachment, ensure that the physical attachment exists
       
    83 		// as per the file path given in the attachment info
       
    84 		CMsvAttachment* attachInfo = attManager.GetAttachmentInfoL(ii);
       
    85 		CleanupStack::PushL(attachInfo);
       
    86 		
       
    87 		// use the Att() method just to check if the file exists
       
    88 		RFs& fs(paramSession->FileSession());
       
    89 		TUint fileAttributes;
       
    90 		TInt err = fs.Att(attachInfo->FilePath(), fileAttributes);
       
    91 		User::LeaveIfError(err);
       
    92 		
       
    93 		CleanupStack::PopAndDestroy(attachInfo);
       
    94 		}
       
    95 	
       
    96 	CleanupStack::PopAndDestroy(2, entry); // emailMsg, entry
       
    97 	
       
    98 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCheckAttachmentPathFromEntrySelection);
       
    99 	TestCase().ActionCompletedL(*this);
       
   100 	}
       
   101 
       
   102 
       
   103