|
1 // Copyright (c) 2002-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 // Name : tsemtimedwaitserver.cpp |
|
15 // Part of : testsemtimedwait |
|
16 // This material, including documentation and any related |
|
17 // computer programs, is protected by copyright controlled by |
|
18 // Nokia Corporation. All rights are reserved. Copying, |
|
19 // including reproducing, storing, adapting or translating, any |
|
20 // or all of this material requires the prior written consent of |
|
21 // Nokia Corporation. This material also contains confidential |
|
22 // information which may not be disclosed to others without the |
|
23 // prior written consent of Nokia Corporation. |
|
24 // |
|
25 |
|
26 |
|
27 |
|
28 #include <c32comm.h> |
|
29 |
|
30 #if defined (__WINS__) |
|
31 #define PDD_NAME _L("ECDRV") |
|
32 #else |
|
33 #define PDD_NAME _L("EUART1") |
|
34 #define PDD2_NAME _L("EUART2") |
|
35 #define PDD3_NAME _L("EUART3") |
|
36 #define PDD4_NAME _L("EUART4") |
|
37 #endif |
|
38 |
|
39 #define LDD_NAME _L("ECOMM") |
|
40 |
|
41 /** |
|
42 * @file |
|
43 * |
|
44 * Pipe test server implementation |
|
45 */ |
|
46 #include "tsemtimedwaitserver.h" |
|
47 #include "tsemtimedwait.h" |
|
48 |
|
49 |
|
50 _LIT(KServerName, "tsemtimedwait"); |
|
51 |
|
52 CSemtimedwaitTestServer* CSemtimedwaitTestServer::NewL() |
|
53 { |
|
54 CSemtimedwaitTestServer *server = new(ELeave) CSemtimedwaitTestServer(); |
|
55 CleanupStack::PushL(server); |
|
56 server->ConstructL(KServerName); |
|
57 CleanupStack::Pop(server); |
|
58 return server; |
|
59 } |
|
60 |
|
61 static void InitCommsL() |
|
62 { |
|
63 TInt ret = User::LoadPhysicalDevice(PDD_NAME); |
|
64 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
65 |
|
66 #ifndef __WINS__ |
|
67 ret = User::LoadPhysicalDevice(PDD2_NAME); |
|
68 ret = User::LoadPhysicalDevice(PDD3_NAME); |
|
69 ret = User::LoadPhysicalDevice(PDD4_NAME); |
|
70 #endif |
|
71 |
|
72 ret = User::LoadLogicalDevice(LDD_NAME); |
|
73 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
74 ret = StartC32(); |
|
75 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
76 } |
|
77 |
|
78 LOCAL_C void MainL() |
|
79 { |
|
80 // Leave the hooks in for platform security |
|
81 #if (defined __DATA_CAGING__) |
|
82 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
83 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
84 #endif |
|
85 InitCommsL(); |
|
86 |
|
87 CActiveScheduler* sched=NULL; |
|
88 sched=new(ELeave) CActiveScheduler; |
|
89 CActiveScheduler::Install(sched); |
|
90 CSemtimedwaitTestServer* server = NULL; |
|
91 // Create the CTestServer derived server |
|
92 TRAPD(err, server = CSemtimedwaitTestServer::NewL()); |
|
93 if(!err) |
|
94 { |
|
95 // Sync with the client and enter the active scheduler |
|
96 RProcess::Rendezvous(KErrNone); |
|
97 sched->Start(); |
|
98 } |
|
99 delete server; |
|
100 delete sched; |
|
101 } |
|
102 |
|
103 /** |
|
104 * Server entry point |
|
105 * @return Standard Epoc error code on exit |
|
106 */ |
|
107 TInt main() |
|
108 { |
|
109 __UHEAP_MARK; |
|
110 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
111 if(cleanup == NULL) |
|
112 { |
|
113 return KErrNoMemory; |
|
114 } |
|
115 TRAP_IGNORE(MainL()); |
|
116 delete cleanup; |
|
117 __UHEAP_MARKEND; |
|
118 |
|
119 return KErrNone; |
|
120 } |
|
121 |
|
122 CTestStep* CSemtimedwaitTestServer::CreateTestStep(const TDesC& aStepName) |
|
123 { |
|
124 CTestStep* testStep = NULL; |
|
125 |
|
126 // This server creates just one step but create as many as you want |
|
127 // They are created "just in time" when the worker thread is created |
|
128 // install steps |
|
129 if(aStepName == KTestSem291) |
|
130 { |
|
131 testStep = new CTestSemtimedwait(aStepName); |
|
132 } |
|
133 else if(aStepName == KTestSem292) |
|
134 { |
|
135 testStep = new CTestSemtimedwait(aStepName); |
|
136 } |
|
137 else if(aStepName == KTestSem303) |
|
138 { |
|
139 testStep = new CTestSemtimedwait(aStepName); |
|
140 } |
|
141 else if(aStepName == KTestSem304) |
|
142 { |
|
143 testStep = new CTestSemtimedwait(aStepName); |
|
144 } |
|
145 else if(aStepName == KTestSem305) |
|
146 { |
|
147 testStep = new CTestSemtimedwait(aStepName); |
|
148 } |
|
149 else if(aStepName == KTestSem306) |
|
150 { |
|
151 testStep = new CTestSemtimedwait(aStepName); |
|
152 } |
|
153 else if(aStepName == KTestSem701) |
|
154 { |
|
155 testStep = new CTestSemtimedwait(aStepName); |
|
156 } |
|
157 else if(aStepName == KTestSem702) |
|
158 { |
|
159 testStep = new CTestSemtimedwait(aStepName); |
|
160 } |
|
161 return testStep; |
|
162 } |
|
163 |