diff -r 000000000000 -r 8e480a14352b messagingfw/msgtestfw/TestActions/Email/Smtp/src/CMtfTestActionSmtpCountAttachments.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingfw/msgtestfw/TestActions/Email/Smtp/src/CMtfTestActionSmtpCountAttachments.cpp Mon Jan 18 20:36:02 2010 +0200 @@ -0,0 +1,95 @@ +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// __ACTION_INFO_BEGIN__ +// [Action Name] +// SmtpCountAttachments +// [Action Parameters] +// Session : Reference to the session. +// MsgId : Value of the message Id. +// ExpectedCount : (Optional) Additional check to check the expected number of attachments. +// Count : The number of attachments. +// [Action Description] +// Counts the number attachments associated with the specified message entry. +// [APIs Used] +// CMsvSession::GetEntryL +// CImEmailMessage::AttachmentManagerL +// MMsvAttachmentManager::AttachmentCount +// __ACTION_INFO_END__ +// +// + + +#include "CMtfTestActionSmtpCountAttachments.h" +#include "CMtfTestCase.h" +#include "CMtfTestActionParameters.h" +#include "MtfTestActionUtilsUser.h" + +#include +#include +#include + +CMtfTestAction* CMtfTestActionSmtpCountAttachments::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) + { + CMtfTestActionSmtpCountAttachments* self = new(ELeave) CMtfTestActionSmtpCountAttachments(aTestCase); + CleanupStack::PushL(self); + self->ConstructL(aActionParameters); + CleanupStack::Pop(); + return self; + } + + +CMtfTestActionSmtpCountAttachments::CMtfTestActionSmtpCountAttachments(CMtfTestCase& aTestCase) + : CMtfSynchronousTestAction(aTestCase) + { + } + + +CMtfTestActionSmtpCountAttachments::~CMtfTestActionSmtpCountAttachments() + { + } + + +void CMtfTestActionSmtpCountAttachments::ExecuteActionL() + { + TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSmtpCountAttachments); + CMsvSession* paramSession = ObtainParameterReferenceL(TestCase(),ActionParameters().Parameter(0)); + TMsvId messageEntry = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(1)); + TInt expectedCount = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(2), KErrNotFound); + + CMsvEntry* entry = paramSession->GetEntryL(messageEntry); + CleanupStack::PushL(entry); + + CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); + CleanupStack::PushL(emailMsg); + + MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); + + TInt attachmentCount = manager.AttachmentCount(); + + CleanupStack::PopAndDestroy(2, entry); // emailMsg, entry + + if( expectedCount >= 0 ) + { + // Expected count check is enabled + if( expectedCount!=attachmentCount ) + { + // Not the expected number of attachments + User::Leave(KErrGeneral); + } + } + + StoreParameterL(TestCase(),attachmentCount,ActionParameters().Parameter(3)); + TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSmtpCountAttachments); + TestCase().ActionCompletedL(*this); + }