|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This module contains implementation of CSettingServer |
|
15 * class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include <e32svr.h> |
|
22 |
|
23 #include "SettingServerClient.h" |
|
24 #include "SettingServer.h" |
|
25 |
|
26 #include <StifLogger.h> |
|
27 #include "Logging.h" |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 // MACROS |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 |
|
39 // MODULE DATA STRUCTURES |
|
40 |
|
41 // LOCAL FUNCTION PROTOTYPES |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 |
|
45 // ==================== LOCAL FUNCTIONS ======================================= |
|
46 // None |
|
47 |
|
48 #undef LOGGER |
|
49 #define LOGGER iSettingServerLogger |
|
50 |
|
51 // ================= MEMBER FUNCTIONS ========================================= |
|
52 |
|
53 /* |
|
54 ------------------------------------------------------------------------------- |
|
55 |
|
56 Class: CSettingServer |
|
57 |
|
58 Method: PanicServer |
|
59 |
|
60 Description: Panics the server. |
|
61 |
|
62 Parameters: const TSettingServerPanic aPanic :in: Panic code |
|
63 |
|
64 Return Values: None |
|
65 |
|
66 Errors/Exceptions: None |
|
67 |
|
68 Status: Proposal |
|
69 |
|
70 ------------------------------------------------------------------------------- |
|
71 */ |
|
72 void CSettingServer::PanicServer( const TSettingServerPanic aPanic ) |
|
73 { |
|
74 RDebug::Print( _L( "CSettingServer::PanicServer" ) ); |
|
75 _LIT( KTxtServer,"CSettingServer" ); |
|
76 User::Panic( KTxtServer,aPanic ); |
|
77 } |
|
78 |
|
79 /* |
|
80 ------------------------------------------------------------------------------- |
|
81 |
|
82 Class: CSettingServer |
|
83 |
|
84 Method: NewL |
|
85 |
|
86 Description: Returns new CSettingServer object |
|
87 |
|
88 Parameters: const TName& aName: in: Server name |
|
89 |
|
90 Return Values: None |
|
91 |
|
92 Errors/Exceptions: Leaves if memory allocation, ConstructL or StartL |
|
93 leaves. |
|
94 |
|
95 Status: Proposal |
|
96 |
|
97 ------------------------------------------------------------------------------- |
|
98 */ |
|
99 CSettingServer* CSettingServer::NewL( const TName& aName ) |
|
100 |
|
101 { |
|
102 CSettingServer* self = new( ELeave ) CSettingServer(); |
|
103 CleanupStack::PushL( self ); |
|
104 |
|
105 // Construct the server |
|
106 self->ConstructL(); |
|
107 |
|
108 // Start the server |
|
109 self->StartL( aName ); |
|
110 |
|
111 CleanupStack::Pop( self ); |
|
112 |
|
113 return self; |
|
114 |
|
115 } |
|
116 |
|
117 /* |
|
118 ------------------------------------------------------------------------------- |
|
119 |
|
120 Class: CSettingServer |
|
121 |
|
122 Method: ConstructL |
|
123 |
|
124 Description: Second level constructor. |
|
125 |
|
126 Parameters: None |
|
127 |
|
128 Return Values: None |
|
129 |
|
130 Errors/Exceptions: None |
|
131 |
|
132 Status: Proposal |
|
133 |
|
134 ------------------------------------------------------------------------------- |
|
135 */ |
|
136 void CSettingServer::ConstructL() |
|
137 { |
|
138 // Create logger, in Wins use HTML in HW default logger |
|
139 TLoggerSettings loggerSettings; |
|
140 // Directory must create by hand if test engine log wanted |
|
141 loggerSettings.iCreateLogDirectories = EFalse; |
|
142 loggerSettings.iOverwrite = ETrue; |
|
143 loggerSettings.iTimeStamp = ETrue; |
|
144 loggerSettings.iLineBreak = ETrue; |
|
145 loggerSettings.iEventRanking = EFalse; |
|
146 loggerSettings.iThreadId = EFalse; |
|
147 loggerSettings.iHardwareFormat = CStifLogger::ETxt; |
|
148 #ifndef FORCE_STIF_INTERNAL_LOGGING_TO_RDEBUG |
|
149 loggerSettings.iEmulatorFormat = CStifLogger::EHtml; |
|
150 loggerSettings.iHardwareOutput = CStifLogger::EFile; |
|
151 loggerSettings.iEmulatorOutput = CStifLogger::EFile; |
|
152 #else |
|
153 RDebug::Print( _L( "STIF SettingServer logging forced to RDebug" ) ); |
|
154 loggerSettings.iEmulatorFormat = CStifLogger::ETxt; |
|
155 loggerSettings.iHardwareOutput = CStifLogger::ERDebug; |
|
156 loggerSettings.iEmulatorOutput = CStifLogger::ERDebug; |
|
157 #endif |
|
158 loggerSettings.iUnicode = EFalse; |
|
159 loggerSettings.iAddTestCaseTitle = EFalse; |
|
160 iSettingServerLogger = CStifLogger::NewL( |
|
161 _L( "C:\\logs\\testframework\\testengine\\"), |
|
162 _L( "SettingServer" ), |
|
163 loggerSettings ); |
|
164 |
|
165 ResetLoggerSettings(); |
|
166 |
|
167 __TRACE( KInit,( _L( "-.-.-.-.-.-.-.-.-.- SettingServer log starts -.-.-.-.-.-.-.-.-.-" ) ) ); |
|
168 __TRACE( KInit,( _L( "CSettingServer::ConstructL()" ) ) ); |
|
169 } |
|
170 |
|
171 /* |
|
172 ------------------------------------------------------------------------------- |
|
173 |
|
174 Class: CSettingServer |
|
175 |
|
176 Method: CSettingServer |
|
177 |
|
178 Description: Constructor. |
|
179 |
|
180 Initialises non-zero member variables and base class with correct |
|
181 priority. |
|
182 |
|
183 Parameters: None |
|
184 |
|
185 Return Values: None |
|
186 |
|
187 Errors/Exceptions: None |
|
188 |
|
189 Status: Proposal |
|
190 |
|
191 ------------------------------------------------------------------------------- |
|
192 */ |
|
193 CSettingServer::CSettingServer() : |
|
194 CServer2( CSettingServer::ESettingServerSchedulerPriority ) |
|
195 { |
|
196 |
|
197 } |
|
198 |
|
199 /* |
|
200 ------------------------------------------------------------------------------- |
|
201 |
|
202 Class: CSettingServer |
|
203 |
|
204 Method: ~CSettingServer |
|
205 |
|
206 Description: Destructor. |
|
207 |
|
208 Parameters: None |
|
209 |
|
210 Return Values: None |
|
211 |
|
212 Errors/Exceptions: None |
|
213 |
|
214 Status: Proposal |
|
215 |
|
216 ------------------------------------------------------------------------------- |
|
217 */ |
|
218 CSettingServer::~CSettingServer() |
|
219 { |
|
220 delete iSettingServerLogger; |
|
221 |
|
222 } |
|
223 |
|
224 /* |
|
225 ------------------------------------------------------------------------------- |
|
226 |
|
227 Class: CSettingServer |
|
228 |
|
229 Method: NewSessionL |
|
230 |
|
231 Description: Returns new session. |
|
232 |
|
233 Parameters: const TVersion &aVersion:in :Version required |
|
234 |
|
235 Return Values: CSharableSession* New session |
|
236 |
|
237 Errors/Exceptions: Leaves if invalid version |
|
238 Leaves if CSettingServer construction leaves |
|
239 |
|
240 Status: Proposal |
|
241 |
|
242 ------------------------------------------------------------------------------- |
|
243 */ |
|
244 CSession2* CSettingServer::NewSessionL( const TVersion& aVersion, |
|
245 const RMessage2& /*aMessage*/ ) const |
|
246 |
|
247 { |
|
248 // check version is ok |
|
249 TVersion v( KSettingServerMajorVersionNumber, |
|
250 KSettingServerMinorVersionNumber, |
|
251 KSettingServerVersionNumber |
|
252 ); |
|
253 |
|
254 if( !User::QueryVersionSupported( v, aVersion ) ) |
|
255 { |
|
256 User::Leave( KErrNotSupported ); |
|
257 } |
|
258 |
|
259 return CLoggerSetting::NewL( ( CSettingServer* ) this ); |
|
260 } |
|
261 /* |
|
262 ------------------------------------------------------------------------------- |
|
263 |
|
264 Class: CSettingServer |
|
265 |
|
266 Method: OpenSession |
|
267 |
|
268 Description: Opens session. Session calls calls this when session is |
|
269 properly constructed. |
|
270 |
|
271 Parameters: None |
|
272 |
|
273 Return Values: None |
|
274 |
|
275 Errors/Exceptions: None |
|
276 |
|
277 Status: Proposal |
|
278 |
|
279 ------------------------------------------------------------------------------- |
|
280 */ |
|
281 void CSettingServer::OpenSession() |
|
282 { |
|
283 iSessions++; |
|
284 |
|
285 } |
|
286 |
|
287 /* |
|
288 ------------------------------------------------------------------------------- |
|
289 |
|
290 Class: CSettingServer |
|
291 |
|
292 Method: Logger |
|
293 |
|
294 Description: Return pointer to the Logger(iSettingServerLogger) |
|
295 |
|
296 Parameters: None |
|
297 |
|
298 Return Values: CStifLogger*: Pointer to Logger |
|
299 |
|
300 Errors/Exceptions: None |
|
301 |
|
302 Status: Proposal |
|
303 |
|
304 ------------------------------------------------------------------------------- |
|
305 */ |
|
306 CStifLogger* CSettingServer::Logger() |
|
307 { |
|
308 return iSettingServerLogger; |
|
309 |
|
310 } |
|
311 |
|
312 /* |
|
313 ------------------------------------------------------------------------------- |
|
314 |
|
315 Class: CSettingServer |
|
316 |
|
317 Method: CloseSession |
|
318 |
|
319 Description: Closes session. CLoggerSetting::CloseSession calls this |
|
320 to inform server class. |
|
321 |
|
322 If there are not any active sessions, then stop active scheduler and |
|
323 close whole server. |
|
324 |
|
325 Parameters: None |
|
326 |
|
327 Return Values: None |
|
328 |
|
329 Errors/Exceptions: Function panics if OpenSessions() and CloseSessions() |
|
330 does not match. |
|
331 |
|
332 Status: Proposal |
|
333 |
|
334 ------------------------------------------------------------------------------- |
|
335 */ |
|
336 void CSettingServer::CloseSession() |
|
337 { |
|
338 __ASSERT_ALWAYS ( iSessions > 0, CSettingServer::PanicServer(ETooManyCloseSessions)); |
|
339 iSessions--; |
|
340 |
|
341 if ( iSessions == 0 ) |
|
342 { |
|
343 // Stop the active scheduler if no-one is using server anymore |
|
344 CActiveScheduler::Stop(); |
|
345 } |
|
346 |
|
347 } |
|
348 |
|
349 void CSettingServer::ResetLoggerSettings() |
|
350 { |
|
351 // iLoggerSettings initializations to indicate is setting in use |
|
352 iLoggerSettings.iIsDefined.iCreateLogDir = EFalse; |
|
353 iLoggerSettings.iEmulatorPath.Copy( _L( "" ) ); |
|
354 iLoggerSettings.iEmulatorFormat = CStifLogger::ETxt; |
|
355 iLoggerSettings.iEmulatorOutput = CStifLogger::EFile; |
|
356 iLoggerSettings.iHardwarePath.Copy( _L( "" ) ); |
|
357 iLoggerSettings.iHardwareFormat = CStifLogger::ETxt; |
|
358 iLoggerSettings.iHardwareOutput = CStifLogger::EFile; |
|
359 iLoggerSettings.iOverwrite = ETrue; |
|
360 iLoggerSettings.iTimeStamp = ETrue; |
|
361 iLoggerSettings.iLineBreak = ETrue; |
|
362 iLoggerSettings.iEventRanking = EFalse; |
|
363 iLoggerSettings.iThreadId = EFalse; |
|
364 iLoggerSettings.iUnicode = EFalse; |
|
365 iLoggerSettings.iAddTestCaseTitle = EFalse; |
|
366 |
|
367 iLoggerSettings.iIsDefined.iPath = EFalse; |
|
368 iLoggerSettings.iIsDefined.iHwPath = EFalse; |
|
369 iLoggerSettings.iIsDefined.iFormat = EFalse; |
|
370 iLoggerSettings.iIsDefined.iHwFormat = EFalse; |
|
371 iLoggerSettings.iIsDefined.iOutput = EFalse; |
|
372 iLoggerSettings.iIsDefined.iHwOutput = EFalse; |
|
373 iLoggerSettings.iIsDefined.iOverwrite = EFalse; |
|
374 iLoggerSettings.iIsDefined.iLineBreak = EFalse; |
|
375 iLoggerSettings.iIsDefined.iTimeStamp = EFalse; |
|
376 iLoggerSettings.iIsDefined.iEventRanking = EFalse; |
|
377 iLoggerSettings.iIsDefined.iThreadId = EFalse; |
|
378 iLoggerSettings.iIsDefined.iUnicode = EFalse; |
|
379 iLoggerSettings.iIsDefined.iAddTestCaseTitle = EFalse; |
|
380 |
|
381 iIniFile = KNullDesC; |
|
382 iDefaultSettings = ETrue; |
|
383 } |
|
384 |
|
385 |
|
386 // End of File |