0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* Example file/test code to demonstrate how to develop a TestExecute Server
|
|
16 |
* Developers should take this project as a template and substitute their own
|
|
17 |
* code at the __EDIT_ME__ tags
|
|
18 |
* for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
|
|
19 |
* in the process of the client. The client initialises the server by calling the
|
|
20 |
* one and only ordinal.
|
|
21 |
*
|
|
22 |
*/
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
/**
|
|
27 |
@file SampleServer.cpp
|
|
28 |
*/
|
|
29 |
#include "SampleServer.h"
|
|
30 |
#include "SampleStep.h"
|
|
31 |
|
|
32 |
// __EDIT_ME__ - Substitute the name of your test server
|
|
33 |
_LIT(KServerName,"SampleServer");
|
|
34 |
// __EDIT_ME__ - Use your own server class name
|
|
35 |
CSampleServer* CSampleServer::NewL()
|
|
36 |
/**
|
|
37 |
* @return - Instance of the test server
|
|
38 |
* Called inside the MainL() function to create and start the
|
|
39 |
* CTestServer derived server.
|
|
40 |
*/
|
|
41 |
{
|
|
42 |
// __EDIT_ME__ new your server class here
|
|
43 |
CSampleServer * server = new (ELeave) CSampleServer();
|
|
44 |
CleanupStack::PushL(server);
|
|
45 |
|
|
46 |
// Either use a StartL or ConstructL, the latter will permit
|
|
47 |
// Server Logging.
|
|
48 |
|
|
49 |
//server->StartL(KServerName);
|
|
50 |
server-> ConstructL(KServerName);
|
|
51 |
CleanupStack::Pop(server);
|
|
52 |
return server;
|
|
53 |
}
|
|
54 |
|
|
55 |
// EKA2 much simpler
|
|
56 |
// Just an E32Main and a MainL()
|
|
57 |
LOCAL_C void MainL()
|
|
58 |
/**
|
|
59 |
* Much simpler, uses the new Rendezvous() call to sync with the client
|
|
60 |
*/
|
|
61 |
{
|
|
62 |
// Leave the hooks in for platform security
|
|
63 |
#if (defined __DATA_CAGING__)
|
|
64 |
RProcess().DataCaging(RProcess::EDataCagingOn);
|
|
65 |
RProcess().SecureApi(RProcess::ESecureApiOn);
|
|
66 |
#endif
|
|
67 |
CActiveScheduler* sched=NULL;
|
|
68 |
sched=new(ELeave) CActiveScheduler;
|
|
69 |
CActiveScheduler::Install(sched);
|
|
70 |
// __EDIT_ME__ Your server name
|
|
71 |
CSampleServer* server = NULL;
|
|
72 |
// Create the CTestServer derived server
|
|
73 |
// __EDIT_ME__ Your server name
|
|
74 |
TRAPD(err,server = CSampleServer::NewL());
|
|
75 |
if(!err)
|
|
76 |
{
|
|
77 |
// Sync with the client and enter the active scheduler
|
|
78 |
RProcess::Rendezvous(KErrNone);
|
|
79 |
sched->Start();
|
|
80 |
}
|
|
81 |
delete server;
|
|
82 |
delete sched;
|
|
83 |
}
|
|
84 |
|
|
85 |
// Only a DLL on emulator
|
|
86 |
|
|
87 |
GLDEF_C TInt E32Main()
|
|
88 |
/**
|
|
89 |
* @return - Standard Epoc error code on exit
|
|
90 |
*/
|
|
91 |
{
|
|
92 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
93 |
if(cleanup == NULL)
|
|
94 |
{
|
|
95 |
return KErrNoMemory;
|
|
96 |
}
|
|
97 |
TRAP_IGNORE(MainL());
|
|
98 |
delete cleanup;
|
|
99 |
return KErrNone;
|
|
100 |
}
|
|
101 |
|
|
102 |
// Create a thread in the calling process
|
|
103 |
|
|
104 |
// __EDIT_ME__ - Use your own server class name
|
|
105 |
CTestStep* CSampleServer::CreateTestStep(const TDesC& aStepName)
|
|
106 |
/**
|
|
107 |
* @return - A CTestStep derived instance
|
|
108 |
* Implementation of CTestServer pure virtual
|
|
109 |
*/
|
|
110 |
{
|
|
111 |
CTestStep* testStep = NULL;
|
|
112 |
// __EDIT_ME__ - Create your own test steps here
|
|
113 |
// This server creates just one step but create as many as you want
|
|
114 |
// They are created "just in time" when the worker thread is created
|
|
115 |
|
|
116 |
|
|
117 |
if(aStepName == KSampleStep1)
|
|
118 |
testStep = new CSampleStep1();
|
|
119 |
else if(aStepName == KSampleStep2)
|
|
120 |
testStep = new CSampleStep2(*this);
|
|
121 |
else if(aStepName == KSampleStep3)
|
|
122 |
testStep = new CSampleStep3(*this);
|
|
123 |
else if(aStepName == KSampleStep4)
|
|
124 |
testStep = new CSampleStep4();
|
|
125 |
else if(aStepName == KSampleStep5)
|
|
126 |
testStep = new CSampleStep5();
|
|
127 |
else if(aStepName == KSampleStep6)
|
|
128 |
testStep = new CSampleStep6();
|
|
129 |
else if(aStepName == KSampleStep7)
|
|
130 |
testStep = new CSampleStep7();
|
|
131 |
else if(aStepName == KSampleStep8)
|
|
132 |
testStep = new CSampleStep8();
|
|
133 |
else if(aStepName == KSampleStep9)
|
|
134 |
testStep = new CSampleStep9();
|
|
135 |
else if(aStepName == KSampleStep10)
|
|
136 |
testStep = new CSampleStep10();
|
|
137 |
else if(aStepName == KSampleStep11)
|
|
138 |
testStep = new CSampleStep11();
|
|
139 |
else if(aStepName == KSampleStep12)
|
|
140 |
testStep = new CSampleStep12();
|
|
141 |
else if(aStepName == KSampleStep13)
|
|
142 |
testStep = new CSampleStep13();
|
|
143 |
return testStep;
|
|
144 |
}
|
|
145 |
|