|
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 CWsfAiPlugin |
|
15 * |
|
16 */ |
|
17 |
|
18 // EXTERNAL INCLUDES |
|
19 #include <aicontentobserver.h> |
|
20 #include <aiutility.h> |
|
21 #include <apgcli.h> |
|
22 #include <wsfaipluginrsc.rsg> |
|
23 |
|
24 #include <e32std.h> |
|
25 #include <ecom/ecom.h> |
|
26 #include <ecom/implementationproxy.h> |
|
27 |
|
28 #include <f32file.h> |
|
29 #include <AknsConstants.h> |
|
30 #include <AknUtils.h> |
|
31 #include <StringLoader.h> |
|
32 #include <bautils.h> |
|
33 #include <avkon.rsg> |
|
34 #include <apgtask.h> |
|
35 #include <eiklabel.h> |
|
36 |
|
37 #include <data_caging_path_literals.hrh> // KDC_APP_BITMAP_DIR |
|
38 |
|
39 // INTERNAL INCLUDES |
|
40 #include "wsfaiplugin.h" |
|
41 #include "wsfaipluginuids.hrh" |
|
42 #include "wsfaiplugincontentmodel.h" |
|
43 #include "wsfaimodel.h" |
|
44 #include "wsfmodel.h" |
|
45 #include "wsfaiview.h" |
|
46 #include "wsficonarraycreator.h" |
|
47 #include "wsfdbobserver.h" |
|
48 #include "wsflogger.h" |
|
49 |
|
50 |
|
51 // define icon id for Navigation Bar icon |
|
52 LOCAL_D const TInt KNaviBarIcon = EWlanOffIcon; |
|
53 LOCAL_D const TInt KTransparentIcon = ETransparentIcon; |
|
54 LOCAL_D const TUid KUidSnifferApp = {0x10281CAA}; |
|
55 LOCAL_D const TInt KRefreshStepTime = 200 * 1000; |
|
56 LOCAL_D const TInt KConnectingStepTime = 200 * 1000; |
|
57 _LIT8( KWlanWizardName, "WLANWizard" ); |
|
58 |
|
59 |
|
60 |
|
61 // -------------------------------------------------------------------------- |
|
62 // CWsfAiPlugin::NewL |
|
63 // -------------------------------------------------------------------------- |
|
64 // |
|
65 CWsfAiPlugin* CWsfAiPlugin::NewL() |
|
66 { |
|
67 LOG_ENTERFN( "CWsfAiPlugin::NewL" ); |
|
68 CWsfAiPlugin* self = new (ELeave) CWsfAiPlugin; |
|
69 |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(self); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // -------------------------------------------------------------------------- |
|
79 // CWsfAiPlugin::~CWsfAiPlugin |
|
80 // -------------------------------------------------------------------------- |
|
81 // |
|
82 CWsfAiPlugin::~CWsfAiPlugin() |
|
83 { |
|
84 // Cancel periodic animation update |
|
85 if ( iAnimationPeriodic ) |
|
86 { |
|
87 LOG_WRITE( "Cancel animation update" ); |
|
88 iAnimationPeriodic->Cancel(); |
|
89 delete iAnimationPeriodic; |
|
90 iAnimationPeriodic = NULL; |
|
91 } |
|
92 |
|
93 delete iDbObserver; |
|
94 |
|
95 // Cancel start up refresh |
|
96 if ( iStartupRefresh ) |
|
97 { |
|
98 LOG_WRITE( "Cancel start up refresh" ); |
|
99 iStartupRefresh->Cancel(); |
|
100 delete iStartupRefresh; |
|
101 iStartupRefresh = NULL; |
|
102 } |
|
103 |
|
104 delete iModel; |
|
105 delete iAiModel; |
|
106 delete iUi; |
|
107 |
|
108 delete iCurrentSignalStrength; |
|
109 delete iCurrentSecureInfo; |
|
110 |
|
111 if ( iWlanTitle ) |
|
112 { |
|
113 delete iWlanTitle; |
|
114 } |
|
115 |
|
116 if ( iMskActivate ) |
|
117 { |
|
118 delete iMskActivate; |
|
119 } |
|
120 |
|
121 if ( iConnectedTo ) |
|
122 { |
|
123 delete iConnectedTo; |
|
124 } |
|
125 |
|
126 if ( iKnownNetworkFound ) |
|
127 { |
|
128 delete iKnownNetworkFound; |
|
129 } |
|
130 |
|
131 CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); |
|
132 |
|
133 iObservers.Close(); |
|
134 |
|
135 Release( iContent ); |
|
136 Release( iEvents ); |
|
137 } |
|
138 |
|
139 |
|
140 // -------------------------------------------------------------------------- |
|
141 // CWsfAiPlugin::CWsfAiPlugin |
|
142 // -------------------------------------------------------------------------- |
|
143 // |
|
144 CWsfAiPlugin::CWsfAiPlugin() |
|
145 { |
|
146 } |
|
147 |
|
148 |
|
149 // -------------------------------------------------------------------------- |
|
150 // CWsfAiPlugin::ConstructL |
|
151 // -------------------------------------------------------------------------- |
|
152 // |
|
153 void CWsfAiPlugin::ConstructL() |
|
154 { |
|
155 LOG_ENTERFN( "CWsfAiPlugin::ConstructL" ); |
|
156 AllocateResourcesL(); |
|
157 |
|
158 iInfo.iUid = KUidWlanWizardPlugin; |
|
159 iInfo.iName.Copy( KWlanWizardName ); |
|
160 |
|
161 iContent = AiUtility::CreateContentItemArrayIteratorL( |
|
162 KAiWizardContent ); |
|
163 iEvents = AiUtility::CreateContentItemArrayIteratorL( KAiWizardEvents ); |
|
164 |
|
165 // create the engine first... |
|
166 iModel = CWsfModel::NewL( iController, EFalse ); |
|
167 |
|
168 // then model |
|
169 iAiModel = CWsfAiModel::NewL(); |
|
170 iUi = CWsfAiView::NewL( *this ); |
|
171 iStartupRefresh = new (ELeave) CAsyncCallBack( |
|
172 TCallBack( StartupRefresh, this ), |
|
173 CActive::EPriorityIdle ); |
|
174 iDbObserver = CWsfDbObserver::NewL(); |
|
175 iController.SetUi( *static_cast<CWsfAiView*>( iUi ) ); |
|
176 iController.InitializeL( iModel, iAiModel, iDbObserver ); |
|
177 } |
|
178 |
|
179 |
|
180 // -------------------------------------------------------------------------- |
|
181 // CWsfAiPlugin::PublishContentL |
|
182 // -------------------------------------------------------------------------- |
|
183 // |
|
184 void CWsfAiPlugin::PublishContentL( CArrayFix<TInt>* aPublishIconArray, |
|
185 CEikLabel* aText1 ) |
|
186 { |
|
187 LOG_ENTERFN( "CWsfAiPlugin::PublishContentL" ); |
|
188 TInt leftBoundary( 0 ); |
|
189 TInt rightBoundary( 0 ); |
|
190 TChar boundary('\''); |
|
191 HBufC* localCurrentStatusText( NULL ); |
|
192 HBufC* localCurrentTypeText( NULL ); |
|
193 |
|
194 HBufC* localCurrentNetworkStatus( NULL ); |
|
195 HBufC* localCurrentNetworkName( NULL ); |
|
196 |
|
197 HBufC* localFullText = ( aText1->Text() )->AllocLC(); |
|
198 |
|
199 // Locate ' chars from the full string |
|
200 TPtrC fullText = localFullText->Des(); |
|
201 leftBoundary = fullText.Locate( boundary ); // char = ' |
|
202 rightBoundary = fullText.LocateReverse( boundary ); |
|
203 |
|
204 // if we have status name then we parse it |
|
205 if ( leftBoundary != rightBoundary && |
|
206 leftBoundary != KErrNotFound && |
|
207 rightBoundary != KErrNotFound ) |
|
208 { |
|
209 TPtrC begin = fullText.Mid( leftBoundary, |
|
210 rightBoundary - leftBoundary + 1 ); |
|
211 localCurrentStatusText = begin.AllocLC(); |
|
212 localCurrentNetworkName = begin.AllocLC(); |
|
213 |
|
214 TPtrC end = fullText.Mid( rightBoundary + 1 ); |
|
215 localCurrentTypeText = end.AllocLC(); |
|
216 } |
|
217 else |
|
218 { |
|
219 localCurrentStatusText = fullText.AllocLC(); |
|
220 delete localCurrentTypeText; |
|
221 localCurrentTypeText = NULL; |
|
222 } |
|
223 |
|
224 //Connected |
|
225 if ( localCurrentNetworkName ) |
|
226 { |
|
227 if ( iAiModel->Connected() ) |
|
228 { |
|
229 if ( !iConnectedTo ) |
|
230 { |
|
231 iConnectedTo = StringLoader::LoadL( |
|
232 R_QTN_SNIFFER_PLUG_IN_CONNECTED_TO ); |
|
233 } |
|
234 localCurrentNetworkStatus = iConnectedTo; |
|
235 } |
|
236 else |
|
237 { |
|
238 if ( !iKnownNetworkFound ) |
|
239 { |
|
240 iKnownNetworkFound = StringLoader::LoadL( |
|
241 R_QTN_SNIFFER_PLUG_IN_WLAN_NETWORK_FOUND ); |
|
242 } |
|
243 localCurrentNetworkStatus = iKnownNetworkFound; |
|
244 } |
|
245 } |
|
246 else |
|
247 { |
|
248 localCurrentNetworkStatus = localCurrentStatusText; |
|
249 } |
|
250 |
|
251 TBool published( EFalse ); |
|
252 TInt iconId( 0 ); |
|
253 |
|
254 ClearL(); // Clear all WLAN Wizard content from the AI2 |
|
255 |
|
256 for ( iCurrentObserverIndex = 0; |
|
257 iCurrentObserverIndex < iObservers.Count(); |
|
258 ++iCurrentObserverIndex ) |
|
259 { |
|
260 MAiContentObserver* observer = iObservers[iCurrentObserverIndex]; |
|
261 observer->StartTransaction( reinterpret_cast<TInt32>( this ) ); |
|
262 // make sure we cancel the tracsaction if leaves |
|
263 CleanupStack::PushL( TCleanupItem( PublishCleanup, this ) ); |
|
264 |
|
265 // Publish Full Text if Classic or Navigation Bar Classic used |
|
266 if ( localFullText ) |
|
267 { |
|
268 published = PublishText( observer, |
|
269 EAiWizardContentFullText, |
|
270 *localFullText ) || published; |
|
271 } |
|
272 |
|
273 // Publish Navigation Bar Icon: EAiWizardContentNaviBarIcon |
|
274 published = PublishIconL( observer, |
|
275 EAiWizardContentNaviBarIcon, |
|
276 KNaviBarIcon ) || published; |
|
277 |
|
278 // Publish Application Title: EAiWizardContentTitleText |
|
279 if ( !iWlanTitle ) |
|
280 { |
|
281 iWlanTitle = StringLoader::LoadL( R_QTN_AI_WIZARD_TITLE ); |
|
282 } |
|
283 if ( iWlanTitle ) |
|
284 { |
|
285 published = PublishText( observer, |
|
286 EAiWizardContentTitleText, |
|
287 *iWlanTitle ) || published; |
|
288 } |
|
289 |
|
290 if ( localCurrentStatusText ) |
|
291 { |
|
292 // Publish Status icon: EAiWizardContentStatusIcon |
|
293 iconId = aPublishIconArray->At( 0 ); |
|
294 published = PublishIconL( observer, |
|
295 EAiWizardContentStatusIcon, |
|
296 iconId ) || published; |
|
297 |
|
298 // Publish Status text: EAiWizardContentStatusText |
|
299 published = PublishText( observer, |
|
300 EAiWizardContentStatusText, |
|
301 *localCurrentStatusText ) || published; |
|
302 } |
|
303 |
|
304 if ( localCurrentTypeText ) |
|
305 { |
|
306 // Publish Type icon: EAiWizardContentTypeIcon |
|
307 published = PublishIconL( observer, |
|
308 EAiWizardContentTypeIcon, |
|
309 KTransparentIcon ) || published; |
|
310 |
|
311 // Publish Type text: EAiWizardContentTypeText |
|
312 published = PublishText( observer, |
|
313 EAiWizardContentTypeText, |
|
314 *localCurrentTypeText ) || published; |
|
315 } |
|
316 |
|
317 // Publish Strength icon: EAiWizardContentStrengthIcon |
|
318 iconId = aPublishIconArray->At( 2 ); |
|
319 published = PublishIconL( observer, |
|
320 EAiWizardContentStrengthIcon, |
|
321 iconId ) || published; |
|
322 |
|
323 // Publish Strength text: EAiWizardContentStrengthText |
|
324 if ( iCurrentSignalStrength && iScanState ) |
|
325 { |
|
326 published = PublishText( observer, |
|
327 EAiWizardContentStrengthText, |
|
328 *iCurrentSignalStrength ) || published; |
|
329 } |
|
330 |
|
331 // Publish Secure icon: EAiWizardContentSecureIcon |
|
332 iconId = aPublishIconArray->At( 1 ); |
|
333 published = PublishIconL( observer, |
|
334 EAiWizardContentSecureIcon, |
|
335 iconId ) || published; |
|
336 |
|
337 // Publish Secure text: EAiWizardContentSecureText |
|
338 if ( iCurrentSecureInfo && iScanState ) |
|
339 { |
|
340 published = PublishText( observer, |
|
341 EAiWizardContentSecureText, |
|
342 *iCurrentSecureInfo ) || published; |
|
343 } |
|
344 |
|
345 if ( localCurrentNetworkName ) |
|
346 { |
|
347 // Publish NetworkName text: EAiWizardContentNetworkName |
|
348 published = PublishText( observer, |
|
349 EAiWizardContentNetworkName, |
|
350 *localCurrentNetworkName ) || published; |
|
351 } |
|
352 |
|
353 if ( localCurrentNetworkStatus ) |
|
354 { |
|
355 // Publish NetworkName text: EAiWizardContentNetworkName |
|
356 published = PublishText( observer, |
|
357 EAiWizardContentNetworkStatus, |
|
358 *localCurrentNetworkStatus ) || published; |
|
359 } |
|
360 |
|
361 // If we published something then commit, |
|
362 // otherwise cancel transaction |
|
363 if ( published ) |
|
364 { |
|
365 observer->Commit( reinterpret_cast<TInt32>( this ) ); |
|
366 published = EFalse; |
|
367 } |
|
368 else |
|
369 { |
|
370 observer->CancelTransaction( reinterpret_cast<TInt32>( this ) ); |
|
371 } |
|
372 CleanupStack::Pop( 1 ); // PublishCleanup() |
|
373 } |
|
374 |
|
375 if ( localCurrentTypeText ) |
|
376 { |
|
377 CleanupStack::PopAndDestroy( localCurrentTypeText ); |
|
378 } |
|
379 |
|
380 if ( localCurrentNetworkName ) |
|
381 { |
|
382 CleanupStack::PopAndDestroy( localCurrentNetworkName ); |
|
383 } |
|
384 |
|
385 if ( localCurrentStatusText ) |
|
386 { |
|
387 CleanupStack::PopAndDestroy( localCurrentStatusText ); |
|
388 } |
|
389 |
|
390 CleanupStack::PopAndDestroy( localFullText ); |
|
391 } |
|
392 |
|
393 |
|
394 // -------------------------------------------------------------------------- |
|
395 // CWsfAiPlugin::AllocateResourcesL |
|
396 // -------------------------------------------------------------------------- |
|
397 // |
|
398 void CWsfAiPlugin::AllocateResourcesL() |
|
399 { |
|
400 LOG_ENTERFN( "CWsfAiPlugin::AllocateResourcesL" ); |
|
401 // create resourcefile |
|
402 CCoeEnv* env = CCoeEnv::Static(); |
|
403 TFindFile finder( env->FsSession() ); |
|
404 CDir* fileEntries; |
|
405 User::LeaveIfError( finder.FindWildByDir( KResourceFile, |
|
406 KDC_RESOURCE_FILES_DIR, |
|
407 fileEntries ) ); |
|
408 |
|
409 TParse pathParse; |
|
410 pathParse.Set( (*fileEntries)[0].iName, &finder.File(), NULL ); |
|
411 |
|
412 TFileName resourceFile = pathParse.FullName(); |
|
413 delete fileEntries; |
|
414 |
|
415 BaflUtils::NearestLanguageFile( env->FsSession(), resourceFile ); |
|
416 iResourceFileOffset = env->AddResourceFileL( resourceFile ); |
|
417 } |
|
418 |
|
419 |
|
420 // -------------------------------------------------------------------------- |
|
421 // CWsfAiPlugin::Resume |
|
422 // -------------------------------------------------------------------------- |
|
423 // |
|
424 void CWsfAiPlugin::Resume( TAiTransitionReason aReason ) |
|
425 { |
|
426 LOG_ENTERFN( "CWsfAiPlugin::Resume" ); |
|
427 switch ( aReason ) |
|
428 { |
|
429 case EAiSystemStartup: |
|
430 { |
|
431 LOG_WRITE( "Resume - EAiSystemStartup"); |
|
432 iStartupRefresh->CallBack(); |
|
433 break; |
|
434 } |
|
435 |
|
436 case EAiIdleForeground: |
|
437 { |
|
438 // AI came to foreground -> make refresh scan |
|
439 if ( !iAiModel->Connected() && !iModel->IsConnecting() ) |
|
440 { |
|
441 LOG_WRITE( "Call Refresh scan" ); |
|
442 TRAP_IGNORE( iModel->RefreshScanL() ); |
|
443 } |
|
444 else |
|
445 { |
|
446 LOG_WRITE( "Connected no need to refresh scan results" ); |
|
447 } |
|
448 break; |
|
449 } |
|
450 |
|
451 case EAiIdleBackground: |
|
452 { |
|
453 // AI went to background -> dismiss open dialogs/menus |
|
454 TRAP_IGNORE( iController.DismissDialogsL() ); |
|
455 break; |
|
456 } |
|
457 |
|
458 default: |
|
459 { |
|
460 break; |
|
461 } |
|
462 } |
|
463 } |
|
464 |
|
465 |
|
466 // -------------------------------------------------------------------------- |
|
467 // CWsfAiPlugin::Suspend |
|
468 // -------------------------------------------------------------------------- |
|
469 // |
|
470 void CWsfAiPlugin::Suspend( TAiTransitionReason /*aReason*/ ) |
|
471 { |
|
472 LOG_ENTERFN( "CWsfAiPlugin::Suspend" ); |
|
473 } |
|
474 |
|
475 |
|
476 // -------------------------------------------------------------------------- |
|
477 // CWsfAiPlugin::Stop |
|
478 // -------------------------------------------------------------------------- |
|
479 // |
|
480 void CWsfAiPlugin::Stop( TAiTransitionReason /*aReason*/ ) |
|
481 { |
|
482 LOG_ENTERFN( "CWsfAiPlugin::Stop" ); |
|
483 TRAP_IGNORE( iController.DeInitializeL() ); |
|
484 if ( iAnimationPeriodic ) |
|
485 { |
|
486 LOG_WRITE( "Cancel animation update" ); |
|
487 iAnimationPeriodic->Cancel(); |
|
488 delete iAnimationPeriodic; |
|
489 iAnimationPeriodic = NULL; |
|
490 } |
|
491 } |
|
492 |
|
493 |
|
494 // -------------------------------------------------------------------------- |
|
495 // CWsfAiPlugin::SubscribeL |
|
496 // -------------------------------------------------------------------------- |
|
497 // |
|
498 void CWsfAiPlugin::SubscribeL( MAiContentObserver& aObserver ) |
|
499 { |
|
500 LOG_ENTERFN( "CWsfAiPlugin::Subscribe" ); |
|
501 return iObservers.AppendL( &aObserver ); |
|
502 } |
|
503 |
|
504 |
|
505 // -------------------------------------------------------------------------- |
|
506 // CWsfAiPlugin::ConfigureL |
|
507 // -------------------------------------------------------------------------- |
|
508 // |
|
509 void CWsfAiPlugin::ConfigureL( RAiSettingsItemArray& /*aSettings*/ ) |
|
510 { |
|
511 LOG_ENTERFN( "CWsfAiPlugin::ConfigureL" ); |
|
512 } |
|
513 |
|
514 |
|
515 // -------------------------------------------------------------------------- |
|
516 // CWsfAiPlugin::Extension |
|
517 // -------------------------------------------------------------------------- |
|
518 // |
|
519 TAny* CWsfAiPlugin::Extension( TUid aUid ) |
|
520 { |
|
521 LOG_ENTERFN( "CWsfAiPlugin::Extension" ); |
|
522 if ( aUid == KExtensionUidProperty ) |
|
523 { |
|
524 return static_cast<MAiPropertyExtension*>( this ); |
|
525 } |
|
526 else if ( aUid == KExtensionUidEventHandler ) |
|
527 { |
|
528 return static_cast<MAiEventHandlerExtension*>( this ); |
|
529 } |
|
530 |
|
531 return NULL; |
|
532 } |
|
533 |
|
534 |
|
535 // -------------------------------------------------------------------------- |
|
536 // CWsfAiPlugin::GetPropertyL |
|
537 // -------------------------------------------------------------------------- |
|
538 // |
|
539 TAny* CWsfAiPlugin::GetPropertyL( TInt aProperty ) |
|
540 { |
|
541 switch ( aProperty ) |
|
542 { |
|
543 case EAiPublisherInfo: |
|
544 { |
|
545 return &iInfo; |
|
546 } |
|
547 |
|
548 case EAiPublisherContent: |
|
549 { |
|
550 return static_cast<MAiContentItemIterator*>( iContent ); |
|
551 } |
|
552 |
|
553 case EAiPublisherEvents: |
|
554 { |
|
555 return static_cast<MAiContentItemIterator*>( iEvents ); |
|
556 } |
|
557 |
|
558 default: |
|
559 { |
|
560 User::Leave( KErrNotSupported ); |
|
561 } |
|
562 } |
|
563 |
|
564 return NULL; |
|
565 } |
|
566 |
|
567 |
|
568 // -------------------------------------------------------------------------- |
|
569 // CWsfAiPlugin::SetPropertyL |
|
570 // -------------------------------------------------------------------------- |
|
571 // |
|
572 void CWsfAiPlugin::SetPropertyL( TInt aProperty, TAny* aValue ) |
|
573 { |
|
574 LOG_ENTERFN( "CWsfAiPlugin::SetProperty" ); |
|
575 if ( aValue && ( aProperty == EAiPublisherInfo ) ) |
|
576 { |
|
577 const TAiPublisherInfo* info = |
|
578 static_cast<const TAiPublisherInfo*>( aValue ); |
|
579 iInfo = *info; |
|
580 } |
|
581 } |
|
582 |
|
583 |
|
584 // -------------------------------------------------------------------------- |
|
585 // CWsfAiPlugin::HandleEvent |
|
586 // -------------------------------------------------------------------------- |
|
587 // |
|
588 void CWsfAiPlugin::HandleEvent( TInt aEvent, const TDesC& /*aParam*/ ) |
|
589 { |
|
590 LOG_ENTERFN( "CWsfAiPlugin::HandleEvent" ); |
|
591 switch ( aEvent ) |
|
592 { |
|
593 case EAiWizardEventLaunchApplication: |
|
594 { |
|
595 TRAP_IGNORE( LaunchApplicationL() ); |
|
596 break; |
|
597 } |
|
598 |
|
599 case EAiWizardGainFocusInfoArea: |
|
600 { |
|
601 iInfoAreaFocus = ETrue; |
|
602 TRAP_IGNORE( SetMskL() ); |
|
603 break; |
|
604 } |
|
605 |
|
606 case EAiWizardLostFocusInfoArea: |
|
607 { |
|
608 iInfoAreaFocus = EFalse; |
|
609 break; |
|
610 } |
|
611 |
|
612 case EAiWizardOpenMenu: |
|
613 { |
|
614 if ( !iRefreshing ) |
|
615 { |
|
616 TRAP_IGNORE( iController.HandleSelectionKeyL() ); |
|
617 } |
|
618 break; |
|
619 } |
|
620 |
|
621 default: |
|
622 { |
|
623 } |
|
624 } |
|
625 } |
|
626 |
|
627 |
|
628 // -------------------------------------------------------------------------- |
|
629 // CWsfAiPlugin::ClearL |
|
630 // -------------------------------------------------------------------------- |
|
631 // |
|
632 void CWsfAiPlugin::ClearL() |
|
633 { |
|
634 LOG_ENTERFN( "CWsfAiPlugin::ClearL" ); |
|
635 for ( TInt i = 0; i < iObservers.Count(); ++i ) |
|
636 { |
|
637 MAiContentObserver* observer = iObservers[i]; |
|
638 |
|
639 observer->StartTransaction( reinterpret_cast<TInt32>( this ) ); |
|
640 |
|
641 observer->Clean( *this, EAiWizardContentNaviBarIcon, |
|
642 EAiWizardContentNaviBarIcon ); |
|
643 observer->Clean( *this, EAiWizardContentTitleText, |
|
644 EAiWizardContentTitleText ); |
|
645 observer->Clean( *this, EAiWizardContentStatusIcon, |
|
646 EAiWizardContentStatusIcon ); |
|
647 observer->Clean( *this, EAiWizardContentStatusText, |
|
648 EAiWizardContentStatusText ); |
|
649 observer->Clean( *this, EAiWizardContentTypeIcon, |
|
650 EAiWizardContentTypeIcon ); |
|
651 observer->Clean( *this, EAiWizardContentTypeText, |
|
652 EAiWizardContentTypeText ); |
|
653 observer->Clean( *this, EAiWizardContentStrengthIcon, |
|
654 EAiWizardContentStrengthIcon ); |
|
655 observer->Clean( *this, EAiWizardContentStrengthText, |
|
656 EAiWizardContentStrengthText ); |
|
657 observer->Clean( *this, EAiWizardContentSecureIcon, |
|
658 EAiWizardContentSecureIcon ); |
|
659 observer->Clean( *this, EAiWizardContentSecureText, |
|
660 EAiWizardContentSecureText ); |
|
661 observer->Clean( *this, EAiWizardContentNetworkName, |
|
662 EAiWizardContentNetworkName ); |
|
663 observer->Commit( reinterpret_cast<TInt32>( this ) ); |
|
664 } |
|
665 } |
|
666 |
|
667 |
|
668 // -------------------------------------------------------------------------- |
|
669 // CWsfAiPlugin::SetStrengthAndSecure |
|
670 // -------------------------------------------------------------------------- |
|
671 // |
|
672 void CWsfAiPlugin::SetStrengthAndSecure( TDesC* aStrength, TDesC* aSecure ) |
|
673 { |
|
674 LOG_ENTERFN( "CWsfAiPlugin::SetStrengthAndSecure" ); |
|
675 delete iCurrentSignalStrength; |
|
676 iCurrentSignalStrength = NULL; |
|
677 if ( aStrength && aStrength->Length() > 0) |
|
678 { |
|
679 iCurrentSignalStrength = aStrength->Alloc(); |
|
680 } |
|
681 |
|
682 delete iCurrentSecureInfo; |
|
683 iCurrentSecureInfo = NULL; |
|
684 if ( aSecure && aSecure->Length() > 0) |
|
685 { |
|
686 // r_qtn_sniffer_plug_in_content_secure |
|
687 iCurrentSecureInfo = aSecure->Alloc(); |
|
688 } |
|
689 } |
|
690 |
|
691 |
|
692 // -------------------------------------------------------------------------- |
|
693 // CWsfAiPlugin::SetScanningState |
|
694 // -------------------------------------------------------------------------- |
|
695 // |
|
696 void CWsfAiPlugin::SetScanningState( TBool aScanState ) |
|
697 { |
|
698 LOG_ENTERFN( "CWsfAiPlugin::SetScanningState" ); |
|
699 iScanState = aScanState; |
|
700 TRAP_IGNORE( SetMskL() ); |
|
701 } |
|
702 |
|
703 |
|
704 // -------------------------------------------------------------------------- |
|
705 // CWsfAiPlugin::SetRefreshingL |
|
706 // -------------------------------------------------------------------------- |
|
707 // |
|
708 void CWsfAiPlugin::SetRefreshingL( TBool aRefreshing ) |
|
709 { |
|
710 LOG_ENTERFN( "CWsfAiPlugin::SetRefreshingL" ); |
|
711 if( iRefreshing != aRefreshing ) |
|
712 { |
|
713 LOG_WRITEF( "iRefreshing = %d and aRefreshing = %d ", |
|
714 iRefreshing, aRefreshing ); |
|
715 if( aRefreshing ) |
|
716 { |
|
717 if ( iAnimationPeriodic ) |
|
718 { |
|
719 iAnimationPeriodic->Cancel(); |
|
720 delete iAnimationPeriodic; |
|
721 iAnimationPeriodic = NULL; |
|
722 } |
|
723 iAiModel->InitializeRefreshAnimation(); |
|
724 iAnimationPeriodic = CPeriodic::NewL( |
|
725 CActive::EPriorityStandard ); |
|
726 |
|
727 iAnimationPeriodic->Start( |
|
728 TTimeIntervalMicroSeconds32( KRefreshStepTime ), |
|
729 TTimeIntervalMicroSeconds32( KRefreshStepTime ), |
|
730 TCallBack( |
|
731 CWsfAiPlugin::DoRefreshingStepL, |
|
732 this |
|
733 ) ); |
|
734 } |
|
735 else |
|
736 { |
|
737 iAnimationPeriodic->Cancel(); |
|
738 delete iAnimationPeriodic; |
|
739 iAnimationPeriodic = NULL; |
|
740 } |
|
741 } |
|
742 iRefreshing = aRefreshing; |
|
743 } |
|
744 |
|
745 |
|
746 // -------------------------------------------------------------------------- |
|
747 // CWsfAiPlugin::SetRefreshingL |
|
748 // -------------------------------------------------------------------------- |
|
749 // |
|
750 void CWsfAiPlugin::StartConnectingL() |
|
751 { |
|
752 LOG_ENTERFN( "CWsfAiPlugin::StartConnectingL" ); |
|
753 |
|
754 if ( iAnimationPeriodic ) |
|
755 { |
|
756 iAnimationPeriodic->Cancel(); |
|
757 delete iAnimationPeriodic; |
|
758 iAnimationPeriodic = NULL; |
|
759 } |
|
760 |
|
761 iAiModel->InitializeConnectingAnimation(); |
|
762 iAnimationPeriodic = CPeriodic::NewL( |
|
763 CActive::EPriorityStandard ); |
|
764 |
|
765 iAnimationPeriodic->Start( |
|
766 TTimeIntervalMicroSeconds32( KConnectingStepTime ), |
|
767 TTimeIntervalMicroSeconds32( KConnectingStepTime ), |
|
768 TCallBack( |
|
769 CWsfAiPlugin::DoConnectingStepL, |
|
770 this |
|
771 ) ); |
|
772 } |
|
773 |
|
774 |
|
775 // -------------------------------------------------------------------------- |
|
776 // CWsfAiPlugin::NewL |
|
777 // -------------------------------------------------------------------------- |
|
778 // |
|
779 void CWsfAiPlugin::LaunchApplicationL() |
|
780 { |
|
781 LOG_ENTERFN( "CWsfAiPlugin::LaunchApplication" ); |
|
782 RApaLsSession appArcSession; |
|
783 |
|
784 // connect to AppArc server |
|
785 User::LeaveIfError( appArcSession.Connect() ); |
|
786 CleanupClosePushL( appArcSession ); |
|
787 |
|
788 |
|
789 // check if the app is already running ... and brings it to foreground. |
|
790 TUid id( TUid::Uid( KUidSnifferApp.iUid ) ); |
|
791 TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); |
|
792 TApaTask task = taskList.FindApp( id ); |
|
793 |
|
794 if ( task.Exists() ) |
|
795 { |
|
796 task.BringToForeground(); |
|
797 } |
|
798 else |
|
799 { |
|
800 TThreadId threadId; |
|
801 User::LeaveIfError( appArcSession.StartDocument( |
|
802 KNullDesC, |
|
803 TUid::Uid( KUidSnifferApp.iUid ), |
|
804 threadId ) ); |
|
805 } |
|
806 |
|
807 CleanupStack::PopAndDestroy( &appArcSession ); //appArcSession |
|
808 } |
|
809 |
|
810 |
|
811 // -------------------------------------------------------------------------- |
|
812 // CWsfAiPlugin::SetMskL |
|
813 // -------------------------------------------------------------------------- |
|
814 // |
|
815 void CWsfAiPlugin::SetMskL() |
|
816 { |
|
817 LOG_ENTERFN( "CWsfAiPlugin::SetMsk" ); |
|
818 |
|
819 if ( AknLayoutUtils::PenEnabled() ) |
|
820 { |
|
821 // MSK not updated in touch products |
|
822 return; |
|
823 } |
|
824 |
|
825 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
826 |
|
827 if( cba ) |
|
828 { |
|
829 if ( iAiModel->ScanningOn() || iAiModel->Connected() ) |
|
830 { |
|
831 // Show context menu icon |
|
832 cba->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
833 EAknSoftkeyContextOptions, |
|
834 KNullDesC ); |
|
835 } |
|
836 else |
|
837 { |
|
838 if ( !iMskActivate ) |
|
839 { |
|
840 iMskActivate = StringLoader::LoadL( R_QTN_MSK_SNIFFER_ACTIVATE ); |
|
841 } |
|
842 // Show 'Activate' |
|
843 cba->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
844 EAknSoftkeyOk, |
|
845 *iMskActivate ); |
|
846 } |
|
847 cba->DrawDeferred(); |
|
848 } |
|
849 } |
|
850 |
|
851 |
|
852 // -------------------------------------------------------------------------- |
|
853 // CWsfAiPlugin::PublishText |
|
854 // -------------------------------------------------------------------------- |
|
855 // |
|
856 TBool CWsfAiPlugin::PublishText( MAiContentObserver* aObserver, |
|
857 TWsfAiWizardContentIds aContentId, |
|
858 const TDesC16& aText ) |
|
859 { |
|
860 LOG_ENTERFN( "CWsfAiPlugin::PublishText" ); |
|
861 TBool published( EFalse ); |
|
862 TInt error( 0 ); |
|
863 if ( aObserver->CanPublish( *this, aContentId, aContentId ) ) |
|
864 { |
|
865 error = aObserver->Publish( *this, |
|
866 aContentId, |
|
867 aText, |
|
868 aContentId ); |
|
869 |
|
870 if ( error == KErrNone ) |
|
871 { |
|
872 published = ETrue; |
|
873 } |
|
874 } |
|
875 return published; |
|
876 } |
|
877 |
|
878 |
|
879 // -------------------------------------------------------------------------- |
|
880 // CWsfAiPlugin::PublishIconL |
|
881 // -------------------------------------------------------------------------- |
|
882 // |
|
883 TBool CWsfAiPlugin::PublishIconL( MAiContentObserver* aObserver, |
|
884 TWsfAiWizardContentIds aContentId, |
|
885 TInt aIconId ) |
|
886 { |
|
887 LOG_ENTERFN( "CWsfAiPlugin::PublishIcon" ); |
|
888 TBool published( EFalse ); |
|
889 TInt error( 0 ); |
|
890 if ( aObserver->CanPublish( *this, aContentId, aContentId ) ) |
|
891 { |
|
892 error = aObserver->PublishPtr( |
|
893 *this, |
|
894 aContentId, |
|
895 CWsfIconArrayCreator::GetIconLC( aIconId ), |
|
896 aContentId ); |
|
897 |
|
898 CleanupStack::Pop(); // pop the icon |
|
899 |
|
900 if ( error == KErrNone ) |
|
901 { |
|
902 published = ETrue; |
|
903 } |
|
904 } |
|
905 return published; |
|
906 } |
|
907 |
|
908 |
|
909 // --------------------------------------------------------------------------- |
|
910 // CWsfAiPlugin::PublishCleanup |
|
911 // --------------------------------------------------------------------------- |
|
912 // |
|
913 void CWsfAiPlugin::PublishCleanup( TAny* aPtr ) |
|
914 { |
|
915 LOG_ENTERFN( "CWsfAiPlugin::PublishClearup" ); |
|
916 CWsfAiPlugin* self = static_cast<CWsfAiPlugin*>( aPtr ); |
|
917 self->iObservers[self->iCurrentObserverIndex] |
|
918 ->CancelTransaction( reinterpret_cast<TInt32>( self ) ); |
|
919 } |
|
920 |
|
921 |
|
922 // --------------------------------------------------------------------------- |
|
923 // CWsfAiPlugin::StartupRefresh |
|
924 // --------------------------------------------------------------------------- |
|
925 // |
|
926 TInt CWsfAiPlugin::StartupRefresh( TAny* aPtr ) |
|
927 { |
|
928 LOG_ENTERFN( "CWsfAiPlugin::StartupRefresh" ); |
|
929 CWsfAiPlugin* self = static_cast<CWsfAiPlugin*>( aPtr ); |
|
930 TRAP_IGNORE( self->StartupRefreshL(); ); |
|
931 |
|
932 return 0; |
|
933 } |
|
934 |
|
935 |
|
936 // --------------------------------------------------------------------------- |
|
937 // CWsfAiPlugin::StartupRefreshL |
|
938 // --------------------------------------------------------------------------- |
|
939 // |
|
940 TInt CWsfAiPlugin::StartupRefreshL() |
|
941 { |
|
942 LOG_ENTERFN( "CWsfAiPlugin::StartupRefresh" ); |
|
943 iController.StartupRefreshL(); |
|
944 |
|
945 return 0; |
|
946 } |
|
947 |
|
948 // --------------------------------------------------------------------------- |
|
949 // CWsfAiPlugin::DoRefreshingStepL |
|
950 // --------------------------------------------------------------------------- |
|
951 // |
|
952 TInt CWsfAiPlugin::DoRefreshingStepL( TAny* ptr ) |
|
953 { |
|
954 LOG_ENTERFN( "CWsfAiPlugin::DoRefreshingStepL( ptr )" ); |
|
955 static_cast<CWsfAiPlugin*>( ptr )->DoRefreshingStepL(); |
|
956 return ETrue; |
|
957 } |
|
958 |
|
959 // --------------------------------------------------------------------------- |
|
960 // CWsfAiPlugin::DoRefreshingStepL |
|
961 // --------------------------------------------------------------------------- |
|
962 // |
|
963 void CWsfAiPlugin::DoRefreshingStepL() |
|
964 { |
|
965 LOG_ENTERFN( "CWsfAiPlugin::DoRefreshingStepL" ); |
|
966 |
|
967 if ( !iAiModel->ScanningOn() ) |
|
968 { |
|
969 LOG_WRITE( "Disable refreshing" ); |
|
970 if ( iAnimationPeriodic ) |
|
971 { |
|
972 LOG_WRITE( "Cancel animation update" ); |
|
973 iAnimationPeriodic->Cancel(); |
|
974 delete iAnimationPeriodic; |
|
975 iAnimationPeriodic = NULL; |
|
976 } |
|
977 iRefreshing = EFalse; |
|
978 } |
|
979 else |
|
980 { |
|
981 iAiModel->AnimateRefresh(); |
|
982 iController.RefreshRefreshingL(); |
|
983 } |
|
984 } |
|
985 |
|
986 // --------------------------------------------------------------------------- |
|
987 // CWsfAiPlugin::DoConnectingStepL |
|
988 // --------------------------------------------------------------------------- |
|
989 // |
|
990 TInt CWsfAiPlugin::DoConnectingStepL( TAny* ptr ) |
|
991 { |
|
992 LOG_ENTERFN( "CWsfAiPlugin::DoConnectingStepL( ptr )" ); |
|
993 static_cast<CWsfAiPlugin*>( ptr )->DoConnectingStepL(); |
|
994 return ETrue; |
|
995 } |
|
996 |
|
997 // --------------------------------------------------------------------------- |
|
998 // CWsfAiPlugin::DoConnectingStepL |
|
999 // --------------------------------------------------------------------------- |
|
1000 // |
|
1001 void CWsfAiPlugin::DoConnectingStepL() |
|
1002 { |
|
1003 LOG_ENTERFN( "CWsfAiPlugin::DoConnectingStepL" ); |
|
1004 |
|
1005 if ( !iModel->IsConnecting() ) |
|
1006 { |
|
1007 LOG_WRITE( "Disable refreshing" ); |
|
1008 if ( iAnimationPeriodic ) |
|
1009 { |
|
1010 LOG_WRITE( "Cancel animation update" ); |
|
1011 iAnimationPeriodic->Cancel(); |
|
1012 delete iAnimationPeriodic; |
|
1013 iAnimationPeriodic = NULL; |
|
1014 } |
|
1015 } |
|
1016 else |
|
1017 { |
|
1018 iAiModel->AnimateConnecting(); |
|
1019 iController.RefreshConnectingL(); |
|
1020 } |
|
1021 } |
|
1022 |
|
1023 // --------------------------------------------------------------------------- |
|
1024 // CWsfAiPlugin::PublishStatusIconL |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // |
|
1027 void CWsfAiPlugin::PublishStatusIconL( CArrayFix<TInt>* aPublishIconArray, |
|
1028 CEikLabel* /*aText1*/ ) |
|
1029 { |
|
1030 LOG_ENTERFN( "CWsfAiPlugin::PublishStatusIconL" ); |
|
1031 TBool published( EFalse ); |
|
1032 TInt iconId( 0 ); |
|
1033 |
|
1034 ClearL(); // Clear all WLAN Wizard content from the AI2 |
|
1035 |
|
1036 for ( iCurrentObserverIndex = 0; |
|
1037 iCurrentObserverIndex < iObservers.Count(); |
|
1038 ++iCurrentObserverIndex ) |
|
1039 { |
|
1040 MAiContentObserver* observer = iObservers[iCurrentObserverIndex]; |
|
1041 |
|
1042 // Publish Status icon: EAiWizardContentStatusIcon |
|
1043 iconId = aPublishIconArray->At( 0 ); |
|
1044 published = PublishIconL( observer, |
|
1045 EAiWizardContentStatusIcon, |
|
1046 iconId ) || published; |
|
1047 // If we published something then commit, |
|
1048 // otherwise cancel transaction |
|
1049 if ( published ) |
|
1050 { |
|
1051 published = EFalse; |
|
1052 } |
|
1053 } |
|
1054 } |
|
1055 |
|
1056 |
|
1057 // End of File. |