messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionCreateService.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 // CreateService
       
    17 // [Action Parameters]
       
    18 // Session        <input>: Reference to the session.
       
    19 // MtmUid         <input>: Value of the MTM uid.
       
    20 // (Priority)     <input>: Value of the entry priority. Default is medium priority.
       
    21 // (ReadOnlyFlag) <input>: Value of the read only flag. Default is false.
       
    22 // (VisibleFlag)  <input>: Value of the visible flag. Default is true.
       
    23 // (Description)  <input>: Name of the description.	Default is blank.
       
    24 // (Details)      <input>: Name of the details. Default is blank.
       
    25 // ServiceId     <output>: Value of the created service id.
       
    26 // [Action Description]
       
    27 // Creates a service.
       
    28 // [APIs Used]
       
    29 // TMsvEntry::iType
       
    30 // TMsvEntry::SetPriority	
       
    31 // TMsvEntry::iMtm	
       
    32 // TMsvEntry::SetReadOnly	
       
    33 // TMsvEntry::SetVisible	
       
    34 // TMsvEntry::iDescription
       
    35 // TMsvEntry::iDetails
       
    36 // TMsvEntry::iDate
       
    37 // TMsvEntry::Id
       
    38 // CMsvEntry::SetEntryL
       
    39 // CMsvEntry::CreateL
       
    40 // __ACTION_INFO_END__
       
    41 // 
       
    42 //
       
    43 
       
    44 /**
       
    45  @file
       
    46 */
       
    47 
       
    48 
       
    49 #include "CMtfTestActionCreateService.h"
       
    50 #include "CMtfTestCase.h"
       
    51 #include "CMtfTestActionParameters.h"
       
    52 
       
    53 #include <msvapi.h>
       
    54 #include <miutset.h>
       
    55 
       
    56 
       
    57 CMtfTestAction* CMtfTestActionCreateService::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    58 	{
       
    59 	CMtfTestActionCreateService* self = new (ELeave) CMtfTestActionCreateService(aTestCase);
       
    60 	CleanupStack::PushL(self);
       
    61 	self->ConstructL(aActionParameters);
       
    62 	CleanupStack::Pop();
       
    63 	return self;
       
    64 	}
       
    65 	
       
    66 
       
    67 CMtfTestActionCreateService::CMtfTestActionCreateService(CMtfTestCase& aTestCase)
       
    68 	: CMtfSynchronousTestAction(aTestCase)
       
    69 	{
       
    70 	}
       
    71 
       
    72 
       
    73 CMtfTestActionCreateService::~CMtfTestActionCreateService()
       
    74 	{
       
    75 	delete iBlank;
       
    76 	}
       
    77 
       
    78 
       
    79 void CMtfTestActionCreateService::ExecuteActionL()
       
    80 	{
       
    81 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateService);
       
    82 	iBlank = KNullDesC().AllocL();
       
    83 
       
    84 	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
       
    85 	TUid paramMtmUid = ObtainValueParameterL<TUid>(TestCase(),ActionParameters().Parameter(1));
       
    86 	TMsvPriority paramPriority = ObtainValueParameterL<TMsvPriority>(TestCase(),ActionParameters().Parameter(2),EMsvMediumPriority);
       
    87 	TInt paramReadOnlyFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3),EFalse);
       
    88 	TInt paramVisibleFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(4),ETrue);
       
    89 	HBufC* paramDescription = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(5),iBlank);
       
    90 	HBufC* paramDetails = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(6),iBlank);
       
    91 
       
    92 	TMsvEntry indexEntry;
       
    93 	indexEntry.iType = KUidMsvServiceEntry;
       
    94 	indexEntry.iMtm = paramMtmUid;	
       
    95 	indexEntry.SetPriority(paramPriority);
       
    96 	indexEntry.SetReadOnly(paramReadOnlyFlag);	
       
    97 	indexEntry.SetVisible(paramVisibleFlag);	
       
    98 	indexEntry.iDescription.Set(paramDescription->Des());
       
    99 	indexEntry.iDetails.Set(paramDetails->Des());
       
   100 	indexEntry.iDate.HomeTime();
       
   101 
       
   102 	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,KMsvRootIndexEntryId,TMsvSelectionOrdering());
       
   103 	CleanupStack::PushL(entry);
       
   104 	entry->SetEntryL(KMsvRootIndexEntryId);
       
   105 	entry->CreateL(indexEntry);
       
   106 	CleanupStack::PopAndDestroy(entry);
       
   107 	TMsvId paramServiceId;
       
   108 	paramServiceId = indexEntry.Id();
       
   109 
       
   110 	StoreParameterL<TMsvId>(TestCase(),paramServiceId,ActionParameters().Parameter(7));
       
   111 
       
   112 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateService);
       
   113 	TestCase().ActionCompletedL(*this);
       
   114 	}
       
   115