|
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 // CreateSmsService |
|
17 // [Action Parameters] |
|
18 // CMsvSession Session <input>: Reference to the session. |
|
19 // TInt Priority <input-optional>: Value of the service priority. |
|
20 // TInt ReadOnlyFlag <input-optional>: Value of the read only flag. |
|
21 // TInt VisibleFlag <input-optional>: Value of the visible flag. |
|
22 // HBufC Description <input-optional>: Name of the description. |
|
23 // HBufC Details <input-optional>: Name of the details. |
|
24 // TMsvId ServiceId <output-completion>: Value of an SMS service id. |
|
25 // [Action Description] |
|
26 // Checks for an existing SMS service and returns it. |
|
27 // If the service does not exist, creates a new SMS service with optional |
|
28 // parameters Priority,ReadOnlyFlag,VisibleFlag,Description and Details. |
|
29 // [APIs Used] |
|
30 // TMsvEntry::iType |
|
31 // TMsvEntry::SetPriority |
|
32 // TMsvEntry::iMtm |
|
33 // TMsvEntry::SetReadOnly |
|
34 // TMsvEntry::SetVisible |
|
35 // TMsvEntry::iDescription |
|
36 // TMsvEntry::iDetails |
|
37 // TMsvEntry::iDate |
|
38 // CMsvEntry::SetEntryL |
|
39 // CMsvEntry::CreateL |
|
40 // __ACTION_INFO_END__ |
|
41 // |
|
42 // |
|
43 |
|
44 /** |
|
45 @file |
|
46 */ |
|
47 |
|
48 |
|
49 #include "CMtfTestActionCreateSmsService.h" |
|
50 #include "CMtfTestCase.h" |
|
51 #include "CMtfTestActionParameters.h" |
|
52 #include "MtfTestActionUtilsUser.h" |
|
53 |
|
54 #include <smut.h> |
|
55 #include <msvstd.h> |
|
56 #include <miutset.h> |
|
57 #include <msvapi.h> |
|
58 |
|
59 |
|
60 CMtfTestAction* CMtfTestActionCreateSmsService::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
61 { |
|
62 CMtfTestActionCreateSmsService* self = new (ELeave) CMtfTestActionCreateSmsService(aTestCase); |
|
63 CleanupStack::PushL(self); |
|
64 self->ConstructL(aActionParameters); |
|
65 CleanupStack::Pop(); |
|
66 return self; |
|
67 } |
|
68 |
|
69 CMtfTestActionCreateSmsService::CMtfTestActionCreateSmsService(CMtfTestCase& aTestCase) |
|
70 : CMtfTestAction(aTestCase) |
|
71 { |
|
72 } |
|
73 |
|
74 |
|
75 CMtfTestActionCreateSmsService::~CMtfTestActionCreateSmsService() |
|
76 { |
|
77 Cancel(); |
|
78 delete iOperation; |
|
79 } |
|
80 |
|
81 void CMtfTestActionCreateSmsService::ExecuteActionL() |
|
82 { |
|
83 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateSmsService); |
|
84 TInt err; |
|
85 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
86 TRAP(err, TSmsUtilities::ServiceIdL(*paramSession,iSmsServiceId)); |
|
87 if (err==KErrNotFound) |
|
88 { |
|
89 TPtrC defaultDescription(_L("SMSService")); |
|
90 HBufC* defDescriptionBuf = defaultDescription.AllocLC(); |
|
91 TPtrC defaultDetails(_L("SMS")); |
|
92 HBufC* defDetailsBuf = defaultDetails.AllocLC(); |
|
93 |
|
94 TInt paramPriority = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1), EMsvMediumPriority); |
|
95 TInt paramReadOnlyFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2), EFalse); |
|
96 TInt paramVisibleFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3), ETrue); |
|
97 HBufC* paramDescription = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(4), defDescriptionBuf); |
|
98 HBufC* paramDetails = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(5), defDetailsBuf); |
|
99 TMsvEntry indexEntry; |
|
100 indexEntry.iType = KUidMsvServiceEntry; |
|
101 indexEntry.iMtm = KUidMsgTypeSMS; |
|
102 indexEntry.SetReadOnly(paramReadOnlyFlag); |
|
103 indexEntry.SetVisible(paramVisibleFlag); |
|
104 indexEntry.SetPriority(TMsvPriority(paramPriority)); |
|
105 indexEntry.iDescription.Set(paramDescription->Des()); |
|
106 indexEntry.iDetails.Set(paramDetails->Des()); |
|
107 indexEntry.iDate.HomeTime(); |
|
108 |
|
109 CMsvEntry* entry = CMsvEntry::NewL(*paramSession,KMsvRootIndexEntryId,TMsvSelectionOrdering()); |
|
110 CleanupStack::PushL(entry); |
|
111 iOperation = entry->CreateL(indexEntry,iStatus); |
|
112 CleanupStack::PopAndDestroy(entry); |
|
113 |
|
114 CActiveScheduler::Add(this); |
|
115 SetActive(); |
|
116 StoreParameterL<TMsvId>(TestCase(),iSmsServiceId,ActionParameters().Parameter(6)); |
|
117 CleanupStack::PopAndDestroy(2, defDescriptionBuf); // defDetailsBuf, defDescriptionBuf |
|
118 } |
|
119 else if (err == KErrNone) |
|
120 { |
|
121 StoreParameterL<TMsvId>(TestCase(),iSmsServiceId,ActionParameters().Parameter(6)); |
|
122 TestCase().ActionCompletedL(*this); |
|
123 } |
|
124 else |
|
125 { |
|
126 User::LeaveIfError(err); |
|
127 } |
|
128 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateSmsService); |
|
129 } |
|
130 |
|
131 void CMtfTestActionCreateSmsService::DoCancel() |
|
132 { |
|
133 iOperation->Cancel(); |
|
134 } |
|
135 |
|
136 void CMtfTestActionCreateSmsService::RunL() |
|
137 { |
|
138 TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation, iStatus); |
|
139 User::LeaveIfError(err); |
|
140 |
|
141 TPckgBuf<TMsvLocalOperationProgress> progress; |
|
142 progress.Copy(iOperation->FinalProgress()); |
|
143 |
|
144 iSmsServiceId = progress().iId; |
|
145 StoreParameterL<TMsvId>(TestCase(),iSmsServiceId,ActionParameters().Parameter(6)); |
|
146 |
|
147 TestCase().ActionCompletedL(*this); |
|
148 } |
|
149 |