|
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 // Name : twcharapiserver.cpp |
|
15 // This material, including documentation and any related |
|
16 // computer programs, is protected by copyright controlled by |
|
17 // Nokia Corporation. All rights are reserved. Copying, |
|
18 // including reproducing, storing, adapting or translating, any |
|
19 // or all of this material requires the prior written consent of |
|
20 // Nokia Corporation. This material also contains confidential |
|
21 // information which may not be disclosed to others without the |
|
22 // prior written consent of Nokia Corporation. |
|
23 // |
|
24 |
|
25 |
|
26 |
|
27 #include <c32comm.h> |
|
28 |
|
29 #if defined (__WINS__) |
|
30 #define PDD_NAME _L("ECDRV") |
|
31 #else |
|
32 #define PDD_NAME _L("EUART1") |
|
33 #define PDD2_NAME _L("EUART2") |
|
34 #define PDD3_NAME _L("EUART3") |
|
35 #define PDD4_NAME _L("EUART4") |
|
36 #endif |
|
37 |
|
38 #define LDD_NAME _L("ECOMM") |
|
39 |
|
40 /** |
|
41 * @file |
|
42 * |
|
43 * Pipe test server implementation |
|
44 */ |
|
45 #include "twcharapiserver.h" |
|
46 #include "twcharapi.h" |
|
47 |
|
48 |
|
49 _LIT(KServerName, "twcharapi"); |
|
50 |
|
51 CWCharApiTestServer* CWCharApiTestServer::NewL() |
|
52 { |
|
53 CWCharApiTestServer *server = new(ELeave) CWCharApiTestServer(); |
|
54 CleanupStack::PushL(server); |
|
55 server->ConstructL(KServerName); |
|
56 CleanupStack::Pop(server); |
|
57 return server; |
|
58 } |
|
59 |
|
60 static void InitCommsL() |
|
61 { |
|
62 TInt ret = User::LoadPhysicalDevice(PDD_NAME); |
|
63 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
64 |
|
65 #ifndef __WINS__ |
|
66 ret = User::LoadPhysicalDevice(PDD2_NAME); |
|
67 ret = User::LoadPhysicalDevice(PDD3_NAME); |
|
68 ret = User::LoadPhysicalDevice(PDD4_NAME); |
|
69 #endif |
|
70 |
|
71 ret = User::LoadLogicalDevice(LDD_NAME); |
|
72 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
73 ret = StartC32(); |
|
74 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
75 } |
|
76 |
|
77 LOCAL_C void MainL() |
|
78 { |
|
79 // Leave the hooks in for platform security |
|
80 #if (defined __DATA_CAGING__) |
|
81 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
82 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
83 #endif |
|
84 InitCommsL(); |
|
85 |
|
86 CActiveScheduler* sched=NULL; |
|
87 sched=new(ELeave) CActiveScheduler; |
|
88 CActiveScheduler::Install(sched); |
|
89 CWCharApiTestServer* server = NULL; |
|
90 // Create the CTestServer derived server |
|
91 TRAPD(err, server = CWCharApiTestServer::NewL()); |
|
92 if(!err) |
|
93 { |
|
94 // Sync with the client and enter the active scheduler |
|
95 RProcess::Rendezvous(KErrNone); |
|
96 sched->Start(); |
|
97 } |
|
98 delete server; |
|
99 delete sched; |
|
100 } |
|
101 |
|
102 /** |
|
103 * Server entry point |
|
104 * @return Standard Epoc error code on exit |
|
105 */ |
|
106 TInt main() |
|
107 { |
|
108 __UHEAP_MARK; |
|
109 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
110 if(cleanup == NULL) |
|
111 { |
|
112 return KErrNoMemory; |
|
113 } |
|
114 TRAP_IGNORE(MainL()); |
|
115 delete cleanup; |
|
116 __UHEAP_MARKEND; |
|
117 |
|
118 return KErrNone; |
|
119 } |
|
120 |
|
121 |
|
122 CTestStep* CWCharApiTestServer::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 testStep = new CTestWCharApi(aStepName); |
|
130 |
|
131 return testStep; |
|
132 } |
|
133 |