|
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 : tftwserver.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <c32comm.h> |
|
19 |
|
20 #if defined (__WINS__) |
|
21 #define PDD_NAME _L("ECDRV") |
|
22 #else |
|
23 #define PDD_NAME _L("EUART1") |
|
24 #define PDD2_NAME _L("EUART2") |
|
25 #define PDD3_NAME _L("EUART3") |
|
26 #define PDD4_NAME _L("EUART4") |
|
27 #endif |
|
28 |
|
29 #define LDD_NAME _L("ECOMM") |
|
30 |
|
31 /** |
|
32 * @file |
|
33 * |
|
34 * Pipe test server implementation |
|
35 */ |
|
36 #include "tftwserver.h" |
|
37 #include "tftw.h" |
|
38 |
|
39 |
|
40 _LIT(KServerName, "tftw"); |
|
41 |
|
42 CftwTestServer* CftwTestServer::NewL() |
|
43 { |
|
44 CftwTestServer *server = new(ELeave) CftwTestServer(); |
|
45 CleanupStack::PushL(server); |
|
46 server->ConstructL(KServerName); |
|
47 CleanupStack::Pop(server); |
|
48 return server; |
|
49 } |
|
50 |
|
51 static void InitCommsL() |
|
52 { |
|
53 TInt ret = User::LoadPhysicalDevice(PDD_NAME); |
|
54 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
55 |
|
56 #ifndef __WINS__ |
|
57 ret = User::LoadPhysicalDevice(PDD2_NAME); |
|
58 ret = User::LoadPhysicalDevice(PDD3_NAME); |
|
59 ret = User::LoadPhysicalDevice(PDD4_NAME); |
|
60 #endif |
|
61 |
|
62 ret = User::LoadLogicalDevice(LDD_NAME); |
|
63 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
64 ret = StartC32(); |
|
65 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
66 } |
|
67 |
|
68 LOCAL_C void MainL() |
|
69 { |
|
70 // Leave the hooks in for platform security |
|
71 #if (defined __DATA_CAGING__) |
|
72 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
73 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
74 #endif |
|
75 InitCommsL(); |
|
76 |
|
77 CActiveScheduler* sched=NULL; |
|
78 sched=new(ELeave) CActiveScheduler; |
|
79 CActiveScheduler::Install(sched); |
|
80 CftwTestServer* server = NULL; |
|
81 // Create the CTestServer derived server |
|
82 TRAPD(err, server = CftwTestServer::NewL()); |
|
83 if(!err) |
|
84 { |
|
85 // Sync with the client and enter the active scheduler |
|
86 RProcess::Rendezvous(KErrNone); |
|
87 sched->Start(); |
|
88 } |
|
89 delete server; |
|
90 delete sched; |
|
91 } |
|
92 |
|
93 /** |
|
94 * Server entry point |
|
95 * @return Standard Epoc error code on exit |
|
96 */ |
|
97 TInt main() |
|
98 { |
|
99 __UHEAP_MARK; |
|
100 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
101 if(cleanup == NULL) |
|
102 { |
|
103 return KErrNoMemory; |
|
104 } |
|
105 TRAP_IGNORE(MainL()); |
|
106 delete cleanup; |
|
107 __UHEAP_MARKEND; |
|
108 |
|
109 return KErrNone; |
|
110 } |
|
111 |
|
112 CTestStep* CftwTestServer::CreateTestStep(const TDesC& aStepName) |
|
113 { |
|
114 CTestStep* testStep = NULL; |
|
115 |
|
116 // This server creates just one step but create as many as you want |
|
117 // They are created "just in time" when the worker thread is created |
|
118 // install steps |
|
119 if(aStepName == KTestFtw) |
|
120 { |
|
121 testStep = new CTestftw(aStepName); |
|
122 } |
|
123 else if(aStepName == KTestFtw2) |
|
124 { |
|
125 testStep = new CTestftw(aStepName); |
|
126 } |
|
127 else if(aStepName == KTestFtw3) |
|
128 { |
|
129 testStep = new CTestftw(aStepName); |
|
130 } |
|
131 else if(aStepName == KTestFtw4) |
|
132 { |
|
133 testStep = new CTestftw(aStepName); |
|
134 } |
|
135 else if(aStepName == KTestFtw5) |
|
136 { |
|
137 testStep = new CTestftw(aStepName); |
|
138 } |
|
139 return testStep; |
|
140 } |
|
141 |