|
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 // for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started |
|
15 // in the process of the client. The client initialises the server by calling the |
|
16 // one and only ordinal. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file TlsProvServer.cpp |
|
22 */ |
|
23 #include "TlsProvServer.h" |
|
24 #include "TlsProvTestStep.h" |
|
25 #include "TSecureConnection.h" |
|
26 #include "tlstest2servercertstep.h" |
|
27 |
|
28 _LIT(KServerName,"TlsProvServer"); |
|
29 |
|
30 CTlsProvServer* CTlsProvServer::NewL() |
|
31 /** |
|
32 * @return - Instance of the test server |
|
33 * Called inside the MainL() function to create and start the |
|
34 * CTestServer derived server. |
|
35 */ |
|
36 { |
|
37 |
|
38 CTlsProvServer * server = new (ELeave) CTlsProvServer(); |
|
39 CleanupStack::PushL(server); |
|
40 // CServer base class call |
|
41 server->StartL(KServerName); |
|
42 CleanupStack::Pop(server); |
|
43 return server; |
|
44 } |
|
45 |
|
46 // EKA2 much simpler |
|
47 // Just an E32Main and a MainL() |
|
48 LOCAL_C void MainL() |
|
49 /** |
|
50 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
51 */ |
|
52 { |
|
53 // Leave the hooks in for platform security |
|
54 #if (defined __DATA_CAGING__) |
|
55 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
56 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
57 #endif |
|
58 CActiveScheduler* sched=NULL; |
|
59 sched=new(ELeave) CActiveScheduler; |
|
60 CActiveScheduler::Install(sched); |
|
61 |
|
62 CTlsProvServer* server = NULL; |
|
63 // Create the CTestServer derived server |
|
64 TRAPD(err,server = CTlsProvServer::NewL()); |
|
65 if(!err) |
|
66 { |
|
67 // Sync with the client and enter the active scheduler |
|
68 RProcess::Rendezvous(KErrNone); |
|
69 sched->Start(); |
|
70 } |
|
71 delete server; |
|
72 delete sched; |
|
73 } |
|
74 |
|
75 // Only a DLL on emulator for typhoon and earlier |
|
76 |
|
77 GLDEF_C TInt E32Main() |
|
78 /** |
|
79 * @return - Standard Epoc error code on exit |
|
80 */ |
|
81 { |
|
82 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
83 if(cleanup == NULL) |
|
84 { |
|
85 return KErrNoMemory; |
|
86 } |
|
87 TRAP_IGNORE(MainL()); |
|
88 delete cleanup; |
|
89 return KErrNone; |
|
90 } |
|
91 |
|
92 // Create a thread in the calling process |
|
93 // Emulator typhoon and earlier |
|
94 |
|
95 |
|
96 CTestStep* CTlsProvServer::CreateTestStep(const TDesC& aStepName) |
|
97 /** |
|
98 * @return - A CTestStep derived instance |
|
99 * Implementation of CTestServer pure virtual |
|
100 */ |
|
101 { |
|
102 CTestStep* testStep = NULL; |
|
103 // This server creates just one step but create as many as you want |
|
104 // They are created "just in time" when the worker thread is created |
|
105 if(aStepName == KTlsSecureConnectionTestStep) |
|
106 { |
|
107 testStep = new CTSecureConnectionStep(aStepName); |
|
108 } |
|
109 else if (aStepName == KServerCertStep) |
|
110 { |
|
111 testStep = new CServerCertStep; |
|
112 } |
|
113 else |
|
114 { |
|
115 testStep = new CTlsProvStep( aStepName ); |
|
116 } |
|
117 |
|
118 return testStep; |
|
119 } |
|
120 |