messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionCreateEntry.cpp
changeset 0 8e480a14352b
child 58 6c34d0baa0b1
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 // CreateEntry
       
    17 // [Action Parameters]
       
    18 // Session        <input>: Reference to the session.
       
    19 // TypeUid	 	  <input>: Value of the entry type uid;
       
    20 // ParentId       <input>: Value of the parent id.
       
    21 // MtmUid         <input>: Value of the MTM uid.
       
    22 // ServiceId      <input>: Value of the the service id.
       
    23 // (Priority)     <input>: Value of the entry priority. Default is medium priority.
       
    24 // (ReadOnlyFlag) <input>: Value of the read only flag. Default is false.
       
    25 // (VisibleFlag)  <input>: Value of the visible flag. Default is true.
       
    26 // (Description)  <input>: Name of the description.	Default is blank.
       
    27 // (Details)      <input>: Name of the details. Default is blank.
       
    28 // EntryId       <output>: Value of the created entry id.
       
    29 // [Action Description]
       
    30 // Creates an entry on the specified parent.
       
    31 // [APIs Used]
       
    32 // TMsvEntry::iType
       
    33 // TMsvEntry::SetPriority	
       
    34 // TMsvEntry::iMtm	
       
    35 // TMsvEntry::iServiceId
       
    36 // TMsvEntry::SetReadOnly	
       
    37 // TMsvEntry::SetVisible	
       
    38 // TMsvEntry::iDescription
       
    39 // TMsvEntry::iDetails
       
    40 // TMsvEntry::iDate
       
    41 // TMsvEntry::Id
       
    42 // CMsvEntry::SetEntryL
       
    43 // CMsvEntry::CreateL
       
    44 // CMsvEntry::OwningService
       
    45 // __ACTION_INFO_END__
       
    46 // 
       
    47 //
       
    48 
       
    49 /**
       
    50  @file
       
    51 */
       
    52 
       
    53 
       
    54 #include "CMtfTestActionCreateEntry.h"
       
    55 #include "CMtfTestCase.h"
       
    56 #include "CMtfTestActionParameters.h"
       
    57 #include "MtfTestActionUtilsUser.h"
       
    58 
       
    59 #include <miutset.h>
       
    60 
       
    61 
       
    62 CMtfTestAction* CMtfTestActionCreateEntry::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    63 	{
       
    64 	CMtfTestActionCreateEntry* self = new (ELeave) CMtfTestActionCreateEntry(aTestCase);
       
    65 	CleanupStack::PushL(self);
       
    66 	self->ConstructL(aActionParameters);
       
    67 	CleanupStack::Pop();
       
    68 	return self;
       
    69 	}
       
    70 	
       
    71 
       
    72 CMtfTestActionCreateEntry::CMtfTestActionCreateEntry(CMtfTestCase& aTestCase)
       
    73 	: CMtfTestAction(aTestCase)
       
    74 	{
       
    75 	}
       
    76 
       
    77 
       
    78 CMtfTestActionCreateEntry::~CMtfTestActionCreateEntry()
       
    79 	{
       
    80 	delete iBlank;
       
    81 	}
       
    82 
       
    83 
       
    84 void CMtfTestActionCreateEntry::ExecuteActionL()
       
    85 	{
       
    86 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateEntry);
       
    87 	CActiveScheduler::Add(this);
       
    88 	
       
    89 	iBlank = KNullDesC().AllocL();
       
    90 
       
    91 	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
       
    92 	TUid paramEntryTypeUid = ObtainValueParameterL<TUid>(TestCase(),ActionParameters().Parameter(1));
       
    93 	TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2));
       
    94 	TUid paramMtmUid = ObtainValueParameterL<TUid>(TestCase(),ActionParameters().Parameter(3), KUidMsvLocalServiceMtm);
       
    95 	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(4), KMsvLocalServiceIndexEntryId);
       
    96 	TMsvPriority paramPriority = ObtainValueParameterL<TMsvPriority>(TestCase(),ActionParameters().Parameter(5),EMsvMediumPriority);
       
    97 	TInt paramReadOnlyFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(6),EFalse);
       
    98 	TInt paramVisibleFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(7),ETrue);
       
    99 	HBufC* paramDescription = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(8),iBlank);
       
   100 	HBufC* paramDetails = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(9),iBlank);
       
   101 
       
   102 	iIndexEntry.iType = paramEntryTypeUid;
       
   103 	iIndexEntry.iMtm = paramMtmUid;	
       
   104 	iIndexEntry.iServiceId = paramServiceId;
       
   105 	iIndexEntry.SetPriority(paramPriority);	
       
   106 	iIndexEntry.SetReadOnly(paramReadOnlyFlag);	
       
   107 	iIndexEntry.SetVisible(paramVisibleFlag);	
       
   108 	iIndexEntry.iDescription.Set(paramDescription->Des());
       
   109 	iIndexEntry.iDetails.Set(paramDetails->Des());
       
   110 	iIndexEntry.iDate.HomeTime();
       
   111 
       
   112 	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramParentId,TMsvSelectionOrdering());
       
   113 	CleanupStack::PushL(entry);
       
   114 	entry->SetEntryL(paramParentId);
       
   115 	if (entry->OwningService() == KMsvLocalServiceIndexEntryId)
       
   116 		{
       
   117 		entry->CreateL(iIndexEntry);
       
   118 		CleanupStack::PopAndDestroy(entry);
       
   119 		TMsvId paramEntryId;
       
   120 		paramEntryId = iIndexEntry.Id();
       
   121 
       
   122 		StoreParameterL<TMsvId>(TestCase(),paramEntryId,ActionParameters().Parameter(10));
       
   123 
       
   124 		TestCase().ActionCompletedL(*this);
       
   125 		}
       
   126 	else
       
   127 		{
       
   128 		iOperation = entry->CreateL(iIndexEntry,iStatus);
       
   129 		SetActive();
       
   130 		}
       
   131 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateEntry);
       
   132 	}
       
   133 
       
   134 
       
   135 void CMtfTestActionCreateEntry::DoCancel()
       
   136 	{
       
   137 	iOperation->Cancel();
       
   138 	}
       
   139 
       
   140 
       
   141 void CMtfTestActionCreateEntry::RunL()
       
   142 	{
       
   143 	TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus);
       
   144 	delete iOperation;
       
   145 	User::LeaveIfError(err);
       
   146 
       
   147 	TMsvId paramEntryId;
       
   148 	paramEntryId = iIndexEntry.Id();
       
   149 	StoreParameterL<TMsvId>(TestCase(),paramEntryId,ActionParameters().Parameter(10));
       
   150 
       
   151 	TestCase().ActionCompletedL(*this);
       
   152 	}
       
   153 
       
   154