gssettingsuis/Gs/GSCallBarringPlugin/Src/GSCallBarringPlugin.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
parent 23 8bda91a87a00
child 25 7e0eff37aedb
equal deleted inserted replaced
23:8bda91a87a00 24:8ee96d21d9bf
     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:  View for the Barring folder
       
    15 *
       
    16 */
       
    17 
       
    18  
       
    19 // INCLUDE FILES
       
    20 #include "GSCallBarringPlugin.h"
       
    21 #include "GSCallBarringPluginContainer.h"
       
    22 #include "GSPhoneSettingConstants.h"
       
    23 #include "GSInternetBarringView.h"
       
    24 #include "GSCellularCallBarringView.h"
       
    25 #include "GSMainBarringView.h"
       
    26 #include "CallBarringPlugin.hrh"
       
    27 #include "LocalViewIds.h"
       
    28 #include "GsLogger.h"
       
    29 
       
    30 #include <coeaui.h>
       
    31 #include <hlplch.h>                 // For HlpLauncher
       
    32 #include <e32base.h>
       
    33 #include <featmgr.h>
       
    34 #include <exterror.h>               //for extended error codes
       
    35 #include <StringLoader.h>           //for StringLoader
       
    36 #include <PsetContainer.h>          //for CPsetContainer
       
    37 #include <PsuiContainer.h>          //for CPsuiContainer
       
    38 #include <eikmenup.h>               //for menu bar
       
    39 #include <secuicodequerydialog.h>
       
    40 #include <nwdefs.h>
       
    41 #include <aknViewAppUi.h>
       
    42 
       
    43 #include <gscommon.hrh>
       
    44 #include <gscallbarringpluginrsc.rsg>
       
    45 #include <gscallbarringplugin.mbg>
       
    46 #include <gsfwviewuids.h>
       
    47 #include <gsprivatepluginproviderids.h>
       
    48 #include <BTSapInternalPSKeys.h>
       
    49 #include <centralrepository.h>
       
    50 #include <settingsinternalcrkeys.h>
       
    51 
       
    52 #if defined(__VOIP) && defined(RD_VOIP_REL_2_2)
       
    53 #include <spsettings.h>
       
    54 #endif // __VOIP && RD_VOIP_REL_2_2
       
    55 // LOCAL CONSTANTS
       
    56 _LIT( KGSCallBarringPluginResourceFileName, "z:GSCallBarringPluginRsc.rsc" );
       
    57 _LIT( KGSNameOfClass, "CGSCallBarringPlugin" );
       
    58 
       
    59 enum
       
    60     {
       
    61     EGSCallBarringPluginPanicNullPtr
       
    62     };
       
    63  
       
    64 
       
    65 // ========================= MEMBER FUNCTIONS ================================
       
    66 // ---------------------------------------------------------------------------
       
    67 // 
       
    68 // C++ constructor.
       
    69 // 
       
    70 // ---------------------------------------------------------------------------
       
    71 CGSCallBarringPlugin::CGSCallBarringPlugin()
       
    72     {
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // 
       
    77 // Symbian OS two-phased constructor (second phase)
       
    78 // 
       
    79 // ---------------------------------------------------------------------------
       
    80 void CGSCallBarringPlugin::ConstructL()
       
    81     {
       
    82     __GSLOGSTRING("[GS]--> CGSCallBarringPlugin::ConstructL");
       
    83     FeatureManager::InitializeLibL();
       
    84     OpenLocalizedResourceFileL( KGSCallBarringPluginResourceFileName,
       
    85                                 iResourceLoader );
       
    86     //PS listener initialization
       
    87     iBtSapListener = CGSPubSubsListener::NewL( 
       
    88                      KPSUidBluetoothSapConnectionState,
       
    89                      KBTSapConnectionState, this );
       
    90     SetCSPActiveL( ETrue );
       
    91     iBarringView = NULL;
       
    92 #if defined(__VOIP) && defined(RD_VOIP_REL_2_2)
       
    93     iVoipSupported = EFalse;
       
    94     CSPSettings* spSettings = CSPSettings::NewL();
       
    95     if ( spSettings->IsFeatureSupported( ESupportVoIPFeature ) &&
       
    96         spSettings->IsFeatureSupported( ESupportVoIPSSFeature ) )
       
    97         {
       
    98         iVoipSupported = ETrue;
       
    99         }
       
   100     delete spSettings;
       
   101 #else // __VOIP && RD_VOIP_REL_2_2
       
   102     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   103         {
       
   104         TInt supported( KGSSettingOff );
       
   105         CRepository* telephonyrep = 
       
   106             CRepository::NewL( KCRUidTelephonySettings );
       
   107         telephonyrep->Get( KDynamicVoIP, supported );
       
   108         iVoipSupported = KGSSettingOff != supported;
       
   109         delete telephonyrep;
       
   110         }
       
   111 #endif // __VOIP && RD_VOIP_REL_2_2
       
   112     BaseConstructL( R_GS_BARRING_MAIN_VIEW );
       
   113     // VoIP feature supported
       
   114     __GSLOGSTRING("[GS] <--CGSCallBarringPlugin::ConstructL");
       
   115     }
       
   116 
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CGSCallBarringPlugin::NewL()
       
   120 //
       
   121 // Symbian OS default constructor
       
   122 // ---------------------------------------------------------------------------
       
   123 CGSCallBarringPlugin* CGSCallBarringPlugin::NewL( TAny* /*aInitParams*/ )
       
   124     {
       
   125     CGSCallBarringPlugin* self = new( ELeave ) CGSCallBarringPlugin();
       
   126 
       
   127     CleanupStack::PushL( self );
       
   128     self->ConstructL();
       
   129     CleanupStack::Pop();
       
   130 
       
   131     return self;
       
   132     }
       
   133 
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // 
       
   137 // Symbian OS two-phased constructor (first phase)
       
   138 // 
       
   139 // ---------------------------------------------------------------------------
       
   140 CGSCallBarringPlugin* CGSCallBarringPlugin::NewLC()
       
   141     {
       
   142     __GSLOGSTRING("[GS]--> CGSCallBarringPlugin::NewLC");
       
   143     CGSCallBarringPlugin* self = new ( ELeave ) CGSCallBarringPlugin;
       
   144     CleanupStack::PushL( self );
       
   145     self->ConstructL();
       
   146 
       
   147     __GSLOGSTRING("[GS] <--CGSCallBarringPlugin::NewLC");
       
   148     return self;
       
   149     }
       
   150  
       
   151 // ---------------------------------------------------------------------------
       
   152 // 
       
   153 // C++ destructor
       
   154 // 
       
   155 // ---------------------------------------------------------------------------
       
   156 CGSCallBarringPlugin::~CGSCallBarringPlugin()
       
   157     {
       
   158     FeatureManager::UnInitializeLib();
       
   159     TRAP_IGNORE( SetCSPActiveL( EFalse ) );
       
   160     if ( iBtSapListener )
       
   161         {
       
   162         delete iBtSapListener;
       
   163         }
       
   164     }
       
   165  
       
   166 // ---------------------------------------------------------------------------
       
   167 // 
       
   168 // Returns Id of the Barring view.
       
   169 // 
       
   170 // ---------------------------------------------------------------------------
       
   171 TUid CGSCallBarringPlugin::Id() const
       
   172     {
       
   173     return KCallBarringPluginId;
       
   174     }
       
   175  
       
   176 // ---------------------------------------------------------------------------
       
   177 // 
       
   178 // Handles other than list box events.
       
   179 // 
       
   180 // ---------------------------------------------------------------------------
       
   181 void CGSCallBarringPlugin::HandleCommandL( TInt aCommand )
       
   182     {
       
   183     __GSLOGSTRING("[GS]--> CGSCallBarringPlugin::HandleCommandL");
       
   184 		switch ( aCommand )
       
   185         {
       
   186         case EAknSoftkeyBack:
       
   187             RemoveLocalViews();
       
   188             iAppUi->ActivateLocalViewL( KGSMainViewUid );
       
   189             break;
       
   190         case EAknCmdHelp:
       
   191             {
       
   192             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   193                 {
       
   194                 HlpLauncher::LaunchHelpApplicationL(
       
   195                     iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
       
   196                 }
       
   197             break;
       
   198             }
       
   199         default:
       
   200             iAppUi->HandleCommandL( aCommand );
       
   201             break;
       
   202         }
       
   203     __GSLOGSTRING("[GS] <--CGSCallBarringPlugin::HandleCommandL");
       
   204     }
       
   205   
       
   206 // ---------------------------------------------------------------------------
       
   207 // 
       
   208 // Activates view.
       
   209 // 
       
   210 // ---------------------------------------------------------------------------
       
   211 void CGSCallBarringPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
       
   212                                         TUid aCustomMessageId,
       
   213                                         const TDesC8& aCustomMessage )
       
   214     {
       
   215     __GSLOGSTRING("[GS]--> CGSCallBarringPlugin::DoActivateL");
       
   216     CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   217     ActivateInternalViewL();
       
   218     __GSLOGSTRING("[GS] <--CGSCallBarringPlugin::DoActivateL");
       
   219     }
       
   220  
       
   221 // ---------------------------------------------------------------------------
       
   222 // 
       
   223 // Deactivates view.
       
   224 // 
       
   225 // ---------------------------------------------------------------------------
       
   226 void CGSCallBarringPlugin::DoDeactivate()
       
   227     {
       
   228     __GSLOGSTRING("[GS]--> CGSCallBarringPlugin::DoDeactivate");
       
   229     CGSBaseView::DoDeactivate();
       
   230     __GSLOGSTRING("[GS] <--CGSCallBarringPlugin::DoDeactivate");
       
   231     }
       
   232  
       
   233  
       
   234 // ---------------------------------------------------------------------------
       
   235 // 
       
   236 // Creates new iContainer.
       
   237 // 
       
   238 // ---------------------------------------------------------------------------
       
   239 void CGSCallBarringPlugin::NewContainerL()
       
   240     {
       
   241     iContainer = new (ELeave) CGSCallBarringPluginContainer();
       
   242     }
       
   243 
       
   244 // ---------------------------------------------------------------------------
       
   245 // CGSCallBarringPlugin::Container
       
   246 //
       
   247 // Returns call container item
       
   248 // ---------------------------------------------------------------------------
       
   249 //
       
   250 CGSCallBarringPluginContainer* CGSCallBarringPlugin::Container()
       
   251     {
       
   252     return static_cast <CGSCallBarringPluginContainer*> ( iContainer );
       
   253     }
       
   254 
       
   255 // ========================= from CGSPluginInterface ==================
       
   256 
       
   257 // ----------------------------------------------------------------------------
       
   258 // CGSCallBarringPlugin::GetCaption
       
   259 //
       
   260 // Return application/view caption.
       
   261 // ----------------------------------------------------------------------------
       
   262 //
       
   263 void CGSCallBarringPlugin::GetCaptionL( TDes& aCaption ) const
       
   264     {
       
   265     // the resource file is already opened.
       
   266     HBufC* result = StringLoader::LoadL( R_GS_CALL_BARRING_CAPTION );
       
   267 
       
   268     aCaption.Copy( *result );
       
   269     delete result;
       
   270     }
       
   271 
       
   272 
       
   273 // ----------------------------------------------------------------------------
       
   274 // CGSCallBarringPlugin::PluginProviderCategory
       
   275 //
       
   276 // A means to identify the location of this plug-in in the framework.
       
   277 // ----------------------------------------------------------------------------
       
   278 //
       
   279 TInt CGSCallBarringPlugin::PluginProviderCategory() const
       
   280     {
       
   281     //To identify internal plug-ins.
       
   282     return KGSPluginProviderInternal;
       
   283     }
       
   284 
       
   285 
       
   286 // ----------------------------------------------------------------------------
       
   287 // CGSCallBarringPlugin::Visible
       
   288 //
       
   289 // Provides the visibility status of self to framework.
       
   290 // ----------------------------------------------------------------------------
       
   291 //
       
   292 TBool CGSCallBarringPlugin::Visible() const
       
   293     {
       
   294     TBool result( ETrue );
       
   295     TInt value = 0;
       
   296     RProperty::Get( KPSUidBluetoothSapConnectionState, 
       
   297                     KBTSapConnectionState, value );
       
   298     if ( value == EBTSapNotConnected || value == EBTSapConnecting )
       
   299         {
       
   300         //Now checking also for CSP support
       
   301         __ASSERT_ALWAYS( iCSP != NULL, User::Panic( KGSNameOfClass, 
       
   302                                    EGSCallBarringPluginPanicNullPtr ) );
       
   303         TInt err = KErrNone;
       
   304         err = iCSP->IsCBSupported( result );
       
   305         //CSP modifies result value even if something goes wrong
       
   306         //CSP will return KErrNotSupported (-5) in cases when
       
   307         //it is not possible to read CSP values from SIM card
       
   308         //Call Barring should be still displayed in this case
       
   309         if ( err != KErrNone )
       
   310             {
       
   311             result = ETrue;
       
   312             }
       
   313         }
       
   314     else
       
   315         {
       
   316         result = EFalse;
       
   317         }
       
   318     return result;    
       
   319     }    
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CGSCallBarringPlugin::CreateIconL()
       
   323 //
       
   324 //
       
   325 // -----------------------------------------------------------------------------
       
   326 //
       
   327 CGulIcon* CGSCallBarringPlugin::CreateIconL( const TUid aIconType )
       
   328     {
       
   329     //EMbm<Mbm_file_name><Bitmap_name>
       
   330     CGulIcon* icon;
       
   331     TParse* fp = new( ELeave ) TParse();
       
   332     CleanupStack::PushL( fp );
       
   333     fp->Set( KGSCallBarringPluginIconDirAndName, &KDC_BITMAP_DIR, NULL );
       
   334 
       
   335     if( aIconType == KGSIconTypeLbxItem )
       
   336         {
       
   337         icon = AknsUtils::CreateGulIconL(
       
   338         AknsUtils::SkinInstance(),
       
   339         KAknsIIDQgnPropSetBarrSub,
       
   340         fp->FullName(),
       
   341         EMbmGscallbarringpluginQgn_prop_set_barr_sub,
       
   342         EMbmGscallbarringpluginQgn_prop_set_barr_sub_mask );
       
   343         }
       
   344     else
       
   345         {
       
   346         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   347         }
       
   348 
       
   349     CleanupStack::PopAndDestroy( fp );
       
   350 
       
   351     return icon;
       
   352     }
       
   353 
       
   354 
       
   355 // ---------------------------------------------------------------------------
       
   356 // CGSCallBarringPlugin::HandleNotifyPSL
       
   357 //
       
   358 // Handling PS keys change
       
   359 // ---------------------------------------------------------------------------
       
   360 //  
       
   361 void CGSCallBarringPlugin::HandleNotifyPSL( const TUid aUid, const TInt& aKey,
       
   362                                           const TRequestStatus& /* aStatus */ )
       
   363     {
       
   364     if ( aUid == KPSUidBluetoothSapConnectionState && 
       
   365          aKey == KBTSapConnectionState )
       
   366         {
       
   367         Visible();
       
   368         }
       
   369     }
       
   370 
       
   371 // ----------------------------------------------------------------------------
       
   372 // CGSCallBarringPlugin::SetCSPActiveL
       
   373 // 
       
   374 // Set Customer Service Profile active
       
   375 // ----------------------------------------------------------------------------
       
   376 //
       
   377 void CGSCallBarringPlugin::SetCSPActiveL( TBool aValue )
       
   378     {
       
   379     if ( aValue )
       
   380         {
       
   381         iCSP = CPsetCustomerServiceProfile::NewL();
       
   382         User::LeaveIfError( iCSP->OpenCSProfileL() );
       
   383         }
       
   384     else
       
   385         {        
       
   386         delete iCSP;
       
   387         iCSP = NULL;
       
   388         }
       
   389     }
       
   390 
       
   391 // ---------------------------------------------------------------------------
       
   392 // CGSCallBarringPlugin::HandleClientRectChange
       
   393 //
       
   394 // Handle changes to rect().
       
   395 // ---------------------------------------------------------------------------
       
   396 //
       
   397 void CGSCallBarringPlugin::HandleClientRectChange()
       
   398     {
       
   399     if ( iContainer )
       
   400         {
       
   401         iContainer->SetRect( ClientRect() );
       
   402         }
       
   403     }
       
   404 
       
   405 // ---------------------------------------------------------------------------
       
   406 // CGSCallBarringPlugin::ActivateInternalViewL
       
   407 //
       
   408 // Activate local views within this plug-in.
       
   409 // ---------------------------------------------------------------------------
       
   410 void CGSCallBarringPlugin::ActivateInternalViewL()
       
   411     {
       
   412     TInt btSapState = 0; 
       
   413     RProperty::Get( KPSUidBluetoothSapConnectionState,
       
   414                     KBTSapConnectionState,
       
   415                     btSapState );
       
   416 
       
   417     if ( iVoipSupported )
       
   418         {
       
   419         CreateLocalViewL( KCallMainBarringViewId );
       
   420         }
       
   421     else
       
   422         {
       
   423         if ( btSapState == EBTSapNotConnected )
       
   424             {
       
   425             CreateLocalViewL( KCallBarringViewId );
       
   426             }
       
   427         }
       
   428 
       
   429     }
       
   430 
       
   431 // ---------------------------------------------------------------------------
       
   432 // CGSCallBarringPlugin::CreateLocalViewL
       
   433 //
       
   434 // Initializes local views within this plug-in based on the view ID.
       
   435 // ---------------------------------------------------------------------------
       
   436 void CGSCallBarringPlugin::CreateLocalViewL( TUid aLocalViewId )
       
   437     {
       
   438     CGSLocalBaseView* view;
       
   439 
       
   440     // Check if the view exists. If view does not exist:
       
   441     // 1. Create the view
       
   442     // 2. Add view to cleanupstack (NewLC)
       
   443     // 3. Add view to iAppUi -> iAppUi takes the view ownership.
       
   444     // 4. Remove view from cleanupstack
       
   445     // 5. Assign pointer of created view to member variable
       
   446     //
       
   447     if ( aLocalViewId == KCallBarringViewId )
       
   448         {
       
   449         //Check if BarringView already exists
       
   450         if ( !iBarringView )
       
   451             {
       
   452             view = CGSSettListBarringView::NewLC();
       
   453             iAppUi->AddViewL( view );
       
   454             CleanupStack::Pop( view );
       
   455             iBarringView = view;
       
   456             }
       
   457         iAppUi->ActivateLocalViewL( aLocalViewId );
       
   458         }
       
   459     else if ( aLocalViewId == KCallMainBarringViewId )
       
   460         {
       
   461         TUid viewId = aLocalViewId;
       
   462         if ( !iBarringView )
       
   463             {            
       
   464             if ( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallBarring ) )
       
   465                 {
       
   466                 // create the barring view directly if it's in restricted
       
   467                 // call barring
       
   468                 view = CGSSettListBarringView::NewLC();
       
   469                 viewId = view->Id();
       
   470                 }
       
   471             else
       
   472                 {
       
   473                 view = CGSSettListMainBarringView::NewLC();
       
   474                 }
       
   475             iAppUi->AddViewL( view );
       
   476             CleanupStack::Pop( view );
       
   477             iBarringView = view;    
       
   478             }
       
   479         // Activate the correct view in case restricted call barring is
       
   480         // active
       
   481         iAppUi->ActivateLocalViewL( viewId );    
       
   482         }
       
   483 
       
   484     }
       
   485 
       
   486 
       
   487 // ---------------------------------------------------------------------------
       
   488 // CGSCallBarringPlugin::RemoveLocalViews
       
   489 //
       
   490 //
       
   491 // ---------------------------------------------------------------------------
       
   492 //
       
   493 void CGSCallBarringPlugin::RemoveLocalViews()
       
   494     {
       
   495     // Remove view from iAppUi -> View is deleted by iAppUi automatically.
       
   496     if ( iBarringView )
       
   497         {
       
   498         if ( iVoipSupported )
       
   499             {
       
   500             iAppUi->RemoveView( KCallMainBarringViewId );// Also deletes view.
       
   501             }
       
   502         else
       
   503             {
       
   504             iAppUi->RemoveView( KCallBarringViewId );// Also deletes view.
       
   505             }    
       
   506         iBarringView = NULL;
       
   507         }
       
   508     }
       
   509 
       
   510 // ---------------------------------------------------------------------------
       
   511 // CGSCallBarringPlugin::HandleListBoxSelectionL
       
   512 //
       
   513 // Handle any user actions while in the list view.
       
   514 // ---------------------------------------------------------------------------
       
   515 void CGSCallBarringPlugin::HandleListBoxSelectionL()
       
   516     {
       
   517     }
       
   518 
       
   519 // ---------------------------------------------------------------------------
       
   520 // CGSCallBarringPlugin::VoIPSupported
       
   521 //
       
   522 // Is VoIP feature supported.
       
   523 // ---------------------------------------------------------------------------
       
   524 
       
   525 TBool CGSCallBarringPlugin::VoipSupported() const 
       
   526     {
       
   527     return iVoipSupported;
       
   528     }
       
   529 
       
   530 TGSListboxItemTypes CGSCallBarringPlugin::ItemType()
       
   531     {
       
   532     __GSLOGSTRING1( "[CGSCallBarringPlugin::ItemType] type %d", EGSItemTypeSettingDialog );
       
   533     return EGSItemTypeSettingDialog;
       
   534     }
       
   535 
       
   536 void CGSCallBarringPlugin::HandleSelection(
       
   537                 const TGSSelectionTypes /*aSelectionType*/ )
       
   538     {
       
   539     __GSLOGSTRING( "[CGSCallBarringPlugin::HandleSelection] Start" );
       
   540     ActivateInternalViewL();
       
   541     __GSLOGSTRING( "[CGSCallBarringPlugin::HandleSelection] End" );
       
   542     }
       
   543  // End of file