wlanutilities/wlansniffer/aiplugin/src/wsfaiplugin.cpp
branchRCL_3
changeset 12 981afc7d3841
parent 11 8b0eae1b1d71
child 13 858c6c491d0e
equal deleted inserted replaced
11:8b0eae1b1d71 12:981afc7d3841
    13 *
    13 *
    14 * Description:  Implementation of CWsfAiPlugin
    14 * Description:  Implementation of CWsfAiPlugin
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 
       
    19 
    18 //  EXTERNAL INCLUDES
    20 //  EXTERNAL INCLUDES
    19 #include <aicontentobserver.h>
    21 #include <aicontentobserver.h>
    20 #include <aiutility.h>
    22 #include <aiutility.h>
    21 #include <apgcli.h>
    23 #include <apgcli.h>
    22 #include <wsfaipluginrsc.rsg>
    24 #include <wsfaipluginrsc.rsg>
    48 #include "wsflogger.h"
    50 #include "wsflogger.h"
    49 #include "wsfactivewrappers.h"
    51 #include "wsfactivewrappers.h"
    50 
    52 
    51 
    53 
    52 // define icon id for Navigation Bar icon
    54 // define icon id for Navigation Bar icon
    53 LOCAL_D const TInt KNaviBarIcon = EWlanOffIcon;
       
    54 LOCAL_D const TInt KTransparentIcon = ETransparentIcon;
       
    55 LOCAL_D const TUid KUidSnifferApp = {0x10281CAA};
    55 LOCAL_D const TUid KUidSnifferApp = {0x10281CAA};
    56 LOCAL_D const TInt KRefreshStepTime = 200 * 1000;
    56 LOCAL_D const TInt KRefreshStepTime = 200 * 1000;
    57 LOCAL_D const TInt KConnectingStepTime = 200 * 1000;
    57 LOCAL_D const TInt KConnectingStepTime = 200 * 1000;
    58 
    58 
    59 
    59 
    96     delete iActiveWrappers;
    96     delete iActiveWrappers;
    97     
    97     
    98     delete iModel;
    98     delete iModel;
    99     delete iAiModel;
    99     delete iAiModel;
   100     delete iUi;
   100     delete iUi;
   101 
       
   102     delete iCurrentSignalStrength;
       
   103     delete iCurrentSecureInfo;
       
   104     
       
   105     if ( iWlanTitle )
       
   106         {
       
   107         delete iWlanTitle;
       
   108         }
       
   109     
   101     
   110     if ( iMskActivate )
   102     if ( iMskActivate )
   111         {
   103         {
   112         delete iMskActivate;
   104         delete iMskActivate;
   113         }
   105         }
   182     LOG_ENTERFN( "CWsfAiPlugin::PublishContentL" );
   174     LOG_ENTERFN( "CWsfAiPlugin::PublishContentL" );
   183     TInt leftBoundary( 0 );
   175     TInt leftBoundary( 0 );
   184     TInt rightBoundary( 0 );
   176     TInt rightBoundary( 0 );
   185     TChar boundary('\'');
   177     TChar boundary('\'');
   186     HBufC* localCurrentStatusText( NULL );
   178     HBufC* localCurrentStatusText( NULL );
   187     HBufC* localCurrentTypeText( NULL );
       
   188     
   179     
   189     HBufC* localCurrentNetworkStatus( NULL );
   180     HBufC* localCurrentNetworkStatus( NULL );
   190     HBufC* localCurrentNetworkName( NULL );
   181     HBufC* localCurrentNetworkName( NULL );
   191 
   182 
   192     HBufC* localFullText = ( aText1->Text() )->AllocLC();
   183     HBufC* localFullText = ( aText1->Text() )->AllocLC();
   199     // if we have status name then we parse it
   190     // if we have status name then we parse it
   200     if ( leftBoundary != rightBoundary && 
   191     if ( leftBoundary != rightBoundary && 
   201          leftBoundary != KErrNotFound && 
   192          leftBoundary != KErrNotFound && 
   202          rightBoundary != KErrNotFound )
   193          rightBoundary != KErrNotFound )
   203         {
   194         {
       
   195         LOG_WRITE( "status name exists" );
   204         TPtrC begin = fullText.Mid( leftBoundary, 
   196         TPtrC begin = fullText.Mid( leftBoundary, 
   205                                     rightBoundary - leftBoundary + 1 );
   197                                     rightBoundary - leftBoundary + 1 );
   206         localCurrentStatusText = begin.AllocLC();
   198         localCurrentStatusText = begin.AllocLC();
   207         localCurrentNetworkName = begin.AllocLC();
   199         localCurrentNetworkName = begin.AllocLC();
   208 
   200 
   209         TPtrC end = fullText.Mid( rightBoundary + 1 );
   201         TPtrC end = fullText.Mid( rightBoundary + 1 );
   210         localCurrentTypeText = end.AllocLC();
       
   211        }
   202        }
   212     else
   203     else
   213         {
   204         {
       
   205         LOG_WRITE( "status name does not exist" );
   214         localCurrentStatusText = fullText.AllocLC();
   206         localCurrentStatusText = fullText.AllocLC();
   215         delete localCurrentTypeText;
       
   216         localCurrentTypeText = NULL;
       
   217         }
   207         }
   218     
   208     
   219     //Connected
   209     //Connected
   220     if ( localCurrentNetworkName )
   210     if ( localCurrentNetworkName )
   221         {
   211         {
   222         if ( iAiModel->Connected() )
   212         if ( iAiModel->Connected() )
   223             {
   213             {
       
   214             LOG_WRITE( "ai model is connected" );
   224             if ( !iConnectedTo )
   215             if ( !iConnectedTo )
   225                 {
   216                 {
   226                 iConnectedTo = StringLoader::LoadL( 
   217                 iConnectedTo = StringLoader::LoadL( 
   227                         R_QTN_SNIFFER_PLUG_IN_CONNECTED_TO );
   218                         R_QTN_SNIFFER_PLUG_IN_CONNECTED_TO );
   228                 }
   219                 }
   233             if ( !iKnownNetworkFound )
   224             if ( !iKnownNetworkFound )
   234                 {
   225                 {
   235                 iKnownNetworkFound = StringLoader::LoadL( 
   226                 iKnownNetworkFound = StringLoader::LoadL( 
   236                         R_QTN_SNIFFER_PLUG_IN_WLAN_NETWORK_FOUND );
   227                         R_QTN_SNIFFER_PLUG_IN_WLAN_NETWORK_FOUND );
   237                 }
   228                 }
       
   229             LOG_WRITE( "there is known network" );
   238             localCurrentNetworkStatus = iKnownNetworkFound;
   230             localCurrentNetworkStatus = iKnownNetworkFound;
   239             }
   231             }
   240         }
   232         }
   241     else
   233     else
   242         {
   234         {
       
   235         LOG_WRITE( "use current status text" );
   243         localCurrentNetworkStatus = localCurrentStatusText;
   236         localCurrentNetworkStatus = localCurrentStatusText;
   244         }
   237         }
   245 
   238 
   246     TBool published( EFalse );
   239     TBool published( EFalse );
   247     TInt iconId( 0 );
   240     TInt iconId( 0 );
   250 
   243 
   251     for ( iCurrentObserverIndex = 0; 
   244     for ( iCurrentObserverIndex = 0; 
   252           iCurrentObserverIndex < iObservers.Count(); 
   245           iCurrentObserverIndex < iObservers.Count(); 
   253           ++iCurrentObserverIndex )
   246           ++iCurrentObserverIndex )
   254         {
   247         {
       
   248         LOG_WRITEF( "Start publish - index = %d", iCurrentObserverIndex );
       
   249         
   255         MAiContentObserver* observer = iObservers[iCurrentObserverIndex];
   250         MAiContentObserver* observer = iObservers[iCurrentObserverIndex];
   256         observer->StartTransaction( reinterpret_cast<TInt32>( this ) );
   251         observer->StartTransaction( reinterpret_cast<TInt32>( this ) );
   257         // make sure we cancel the tracsaction if leaves
   252         // make sure we cancel the tracsaction if leaves
   258         CleanupStack::PushL( TCleanupItem( PublishCleanup, this ) );
   253         CleanupStack::PushL( TCleanupItem( PublishCleanup, this ) );
   259 
   254 
   260         // Publish Full Text if Classic or Navigation Bar Classic used
       
   261         if ( localFullText )
       
   262             {
       
   263             published = PublishText( observer, 
       
   264                                      EAiWizardContentFullText,
       
   265                                      *localFullText ) || published;
       
   266             }
       
   267 
       
   268         // Publish Navigation Bar Icon: EAiWizardContentNaviBarIcon
       
   269         published = PublishIconL( observer, 
       
   270                                   EAiWizardContentNaviBarIcon,
       
   271                                   KNaviBarIcon ) || published;
       
   272 
       
   273         // Publish Application Title: EAiWizardContentTitleText
       
   274         if ( !iWlanTitle )
       
   275             {
       
   276             iWlanTitle = StringLoader::LoadL( R_QTN_AI_WIZARD_TITLE );
       
   277             }
       
   278         if ( iWlanTitle )
       
   279             {
       
   280             published = PublishText( observer, 
       
   281                                      EAiWizardContentTitleText,
       
   282                                      *iWlanTitle ) || published;
       
   283             }
       
   284 
       
   285         if ( localCurrentStatusText )
   255         if ( localCurrentStatusText )
   286             {
   256             {
       
   257             LOG_WRITE( "Publish -> status icon" );
   287             // Publish Status icon: EAiWizardContentStatusIcon
   258             // Publish Status icon: EAiWizardContentStatusIcon
   288             iconId = aPublishIconArray->At( 0 );
   259             iconId = aPublishIconArray->At( 0 );
   289             published = PublishIconL( observer, 
   260             published = PublishIconL( observer, 
   290                                       EAiWizardContentStatusIcon,
   261                                       EAiWizardContentStatusIcon,
   291                                       iconId ) || published;
   262                                       iconId ) || published;
   292             
   263             }
   293             // Publish Status text: EAiWizardContentStatusText
   264 
   294             published = PublishText( observer, 
   265         LOG_WRITE( "Publish -> Strength icon" );
   295                                      EAiWizardContentStatusText,
       
   296                                      *localCurrentStatusText ) || published;
       
   297             }
       
   298 
       
   299         if ( localCurrentTypeText )
       
   300             {
       
   301             // Publish Type icon: EAiWizardContentTypeIcon
       
   302             published = PublishIconL( observer, 
       
   303                                       EAiWizardContentTypeIcon,
       
   304                                       KTransparentIcon ) || published;
       
   305 
       
   306             // Publish Type text: EAiWizardContentTypeText
       
   307             published = PublishText( observer, 
       
   308                                      EAiWizardContentTypeText,
       
   309                                      *localCurrentTypeText ) || published;
       
   310             }
       
   311 
       
   312         // Publish Strength icon: EAiWizardContentStrengthIcon
   266         // Publish Strength icon: EAiWizardContentStrengthIcon
   313         iconId = aPublishIconArray->At( 2 );
   267         iconId = aPublishIconArray->At( 2 );
   314         published = PublishIconL( observer, 
   268         published = PublishIconL( observer, 
   315                                   EAiWizardContentStrengthIcon,
   269                                   EAiWizardContentStrengthIcon,
   316                                   iconId ) || published;
   270                                   iconId ) || published;
   317 
   271 
   318         // Publish Strength text: EAiWizardContentStrengthText
   272         LOG_WRITE( "Publish -> secure icon" );
   319         if ( iCurrentSignalStrength && iScanState )
       
   320             {
       
   321             published = PublishText( observer, 
       
   322                                      EAiWizardContentStrengthText,
       
   323                                      *iCurrentSignalStrength ) || published;
       
   324             }
       
   325 
       
   326         // Publish Secure icon: EAiWizardContentSecureIcon
   273         // Publish Secure icon: EAiWizardContentSecureIcon
   327         iconId = aPublishIconArray->At( 1 );
   274         iconId = aPublishIconArray->At( 1 );
   328         published = PublishIconL( observer, 
   275         published = PublishIconL( observer, 
   329                                   EAiWizardContentSecureIcon,
   276                                   EAiWizardContentSecureIcon,
   330                                   iconId ) || published;
   277                                   iconId ) || published;
   331 
       
   332         // Publish Secure text: EAiWizardContentSecureText
       
   333         if ( iCurrentSecureInfo && iScanState )
       
   334             {
       
   335             published = PublishText( observer, 
       
   336                                      EAiWizardContentSecureText,
       
   337                                      *iCurrentSecureInfo ) || published;
       
   338             }
       
   339         
   278         
   340         if ( localCurrentNetworkName )
   279         if ( localCurrentNetworkName )
   341             {
   280             {
       
   281             LOG_WRITE( "Publish -> localCurrentNetworkName" );
   342             // Publish NetworkName text: EAiWizardContentNetworkName
   282             // Publish NetworkName text: EAiWizardContentNetworkName
   343             published = PublishText( observer, 
   283             published = PublishText( observer, 
   344                                      EAiWizardContentNetworkName,
   284                                      EAiWizardContentNetworkName,
   345                                      *localCurrentNetworkName ) || published;
   285                                      *localCurrentNetworkName ) || published;
   346             }
   286             }
   347         
   287         
   348         if ( localCurrentNetworkStatus )
   288         if ( localCurrentNetworkStatus )
   349             {
   289             {
       
   290             LOG_WRITE( "Publish -> localCurrentNetworkStatus" );
   350             // Publish NetworkName text: EAiWizardContentNetworkName
   291             // Publish NetworkName text: EAiWizardContentNetworkName
   351             published = PublishText( observer, 
   292             published = PublishText( observer, 
   352                                      EAiWizardContentNetworkStatus,
   293                                      EAiWizardContentNetworkStatus,
   353                                      *localCurrentNetworkStatus ) || published;
   294                                      *localCurrentNetworkStatus ) || published;
   354             }
   295             }
   355         
   296         
   356         // If we published something then commit, 
   297         // If we published something then commit, 
   357         // otherwise cancel transaction
   298         // otherwise cancel transaction
   358         if ( published )
   299         if ( published )
   359             {
   300             {
       
   301             LOG_WRITE( "Commit" );
   360             observer->Commit( reinterpret_cast<TInt32>( this ) );
   302             observer->Commit( reinterpret_cast<TInt32>( this ) );
   361             published = EFalse;
   303             published = EFalse;
   362             }
   304             }
   363         else
   305         else
   364             {
   306             {
       
   307             LOG_WRITE( "Cancel transaction" );
   365             observer->CancelTransaction( reinterpret_cast<TInt32>( this ) );
   308             observer->CancelTransaction( reinterpret_cast<TInt32>( this ) );
   366             }
   309             }
   367         CleanupStack::Pop( 1 ); // PublishCleanup()
   310         CleanupStack::Pop( 1 ); // PublishCleanup()
   368         }
   311         }
   369     
   312     
   370     if ( localCurrentTypeText ) 
   313     LOG_WRITE( "Publishing ready" );
   371         {
       
   372         CleanupStack::PopAndDestroy( localCurrentTypeText );
       
   373         }
       
   374     
   314     
   375     if ( localCurrentNetworkName ) 
   315     if ( localCurrentNetworkName ) 
   376         {
   316         {
   377         CleanupStack::PopAndDestroy( localCurrentNetworkName );
   317         CleanupStack::PopAndDestroy( localCurrentNetworkName );
   378         }
   318         }
   467             LOG_WRITE( "Cancel animation update" );
   407             LOG_WRITE( "Cancel animation update" );
   468             iAnimationPeriodic->Cancel();
   408             iAnimationPeriodic->Cancel();
   469             delete iAnimationPeriodic;
   409             delete iAnimationPeriodic;
   470             iAnimationPeriodic = NULL;
   410             iAnimationPeriodic = NULL;
   471             }
   411             }
   472                 
       
   473         // HS went to background -> dismiss open dialogs/menus
       
   474         TRAP_IGNORE( iController.DismissDialogsL() );
       
   475         }
   412         }
   476     }
   413     }
   477 
   414 
   478 // --------------------------------------------------------------------------
   415 // --------------------------------------------------------------------------
   479 // CWsfAiPlugin::SubscribeL
   416 // CWsfAiPlugin::SubscribeL
   568         {
   505         {
   569         MAiContentObserver* observer = iObservers[i];
   506         MAiContentObserver* observer = iObservers[i];
   570 
   507 
   571         observer->StartTransaction( reinterpret_cast<TInt32>( this ) );
   508         observer->StartTransaction( reinterpret_cast<TInt32>( this ) );
   572 
   509 
   573         observer->Clean( *this, EAiWizardContentNaviBarIcon, 
       
   574                                 EAiWizardContentNaviBarIcon );
       
   575         observer->Clean( *this, EAiWizardContentTitleText, 
       
   576                                 EAiWizardContentTitleText );
       
   577         observer->Clean( *this, EAiWizardContentStatusIcon, 
   510         observer->Clean( *this, EAiWizardContentStatusIcon, 
   578                                 EAiWizardContentStatusIcon );
   511                                 EAiWizardContentStatusIcon );
   579         observer->Clean( *this, EAiWizardContentStatusText, 
       
   580                                 EAiWizardContentStatusText );
       
   581         observer->Clean( *this, EAiWizardContentTypeIcon,
       
   582                                 EAiWizardContentTypeIcon );
       
   583         observer->Clean( *this, EAiWizardContentTypeText, 
       
   584                                 EAiWizardContentTypeText );
       
   585         observer->Clean( *this, EAiWizardContentStrengthIcon, 
   512         observer->Clean( *this, EAiWizardContentStrengthIcon, 
   586                                 EAiWizardContentStrengthIcon );
   513                                 EAiWizardContentStrengthIcon );
   587         observer->Clean( *this, EAiWizardContentStrengthText, 
       
   588                                 EAiWizardContentStrengthText );
       
   589         observer->Clean( *this, EAiWizardContentSecureIcon, 
   514         observer->Clean( *this, EAiWizardContentSecureIcon, 
   590                                 EAiWizardContentSecureIcon );
   515                                 EAiWizardContentSecureIcon );
   591         observer->Clean( *this, EAiWizardContentSecureText, 
       
   592                                 EAiWizardContentSecureText );
       
   593         observer->Clean( *this, EAiWizardContentNetworkName, 
   516         observer->Clean( *this, EAiWizardContentNetworkName, 
   594                                 EAiWizardContentNetworkName );
   517                                 EAiWizardContentNetworkName );
       
   518         
   595         observer->Commit( reinterpret_cast<TInt32>( this ) );
   519         observer->Commit( reinterpret_cast<TInt32>( this ) );
   596         }
       
   597     }
       
   598 
       
   599 
       
   600 // --------------------------------------------------------------------------
       
   601 // CWsfAiPlugin::SetStrengthAndSecure
       
   602 // --------------------------------------------------------------------------
       
   603 //
       
   604 void CWsfAiPlugin::SetStrengthAndSecure( TDesC* aStrength, TDesC* aSecure )
       
   605     {
       
   606     LOG_ENTERFN( "CWsfAiPlugin::SetStrengthAndSecure" );
       
   607     delete iCurrentSignalStrength;
       
   608     iCurrentSignalStrength = NULL;
       
   609     if ( aStrength && aStrength->Length() > 0)
       
   610         {
       
   611         iCurrentSignalStrength = aStrength->Alloc();
       
   612         }
       
   613 
       
   614     delete iCurrentSecureInfo;
       
   615     iCurrentSecureInfo = NULL;
       
   616     if ( aSecure && aSecure->Length() > 0)
       
   617         {
       
   618         // r_qtn_sniffer_plug_in_content_secure
       
   619         iCurrentSecureInfo = aSecure->Alloc();
       
   620         }
   520         }
   621     }
   521     }
   622 
   522 
   623 
   523 
   624 // --------------------------------------------------------------------------
   524 // --------------------------------------------------------------------------
   845 // CWsfAiPlugin::PublishCleanup
   745 // CWsfAiPlugin::PublishCleanup
   846 // ---------------------------------------------------------------------------
   746 // ---------------------------------------------------------------------------
   847 //
   747 //
   848 void CWsfAiPlugin::PublishCleanup( TAny* aPtr )
   748 void CWsfAiPlugin::PublishCleanup( TAny* aPtr )
   849     {
   749     {
   850     LOG_ENTERFN( "CWsfAiPlugin::PublishClearup" );
   750     LOG_ENTERFN( "CWsfAiPlugin::PublishCleanup" );
   851     CWsfAiPlugin* self = static_cast<CWsfAiPlugin*>( aPtr );
   751     CWsfAiPlugin* self = static_cast<CWsfAiPlugin*>( aPtr );
   852     self->iObservers[self->iCurrentObserverIndex]
   752     
       
   753     if ( self && self->iCurrentObserverIndex < self->iObservers.Count() )
       
   754         {
       
   755         LOG_WRITE( "Cancel transaction" );
       
   756         self->iObservers[self->iCurrentObserverIndex]
   853                      ->CancelTransaction( reinterpret_cast<TInt32>( self ) );
   757                      ->CancelTransaction( reinterpret_cast<TInt32>( self ) );
       
   758         }
   854     }
   759     }
   855 
   760 
   856 
   761 
   857 // ---------------------------------------------------------------------------
   762 // ---------------------------------------------------------------------------
   858 // CWsfAiPlugin::DoRefreshingStepL
   763 // CWsfAiPlugin::DoRefreshingStepL