|
1 // Copyright (c) 2007-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 /** |
|
22 @file filewritertestserver.cpp |
|
23 */ |
|
24 #include "filewritertestserver.h" |
|
25 #include "filewriterteststeps.h" |
|
26 |
|
27 // __EDIT_ME__ - Substitute the name of your test server |
|
28 _LIT(KServerName,"filewritertestserver"); |
|
29 // __EDIT_ME__ - Use your own server class name |
|
30 CFileWriterTestServer* CFileWriterTestServer::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 // __EDIT_ME__ new your server class here |
|
38 CFileWriterTestServer * server = new (ELeave) CFileWriterTestServer (); |
|
39 CleanupStack::PushL(server); |
|
40 |
|
41 // Either use a StartL or ConstructL, the latter will permit |
|
42 // Server Logging. |
|
43 |
|
44 //server->StartL(KServerName); |
|
45 server->ConstructL(KServerName); |
|
46 CleanupStack::Pop(server); |
|
47 return server; |
|
48 } |
|
49 |
|
50 // EKA2 much simpler |
|
51 // Just an E32Main and a MainL() |
|
52 LOCAL_C void MainL() |
|
53 /** |
|
54 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
55 */ |
|
56 { |
|
57 // Leave the hooks in for platform security |
|
58 #if (defined __DATA_CAGING__) |
|
59 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
60 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
61 #endif |
|
62 CActiveScheduler* sched=NULL; |
|
63 sched=new(ELeave) CActiveScheduler; |
|
64 CActiveScheduler::Install(sched); |
|
65 // __EDIT_ME__ Your server name |
|
66 CFileWriterTestServer * server = NULL; |
|
67 // Create the CTestServer derived server |
|
68 // __EDIT_ME__ Your server name |
|
69 TRAPD(err,server = CFileWriterTestServer::NewL()); |
|
70 if(!err) |
|
71 { |
|
72 // Sync with the client and enter the active scheduler |
|
73 RProcess::Rendezvous(KErrNone); |
|
74 sched->Start(); |
|
75 } |
|
76 delete server; |
|
77 delete sched; |
|
78 } |
|
79 |
|
80 // Only a DLL on emulator for typhoon and earlier |
|
81 |
|
82 GLDEF_C TInt E32Main() |
|
83 /** |
|
84 * @return - Standard Epoc error code on exit |
|
85 */ |
|
86 { |
|
87 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
88 if(cleanup == NULL) |
|
89 { |
|
90 return KErrNoMemory; |
|
91 } |
|
92 TRAP_IGNORE(MainL()); |
|
93 delete cleanup; |
|
94 return KErrNone; |
|
95 } |
|
96 |
|
97 // Create a thread in the calling process |
|
98 // Emulator typhoon and earlier |
|
99 |
|
100 // __EDIT_ME__ - Use your own server class name |
|
101 CTestStep* CFileWriterTestServer::CreateTestStep(const TDesC& aStepName) |
|
102 /** |
|
103 * @return - A CTestStep derived instance |
|
104 * Implementation of CTestServer pure virtual |
|
105 */ |
|
106 { |
|
107 CTestStep* testStep = NULL; |
|
108 // __EDIT_ME__ - Create your own test steps here |
|
109 // This server creates just one step but create as many as you want |
|
110 // They are created "just in time" when the worker thread is created |
|
111 TInt err = KErrNone; |
|
112 |
|
113 if(aStepName == KFileWriterTestStep1) |
|
114 { |
|
115 TRAP(err, testStep = new(ELeave) CFileWriterTestStep1()); |
|
116 } |
|
117 else if(aStepName == KFileWriterTestStep2) |
|
118 { |
|
119 TRAP(err, testStep = new(ELeave) CFileWriterTestStep2()); |
|
120 } |
|
121 else if(aStepName == KFileWriterTestStep3) |
|
122 { |
|
123 TRAP(err, testStep = new(ELeave) CFileWriterTestStep3()); |
|
124 } |
|
125 else if(aStepName == KFileWriterTestStep4) |
|
126 { |
|
127 TRAP(err, testStep = new(ELeave) CFileWriterTestStep4()); |
|
128 } |
|
129 else if(aStepName == KFileWriterTestStep5) |
|
130 { |
|
131 TRAP(err, testStep = new(ELeave) CFileWriterTestStep5()); |
|
132 } |
|
133 |
|
134 if(err != KErrNone) |
|
135 { |
|
136 return NULL; |
|
137 } |
|
138 |
|
139 return testStep; |
|
140 } |
|
141 |