accesspointcontrol/apcontrollistplugin/src/apcontrollistplugin.cpp
changeset 27 489cf6208544
parent 23 7ec726f93df1
child 42 017c42709822
child 46 95d45f234cf3
equal deleted inserted replaced
23:7ec726f93df1 27:489cf6208544
     1 /*
       
     2 * Copyright (c) 2006 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:  APControlListPlugin class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // System includes
       
    22 #include <hlplch.h>
       
    23 
       
    24 #include <aknlists.h>        //for CListBox
       
    25 #include <f32file.h>
       
    26 #include <aknnotewrappers.h> //for CAknInformationNote
       
    27 #include <AknQueryDialog.h>
       
    28 #include <StringLoader.h>
       
    29 #include <apcontrollistpluginrsc.rsg>
       
    30 #include <data_caging_path_literals.hrh>
       
    31 #include <apcontrollistplugin.mbg>
       
    32 #include <featmgr.h>
       
    33 
       
    34 // User includes
       
    35 #include "apcontrollistplugin.hrh"
       
    36 #include "apcontrollistplugin.h"
       
    37 #include "apcontrollistplugincontainer.h"
       
    38 #include "apcontrollistpluginlogger.h"
       
    39 #include "apcontrollistapiwrapper.h"
       
    40 #include "apcontrollistcapschange.h"
       
    41 
       
    42 // CONSTANTS
       
    43 // Resource file location constant
       
    44 _LIT( KResourceFileName, "APControlListPluginRsc.rsc" );
       
    45 
       
    46 // ROM folder
       
    47 _LIT( KDriveZ, "z:" );
       
    48 
       
    49 // Name of the MBM file containing icons
       
    50 _LIT( KFileIcons, "apcontrollistplugin.mbm");
       
    51 
       
    52 // ================= MEMBER FUNCTIONS =======================
       
    53 
       
    54 // ---------------------------------------------------------
       
    55 // CAPControlListPlugin::NewL
       
    56 // First phase constructor
       
    57 // ---------------------------------------------------------
       
    58 CAPControlListPlugin* CAPControlListPlugin::NewL( TAny* /*aInitParams*/ )
       
    59     {
       
    60 	CLOG_CREATE()
       
    61     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::NewL" ) ) );
       
    62     CAPControlListPlugin* self = new ( ELeave ) CAPControlListPlugin();
       
    63     CleanupStack::PushL( self );
       
    64     
       
    65     self->ConstructL( );
       
    66                       
       
    67     CleanupStack::Pop( self );
       
    68     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::NewL" ) ) );
       
    69     return self;     
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // CAPControlListPlugin::NewL
       
    74 // Destructor
       
    75 // ---------------------------------------------------------
       
    76 CAPControlListPlugin::~CAPControlListPlugin()
       
    77     {
       
    78     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::~CAPControlListPlugin" ) ) );
       
    79     if( iContainer )
       
    80     {
       
    81         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    82         delete iContainer;
       
    83     }
       
    84     if (iAPIWrapper)
       
    85     {
       
    86     	delete iAPIWrapper;
       
    87     }
       
    88     if (iChangeNotifier)
       
    89     {
       
    90     	delete iChangeNotifier;
       
    91     }
       
    92     iResources.Close();
       
    93     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::~CAPControlListPlugin" ) ) );
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------
       
    97 // CAPControlListPlugin::Id
       
    98 // ---------------------------------------------------------
       
    99 TUid CAPControlListPlugin::Id() const
       
   100     {
       
   101     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::Id" ) ) );
       
   102     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::Id" ) ) );
       
   103     return KAPControlListPluginUid;
       
   104     }
       
   105     
       
   106 // ---------------------------------------------------------
       
   107 // CAPControlListPlugin::HandleCommandL( TInt aCommand )
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 void CAPControlListPlugin::HandleCommandL( TInt aCommand )
       
   111     {   
       
   112     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::HandleCommandL" ) ) );
       
   113     switch ( aCommand )
       
   114         {
       
   115         case EAknSoftkeyBack :
       
   116             {
       
   117             // Activate the view ( from GS ) that we
       
   118             // are supposed to return to
       
   119             AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid );
       
   120             break;
       
   121             }
       
   122         case EAPControlListCmdActivate :
       
   123             {
       
   124             iAPIWrapper->ActivateACL();
       
   125             break;
       
   126             }
       
   127         case EAPControlListCmdDeactivate :
       
   128             {
       
   129             iAPIWrapper->DeActivateACL();
       
   130             break;
       
   131             }
       
   132         case EAPControlListCmdAdd :
       
   133             {
       
   134             iAPIWrapper->AddAPNL();
       
   135             break;
       
   136             }
       
   137         case EAPControlListCmdRemove :
       
   138             {
       
   139             iAPIWrapper->RemoveAPN();
       
   140             break;
       
   141             }
       
   142         case EAknCmdHelp : 
       
   143             {
       
   144             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), 
       
   145                                                  AppUi()->AppHelpContextL() );
       
   146             break;
       
   147             }
       
   148         case EEikCmdExit :
       
   149         default :
       
   150             {            
       
   151             AppUi()->HandleCommandL( aCommand );
       
   152             break;
       
   153             }
       
   154         }
       
   155     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::HandleCommandL" ) ) );
       
   156     }
       
   157     
       
   158 // ---------------------------------------------------------
       
   159 // CAPControlListPlugin::ExitOnUSIMRemovalL
       
   160 // ---------------------------------------------------------
       
   161 void CAPControlListPlugin::ExitOnUSIMRemovalL() 
       
   162     {
       
   163     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ExitOnUSIMRemovalL" ) ) );
       
   164     iVisible = EFalse;
       
   165 	AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid );
       
   166     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ExitOnUSIMRemovalL" ) ) );
       
   167     }
       
   168     
       
   169 // ---------------------------------------------------------
       
   170 // CAPControlListPlugin::DoActivateL
       
   171 // ---------------------------------------------------------
       
   172 void CAPControlListPlugin::DoActivateL( const TVwsViewId& aPrevViewId, 
       
   173                                       TUid /*aCustomMessageId*/, 
       
   174                                       const TDesC8& /*aCustomMessage*/ )
       
   175     {
       
   176     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::DoActivateL" ) ) );
       
   177     if ( iPrevViewId.iViewUid.iUid == 0 )
       
   178         {
       
   179         //must be prepared to application switch, so it stores
       
   180         //only the parent view (General Settings Main View)
       
   181         iPrevViewId = aPrevViewId;
       
   182         }
       
   183 
       
   184     if ( !iContainer )
       
   185         {
       
   186         iContainer = new( ELeave ) CAPControlListPluginContainer;
       
   187         iContainer->SetMopParent( this );
       
   188         
       
   189         TRAPD( error, iContainer->ConstructL( ClientRect(), this ) );
       
   190         if ( error )
       
   191             {
       
   192             delete iContainer;
       
   193             iContainer = NULL;
       
   194             User::Leave( error );
       
   195             }
       
   196         
       
   197 	    if (!iAPIWrapper)  
       
   198 		    {
       
   199 	    	iAPIWrapper = new( ELeave ) CAPControlListAPIWrapper(*this);
       
   200 	    	iAPIWrapper->ConstructL();
       
   201 	    	}
       
   202 	    if (!iChangeNotifier)  
       
   203 		    {
       
   204 	    	iChangeNotifier = new( ELeave ) CAPControlListCapsChange(*this);
       
   205             iChangeNotifier->NotifyCapsChange();
       
   206 	    	}
       
   207 	    				
       
   208 		    ShowInfoNoteL(R_QTN_ACL_WAIT_READING_SIM);
       
   209     	  iAPIWrapper->ReadData();  
       
   210         iContainer->HandleResourceChange(KEikDynamicLayoutVariantSwitch);
       
   211     	  		
       
   212 	    
       
   213         AppUi()->AddToViewStackL( *this, iContainer );
       
   214         }
       
   215     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::DoActivateL" ) ) );
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------
       
   219 // CAPControlListPlugin::PluginUid
       
   220 // ---------------------------------------------------------
       
   221 TUid CAPControlListPlugin::PluginUid() const
       
   222     {
       
   223     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::PluginUid" ) ) );
       
   224     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::PluginUid" ) ) );
       
   225     return KAPControlListPluginUid;
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------
       
   229 // CAPControlListPlugin::GetCaption
       
   230 // ---------------------------------------------------------
       
   231 void CAPControlListPlugin::GetCaptionL( TDes& aCaption ) const
       
   232     {
       
   233     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::GetCaptionL" ) ) );
       
   234     StringLoader::Load( aCaption, R_QTN_ACL_MENU_ITEM );
       
   235     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::GetCaptionL" ) ) );
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------
       
   239 // CAPControlListPlugin::HasBitmap
       
   240 // ---------------------------------------------------------
       
   241 TBool CAPControlListPlugin::HasBitmap() const
       
   242     {
       
   243     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::HasBitmap" ) ) );
       
   244     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::HasBitmap" ) ) );
       
   245     return EFalse;
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------
       
   249 // CAPControlListPlugin::GetBitmapL
       
   250 // ---------------------------------------------------------
       
   251 void CAPControlListPlugin::GetBitmapL( CFbsBitmap* /*aBitmap*/, 
       
   252                                      CFbsBitmap* /*aMask*/ ) const
       
   253     {
       
   254     //no bitmap
       
   255     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::GetBitmapL" ) ) );
       
   256     User::Leave( KErrNotFound );
       
   257     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::GetBitmapL" ) ) );
       
   258     }
       
   259     
       
   260 // ---------------------------------------------------------
       
   261 // CAPControlListPlugin::PluginProviderCategory
       
   262 // ---------------------------------------------------------
       
   263 TInt CAPControlListPlugin::PluginProviderCategory() const
       
   264     {
       
   265     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::PluginProviderCategory" ) ) );
       
   266     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::PluginProviderCategory" ) ) );
       
   267     return EGSPluginProviderOEM;
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------
       
   271 // CApSettingsPlugin::CreateIconL
       
   272 // ---------------------------------------------------------    
       
   273 CGulIcon* CAPControlListPlugin::CreateIconL( const TUid aIconType )
       
   274     {
       
   275     TFileName iconsFileName;
       
   276 
       
   277     iconsFileName.Append( KDriveZ );
       
   278     iconsFileName.Append( KDC_APP_BITMAP_DIR );
       
   279     iconsFileName.Append( KFileIcons );
       
   280     
       
   281 	CGulIcon* icon;
       
   282        
       
   283     if( aIconType == KGSIconTypeLbxItem )
       
   284         {
       
   285         icon = AknsUtils::CreateGulIconL(
       
   286         AknsUtils::SkinInstance(), 
       
   287         KAknsIIDQgnPropSetConnAccp, 
       
   288         iconsFileName,
       
   289         EMbmApcontrollistpluginQgn_prop_set_conn_acl,
       
   290         EMbmApcontrollistpluginQgn_prop_set_conn_acl_mask );
       
   291         }
       
   292      else
       
   293         {
       
   294         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   295         }
       
   296 	
       
   297 	return icon;
       
   298     }    
       
   299     
       
   300 // ---------------------------------------------------------
       
   301 // CAPControlListPlugin::Visible
       
   302 // ---------------------------------------------------------
       
   303 TBool CAPControlListPlugin::Visible() const
       
   304     {
       
   305     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::Visible" ) ) );
       
   306     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::Visible" ) ) );
       
   307     return iVisible;
       
   308     }
       
   309     
       
   310 // ---------------------------------------------------------
       
   311 // CAPControlListPlugin::CAPControlListPlugin
       
   312 // ---------------------------------------------------------
       
   313 CAPControlListPlugin::CAPControlListPlugin():
       
   314     iPrevViewId(),
       
   315     iResources( *CCoeEnv::Static() ),
       
   316     iVisible(EFalse)
       
   317     {
       
   318     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::CAPControlListPlugin" ) ) );
       
   319     // no implementation required
       
   320     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::CAPControlListPlugin" ) ) );
       
   321     }
       
   322 
       
   323 // ---------------------------------------------------------
       
   324 // CAPControlListPlugin::ConstructL
       
   325 // ---------------------------------------------------------
       
   326 TAny CAPControlListPlugin::ConstructL()
       
   327     {
       
   328     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ConstructL" ) ) );
       
   329    
       
   330     TFileName fileName;
       
   331     TDriveUnit drive( EDriveZ );
       
   332     
       
   333     fileName.Append( drive.Name() );
       
   334     fileName.Append( KDC_RESOURCE_FILES_DIR );
       
   335     fileName.Append( KResourceFileName );    
       
   336     iResources.OpenL( fileName );
       
   337 
       
   338     BaseConstructL( R_APCLPLUGIN_MAIN_VIEW );
       
   339      
       
   340 	// get Visible   
       
   341     iAPIWrapper = new( ELeave ) CAPControlListAPIWrapper(*this);
       
   342     iAPIWrapper->ConstructL();
       
   343     iVisible = iAPIWrapper->Visible();
       
   344     iAPIWrapper->Cancel();
       
   345     delete iAPIWrapper;
       
   346     iAPIWrapper = NULL;
       
   347         
       
   348     FeatureManager::InitializeLibL();
       
   349     iHelp = FeatureManager::FeatureSupported( KFeatureIdHelp ); 
       
   350     FeatureManager::UnInitializeLib();
       
   351     
       
   352     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ConstructL" ) ) );
       
   353     }
       
   354     
       
   355     
       
   356 // ---------------------------------------------------------
       
   357 // CAPControlListPlugin::DynInitMenuPaneL
       
   358 // ---------------------------------------------------------
       
   359 void CAPControlListPlugin::DynInitMenuPaneL( TInt aResourceId,
       
   360                                          CEikMenuPane* aMenuPane )
       
   361     {
       
   362     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::DynInitMenuPaneL" ) ) );
       
   363     CAknView::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   364     if ( aResourceId == R_APCLPLUGIN_MAIN_MENU )
       
   365     {    
       
   366 		if ( iAPIWrapper->Enabled() )
       
   367 		{
       
   368     		aMenuPane->DeleteMenuItem( EAPControlListCmdActivate );
       
   369 		}
       
   370 		else
       
   371 		{
       
   372     		aMenuPane->DeleteMenuItem( EAPControlListCmdDeactivate );
       
   373 		}
       
   374 		if ( !iContainer->NumberOfItems() )
       
   375 		{
       
   376     		aMenuPane->DeleteMenuItem( EAPControlListCmdRemove );
       
   377 		}
       
   378 		if (!iHelp)
       
   379 		{
       
   380     		aMenuPane->DeleteMenuItem( EAknCmdHelp );		    
       
   381 		}
       
   382     }
       
   383     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::DynInitMenuPaneL" ) ) );
       
   384     }
       
   385         
       
   386 // ---------------------------------------------------------
       
   387 // CAPControlListPlugin::DoDeactivate
       
   388 // ---------------------------------------------------------
       
   389 void CAPControlListPlugin::DoDeactivate()
       
   390     {        
       
   391     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::DoDeactivate" ) ) );
       
   392     if ( iContainer )
       
   393         {
       
   394         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   395         }
       
   396 
       
   397     delete iContainer;
       
   398     iContainer = NULL; 
       
   399     if (iChangeNotifier)
       
   400     {
       
   401     	delete iChangeNotifier;
       
   402 		iChangeNotifier = NULL; 
       
   403     }
       
   404     if (iAPIWrapper)  
       
   405 	    {
       
   406 	    delete iAPIWrapper;
       
   407 	    iAPIWrapper = NULL;    	
       
   408 	    }
       
   409     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::DoDeactivate" ) ) );
       
   410     }
       
   411     
       
   412 // ---------------------------------------------------------
       
   413 // CAPControlListPlugin::UiComplete( TInt aUirEvent )
       
   414 // ---------------------------------------------------------
       
   415 //
       
   416 void CAPControlListPlugin::UiComplete( TInt /*aUirEvent*/ )
       
   417     {    
       
   418     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::UiComplete" ) ) );
       
   419     // Activate this view as we are coming back
       
   420     // from some other view in the UI
       
   421     TRAP_IGNORE( 
       
   422         AppUi()->ActivateLocalViewL( KAPControlListPluginUid ) )
       
   423     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::UiComplete" ) ) );
       
   424     }
       
   425     
       
   426 // ---------------------------------------------------------
       
   427 //  CAPControlListPlugin::HandleListBoxEventL
       
   428 // ---------------------------------------------------------
       
   429 void CAPControlListPlugin::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   430                                               TListBoxEvent aEventType )
       
   431     {
       
   432     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::HandleListBoxEventL" ) ) );
       
   433     switch ( aEventType )
       
   434         {
       
   435         case EEventEnterKeyPressed :
       
   436         case EEventItemClicked :
       
   437             {
       
   438             break;
       
   439             }
       
   440         default :
       
   441            break;
       
   442         }
       
   443     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::HandleListBoxEventL" ) ) );
       
   444     }
       
   445     
       
   446 // ----------------------------------------------------------
       
   447 // CAPControlListPlugin::ShowInfoNoteL( TInt aResourceId )
       
   448 // ----------------------------------------------------------
       
   449 //
       
   450 void CAPControlListPlugin::ShowInfoNoteL( TInt aResourceId )
       
   451     {
       
   452     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ShowInfoNoteL" ) ) );
       
   453     HBufC* text = iCoeEnv->AllocReadResourceLC( aResourceId );
       
   454     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
   455     note->ExecuteLD( *text );
       
   456     CleanupStack::PopAndDestroy( text );
       
   457     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ShowInfoNoteL" ) ) );
       
   458     }
       
   459     
       
   460 // ----------------------------------------------------------
       
   461 // CAPControlListPlugin::ShowConfirmNoteL( TInt aResourceId )
       
   462 // ----------------------------------------------------------
       
   463 //
       
   464 
       
   465 void CAPControlListPlugin::ShowConfirmNoteL( TInt aResourceId )
       
   466     {
       
   467     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ShowConfirmNoteL" ) ) );
       
   468     HBufC* text = iCoeEnv->AllocReadResourceLC( aResourceId );
       
   469     CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue );
       
   470     note->ExecuteLD( *text );
       
   471     CleanupStack::PopAndDestroy( text );
       
   472     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ShowConfirmNoteL" ) ) );
       
   473     }
       
   474     
       
   475 // ----------------------------------------------------------
       
   476 // CAPControlListPlugin::ShowConfirmNoteL( TInt aResourceId )
       
   477 // ----------------------------------------------------------
       
   478 //
       
   479 void CAPControlListPlugin::ShowConfirmNoteAPNL( TInt aResourceId, TPtrC& aAPN )
       
   480     {
       
   481     CLOG( ( ESelector, 0, _L( "-> CAPControlListPlugin::ShowConfirmNoteL" ) ) );
       
   482     HBufC* text = StringLoader::LoadLC ( aResourceId, aAPN);
       
   483     CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue );
       
   484     note->ExecuteLD( *text );
       
   485     CleanupStack::PopAndDestroy( text );
       
   486     CLOG( ( ESelector, 0, _L( "<- CAPControlListPlugin::ShowConfirmNoteL" ) ) );
       
   487     }
       
   488     
       
   489 // ----------------------------------------------------------
       
   490 // CAPControlListPlugin::Container()
       
   491 // ----------------------------------------------------------
       
   492 //
       
   493 CAPControlListPluginContainer* CAPControlListPlugin::Container()
       
   494     {
       
   495     return iContainer;
       
   496     }
       
   497     
       
   498 // ----------------------------------------------------------
       
   499 // CAPControlListPlugin::APIWrapper()
       
   500 // ----------------------------------------------------------
       
   501 //
       
   502 CAPControlListAPIWrapper* CAPControlListPlugin::APIWrapper()
       
   503     {
       
   504     	return iAPIWrapper;
       
   505     }
       
   506 //End of file