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 |
#include "tpkcs12libtestserver.h"
|
sl@0
|
21 |
#include "tpkcs12libteststep.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
_LIT(KServerName, "tpkcs12libtest");
|
sl@0
|
25 |
CPKCS12LibTestServer* CPKCS12LibTestServer::NewL()
|
sl@0
|
26 |
/**
|
sl@0
|
27 |
* @return - Instance of the test server
|
sl@0
|
28 |
* Called inside the Mail() function to create and start the
|
sl@0
|
29 |
* CTestServer derived server
|
sl@0
|
30 |
*
|
sl@0
|
31 |
*/
|
sl@0
|
32 |
{
|
sl@0
|
33 |
CPKCS12LibTestServer* server = new (ELeave) CPKCS12LibTestServer();
|
sl@0
|
34 |
CleanupStack::PushL(server);
|
sl@0
|
35 |
server->ConstructL(KServerName);
|
sl@0
|
36 |
CleanupStack::Pop(server);
|
sl@0
|
37 |
return server;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
CTestStep* CPKCS12LibTestServer::CreateTestStep(const TDesC& aStepName)
|
sl@0
|
42 |
/**
|
sl@0
|
43 |
* @return - A CTestStep derived instance
|
sl@0
|
44 |
* Implementation of CTestServer pure virtual
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
{
|
sl@0
|
47 |
CTestStep* testStep = NULL;
|
sl@0
|
48 |
|
sl@0
|
49 |
if(aStepName == KStep)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
testStep = new CPKCS12LibTestStep();
|
sl@0
|
52 |
}
|
sl@0
|
53 |
if(aStepName == KTPKCS12OOMStep)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
testStep = new CTPKCS12OOMStep();
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
return testStep;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
// Just an E32Main and a MainL()
|
sl@0
|
62 |
LOCAL_C void MainL()
|
sl@0
|
63 |
/**
|
sl@0
|
64 |
* Much simpler, uses the new Rendezvous() call to sync with the client
|
sl@0
|
65 |
*/
|
sl@0
|
66 |
{
|
sl@0
|
67 |
// Leave the hooks in for platform security
|
sl@0
|
68 |
#if (defined __DATA_CAGING__)
|
sl@0
|
69 |
RProcess().DataCaging(RProcess::EDataCagingOn);
|
sl@0
|
70 |
RProcess().SecureApi(RProcess::ESecureApiOn);
|
sl@0
|
71 |
#endif
|
sl@0
|
72 |
CActiveScheduler* sched=NULL;
|
sl@0
|
73 |
sched=new(ELeave) CActiveScheduler;
|
sl@0
|
74 |
CActiveScheduler::Install(sched);
|
sl@0
|
75 |
// __EDIT_ME__ Your server name
|
sl@0
|
76 |
CPKCS12LibTestServer* server = NULL;
|
sl@0
|
77 |
// Create the CTestServer derived server
|
sl@0
|
78 |
// __EDIT_ME__ Your server name
|
sl@0
|
79 |
TRAPD(err,server = CPKCS12LibTestServer::NewL());
|
sl@0
|
80 |
if(!err)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
// Sync with the client and enter the active scheduler
|
sl@0
|
83 |
RProcess::Rendezvous(KErrNone);
|
sl@0
|
84 |
sched->Start();
|
sl@0
|
85 |
}
|
sl@0
|
86 |
delete server;
|
sl@0
|
87 |
delete sched;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
|
sl@0
|
91 |
GLDEF_C TInt E32Main()
|
sl@0
|
92 |
/**
|
sl@0
|
93 |
* @return - Standard Epoc error code on exit
|
sl@0
|
94 |
*/
|
sl@0
|
95 |
{
|
sl@0
|
96 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
97 |
if(cleanup == NULL)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
return KErrNoMemory;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
TRAPD(err,MainL());
|
sl@0
|
102 |
// This if statement is here just to shut up RVCT, which would otherwise warn
|
sl@0
|
103 |
// that err was set but never used
|
sl@0
|
104 |
if(err)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
err = KErrNone;
|
sl@0
|
107 |
}
|
sl@0
|
108 |
delete cleanup;
|
sl@0
|
109 |
return KErrNone;
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
// Create a thread in the calling process
|
sl@0
|
113 |
// Emulator typhoon and earlier
|
sl@0
|
114 |
#if (defined __WINS__ && !defined EKA2)
|
sl@0
|
115 |
TInt ThreadFunc (TAny* /*aParam*/)
|
sl@0
|
116 |
/**
|
sl@0
|
117 |
* @return - Server exit code
|
sl@0
|
118 |
* @param - unused
|
sl@0
|
119 |
* Server Thread function. Guts of the code in the MainL() function
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
{
|
sl@0
|
122 |
return E32Main();
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
EXPORT_C TInt WinsMain()
|
sl@0
|
126 |
/**
|
sl@0
|
127 |
* @return - Standard Epoc error codes
|
sl@0
|
128 |
* 1st and only ordinal, called by the client API to initialise the server
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
{
|
sl@0
|
131 |
_LIT(KThread,"Thread");
|
sl@0
|
132 |
RThread thread;
|
sl@0
|
133 |
// __EDIT_ME__ - Make sure the TBuf is large enough
|
sl@0
|
134 |
TBuf<KMaxTestExecuteNameLength> threadName(KServerName);
|
sl@0
|
135 |
// Create a hopefully unique thread name and use the ThreadFunc
|
sl@0
|
136 |
threadName.Append(KThread);
|
sl@0
|
137 |
const TInt KMaxHeapSize = 0x1000000; ///< Allow a 1Mb max heap
|
sl@0
|
138 |
TInt err = thread.Create(threadName, ThreadFunc, KDefaultStackSize,
|
sl@0
|
139 |
KMinHeapSize, KMaxHeapSize,
|
sl@0
|
140 |
NULL, EOwnerProcess);
|
sl@0
|
141 |
if(err)
|
sl@0
|
142 |
return err;
|
sl@0
|
143 |
thread.Resume();
|
sl@0
|
144 |
thread.Close();
|
sl@0
|
145 |
return KErrNone;
|
sl@0
|
146 |
}
|
sl@0
|
147 |
|
sl@0
|
148 |
GLDEF_C TInt E32Dll(enum TDllReason)
|
sl@0
|
149 |
{
|
sl@0
|
150 |
return 0;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
#endif
|