|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 #include <ssm/ssmcommandlist.h> |
|
17 #include "ssmcommandlistimpl.h" |
|
18 |
|
19 /** |
|
20 * Constructs and returns a new CSsmCommandList object. |
|
21 * |
|
22 * @publishedPartner |
|
23 * @released |
|
24 */ |
|
25 EXPORT_C CSsmCommandList* CSsmCommandList::NewL() |
|
26 { |
|
27 CSsmCommandList* self = NewLC(); |
|
28 CleanupStack::Pop(self); |
|
29 return self; |
|
30 } |
|
31 |
|
32 /** |
|
33 * Constructs and returns a new CSsmCommandList object. |
|
34 * |
|
35 * If this function returns successfully then that allocated object |
|
36 * is pushed onto the cleanup stack. |
|
37 * |
|
38 * @publishedPartner |
|
39 * @released |
|
40 */ |
|
41 EXPORT_C CSsmCommandList* CSsmCommandList::NewLC() |
|
42 { |
|
43 CSsmCommandList* self = new(ELeave) CSsmCommandList; |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 /** |
|
50 Used to create an instance of CSsmCommandList class from CSsmCommandList object |
|
51 Must be used only by CLE |
|
52 @param aSsmCommandList CSsmCommandList reference |
|
53 @param aUtilProvider CSsmCommandUtilProvider pointer |
|
54 @return A pointer to an object of type CSsmCommandList. |
|
55 |
|
56 @internalComponent |
|
57 */ |
|
58 EXPORT_C CSsmCommandList* CSsmCommandList::NewLC(const CSsmCommandList* aSsmCommandList, CSsmCommandUtilProvider* aUtilProvider) |
|
59 { |
|
60 CSsmCommandList* self = new(ELeave) CSsmCommandList; |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(aSsmCommandList, aUtilProvider); |
|
63 return self; |
|
64 } |
|
65 /** |
|
66 @internalComponent |
|
67 */ |
|
68 CSsmCommandList::CSsmCommandList() |
|
69 { |
|
70 } |
|
71 |
|
72 /** |
|
73 @internalComponent |
|
74 */ |
|
75 void CSsmCommandList::ConstructL() |
|
76 { |
|
77 iImpl = CSsmCommandListImpl::NewL(); |
|
78 } |
|
79 |
|
80 void CSsmCommandList::ConstructL(const CSsmCommandList* aSsmCommandList, CSsmCommandUtilProvider* aUtilProvider) |
|
81 { |
|
82 iImpl = CSsmCommandListImpl::NewL(aSsmCommandList->Impl(), aUtilProvider); |
|
83 } |
|
84 |
|
85 CSsmCommandListImpl* CSsmCommandList::Impl() const |
|
86 { |
|
87 return iImpl; |
|
88 } |
|
89 /** |
|
90 * Frees any resources allocated to this object. |
|
91 * |
|
92 * @publishedPartner |
|
93 * @released |
|
94 */ |
|
95 EXPORT_C CSsmCommandList::~CSsmCommandList() |
|
96 { |
|
97 delete iImpl; |
|
98 } |
|
99 |
|
100 /** |
|
101 * Conversion operator to allow CSsmCommandList objects to be used as MSsmCommandLists. |
|
102 * |
|
103 * @publishedPartner |
|
104 * @released |
|
105 */ |
|
106 CSsmCommandList::operator class MSsmCommandList&() |
|
107 { |
|
108 return *iImpl; |
|
109 } |
|
110 |
|
111 /** |
|
112 * Appends the provided command to the end of the command list. |
|
113 * |
|
114 * If this function does not leave then it takes ownership of the command |
|
115 * passed in. |
|
116 * |
|
117 * @param aCmd The command object to be appended to the command list. |
|
118 * |
|
119 * @publishedPartner |
|
120 * @released |
|
121 */ |
|
122 EXPORT_C void CSsmCommandList::AppendL(MSsmCommand* aCmd) |
|
123 { |
|
124 iImpl->AppendL(aCmd); |
|
125 } |
|
126 |
|
127 /** |
|
128 * Gets the number of Publish System State and SWP commands and a bool value to validate the commandlist. |
|
129 * |
|
130 * On return aSystemState number of publish System State commands. |
|
131 * On return aSWP number of publish SWP commands. |
|
132 * On return aDeferredWait Boolean value, ETrue if commandlist contains a deferred wait command which is not followed by multiple wait, EFalse otherwise. |
|
133 * |
|
134 * @internalComponent |
|
135 * @released |
|
136 */ |
|
137 EXPORT_C void CSsmCommandList::GetDataToValidateCommandlist(TInt& aPublishSystemStateCount , TInt& aPublishSwpCount) const |
|
138 { |
|
139 return iImpl->GetDataToValidateCommandlist(aPublishSystemStateCount,aPublishSwpCount); |
|
140 } |
|
141 |
|
142 /** |
|
143 * Sets the delay between command execution for this command list. |
|
144 * |
|
145 * When this value is set the execution of the command list will pause between each command |
|
146 * by the specified number of milliseconds. |
|
147 * |
|
148 * Pausing between command execution can be useful |
|
149 * to avoid overloading the system when starting many processes with ESsmFireAndForget due to |
|
150 * the processes not rendezvousing. |
|
151 * |
|
152 * @param aDelayBetweenCommands The delay between command execution in milliseconds. If this value is 0 then there will be no delay between command execution. |
|
153 * |
|
154 * @publishedPartner |
|
155 * @released |
|
156 */ |
|
157 EXPORT_C void CSsmCommandList::SetDelayBetweenCommands(TInt aDelayBetweenCommands) |
|
158 { |
|
159 iImpl->SetDelayBetweenCommands(aDelayBetweenCommands); |
|
160 } |
|
161 |
|
162 /** |
|
163 @internalComponent |
|
164 */ |
|
165 EXPORT_C TInt CSsmCommandList::DelayBetweenCommands() const |
|
166 { |
|
167 return iImpl->DelayBetweenCommands(); |
|
168 } |
|
169 |
|
170 /** Read all commands into the list from a stream. This method is used by cle. |
|
171 Since cle executes all the commands in the commandlist utilprovider should also be internalized. |
|
172 @internalComponent |
|
173 */ |
|
174 EXPORT_C void CSsmCommandList::InternalizeL(RReadStream& aReadStream, CSsmCommandUtilProvider& aUtilProvider ) |
|
175 { |
|
176 iImpl->InternalizeL(aReadStream, &aUtilProvider); |
|
177 } |
|
178 |
|
179 /** Read all commands into the list from a stream. This method is used only by the ssmswppolicyserver and |
|
180 ssmswppolicycli. The ssmswppolicyserver and ssmswppolicycli code internalizes and externalizes |
|
181 the commandlist in order to pass the it from server to the client. |
|
182 This commandlist is not executed by ssmswppolicycli, it just passes it to the cle where the commandlist is executed |
|
183 and hence it does not require the utilprovider to be passed in to this method. |
|
184 @internalComponent |
|
185 */ |
|
186 EXPORT_C void CSsmCommandList::InternalizeL(RReadStream& aReadStream) |
|
187 { |
|
188 iImpl->InternalizeL(aReadStream, NULL); |
|
189 } |
|
190 |
|
191 |
|
192 /** Write all commands from the list to a stream |
|
193 @internalComponent |
|
194 */ |
|
195 EXPORT_C void CSsmCommandList::ExternalizeL(RWriteStream& aWriteStream) const |
|
196 { |
|
197 iImpl->ExternalizeL(aWriteStream); |
|
198 } |
|
199 |
|
200 |
|
201 /** Execute a specific command in the list |
|
202 @internalComponent |
|
203 */ |
|
204 EXPORT_C void CSsmCommandList::Execute(TInt aIndex, TRequestStatus& aStatus) |
|
205 { |
|
206 iImpl->Execute(aIndex, aStatus); |
|
207 } |
|
208 |
|
209 |
|
210 /** Cancel a specific command in the list |
|
211 @internalComponent |
|
212 */ |
|
213 EXPORT_C void CSsmCommandList::ExecuteCancel(TInt aIndex) |
|
214 { |
|
215 iImpl->ExecuteCancel(aIndex); |
|
216 } |
|
217 |
|
218 /** Count of items in the list |
|
219 @internalComponent |
|
220 */ |
|
221 EXPORT_C TInt CSsmCommandList::Count() const |
|
222 { |
|
223 return iImpl->Count(); |
|
224 } |
|
225 |
|
226 /** |
|
227 This function should be used only if command list is executed. |
|
228 It waits for pending deferred commands to finish and then deletes the list. |
|
229 @internalComponent |
|
230 */ |
|
231 EXPORT_C void CSsmCommandList::DeferredDelete() |
|
232 { |
|
233 if (iImpl) |
|
234 { |
|
235 iImpl->DeferredDelete(); |
|
236 iImpl = NULL; |
|
237 } |
|
238 delete this; |
|
239 } |
|
240 |
|
241 /** |
|
242 * Retrieves the command at the position specified position. |
|
243 * |
|
244 * @param aIndex The index of the command to retrieve. |
|
245 * |
|
246 * @return The command at the specified index. |
|
247 * @publishedPartner |
|
248 * @released |
|
249 */ |
|
250 EXPORT_C const MSsmCommand* CSsmCommandList::operator[](TInt aIndex) const |
|
251 { |
|
252 return (*iImpl)[aIndex]; |
|
253 } |
|
254 |
|
255 /** |
|
256 * Retrieves the command's severity |
|
257 * |
|
258 * @param aIndex The severity of the command to retrieve. |
|
259 * |
|
260 * @return The command's severity. |
|
261 * @internalComponent |
|
262 * @released |
|
263 */ |
|
264 EXPORT_C TCmdErrorSeverity CSsmCommandList::Severity(TInt aCommandIndex) const |
|
265 { |
|
266 return iImpl->Severity(aCommandIndex); |
|
267 } |