146 // ---------------------------------------------------------------------------------------- |
146 // ---------------------------------------------------------------------------------------- |
147 // |
147 // |
148 void CHotSpotSession::DispatchMessageL( const RMessage2& aMessage ) |
148 void CHotSpotSession::DispatchMessageL( const RMessage2& aMessage ) |
149 { |
149 { |
150 DEBUG( "CHotSpotSession::DispatchMessageL()" ); |
150 DEBUG( "CHotSpotSession::DispatchMessageL()" ); |
151 TUint value1(NULL); |
151 TInt value( NULL ); |
152 TInt value2(NULL); |
152 TInt err( KErrNone ); |
153 TInt err(KErrNone); |
153 TInt indx( KErrNone ); |
154 TInt indx(KErrNone); |
|
155 TPckgBuf<TInt> iapPackage( iIapId ); |
154 TPckgBuf<TInt> iapPackage( iIapId ); |
156 |
155 |
157 switch ( aMessage.Function() ) |
156 switch ( aMessage.Function() ) |
158 { |
157 { |
159 case EHssActivateNotifications : |
158 case EHssActivateNotifications : |
|
159 DEBUG( "CHotSpotSession::ActivateNotificationsL" ); |
160 iAllowNotifications = EFalse; |
160 iAllowNotifications = EFalse; |
161 DEBUG( "CHotSpotSession::ActivateNotificationsL" ); |
161 |
162 if ( iNotifications == NULL ) |
162 if ( iNotifications == NULL ) |
163 { |
163 { |
164 DEBUG( "CHotSpotSession::DispatchMessageL activated !!!" ); |
164 iNotifications = new ( ELeave ) HssNotifications( *this ); |
165 iNotifications = new (ELeave) HssNotifications(*this); |
|
166 iMgtClient->ActivateNotificationsL( *iNotifications ); |
165 iMgtClient->ActivateNotificationsL( *iNotifications ); |
167 } |
166 } |
168 HandleOrderNotifications( aMessage ); |
167 HandleOrderNotifications( aMessage ); |
169 break; |
168 break; |
170 case EHssCancelNotifications : |
169 case EHssCancelNotifications : |
|
170 DEBUG( "CHotSpotSession::CancelNotifications" ); |
171 iAllowNotifications = EFalse; |
171 iAllowNotifications = EFalse; |
172 DEBUG( "CHotSpotSession::CancelNotifications" ); |
|
173 iMgtClient->CancelNotifications( ); |
172 iMgtClient->CancelNotifications( ); |
|
173 |
174 if ( iNotifications != NULL ) |
174 if ( iNotifications != NULL ) |
175 { |
175 { |
176 delete iNotifications; |
176 delete iNotifications; |
177 } |
177 } |
178 iNotifications = NULL; |
178 iNotifications = NULL; |
179 HandleCancelNotifications( aMessage ); |
179 HandleCancelNotifications( aMessage ); |
180 break; |
180 break; |
181 case EHssGetScanResults : |
|
182 // Handled now in client side. Left here for future use. |
|
183 break; |
|
184 case EHssRegister : |
181 case EHssRegister : |
185 ProcessRegisterL( aMessage ); |
182 ProcessRegisterL( aMessage ); |
186 break; |
183 break; |
187 case EHssUnRegister : |
184 case EHssUnRegister : |
188 ProcessUnRegisterL( aMessage ); |
185 ProcessUnRegisterL( aMessage ); |
189 break; |
186 break; |
190 case EHssJoin : |
187 case EHssJoin : |
191 iAllowNotifications = EFalse; |
188 iAllowNotifications = EFalse; |
192 // IAP id |
189 iIapId = ( TInt )aMessage.Int0(); |
193 value1 = ( TInt )aMessage.Int0(); |
190 |
194 iIapId = value1; |
191 indx = iServer.FindMessage( iIapId, EHssStart ); |
195 indx = iServer.FindMessage(value1, EHssStart ); |
|
196 if ( indx >= 0 ) |
192 if ( indx >= 0 ) |
197 { |
193 { |
198 iServer.CompleteMessage( indx , KErrNone ); |
194 iServer.CompleteMessage( indx , KErrNone ); |
199 } |
195 } |
200 else |
196 else |
201 { |
197 { |
202 indx = iServer.FindMessage(value1, EHssStartAgain ); |
198 indx = iServer.FindMessage( iIapId, EHssStartAgain ); |
203 if ( indx >= 0 ) |
199 if ( indx >= 0 ) |
204 { |
200 { |
205 iServer.CompleteMessage( indx , KErrNone ); |
201 iServer.CompleteMessage( indx , KErrNone ); |
206 } |
202 } |
207 } |
203 } |
209 break; |
205 break; |
210 case EHssCancelStart : |
206 case EHssCancelStart : |
211 iServer.SetLogoutFlag( ETrue ); |
207 iServer.SetLogoutFlag( ETrue ); |
212 // Do not send association status to client |
208 // Do not send association status to client |
213 iServer.SetAssociationFlag( EFalse ); |
209 iServer.SetAssociationFlag( EFalse ); |
214 // IAP id |
|
215 iIapId = ( TInt )aMessage.Int0(); |
210 iIapId = ( TInt )aMessage.Int0(); |
|
211 |
216 indx = iServer.FindMessage(iIapId, EHssStart ); |
212 indx = iServer.FindMessage(iIapId, EHssStart ); |
217 if ( indx >= 0 ) |
213 if ( indx >= 0 ) |
218 { |
214 { |
219 iServer.CompleteMessage( indx , KErrAbort); |
215 iServer.CompleteMessage( indx , KErrAbort); |
220 } |
216 } |
224 if ( indx >= 0 ) |
220 if ( indx >= 0 ) |
225 { |
221 { |
226 iServer.CompleteMessage( indx , KErrAbort ); |
222 iServer.CompleteMessage( indx , KErrAbort ); |
227 } |
223 } |
228 } |
224 } |
229 |
|
230 aMessage.Complete( KErrNone ); |
225 aMessage.Complete( KErrNone ); |
231 break; |
226 break; |
232 case EHssStop : |
227 case EHssStop : |
233 iAllowNotifications = EFalse; |
228 iAllowNotifications = EFalse; |
234 iServer.SetLogoutFlag( ETrue ); |
229 iServer.SetLogoutFlag( ETrue ); |
235 |
|
236 iLoginTimer->Cancel(); |
230 iLoginTimer->Cancel(); |
237 iLogoutTimer->Cancel(); |
231 iLogoutTimer->Cancel(); |
238 // IAP id |
232 iIapId = ( TInt )aMessage.Int0(); |
239 value1 = ( TInt )aMessage.Int0(); |
233 |
240 for (TInt counter = EHssGetScanResults; counter <EHssServerShutdown ;counter++) |
234 for ( TInt counter = EHssGetScanResults; |
241 { |
235 counter <EHssServerShutdown ;counter++ ) |
242 indx = iServer.FindMessage(value1, THotSpotCommands(counter )); |
236 { |
|
237 indx = iServer.FindMessage( iIapId, |
|
238 THotSpotCommands( counter ) ); |
243 if ( indx >= 0 ) |
239 if ( indx >= 0 ) |
244 { |
240 { |
245 iServer.CompleteMessage( indx , KErrCancel); |
241 iServer.CompleteMessage( indx , KErrCancel ); |
246 } |
242 } |
247 } |
243 } |
248 |
|
249 aMessage.Complete( KErrNone ); |
244 aMessage.Complete( KErrNone ); |
250 break; |
245 break; |
251 case EHssLoginComplete : |
246 case EHssLoginComplete : |
252 iAllowNotifications = EFalse; |
247 iAllowNotifications = EFalse; |
253 // IAP id |
|
254 value1 = ( TInt )aMessage.Int0(); |
|
255 // ret value |
|
256 value2 = ( TInt )aMessage.Int1(); |
|
257 |
|
258 iLoginTimer->Cancel(); |
248 iLoginTimer->Cancel(); |
259 |
249 iIapId = ( TInt )aMessage.Int0(); |
260 DEBUG1( "EHssLoginComplete value2: %d", value2 ); |
250 value = ( TInt )aMessage.Int1(); |
261 indx = iServer.FindMessage( value1, EHssStartLogin ); |
251 |
|
252 DEBUG1( "EHssLoginComplete return value: %d", value ); |
|
253 indx = iServer.FindMessage( iIapId, EHssStartLogin ); |
262 if ( KErrNotFound != indx ) |
254 if ( KErrNotFound != indx ) |
263 { |
255 { |
264 if (value2 == KErrNone) |
256 if ( value == KErrNone ) |
265 { |
257 { |
266 DEBUG( "EHssLoginComplete1" ); |
258 DEBUG( "EHssLoginComplete1" ); |
267 iServer.CompleteMessage( indx, KErrNone ); |
259 iServer.CompleteMessage( indx, KErrNone ); |
268 } |
260 } |
269 else |
261 else |
277 aMessage.Complete( KErrNone ); |
269 aMessage.Complete( KErrNone ); |
278 break; |
270 break; |
279 case EHssLogoutComplete : |
271 case EHssLogoutComplete : |
280 iAllowNotifications = EFalse; |
272 iAllowNotifications = EFalse; |
281 iLogoutTimer->Cancel(); |
273 iLogoutTimer->Cancel(); |
282 |
274 iIapId = ( TInt )aMessage.Int0(); |
283 // IAP id |
275 |
284 value1 = ( TInt )aMessage.Int0(); |
276 indx = iServer.FindMessage( iIapId, EHssCloseConnection ); |
285 |
|
286 indx = iServer.FindMessage( value1, EHssCloseConnection ); |
|
287 if ( KErrNotFound != indx ) |
277 if ( KErrNotFound != indx ) |
288 { |
278 { |
289 iServer.CompleteMessage( indx, KErrNone ); |
279 iServer.CompleteMessage( indx, KErrNone ); |
290 } |
280 } |
291 |
281 |
292 aMessage.Complete( KErrNone ); |
282 aMessage.Complete( KErrNone ); |
293 break; |
283 break; |
294 case EHssStartLogin : |
284 case EHssStartLogin : |
295 // Do not send association status, since it's already done. |
285 // Do not send association status, since it's already done. |
296 iServer.SetAssociationFlag( EFalse ); |
286 iServer.SetAssociationFlag( EFalse ); |
297 // IAP id |
|
298 iIapId = ( TInt )aMessage.Int0(); |
287 iIapId = ( TInt )aMessage.Int0(); |
299 // Network id |
|
300 iNetId = ( TInt )aMessage.Int1(); |
288 iNetId = ( TInt )aMessage.Int1(); |
|
289 |
301 err = iServer.SaveMessage( iIapId, aMessage, EHssStartLogin ); |
290 err = iServer.SaveMessage( iIapId, aMessage, EHssStartLogin ); |
302 if ( KErrNone != err ) |
291 if ( KErrNone != err ) |
303 { |
292 { |
304 aMessage.Complete( err ); |
293 aMessage.Complete( err ); |
305 } |
294 } |
337 iServer.CompleteMessage( indx , err ); |
326 iServer.CompleteMessage( indx , err ); |
338 } |
327 } |
339 aMessage.Complete( KErrNone ); |
328 aMessage.Complete( KErrNone ); |
340 break; |
329 break; |
341 case EHssStart: |
330 case EHssStart: |
342 // IAP id |
|
343 iServer.SetLoginFlag( ETrue ); |
331 iServer.SetLoginFlag( ETrue ); |
344 iIapId = ( TInt )aMessage.Int0(); |
332 iIapId = ( TInt )aMessage.Int0(); |
345 err = iServer.SaveMessage( iIapId, aMessage, EHssStart ); |
333 err = iServer.SaveMessage( iIapId, aMessage, EHssStart ); |
346 if ( err != KErrNone) |
334 |
|
335 if ( err != KErrNone) |
347 { |
336 { |
348 aMessage.Complete( err ); |
337 aMessage.Complete( err ); |
349 } |
338 } |
350 else |
339 else |
351 { |
340 { |
352 TRAPD( startLeaved, err = ProcessStartL( iIapId ) ); |
341 TRAPD( startLeaved, err = ProcessStartL( iIapId ) ); |
353 |
|
354 if ( startLeaved != KErrNone) |
342 if ( startLeaved != KErrNone) |
355 { |
343 { |
356 indx = iServer.FindMessage(iIapId, EHssStart ); |
344 indx = iServer.FindMessage(iIapId, EHssStart ); |
357 if ( indx >= 0 ) |
345 if ( indx >= 0 ) |
358 { |
346 { |
374 else |
361 else |
375 { |
362 { |
376 aMessage.Complete( KErrNotSupported ); |
363 aMessage.Complete( KErrNotSupported ); |
377 } |
364 } |
378 } |
365 } |
379 // else -> client is created and called |
|
380 // WLAN agent waits for 30 seconds before continuing connection setup. |
|
381 } |
366 } |
382 break; |
367 break; |
383 case EHssStartAgain: |
368 case EHssStartAgain: |
384 // IAP id |
|
385 iServer.SetLoginFlag( ETrue ); |
369 iServer.SetLoginFlag( ETrue ); |
386 iIapId = ( TInt )aMessage.Int0(); |
370 iIapId = ( TInt )aMessage.Int0(); |
387 err = iServer.SaveMessage( iIapId, aMessage, EHssStartAgain ); |
371 err = iServer.SaveMessage( iIapId, aMessage, EHssStartAgain ); |
388 if ( err != KErrNone) |
372 |
|
373 if ( err != KErrNone) |
389 { |
374 { |
390 aMessage.Complete( err ); |
375 aMessage.Complete( err ); |
391 } |
376 } |
392 else |
377 else |
393 { |
378 { |
404 aMessage.Complete( err ); |
389 aMessage.Complete( err ); |
405 } |
390 } |
406 } |
391 } |
407 } |
392 } |
408 break; |
393 break; |
409 |
|
410 case EHssCancel: |
394 case EHssCancel: |
411 iLoginTimer->Cancel(); |
395 iLoginTimer->Cancel(); |
412 iLogoutTimer->Cancel(); |
396 iLogoutTimer->Cancel(); |
413 // IAP id |
|
414 iIapId = ( TInt )aMessage.Int0(); |
397 iIapId = ( TInt )aMessage.Int0(); |
|
398 |
415 if ( iServer.GetAssociationFlagValue() ) |
399 if ( iServer.GetAssociationFlagValue() ) |
416 { |
400 { |
417 // We are in association phase and Agent failed it for some reason |
401 // We are in association phase and Agent failed it for some reason |
418 ProcessAssociationStatus( iIapId, EFalse ); |
402 ProcessAssociationStatus( iIapId, EFalse ); |
419 } |
403 } |
431 indx = iServer.FindMessage(iIapId, EHssCloseConnection ); |
415 indx = iServer.FindMessage(iIapId, EHssCloseConnection ); |
432 if ( indx >= 0 ) |
416 if ( indx >= 0 ) |
433 { |
417 { |
434 iServer.CompleteMessage( indx , KErrCancel ); |
418 iServer.CompleteMessage( indx , KErrCancel ); |
435 } |
419 } |
436 //Not needed to send Logout() |
|
437 //iServer.SetLogoutFlag( ETrue ) |
|
438 //ProcessCloseL( iIapId ) |
|
439 aMessage.Complete( KErrNone ); |
420 aMessage.Complete( KErrNone ); |
440 break; |
421 break; |
441 |
|
442 case EHssCloseConnection: |
422 case EHssCloseConnection: |
443 iLoginTimer->Cancel(); |
423 iLoginTimer->Cancel(); |
444 iLogoutTimer->Cancel(); |
424 iLogoutTimer->Cancel(); |
445 |
|
446 // IAP id |
|
447 iIapId = ( TInt )aMessage.Int0(); |
425 iIapId = ( TInt )aMessage.Int0(); |
448 |
426 |
449 if ( iServer.GetAssociationFlagValue() ) |
427 if ( iServer.GetAssociationFlagValue() ) |
450 { |
428 { |
451 // We are in association phase and Agent failed it for some reason |
429 // We are in association phase and Agent failed it for some reason |
474 aMessage.Complete( KErrNone ); |
452 aMessage.Complete( KErrNone ); |
475 } |
453 } |
476 } |
454 } |
477 } |
455 } |
478 break; |
456 break; |
479 |
|
480 case EHssServerShutdown: |
457 case EHssServerShutdown: |
481 ProcessServerShutdown( aMessage ); |
458 ProcessServerShutdown( aMessage ); |
482 break; |
459 break; |
483 |
|
484 case EHssGetIAP: |
460 case EHssGetIAP: |
485 aMessage.WriteL( 0, iapPackage ); |
461 aMessage.WriteL( 0, iapPackage ); |
486 aMessage.Complete( KErrNone ); |
462 aMessage.Complete( KErrNone ); |
487 break; |
463 break; |
488 |
|
489 case EHssUiState: |
464 case EHssUiState: |
490 ProcessUiState( aMessage ); |
465 ProcessUiState( aMessage ); |
491 break; |
466 break; |
492 case EHssStartBrowser: |
467 case EHssStartBrowser: |
493 { |
468 { |
494 TInt len = aMessage.GetDesLength( 0 ); |
469 TInt len = aMessage.GetDesLength( 0 ); |
495 iIapId = ( TInt )aMessage.Int1(); |
470 iIapId = ( TInt )aMessage.Int1(); |
496 iNetId = ( TInt )aMessage.Int2(); |
471 iNetId = ( TInt )aMessage.Int2(); |
497 err = iServer.SaveMessage( iIapId, aMessage, EHssStartBrowser ); |
472 err = iServer.SaveMessage( iIapId, aMessage, EHssStartBrowser ); |
498 HBufC* buf = HBufC::NewLC( len ); |
473 HBufC* buf = HBufC::NewLC( len ); |
500 User::LeaveIfError( aMessage.Read( 0, ptr ) ); |
475 User::LeaveIfError( aMessage.Read( 0, ptr ) ); |
501 |
476 |
502 AuthenticateL( ptr ); |
477 AuthenticateL( ptr ); |
503 |
478 |
504 CleanupStack::PopAndDestroy(buf); |
479 CleanupStack::PopAndDestroy(buf); |
505 } |
480 break; |
506 break; |
481 } |
507 |
|
508 case EHssSetTimerValues: |
482 case EHssSetTimerValues: |
509 { |
483 { |
510 TUid clientUid( TUid::Uid( aMessage.Int0() ) ); |
484 TUid clientUid( TUid::Uid( aMessage.Int0() ) ); |
511 TUint loginTimerValue = aMessage.Int1(); |
485 TUint loginTimerValue = aMessage.Int1(); |
512 TUint logoutTimerValue = aMessage.Int2(); |
486 TUint logoutTimerValue = aMessage.Int2(); |
513 iServer.SetTimerValues( clientUid, loginTimerValue, logoutTimerValue ); |
487 iServer.SetTimerValues( clientUid, loginTimerValue, logoutTimerValue ); |
514 aMessage.Complete( KErrNone ); |
488 aMessage.Complete( KErrNone ); |
515 } |
489 break; |
516 break; |
490 } |
517 |
|
518 default: |
491 default: |
519 aMessage.Complete( KErrNotSupported ); |
492 aMessage.Complete( KErrNotSupported ); |
520 //PanicClient( aMessage, EBadRequest ) |
|
521 break; |
493 break; |
522 } |
494 } |
523 iAllowNotifications = TRUE; |
495 iAllowNotifications = TRUE; |
524 |
|
525 } |
496 } |
526 |
497 |
527 // --------------------------------------------------------- |
498 // --------------------------------------------------------- |
528 // HandleOrderNotifications |
499 // HandleOrderNotifications |
529 // --------------------------------------------------------- |
500 // --------------------------------------------------------- |
753 clientUid = uidPckg().ClientUid(); |
724 clientUid = uidPckg().ClientUid(); |
754 aMessage.ReadL( 1, iapPckg ); |
725 aMessage.ReadL( 1, iapPckg ); |
755 iapName = iapPckg().IapName(); |
726 iapName = iapPckg().IapName(); |
756 |
727 |
757 TUint32 iapId( 0 ); |
728 TUint32 iapId( 0 ); |
758 // TRAPD needed here so that 0 can be returned if DeleteIapL leaves |
729 |
759 TInt ret( KErrNone ); |
730 TInt ret( KErrNone ); |
760 TRAP( ret, iIapSettingsHandler->CreateClientIapL( iapName, iapId, clientUid )); |
731 TRAP( ret, iIapSettingsHandler->CreateClientIapL( iapName, iapId, clientUid )); |
761 DEBUG1( "CHotSpotSession::EHssRegister iapId: %d", iapId ); |
732 DEBUG1( "CHotSpotSession::EHssRegister iapId: %d", iapId ); |
762 DEBUG1( "CHotSpotSession::EHssRegister ret: %d", ret ); |
733 DEBUG1( "CHotSpotSession::EHssRegister ret: %d", ret ); |
763 if ( KErrNone == ret ) |
734 if ( KErrNone == ret ) |