gssettingsuis/Gs/GSCallDivertPlugin/Src/GSCallDivertPlugin.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-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:  Main view handling for Call Divert.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "GSCallDivertPlugin.h"
       
    21 #include "GSCallDivertPluginContainer.h"
       
    22 #include "GSCallDivertView.h"
       
    23 #include "LocalViewId.h"
       
    24 #include "GSCallDivertModel.h"
       
    25 
       
    26 #include <gscommon.hrh>
       
    27 #include <coeaui.h>
       
    28 #include <hlplch.h>             // For HlpLauncher
       
    29 #include <aknViewAppUi.h>
       
    30 #include <gscalldivertpluginrsc.rsg>
       
    31 #include <gscalldivertplugin.mbg>
       
    32 #include <StringLoader.h>
       
    33 #include <featmgr.h>
       
    34 #include <gsfwviewuids.h>
       
    35 #include <gscommon.hrh>
       
    36 #include <gsprivatepluginproviderids.h>
       
    37 #include <BTSapInternalPSKeys.h>
       
    38 
       
    39 // LOCAL CONSTANTS
       
    40 _LIT( KGSCallDivertPluginResourceFileName, "z:GSCallDivertPluginRsc.rsc" );
       
    41 _LIT( KGSNameOfClass, "CGSCallDivertPlugin" );
       
    42 enum
       
    43     {
       
    44     EGSCallDivertPluginPanicNullPtr
       
    45     };
       
    46 
       
    47 // ========================= MEMBER FUNCTIONS ================================
       
    48 // ---------------------------------------------------------------------------
       
    49 // CGSCallDivertPlugin::CGSCallDivertPlugin
       
    50 //
       
    51 // C++ constructor.
       
    52 // ---------------------------------------------------------------------------
       
    53 CGSCallDivertPlugin::CGSCallDivertPlugin()
       
    54     {
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CGSCallDivertPlugin::ConstructL
       
    59 //
       
    60 // Symbian OS two-phased constructor
       
    61 // ---------------------------------------------------------------------------
       
    62 void CGSCallDivertPlugin::ConstructL()
       
    63     {
       
    64     FeatureManager::InitializeLibL();
       
    65     OpenLocalizedResourceFileL( KGSCallDivertPluginResourceFileName,
       
    66                                 iResourceLoader );
       
    67 
       
    68     //PS listener initialization
       
    69     iBtSapListener = CGSPubSubsListener::NewL(
       
    70                      KPSUidBluetoothSapConnectionState,
       
    71                      KBTSapConnectionState, this );
       
    72 
       
    73     SetCSPActiveL( ETrue );
       
    74     BaseConstructL( R_CF_MAIN_VIEW );
       
    75 
       
    76     iCallDivertModel = CGSCallDivertModel::NewL();
       
    77     CGSCallDivertView* callDivertView = CGSCallDivertView::NewLC( iCallDivertModel );
       
    78     iAppUi->AddViewL( callDivertView );
       
    79     CleanupStack::Pop( callDivertView );
       
    80     iCallDivertView = callDivertView;
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CGSCallDivertPlugin::~CGSCallDivertPlugin
       
    85 //
       
    86 // Destructor.
       
    87 // ---------------------------------------------------------------------------
       
    88 CGSCallDivertPlugin::~CGSCallDivertPlugin()
       
    89     {
       
    90     FeatureManager::UnInitializeLib();
       
    91     TRAP_IGNORE( SetCSPActiveL( EFalse ) );
       
    92     if ( iBtSapListener )
       
    93         {
       
    94         delete iBtSapListener;
       
    95         }
       
    96 
       
    97     if( iContainer )
       
    98         {
       
    99         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   100         AppUi()->RemoveView( KCallDivertPluginId );
       
   101         delete iContainer;
       
   102         }
       
   103     delete iCallDivertModel;
       
   104     }
       
   105 
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CGSCallDivertPlugin::NewL()
       
   109 //
       
   110 // Symbian OS default constructor
       
   111 // ---------------------------------------------------------------------------
       
   112 CGSCallDivertPlugin* CGSCallDivertPlugin::NewL( TAny* /*aInitParams*/ )
       
   113     {
       
   114     CGSCallDivertPlugin* self = new( ELeave ) CGSCallDivertPlugin();
       
   115 
       
   116     CleanupStack::PushL( self );
       
   117     self->ConstructL();
       
   118     CleanupStack::Pop();
       
   119 
       
   120     return self;
       
   121     }
       
   122 
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CGSCallDivertPlugin::NewLC
       
   126 //
       
   127 // 1st phase constructor.
       
   128 // ---------------------------------------------------------------------------
       
   129 CGSCallDivertPlugin* CGSCallDivertPlugin::NewLC()
       
   130     {
       
   131     CGSCallDivertPlugin* self =
       
   132             new ( ELeave ) CGSCallDivertPlugin;
       
   133     CleanupStack::PushL( self );
       
   134     self->ConstructL();
       
   135     return self;
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CGSCallDivertPlugin::NewContainerL
       
   140 //
       
   141 // Creates new iContainer.
       
   142 // ---------------------------------------------------------------------------
       
   143 void CGSCallDivertPlugin::NewContainerL()
       
   144     {
       
   145     iContainer = new ( ELeave ) CGSCallDivertPluginContainer;
       
   146     }
       
   147 
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CGSCallDivertPlugin::Id
       
   151 //
       
   152 // implementation of the frameworks virtual function, closely related with view
       
   153 // architecture and has little or no relevance here
       
   154 // ---------------------------------------------------------------------------
       
   155 TUid CGSCallDivertPlugin::Id() const
       
   156     {
       
   157     return KCallDivertPluginId;
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CGSCallDivertPlugin::HandleCommandL
       
   162 //
       
   163 // Handles the received commands
       
   164 // ---------------------------------------------------------------------------
       
   165 void CGSCallDivertPlugin::HandleCommandL( TInt aCommand )
       
   166     {
       
   167     switch ( aCommand )
       
   168         {
       
   169         case EAknSoftkeyBack:
       
   170             iAppUi->ActivateLocalViewL( KGSTelPluginUid );
       
   171             break;
       
   172         case EGSCmdAppOpen:
       
   173         case EAknSoftkeyOpen:
       
   174             HandleListBoxSelectionL();
       
   175             break;
       
   176         case ECFCmdCancelAll:
       
   177             iCallDivertView->HandleCommandL( ECFCmdCancelAll );
       
   178             break;
       
   179         case EAknCmdHelp:
       
   180             {
       
   181             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   182                 {
       
   183                 HlpLauncher::LaunchHelpApplicationL(
       
   184                     iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
       
   185                 }
       
   186             break;
       
   187             }
       
   188         default:
       
   189             iAppUi->HandleCommandL( aCommand );
       
   190             break;
       
   191         }
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // CGSCallDivertPlugin::HandleListBoxSelectionL
       
   196 //
       
   197 // Handles List box selection
       
   198 // ---------------------------------------------------------------------------
       
   199 void CGSCallDivertPlugin::HandleListBoxSelectionL()
       
   200     {
       
   201     // Other components will see updated value each time this funciton is 
       
   202     // called.
       
   203     iCallDivertModel->SetDivertServiceGroup( Container()->CurrentFeatureId() );
       
   204 
       
   205     switch ( iCallDivertModel->DivertServiceGroup() )
       
   206         {
       
   207         case EGSSettIdVoiceDivert:
       
   208         case EGSSettIdVideoDivert:
       
   209             iAppUi->ActivateLocalViewL( KCallDivertViewId );
       
   210             break;
       
   211         default:
       
   212             break;
       
   213         }
       
   214     }
       
   215 
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // CGSCallDivertPlugin::UpdateListBox
       
   219 //
       
   220 // Calls Containers UpdateListBoxL method
       
   221 // ---------------------------------------------------------------------------
       
   222 void CGSCallDivertPlugin::UpdateListBox( TInt aItemId )
       
   223     {
       
   224     if ( Container() )
       
   225         {
       
   226         TRAP_IGNORE( Container()->UpdateListBoxL( aItemId ) );
       
   227         }
       
   228     }
       
   229 
       
   230 
       
   231 // ---------------------------------------------------------------------------
       
   232 // CGSCallDivertPlugin::DoActivateL
       
   233 //
       
   234 // Activates view
       
   235 // ---------------------------------------------------------------------------
       
   236 void CGSCallDivertPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
       
   237                                              TUid aCustomMessageId,
       
   238                                              const TDesC8& aCustomMessage )
       
   239     {
       
   240     CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   241 
       
   242     iContainer->iListBox->SetTopItemIndex( iTopItemIndex );
       
   243 
       
   244     if ( iCurrentItem >= 0 &&
       
   245         iCurrentItem < iContainer->iListBox->Model()->NumberOfItems() ) // magic
       
   246         {
       
   247         iContainer->iListBox->SetCurrentItemIndexAndDraw( iCurrentItem );
       
   248         }
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // CGSCallDivertPlugin::DoDeactivate
       
   253 //
       
   254 // Deactivates view
       
   255 // ---------------------------------------------------------------------------
       
   256 void CGSCallDivertPlugin::DoDeactivate()
       
   257     {
       
   258     CGSBaseView::DoDeactivate();
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // CGSCallDivertPlugin::Container
       
   263 //
       
   264 // Returns call container item
       
   265 // ---------------------------------------------------------------------------
       
   266 //
       
   267 CGSCallDivertPluginContainer* CGSCallDivertPlugin::Container()
       
   268     {
       
   269     return static_cast <CGSCallDivertPluginContainer*> ( iContainer );
       
   270     }
       
   271 
       
   272 
       
   273 // ========================= From CGSPluginInterface ==================
       
   274 
       
   275 // ----------------------------------------------------------------------------
       
   276 // CGSCallDivertPlugin::GetCaption
       
   277 //
       
   278 // Return application/view caption.
       
   279 // ----------------------------------------------------------------------------
       
   280 //
       
   281 void CGSCallDivertPlugin::GetCaptionL( TDes& aCaption ) const
       
   282     {
       
   283     // the resource file is already opened.
       
   284     HBufC* result = StringLoader::LoadL( R_GS_CALL_DIVERT_CAPTION );
       
   285 
       
   286     aCaption.Copy( *result );
       
   287     delete result;
       
   288     }
       
   289 
       
   290 
       
   291 // ----------------------------------------------------------------------------
       
   292 // CGSCallDivertPlugin::PluginProviderCategory
       
   293 //
       
   294 // A means to identify the location of this plug-in in the framework.
       
   295 // ----------------------------------------------------------------------------
       
   296 //
       
   297 TInt CGSCallDivertPlugin::PluginProviderCategory() const
       
   298     {
       
   299     //To identify internal plug-ins.
       
   300     return KGSPluginProviderInternal;
       
   301     }
       
   302 
       
   303 
       
   304 // ----------------------------------------------------------------------------
       
   305 // CGSCallDivertPlugin::Visible
       
   306 //
       
   307 // Provides the visibility status of self to framework.
       
   308 // ----------------------------------------------------------------------------
       
   309 //
       
   310 TBool CGSCallDivertPlugin::Visible() const
       
   311     {
       
   312     TBool result( ETrue );
       
   313     TInt value = 0;
       
   314     iBtSapListener->Get( value );
       
   315     if ( value == EBTSapNotConnected || value == EBTSapConnecting )
       
   316         {
       
   317         //Now checking also for CSP support
       
   318         __ASSERT_ALWAYS( iCSP, User::Panic( KGSNameOfClass,
       
   319                          EGSCallDivertPluginPanicNullPtr ) );
       
   320         TInt err = KErrNone;
       
   321         err = iCSP->IsCFSupported( result );
       
   322         //CSP modifies result value even if something goes wrong
       
   323         //CSP will return KErrNotSupported (-5) in cases when
       
   324         //it is not possible to read CSP values from SIM card
       
   325         //Call Barring should be still displayed in this case
       
   326         if ( err != KErrNone )
       
   327             {
       
   328             result = ETrue;
       
   329             }
       
   330         }
       
   331     else
       
   332         {
       
   333         result = EFalse;
       
   334         }
       
   335     return result;
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CGSCallDivertPlugin::CreateIconL()
       
   340 //
       
   341 //
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 CGulIcon* CGSCallDivertPlugin::CreateIconL( const TUid aIconType )
       
   345     {
       
   346     //EMbm<Mbm_file_name><Bitmap_name>
       
   347     CGulIcon* icon;
       
   348     TParse* fp = new( ELeave ) TParse();
       
   349     CleanupStack::PushL( fp );
       
   350     fp->Set( KGSCallDivertPluginIconDirAndName, &KDC_BITMAP_DIR, NULL );
       
   351 
       
   352     if( aIconType == KGSIconTypeLbxItem )
       
   353         {
       
   354         icon = AknsUtils::CreateGulIconL(
       
   355         AknsUtils::SkinInstance(),
       
   356         KAknsIIDQgnPropSetDivSub,
       
   357         fp->FullName(),
       
   358         EMbmGscalldivertpluginQgn_prop_set_div_sub,
       
   359         EMbmGscalldivertpluginQgn_prop_set_div_sub_mask );
       
   360         }
       
   361     else
       
   362         {
       
   363         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   364         }
       
   365 
       
   366     CleanupStack::PopAndDestroy( fp );
       
   367 
       
   368     return icon;
       
   369     }
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // CGSCallDivertPlugin::HandleNotifyPSL
       
   373 //
       
   374 // Handling PS keys change
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 void CGSCallDivertPlugin::HandleNotifyPSL( const TUid aUid, const TInt& aKey,
       
   378                                           const TRequestStatus& /* aStatus */ )
       
   379     {
       
   380     if ( aUid == KPSUidBluetoothSapConnectionState &&
       
   381          aKey == KBTSapConnectionState )
       
   382         {
       
   383         Visible();
       
   384         }
       
   385     }
       
   386 
       
   387 // ----------------------------------------------------------------------------
       
   388 // CGSCallDivertPlugin::SetCSPActiveL
       
   389 //
       
   390 // Set Customer Service Profile active
       
   391 // ----------------------------------------------------------------------------
       
   392 //
       
   393 void CGSCallDivertPlugin::SetCSPActiveL( TBool aValue )
       
   394     {
       
   395     if ( aValue )
       
   396         {
       
   397         iCSP = CPsetCustomerServiceProfile::NewL();
       
   398         User::LeaveIfError( iCSP->OpenCSProfileL() );
       
   399         }
       
   400     else
       
   401         {
       
   402         delete iCSP;
       
   403         iCSP = NULL;
       
   404         }
       
   405     }
       
   406 
       
   407 
       
   408 // ----------------------------------------------------------------------------
       
   409 // CGSCallDivertPlugin::DynInitMenuPaneL()
       
   410 //
       
   411 // Display the dynamic menu
       
   412 // ----------------------------------------------------------------------------
       
   413 void CGSCallDivertPlugin::DynInitMenuPaneL( TInt aResourceId,
       
   414                                             CEikMenuPane* aMenuPane )
       
   415     {
       
   416     // show or hide the 'help' menu item when supported
       
   417     if( aResourceId == R_GS_MENU_ITEM_HELP )
       
   418         {
       
   419         User::LeaveIfNull( aMenuPane );
       
   420 
       
   421         if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   422             {
       
   423             aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
       
   424             }
       
   425         else
       
   426             {
       
   427             aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
   428             }
       
   429         }
       
   430     }
       
   431 
       
   432 // End of File