wlanutilities/wlansniffer/aiplugin/src/wsfaiplugin.cpp
branchRCL_3
changeset 8 c2bc3f8c7777
parent 0 56b72877c1cb
child 10 dff6ebfd236f
equal deleted inserted replaced
4:107412708b22 8:c2bc3f8c7777
    52 LOCAL_D const TInt KNaviBarIcon = EWlanOffIcon;
    52 LOCAL_D const TInt KNaviBarIcon = EWlanOffIcon;
    53 LOCAL_D const TInt KTransparentIcon = ETransparentIcon;
    53 LOCAL_D const TInt KTransparentIcon = ETransparentIcon;
    54 LOCAL_D const TUid KUidSnifferApp = {0x10281CAA};
    54 LOCAL_D const TUid KUidSnifferApp = {0x10281CAA};
    55 LOCAL_D const TInt KRefreshStepTime = 200 * 1000;
    55 LOCAL_D const TInt KRefreshStepTime = 200 * 1000;
    56 LOCAL_D const TInt KConnectingStepTime = 200 * 1000;
    56 LOCAL_D const TInt KConnectingStepTime = 200 * 1000;
    57 _LIT8( KWlanWizardName, "WLANWizard" );
       
    58 
    57 
    59 
    58 
    60 
    59 
    61 // --------------------------------------------------------------------------
    60 // --------------------------------------------------------------------------
    62 // CWsfAiPlugin::NewL
    61 // CWsfAiPlugin::NewL
   152 //
   151 //
   153 void CWsfAiPlugin::ConstructL()
   152 void CWsfAiPlugin::ConstructL()
   154     {
   153     {
   155     LOG_ENTERFN( "CWsfAiPlugin::ConstructL" );
   154     LOG_ENTERFN( "CWsfAiPlugin::ConstructL" );
   156     AllocateResourcesL();
   155     AllocateResourcesL();
   157         
       
   158     iInfo.iUid = KUidWlanWizardPlugin;
       
   159     iInfo.iName.Copy( KWlanWizardName );
       
   160     
   156     
   161     iContent = AiUtility::CreateContentItemArrayIteratorL( 
   157     iContent = AiUtility::CreateContentItemArrayIteratorL( 
   162                                                     KAiWizardContent );
   158                                                     KAiWizardContent );
   163     iEvents = AiUtility::CreateContentItemArrayIteratorL( KAiWizardEvents );
   159     iEvents = AiUtility::CreateContentItemArrayIteratorL( KAiWizardEvents );
   164     
   160     
   414 
   410 
   415     BaflUtils::NearestLanguageFile( env->FsSession(), resourceFile );
   411     BaflUtils::NearestLanguageFile( env->FsSession(), resourceFile );
   416     iResourceFileOffset = env->AddResourceFileL( resourceFile );    
   412     iResourceFileOffset = env->AddResourceFileL( resourceFile );    
   417     }
   413     }
   418 
   414 
   419 
   415 // --------------------------------------------------------------------------
   420 // --------------------------------------------------------------------------
   416 // CWsfAiPlugin::Start
   421 // CWsfAiPlugin::Resume
   417 // --------------------------------------------------------------------------
   422 // --------------------------------------------------------------------------
   418 //
   423 //
   419 void CWsfAiPlugin::Start( TStartReason /*aReason*/ )
   424 void CWsfAiPlugin::Resume( TAiTransitionReason aReason )
   420     {
   425     {
   421     LOG_ENTERFN( "CWsfAiPlugin::Start");
   426     LOG_ENTERFN( "CWsfAiPlugin::Resume" );
   422     iStartupRefresh->CallBack();
   427     switch ( aReason ) 
   423     }
   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 
   424 
   476 // --------------------------------------------------------------------------
   425 // --------------------------------------------------------------------------
   477 // CWsfAiPlugin::Stop
   426 // CWsfAiPlugin::Stop
   478 // --------------------------------------------------------------------------
   427 // --------------------------------------------------------------------------
   479 //
   428 //
   480 void CWsfAiPlugin::Stop( TAiTransitionReason /*aReason*/ )
   429 void CWsfAiPlugin::Stop( TStopReason /*aReason*/ )
   481     {
   430     {
   482     LOG_ENTERFN( "CWsfAiPlugin::Stop" );
   431     LOG_ENTERFN( "CWsfAiPlugin::Stop" );
   483     TRAP_IGNORE( iController.DeInitializeL() );
   432     TRAP_IGNORE( iController.DeInitializeL() );
   484     if ( iAnimationPeriodic )
   433     if ( iAnimationPeriodic )
   485         {
   434         {
   488         delete iAnimationPeriodic;
   437         delete iAnimationPeriodic;
   489         iAnimationPeriodic = NULL;
   438         iAnimationPeriodic = NULL;
   490         }
   439         }
   491     }
   440     }
   492 
   441 
       
   442 // --------------------------------------------------------------------------
       
   443 // CWsfAiPlugin::Resume
       
   444 // --------------------------------------------------------------------------
       
   445 //
       
   446 void CWsfAiPlugin::Resume( TResumeReason aReason )
       
   447     {
       
   448     LOG_ENTERFN( "CWsfAiPlugin::Resume" );
       
   449     if( aReason == EForeground ) 
       
   450         {
       
   451         // HS came to foreground -> make refresh scan
       
   452         if ( !iAiModel->Connected() && !iModel->IsConnecting() )
       
   453             {
       
   454             LOG_WRITE( "Call Refresh scan" );
       
   455             TRAP_IGNORE( iModel->RefreshScanL() );
       
   456             }
       
   457         else
       
   458             {
       
   459             LOG_WRITE( "Connected no need to refresh scan results" );
       
   460             }
       
   461         }
       
   462     }
       
   463 
       
   464 // --------------------------------------------------------------------------
       
   465 // CWsfAiPlugin::Suspend
       
   466 // --------------------------------------------------------------------------
       
   467 //
       
   468 void CWsfAiPlugin::Suspend( TSuspendReason aReason )
       
   469     {
       
   470     LOG_ENTERFN( "CWsfAiPlugin::Suspend" );
       
   471     
       
   472     if( aReason == EBackground )
       
   473         {
       
   474         if ( iAnimationPeriodic )
       
   475             {
       
   476             LOG_WRITE( "Cancel animation update" );
       
   477             iAnimationPeriodic->Cancel();
       
   478             delete iAnimationPeriodic;
       
   479             iAnimationPeriodic = NULL;
       
   480             }
       
   481                 
       
   482         // HS went to background -> dismiss open dialogs/menus
       
   483         TRAP_IGNORE( iController.DismissDialogsL() );
       
   484         }
       
   485     }
   493 
   486 
   494 // --------------------------------------------------------------------------
   487 // --------------------------------------------------------------------------
   495 // CWsfAiPlugin::SubscribeL
   488 // CWsfAiPlugin::SubscribeL
   496 // --------------------------------------------------------------------------
   489 // --------------------------------------------------------------------------
   497 //
   490 //
   498 void CWsfAiPlugin::SubscribeL( MAiContentObserver& aObserver )
   491 void CWsfAiPlugin::SubscribeL( MAiContentObserver& aObserver )
   499     {
   492     {
   500     LOG_ENTERFN( "CWsfAiPlugin::Subscribe" );
   493     LOG_ENTERFN( "CWsfAiPlugin::Subscribe" );
   501     return iObservers.AppendL( &aObserver );
   494     iObservers.AppendL( &aObserver );
   502     }
   495     }
   503 
   496 
   504 
   497 
   505 // --------------------------------------------------------------------------
   498 // --------------------------------------------------------------------------
   506 // CWsfAiPlugin::ConfigureL
   499 // CWsfAiPlugin::ConfigureL
   509 void CWsfAiPlugin::ConfigureL( RAiSettingsItemArray& /*aSettings*/ )
   502 void CWsfAiPlugin::ConfigureL( RAiSettingsItemArray& /*aSettings*/ )
   510     {
   503     {
   511     LOG_ENTERFN( "CWsfAiPlugin::ConfigureL" );
   504     LOG_ENTERFN( "CWsfAiPlugin::ConfigureL" );
   512     }
   505     }
   513 
   506 
   514 
   507 // --------------------------------------------------------------------------
   515 // --------------------------------------------------------------------------
   508 // CWsfAiPlugin::GetPropertyL
   516 // CWsfAiPlugin::Extension
   509 // --------------------------------------------------------------------------
   517 // --------------------------------------------------------------------------
   510 //
   518 //
   511 TAny* CWsfAiPlugin::GetProperty( TProperty aProperty )
   519 TAny* CWsfAiPlugin::Extension( TUid aUid )
   512     {
   520     {
   513     if( aProperty == EPublisherContent )
   521     LOG_ENTERFN( "CWsfAiPlugin::Extension" );
   514         {
   522     if ( aUid == KExtensionUidProperty )
   515         return iContent;
   523         {
   516         }
   524         return static_cast<MAiPropertyExtension*>( this );
   517     else if( aProperty == EPublisherEvents )
   525         }
   518         {
   526     else if ( aUid == KExtensionUidEventHandler )
   519         return iEvents;
   527         {
       
   528         return static_cast<MAiEventHandlerExtension*>( this );
       
   529         }
   520         }
   530 
   521 
   531     return NULL;
   522     return NULL;
   532     }
   523     }
   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 
   524 
   584 // --------------------------------------------------------------------------
   525 // --------------------------------------------------------------------------
   585 // CWsfAiPlugin::HandleEvent
   526 // CWsfAiPlugin::HandleEvent
   586 // --------------------------------------------------------------------------
   527 // --------------------------------------------------------------------------
   587 //
   528 //
   732                             this
   673                             this
   733                             ) );
   674                             ) );
   734             }
   675             }
   735         else
   676         else
   736             {
   677             {
   737             iAnimationPeriodic->Cancel();
   678             if ( iAnimationPeriodic )
   738             delete iAnimationPeriodic;
   679                 {
   739             iAnimationPeriodic = NULL;
   680                 iAnimationPeriodic->Cancel();
       
   681                 delete iAnimationPeriodic;
       
   682                 iAnimationPeriodic = NULL;                
       
   683                 }
   740             }
   684             }
   741         }
   685         }
   742     iRefreshing = aRefreshing;
   686     iRefreshing = aRefreshing;
   743     }
   687     }
   744 
   688