26
|
1 |
/*
|
|
2 |
* Copyright (c) 2001-2010 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 the License "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: scheduler of EAP-server.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
/*
|
49
|
19 |
* %version: 41 %
|
26
|
20 |
*/
|
|
21 |
|
|
22 |
#include "EapServer.h"
|
|
23 |
#include "EapTraceSymbian.h"
|
|
24 |
#include <ecom.h>
|
|
25 |
#include "eap_automatic_variable.h"
|
|
26 |
|
|
27 |
/*
|
|
28 |
class CEapServer
|
|
29 |
*/
|
|
30 |
|
|
31 |
//----------------------------------------------------------------------------
|
|
32 |
|
|
33 |
CEapServer::CEapServer()
|
|
34 |
: CServer2(0, EGlobalSharableSessions) // //ESharableSessions
|
|
35 |
{
|
|
36 |
EAP_TRACE_DEBUG_SYMBIAN((_L("CEapServer::CEapServer(): this=0x%08x"),
|
|
37 |
this));
|
|
38 |
|
|
39 |
EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapServer::CEapServer()"));
|
|
40 |
}
|
|
41 |
|
|
42 |
//----------------------------------------------------------------------------
|
|
43 |
|
|
44 |
void CEapServer::ConstructL()
|
|
45 |
{
|
|
46 |
EAP_TRACE_DEBUG_SYMBIAN((_L("CEapServer::ConstructL(): start")));
|
|
47 |
|
|
48 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
49 |
|
|
50 |
iIsValid = EFalse;
|
|
51 |
iTools = abs_eap_am_tools_c::new_abs_eap_am_tools_c();
|
|
52 |
|
|
53 |
// Check if creation went ok and the the iIsValid variable
|
|
54 |
if (iTools == 0
|
|
55 |
|| iTools->get_is_valid() == false)
|
|
56 |
{
|
|
57 |
if (iTools != 0)
|
|
58 |
{
|
|
59 |
iTools->am_cancel_all_timers();
|
|
60 |
}
|
|
61 |
abs_eap_am_tools_c::delete_abs_eap_am_tools_c(iTools);
|
|
62 |
User::Leave(KErrNoMemory);
|
|
63 |
}
|
|
64 |
else
|
|
65 |
{
|
|
66 |
iIsValid = iTools->get_is_valid();
|
|
67 |
}
|
|
68 |
|
|
69 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::ConstructL()");
|
|
70 |
|
|
71 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
72 |
|
49
|
73 |
eap_status_e status(eap_status_ok);
|
|
74 |
|
26
|
75 |
{
|
|
76 |
const u8_t DEFAULT_PREFIX[] = "EAP-SERVER";
|
|
77 |
eap_variable_data_c tmp_prefix(iTools);
|
|
78 |
|
|
79 |
if (tmp_prefix.get_is_valid() == false)
|
|
80 |
{
|
49
|
81 |
status = eap_status_allocation_error;
|
|
82 |
(void) EAP_STATUS_RETURN(iTools, status);
|
26
|
83 |
}
|
|
84 |
|
49
|
85 |
if (status == eap_status_ok)
|
26
|
86 |
{
|
49
|
87 |
status = tmp_prefix.set_copy_of_buffer(DEFAULT_PREFIX, sizeof(DEFAULT_PREFIX)-1ul);;
|
|
88 |
if (status != eap_status_ok)
|
|
89 |
{
|
|
90 |
(void) EAP_STATUS_RETURN(iTools, status);
|
|
91 |
}
|
26
|
92 |
}
|
|
93 |
|
49
|
94 |
if (status == eap_status_ok)
|
26
|
95 |
{
|
49
|
96 |
status = tmp_prefix.add_end_null();
|
|
97 |
if (status != eap_status_ok)
|
|
98 |
{
|
|
99 |
(void) EAP_STATUS_RETURN(iTools, status);
|
|
100 |
}
|
26
|
101 |
}
|
|
102 |
|
49
|
103 |
if (status == eap_status_ok)
|
26
|
104 |
{
|
49
|
105 |
status = iTools->set_trace_prefix(&tmp_prefix);
|
|
106 |
if (status != eap_status_ok)
|
|
107 |
{
|
|
108 |
(void) EAP_STATUS_RETURN(iTools, status);
|
|
109 |
}
|
26
|
110 |
}
|
|
111 |
}
|
|
112 |
|
49
|
113 |
if (status != eap_status_ok)
|
|
114 |
{
|
|
115 |
iTools->am_cancel_all_timers();
|
|
116 |
abs_eap_am_tools_c::delete_abs_eap_am_tools_c(iTools);
|
|
117 |
User::Leave(KErrGeneral);
|
|
118 |
}
|
|
119 |
|
26
|
120 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
121 |
|
|
122 |
{
|
|
123 |
TInt error;
|
|
124 |
RFs aFileServerSession;
|
|
125 |
|
|
126 |
// Open file server session
|
|
127 |
EAP_TRACE_DEBUG(
|
|
128 |
iTools,
|
|
129 |
TRACE_FLAGS_DEFAULT,
|
|
130 |
(EAPL("CEapServer::ConstructL(): - calls aFileServerSession.Connect()\n")));
|
|
131 |
|
|
132 |
error = aFileServerSession.Connect();
|
|
133 |
|
|
134 |
EAP_TRACE_DEBUG(
|
|
135 |
iTools,
|
|
136 |
TRACE_FLAGS_DEFAULT,
|
|
137 |
(EAPL("CEapServer::ConstructL(): - aFileServerSession.Connect(), error=%d\n"),
|
|
138 |
error));
|
|
139 |
|
|
140 |
User::LeaveIfError(error);
|
|
141 |
|
|
142 |
// Create the private path - it is not automatically created by Symbian OS.
|
|
143 |
EAP_TRACE_DEBUG(
|
|
144 |
iTools,
|
|
145 |
TRACE_FLAGS_DEFAULT,
|
|
146 |
(EAPL("CEapServer::ConstructL(): - calls aFileServerSession.CreatePrivatePath(%d)\n"),
|
|
147 |
RFs::GetSystemDrive()));
|
|
148 |
|
|
149 |
error = aFileServerSession.CreatePrivatePath(RFs::GetSystemDrive());
|
|
150 |
|
|
151 |
EAP_TRACE_DEBUG(
|
|
152 |
iTools,
|
|
153 |
TRACE_FLAGS_DEFAULT,
|
|
154 |
(EAPL("CEapServer::ConstructL(): - aFileServerSession.CreatePrivatePath(%d), error=%d\n"),
|
|
155 |
RFs::GetSystemDrive(),
|
|
156 |
error));
|
|
157 |
|
|
158 |
User::LeaveIfError(error);
|
|
159 |
|
|
160 |
// Set the session path to the private directory
|
|
161 |
EAP_TRACE_DEBUG(
|
|
162 |
iTools,
|
|
163 |
TRACE_FLAGS_DEFAULT,
|
|
164 |
(EAPL("CEapServer::ConstructL(): - calls aFileServerSession.SetSessionToPrivate(%d)\n"),
|
|
165 |
RFs::GetSystemDrive()));
|
|
166 |
|
|
167 |
error = aFileServerSession.SetSessionToPrivate(RFs::GetSystemDrive());
|
|
168 |
|
|
169 |
EAP_TRACE_DEBUG(
|
|
170 |
iTools,
|
|
171 |
TRACE_FLAGS_DEFAULT,
|
|
172 |
(EAPL("CEapServer::ConstructL(): - aFileServerSession.SetSessionToPrivate(%d), error=%d\n"),
|
|
173 |
RFs::GetSystemDrive(),
|
|
174 |
error));
|
|
175 |
|
|
176 |
User::LeaveIfError(error);
|
|
177 |
|
|
178 |
// Close the session with the file server.
|
|
179 |
aFileServerSession.Close();
|
|
180 |
}
|
|
181 |
|
|
182 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
183 |
|
|
184 |
{
|
|
185 |
// construct shutdown timer
|
|
186 |
iShutdown = new(ELeave) CEapDelayedShutdown(iTools, this);
|
|
187 |
iShutdown->ConstructL();
|
|
188 |
// identify ourselves and open for service
|
|
189 |
TBuf<KMaxServerExe> ServerName;
|
|
190 |
TBuf<KMaxServerExe> ServerExe;
|
|
191 |
|
|
192 |
GetServerNameAndExe(&ServerName, &ServerExe);
|
|
193 |
|
|
194 |
StartL(ServerName);
|
|
195 |
|
|
196 |
// Initiates shut down timer. Timer will close server unless we get client connections.
|
|
197 |
iShutdown->Start();
|
|
198 |
}
|
|
199 |
|
|
200 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
201 |
|
|
202 |
{
|
|
203 |
// construct backup and restore observer
|
|
204 |
iBackupRestore = new(ELeave) CEapserverBackup(this);
|
|
205 |
iBackupRestore->ConstructL();
|
|
206 |
}
|
|
207 |
|
|
208 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
209 |
|
|
210 |
}
|
|
211 |
|
|
212 |
//----------------------------------------------------------------------------
|
|
213 |
|
|
214 |
CEapServer* CEapServer::NewL()
|
|
215 |
{
|
|
216 |
EAP_TRACE_DEBUG_SYMBIAN((_L("CEapServer::NewL(): starts")));
|
|
217 |
|
|
218 |
EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapServer::NewL()"));
|
|
219 |
|
|
220 |
CEapServer* self = new(ELeave)CEapServer();
|
|
221 |
CleanupStack::PushL(self);
|
|
222 |
|
|
223 |
self->ConstructL();
|
|
224 |
|
|
225 |
CleanupStack::Pop(self);
|
|
226 |
|
|
227 |
return self;
|
|
228 |
}
|
|
229 |
|
|
230 |
//----------------------------------------------------------------------------
|
|
231 |
|
|
232 |
CEapServer::~CEapServer()
|
|
233 |
{
|
|
234 |
EAP_TRACE_DEBUG(
|
|
235 |
iTools,
|
|
236 |
TRACE_FLAGS_DEFAULT,
|
|
237 |
(EAPL("CEapServer::~CEapServer(): this=0x%08x\n"),
|
|
238 |
this));
|
|
239 |
|
|
240 |
// Do not use iTools, because it will be destroyed before return.
|
|
241 |
EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapServer::~CEapServer()"));
|
|
242 |
|
49
|
243 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
244 |
|
|
245 |
TInt aCount = iReadyHandlers.Count();
|
|
246 |
|
|
247 |
while (aCount > 0)
|
|
248 |
{
|
|
249 |
EAP_TRACE_DEBUG(
|
|
250 |
iTools,
|
|
251 |
TRACE_FLAGS_DEFAULT,
|
|
252 |
(EAPL("CEapServer::~CEapServer(): Removes iReadyHandlers[0]=0x%08x\n"),
|
|
253 |
iReadyHandlers[0]));
|
|
254 |
|
|
255 |
iReadyHandlers.Remove(0);
|
|
256 |
|
|
257 |
aCount = iReadyHandlers.Count();
|
|
258 |
}
|
|
259 |
|
|
260 |
iReadyHandlers.Close();
|
|
261 |
|
|
262 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
263 |
|
26
|
264 |
delete iShutdown;
|
|
265 |
delete iBackupRestore;
|
|
266 |
|
|
267 |
if (iTools)
|
|
268 |
{
|
|
269 |
iTools->am_cancel_all_timers();
|
|
270 |
abs_eap_am_tools_c::delete_abs_eap_am_tools_c(iTools);
|
|
271 |
}
|
|
272 |
|
34
|
273 |
EAP_TRACE_DEBUG_SYMBIAN((_L("REComSession::FinalClose(): start")));
|
|
274 |
|
26
|
275 |
REComSession::FinalClose();
|
34
|
276 |
|
|
277 |
EAP_TRACE_DEBUG_SYMBIAN((_L("REComSession::FinalClose(): ready")));
|
|
278 |
|
26
|
279 |
}
|
|
280 |
|
|
281 |
//----------------------------------------------------------------------------
|
|
282 |
|
|
283 |
// from CServer
|
|
284 |
|
34
|
285 |
CSession2* CEapServer::NewSessionL(const TVersion& /* aVersion */, const RMessage2& /* aMessage */) const
|
26
|
286 |
{
|
|
287 |
EAP_TRACE_DEBUG(
|
|
288 |
iTools,
|
|
289 |
TRACE_FLAGS_DEFAULT,
|
|
290 |
(EAPL("CEapServer::NewSessionL(): starts\n")));
|
|
291 |
|
|
292 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::NewSessionL()");
|
|
293 |
|
|
294 |
CEapSession* session = new(ELeave) CEapSession();
|
|
295 |
CleanupStack::PushL(session);
|
|
296 |
|
|
297 |
EAP_TRACE_DEBUG(
|
|
298 |
iTools,
|
|
299 |
TRACE_FLAGS_DEFAULT,
|
|
300 |
(EAPL("CEapServer::NewSessionL(): session=0x%08x\n"),
|
|
301 |
session));
|
|
302 |
|
|
303 |
EAP_TRACE_DEBUG(
|
|
304 |
iTools,
|
|
305 |
TRACE_FLAGS_DEFAULT,
|
|
306 |
(EAPL("CEapServer::NewSessionL(): session->ConstructL() starts")));
|
|
307 |
|
|
308 |
session->ConstructL(*const_cast<CEapServer*>(this), iTools);
|
|
309 |
|
|
310 |
EAP_TRACE_DEBUG(
|
|
311 |
iTools,
|
|
312 |
TRACE_FLAGS_DEFAULT,
|
|
313 |
(EAPL("CEapServer::NewSessionL(): session->ConstructL() ends")));
|
|
314 |
|
|
315 |
CleanupStack::Pop(session);
|
|
316 |
|
|
317 |
const_cast<CEapServer*>(this)->IncrementSessions();
|
|
318 |
|
|
319 |
return session;
|
|
320 |
}
|
|
321 |
|
|
322 |
//----------------------------------------------------------------------------
|
|
323 |
|
|
324 |
TInt CEapServer::RunError(TInt aErr)
|
|
325 |
/**
|
|
326 |
Handle leaves from ServiceL.
|
|
327 |
|
|
328 |
Any leave from a ServiceL() will land up here.
|
|
329 |
*/
|
|
330 |
{
|
|
331 |
EAP_TRACE_DEBUG(
|
|
332 |
iTools,
|
|
333 |
TRACE_FLAGS_DEFAULT,
|
|
334 |
(EAPL("CEapServer::RunError(), aErr=%d\n"),
|
|
335 |
aErr));
|
|
336 |
|
|
337 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::RunError()");
|
|
338 |
|
|
339 |
// if it's a bad descriptor, panic the client
|
|
340 |
if (aErr==KErrBadDescriptor) // client had a bad descriptor
|
|
341 |
{
|
|
342 |
PanicClient(EBadDescriptor);
|
|
343 |
}
|
|
344 |
|
|
345 |
// anyway, complete the outstanding message
|
|
346 |
Message().Complete(aErr);
|
|
347 |
ReStart(); // really means just continue reading client requests
|
|
348 |
return KErrNone;
|
|
349 |
}
|
|
350 |
|
|
351 |
//----------------------------------------------------------------------------
|
|
352 |
|
|
353 |
/**
|
|
354 |
session count support
|
|
355 |
*/
|
|
356 |
void CEapServer::IncrementSessions()
|
|
357 |
{
|
|
358 |
iSessionCount++;
|
|
359 |
|
|
360 |
EAP_TRACE_DEBUG(
|
|
361 |
iTools,
|
|
362 |
TRACE_FLAGS_DEFAULT,
|
|
363 |
(EAPL("CEapServer::IncrementSessions(): iSessionCount=%d\n"),
|
|
364 |
iSessionCount));
|
|
365 |
|
|
366 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::IncrementSessions()");
|
|
367 |
|
|
368 |
iShutdown->Cancel();
|
|
369 |
}
|
|
370 |
|
|
371 |
//----------------------------------------------------------------------------
|
|
372 |
|
|
373 |
void CEapServer::DecrementSessions()
|
|
374 |
{
|
|
375 |
EAP_TRACE_DEBUG(
|
|
376 |
iTools,
|
|
377 |
TRACE_FLAGS_DEFAULT,
|
|
378 |
(EAPL("CEapServer::DecrementSessions(): iSessionCount=%d\n"),
|
|
379 |
iSessionCount));
|
|
380 |
|
|
381 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::DecrementSessions()");
|
|
382 |
|
|
383 |
iSessionCount--;
|
|
384 |
if (iSessionCount>0)
|
|
385 |
return;
|
|
386 |
|
|
387 |
iShutdown->Start();
|
|
388 |
}
|
|
389 |
|
|
390 |
//----------------------------------------------------------------------------
|
|
391 |
|
|
392 |
void CEapServer::PanicClient(TInt aPanic) const
|
|
393 |
{
|
34
|
394 |
EAP_UNREFERENCED_PARAMETER(aPanic);
|
26
|
395 |
EAP_TRACE_DEBUG(
|
|
396 |
iTools,
|
|
397 |
TRACE_FLAGS_DEFAULT,
|
|
398 |
(EAPL("CEapServer::PanicClient(): aPanic=%d\n"),
|
|
399 |
aPanic));
|
|
400 |
|
|
401 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::PanicClient()");
|
|
402 |
|
|
403 |
// let's have a look before we panic the client
|
|
404 |
__DEBUGGER()
|
|
405 |
// ok, go for it
|
|
406 |
|
|
407 |
const TBufC<KMaxCategoryLength> aCategory;
|
|
408 |
Message().Panic(aCategory, EBadRequest);
|
|
409 |
}
|
|
410 |
|
|
411 |
//----------------------------------------------------------------------------
|
|
412 |
|
|
413 |
void CEapServer::StopL()
|
|
414 |
{
|
|
415 |
EAP_TRACE_DEBUG(
|
|
416 |
iTools,
|
|
417 |
TRACE_FLAGS_DEFAULT,
|
|
418 |
(EAPL("CEapServer::StopL()\n")));
|
|
419 |
|
|
420 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::StopL()");
|
|
421 |
|
|
422 |
for (iSessionIter.SetToFirst(); iSessionIter; iSessionIter++)
|
|
423 |
{
|
|
424 |
CSession2 * aSession = iSessionIter;
|
|
425 |
|
|
426 |
EAP_TRACE_DEBUG(
|
|
427 |
iTools,
|
|
428 |
TRACE_FLAGS_DEFAULT,
|
|
429 |
(EAPL("CEapServer::StopL(): aSession=0x%08x calls CancelReceive()\n"),
|
|
430 |
aSession));
|
|
431 |
|
27
|
432 |
if (static_cast<CEapSession *>(aSession) != NULL)
|
26
|
433 |
{
|
27
|
434 |
static_cast<CEapSession *>(aSession)->CancelReceive();
|
26
|
435 |
}
|
|
436 |
}
|
|
437 |
}
|
|
438 |
|
|
439 |
//----------------------------------------------------------------------------
|
|
440 |
|
|
441 |
void CEapServer::BackupOrRestoreCompleteL()
|
|
442 |
{
|
|
443 |
EAP_TRACE_DEBUG(
|
|
444 |
iTools,
|
|
445 |
TRACE_FLAGS_DEFAULT,
|
|
446 |
(EAPL("ERROR: CEapServer::BackupOrRestoreCompleteL(): Do something\n")));
|
|
447 |
|
|
448 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::BackupOrRestoreCompleteL()");
|
|
449 |
}
|
|
450 |
|
|
451 |
//----------------------------------------------------------------------------
|
|
452 |
|
|
453 |
void CEapServer::BackupOrRestoreStartingL()
|
|
454 |
{
|
|
455 |
EAP_TRACE_DEBUG(
|
|
456 |
iTools,
|
|
457 |
TRACE_FLAGS_DEFAULT,
|
|
458 |
(EAPL("WARNING: CEapServer::BackupOrRestoreStartingL(): Terminates EAP-SERVER. All sessions are also closed. All files are unlocked for backup or restore.\n")));
|
|
459 |
|
|
460 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::BackupOrRestoreStartingL()");
|
|
461 |
|
|
462 |
StopL();
|
|
463 |
}
|
|
464 |
|
49
|
465 |
// -----------------------------------------------------------------------------------------
|
|
466 |
|
|
467 |
TInt CEapServer::AddReadyHandler(CEapServerProcessHandler * const handler)
|
|
468 |
{
|
|
469 |
EAP_TRACE_DEBUG(
|
|
470 |
iTools,
|
|
471 |
TRACE_FLAGS_DEFAULT,
|
|
472 |
(EAPL("CEapServer::AddReadyHandler(): this=0x%08x: handler=0x%08x\n"),
|
|
473 |
this,
|
|
474 |
handler));
|
|
475 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::AddReadyHandler()");
|
|
476 |
|
|
477 |
TInt aCount = iReadyHandlers.Count();
|
|
478 |
|
|
479 |
if (aCount > 0)
|
|
480 |
{
|
|
481 |
EAP_TRACE_DEBUG(
|
|
482 |
iTools,
|
|
483 |
TRACE_FLAGS_DEFAULT,
|
|
484 |
(EAPL("CEapServer::AddReadyHandler(): this=0x%08x: iReadyHandlers[0]=0x%08x\n"),
|
|
485 |
this,
|
|
486 |
iReadyHandlers[0]));
|
|
487 |
}
|
|
488 |
|
|
489 |
TInt error = iReadyHandlers.Append(handler);
|
|
490 |
if (error != KErrNone)
|
|
491 |
{
|
|
492 |
EAP_TRACE_DEBUG(
|
|
493 |
iTools,
|
|
494 |
TRACE_FLAGS_DEFAULT,
|
|
495 |
(EAPL("ERROR: CEapServer::AddReadyHandler(): Cannot append handler, error = %d\n"),
|
|
496 |
error));
|
|
497 |
}
|
|
498 |
|
|
499 |
if (aCount == 0
|
|
500 |
&& error == KErrNone)
|
|
501 |
{
|
|
502 |
EAP_TRACE_DEBUG(
|
|
503 |
iTools,
|
|
504 |
TRACE_FLAGS_DEFAULT,
|
|
505 |
(EAPL("CEapServer::AddReadyHandler(): this=0x%08x: Activates handler=0x%08x\n"),
|
|
506 |
this,
|
|
507 |
handler));
|
|
508 |
|
|
509 |
// Acticate the first handler.
|
|
510 |
handler->Activate(EapServerProcessHandlerState_All);
|
|
511 |
}
|
|
512 |
|
|
513 |
return error;
|
|
514 |
}
|
|
515 |
|
|
516 |
// -----------------------------------------------------------------------------------------
|
|
517 |
|
|
518 |
TInt CEapServer::CompleteReadyHandler(CEapServerProcessHandler * const handler)
|
|
519 |
{
|
|
520 |
EAP_TRACE_DEBUG(
|
|
521 |
iTools,
|
|
522 |
TRACE_FLAGS_DEFAULT,
|
|
523 |
(EAPL("CEapServer::CompleteReadyHandler(): this=0x%08x: handler=0x%08x\n"),
|
|
524 |
this,
|
|
525 |
handler));
|
|
526 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::CompleteReadyHandler()");
|
|
527 |
|
|
528 |
TInt aCount = iReadyHandlers.Count();
|
|
529 |
|
|
530 |
TInt error(KErrNone);
|
|
531 |
|
|
532 |
if (aCount == 0)
|
|
533 |
{
|
|
534 |
EAP_TRACE_DEBUG(
|
|
535 |
iTools,
|
|
536 |
TRACE_FLAGS_DEFAULT,
|
|
537 |
(EAPL("CEapServer::CompleteReadyHandler(): this=0x%08x, no handlers ready.\n"),
|
|
538 |
this,
|
|
539 |
handler));
|
|
540 |
}
|
|
541 |
else if (iReadyHandlers[0] != handler)
|
|
542 |
{
|
|
543 |
EAP_TRACE_DEBUG(
|
|
544 |
iTools,
|
|
545 |
TRACE_FLAGS_DEFAULT,
|
|
546 |
(EAPL("ERROR: CEapServer::CompleteReadyHandler(): this=0x%08x, handler=0x%08x is not the first one 0x%08x\n"),
|
|
547 |
this,
|
|
548 |
handler,
|
|
549 |
iReadyHandlers[0]));
|
|
550 |
|
|
551 |
error = KErrGeneral;
|
|
552 |
}
|
|
553 |
else
|
|
554 |
{
|
|
555 |
iReadyHandlers.Remove(0);
|
|
556 |
|
|
557 |
aCount = iReadyHandlers.Count();
|
|
558 |
|
|
559 |
if (aCount > 0)
|
|
560 |
{
|
|
561 |
EAP_TRACE_DEBUG(
|
|
562 |
iTools,
|
|
563 |
TRACE_FLAGS_DEFAULT,
|
|
564 |
(EAPL("CEapServer::CompleteReadyHandler(): this=0x%08x, Activates handler=0x%08x\n"),
|
|
565 |
this,
|
|
566 |
iReadyHandlers[0]));
|
|
567 |
|
|
568 |
// Activate the next handler.
|
|
569 |
iReadyHandlers[0]->Activate(EapServerProcessHandlerState_All);
|
|
570 |
}
|
|
571 |
}
|
|
572 |
|
|
573 |
return error;
|
|
574 |
}
|
|
575 |
|
|
576 |
// -----------------------------------------------------------------------------------------
|
|
577 |
|
|
578 |
TInt CEapServer::CancelReadyHandler(CEapServerProcessHandler * const handler)
|
|
579 |
{
|
|
580 |
EAP_TRACE_DEBUG(
|
|
581 |
iTools,
|
|
582 |
TRACE_FLAGS_DEFAULT,
|
|
583 |
(EAPL("CEapServer::CancelReadyHandler(): this=0x%08x: handler=0x%08x\n"),
|
|
584 |
this,
|
|
585 |
handler));
|
|
586 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapServer::CancelReadyHandler()");
|
|
587 |
|
|
588 |
TInt index(0);
|
|
589 |
TInt aCount = iReadyHandlers.Count();
|
|
590 |
|
|
591 |
while (index < aCount)
|
|
592 |
{
|
|
593 |
if (iReadyHandlers[index] != handler)
|
|
594 |
{
|
|
595 |
EAP_TRACE_DEBUG(
|
|
596 |
iTools,
|
|
597 |
TRACE_FLAGS_DEFAULT,
|
|
598 |
(EAPL("CEapServer::CancelReadyHandler(): Removes iReadyHandlers[%d]=0x%08x\n"),
|
|
599 |
index,
|
|
600 |
iReadyHandlers[index]));
|
|
601 |
|
|
602 |
iReadyHandlers.Remove(index);
|
|
603 |
|
|
604 |
aCount = iReadyHandlers.Count();
|
|
605 |
}
|
|
606 |
else
|
|
607 |
{
|
|
608 |
++index;
|
|
609 |
}
|
|
610 |
} // while()
|
|
611 |
|
|
612 |
return KErrNone;
|
|
613 |
}
|
|
614 |
|
|
615 |
//----------------------------------------------------------------------------
|
|
616 |
//----------------------------------------------------------------------------
|
26
|
617 |
//----------------------------------------------------------------------------
|
|
618 |
|
|
619 |
/*
|
|
620 |
class CEapDelayedShutdown
|
|
621 |
*/
|
|
622 |
|
|
623 |
CEapDelayedShutdown::CEapDelayedShutdown(abs_eap_am_tools_c * const tools, CEapServer * const aServer)
|
|
624 |
: CActive(0)
|
|
625 |
, iTools(tools)
|
|
626 |
, iServer(aServer)
|
|
627 |
{
|
|
628 |
}
|
|
629 |
|
|
630 |
//----------------------------------------------------------------------------
|
|
631 |
|
|
632 |
void CEapDelayedShutdown::ConstructL()
|
|
633 |
{
|
|
634 |
EAP_TRACE_DEBUG(
|
|
635 |
iTools,
|
|
636 |
TRACE_FLAGS_DEFAULT,
|
|
637 |
(EAPL("CEapDelayedShutdown::ConstructL()\n")));
|
|
638 |
|
|
639 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapDelayedShutdown::ConstructL()");
|
|
640 |
|
|
641 |
CActiveScheduler::Add(this);
|
|
642 |
User::LeaveIfError(iTimer.CreateLocal());
|
|
643 |
}
|
|
644 |
|
|
645 |
//----------------------------------------------------------------------------
|
|
646 |
|
|
647 |
CEapDelayedShutdown::~CEapDelayedShutdown()
|
|
648 |
{
|
|
649 |
EAP_TRACE_DEBUG(
|
|
650 |
iTools,
|
|
651 |
TRACE_FLAGS_DEFAULT,
|
|
652 |
(EAPL("CEapDelayedShutdown::~CEapDelayedShutdown()\n")));
|
|
653 |
|
|
654 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapDelayedShutdown::~CEapDelayedShutdown()");
|
|
655 |
|
|
656 |
Cancel();
|
|
657 |
iTimer.Close();
|
|
658 |
}
|
|
659 |
|
|
660 |
//----------------------------------------------------------------------------
|
|
661 |
|
|
662 |
void CEapDelayedShutdown::Start()
|
|
663 |
{
|
|
664 |
EAP_TRACE_DEBUG(
|
|
665 |
iTools,
|
|
666 |
TRACE_FLAGS_DEFAULT,
|
|
667 |
(EAPL("CEapDelayedShutdown::Start()\n")));
|
|
668 |
|
|
669 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapDelayedShutdown::Start()");
|
|
670 |
|
|
671 |
iTimer.After(iStatus, KEapShutdownInterval);
|
|
672 |
SetActive();
|
|
673 |
}
|
|
674 |
|
|
675 |
//----------------------------------------------------------------------------
|
|
676 |
|
|
677 |
void CEapDelayedShutdown::DoCancel()
|
|
678 |
{
|
|
679 |
EAP_TRACE_DEBUG(
|
|
680 |
iTools,
|
|
681 |
TRACE_FLAGS_DEFAULT,
|
|
682 |
(EAPL("CEapDelayedShutdown::DoCancel()\n")));
|
|
683 |
|
|
684 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapDelayedShutdown::DoCancel()");
|
|
685 |
|
|
686 |
iTimer.Cancel();
|
|
687 |
}
|
|
688 |
|
|
689 |
//----------------------------------------------------------------------------
|
|
690 |
|
|
691 |
TInt CEapDelayedShutdown::RunError(TInt aError)
|
|
692 |
{
|
|
693 |
EAP_TRACE_DEBUG(
|
|
694 |
iTools,
|
|
695 |
TRACE_FLAGS_DEFAULT,
|
|
696 |
(EAPL("CEapDelayedShutdown::RunError(): aError=%d, this=0x%08x\n"),
|
|
697 |
aError,
|
|
698 |
this));
|
|
699 |
|
|
700 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapDelayedShutdown::RunError()");
|
|
701 |
|
|
702 |
iTimer.Cancel();
|
|
703 |
|
|
704 |
return aError;
|
|
705 |
}
|
|
706 |
|
|
707 |
//----------------------------------------------------------------------------
|
|
708 |
|
|
709 |
void CEapDelayedShutdown::RunL()
|
|
710 |
{
|
|
711 |
EAP_TRACE_DEBUG(
|
|
712 |
iTools,
|
|
713 |
TRACE_FLAGS_DEFAULT,
|
|
714 |
(EAPL("CEapDelayedShutdown::RunL(), calls CActiveScheduler::Stop()\n")));
|
|
715 |
|
|
716 |
EAP_TRACE_RETURN_STRING(iTools, "returns: CEapDelayedShutdown::RunL()");
|
|
717 |
|
|
718 |
CActiveScheduler::Stop();
|
|
719 |
}
|
|
720 |
|
|
721 |
//----------------------------------------------------------------------------
|
|
722 |
|
|
723 |
// end
|