|
1 /* |
|
2 * Copyright (c) 2002-2006 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: Implementation of HotSpot Plugin Server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <e32std.h> |
|
25 #include <f32file.h> |
|
26 #include <wlanmgmtclient.h> |
|
27 #include <wlanmgmtinterface.h> |
|
28 #include <e32std.h> |
|
29 #include <commsdattypesv1_1.h> |
|
30 |
|
31 #include <cmconnectionmethodext.h> |
|
32 #include <cmconnectionmethoddef.h> |
|
33 #include <cmpluginwlandef.h> |
|
34 #include <cmmanagerext.h> |
|
35 #include <cmmanagerdef.h> |
|
36 #include <cmdestinationext.h> |
|
37 |
|
38 #include "hotspotserver.h" |
|
39 #include "am_debug.h" |
|
40 #include "hotspotsession.h" |
|
41 #include "hssclientplugin.h" |
|
42 #include "hssiapsettingshandler.h" |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 GLDEF_C TInt E32Main(); |
|
46 |
|
47 using namespace CMManager; |
|
48 |
|
49 // CONSTANTS |
|
50 // Panic codes for HotSpot server |
|
51 const TInt KHotSpotPanicCleanupStackCreationFailed = 1; |
|
52 const TInt KHotSpotPanicOpenSemaforeFailed = 2; |
|
53 const TInt KHotSpotPanicCreationOfSchedulerFailed = 3; |
|
54 |
|
55 // Default timeout values |
|
56 |
|
57 const TUint KMillion = 1000000; |
|
58 const TUint KHssDefaultLoginTimeMicroSecs = 180 * KMillion; // 180 seconds (3 mins) |
|
59 const TUint KHssMinLoginTime = 5; // 5 seconds |
|
60 const TUint KHssMaxLoginTime = 1200; // 1200 seconds (20 mins) |
|
61 const TUint KHssDefaultLogoutTimeMicroSecs = 12 * KMillion; // 12 seconds |
|
62 const TUint KHssMinLogoutTime = 1; // 1 seconds |
|
63 const TUint KHssMaxLogoutTime = 30; // 30 seconds |
|
64 |
|
65 // Panic category of HotSpot server |
|
66 _LIT( KHotSpotModuleName, "HOTSPOTSRV" ); |
|
67 |
|
68 // ============================= LOCAL FUNCTIONS =============================== |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // RunServerL |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 static void RunServerL() |
|
75 { |
|
76 User::LeaveIfError( User::RenameThread( KHotSpotServerName ) ); |
|
77 |
|
78 CActiveScheduler* s=new(ELeave) CActiveScheduler; |
|
79 if ( !s ) |
|
80 { |
|
81 User::Panic( KHotSpotModuleName, KHotSpotPanicCreationOfSchedulerFailed ); |
|
82 } |
|
83 CleanupStack::PushL(s); |
|
84 CActiveScheduler::Install(s); |
|
85 |
|
86 CHotSpotServer::NewLC(); // Is NewLC: Server was pushed into cleanup stack. |
|
87 |
|
88 RSemaphore started; |
|
89 TInt err = started.CreateGlobal( KHotSpotServerSemaphore, 0 ); |
|
90 if ( err != KErrNone ) |
|
91 { |
|
92 err = started.OpenGlobal( KHotSpotServerSemaphore ); |
|
93 } |
|
94 |
|
95 __ASSERT_ALWAYS( |
|
96 err == KErrNone, |
|
97 User::Panic( KHotSpotModuleName, KHotSpotPanicOpenSemaforeFailed ) |
|
98 ); |
|
99 |
|
100 // lets everyone know that the thread is ready to deal with requests |
|
101 RProcess::Rendezvous(KErrNone); |
|
102 |
|
103 started.Signal(); |
|
104 started.Close(); |
|
105 |
|
106 DEBUG("**** HotspotServer: server fully running"); |
|
107 CActiveScheduler::Start(); |
|
108 CleanupStack::PopAndDestroy( 2, s ); // Cleanup both server and scheduler |
|
109 REComSession::FinalClose(); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // PanicClient |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void PanicClient(const RMessagePtr2& aMessage,THotspotPanic aPanic) |
|
117 { |
|
118 _LIT(KPanic,"HotspotServer"); |
|
119 aMessage.Panic(KPanic,aPanic); |
|
120 } |
|
121 |
|
122 // ============================ MEMBER FUNCTIONS =============================== |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CHotSpotServer |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 CHotSpotServer::CHotSpotServer() |
|
129 :CPolicyServer( EPriorityStandard, THotSpotServerPlatSecPolicy, ESharableSessions ) |
|
130 { |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // NewLC |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 CHotSpotServer* CHotSpotServer::NewLC() |
|
138 { |
|
139 DEBUG("**** HotSpotServer: CHotSpotServer::NewLC"); |
|
140 CHotSpotServer* self = new(ELeave) CHotSpotServer; |
|
141 CleanupStack::PushL(self); |
|
142 self->ConstructL(); |
|
143 return self; |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // ~CHotSpotServer |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 CHotSpotServer::~CHotSpotServer() |
|
151 { |
|
152 DEBUG("**** HotSpotServer: CHotSpotServer::~CHotSpotServer"); |
|
153 |
|
154 iMap.Close(); |
|
155 iNotificationArray.Close(); |
|
156 iLoginLogoutTimerArray.Close(); |
|
157 |
|
158 if ( iMgtClient != NULL ) |
|
159 { |
|
160 #ifndef __WINS__ |
|
161 iMgtClient->CancelNotifications(); |
|
162 #endif |
|
163 delete iMgtClient; |
|
164 } |
|
165 iMgtClient = NULL; |
|
166 |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // ConstructL |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CHotSpotServer::ConstructL() |
|
174 { |
|
175 |
|
176 DEBUG("**** HotSpotServer: CHotSpotServer::ConstructL"); |
|
177 StartL( KHotSpotServerName ); |
|
178 |
|
179 iIapCheckValue = EFalse; |
|
180 iLogoutSent = EFalse; |
|
181 iLoginValue = ETrue; |
|
182 iAssociationValue = EFalse; |
|
183 |
|
184 #ifndef __WINS__ |
|
185 |
|
186 // Change config daemon for Easy WLAN access point |
|
187 iConfigDaemonChanged = KErrNone; |
|
188 TBool retVal( EFalse ); |
|
189 iEasyWlanId = KEasyWlanServiceId; // Set to default value |
|
190 TRAPD( leave, retVal = EasyWlanIdL() ); |
|
191 if ( KErrNone != leave ) |
|
192 { |
|
193 iConfigDaemonChanged = leave; |
|
194 } |
|
195 if ( !retVal ) |
|
196 { |
|
197 iConfigDaemonChanged = KErrGeneral; |
|
198 } |
|
199 DEBUG1("**** HotSpotServer: CHotSpotServer::ConstructL iConfigDaemonChanged: %d", iConfigDaemonChanged ); |
|
200 #endif |
|
201 // Activate notifications for IAP check purposes |
|
202 // When EWlanConnectionModeNotConnected is received we can cancel this and |
|
203 // we know that it safe to go through IAPs. |
|
204 iMgtClient = CWlanMgmtClient::NewL(); |
|
205 #ifndef __WINS__ |
|
206 iMgtClient->ActivateNotificationsL( *this ); |
|
207 #endif |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // ConnectionStateChanged |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CHotSpotServer::ConnectionStateChanged( TWlanConnectionMode aNewState ) |
|
215 { |
|
216 DEBUG1( "CHotSpotServer::ConnectionStateChanged() aNewState=%d", aNewState ); |
|
217 if ( aNewState == EWlanConnectionModeNotConnected ) |
|
218 { |
|
219 if ( iMgtClient != NULL ) |
|
220 { |
|
221 #ifndef __WINS__ |
|
222 iMgtClient->CancelNotifications(); |
|
223 #endif |
|
224 DEBUG("CHotSpotServer::ConnectionStateChanged2"); |
|
225 } |
|
226 |
|
227 TRAPD(err, CheckIapsL()); |
|
228 if ( err != KErrNone ) |
|
229 { |
|
230 DEBUG1("CHotSpotServer::ConnectionStateChanged(): %d", err); |
|
231 } |
|
232 if ( iConfigDaemonChanged != KErrNone ) |
|
233 { |
|
234 // ConstructL call leaved. Let's call again once more. |
|
235 TRAP_IGNORE( EasyWlanIdL() ); |
|
236 } |
|
237 } |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CheckIapsL |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CHotSpotServer::CheckIapsL() |
|
245 { |
|
246 DEBUG("CHotSpotServer::CheckIapsL"); |
|
247 |
|
248 _LIT(KMarkFirst, "[" ); |
|
249 _LIT(KMarkLast, "]" ); |
|
250 // This is needed to be checked only once per boot |
|
251 if ( iIapCheckValue == EFalse ) |
|
252 { |
|
253 iIapCheckValue = ETrue; |
|
254 |
|
255 RCmManagerExt cmManager; |
|
256 cmManager.OpenL(); |
|
257 CleanupClosePushL(cmManager); |
|
258 |
|
259 TBool supportedBearersOnly = ETrue; |
|
260 TBool legacyCmsOnly = EFalse; |
|
261 |
|
262 RArray<TUint32> cmArray; |
|
263 CleanupClosePushL( cmArray ); |
|
264 |
|
265 cmManager.ConnectionMethodL( cmArray, supportedBearersOnly, legacyCmsOnly ); |
|
266 DEBUG1("CHotSpotServer::CheckIapsL count: %d", cmArray.Count()); |
|
267 for( TInt i = 0; i < cmArray.Count(); i++ ) |
|
268 { |
|
269 RCmConnectionMethodExt cm; |
|
270 TRAPD( err, cm = cmManager.ConnectionMethodL( cmArray[i] ) ); |
|
271 DEBUG1("CHotSpotServer::CheckIapsL: err %d", err ); |
|
272 if ( KErrNone == err ) |
|
273 { |
|
274 HBufC* client( NULL ); |
|
275 TRAPD( errr, client = cm.GetStringAttributeL( EWlanServiceExtensionTableName )); |
|
276 DEBUG1("CHotSpotServer::CheckIapsL: errr %d", errr ); |
|
277 if( KErrNone == errr ) |
|
278 { |
|
279 TBuf<KIapNameLength> clientUid; |
|
280 TUid uid(TUid::Null()); |
|
281 |
|
282 clientUid.Copy( client->Des() ); |
|
283 delete client; |
|
284 TInt indx = clientUid.Find( KMarkFirst ); |
|
285 if ( KErrNotFound != indx ) |
|
286 { |
|
287 DEBUG("CHotSpotServer::CheckIapsL Client is found"); |
|
288 clientUid.Delete( indx, 1 ); |
|
289 indx = clientUid.Find( KMarkLast ); |
|
290 if ( KErrNotFound != indx ) |
|
291 { |
|
292 clientUid.Delete( indx, 1 ); |
|
293 } |
|
294 // Convert TBuf to TUid |
|
295 TLex lex( clientUid ); |
|
296 TUint value( 0 ); |
|
297 User::LeaveIfError( lex.Val( value, EHex ) ); |
|
298 uid.iUid = value; |
|
299 |
|
300 // Try to find if 3rd party client exists. |
|
301 // Delete IAP if no client. |
|
302 CHssClientPlugin* plugin(NULL); |
|
303 TBuf8<KExtensionAPILength> nullBuf; |
|
304 TRAPD( error, plugin = CHssClientPlugin::NewL( uid, nullBuf ) ); |
|
305 delete plugin; |
|
306 |
|
307 DEBUG1("CHotSpotServer::CheckIapsL find client error: %d", error ); |
|
308 if ( error == KErrNotFound ) |
|
309 { |
|
310 cm.DeleteL(); |
|
311 } |
|
312 } |
|
313 } |
|
314 } |
|
315 DEBUG("CHotSpotServer::CheckIapsLOK"); |
|
316 } |
|
317 CleanupStack::PopAndDestroy( &cmArray ); |
|
318 CleanupStack::PopAndDestroy( &cmManager ); |
|
319 } |
|
320 DEBUG("CHotSpotServer::CheckIapsL Done"); |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // NewSessionL |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 CSession2* CHotSpotServer::NewSessionL( const TVersion& aVersion, |
|
328 const RMessage2& /* aMessage */ ) const |
|
329 { |
|
330 TVersion version( KHotSpotMajorVersionNumber, |
|
331 KHotSpotMinorVersionNumber, |
|
332 KHotSpotBuildVersionNumber ); |
|
333 |
|
334 if ( !User::QueryVersionSupported( version, aVersion ) ) |
|
335 { |
|
336 User::Leave( KErrNotSupported ); |
|
337 } |
|
338 |
|
339 DEBUG("**** CHotSpotServer::NewSessionL"); |
|
340 CHotSpotSession* session = |
|
341 CHotSpotSession::NewL( const_cast<CHotSpotServer&>( *this ) ); |
|
342 return session; |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------- |
|
346 // NotifyAdd |
|
347 // --------------------------------------------------------- |
|
348 // |
|
349 void CHotSpotServer::NotifyAdd( |
|
350 CNotificationBase& aNotification ) |
|
351 { |
|
352 DEBUG( "CHotSpotServer::NotifyAdd()" ); |
|
353 iNotificationArray.Insert( &aNotification, 0 ); |
|
354 } |
|
355 |
|
356 // --------------------------------------------------------- |
|
357 // NotifyRemove |
|
358 // --------------------------------------------------------- |
|
359 // |
|
360 void CHotSpotServer::NotifyRemove( |
|
361 CNotificationBase& aNotification ) |
|
362 { |
|
363 DEBUG( "CHotSpotServer::NotifyRemove()" ); |
|
364 TInt index = iNotificationArray.Find( &aNotification ); |
|
365 iNotificationArray.Remove( index ); |
|
366 } |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // SaveMessage |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 TInt CHotSpotServer::SaveMessage( TUint aIapId, const RMessage2& aMessage, |
|
373 THotSpotCommands aCommand ) |
|
374 { |
|
375 DEBUG("**** HotspotServer: SaveMessage"); |
|
376 TInt ret( KErrNone ); |
|
377 SRequestMapEntry entry; |
|
378 entry.iMessage = aMessage; |
|
379 entry.iFunction = aCommand; |
|
380 entry.iIapId = aIapId; |
|
381 ret = iMap.Append(entry); |
|
382 return ret; |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CompleteMessage |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 void CHotSpotServer::CompleteMessage( TInt aIndex, TInt aResult ) |
|
390 { |
|
391 DEBUG("**** HotspotServer: CompleteMessage"); |
|
392 SRequestMapEntry entry = iMap[aIndex]; |
|
393 |
|
394 RMessagePtr2 message = entry.iMessage; |
|
395 message.Complete( aResult ); |
|
396 iMap.Remove( aIndex ); |
|
397 } |
|
398 |
|
399 // ----------------------------------------------------------------------------- |
|
400 // EditMessage |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 TInt CHotSpotServer::EditMessage( TInt aIndex, TPckg<HssScanList>& aData) |
|
404 { |
|
405 DEBUG("**** HotspotServer: EditMessage"); |
|
406 TInt ret( KErrNone ); |
|
407 |
|
408 iMap[aIndex].iMessage.Write(0, aData); |
|
409 |
|
410 DEBUG1("**** HotspotServer: EditMessage ret: %d", ret); |
|
411 return ret; |
|
412 } |
|
413 |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // FindMessage |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 TInt CHotSpotServer::FindMessage( TUint aIapId, THotSpotCommands aCommand ) |
|
420 { |
|
421 DEBUG("**** HotspotServer: FindMessage"); |
|
422 TInt ret( KErrNotFound ); |
|
423 SRequestMapEntry entry; |
|
424 |
|
425 for ( TInt i = 0; i < iMap.Count(); i++ ) |
|
426 { |
|
427 entry = iMap[i]; |
|
428 if ( ( entry.iFunction == aCommand ) && ( entry.iIapId == aIapId ) ) |
|
429 { |
|
430 // Correct message found |
|
431 // Now stop loop and return index value, so that CompeteMessage can |
|
432 // be called with that |
|
433 ret = i; |
|
434 i = iMap.Count(); |
|
435 } |
|
436 } |
|
437 DEBUG1("**** HotspotServer: FindMessage ret: %d", ret); |
|
438 return ret; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // SetLogoutFlag |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CHotSpotServer::SetLogoutFlag( TBool aValue ) |
|
446 { |
|
447 DEBUG("HotspotServer::SetLogoutFlag"); |
|
448 iLogoutSent = aValue; |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // GetLogoutFlagValue |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 TBool CHotSpotServer::GetLogoutFlagValue() |
|
456 { |
|
457 DEBUG("HotspotServer::GetLogoutFlagValue()"); |
|
458 return iLogoutSent; |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // SetLoginFlag |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 void CHotSpotServer::SetLoginFlag( TBool aValue ) |
|
466 { |
|
467 DEBUG("HotspotServer::SetLoginFlag"); |
|
468 iLoginValue = aValue; |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // GetLoginFlagValue |
|
473 // ----------------------------------------------------------------------------- |
|
474 // |
|
475 TBool CHotSpotServer::GetLoginFlagValue() |
|
476 { |
|
477 DEBUG("HotspotServer::GetLoginFlagValue()"); |
|
478 return iLoginValue; |
|
479 } |
|
480 |
|
481 |
|
482 // ----------------------------------------------------------------------------- |
|
483 // SetAssociationFlag |
|
484 // ----------------------------------------------------------------------------- |
|
485 // |
|
486 void CHotSpotServer::SetAssociationFlag( TBool aValue ) |
|
487 { |
|
488 DEBUG("HotspotServer::SetAssociationFlag"); |
|
489 iAssociationValue = aValue; |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // GetAssociationFlagValue |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 TBool CHotSpotServer::GetAssociationFlagValue() |
|
497 { |
|
498 DEBUG("HotspotServer::GetAssociationFlagValue()"); |
|
499 return iAssociationValue; |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // SetServiceId |
|
504 // ----------------------------------------------------------------------------- |
|
505 // |
|
506 void CHotSpotServer::SetServiceId( TInt aServiceId ) |
|
507 { |
|
508 DEBUG("HotspotServer::SetServiceId"); |
|
509 iCurrentServiceIdInUse = aServiceId; |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // GetServiceId |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 TInt CHotSpotServer::GetServiceId() |
|
517 { |
|
518 DEBUG("HotspotServer::GetServiceId()"); |
|
519 return iCurrentServiceIdInUse; |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // RunError |
|
524 // ----------------------------------------------------------------------------- |
|
525 // |
|
526 TInt CHotSpotServer::RunError( TInt aError ) |
|
527 { |
|
528 // error from CHotSpotSession::ServiceL |
|
529 Message().Complete( aError ); |
|
530 // Continue reading client requests |
|
531 ReStart(); |
|
532 return (KErrNone); |
|
533 } |
|
534 |
|
535 // ----------------------------------------------------------------------------- |
|
536 // EasyWlanIdL |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 TBool CHotSpotServer::EasyWlanIdL() |
|
540 { |
|
541 TBool ret( EFalse ); |
|
542 DEBUG("CHotSpotServer::EasyWlanIdL()"); |
|
543 RCmManagerExt cmManager; |
|
544 cmManager.OpenL(); |
|
545 CleanupClosePushL( cmManager ); |
|
546 |
|
547 iEasyWlanId = cmManager.EasyWlanIdL(); |
|
548 DEBUG1("CHotSpotServer::EasyWlanIdL() ret: % d", iEasyWlanId); |
|
549 // if iEasyWlanId is 0, then it was not found |
|
550 if ( iEasyWlanId > 0 ) |
|
551 { |
|
552 RCmConnectionMethodExt plugin = cmManager.ConnectionMethodL( iEasyWlanId ); |
|
553 CleanupClosePushL( plugin ); |
|
554 //iEasyWlanId = plugin.GetIntAttributeL( /*ECmIapServiceId*/EWlanServiceId ) |
|
555 plugin.SetStringAttributeL( ECmConfigDaemonManagerName, KHotSpotPlugin ); |
|
556 // commit changes |
|
557 plugin.UpdateL(); |
|
558 CleanupStack::PopAndDestroy( &plugin ); // Close() called on "plugin" |
|
559 ret = ETrue; |
|
560 } |
|
561 CleanupStack::PopAndDestroy( &cmManager ); |
|
562 DEBUG("CHotSpotServer::EasyWlanIdL() DONE"); |
|
563 return ret; |
|
564 } |
|
565 |
|
566 // ----------------------------------------------------------------------------- |
|
567 // GetEasyWlanId |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 TUint32 CHotSpotServer::GetEasyWlanId() |
|
571 { |
|
572 return iEasyWlanId; |
|
573 } |
|
574 |
|
575 // ----------------------------------------------------------------------------- |
|
576 // GetLoginTimerMicroSecs |
|
577 // ----------------------------------------------------------------------------- |
|
578 // |
|
579 TUint CHotSpotServer::GetLoginTimeMicroSecs( TUid aClientUid ) |
|
580 { |
|
581 // Default timer value will be returned if matching client UID isn't found. |
|
582 TUint retval = KHssDefaultLoginTimeMicroSecs ; |
|
583 |
|
584 TInt ret = CHotSpotServer::FindClientUid( aClientUid ); |
|
585 if (ret != KErrNotFound) |
|
586 { |
|
587 // ret is the matching element's index. |
|
588 retval = iLoginLogoutTimerArray[ret].loginTimeMicroSecs; |
|
589 } |
|
590 |
|
591 return retval; |
|
592 } |
|
593 |
|
594 // ----------------------------------------------------------------------------- |
|
595 // GetLogoutTimerMicroSecs |
|
596 // ----------------------------------------------------------------------------- |
|
597 // |
|
598 TUint CHotSpotServer::GetLogoutTimeMicroSecs( TUid aClientUid ) |
|
599 { |
|
600 // Default timer value will be returned if matching client UID isn't found. |
|
601 TUint retval = KHssDefaultLogoutTimeMicroSecs ; |
|
602 |
|
603 TInt ret = CHotSpotServer::FindClientUid( aClientUid ); |
|
604 if (ret != KErrNotFound) |
|
605 { |
|
606 // ret is the matching element's index. |
|
607 retval = iLoginLogoutTimerArray[ret].logoutTimeMicroSecs; |
|
608 } |
|
609 |
|
610 return retval; |
|
611 } |
|
612 |
|
613 // ----------------------------------------------------------------------------- |
|
614 // SetTimerValues |
|
615 // ----------------------------------------------------------------------------- |
|
616 // |
|
617 void CHotSpotServer::SetTimerValues( |
|
618 TUid aClientUid, |
|
619 TUint aLoginTimerValue, // in seconds |
|
620 TUint aLogoutTimerValue ) // in seconds |
|
621 { |
|
622 TInt ret = CHotSpotServer::FindClientUid( aClientUid ); |
|
623 TUint loginTimeMicroSecs = KHssDefaultLoginTimeMicroSecs ; |
|
624 TUint logoutTimeMicroSecs = KHssDefaultLogoutTimeMicroSecs ; |
|
625 |
|
626 // Check that values are in bounds and modify them into micro seconds. |
|
627 if( aLoginTimerValue >= KHssMinLoginTime && |
|
628 aLoginTimerValue <= KHssMaxLoginTime ) |
|
629 { |
|
630 loginTimeMicroSecs = KMillion * aLoginTimerValue; |
|
631 } |
|
632 |
|
633 if( aLogoutTimerValue >= KHssMinLogoutTime && |
|
634 aLogoutTimerValue <= KHssMaxLogoutTime ) |
|
635 { |
|
636 logoutTimeMicroSecs = KMillion * aLogoutTimerValue; |
|
637 } |
|
638 |
|
639 if (ret != KErrNotFound) |
|
640 { |
|
641 DEBUG("CHotSpotServer::SetTimerValues(): Existing client modified."); |
|
642 // ret is the matching element's index. |
|
643 iLoginLogoutTimerArray[ret].loginTimeMicroSecs = loginTimeMicroSecs; |
|
644 iLoginLogoutTimerArray[ret].logoutTimeMicroSecs = logoutTimeMicroSecs; |
|
645 } |
|
646 else |
|
647 { |
|
648 DEBUG("CHotSpotServer::SetTimerValues(): New Client added."); |
|
649 // Create a new element and append it to the array. |
|
650 const SLoginLogoutTimers addedElement = { |
|
651 aClientUid, |
|
652 loginTimeMicroSecs, |
|
653 logoutTimeMicroSecs }; |
|
654 iLoginLogoutTimerArray.Append( addedElement ); |
|
655 } |
|
656 } |
|
657 |
|
658 // ----------------------------------------------------------------------------- |
|
659 // FindClientUid |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 TInt CHotSpotServer::FindClientUid( TUid aClientUid ) |
|
663 { |
|
664 TInt count = iLoginLogoutTimerArray.Count(); |
|
665 TInt i = 0; |
|
666 TInt ret = KErrNotFound; |
|
667 |
|
668 while (i < count) |
|
669 { |
|
670 if (aClientUid == iLoginLogoutTimerArray[i].clientUid) |
|
671 { |
|
672 ret = i; |
|
673 break; |
|
674 } |
|
675 i++; |
|
676 } |
|
677 |
|
678 return ret; |
|
679 } |
|
680 |
|
681 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
682 |
|
683 // ----------------------------------------------------------------------------- |
|
684 // E32Main implements the executable entry function. |
|
685 // Note that because the target type of the IPWServer Hss |
|
686 // is EXEDLL, the entry point has different signature depending |
|
687 // on the build platform. |
|
688 // Creates a cleanup stack and runs the server. |
|
689 // Returns: Zero |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 GLDEF_C TInt E32Main() |
|
693 { |
|
694 __UHEAP_MARK; |
|
695 DEBUG("**** HotspotServer: E32Main"); |
|
696 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
697 TInt r=KErrNoMemory; |
|
698 if (cleanup) |
|
699 { |
|
700 TRAP(r,RunServerL()); |
|
701 delete cleanup; |
|
702 } |
|
703 else |
|
704 { |
|
705 User::Panic( KHotSpotModuleName, KHotSpotPanicCleanupStackCreationFailed ); |
|
706 } |
|
707 __UHEAP_MARKEND; |
|
708 return r; |
|
709 } |
|
710 |
|
711 // end of file |