1 /* |
|
2 * Copyright (c) 2007-2008 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 TWsfAiController. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // EXTERNAL INCLUDES |
|
21 #include <apgcli.h> |
|
22 #include <centralrepository.h> |
|
23 #include <browseruisdkcrkeys.h> |
|
24 #include <AknIconArray.h> |
|
25 #include <AknQueryDialog.h> |
|
26 #include <cmpluginwlandef.h> |
|
27 #include <ErrorUI.h> |
|
28 #include <StringLoader.h> |
|
29 #include <aknnotewrappers.h> |
|
30 #include <wsfaipluginrsc.rsg> |
|
31 #include <rconnmon.h> |
|
32 #include <utf.h> |
|
33 #include <cmmanager.h> |
|
34 #include <internetconnectivitycrkeys.h> |
|
35 #include <wlanerrorcodes.h> |
|
36 #include <ConnectionUiUtilities.h> |
|
37 |
|
38 // CLASS HEADER |
|
39 #include "wsfaicontroller.h" |
|
40 |
|
41 // INTERNAL INCLUDES |
|
42 #include "wsfwlaninfo.h" |
|
43 #include "wsfwlaninfoarray.h" |
|
44 #include "wsfaiuiobserver.h" |
|
45 #include "wsfaimodel.h" |
|
46 #include "wsficonarraycreator.h" |
|
47 #include "wsfmodel.h" |
|
48 #include "wsfsearchwlansdialog.h" |
|
49 #include "wsfaicontrollercmds.h" |
|
50 #include "wsfactivewaiter.h" |
|
51 #include "wsflogger.h" |
|
52 #include "wsfdbobserver.h" |
|
53 #include "wsfactivewrappers.h" |
|
54 |
|
55 |
|
56 // MACROS |
|
57 #ifdef _DEBUG |
|
58 _LIT( KControllerPanic, "CWsfAiController" ); |
|
59 #define _ASS_D( cond ) __ASSERT_DEBUG( (cond), \ |
|
60 User::Panic( KControllerPanic, __LINE__) ) |
|
61 #else |
|
62 #define _ASS_D( cond ) |
|
63 #endif //_DEBUG |
|
64 |
|
65 |
|
66 // LOCAL DEFINITIONS |
|
67 LOCAL_D const TInt KFirstItemArrayIndex = 0; |
|
68 |
|
69 // index value to suppress 1 second refreshing state |
|
70 static const TInt KSuppressRefreshIndex = 1024; |
|
71 |
|
72 |
|
73 |
|
74 // -------------------------------------------------------------------------- |
|
75 // TWsfAiController::TWsfAiController |
|
76 // -------------------------------------------------------------------------- |
|
77 // |
|
78 TWsfAiController::TWsfAiController(): |
|
79 iModel( NULL ), |
|
80 iAiModel( NULL ), |
|
81 iUi( NULL ), |
|
82 iDbObserver( NULL ), |
|
83 iConnectOnly( EFalse ) |
|
84 { |
|
85 // null the pointers |
|
86 iConnectedWlan.iConnectionState = ENotConnected; |
|
87 } |
|
88 |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // CWsfActiveWaiter::DeInitializeL |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 void TWsfAiController::DeInitializeL() |
|
95 { |
|
96 LOG_ENTERFN( "TWsfAiController::DeInitializeL" ); |
|
97 } |
|
98 |
|
99 |
|
100 // -------------------------------------------------------------------------- |
|
101 // TWsfAiController::Initialize |
|
102 // -------------------------------------------------------------------------- |
|
103 // |
|
104 void TWsfAiController::InitializeL( CEikonEnv* aEnv, CWsfModel* aModel, |
|
105 CWsfAiModel* aAiModel, |
|
106 CWsfDbObserver* aObserver, |
|
107 CWsfActiveWrappers* aActiveWrappers ) |
|
108 { |
|
109 LOG_ENTERFN( "TWsfAiController::InitializeL" ); |
|
110 iEnv = aEnv; |
|
111 iModel = aModel; |
|
112 iAiModel = aAiModel; |
|
113 iDbObserver = aObserver; |
|
114 iActiveWrappers = aActiveWrappers; |
|
115 iDbObserver->SetController( this ); |
|
116 iDbObserver->ActivateItL(); |
|
117 iModel->SetEngineObserver( this ); |
|
118 } |
|
119 |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // TWsfMainController::BrowserLaunchCompleteL |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void TWsfAiController::BrowserLaunchCompleteL() |
|
126 { |
|
127 LOG_ENTERFN( "TWsfAiController::BrowserLaunchCompleteL" ); |
|
128 // no implementation required |
|
129 } |
|
130 |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // TWsfMainController::BrowserExitL |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void TWsfAiController::BrowserExitL() |
|
137 { |
|
138 LOG_ENTERFN( "TWsfAiController::BrowserExitL" ); |
|
139 // no implementation required |
|
140 } |
|
141 |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // TWsfMainController::BrowserLaunchFailed |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 #ifdef _DEBUG |
|
148 void TWsfAiController::BrowserLaunchFailed( TInt aError ) |
|
149 { |
|
150 LOG_ENTERFN( "TWsfAiController::BrowserLaunchFailed" ); |
|
151 LOG_WRITEF( "error = %d", aError ); |
|
152 #else |
|
153 void TWsfAiController::BrowserLaunchFailed( TInt /*aError*/ ) |
|
154 { |
|
155 // no implementation required |
|
156 #endif |
|
157 } |
|
158 |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // TWsfMainController::ConnectingL |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void TWsfAiController::ConnectingL( TUint32 /*aIapId*/ ) |
|
165 { |
|
166 LOG_ENTERFN( "TWsfAiController::ConnectingL" ); |
|
167 iModel->SetConnecting( ETrue ); |
|
168 iAiModel->SetConnecting( ETrue ); |
|
169 iUi->StartConnectingAnimationL(); |
|
170 RefreshUiL(); |
|
171 } |
|
172 |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // TWsfMainController::ConnectingFinishedL |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 #ifdef _DEBUG |
|
179 void TWsfAiController::ConnectingFinishedL( TInt aResult ) |
|
180 { |
|
181 LOG_ENTERFN( "TWsfAiController::ConnectingFinishedL" ); |
|
182 LOG_WRITEF( "aResult = %d", aResult ); |
|
183 #else |
|
184 void TWsfAiController::ConnectingFinishedL( TInt /*aResult*/ ) |
|
185 { |
|
186 #endif |
|
187 if ( iModel->IsConnecting() ) |
|
188 { |
|
189 iModel->SetConnecting( EFalse ); |
|
190 } |
|
191 iAiModel->SetConnecting( EFalse ); |
|
192 RefreshUiL(); |
|
193 } |
|
194 |
|
195 |
|
196 // -------------------------------------------------------------------------- |
|
197 // TWsfAiController::StartupRefresh |
|
198 // -------------------------------------------------------------------------- |
|
199 // |
|
200 void TWsfAiController::StartupRefresh() |
|
201 { |
|
202 LOG_ENTERFN( "TWsfAiController::StartupRefresh" ); |
|
203 iActiveWrappers->RefreshWLANList( ETrue ); |
|
204 } |
|
205 |
|
206 |
|
207 // -------------------------------------------------------------------------- |
|
208 // TWsfAiController::StartupRefreshDataReadyL |
|
209 // -------------------------------------------------------------------------- |
|
210 // |
|
211 void TWsfAiController::StartupRefreshDataReadyL() |
|
212 { |
|
213 LOG_ENTERFN( "TWsfAiController::StartupRefreshDataReadyL" ); |
|
214 |
|
215 iInfoArray = iActiveWrappers->GetWLANList(); |
|
216 iConnectedWlan = iActiveWrappers->GetConnectedWLANNetwork(); |
|
217 iAiModel->SetConnected( iConnectedWlan.Connected() ); |
|
218 iAiModel->SetConnectedWlanInfo( iConnectedWlan ); |
|
219 |
|
220 LOG_WRITEF( "Connected = %d", iConnectedWlan.Connected() ); |
|
221 |
|
222 MDesCArray* data = iAiModel->FormatSingleLineWlanListL( iInfoArray ); |
|
223 |
|
224 iUi->UpdateHotSpotsL( data, KSuppressRefreshIndex ); |
|
225 } |
|
226 |
|
227 |
|
228 // -------------------------------------------------------------------------- |
|
229 // TWsfAiController::SetUi |
|
230 // -------------------------------------------------------------------------- |
|
231 // |
|
232 void TWsfAiController::SetUi( MWsfAiUiObserver& aUi ) |
|
233 { |
|
234 LOG_ENTERFN( "TWsfAiController::SetUi" ); |
|
235 iUi = &aUi; |
|
236 } |
|
237 |
|
238 |
|
239 // -------------------------------------------------------------------------- |
|
240 // TWsfAiController::HandleSelectionKeyL |
|
241 // -------------------------------------------------------------------------- |
|
242 // |
|
243 void TWsfAiController::HandleSelectionKeyL() |
|
244 { |
|
245 LOG_ENTERFN( "TWsfAiController::HandleSelectionKeyL" ); |
|
246 _ASS_D( iAiModel ); |
|
247 |
|
248 if ( !iAiModel->ScanningOn() && !iAiModel->Connected() ) |
|
249 { |
|
250 // scanning was off and there wasn't a connected network |
|
251 EnableScanL(); |
|
252 } |
|
253 else |
|
254 { |
|
255 // scanning was on |
|
256 // menu contents depend on the connection and browser status |
|
257 if ( iModel->IsConnecting() ) |
|
258 { |
|
259 // connecting |
|
260 HandleMskIfConnectingL(); |
|
261 } |
|
262 else if ( !iAiModel->Connected() ) |
|
263 { |
|
264 // not connected |
|
265 HandleMskIfOfflineL(); |
|
266 } |
|
267 else |
|
268 { |
|
269 // connected |
|
270 if ( IsWlanUsedByBrowserL() ) |
|
271 { |
|
272 // browser is using active WLAN connection |
|
273 HandleMskIfBrowsingL(); |
|
274 } |
|
275 else |
|
276 { |
|
277 // browser is not running or not using the WLAN |
|
278 HandleMskIfConnectedL(); |
|
279 } |
|
280 } |
|
281 } |
|
282 } |
|
283 |
|
284 |
|
285 // -------------------------------------------------------------------------- |
|
286 // TWsfAiController::WlanListChangedL |
|
287 // -------------------------------------------------------------------------- |
|
288 // |
|
289 void TWsfAiController::WlanListChangedL() |
|
290 { |
|
291 LOG_ENTERFN("TWsfAiController::WlanListChangedL" ); |
|
292 |
|
293 _ASS_D( iAiModel ); |
|
294 |
|
295 if ( !iAiModel->ScanningOn() ) |
|
296 { |
|
297 return; |
|
298 } |
|
299 |
|
300 iActiveWrappers->RefreshWLANList( EFalse ); |
|
301 } |
|
302 |
|
303 |
|
304 // -------------------------------------------------------------------------- |
|
305 // TWsfAiController::WlanListDataReadyL |
|
306 // -------------------------------------------------------------------------- |
|
307 // |
|
308 void TWsfAiController::WlanListDataReadyL() |
|
309 { |
|
310 LOG_ENTERFN("TWsfAiController::WlanListDataReadyL" ); |
|
311 |
|
312 _ASS_D( iAiModel ); |
|
313 |
|
314 iInfoArray = iActiveWrappers->GetWLANList(); |
|
315 iConnectedWlan = iActiveWrappers->GetConnectedWLANNetwork(); |
|
316 iAiModel->SetConnected( iConnectedWlan.Connected() ); |
|
317 iAiModel->SetConnectedWlanInfo( iConnectedWlan ); |
|
318 |
|
319 LOG_WRITEF( "Connected = %d", iConnectedWlan.Connected() ); |
|
320 |
|
321 if ( !iAiModel->ScanningOn() && !iAiModel->Connected() ) |
|
322 { |
|
323 return; |
|
324 } |
|
325 |
|
326 _ASS_D( iModel ); |
|
327 _ASS_D( iUi ); |
|
328 |
|
329 TBool match( EFalse ); |
|
330 TWsfWlanInfo previousSelected; |
|
331 CWsfWlanInfoArray* modelArr = iAiModel->GetInfoArray(); |
|
332 |
|
333 if ( modelArr ) |
|
334 { |
|
335 TInt selectedItem = iUi->SelectedItem(); |
|
336 if ( selectedItem >= KFirstItemArrayIndex && |
|
337 selectedItem < modelArr->Count() ) |
|
338 { |
|
339 TWsfWlanInfo* temp = modelArr->At( selectedItem ); |
|
340 if ( temp ) |
|
341 { |
|
342 match = ETrue; |
|
343 previousSelected = *temp; |
|
344 } |
|
345 } |
|
346 } |
|
347 |
|
348 MDesCArray* data = iUi->MultilineControl() ? |
|
349 iAiModel->FormatWlanListL( iInfoArray, ETrue ): |
|
350 iAiModel->FormatSingleLineWlanListL( iInfoArray ); |
|
351 |
|
352 |
|
353 TInt index( KErrNotFound ); |
|
354 if ( match ) |
|
355 { |
|
356 TWsfWlanInfo* currentMatch = iInfoArray->Match( |
|
357 previousSelected.iSsid, |
|
358 iInfoArray->Count() ); |
|
359 if ( currentMatch ) |
|
360 { |
|
361 index = iInfoArray->GetArrayIndex( currentMatch ); |
|
362 } |
|
363 } |
|
364 |
|
365 if ( !iUi->MultilineControl() && iModel->IsConnecting() ) |
|
366 { |
|
367 index = KSuppressRefreshIndex; |
|
368 } |
|
369 |
|
370 iUi->UpdateHotSpotsL( data, index ); |
|
371 } |
|
372 |
|
373 |
|
374 // -------------------------------------------------------------------------- |
|
375 // TWsfAiController::NotifyEngineError |
|
376 // -------------------------------------------------------------------------- |
|
377 // |
|
378 void TWsfAiController::NotifyEngineError( TInt aError ) |
|
379 { |
|
380 LOG_ENTERFN( "TWsfAiController::NotifyEngineError" ); |
|
381 //Let the user know about the error. |
|
382 LOG_WRITEF( "error = %d", aError ); |
|
383 TRAP_IGNORE( DoHandleEngineErrorL( aError ) ); |
|
384 } |
|
385 |
|
386 |
|
387 // -------------------------------------------------------------------------- |
|
388 // TWsfAiController::ScanDisabledL |
|
389 // -------------------------------------------------------------------------- |
|
390 // |
|
391 void TWsfAiController::ScanDisabledL() |
|
392 { |
|
393 LOG_ENTERFN( "TWsfAiController::ScanDisabledL" ); |
|
394 // no implementation required |
|
395 } |
|
396 |
|
397 |
|
398 // -------------------------------------------------------------------------- |
|
399 // TWsfAiController::ScanEnabledL |
|
400 // -------------------------------------------------------------------------- |
|
401 // |
|
402 void TWsfAiController::ScanEnabledL() |
|
403 { |
|
404 LOG_ENTERFN( "TWsfAiController::ScanEnabledL" ); |
|
405 iActiveWrappers->RefreshScan(); |
|
406 } |
|
407 |
|
408 |
|
409 // -------------------------------------------------------------------------- |
|
410 // TWsfAiController::WlanConnectionActivatedL |
|
411 // -------------------------------------------------------------------------- |
|
412 // |
|
413 void TWsfAiController::WlanConnectionActivatedL() |
|
414 { |
|
415 LOG_ENTERFN( "TWsfAiController::WlanConnectionActivatedL" ); |
|
416 iModel->SetConnecting( EFalse ); |
|
417 iAiModel->SetConnected( ETrue ); |
|
418 iAiModel->SetConnecting( EFalse ); |
|
419 |
|
420 iActiveWrappers->RefreshWLANList( EFalse ); |
|
421 } |
|
422 |
|
423 |
|
424 // -------------------------------------------------------------------------- |
|
425 // TWsfAiController::WlanConnectionClosedL |
|
426 // -------------------------------------------------------------------------- |
|
427 // |
|
428 void TWsfAiController::WlanConnectionClosedL() |
|
429 { |
|
430 LOG_ENTERFN( "TWsfAiController::WlanConnectionClosedL" ); |
|
431 iModel->SetConnecting( EFalse ); |
|
432 iAiModel->SetConnected( EFalse ); |
|
433 iAiModel->SetConnecting( EFalse ); |
|
434 if ( iAiModel->ScanningOn() ) |
|
435 { |
|
436 iActiveWrappers->RefreshWLANList( EFalse ); |
|
437 } |
|
438 else |
|
439 { |
|
440 iUi->DisplayEngineOffL(); |
|
441 } |
|
442 } |
|
443 |
|
444 |
|
445 // --------------------------------------------------------------------------- |
|
446 // TWsfMainController::ConnectionCreationProcessFinished |
|
447 // --------------------------------------------------------------------------- |
|
448 // |
|
449 void TWsfAiController::ConnectionCreationProcessFinishedL( TInt aResult ) |
|
450 { |
|
451 LOG_ENTERFN( "TWsfAiController::ConnectionCreationProcessFinished" ); |
|
452 LOG_WRITEF( "aResult = %d", aResult ); |
|
453 // release flags if we leave occures |
|
454 CleanupStack::PushL( TCleanupItem( CleanUpConnectingL, this ) ); |
|
455 if ( iModel->IsConnecting() ) |
|
456 { |
|
457 iModel->SetConnecting( EFalse ); |
|
458 } |
|
459 iAiModel->SetConnecting( EFalse ); |
|
460 if ( aResult == KErrNone ) |
|
461 { |
|
462 iAiModel->SetConnected( ETrue ); |
|
463 if ( !iConnectOnly ) |
|
464 { |
|
465 StartWebBrowserL( iUsedInfo ); |
|
466 } |
|
467 } |
|
468 else |
|
469 { |
|
470 iAiModel->SetConnected( EFalse ); |
|
471 } |
|
472 // pop cleanup item |
|
473 CleanupStack::Pop(); |
|
474 } |
|
475 |
|
476 |
|
477 // -------------------------------------------------------------------------- |
|
478 // TWsfAiController::StartBrowsingL |
|
479 // -------------------------------------------------------------------------- |
|
480 // |
|
481 void TWsfAiController::StartBrowsingL( TWsfWlanInfo& aInfo ) |
|
482 { |
|
483 LOG_ENTERFN( "TWsfAiController::StartBrowsingL" ); |
|
484 |
|
485 _ASS_D( iModel ); |
|
486 |
|
487 iUsedInfo = aInfo; |
|
488 |
|
489 // Prevent connections to ad-hoc + WPA |
|
490 if ( iUsedInfo.iNetMode == CMManager::EAdhoc |
|
491 && iUsedInfo.iSecurityMode == CMManager::EWlanSecModeWpa ) |
|
492 { |
|
493 CErrorUI* errorUi = CErrorUI::NewLC(); |
|
494 errorUi->ShowGlobalErrorNoteL( KErrNotSupported ); |
|
495 CleanupStack::PopAndDestroy( errorUi ); // errorUi |
|
496 return; |
|
497 } |
|
498 |
|
499 // make sure we don't show connecting stuff forever |
|
500 CleanupStack::PushL( TCleanupItem( CleanUpConnectingL, this ) ); |
|
501 |
|
502 if ( !iUsedInfo.Connected() ) |
|
503 { |
|
504 ConnectL( iUsedInfo, EFalse, EFalse ); |
|
505 } |
|
506 else |
|
507 { |
|
508 LOG_WRITE("Start browser to connected network..."); |
|
509 iConnectOnly = EFalse; |
|
510 StartWebBrowserL( iUsedInfo ); |
|
511 } |
|
512 |
|
513 // pop cleanup item |
|
514 CleanupStack::Pop(); |
|
515 } |
|
516 |
|
517 |
|
518 // -------------------------------------------------------------------------- |
|
519 // TWsfAiController::StartWebBrowserL |
|
520 // -------------------------------------------------------------------------- |
|
521 // |
|
522 void TWsfAiController::StartWebBrowserL( TWsfWlanInfo& aInfo ) |
|
523 { |
|
524 LOG_ENTERFN( "TWsfAiController::StartWebBrowserL" ); |
|
525 |
|
526 _ASS_D( iModel ); |
|
527 |
|
528 TUint32 passedIap( aInfo.iIapId ); |
|
529 |
|
530 if ( aInfo.Connected() && !passedIap ) |
|
531 { |
|
532 // in case we have an EasyWLAN here |
|
533 RCmManager cmmanager; |
|
534 cmmanager.OpenLC(); |
|
535 |
|
536 passedIap = cmmanager.EasyWlanIdL(); |
|
537 |
|
538 CleanupStack::PopAndDestroy( &cmmanager ); |
|
539 } |
|
540 |
|
541 // launch the browser |
|
542 iModel->LaunchBrowserL( passedIap ); |
|
543 } |
|
544 |
|
545 |
|
546 // -------------------------------------------------------------------------- |
|
547 // TWsfAiController::ConnectL |
|
548 // -------------------------------------------------------------------------- |
|
549 // |
|
550 void TWsfAiController::ConnectL( TWsfWlanInfo& aInfo, TBool aConnectOnly, |
|
551 TBool aTestAccessPoint ) |
|
552 { |
|
553 LOG_ENTERFN( "TWsfAiController::ConnectL" ); |
|
554 |
|
555 _ASS_D( iModel ); |
|
556 TBool testAccessPoint = aTestAccessPoint; |
|
557 iConnectOnly = aConnectOnly; |
|
558 iUsedInfo = aInfo; |
|
559 |
|
560 // Prevent connections to ad-hoc + WPA |
|
561 if ( iUsedInfo.iNetMode == CMManager::EAdhoc |
|
562 && iUsedInfo.iSecurityMode == CMManager::EWlanSecModeWpa ) |
|
563 { |
|
564 CErrorUI* errorUi = CErrorUI::NewLC(); |
|
565 errorUi->ShowGlobalErrorNoteL(KErrNotSupported); |
|
566 CleanupStack::PopAndDestroy(errorUi); // errorUi |
|
567 return; |
|
568 } |
|
569 |
|
570 // make sure we don't show connecting stuff forever |
|
571 CleanupStack::PushL( TCleanupItem( CleanUpConnectingL, this ) ); |
|
572 |
|
573 if ( !iUsedInfo.iIapId && !iUsedInfo.Hidden() && |
|
574 iUsedInfo.iSecurityMode == CMManager::EWlanSecModeOpen ) |
|
575 { |
|
576 TBool success( EFalse ); |
|
577 // just create the IAP |
|
578 TRAPD( accessPointCreatedError, |
|
579 success = iModel->CreateAccessPointL( |
|
580 iUsedInfo, EFalse ); |
|
581 ); |
|
582 |
|
583 // notify user that Disk is full or creation of a WAPI IAP |
|
584 // is not supported on-the-fly and leave |
|
585 if ( accessPointCreatedError == KErrDiskFull || |
|
586 accessPointCreatedError == KErrWlanProtectedSetupSetupLocked ) |
|
587 { |
|
588 LOG_WRITE( "showing error note" ); |
|
589 CErrorUI* errorUi = CErrorUI::NewLC(); |
|
590 errorUi->ShowGlobalErrorNoteL( accessPointCreatedError ); |
|
591 CleanupStack::PopAndDestroy( errorUi ); |
|
592 User::Leave( accessPointCreatedError ); |
|
593 } |
|
594 // just leave because we failed to create accesspoint |
|
595 else if ( accessPointCreatedError != KErrNone || !success ) |
|
596 { |
|
597 User::Leave( accessPointCreatedError ); |
|
598 } |
|
599 ConnectingL( iUsedInfo.iIapId ); |
|
600 testAccessPoint = ETrue; |
|
601 } |
|
602 else if ( !iUsedInfo.iIapId ) |
|
603 { |
|
604 testAccessPoint = ETrue; |
|
605 // let the helper app do the query if necessary |
|
606 LOG_WRITE("AiHelper needs to be launched"); |
|
607 iActiveWrappers->LaunchHelperApplicationL( iUsedInfo, |
|
608 iConnectOnly, |
|
609 testAccessPoint ); |
|
610 } |
|
611 |
|
612 // Connect |
|
613 if ( iUsedInfo.iIapId ) |
|
614 { |
|
615 if ( testAccessPoint ) |
|
616 { |
|
617 iActiveWrappers->Connect( iUsedInfo.iIapId, iConnectOnly, |
|
618 EIapExpireOnDisconnect ); |
|
619 |
|
620 } |
|
621 else |
|
622 { |
|
623 iActiveWrappers->Connect( iUsedInfo.iIapId, iConnectOnly, |
|
624 EIapPersistent ); |
|
625 } |
|
626 } |
|
627 // pop cleanup item |
|
628 CleanupStack::Pop(); |
|
629 } |
|
630 |
|
631 |
|
632 // --------------------------------------------------------------------------- |
|
633 // TWsfAiController::CleanUpConnectingL |
|
634 // --------------------------------------------------------------------------- |
|
635 // |
|
636 void TWsfAiController::CleanUpConnectingL( TAny* aPtr ) |
|
637 { |
|
638 LOG_ENTERFN( "TWsfAiController::CleanUpConnectingL" ); |
|
639 TWsfAiController* self = static_cast<TWsfAiController*>( aPtr ); |
|
640 self->iModel->SetConnecting( EFalse ); |
|
641 self->iAiModel->SetConnecting( EFalse ); |
|
642 TRAP_IGNORE( self->RefreshUiL()); |
|
643 } |
|
644 |
|
645 |
|
646 // -------------------------------------------------------------------------- |
|
647 // TWsfAiController::ContinueBrowsingL |
|
648 // -------------------------------------------------------------------------- |
|
649 // |
|
650 void TWsfAiController::ContinueBrowsingL() |
|
651 { |
|
652 LOG_ENTERFN( "TWsfAiController::ContinueBrowsingL" ); |
|
653 |
|
654 _ASS_D( iModel ); |
|
655 |
|
656 iModel->ContinueBrowsingL(); |
|
657 } |
|
658 |
|
659 |
|
660 // -------------------------------------------------------------------------- |
|
661 // TWsfAiController::LaunchSearchDialogL |
|
662 // -------------------------------------------------------------------------- |
|
663 // |
|
664 TBool TWsfAiController::LaunchSearchDialogL( TWsfWlanInfo& aInfo ) |
|
665 { |
|
666 LOG_ENTERFN( "TWsfAiController::LaunchSearchDialogL" ); |
|
667 |
|
668 _ASS_D( iAiModel ); |
|
669 _ASS_D( iUi ); |
|
670 |
|
671 MWsfAiUiObserver* temp = iUi; |
|
672 TInt selectedWlan( KFirstItemArrayIndex ); |
|
673 TBool success( EFalse ); |
|
674 |
|
675 TRAPD( err, success = DoLaunchSearchDialogL( selectedWlan ) ); |
|
676 |
|
677 iUi = temp; |
|
678 User::LeaveIfError( err ); |
|
679 |
|
680 if ( success ) |
|
681 { |
|
682 if ( iAiModel->Connected() ) |
|
683 { |
|
684 // show the error note of double connections |
|
685 HBufC* txt = StringLoader::LoadLC( |
|
686 R_QTN_WLAN_INFO_CONNECTION_ALREADY_ACTIVE ); |
|
687 |
|
688 CAknErrorNote* errorNote = new (ELeave) CAknErrorNote; |
|
689 errorNote->ExecuteLD( *txt ); |
|
690 |
|
691 CleanupStack::PopAndDestroy( txt ); |
|
692 success = EFalse; |
|
693 } |
|
694 else |
|
695 { |
|
696 CWsfWlanInfoArray* wlanArray = iAiModel->GetInfoArray(); |
|
697 // check that the model still has the entry |
|
698 if ( wlanArray && selectedWlan < wlanArray->Count() ) |
|
699 { |
|
700 // get wlan info |
|
701 aInfo = *wlanArray->At( selectedWlan ); |
|
702 } |
|
703 else |
|
704 { |
|
705 // other unlisted item was selected |
|
706 } |
|
707 } |
|
708 } |
|
709 return success; |
|
710 } |
|
711 |
|
712 |
|
713 // -------------------------------------------------------------------------- |
|
714 // TWsfAiController::DoLaunchSearchDialogL |
|
715 // -------------------------------------------------------------------------- |
|
716 // |
|
717 TBool TWsfAiController::DoLaunchSearchDialogL( TInt& aSelectedItem ) |
|
718 { |
|
719 LOG_ENTERFN( "TWsfAiController::DoLaunchSearchDialogL" ); |
|
720 |
|
721 _ASS_D( iAiModel ); |
|
722 _ASS_D( iModel ); |
|
723 |
|
724 CWsfSearchWlansDialog* dialog = CWsfSearchWlansDialog::NewL( |
|
725 aSelectedItem ); |
|
726 dialog->PrepareLC( R_QTN_PLUGIN_SEARCH_WLAN_NETWORKS ); |
|
727 |
|
728 // ownership of the icon array is passed |
|
729 CAknIconArray* icons = CWsfIconArrayCreator::CreateArrayL(); |
|
730 CleanupStack::PushL( icons ); |
|
731 iAiModel->AppendBrandIconsL( *icons ); |
|
732 dialog->SetIconArrayL( icons ); // ownership of the icon array is passed |
|
733 CleanupStack::Pop( icons ); |
|
734 |
|
735 // the dialog is ready to receive data... |
|
736 iUi = dialog; |
|
737 iUi->UpdateHotSpotsL( iAiModel->FormatWlanListL( |
|
738 iActiveWrappers->GetWLANList(), EFalse ), |
|
739 KFirstItemArrayIndex ); |
|
740 |
|
741 return dialog->RunLD(); |
|
742 } |
|
743 |
|
744 |
|
745 // -------------------------------------------------------------------------- |
|
746 // TWsfAiController::RefreshUiL |
|
747 // -------------------------------------------------------------------------- |
|
748 // |
|
749 void TWsfAiController::RefreshUiL() |
|
750 { |
|
751 LOG_ENTERFN( "TWsfAiController::RefreshUiL" ); |
|
752 |
|
753 _ASS_D( iAiModel ); |
|
754 _ASS_D( iUi ); |
|
755 |
|
756 if ( !iInfoArray ) |
|
757 { |
|
758 return; |
|
759 } |
|
760 |
|
761 MDesCArray* data = iUi->MultilineControl() ? |
|
762 iAiModel->FormatWlanListL( iInfoArray, ETrue ): |
|
763 iAiModel->FormatSingleLineWlanListL( iInfoArray ); |
|
764 |
|
765 TInt currentItem = ( iModel->IsConnecting() )? |
|
766 KSuppressRefreshIndex: KFirstItemArrayIndex; |
|
767 |
|
768 iUi->UpdateHotSpotsL( data, currentItem ); |
|
769 } |
|
770 |
|
771 |
|
772 // -------------------------------------------------------------------------- |
|
773 // TWsfAiController::EnableScanL |
|
774 // -------------------------------------------------------------------------- |
|
775 // |
|
776 void TWsfAiController::EnableScanL() |
|
777 { |
|
778 LOG_ENTERFN( "TWsfAiController::EnableScanL" ); |
|
779 |
|
780 _ASS_D( iAiModel ); |
|
781 _ASS_D( iModel ); |
|
782 _ASS_D( iUi ); |
|
783 |
|
784 if ( iAiModel->ScanningOn() ) |
|
785 { |
|
786 return; |
|
787 } |
|
788 iModel->EnableScanL(); |
|
789 iAiModel->SetScanningOn(); |
|
790 |
|
791 LOG_WRITE( "DbObserver enable scan" ); |
|
792 iDbObserver->EnableScanL(); |
|
793 |
|
794 MDesCArray *data = iAiModel->FormatRefreshingL(); |
|
795 iUi->UpdateHotSpotsL( data, KFirstItemArrayIndex ); |
|
796 } |
|
797 |
|
798 |
|
799 // -------------------------------------------------------------------------- |
|
800 // TWsfAiController::DisableScanL |
|
801 // -------------------------------------------------------------------------- |
|
802 // |
|
803 void TWsfAiController::DisableScanL() |
|
804 { |
|
805 LOG_ENTERFN( "TWsfAiController::DisableScanL" ); |
|
806 |
|
807 _ASS_D( iAiModel ); |
|
808 _ASS_D( iModel ); |
|
809 _ASS_D( iUi ); |
|
810 |
|
811 if ( !iAiModel->ScanningOn() ) |
|
812 { |
|
813 return; |
|
814 } |
|
815 iModel->DisableScanL(); |
|
816 iAiModel->SetScanningOff(); |
|
817 iDbObserver->DisableScanL(); |
|
818 iUi->DisplayEngineOffL(); |
|
819 } |
|
820 |
|
821 |
|
822 // -------------------------------------------------------------------------- |
|
823 // TWsfAiController::DoHandleEngineErrorL |
|
824 // -------------------------------------------------------------------------- |
|
825 // |
|
826 void TWsfAiController::DoHandleEngineErrorL( TInt aError ) |
|
827 { |
|
828 LOG_ENTERFN( "TWsfAiController::DoHandleEngineErrorL" ); |
|
829 // start by freeing some resources... |
|
830 // we could start by freeing wlan search results |
|
831 _ASS_D( iAiModel ); |
|
832 |
|
833 // show error to user... |
|
834 iEnv->ResolveError( aError ); |
|
835 } |
|
836 |
|
837 |
|
838 // --------------------------------------------------------------------------- |
|
839 // TWsfAiController::IsWlanUsedByBrowserL |
|
840 // --------------------------------------------------------------------------- |
|
841 // |
|
842 TBool TWsfAiController::IsWlanUsedByBrowserL() |
|
843 { |
|
844 LOG_ENTERFN( "CWsfMainView::IsWlanUsedByBrowserL" ); |
|
845 |
|
846 _ASS_D( iAiModel ); |
|
847 |
|
848 const TInt KBrowserUid = 0x10008D39; |
|
849 TUid id( TUid::Uid( KBrowserUid ) ); |
|
850 |
|
851 // Check if the Browser application is already running. |
|
852 TApaTaskList taskList( iEnv->WsSession() ); |
|
853 TApaTask task = taskList.FindApp( id ); |
|
854 TBool isWlanUsed( EFalse ); |
|
855 |
|
856 #ifndef __WINS__ |
|
857 |
|
858 if ( task.Exists() ) |
|
859 { |
|
860 LOG_WRITE( "The Browser is running." ); |
|
861 // The Browser is already running. |
|
862 // Check if the selected WLAN is connected. |
|
863 TBool connected( iAiModel->Connected() ); |
|
864 LOG_WRITEF("Connected? %d", connected); |
|
865 |
|
866 if ( connected ) |
|
867 { |
|
868 RConnectionMonitor connectionMonitor; |
|
869 connectionMonitor.ConnectL(); |
|
870 // We have to check if the Browser using the selected |
|
871 // connection. |
|
872 // We have get the connectiond ID first. |
|
873 CWsfActiveWaiter* waiter = CWsfActiveWaiter::NewL(); |
|
874 CleanupStack::PushL( waiter ); |
|
875 |
|
876 // first call, need to get the connection parameters |
|
877 TUint connectionCount( 0 ); |
|
878 |
|
879 connectionMonitor.GetConnectionCount( connectionCount, |
|
880 waiter->iStatus ); |
|
881 waiter->WaitForRequest(); |
|
882 |
|
883 // find the connection with WLAN bearer |
|
884 // that will be the selected WLAN |
|
885 TUint connectionId( 0 ); |
|
886 for ( TUint i = 1; i <= connectionCount; ++i ) |
|
887 { |
|
888 TUint tmpConnectionId( 0 ); |
|
889 TUint subConnectionCount( 0 ); |
|
890 TConnMonBearerType bearerType( EBearerUnknown ); |
|
891 |
|
892 connectionMonitor.GetConnectionInfo( i, |
|
893 tmpConnectionId, |
|
894 subConnectionCount ); |
|
895 connectionMonitor.GetIntAttribute( tmpConnectionId, |
|
896 0, |
|
897 KBearer, |
|
898 ( TInt& )bearerType, |
|
899 waiter->iStatus ); |
|
900 waiter->WaitForRequest(); |
|
901 if ( bearerType == EBearerWLAN ) |
|
902 { |
|
903 connectionId = tmpConnectionId; |
|
904 break; |
|
905 } |
|
906 } |
|
907 // Now we have the connectiond ID. |
|
908 LOG_WRITEF( "connectionId: %d", connectionId ); |
|
909 |
|
910 TInt count( 0 ); |
|
911 TConnMonClientEnumBuf clientBuf; |
|
912 |
|
913 connectionMonitor.GetPckgAttribute( connectionId, |
|
914 0, |
|
915 KClientInfo, |
|
916 clientBuf, |
|
917 waiter->iStatus ); |
|
918 waiter->WaitForRequest(); |
|
919 if ( !waiter->iStatus.Int() ) |
|
920 { |
|
921 count = clientBuf().iCount; |
|
922 } |
|
923 |
|
924 RApaLsSession appSess; |
|
925 TApaAppInfo appInfo; |
|
926 |
|
927 // The connection could be shared by several applications |
|
928 User::LeaveIfError( appSess.Connect() ); |
|
929 |
|
930 for ( TUint i = 0; i < count; i++ ) |
|
931 { |
|
932 appInfo.iCaption.Zero(); |
|
933 TInt result = appSess.GetAppInfo( appInfo, |
|
934 clientBuf().iUid[i] ); |
|
935 |
|
936 LOG_WRITEF( "result: %d", result ); |
|
937 LOG_WRITEF( "iClientInfo.iUid[i].iUid: %x", |
|
938 clientBuf().iUid[i].iUid ); |
|
939 |
|
940 if ( clientBuf().iUid[i].iUid == KBrowserUid ) |
|
941 { |
|
942 isWlanUsed = ETrue; |
|
943 } |
|
944 } |
|
945 CleanupStack::PopAndDestroy( waiter ); |
|
946 appSess.Close(); |
|
947 connectionMonitor.Close(); |
|
948 } |
|
949 } |
|
950 else |
|
951 { |
|
952 LOG_WRITE( "No Browser running." ); |
|
953 } |
|
954 |
|
955 #endif // __WINS__ |
|
956 |
|
957 LOG_WRITEF( "isWlanUsedByBrowser: %d", isWlanUsed ); |
|
958 return isWlanUsed; |
|
959 } |
|
960 |
|
961 |
|
962 // -------------------------------------------------------------------------- |
|
963 // TWsfAiController::HandleMskIfOfflineL |
|
964 // -------------------------------------------------------------------------- |
|
965 // |
|
966 void TWsfAiController::HandleMskIfOfflineL() |
|
967 { |
|
968 LOG_ENTERFN( "TWsfAiController::HandleMskIfOfflineL" ); |
|
969 |
|
970 // create the dialog with options |
|
971 TInt selectedMode( 0 ); |
|
972 CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog( |
|
973 &selectedMode ); |
|
974 listQuery->PrepareLC( R_QTN_AIPLUGIN_OPTIONS_OFFLINE ); |
|
975 |
|
976 if ( !listQuery->RunLD() ) |
|
977 { |
|
978 // cancelled |
|
979 return; |
|
980 } |
|
981 |
|
982 CWsfWlanInfoArray* wlanArray = iAiModel->GetInfoArray(); |
|
983 |
|
984 switch ( selectedMode ) |
|
985 { |
|
986 case EAiOfflineStartBrowsing: |
|
987 { |
|
988 // Start web browsing was selected |
|
989 if ( !wlanArray || !wlanArray->Count() || |
|
990 !wlanArray->At( KFirstItemArrayIndex )->Known() ) |
|
991 { |
|
992 // no known networks, let the user choose one |
|
993 TWsfWlanInfo info; |
|
994 |
|
995 if ( LaunchSearchDialogL( info ) ) |
|
996 { |
|
997 StartBrowsingL( info ); |
|
998 } |
|
999 } |
|
1000 else |
|
1001 { |
|
1002 // there are known networks |
|
1003 StartBrowsingL( *wlanArray->At( KFirstItemArrayIndex ) ); |
|
1004 } |
|
1005 |
|
1006 break; |
|
1007 } |
|
1008 |
|
1009 case EAiOfflineConnect: |
|
1010 { |
|
1011 // Connect was selected |
|
1012 if ( !wlanArray || !wlanArray->Count() || |
|
1013 !wlanArray->At( KFirstItemArrayIndex )->Known() ) |
|
1014 { |
|
1015 // no known networks, let the user choose one |
|
1016 TWsfWlanInfo info; |
|
1017 |
|
1018 if ( LaunchSearchDialogL( info ) ) |
|
1019 { |
|
1020 ConnectL( info, ETrue, EFalse ); |
|
1021 } |
|
1022 } |
|
1023 else |
|
1024 { |
|
1025 // there are known networks |
|
1026 ConnectL( *wlanArray->At( KFirstItemArrayIndex ), ETrue, |
|
1027 EFalse ); |
|
1028 } |
|
1029 |
|
1030 break; |
|
1031 } |
|
1032 |
|
1033 case EAiOfflineSearchWlans: |
|
1034 { |
|
1035 // Search for wlans was selected |
|
1036 if ( !wlanArray || !wlanArray->Count() ) |
|
1037 { |
|
1038 // there are no available networks |
|
1039 CConnectionUiUtilities* connUiUtils = CConnectionUiUtilities::NewL(); |
|
1040 connUiUtils->NoWLANNetworksAvailableNote(); |
|
1041 delete connUiUtils; |
|
1042 } |
|
1043 |
|
1044 // launch the search dialog |
|
1045 TWsfWlanInfo info; |
|
1046 |
|
1047 if ( LaunchSearchDialogL( info ) ) |
|
1048 { |
|
1049 ConnectL( info, ETrue, EFalse ); |
|
1050 } |
|
1051 else |
|
1052 { |
|
1053 // User canceled Search Wlans dialog and probably did not |
|
1054 // find anything interesting from the list - request scan |
|
1055 iActiveWrappers->RefreshScan(); |
|
1056 } |
|
1057 |
|
1058 break; |
|
1059 } |
|
1060 |
|
1061 case EAiOfflineDisableScan: |
|
1062 { |
|
1063 // disable the scan |
|
1064 DisableScanL(); |
|
1065 break; |
|
1066 } |
|
1067 |
|
1068 default: |
|
1069 { |
|
1070 } |
|
1071 } |
|
1072 } |
|
1073 |
|
1074 |
|
1075 |
|
1076 // -------------------------------------------------------------------------- |
|
1077 // TWsfAiController::HandleMskIfConnectedL |
|
1078 // -------------------------------------------------------------------------- |
|
1079 // |
|
1080 void TWsfAiController::HandleMskIfConnectedL() |
|
1081 { |
|
1082 LOG_ENTERFN( "TWsfAiController::HandleMskIfConnectedL" ); |
|
1083 |
|
1084 _ASS_D( iModel ); |
|
1085 |
|
1086 TInt selectedMode( 0 ); |
|
1087 CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog( |
|
1088 &selectedMode ); |
|
1089 listQuery->PrepareLC( R_QTN_AIPLUGIN_OPTIONS_CONNECTED ); |
|
1090 |
|
1091 if ( listQuery->RunLD() ) |
|
1092 { |
|
1093 if ( selectedMode == EAiConnectedStartBrowsing ) |
|
1094 { |
|
1095 StartBrowsingL( iConnectedWlan ); |
|
1096 } |
|
1097 else if ( selectedMode == EAiConnectedDisconnect ) |
|
1098 { |
|
1099 // disconnect wlan |
|
1100 iActiveWrappers->Disconnect(); |
|
1101 } |
|
1102 } |
|
1103 } |
|
1104 |
|
1105 |
|
1106 // -------------------------------------------------------------------------- |
|
1107 // TWsfAiController::HandleMskIfConnectingL |
|
1108 // -------------------------------------------------------------------------- |
|
1109 // |
|
1110 void TWsfAiController::HandleMskIfConnectingL() |
|
1111 { |
|
1112 LOG_ENTERFN( "TWsfAiController::HandleMskIfConnectingL" ); |
|
1113 |
|
1114 _ASS_D( iModel ); |
|
1115 |
|
1116 TInt selectedMode( 0 ); |
|
1117 CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog( |
|
1118 &selectedMode ); |
|
1119 listQuery->PrepareLC( R_QTN_AIPLUGIN_OPTIONS_CONNECTING ); |
|
1120 |
|
1121 if ( listQuery->RunLD() ) |
|
1122 { |
|
1123 if ( selectedMode == EAiConnectingDisconnect ) |
|
1124 { |
|
1125 if ( !iModel->IsConnecting() ) |
|
1126 { |
|
1127 // disconnect wlan |
|
1128 iActiveWrappers->Disconnect(); |
|
1129 } |
|
1130 else |
|
1131 { |
|
1132 // disconnect wlan |
|
1133 iModel->AbortConnectingL(); |
|
1134 ConnectingFinishedL( KErrCancel ); |
|
1135 } |
|
1136 } |
|
1137 } |
|
1138 } |
|
1139 |
|
1140 |
|
1141 // -------------------------------------------------------------------------- |
|
1142 // TWsfAiController::HandleMskIfBrowsingL |
|
1143 // -------------------------------------------------------------------------- |
|
1144 // |
|
1145 void TWsfAiController::HandleMskIfBrowsingL() |
|
1146 { |
|
1147 LOG_ENTERFN( "TWsfAiController::HandleMskIfBrowsingL" ); |
|
1148 |
|
1149 _ASS_D( iModel ); |
|
1150 |
|
1151 TInt selectedMode( KFirstItemArrayIndex ); |
|
1152 CAknListQueryDialog* listQuery = new (ELeave) CAknListQueryDialog( |
|
1153 &selectedMode ); |
|
1154 listQuery->PrepareLC( R_QTN_AIPLUGIN_OPTIONS_BROWSING ); |
|
1155 |
|
1156 if ( listQuery->RunLD() ) |
|
1157 { |
|
1158 if ( selectedMode == EAiBrowsingContinueBrowsing ) |
|
1159 { |
|
1160 // launch the browser... |
|
1161 ContinueBrowsingL(); |
|
1162 } |
|
1163 else if ( selectedMode == EAiBrowsingDisconnect ) |
|
1164 { |
|
1165 // disconnect wlan |
|
1166 iActiveWrappers->Disconnect(); |
|
1167 } |
|
1168 } |
|
1169 } |
|
1170 |
|
1171 // -------------------------------------------------------------------------- |
|
1172 // TWsfAiController::RefreshRefreshingL |
|
1173 // -------------------------------------------------------------------------- |
|
1174 // |
|
1175 void TWsfAiController::RefreshRefreshingL() |
|
1176 { |
|
1177 LOG_ENTERFN( "TWsfAiController::RefreshRefreshingL" ); |
|
1178 if ( !iUi->MultilineControl() ) |
|
1179 { |
|
1180 MDesCArray *data = iAiModel->FormatRefreshingL(); |
|
1181 iUi->UpdateViewL( data ); |
|
1182 } |
|
1183 else |
|
1184 { |
|
1185 LOG_WRITE( "Multiline control in use - no update done" ); |
|
1186 } |
|
1187 } |
|
1188 |
|
1189 // -------------------------------------------------------------------------- |
|
1190 // TWsfAiController::RefreshConnectingL |
|
1191 // -------------------------------------------------------------------------- |
|
1192 // |
|
1193 void TWsfAiController::RefreshConnectingL() |
|
1194 { |
|
1195 LOG_ENTERFN( "TWsfAiController::RefreshConnectingL" ); |
|
1196 if ( !iUi->MultilineControl() ) |
|
1197 { |
|
1198 MDesCArray *data = iAiModel->FormatConnectingL(); |
|
1199 iUi->UpdateViewL( data ); |
|
1200 } |
|
1201 else |
|
1202 { |
|
1203 LOG_WRITE( "Multiline control in use - no update done" ); |
|
1204 } |
|
1205 } |
|
1206 |
|
1207 // End of file |
|