0
|
1 |
// Copyright (c) 2005-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 |
// Example file/test code to demonstrate how to develop a TestExecute Server
|
|
15 |
// Developers should take this project as a template and substitute their own
|
|
16 |
// for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
|
|
17 |
// in the process of the client. The client initialises the server by calling the
|
|
18 |
// one and only ordinal.
|
|
19 |
//
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
/**
|
|
24 |
@file Te_coredumpserverSuiteServer.cpp
|
|
25 |
@internalTechnology
|
|
26 |
*/
|
|
27 |
|
|
28 |
#include "tcoredumpserversuiteserver.h"
|
|
29 |
#include "DEXCusersidestep.h"
|
|
30 |
#include "liststep.h"
|
|
31 |
#include "parameterstep.h"
|
|
32 |
#include "SELFUsersidestep.h"
|
|
33 |
#include "SELFpluginstep.h"
|
|
34 |
#include "DEXCpluginstep.h"
|
|
35 |
#include "testformatterusersidestep.h"
|
|
36 |
#include "CDSconnectionstep.h"
|
|
37 |
#include "CDStokenstep.h"
|
|
38 |
#include "utracestep.h"
|
|
39 |
#include "SELFusersidetrace.h"
|
|
40 |
#include "testsignaling.h"
|
|
41 |
|
|
42 |
_LIT(KServerName,"Te_coredumpserverSuite");
|
|
43 |
CTe_coredumpserverSuite* CTe_coredumpserverSuite::NewL()
|
|
44 |
/**
|
|
45 |
* @return - Instance of the test server
|
|
46 |
* Same code for Secure and non-secure variants
|
|
47 |
* Called inside the MainL() function to create and start the
|
|
48 |
* CTestServer derived server.
|
|
49 |
*/
|
|
50 |
{
|
|
51 |
CTe_coredumpserverSuite * server = new (ELeave) CTe_coredumpserverSuite();
|
|
52 |
CleanupStack::PushL(server);
|
|
53 |
|
|
54 |
server->ConstructL(KServerName);
|
|
55 |
CleanupStack::Pop(server);
|
|
56 |
return server;
|
|
57 |
}
|
|
58 |
|
|
59 |
|
|
60 |
// Secure variants much simpler
|
|
61 |
// For EKA2, just an E32Main and a MainL()
|
|
62 |
LOCAL_C void MainL()
|
|
63 |
/**
|
|
64 |
* Secure variant
|
|
65 |
* Much simpler, uses the new Rendezvous() call to sync with the client
|
|
66 |
*/
|
|
67 |
{
|
|
68 |
// Leave the hooks in for platform security
|
|
69 |
#if (defined __DATA_CAGING__)
|
|
70 |
RProcess().DataCaging(RProcess::EDataCagingOn);
|
|
71 |
RProcess().DataCaging(RProcess::ESecureApiOn);
|
|
72 |
#endif
|
|
73 |
CActiveScheduler* sched=NULL;
|
|
74 |
sched=new(ELeave) CActiveScheduler;
|
|
75 |
CActiveScheduler::Install(sched);
|
|
76 |
CTe_coredumpserverSuite* server = NULL;
|
|
77 |
// Create the CTestServer derived server
|
|
78 |
TRAPD(err,server = CTe_coredumpserverSuite::NewL());
|
|
79 |
if(!err)
|
|
80 |
{
|
|
81 |
// Sync with the client and enter the active scheduler
|
|
82 |
RProcess::Rendezvous(KErrNone);
|
|
83 |
sched->Start();
|
|
84 |
}
|
|
85 |
delete server;
|
|
86 |
delete sched;
|
|
87 |
}
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
GLDEF_C TInt E32Main()
|
|
92 |
/**
|
|
93 |
* @return - Standard Epoc error code on process exit
|
|
94 |
* Secure variant only
|
|
95 |
* Process entry point. Called by client using RProcess API
|
|
96 |
*/
|
|
97 |
{
|
|
98 |
__UHEAP_MARK;
|
|
99 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
100 |
if(cleanup == NULL)
|
|
101 |
{
|
|
102 |
return KErrNoMemory;
|
|
103 |
}
|
|
104 |
TRAPD(err,MainL());
|
|
105 |
delete cleanup;
|
|
106 |
__UHEAP_MARKEND;
|
|
107 |
return err;
|
|
108 |
}
|
|
109 |
|
|
110 |
|
|
111 |
CTestStep* CTe_coredumpserverSuite::CreateTestStep(const TDesC& aStepName)
|
|
112 |
/**
|
|
113 |
* @return - A CTestStep derived instance
|
|
114 |
* Secure and non-secure variants
|
|
115 |
* Implementation of CTestServer pure virtual
|
|
116 |
*/
|
|
117 |
{
|
|
118 |
INFO_PRINTF1(aStepName);
|
|
119 |
|
|
120 |
CTestStep* testStep = NULL;
|
|
121 |
if(aStepName == KDEXECUserSideStep)
|
|
122 |
testStep = new CDEXECUserSideStep();
|
|
123 |
else if(aStepName == KListsStep)
|
|
124 |
testStep = new CListsStep();
|
|
125 |
else if(aStepName == KParametersStep)
|
|
126 |
testStep = new CParametersStep();
|
|
127 |
else if(aStepName == KSELFUserSideStep)
|
|
128 |
testStep = new CSELFUserSideStep();
|
|
129 |
else if(aStepName == KSELFPluginStep)
|
|
130 |
testStep = new CSELFPluginStep();
|
|
131 |
else if(aStepName == KDEXECPluginStep)
|
|
132 |
testStep = new CDEXECPluginStep();
|
|
133 |
else if(aStepName == KTestFormatterUserSideStep)
|
|
134 |
testStep = new CTestFormatterUserSideStep();
|
|
135 |
else if(aStepName == KCDSConnectionsStep)
|
|
136 |
testStep = new CCDSConnectionsStep();
|
|
137 |
else if(aStepName == KTokenStep)
|
|
138 |
testStep = new CTokenStep();
|
|
139 |
else if(aStepName == KUTraceUserSide)
|
|
140 |
testStep = new CUTraceStep();
|
|
141 |
else if(aStepName == KSELFUserSideTrace)
|
|
142 |
testStep = new CSELFUserSideTrace();
|
|
143 |
else if(aStepName == KTestSignaling)
|
|
144 |
testStep = new CTestSignaling();
|
|
145 |
|
|
146 |
return testStep;
|
|
147 |
}
|
|
148 |
|
|
149 |
void CTe_coredumpserverSuite::CleanupProcessList(TAny *aArray)
|
|
150 |
/**
|
|
151 |
* Cleanup operation for RProcessPointerList
|
|
152 |
*/
|
|
153 |
{
|
|
154 |
RProcessPointerList *processList = static_cast<RProcessPointerList*> (aArray);
|
|
155 |
processList->ResetAndDestroy();
|
|
156 |
processList->Close();
|
|
157 |
}
|
|
158 |
void CTe_coredumpserverSuite::CleanupPluginList(TAny *aArray)
|
|
159 |
/**
|
|
160 |
* Cleanup operation for RProcessPointerList
|
|
161 |
*/
|
|
162 |
{
|
|
163 |
RPluginPointerList *pluginList = static_cast<RPluginPointerList*> (aArray);
|
|
164 |
pluginList->ResetAndDestroy();
|
|
165 |
pluginList->Close();
|
|
166 |
}
|
|
167 |
|
|
168 |
void CTe_coredumpserverSuite::CleanupThreadList(TAny *aArray)
|
|
169 |
/**
|
|
170 |
* Cleanup operation for RThreadPointerList
|
|
171 |
*/
|
|
172 |
{
|
|
173 |
RThreadPointerList *threadList = static_cast<RThreadPointerList*> (aArray);
|
|
174 |
threadList->ResetAndDestroy();
|
|
175 |
threadList->Close();
|
|
176 |
}
|
|
177 |
|
|
178 |
CDir* CTe_coredumpserverSuite::DoesFileExistL(const TDesC &aExpectedFile, TFindFile &aFileFinder)
|
|
179 |
{
|
|
180 |
TParse fileParse;
|
|
181 |
fileParse.Set(aExpectedFile, NULL, NULL);
|
|
182 |
|
|
183 |
TBuf<63> filePattern;
|
|
184 |
filePattern = fileParse.Name();
|
|
185 |
filePattern.Append(_L("*"));
|
|
186 |
|
|
187 |
CDir* fileList = NULL;
|
|
188 |
aFileFinder.FindWildByDir(filePattern, fileParse.DriveAndPath(), fileList);
|
|
189 |
|
|
190 |
if(fileList == NULL)
|
|
191 |
{
|
|
192 |
User::Leave(KErrNotFound);
|
|
193 |
}
|
|
194 |
|
|
195 |
return fileList;
|
|
196 |
}
|
|
197 |
|
|
198 |
TBool CTe_coredumpserverSuite::FileStartsWith(const TDesC& aRoot, const TDesC& aFilename )
|
|
199 |
/*
|
|
200 |
* @return - If the file starts with the root
|
|
201 |
* Takes a descriptor and see if it starts with the root
|
|
202 |
*/
|
|
203 |
{
|
|
204 |
if(aFilename.Length() < aRoot.Length())
|
|
205 |
{
|
|
206 |
return EFalse;
|
|
207 |
}
|
|
208 |
|
|
209 |
TInt rootLength = aRoot.Length();
|
|
210 |
TInt cnt = 0;
|
|
211 |
|
|
212 |
while(cnt < rootLength)
|
|
213 |
{
|
|
214 |
|
|
215 |
if(aRoot[cnt] != aFilename[cnt])
|
|
216 |
{
|
|
217 |
return EFalse;
|
|
218 |
}
|
|
219 |
cnt++;
|
|
220 |
}
|
|
221 |
LOG_MSG("leaving");
|
|
222 |
return ETrue;
|
|
223 |
}
|
|
224 |
|
|
225 |
void CTe_coredumpserverSuite::CleanupBufferArray(TAny *aArray)
|
|
226 |
{
|
|
227 |
CDesC16ArrayFlat* buffArray = static_cast<CDesC16ArrayFlat*> (aArray);
|
|
228 |
TInt cntr = 0;
|
|
229 |
for(cntr =0; cntr<buffArray->MdcaCount(); cntr++)
|
|
230 |
{
|
|
231 |
TPtrC16 ptr = (*buffArray)[cntr];
|
|
232 |
}
|
|
233 |
}
|
|
234 |
|
|
235 |
|