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 IPSuiteServer.cpp
|
|
28 |
*/
|
|
29 |
|
|
30 |
// __EDIT_ME__ Include your own server header file and step header file(s) here
|
|
31 |
#include "IPSuiteServer.h"
|
|
32 |
#include "TCPStep.h"
|
|
33 |
#include "UDPStep.h"
|
|
34 |
|
|
35 |
// __EDIT_ME__ - Substitute the name of your test server
|
|
36 |
_LIT(KServerName,"DemoIPSuite");
|
|
37 |
// __EDIT_ME__ - Use your own server class name
|
|
38 |
CDemoIPSuite* CDemoIPSuite::NewL()
|
|
39 |
/**
|
|
40 |
* @return - Instance of the test server
|
|
41 |
* Same code for Secure and non-secure variants
|
|
42 |
* Called inside the MainL() function to create and start the
|
|
43 |
* CTestServer derived server.
|
|
44 |
*/
|
|
45 |
{
|
|
46 |
// __EDIT_ME__ - Use your own server class name
|
|
47 |
CDemoIPSuite * server = new (ELeave) CDemoIPSuite();
|
|
48 |
CleanupStack::PushL(server);
|
|
49 |
// CServer base class call
|
|
50 |
server->StartL(KServerName);
|
|
51 |
CleanupStack::Pop(server);
|
|
52 |
return server;
|
|
53 |
}
|
|
54 |
|
|
55 |
|
|
56 |
// Secure variants much simpler
|
|
57 |
// Just an E32Main and a MainL()
|
|
58 |
LOCAL_C void MainL()
|
|
59 |
/**
|
|
60 |
* Secure variant
|
|
61 |
* Much simpler, uses the new Rendezvous() call to sync with the client
|
|
62 |
*/
|
|
63 |
{
|
|
64 |
#if (defined __DATA_CAGING__)
|
|
65 |
RProcess().DataCaging(RProcess::EDataCagingOn);
|
|
66 |
RProcess().DataCaging(RProcess::ESecureApiOn);
|
|
67 |
#endif
|
|
68 |
CActiveScheduler* sched=NULL;
|
|
69 |
sched=new(ELeave) CActiveScheduler;
|
|
70 |
CActiveScheduler::Install(sched);
|
|
71 |
// __EDIT_ME__ - Use your own server class name
|
|
72 |
CDemoIPSuite* server = NULL;
|
|
73 |
// Create the CTestServer derived server
|
|
74 |
TRAPD(err,server = CDemoIPSuite::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 |
|
|
86 |
|
|
87 |
GLDEF_C TInt E32Main()
|
|
88 |
/**
|
|
89 |
* @return - Standard Epoc error code on process exit
|
|
90 |
* Secure variant only
|
|
91 |
* Process entry point. Called by client using RProcess API
|
|
92 |
*/
|
|
93 |
{
|
|
94 |
__UHEAP_MARK;
|
|
95 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
96 |
if(cleanup == NULL)
|
|
97 |
{
|
|
98 |
return KErrNoMemory;
|
|
99 |
}
|
|
100 |
TRAP_IGNORE(MainL());
|
|
101 |
delete cleanup;
|
|
102 |
__UHEAP_MARKEND;
|
|
103 |
return KErrNone;
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
// __EDIT_ME__ - Use your own server class name
|
|
108 |
CTestStep* CDemoIPSuite::CreateTestStep(const TDesC& aStepName)
|
|
109 |
/**
|
|
110 |
* @return - A CTestStep derived instance
|
|
111 |
* Secure and non-secure variants
|
|
112 |
* Implementation of CTestServer pure virtual
|
|
113 |
*/
|
|
114 |
{
|
|
115 |
CTestStep* testStep = NULL;
|
|
116 |
// __EDIT_ME__ - Create your own test steps here
|
|
117 |
// This server creates just two steps but create as many as you want
|
|
118 |
// They are created "just in time" when the worker thread is created
|
|
119 |
#if !(defined TEF_LITE)
|
|
120 |
if(aStepName == KDemoTCPStep)
|
|
121 |
testStep = new CTCPStep();
|
|
122 |
else if(aStepName == KDemoUDPStep)
|
|
123 |
testStep = new CUDPStep();
|
|
124 |
#endif
|
|
125 |
return testStep;
|
|
126 |
}
|