71 // RunServerL |
65 // RunServerL |
72 // ----------------------------------------------------------------------------- |
66 // ----------------------------------------------------------------------------- |
73 // |
67 // |
74 static void RunServerL() |
68 static void RunServerL() |
75 { |
69 { |
76 User::LeaveIfError( User::RenameThread( KHotSpotServerName ) ); |
70 // Create and install the active scheduler |
77 |
71 CActiveScheduler *scheduler = new (ELeave) CActiveScheduler; |
78 CActiveScheduler* s=new(ELeave) CActiveScheduler; |
72 CleanupStack::PushL( scheduler ); |
79 if ( !s ) |
73 CActiveScheduler::Install( scheduler ); |
80 { |
74 |
81 User::Panic( KHotSpotModuleName, KHotSpotPanicCreationOfSchedulerFailed ); |
75 // Create server |
82 } |
76 CHotSpotServer::NewLC(); |
83 CleanupStack::PushL(s); |
77 |
84 CActiveScheduler::Install(s); |
78 // Initialisation complete, now signal the client |
85 |
79 User::LeaveIfError( RThread().RenameMe( KHotSpotServerName ) ); |
86 CHotSpotServer::NewLC(); // Is NewLC: Server was pushed into cleanup stack. |
80 RProcess::Rendezvous( KErrNone ); |
87 |
81 |
88 RSemaphore started; |
82 // Ready to run |
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"); |
83 DEBUG("**** HotspotServer: server fully running"); |
107 CActiveScheduler::Start(); |
84 CActiveScheduler::Start(); |
108 CleanupStack::PopAndDestroy( 2, s ); // Cleanup both server and scheduler |
85 |
|
86 // Cleanup the server and scheduler |
|
87 CleanupStack::PopAndDestroy( 2, scheduler ); |
109 REComSession::FinalClose(); |
88 REComSession::FinalClose(); |
110 } |
89 } |
111 |
90 |
112 // ----------------------------------------------------------------------------- |
91 // ----------------------------------------------------------------------------- |
113 // PanicClient |
92 // PanicClient |
200 { |
183 { |
201 #ifndef __WINS__ |
184 #ifndef __WINS__ |
202 iMgtClient->CancelNotifications(); |
185 iMgtClient->CancelNotifications(); |
203 #endif |
186 #endif |
204 } |
187 } |
|
188 if ( iClientIapsChecked != KErrNone ) |
|
189 { |
|
190 TRAP_IGNORE( FindClientIapsL() ); |
|
191 } |
|
192 TRAPD(err, CheckIapsL()); |
|
193 if ( err != KErrNone ) |
|
194 { |
|
195 DEBUG1("CHotSpotServer::ConnectionStateChanged(): %d", err); |
|
196 } |
|
197 } |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // FindClientIapsL |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CHotSpotServer::FindClientIapsL() |
|
205 { |
|
206 DEBUG("CHotSpotServer::FindClientIapsL()"); |
|
207 RCmManagerExt cmManager; |
|
208 cmManager.OpenL(); |
|
209 CleanupClosePushL(cmManager); |
|
210 |
|
211 RArray<TUint32> cmArray; |
|
212 CleanupClosePushL( cmArray ); |
|
213 TBool supportedBearersOnly = ETrue; |
|
214 TBool legacyCmsOnly = EFalse; |
|
215 |
|
216 cmManager.ConnectionMethodL( cmArray, supportedBearersOnly, legacyCmsOnly ); |
|
217 DEBUG1("CHotSpotServer::FindClientIapsL count: %d", cmArray.Count()); |
|
218 |
|
219 for( TInt i = 0; i < cmArray.Count(); i++ ) |
|
220 { |
|
221 RCmConnectionMethodExt cm = cmManager.ConnectionMethodL( cmArray[i] ); |
|
222 CleanupClosePushL( cm ); |
|
223 HBufC* daemonName = cm.GetStringAttributeL( |
|
224 ECmConfigDaemonManagerName ); |
|
225 CleanupStack::PushL( daemonName ); |
|
226 if ( daemonName ) |
|
227 { |
|
228 if ( daemonName->Compare( KHotSpotPlugin ) == 0 ) |
|
229 { |
|
230 DEBUG("CHotSpotServer::FindClientIapsL() Client found"); |
|
231 TBuf<KIapNameLength> clientUid; |
|
232 TUid uid(TUid::Null()); |
|
233 TUint iapId = cm.GetIntAttributeL( ECmIapId ); |
|
234 HBufC* client = cm.GetStringAttributeL( |
|
235 EWlanServiceExtensionTableName ); |
|
236 clientUid.Copy( client->Des() ); |
|
237 delete client; |
|
238 SetClientIap( iapId, clientUid ); |
|
239 DEBUG1("CHotSpotServer::FindClientIapsL() iapId: %d", iapId ); |
|
240 } |
|
241 } |
|
242 CleanupStack::PopAndDestroy( daemonName ); |
|
243 CleanupStack::PopAndDestroy( &cm ); |
|
244 } |
|
245 CleanupStack::PopAndDestroy( &cmArray ); |
|
246 |
|
247 // Read Easy WLAN IAP ID |
|
248 iEasyWlanId = cmManager.EasyWlanIdL(); |
|
249 CleanupStack::PopAndDestroy( &cmManager ); |
|
250 DEBUG1("CHotSpotServer::FindClientIapsL() iEasyWlanId: % d", iEasyWlanId); |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CheckIapsL |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 void CHotSpotServer::CheckIapsL() |
|
258 { |
|
259 DEBUG("CHotSpotServer::CheckIapsL"); |
|
260 // This is needed to be checked only once per boot |
|
261 iIapCheckValue = ETrue; |
|
262 TInt count = iClientIaps.Count(); |
|
263 |
|
264 // Check the array. Not supposed to be many elements. |
|
265 for( TInt i = 0; i < count; i++ ) |
|
266 { |
|
267 TLex lex( iClientIaps[i].iClientUid ); |
|
268 TUint value( 0 ); |
|
269 lex.Val( value, EHex ); |
|
270 TUid client = TUid::Null(); |
|
271 client.iUid = value; |
205 |
272 |
206 TRAPD(err, CheckIapsL()); |
273 // Try to find if plugin exists |
207 if ( err != KErrNone ) |
274 CHssClientPlugin* plugin(NULL); |
208 { |
275 TBuf8<KExtensionAPILength> nullBuf; |
209 DEBUG1("CHotSpotServer::ConnectionStateChanged(): %d", err); |
276 TRAPD( error, plugin = CHssClientPlugin::NewL( client, nullBuf ) ); |
210 } |
277 delete plugin; |
211 } |
278 |
212 } |
279 DEBUG1("CHotSpotServer::CheckIapsL find client error: %d", error ); |
213 |
280 if ( error == KErrNotFound ) |
214 // ----------------------------------------------------------------------------- |
281 { |
215 // CheckIapsL |
282 // Remove from database |
216 // ----------------------------------------------------------------------------- |
283 RCmManagerExt cmManager; |
217 // |
284 cmManager.OpenL(); |
218 void CHotSpotServer::CheckIapsL() |
285 CleanupClosePushL(cmManager); |
219 { |
286 |
220 DEBUG("CHotSpotServer::CheckIapsL"); |
|
221 |
|
222 _LIT(KMarkFirst, "[" ); |
|
223 _LIT(KMarkLast, "]" ); |
|
224 // This is needed to be checked only once per boot |
|
225 if ( iIapCheckValue == EFalse ) |
|
226 { |
|
227 iIapCheckValue = ETrue; |
|
228 |
|
229 RCmManagerExt cmManager; |
|
230 cmManager.OpenL(); |
|
231 CleanupClosePushL(cmManager); |
|
232 |
|
233 TBool supportedBearersOnly = ETrue; |
|
234 TBool legacyCmsOnly = EFalse; |
|
235 |
|
236 RArray<TUint32> cmArray; |
|
237 CleanupClosePushL( cmArray ); |
|
238 |
|
239 cmManager.ConnectionMethodL( cmArray, supportedBearersOnly, legacyCmsOnly ); |
|
240 DEBUG1("CHotSpotServer::CheckIapsL count: %d", cmArray.Count()); |
|
241 for( TInt i = 0; i < cmArray.Count(); i++ ) |
|
242 { |
|
243 RCmConnectionMethodExt cm; |
287 RCmConnectionMethodExt cm; |
244 TRAPD( err, cm = cmManager.ConnectionMethodL( cmArray[i] ) ); |
288 cm = cmManager.ConnectionMethodL( iClientIaps[i].iIapId ); |
245 DEBUG1("CHotSpotServer::CheckIapsL: err %d", err ); |
289 CleanupClosePushL( cm ); |
246 if ( KErrNone == err ) |
290 cmManager.RemoveAllReferencesL( cm ); |
247 { |
291 cm.DeleteL(); |
248 HBufC* client( NULL ); |
292 |
249 TRAPD( errr, client = cm.GetStringAttributeL( EWlanServiceExtensionTableName )); |
293 CleanupStack::PopAndDestroy( &cm ); |
250 DEBUG1("CHotSpotServer::CheckIapsL: errr %d", errr ); |
294 CleanupStack::PopAndDestroy( &cmManager ); |
251 if( KErrNone == errr ) |
295 |
252 { |
296 // Remove from array |
253 TBuf<KIapNameLength> clientUid; |
297 RemoveClientIap( iClientIaps[i].iIapId ); |
254 TUid uid(TUid::Null()); |
298 count--; |
255 |
299 i--; |
256 clientUid.Copy( client->Des() ); |
300 } |
257 delete client; |
|
258 TInt indx = clientUid.Find( KMarkFirst ); |
|
259 if ( KErrNotFound != indx ) |
|
260 { |
|
261 DEBUG("CHotSpotServer::CheckIapsL Client is found"); |
|
262 clientUid.Delete( indx, 1 ); |
|
263 indx = clientUid.Find( KMarkLast ); |
|
264 if ( KErrNotFound != indx ) |
|
265 { |
|
266 clientUid.Delete( indx, 1 ); |
|
267 } |
|
268 // Convert TBuf to TUid |
|
269 TLex lex( clientUid ); |
|
270 TUint value( 0 ); |
|
271 User::LeaveIfError( lex.Val( value, EHex ) ); |
|
272 uid.iUid = value; |
|
273 |
|
274 // Try to find if 3rd party client exists. |
|
275 // Delete IAP if no client. |
|
276 CHssClientPlugin* plugin(NULL); |
|
277 TBuf8<KExtensionAPILength> nullBuf; |
|
278 TRAPD( error, plugin = CHssClientPlugin::NewL( uid, nullBuf ) ); |
|
279 delete plugin; |
|
280 |
|
281 DEBUG1("CHotSpotServer::CheckIapsL find client error: %d", error ); |
|
282 if ( error == KErrNotFound ) |
|
283 { |
|
284 cm.DeleteL(); |
|
285 } |
|
286 } |
|
287 } |
|
288 } |
|
289 DEBUG("CHotSpotServer::CheckIapsLOK"); |
|
290 } |
|
291 CleanupStack::PopAndDestroy( &cmArray ); |
|
292 CleanupStack::PopAndDestroy( &cmManager ); |
|
293 } |
301 } |
294 DEBUG("CHotSpotServer::CheckIapsL Done"); |
302 DEBUG("CHotSpotServer::CheckIapsL Done"); |
295 } |
303 } |
296 |
304 |
297 // ----------------------------------------------------------------------------- |
305 // ----------------------------------------------------------------------------- |
470 TBool CHotSpotServer::GetAssociationFlagValue() |
478 TBool CHotSpotServer::GetAssociationFlagValue() |
471 { |
479 { |
472 DEBUG("HotspotServer::GetAssociationFlagValue()"); |
480 DEBUG("HotspotServer::GetAssociationFlagValue()"); |
473 return iAssociationValue; |
481 return iAssociationValue; |
474 } |
482 } |
475 |
483 |
476 // ----------------------------------------------------------------------------- |
|
477 // SetServiceId |
|
478 // ----------------------------------------------------------------------------- |
|
479 // |
|
480 void CHotSpotServer::SetServiceId( TInt aServiceId ) |
|
481 { |
|
482 DEBUG("HotspotServer::SetServiceId"); |
|
483 iCurrentServiceIdInUse = aServiceId; |
|
484 } |
|
485 |
|
486 // ----------------------------------------------------------------------------- |
|
487 // GetServiceId |
|
488 // ----------------------------------------------------------------------------- |
|
489 // |
|
490 TInt CHotSpotServer::GetServiceId() |
|
491 { |
|
492 DEBUG("HotspotServer::GetServiceId()"); |
|
493 return iCurrentServiceIdInUse; |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
484 // ----------------------------------------------------------------------------- |
497 // RunError |
485 // RunError |
498 // ----------------------------------------------------------------------------- |
486 // ----------------------------------------------------------------------------- |
499 // |
487 // |
500 TInt CHotSpotServer::RunError( TInt aError ) |
488 TInt CHotSpotServer::RunError( TInt aError ) |
501 { |
489 { |
|
490 DEBUG1( "HotspotServer::RunError = %d", aError ); |
502 // error from CHotSpotSession::ServiceL |
491 // error from CHotSpotSession::ServiceL |
503 Message().Complete( aError ); |
492 Message().Complete( aError ); |
504 // Continue reading client requests |
493 // Continue reading client requests |
505 ReStart(); |
494 ReStart(); |
506 return (KErrNone); |
495 return (KErrNone); |
508 |
497 |
509 // ----------------------------------------------------------------------------- |
498 // ----------------------------------------------------------------------------- |
510 // GetLoginTimerMicroSecs |
499 // GetLoginTimerMicroSecs |
511 // ----------------------------------------------------------------------------- |
500 // ----------------------------------------------------------------------------- |
512 // |
501 // |
513 TUint CHotSpotServer::GetLoginTimeMicroSecs( TUid aClientUid ) |
502 TUint CHotSpotServer::GetLoginTimeMicroSecs( TDes& aClientUid ) |
514 { |
503 { |
|
504 DEBUG("HotspotServer::GetLoginTimeMicroSecs()"); |
515 // Default timer value will be returned if matching client UID isn't found. |
505 // Default timer value will be returned if matching client UID isn't found. |
516 TUint retval = KHssDefaultLoginTimeMicroSecs ; |
506 TUint retval = KHssDefaultLoginTimeMicroSecs ; |
517 |
507 |
518 TInt ret = CHotSpotServer::FindClientUid( aClientUid ); |
508 TInt ret = FindClientUid( aClientUid ); |
519 if (ret != KErrNotFound) |
509 if (ret != KErrNotFound) |
520 { |
510 { |
521 // ret is the matching element's index. |
511 // ret is the matching element's index. |
522 retval = iLoginLogoutTimerArray[ret].loginTimeMicroSecs; |
512 retval = iLoginLogoutTimerArray[ret].iLoginTimeMicroSecs; |
523 } |
513 } |
524 |
514 |
525 return retval; |
515 return retval; |
526 } |
516 } |
527 |
517 |
528 // ----------------------------------------------------------------------------- |
518 // ----------------------------------------------------------------------------- |
529 // GetLogoutTimerMicroSecs |
519 // GetLogoutTimerMicroSecs |
530 // ----------------------------------------------------------------------------- |
520 // ----------------------------------------------------------------------------- |
531 // |
521 // |
532 TUint CHotSpotServer::GetLogoutTimeMicroSecs( TUid aClientUid ) |
522 TUint CHotSpotServer::GetLogoutTimeMicroSecs( TDes& aClientUid ) |
533 { |
523 { |
|
524 DEBUG("HotspotServer::GetLogoutTimeMicroSecs()"); |
534 // Default timer value will be returned if matching client UID isn't found. |
525 // Default timer value will be returned if matching client UID isn't found. |
535 TUint retval = KHssDefaultLogoutTimeMicroSecs ; |
526 TUint retval = KHssDefaultLogoutTimeMicroSecs ; |
536 |
527 |
537 TInt ret = CHotSpotServer::FindClientUid( aClientUid ); |
528 TInt ret = FindClientUid( aClientUid ); |
538 if (ret != KErrNotFound) |
529 if (ret != KErrNotFound) |
539 { |
530 { |
540 // ret is the matching element's index. |
531 // ret is the matching element's index. |
541 retval = iLoginLogoutTimerArray[ret].logoutTimeMicroSecs; |
532 retval = iLoginLogoutTimerArray[ret].iLogoutTimeMicroSecs; |
542 } |
533 } |
543 |
534 |
544 return retval; |
535 return retval; |
545 } |
536 } |
546 |
537 |
547 // ----------------------------------------------------------------------------- |
538 // ----------------------------------------------------------------------------- |
548 // SetTimerValues |
539 // SetTimerValues |
549 // ----------------------------------------------------------------------------- |
540 // ----------------------------------------------------------------------------- |
550 // |
541 // |
551 void CHotSpotServer::SetTimerValues( |
542 void CHotSpotServer::SetTimerValues( |
552 TUid aClientUid, |
543 TDes& aClientUid, |
553 TUint aLoginTimerValue, // in seconds |
544 TUint aLoginTimerValue, // in seconds |
554 TUint aLogoutTimerValue ) // in seconds |
545 TUint aLogoutTimerValue ) // in seconds |
555 { |
546 { |
556 TInt ret = CHotSpotServer::FindClientUid( aClientUid ); |
547 DEBUG("HotspotServer::SetTimerValues()"); |
|
548 TInt ret = FindClientUid( aClientUid ); |
557 TUint loginTimeMicroSecs = KHssDefaultLoginTimeMicroSecs ; |
549 TUint loginTimeMicroSecs = KHssDefaultLoginTimeMicroSecs ; |
558 TUint logoutTimeMicroSecs = KHssDefaultLogoutTimeMicroSecs ; |
550 TUint logoutTimeMicroSecs = KHssDefaultLogoutTimeMicroSecs ; |
559 |
551 |
560 // Check that values are in bounds and modify them into micro seconds. |
552 // Check that values are in bounds and modify them into micro seconds. |
561 if( aLoginTimerValue >= KHssMinLoginTime && |
553 if( aLoginTimerValue >= KHssMinLoginTime && |
591 |
583 |
592 // ----------------------------------------------------------------------------- |
584 // ----------------------------------------------------------------------------- |
593 // FindClientUid |
585 // FindClientUid |
594 // ----------------------------------------------------------------------------- |
586 // ----------------------------------------------------------------------------- |
595 // |
587 // |
596 TInt CHotSpotServer::FindClientUid( TUid aClientUid ) |
588 TInt CHotSpotServer::FindClientUid( TDes& aClientUid ) |
597 { |
589 { |
|
590 DEBUG("CHotspotServer::FindClientUid()"); |
598 TInt count = iLoginLogoutTimerArray.Count(); |
591 TInt count = iLoginLogoutTimerArray.Count(); |
599 TInt i = 0; |
592 TInt i = 0; |
600 TInt ret = KErrNotFound; |
593 TInt ret = KErrNotFound; |
601 |
594 |
602 while (i < count) |
595 while ( i < count ) |
603 { |
596 { |
604 if (aClientUid == iLoginLogoutTimerArray[i].clientUid) |
597 if ( aClientUid.Compare( iLoginLogoutTimerArray[i].iClientUid ) == 0 ) |
605 { |
598 { |
|
599 DEBUG("CHotspotServer::FindClientUid() FOUND"); |
606 ret = i; |
600 ret = i; |
607 break; |
601 break; |
608 } |
602 } |
609 i++; |
603 i++; |
610 } |
604 } |
611 |
605 |
612 return ret; |
606 return ret; |
|
607 } |
|
608 |
|
609 // ----------------------------------------------------------------------------- |
|
610 // GetClientUid |
|
611 // ----------------------------------------------------------------------------- |
|
612 // |
|
613 TInt CHotSpotServer::GetClientUid( TUint aIapId, TDes& aUid ) |
|
614 { |
|
615 DEBUG("CHotspotServer::GetClientUid()"); |
|
616 TInt ret( KErrNotFound ); |
|
617 TInt count = iClientIaps.Count(); |
|
618 TInt i = 0; |
|
619 |
|
620 while ( i < count ) |
|
621 { |
|
622 if ( aIapId == iClientIaps[i].iIapId ) |
|
623 { |
|
624 DEBUG("CHotspotServer::GetClientUid() FOUND"); |
|
625 aUid = iClientIaps[i].iClientUid; |
|
626 ret = KErrNone; |
|
627 break; |
|
628 } |
|
629 i++; |
|
630 } |
|
631 |
|
632 return ret; |
|
633 } |
|
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // SetClientIap |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 void CHotSpotServer::SetClientIap( TUint aIapId, TDes& aUid ) |
|
640 { |
|
641 DEBUG("CHotspotServer::SetClientIap()"); |
|
642 SClientIaps clientElement = { aIapId, aUid }; |
|
643 iClientIaps.Append( clientElement ); |
|
644 } |
|
645 |
|
646 // ----------------------------------------------------------------------------- |
|
647 // RemoveClientIap |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 void CHotSpotServer::RemoveClientIap( TUint aIapId ) |
|
651 { |
|
652 DEBUG("CHotspotServer::RemoveClientIap()"); |
|
653 TInt count = iClientIaps.Count(); |
|
654 TInt i = 0; |
|
655 |
|
656 while ( i < count ) |
|
657 { |
|
658 if ( aIapId == iClientIaps[i].iIapId ) |
|
659 { |
|
660 DEBUG("CHotspotServer:::RemoveClientIap() FOUND"); |
|
661 iClientIaps.Remove( i ); |
|
662 break; |
|
663 } |
|
664 i++; |
|
665 } |
|
666 } |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // GetEasyWlanId |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 TInt CHotSpotServer::GetEasyWlanId() |
|
673 { |
|
674 DEBUG("CHotspotServer::GetEasyWlanId()"); |
|
675 return iEasyWlanId; |
613 } |
676 } |
614 |
677 |
615 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
678 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
616 |
679 |
617 // ----------------------------------------------------------------------------- |
680 // ----------------------------------------------------------------------------- |