sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "t_certstoreactionsclient.h"
|
sl@0
|
24 |
#include "t_certstoredefs.h"
|
sl@0
|
25 |
#include "t_certstoreout.h"
|
sl@0
|
26 |
#include "t_input.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
CTestAction* CInitCertificateAppInfoManager::NewL(RFs &aFs,
|
sl@0
|
29 |
CConsoleBase& aConsole,
|
sl@0
|
30 |
Output& aOut,
|
sl@0
|
31 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
CTestAction* self = NewLC(aFs, aConsole, aOut, aTestActionSpec);
|
sl@0
|
34 |
CleanupStack::Pop(self);
|
sl@0
|
35 |
return self;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
CTestAction* CInitCertificateAppInfoManager::NewLC(RFs &aFs,
|
sl@0
|
39 |
CConsoleBase& aConsole,
|
sl@0
|
40 |
Output& aOut,
|
sl@0
|
41 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
CInitCertificateAppInfoManager* self =
|
sl@0
|
44 |
new(ELeave) CInitCertificateAppInfoManager(aFs, aConsole, aOut);
|
sl@0
|
45 |
CleanupStack::PushL(self);
|
sl@0
|
46 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
47 |
return self;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
CInitCertificateAppInfoManager::~CInitCertificateAppInfoManager()
|
sl@0
|
51 |
{
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
void CInitCertificateAppInfoManager::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
switch (iState)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
case EInit:
|
sl@0
|
59 |
{
|
sl@0
|
60 |
TRAPD(err, HandleEInit());
|
sl@0
|
61 |
TRequestStatus* status = &aStatus;
|
sl@0
|
62 |
User::RequestComplete(status, err);
|
sl@0
|
63 |
}
|
sl@0
|
64 |
break;
|
sl@0
|
65 |
|
sl@0
|
66 |
case EFinished:
|
sl@0
|
67 |
{
|
sl@0
|
68 |
TRequestStatus* status = &aStatus;
|
sl@0
|
69 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
70 |
if (aStatus == iExpectedResult)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
iResult = ETrue;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
else
|
sl@0
|
75 |
{
|
sl@0
|
76 |
iResult = EFalse;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
if (aStatus == KErrNoMemory)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
iState = EInit;
|
sl@0
|
81 |
}
|
sl@0
|
82 |
else
|
sl@0
|
83 |
{
|
sl@0
|
84 |
iFinished = ETrue;
|
sl@0
|
85 |
}
|
sl@0
|
86 |
}
|
sl@0
|
87 |
break;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
void CInitCertificateAppInfoManager::PerformCancel()
|
sl@0
|
92 |
{
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
void CInitCertificateAppInfoManager::Reset()
|
sl@0
|
96 |
{
|
sl@0
|
97 |
__ASSERT_DEBUG(EFalse, User::Panic(_L("CInitCertificateAppInfoManager::Reset()"), 1));
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
CInitCertificateAppInfoManager::CInitCertificateAppInfoManager(RFs &aFs,
|
sl@0
|
101 |
CConsoleBase& aConsole,
|
sl@0
|
102 |
Output& aOut)
|
sl@0
|
103 |
|
sl@0
|
104 |
: CCertStoreTestAction(aFs, aConsole, aOut), iState(EInit), iFs(aFs)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
void CInitCertificateAppInfoManager::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
CTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
111 |
|
sl@0
|
112 |
// Set expected result
|
sl@0
|
113 |
|
sl@0
|
114 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
115 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
116 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
117 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
void CInitCertificateAppInfoManager::HandleEInit()
|
sl@0
|
121 |
{
|
sl@0
|
122 |
iState = EFinished;
|
sl@0
|
123 |
InitTheCertificateAppInfoManagerL();
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
void CInitCertificateAppInfoManager::DoReportAction()
|
sl@0
|
127 |
{
|
sl@0
|
128 |
iOut.writeString(_L("Creating CertificateAppInfoManager..."));
|
sl@0
|
129 |
iOut.writeNewLine();
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
void CInitCertificateAppInfoManager::DoCheckResult(TInt aError)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
if (iFinished)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
if (aError == KErrNone)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
iConsole.Write(_L("\tcertificate app info manager created successfully\n"));
|
sl@0
|
139 |
iOut.writeString(_L("\tcertificate app info manager created successfully"));
|
sl@0
|
140 |
iOut.writeNewLine();
|
sl@0
|
141 |
iOut.writeNewLine();
|
sl@0
|
142 |
}
|
sl@0
|
143 |
else
|
sl@0
|
144 |
{
|
sl@0
|
145 |
iConsole.Write(_L("\tcertificate app info manager creation failed\n"));
|
sl@0
|
146 |
iOut.writeString(_L("\tcertificate app info manager creation failed"));
|
sl@0
|
147 |
iOut.writeNewLine();
|
sl@0
|
148 |
iOut.writeNewLine();
|
sl@0
|
149 |
}
|
sl@0
|
150 |
}
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
CTestAction* CDeleteCertificateAppInfoManager::NewL(RFs& aFs,
|
sl@0
|
154 |
CConsoleBase& aConsole,
|
sl@0
|
155 |
Output& aOut,
|
sl@0
|
156 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
157 |
{
|
sl@0
|
158 |
CDeleteCertificateAppInfoManager* self =
|
sl@0
|
159 |
new(ELeave) CDeleteCertificateAppInfoManager(aFs, aConsole, aOut);
|
sl@0
|
160 |
CleanupStack::PushL(self);
|
sl@0
|
161 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
162 |
CleanupStack::Pop(self);
|
sl@0
|
163 |
return self;
|
sl@0
|
164 |
}
|
sl@0
|
165 |
|
sl@0
|
166 |
CDeleteCertificateAppInfoManager::~CDeleteCertificateAppInfoManager()
|
sl@0
|
167 |
{
|
sl@0
|
168 |
}
|
sl@0
|
169 |
|
sl@0
|
170 |
CDeleteCertificateAppInfoManager::CDeleteCertificateAppInfoManager(RFs& aFs, CConsoleBase& aConsole,
|
sl@0
|
171 |
Output& aOut)
|
sl@0
|
172 |
: CCertStoreTestAction(aFs, aConsole, aOut), iState(EDelete)
|
sl@0
|
173 |
{
|
sl@0
|
174 |
}
|
sl@0
|
175 |
|
sl@0
|
176 |
void CDeleteCertificateAppInfoManager::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
177 |
{
|
sl@0
|
178 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
179 |
|
sl@0
|
180 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
181 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
182 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
183 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
void CDeleteCertificateAppInfoManager::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
switch (iState)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
case EDelete:
|
sl@0
|
191 |
{
|
sl@0
|
192 |
DeleteTheCertificateAppInfoManager();
|
sl@0
|
193 |
iState = EFinished;
|
sl@0
|
194 |
TRequestStatus* status = &aStatus;
|
sl@0
|
195 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
196 |
}
|
sl@0
|
197 |
break;
|
sl@0
|
198 |
|
sl@0
|
199 |
case EFinished:
|
sl@0
|
200 |
{
|
sl@0
|
201 |
TRequestStatus* status = &aStatus;
|
sl@0
|
202 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
203 |
if (aStatus == iExpectedResult)
|
sl@0
|
204 |
{
|
sl@0
|
205 |
iResult = ETrue;
|
sl@0
|
206 |
}
|
sl@0
|
207 |
else
|
sl@0
|
208 |
{
|
sl@0
|
209 |
iResult = EFalse;
|
sl@0
|
210 |
}
|
sl@0
|
211 |
if (aStatus == KErrNoMemory)
|
sl@0
|
212 |
{
|
sl@0
|
213 |
iState = EDelete;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
else
|
sl@0
|
216 |
{
|
sl@0
|
217 |
iFinished = ETrue;
|
sl@0
|
218 |
}
|
sl@0
|
219 |
}
|
sl@0
|
220 |
break;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
}
|
sl@0
|
223 |
|
sl@0
|
224 |
void CDeleteCertificateAppInfoManager::PerformCancel()
|
sl@0
|
225 |
{
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
void CDeleteCertificateAppInfoManager::Reset()
|
sl@0
|
229 |
{
|
sl@0
|
230 |
__ASSERT_DEBUG(EFalse, User::Panic(_L("CDeleteCertificateAppInfoManager::Reset()"), 1));
|
sl@0
|
231 |
}
|
sl@0
|
232 |
|
sl@0
|
233 |
void CDeleteCertificateAppInfoManager::DoReportAction()
|
sl@0
|
234 |
{
|
sl@0
|
235 |
iOut.writeString(_L("Deleting CertificateAppInfoManager..."));
|
sl@0
|
236 |
iOut.writeNewLine();
|
sl@0
|
237 |
}
|
sl@0
|
238 |
|
sl@0
|
239 |
void CDeleteCertificateAppInfoManager::DoCheckResult(TInt aError)
|
sl@0
|
240 |
{
|
sl@0
|
241 |
if (iFinished)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
if (aError == KErrNone)
|
sl@0
|
244 |
{
|
sl@0
|
245 |
iConsole.Write(_L("\tcertificate app info manager deleted successfully\n"));
|
sl@0
|
246 |
iOut.writeString(_L("\tcertificate app info manager deleted successfully"));
|
sl@0
|
247 |
iOut.writeNewLine();
|
sl@0
|
248 |
iOut.writeNewLine();
|
sl@0
|
249 |
}
|
sl@0
|
250 |
else
|
sl@0
|
251 |
{
|
sl@0
|
252 |
iConsole.Write(_L("\tcertificate app info manager deletion failed\n"));
|
sl@0
|
253 |
iOut.writeString(_L("\tcertificate app info manager deletion failed"));
|
sl@0
|
254 |
iOut.writeNewLine();
|
sl@0
|
255 |
iOut.writeNewLine();
|
sl@0
|
256 |
}
|
sl@0
|
257 |
}
|
sl@0
|
258 |
}
|
sl@0
|
259 |
|
sl@0
|
260 |
CTestAction* CAddClient::NewL(RFs& aFs,
|
sl@0
|
261 |
CConsoleBase& aConsole,
|
sl@0
|
262 |
Output& aOut,
|
sl@0
|
263 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
264 |
{
|
sl@0
|
265 |
CAddClient* self = new(ELeave) CAddClient(aFs, aConsole, aOut);
|
sl@0
|
266 |
CleanupStack::PushL(self);
|
sl@0
|
267 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
268 |
CleanupStack::Pop(self);
|
sl@0
|
269 |
return self;
|
sl@0
|
270 |
}
|
sl@0
|
271 |
|
sl@0
|
272 |
CAddClient::~CAddClient()
|
sl@0
|
273 |
{
|
sl@0
|
274 |
delete iClientInfo;
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
void CAddClient::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
278 |
{
|
sl@0
|
279 |
switch (iState)
|
sl@0
|
280 |
{
|
sl@0
|
281 |
case EAdd:
|
sl@0
|
282 |
{
|
sl@0
|
283 |
TInt err = KErrNotReady;
|
sl@0
|
284 |
CCertificateAppInfoManager* appManager = NULL;
|
sl@0
|
285 |
appManager = TheCertificateAppInfoManager();
|
sl@0
|
286 |
if (appManager)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
TRAP(err, appManager->AddL(*iClientInfo));
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|
sl@0
|
291 |
TRequestStatus* status = &aStatus;
|
sl@0
|
292 |
User::RequestComplete(status, err);
|
sl@0
|
293 |
iState = EFinished;
|
sl@0
|
294 |
}
|
sl@0
|
295 |
break;
|
sl@0
|
296 |
|
sl@0
|
297 |
case EFinished:
|
sl@0
|
298 |
{
|
sl@0
|
299 |
TRequestStatus* status = &aStatus;
|
sl@0
|
300 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
301 |
if ( (aStatus == iExpectedResult) || (aStatus == KErrAlreadyExists) )
|
sl@0
|
302 |
{
|
sl@0
|
303 |
iResult = ETrue;
|
sl@0
|
304 |
}
|
sl@0
|
305 |
else
|
sl@0
|
306 |
{
|
sl@0
|
307 |
iResult = EFalse;
|
sl@0
|
308 |
}
|
sl@0
|
309 |
if (aStatus == KErrNoMemory)
|
sl@0
|
310 |
{
|
sl@0
|
311 |
iState = EAdd;
|
sl@0
|
312 |
}
|
sl@0
|
313 |
else
|
sl@0
|
314 |
{
|
sl@0
|
315 |
iFinished = ETrue;
|
sl@0
|
316 |
}
|
sl@0
|
317 |
}
|
sl@0
|
318 |
break;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
}
|
sl@0
|
321 |
|
sl@0
|
322 |
void CAddClient::PerformCancel()
|
sl@0
|
323 |
{
|
sl@0
|
324 |
}
|
sl@0
|
325 |
|
sl@0
|
326 |
void CAddClient::Reset()
|
sl@0
|
327 |
{
|
sl@0
|
328 |
__ASSERT_DEBUG(EFalse, User::Panic(_L("CAddClient::Reset()"), 1));
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
CAddClient::CAddClient(RFs& aFs, CConsoleBase& aConsole,
|
sl@0
|
332 |
Output& aOut)
|
sl@0
|
333 |
: CCertStoreTestAction(aFs, aConsole, aOut), iState(EAdd)
|
sl@0
|
334 |
{
|
sl@0
|
335 |
}
|
sl@0
|
336 |
|
sl@0
|
337 |
void CAddClient::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
338 |
{
|
sl@0
|
339 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
340 |
TInt err = KErrNone;
|
sl@0
|
341 |
TInt pos = 0;
|
sl@0
|
342 |
const TDesC8& name = Input::ParseElement(aTestActionSpec.iActionBody, KNameStart, KNameEnd,
|
sl@0
|
343 |
pos, err);
|
sl@0
|
344 |
const TDesC8& uid = Input::ParseElement(aTestActionSpec.iActionBody, KUIDStart, KUIDEnd,
|
sl@0
|
345 |
pos, err);
|
sl@0
|
346 |
TLex8 lex(uid);
|
sl@0
|
347 |
TUid u;
|
sl@0
|
348 |
lex.Val(u.iUid);
|
sl@0
|
349 |
TName n;
|
sl@0
|
350 |
n.Copy(name);
|
sl@0
|
351 |
iClientInfo = new(ELeave) TCertificateAppInfo(u, n);
|
sl@0
|
352 |
|
sl@0
|
353 |
// Set expected result
|
sl@0
|
354 |
pos = 0;
|
sl@0
|
355 |
|
sl@0
|
356 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
357 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
358 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
359 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
360 |
}
|
sl@0
|
361 |
|
sl@0
|
362 |
void CAddClient::DoReportAction()
|
sl@0
|
363 |
{
|
sl@0
|
364 |
iOut.writeString(_L("Adding client..."));
|
sl@0
|
365 |
iOut.writeNewLine();
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
void CAddClient::DoCheckResult(TInt aError)
|
sl@0
|
369 |
{
|
sl@0
|
370 |
if (iFinished)
|
sl@0
|
371 |
{
|
sl@0
|
372 |
if (aError == KErrNone)
|
sl@0
|
373 |
{
|
sl@0
|
374 |
iConsole.Write(_L("\tClient added successfully\n"));
|
sl@0
|
375 |
iOut.writeString(_L("\tClient added successfully"));
|
sl@0
|
376 |
iOut.writeNewLine();
|
sl@0
|
377 |
iOut.writeNewLine();
|
sl@0
|
378 |
}
|
sl@0
|
379 |
else
|
sl@0
|
380 |
{
|
sl@0
|
381 |
iConsole.Write(_L("\tClient added successfully\n"));
|
sl@0
|
382 |
iOut.writeString(_L("\tClient added successfully"));
|
sl@0
|
383 |
iOut.writeNewLine();
|
sl@0
|
384 |
iOut.writeNewLine();
|
sl@0
|
385 |
}
|
sl@0
|
386 |
}
|
sl@0
|
387 |
}
|
sl@0
|
388 |
|
sl@0
|
389 |
CTestAction* CGetClients::NewL(RFs& aFs,
|
sl@0
|
390 |
CConsoleBase& aConsole,
|
sl@0
|
391 |
Output& aOut,
|
sl@0
|
392 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
393 |
{
|
sl@0
|
394 |
CGetClients* self = new(ELeave) CGetClients(aFs, aConsole, aOut);
|
sl@0
|
395 |
CleanupStack::PushL(self);
|
sl@0
|
396 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
397 |
CleanupStack::Pop();
|
sl@0
|
398 |
return self;
|
sl@0
|
399 |
}
|
sl@0
|
400 |
|
sl@0
|
401 |
CGetClients::~CGetClients()
|
sl@0
|
402 |
{
|
sl@0
|
403 |
// We own iExpectedClients but not iClients
|
sl@0
|
404 |
iExpectedClients.Close();
|
sl@0
|
405 |
}
|
sl@0
|
406 |
|
sl@0
|
407 |
void CGetClients::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
408 |
{
|
sl@0
|
409 |
switch (iState)
|
sl@0
|
410 |
{
|
sl@0
|
411 |
case EGet:
|
sl@0
|
412 |
{
|
sl@0
|
413 |
TRequestStatus* status = &aStatus;
|
sl@0
|
414 |
CCertificateAppInfoManager* appManager = NULL;
|
sl@0
|
415 |
appManager = TheCertificateAppInfoManager();
|
sl@0
|
416 |
if (appManager)
|
sl@0
|
417 |
{
|
sl@0
|
418 |
iClients = &(appManager->Applications());
|
sl@0
|
419 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
420 |
}
|
sl@0
|
421 |
else
|
sl@0
|
422 |
User::RequestComplete(status, KErrNotReady);
|
sl@0
|
423 |
|
sl@0
|
424 |
iState = EFinished;
|
sl@0
|
425 |
}
|
sl@0
|
426 |
break;
|
sl@0
|
427 |
|
sl@0
|
428 |
case EFinished:
|
sl@0
|
429 |
{
|
sl@0
|
430 |
TRequestStatus* status = &aStatus;
|
sl@0
|
431 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
432 |
if (aStatus == iExpectedResult)
|
sl@0
|
433 |
{
|
sl@0
|
434 |
// Check that we have the expected uids
|
sl@0
|
435 |
TInt iEnd = iClients->Count();
|
sl@0
|
436 |
if (iEnd == iExpectedClients.Count())
|
sl@0
|
437 |
{
|
sl@0
|
438 |
TInt i = 0;
|
sl@0
|
439 |
for (i = 0; i < iEnd; i++)
|
sl@0
|
440 |
{
|
sl@0
|
441 |
if ((*iClients)[i].Id() != iExpectedClients[i])
|
sl@0
|
442 |
{
|
sl@0
|
443 |
break;
|
sl@0
|
444 |
}
|
sl@0
|
445 |
}
|
sl@0
|
446 |
if (i == iEnd)
|
sl@0
|
447 |
{
|
sl@0
|
448 |
iResult = ETrue;
|
sl@0
|
449 |
}
|
sl@0
|
450 |
else
|
sl@0
|
451 |
{
|
sl@0
|
452 |
iResult = EFalse;
|
sl@0
|
453 |
}
|
sl@0
|
454 |
}
|
sl@0
|
455 |
else
|
sl@0
|
456 |
{
|
sl@0
|
457 |
iResult = EFalse;
|
sl@0
|
458 |
}
|
sl@0
|
459 |
}
|
sl@0
|
460 |
else
|
sl@0
|
461 |
{
|
sl@0
|
462 |
iResult = EFalse;
|
sl@0
|
463 |
}
|
sl@0
|
464 |
if (aStatus == KErrNoMemory)
|
sl@0
|
465 |
{
|
sl@0
|
466 |
iState = EGet;
|
sl@0
|
467 |
}
|
sl@0
|
468 |
else
|
sl@0
|
469 |
{
|
sl@0
|
470 |
iFinished = ETrue;
|
sl@0
|
471 |
}
|
sl@0
|
472 |
}
|
sl@0
|
473 |
break;
|
sl@0
|
474 |
}
|
sl@0
|
475 |
}
|
sl@0
|
476 |
|
sl@0
|
477 |
void CGetClients::PerformCancel()
|
sl@0
|
478 |
{
|
sl@0
|
479 |
}
|
sl@0
|
480 |
|
sl@0
|
481 |
void CGetClients::Reset()
|
sl@0
|
482 |
{
|
sl@0
|
483 |
__ASSERT_DEBUG(EFalse, User::Panic(_L("CGetClients::Reset()"), 1));
|
sl@0
|
484 |
}
|
sl@0
|
485 |
|
sl@0
|
486 |
CGetClients::CGetClients(RFs& aFs, CConsoleBase& aConsole,
|
sl@0
|
487 |
Output& aOut)
|
sl@0
|
488 |
: CCertStoreTestAction(aFs, aConsole, aOut),
|
sl@0
|
489 |
iState(EGet)
|
sl@0
|
490 |
{
|
sl@0
|
491 |
}
|
sl@0
|
492 |
|
sl@0
|
493 |
void CGetClients::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
494 |
{
|
sl@0
|
495 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
496 |
TInt err = KErrNone;
|
sl@0
|
497 |
TInt pos = 0;
|
sl@0
|
498 |
|
sl@0
|
499 |
// Set expected result
|
sl@0
|
500 |
pos = 0;
|
sl@0
|
501 |
|
sl@0
|
502 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
503 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
504 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
505 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
506 |
|
sl@0
|
507 |
const TDesC8& uidsString = Input::ParseElement(aTestActionSpec.iActionResult, KUIDStart, KUIDEnd,
|
sl@0
|
508 |
pos, err);
|
sl@0
|
509 |
TLex8 lex(uidsString);
|
sl@0
|
510 |
|
sl@0
|
511 |
err = KErrNone;
|
sl@0
|
512 |
while (err == KErrNone)
|
sl@0
|
513 |
{
|
sl@0
|
514 |
TUid uid;
|
sl@0
|
515 |
err = lex.Val(uid.iUid);
|
sl@0
|
516 |
if (err == KErrNone)
|
sl@0
|
517 |
{
|
sl@0
|
518 |
lex.SkipSpace();
|
sl@0
|
519 |
User::LeaveIfError(iExpectedClients.Append(uid));
|
sl@0
|
520 |
}
|
sl@0
|
521 |
}
|
sl@0
|
522 |
}
|
sl@0
|
523 |
|
sl@0
|
524 |
void CGetClients::DoReportAction()
|
sl@0
|
525 |
{
|
sl@0
|
526 |
iOut.writeString(_L("Getting client..."));
|
sl@0
|
527 |
iOut.writeNewLine();
|
sl@0
|
528 |
iOut.writeString(_L("\tExpected clients :"));
|
sl@0
|
529 |
TInt iEnd = iExpectedClients.Count();
|
sl@0
|
530 |
for (TInt i = 0; i < iEnd; i++)
|
sl@0
|
531 |
{
|
sl@0
|
532 |
iOut.writeString(_L(" "));
|
sl@0
|
533 |
iOut.writeNum(iExpectedClients[i].iUid);
|
sl@0
|
534 |
}
|
sl@0
|
535 |
iOut.writeNewLine();
|
sl@0
|
536 |
iOut.writeNewLine();
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
void CGetClients::DoCheckResult(TInt aError)
|
sl@0
|
540 |
{
|
sl@0
|
541 |
if (iFinished)
|
sl@0
|
542 |
{
|
sl@0
|
543 |
iConsole.Printf(_L("\tClients:\n"));
|
sl@0
|
544 |
iOut.writeString(_L("\tClients: "));
|
sl@0
|
545 |
iOut.writeNewLine();
|
sl@0
|
546 |
iOut.writeString(_L("\t\t"));
|
sl@0
|
547 |
TInt count = iClients->Count();
|
sl@0
|
548 |
for (TInt i = 0; i < count; i++)
|
sl@0
|
549 |
{
|
sl@0
|
550 |
iConsole.Printf(_L("%D "), (*iClients)[i].Id());
|
sl@0
|
551 |
iOut.writeNum((*iClients)[i].Id().iUid);
|
sl@0
|
552 |
iOut.writeString(_L(" "));
|
sl@0
|
553 |
}
|
sl@0
|
554 |
iOut.writeNewLine();
|
sl@0
|
555 |
if (aError == KErrNone)
|
sl@0
|
556 |
{
|
sl@0
|
557 |
iConsole.Printf(_L("\tClients retrieved successfully\n"));
|
sl@0
|
558 |
iOut.writeString(_L("\tClients retrieved successfully"));
|
sl@0
|
559 |
iOut.writeNewLine();
|
sl@0
|
560 |
}
|
sl@0
|
561 |
else
|
sl@0
|
562 |
{
|
sl@0
|
563 |
iConsole.Printf(_L("\tClients retrieved failed\n"));
|
sl@0
|
564 |
iOut.writeString(_L("\tClients retrieved failed"));
|
sl@0
|
565 |
iOut.writeNewLine();
|
sl@0
|
566 |
}
|
sl@0
|
567 |
iOut.writeNewLine();
|
sl@0
|
568 |
}
|
sl@0
|
569 |
}
|
sl@0
|
570 |
|
sl@0
|
571 |
CTestAction* CRemoveClient::NewL(RFs& aFs,
|
sl@0
|
572 |
CConsoleBase& aConsole,
|
sl@0
|
573 |
Output& aOut,
|
sl@0
|
574 |
const TTestActionSpec& aTestActionSpec)
|
sl@0
|
575 |
{
|
sl@0
|
576 |
CRemoveClient* self = new(ELeave) CRemoveClient(aFs, aConsole, aOut);
|
sl@0
|
577 |
CleanupStack::PushL(self);
|
sl@0
|
578 |
self->ConstructL(aTestActionSpec);
|
sl@0
|
579 |
CleanupStack::Pop(self);
|
sl@0
|
580 |
return self;
|
sl@0
|
581 |
}
|
sl@0
|
582 |
|
sl@0
|
583 |
CRemoveClient::~CRemoveClient()
|
sl@0
|
584 |
{
|
sl@0
|
585 |
}
|
sl@0
|
586 |
|
sl@0
|
587 |
void CRemoveClient::PerformAction(TRequestStatus& aStatus)
|
sl@0
|
588 |
{
|
sl@0
|
589 |
switch (iState)
|
sl@0
|
590 |
{
|
sl@0
|
591 |
case ERemove:
|
sl@0
|
592 |
{
|
sl@0
|
593 |
TInt err = KErrNotReady;
|
sl@0
|
594 |
CCertificateAppInfoManager* appManager = NULL;
|
sl@0
|
595 |
appManager = TheCertificateAppInfoManager();
|
sl@0
|
596 |
if (appManager)
|
sl@0
|
597 |
{
|
sl@0
|
598 |
TRAP(err, appManager->RemoveL(iUid));
|
sl@0
|
599 |
}
|
sl@0
|
600 |
TRequestStatus* status = &aStatus;
|
sl@0
|
601 |
User::RequestComplete(status, err);
|
sl@0
|
602 |
iState = EFinished;
|
sl@0
|
603 |
}
|
sl@0
|
604 |
break;
|
sl@0
|
605 |
|
sl@0
|
606 |
case EFinished:
|
sl@0
|
607 |
{
|
sl@0
|
608 |
TRequestStatus* status = &aStatus;
|
sl@0
|
609 |
User::RequestComplete(status, aStatus.Int());
|
sl@0
|
610 |
if (aStatus == iExpectedResult)
|
sl@0
|
611 |
{
|
sl@0
|
612 |
iResult = ETrue;
|
sl@0
|
613 |
}
|
sl@0
|
614 |
else
|
sl@0
|
615 |
{
|
sl@0
|
616 |
iResult = EFalse;
|
sl@0
|
617 |
}
|
sl@0
|
618 |
if (aStatus == KErrNoMemory)
|
sl@0
|
619 |
{
|
sl@0
|
620 |
iState = ERemove;
|
sl@0
|
621 |
}
|
sl@0
|
622 |
else
|
sl@0
|
623 |
{
|
sl@0
|
624 |
iFinished = ETrue;
|
sl@0
|
625 |
}
|
sl@0
|
626 |
}
|
sl@0
|
627 |
break;
|
sl@0
|
628 |
}
|
sl@0
|
629 |
}
|
sl@0
|
630 |
|
sl@0
|
631 |
void CRemoveClient::PerformCancel()
|
sl@0
|
632 |
{
|
sl@0
|
633 |
}
|
sl@0
|
634 |
|
sl@0
|
635 |
void CRemoveClient::Reset()
|
sl@0
|
636 |
{
|
sl@0
|
637 |
__ASSERT_DEBUG(EFalse, User::Panic(_L("CRemoveClient::Reset()"), 1));
|
sl@0
|
638 |
}
|
sl@0
|
639 |
|
sl@0
|
640 |
CRemoveClient::CRemoveClient(RFs& aFs, CConsoleBase& aConsole,
|
sl@0
|
641 |
Output& aOut)
|
sl@0
|
642 |
: CCertStoreTestAction(aFs, aConsole, aOut), iState(ERemove)
|
sl@0
|
643 |
{
|
sl@0
|
644 |
}
|
sl@0
|
645 |
|
sl@0
|
646 |
void CRemoveClient::ConstructL(const TTestActionSpec& aTestActionSpec)
|
sl@0
|
647 |
{
|
sl@0
|
648 |
CCertStoreTestAction::ConstructL(aTestActionSpec);
|
sl@0
|
649 |
TInt err = KErrNone;
|
sl@0
|
650 |
TInt pos = 0;
|
sl@0
|
651 |
const TDesC8& uid = Input::ParseElement(aTestActionSpec.iActionBody, KUIDStart, KUIDEnd,
|
sl@0
|
652 |
pos, err);
|
sl@0
|
653 |
TLex8 lex(uid);
|
sl@0
|
654 |
lex.Val(iUid.iUid);
|
sl@0
|
655 |
|
sl@0
|
656 |
// Set expected result
|
sl@0
|
657 |
pos = 0;
|
sl@0
|
658 |
|
sl@0
|
659 |
HBufC* result = HBufC::NewLC(aTestActionSpec.iActionResult.Length());
|
sl@0
|
660 |
TPtr(result->Des()).Copy(aTestActionSpec.iActionResult);
|
sl@0
|
661 |
Input::GetExpectedResultL(Input::ParseElement(*result, KReturnStart, KReturnEnd), iExpectedResult);
|
sl@0
|
662 |
CleanupStack::PopAndDestroy(result);
|
sl@0
|
663 |
}
|
sl@0
|
664 |
|
sl@0
|
665 |
void CRemoveClient::DoReportAction()
|
sl@0
|
666 |
{
|
sl@0
|
667 |
iOut.writeString(_L("Removing client..."));
|
sl@0
|
668 |
iOut.writeNewLine();
|
sl@0
|
669 |
}
|
sl@0
|
670 |
|
sl@0
|
671 |
void CRemoveClient::DoCheckResult(TInt aError)
|
sl@0
|
672 |
{
|
sl@0
|
673 |
if (iFinished)
|
sl@0
|
674 |
{
|
sl@0
|
675 |
if (aError == KErrNone)
|
sl@0
|
676 |
{
|
sl@0
|
677 |
iConsole.Write(_L("\tClient removed successfully\n"));
|
sl@0
|
678 |
iOut.writeString(_L("\tClient removed successfully"));
|
sl@0
|
679 |
iOut.writeNewLine();
|
sl@0
|
680 |
iOut.writeNewLine();
|
sl@0
|
681 |
}
|
sl@0
|
682 |
else if (aError == KErrNotFound)
|
sl@0
|
683 |
{
|
sl@0
|
684 |
iConsole.Write(_L("\tClient not found\n"));
|
sl@0
|
685 |
iOut.writeString(_L("\tClient not found"));
|
sl@0
|
686 |
iOut.writeNewLine();
|
sl@0
|
687 |
iOut.writeNewLine();
|
sl@0
|
688 |
}
|
sl@0
|
689 |
}
|
sl@0
|
690 |
}
|