|
1 // Copyright (c) 2003-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 // |
|
15 |
|
16 #include <simulprocserver.h> |
|
17 |
|
18 EXPORT_C void CSimulProcServer::SessionClosed() |
|
19 { |
|
20 iSessionCount--; |
|
21 if (iSessionCount == 0) |
|
22 CActiveScheduler::Stop(); |
|
23 } |
|
24 |
|
25 |
|
26 EXPORT_C CSimulProcServer::CSimulProcServer() |
|
27 : CServer2(EPriorityNormal) |
|
28 { |
|
29 } |
|
30 |
|
31 |
|
32 EXPORT_C CSimulProcServer::~CSimulProcServer() |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 EXPORT_C CSimulProcSession::CSimulProcSession() |
|
38 /** |
|
39 * Constructor |
|
40 */ |
|
41 { |
|
42 } |
|
43 |
|
44 EXPORT_C CSimulProcSession::~CSimulProcSession() |
|
45 /** |
|
46 * Destructor |
|
47 */ |
|
48 { |
|
49 const CSimulProcServer* p=reinterpret_cast<const CSimulProcServer*>(Server()); |
|
50 // // Shuts Down the server if this is the last open session |
|
51 const_cast<CSimulProcServer*>(p)->SessionClosed(); |
|
52 } |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 EXPORT_C CSession2* CSimulProcServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const |
|
59 /** |
|
60 * @param RMessage - RMessage for the session open |
|
61 * Secure version |
|
62 */ |
|
63 { |
|
64 CSimulProcSession* session = new (ELeave) CSimulProcSession(); |
|
65 const_cast<CSimulProcServer*>(this)->iSessionCount++; |
|
66 return session; |
|
67 } |
|
68 |
|
69 |
|
70 |
|
71 EXPORT_C void CSimulProcSession::ServiceL(const RMessage2& aMessage) |
|
72 /** |
|
73 * @param aMessage - Function and data for the session |
|
74 * Session was created by pure virtual CTestServer::NewSessionL() |
|
75 * Message Functions defined in TestExecuteClient.h |
|
76 * |
|
77 * EOpenTestStep - Creates a new subsession |
|
78 * ERunTestStep - Executes the test step asynchronously |
|
79 * EAbortTestStep - Kill()'s the executing test step |
|
80 * ECloseTestStep - Free's the resource |
|
81 * |
|
82 * Secure and non-secure variants |
|
83 * There are two modes of operation: |
|
84 * Test step is opened with the shared data boolean set to FALSE: |
|
85 * Create a new CStepControl instance and hence a new thread in its own heap |
|
86 * Consecutive or Concurrent operation |
|
87 * Test step is opened with the shared data boolean set to TRUE: |
|
88 * Create a CPersistentStepControl and keep reusing it, and its thread |
|
89 * Consecutive operation only |
|
90 */ |
|
91 { |
|
92 switch(aMessage.Function()) |
|
93 { |
|
94 case EMMTSOpenTestStep : |
|
95 { |
|
96 TBuf<256> stepName; |
|
97 // Read the step name from the descriptor |
|
98 aMessage.ReadL(0,stepName); |
|
99 const CSimulProcServer* p=reinterpret_cast<const CSimulProcServer*>(Server()); |
|
100 iTestStep = p->CreateTestStep(stepName); |
|
101 aMessage.Complete(KErrNone); |
|
102 } |
|
103 |
|
104 break; |
|
105 case EMMTSStartProcessing: |
|
106 { |
|
107 if (!iTestStep) |
|
108 aMessage.Complete(KErrNotReady); |
|
109 else |
|
110 { |
|
111 if (iActiveCallback) |
|
112 iActiveCallback->Cancel(); |
|
113 delete iActiveCallback; |
|
114 iActiveCallback = NULL; |
|
115 iActiveCallback = new (ELeave) CActiveCallback(aMessage); |
|
116 iTestStep->StartProcessing(iActiveCallback->ActiveStatus()); |
|
117 } |
|
118 } |
|
119 |
|
120 break; |
|
121 case EMMTSStopProcessing : |
|
122 { |
|
123 if (!iTestStep) |
|
124 aMessage.Complete(KErrNotReady); |
|
125 else |
|
126 { |
|
127 TBuf8<256> message; |
|
128 TVerdict verdict = iTestStep->EndProcessingAndReturnResult(message); |
|
129 TPckgBuf<TVerdict> v(verdict); |
|
130 aMessage.WriteL(0,v); |
|
131 aMessage.WriteL(1,message); |
|
132 aMessage.Complete(KErrNone); |
|
133 } |
|
134 break; |
|
135 } |
|
136 case EMMTSClose : |
|
137 { |
|
138 aMessage.Complete(KErrNone); |
|
139 } |
|
140 |
|
141 break; |
|
142 default: |
|
143 break; |
|
144 } |
|
145 } |
|
146 |
|
147 void CSimulProcSession::CActiveCallback::RunL() |
|
148 { |
|
149 iMessage.Complete(iStatus.Int()); |
|
150 } |
|
151 |
|
152 void CSimulProcSession::CActiveCallback::DoCancel() |
|
153 { |
|
154 |
|
155 } |
|
156 |
|
157 CSimulProcSession::CActiveCallback::CActiveCallback(const RMessage2& aMessage) |
|
158 : CActive(EPriorityNormal), iMessage(aMessage) |
|
159 { |
|
160 CActiveScheduler::Add(this); |
|
161 } |
|
162 |
|
163 TRequestStatus& CSimulProcSession::CActiveCallback::ActiveStatus() |
|
164 { |
|
165 SetActive(); |
|
166 iStatus = KRequestPending; |
|
167 return iStatus; |
|
168 } |
|
169 |
|
170 |
|
171 EXPORT_C CSimulProcTestStep::CSimulProcTestStep() |
|
172 { |
|
173 } |
|
174 |
|
175 EXPORT_C CSimulProcTestStep::~CSimulProcTestStep() |
|
176 { |
|
177 } |