diff -r 9f5ae1728557 -r db3f5fa34ec7 messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionCreateEntry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionCreateEntry.cpp Wed Nov 03 22:41:46 2010 +0530 @@ -0,0 +1,154 @@ +// Copyright (c) 2003-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] +// CreateEntry +// [Action Parameters] +// Session : Reference to the session. +// TypeUid : Value of the entry type uid; +// ParentId : Value of the parent id. +// MtmUid : Value of the MTM uid. +// ServiceId : Value of the the service id. +// (Priority) : Value of the entry priority. Default is medium priority. +// (ReadOnlyFlag) : Value of the read only flag. Default is false. +// (VisibleFlag) : Value of the visible flag. Default is true. +// (Description) : Name of the description. Default is blank. +// (Details) : Name of the details. Default is blank. +// EntryId : Value of the created entry id. +// [Action Description] +// Creates an entry on the specified parent. +// [APIs Used] +// TMsvEntry::iType +// TMsvEntry::SetPriority +// TMsvEntry::iMtm +// TMsvEntry::iServiceId +// TMsvEntry::SetReadOnly +// TMsvEntry::SetVisible +// TMsvEntry::iDescription +// TMsvEntry::iDetails +// TMsvEntry::iDate +// TMsvEntry::Id +// CMsvEntry::SetEntryL +// CMsvEntry::CreateL +// CMsvEntry::OwningService +// __ACTION_INFO_END__ +// +// + +/** + @file +*/ + + +#include "CMtfTestActionCreateEntry.h" +#include "CMtfTestCase.h" +#include "CMtfTestActionParameters.h" +#include "MtfTestActionUtilsUser.h" + +#include + + +CMtfTestAction* CMtfTestActionCreateEntry::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) + { + CMtfTestActionCreateEntry* self = new (ELeave) CMtfTestActionCreateEntry(aTestCase); + CleanupStack::PushL(self); + self->ConstructL(aActionParameters); + CleanupStack::Pop(); + return self; + } + + +CMtfTestActionCreateEntry::CMtfTestActionCreateEntry(CMtfTestCase& aTestCase) + : CMtfTestAction(aTestCase) + { + } + + +CMtfTestActionCreateEntry::~CMtfTestActionCreateEntry() + { + delete iBlank; + } + + +void CMtfTestActionCreateEntry::ExecuteActionL() + { + TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateEntry); + CActiveScheduler::Add(this); + + iBlank = KNullDesC().AllocL(); + + CMsvSession* paramSession = ObtainParameterReferenceL(TestCase(),ActionParameters().Parameter(0)); + TUid paramEntryTypeUid = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(1)); + TMsvId paramParentId = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(2)); + TUid paramMtmUid = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(3), KUidMsvLocalServiceMtm); + TMsvId paramServiceId = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(4), KMsvLocalServiceIndexEntryId); + TMsvPriority paramPriority = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(5),EMsvMediumPriority); + TInt paramReadOnlyFlag = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(6),EFalse); + TInt paramVisibleFlag = ObtainValueParameterL(TestCase(),ActionParameters().Parameter(7),ETrue); + HBufC* paramDescription = ObtainParameterReferenceL(TestCase(),ActionParameters().Parameter(8),iBlank); + HBufC* paramDetails = ObtainParameterReferenceL(TestCase(),ActionParameters().Parameter(9),iBlank); + + iIndexEntry.iType = paramEntryTypeUid; + iIndexEntry.iMtm = paramMtmUid; + iIndexEntry.iServiceId = paramServiceId; + iIndexEntry.SetPriority(paramPriority); + iIndexEntry.SetReadOnly(paramReadOnlyFlag); + iIndexEntry.SetVisible(paramVisibleFlag); + iIndexEntry.iDescription.Set(paramDescription->Des()); + iIndexEntry.iDetails.Set(paramDetails->Des()); + iIndexEntry.iDate.HomeTime(); + + CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramParentId,TMsvSelectionOrdering()); + CleanupStack::PushL(entry); + entry->SetEntryL(paramParentId); + if (entry->OwningService() == KMsvLocalServiceIndexEntryId) + { + entry->CreateL(iIndexEntry); + CleanupStack::PopAndDestroy(entry); + TMsvId paramEntryId; + paramEntryId = iIndexEntry.Id(); + + StoreParameterL(TestCase(),paramEntryId,ActionParameters().Parameter(10)); + + TestCase().ActionCompletedL(*this); + } + else + { + iOperation = entry->CreateL(iIndexEntry,iStatus); + SetActive(); + } + TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateEntry); + } + + +void CMtfTestActionCreateEntry::DoCancel() + { + iOperation->Cancel(); + } + + +void CMtfTestActionCreateEntry::RunL() + { + TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus); + delete iOperation; + User::LeaveIfError(err); + + TMsvId paramEntryId; + paramEntryId = iIndexEntry.Id(); + StoreParameterL(TestCase(),paramEntryId,ActionParameters().Parameter(10)); + + TestCase().ActionCompletedL(*this); + } + +