|
1 // Copyright (c) 2004-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 // CreatePigeonMessage |
|
17 // [Action Parameters] |
|
18 // CMsvSession Session <input>: Reference to the session. |
|
19 // TMsvId ParentId <input>: Value of the parent id. |
|
20 // TMsvId ServiceId <input>: Value of the the service id. |
|
21 // TInt Time <input>: Time interval in minutes |
|
22 // for scheduling the message |
|
23 // TMsvId MessageId <output>: Value of the created message id. |
|
24 // [Action Description] |
|
25 // Creates a Pigeon message on the specified parent folder. |
|
26 // [APIs Used] |
|
27 // TMsvEntry::iMtm |
|
28 // TMsvEntry::iServiceId |
|
29 // TMsvEntry::iDate |
|
30 // TMsvEntry::Id |
|
31 // CMsvEntry::SetEntryL |
|
32 // CMsvEntry::CreateL |
|
33 // __ACTION_INFO_END__ |
|
34 // |
|
35 // |
|
36 |
|
37 // System Includes |
|
38 #include <msvapi.h> |
|
39 #include <msvuids.h> |
|
40 #include <txtrich.h> |
|
41 #include <smuthdr.h> |
|
42 #include "pigeonservermtm.h" |
|
43 |
|
44 // User Includes |
|
45 #include "CMtfTestActionCreatePigeonMessage.h" |
|
46 #include "CMtfTestCase.h" |
|
47 #include "CMtfTestActionParameters.h" |
|
48 |
|
49 |
|
50 /** |
|
51 Function : NewL |
|
52 Description : Constructs a new CMtfTestActionCreatePigeonMessage object |
|
53 @internalTechnology |
|
54 @param : aTestCase :Reference to the Test case |
|
55 @param : aActionParams :Test Action parameters |
|
56 @return : CMtfTestAction* :a base class pointer to the newly created object |
|
57 @pre none |
|
58 @post: none |
|
59 */ |
|
60 CMtfTestAction* CMtfTestActionCreatePigeonMessage::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
61 { |
|
62 CMtfTestActionCreatePigeonMessage* self = new (ELeave) CMtfTestActionCreatePigeonMessage(aTestCase); |
|
63 CleanupStack::PushL(self); |
|
64 self->ConstructL(aActionParameters); |
|
65 CleanupStack::Pop(self); |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 Function : CMtfTestActionCreatePigeonMessage |
|
72 Description : Constructor |
|
73 @internalTechnology |
|
74 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
75 @pre none |
|
76 @post: none |
|
77 */ |
|
78 CMtfTestActionCreatePigeonMessage::CMtfTestActionCreatePigeonMessage(CMtfTestCase& aTestCase) |
|
79 : CMtfSynchronousTestAction(aTestCase) |
|
80 { |
|
81 } |
|
82 |
|
83 |
|
84 /** |
|
85 Function : ExecuteActionL |
|
86 Description :Creates a Pigeon Message in the specified folder. |
|
87 @internalTechnology |
|
88 @param : none |
|
89 @return : void |
|
90 @pre : none |
|
91 @post none |
|
92 */ |
|
93 void CMtfTestActionCreatePigeonMessage::ExecuteActionL() |
|
94 { |
|
95 TestCase().Logger().Write(_L("CMtfTestActionCreatePigeonMessage::ExecuteActionL IN")); |
|
96 |
|
97 // Obtain Input parameters |
|
98 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
99 TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
100 TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2)); |
|
101 TInt paramTime = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3)); |
|
102 |
|
103 if(TestCase().TestStepResult() == EPass) |
|
104 { |
|
105 // Create a message entry |
|
106 TMsvEntry indexEntry; |
|
107 indexEntry.iType = KUidMsvMessageEntry; |
|
108 indexEntry.iMtm = KUidMsgTypePigeon; |
|
109 indexEntry.iServiceId = paramServiceId; |
|
110 indexEntry.SetVisible(ETrue); |
|
111 indexEntry.SetInPreparation(EFalse); |
|
112 indexEntry.iDescription.Set(KNullDesC); |
|
113 indexEntry.iDetails.Set(KNullDesC); |
|
114 |
|
115 // Set schedule time |
|
116 TTime date ; |
|
117 date.HomeTime(); |
|
118 // If creating two or more messages for the same time (ie MSG_SCH_SEND_0009.script), they have |
|
119 // to have exactly the same time, otherwise they will cause an assert further on. Fractions of |
|
120 // a second are not acceptable. |
|
121 RoundUpToSecond(date); |
|
122 date += TTimeIntervalMinutes(paramTime); |
|
123 indexEntry.iDate = date; |
|
124 |
|
125 // Set message scheduling info |
|
126 indexEntry.SetOffPeak(EFalse); |
|
127 indexEntry.SetScheduled(EFalse); |
|
128 indexEntry.SetSendingState(KMsvSendStateWaiting); |
|
129 |
|
130 // Create Entry |
|
131 CMsvEntry* entry = paramSession->GetEntryL(paramParentId); |
|
132 CleanupStack::PushL(entry); |
|
133 |
|
134 //Creates a new child entry owned by the context synchronously |
|
135 entry->CreateL(indexEntry); |
|
136 TMsvId paramMessageId = indexEntry.Id(); |
|
137 |
|
138 paramSession->CleanupEntryPushL(paramMessageId); |
|
139 entry->SetEntryL(paramMessageId); |
|
140 |
|
141 paramSession->CleanupEntryPop(); |
|
142 CleanupStack::PopAndDestroy(entry); |
|
143 |
|
144 // Provide the Message Id as output of the Test Action |
|
145 StoreParameterL<TMsvId>(TestCase(),paramMessageId,ActionParameters().Parameter(4)); |
|
146 |
|
147 TestCase().Logger().Write(_L("CMtfTestActionCreatePigeonMessage::ExecuteActionL OUT")); |
|
148 TestCase().ActionCompletedL(*this); |
|
149 } |
|
150 } |
|
151 |
|
152 |
|
153 /** |
|
154 Function : RoundUpToSecond |
|
155 Description : On return, the passed value rounded up to the nearest second. |
|
156 @param aTime |
|
157 @return : void |
|
158 */ |
|
159 void CMtfTestActionCreatePigeonMessage::RoundUpToSecond(TTime& aTime) |
|
160 { |
|
161 TDateTime dt(aTime.DateTime()); |
|
162 dt.SetMicroSecond(0); |
|
163 aTime = dt; |
|
164 aTime += (TTimeIntervalSeconds) 1; |
|
165 } |