profilesapplication/Profiles/ProfilesGSTonesPlugin/src/ProfilesGSTonesPlugin.cpp
branchRCL_3
changeset 19 cd54903d48da
equal deleted inserted replaced
18:b7fa36b488f8 19:cd54903d48da
       
     1 /*
       
     2 * Copyright (c) 2005 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:    Cpp file for plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // Includes
       
    20 #include "ProfilesGSTonesPlugin.h"
       
    21 
       
    22 #include "ProfilesUID.h"
       
    23 #include "CProfilesGSTonesPluginSettingsHandler.h"
       
    24 #include "ProfilesDebug.h"
       
    25 #include "ProfilesGSTonesPlugin.hrh"
       
    26 #include <profilesgstonespluginrsc.rsg>
       
    27 #include <CProfileNaviPaneContainer.h>
       
    28 
       
    29 // Includes from Profiles Settings View:
       
    30 #include <CProfileSettingsContainer.h>
       
    31 #include <CProfileEngineHandler.h>
       
    32 
       
    33 // Includes from Profiles Engine:
       
    34 #include <MProfileEngineExtended.h>
       
    35 #include <MProfilesLocalFeatures.h>
       
    36 #include <CProfileChangeNotifyHandler.h>
       
    37 #include "ProfilesVariant.hrh"
       
    38 
       
    39 // Includes from GS framework:
       
    40 #include <GSFWViewUIDs.h>
       
    41 #include <GSPrivatePluginProviderIds.h>
       
    42 
       
    43 // External includes
       
    44 #include <StringLoader.h>
       
    45 #include <bautils.h>
       
    46 #include <f32file.h>
       
    47 #include <data_caging_path_literals.hrh>
       
    48 #include <FeatMgr.h>
       
    49 #include <hlplch.h>
       
    50 #include <akntitle.h>
       
    51 #include <aknglobalnote.h>
       
    52 
       
    53 class CProfileIndexHandler;
       
    54 class CProfileTabHandler;
       
    55 
       
    56 namespace {
       
    57 // Constants
       
    58     const TUid KProfilesGSTonesPluginUid =
       
    59         { IMPLEMENTATION_UID_PROFILES_GS_TONES_PLUGIN };
       
    60 
       
    61     _LIT( KProfilesGSTonesPluginResourceFileName,
       
    62           "z:ProfilesGSTonesPluginRsc.rsc" );
       
    63 }
       
    64 
       
    65 // CLASS DECLARATION
       
    66 
       
    67 
       
    68 /******************************************************************************
       
    69  * class CProfileGSTonesTopControl
       
    70  ******************************************************************************/
       
    71 
       
    72 
       
    73 CProfileGSTonesTopControl* CProfileGSTonesTopControl::NewL( CCoeControl* aFocusControl )
       
    74     {
       
    75     CProfileGSTonesTopControl* self = new ( ELeave ) CProfileGSTonesTopControl();
       
    76     self->iFocusControl = aFocusControl;
       
    77     return self;
       
    78     }
       
    79 
       
    80 void CProfileGSTonesTopControl::FocusChanged( TDrawNow aDrawNow )
       
    81     {
       
    82     // Not calling super::FocusChanged is intentional
       
    83     if( iFocusControl )
       
    84         {
       
    85         iFocusControl->SetFocus( IsFocused(), aDrawNow );
       
    86         }
       
    87     }
       
    88 
       
    89 
       
    90 /******************************************************************************
       
    91  * class CProfilesGSTonesPlugin
       
    92  ******************************************************************************/
       
    93 
       
    94 
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CProfilesGSTonesPlugin::CProfilesGSTonesPlugin()
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 CProfilesGSTonesPlugin::CProfilesGSTonesPlugin()
       
   101     : iResourceLoader( *iCoeEnv )
       
   102     {
       
   103     }
       
   104 
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // CProfilesGSTonesPlugin::~CProfilesGSTonesPlugin()
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 CProfilesGSTonesPlugin::~CProfilesGSTonesPlugin()
       
   111     {
       
   112     DoDeactivate();
       
   113     delete iEngineHandler;
       
   114     iResourceLoader.Close();
       
   115     delete iNotifier;
       
   116     }
       
   117 
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // CProfilesGSTonesPlugin::ConstructL()
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 void CProfilesGSTonesPlugin::ConstructL()
       
   124     {
       
   125     PRODEBUG( "CProfilesGSTonesPlugin::ConstructL() begin" );
       
   126     // Find the resource file
       
   127     TParse parse;
       
   128     parse.Set( KProfilesGSTonesPluginResourceFileName, 
       
   129                &KDC_RESOURCE_FILES_DIR, NULL );
       
   130     TFileName fileName( parse.FullName() );
       
   131     
       
   132     // Get language of resource file
       
   133     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
   134 
       
   135     // Open resource file
       
   136     iResourceLoader.OpenL( fileName );
       
   137     
       
   138     PRODEBUG( "CProfilesGSTonesPlugin::ConstructL() before BaseConstructL call" );
       
   139     BaseConstructL( R_PROFILES_GS_TONES_VIEW ); // CSI: 9 # The resource file must be opened before this call
       
   140 
       
   141     iNotifier = CProfileChangeNotifyHandler::NewL( this );
       
   142     iEngineHandler = CProfileEngineHandler::NewL();
       
   143     iPreviousProfile = iEngineHandler->Engine()->ActiveProfileId();
       
   144     PRODEBUG( "CProfilesGSTonesPlugin::ConstructL() end" );
       
   145     }
       
   146 
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CProfilesGSTonesPlugin::NewL()
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 CProfilesGSTonesPlugin* CProfilesGSTonesPlugin::NewL( TAny* /*aInitParams*/ )
       
   153 	{
       
   154 	CProfilesGSTonesPlugin* self = new(ELeave) CProfilesGSTonesPlugin();
       
   155 	CleanupStack::PushL(self);
       
   156 	self->ConstructL();
       
   157 	CleanupStack::Pop(self);
       
   158 	return self;
       
   159 	}
       
   160 
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // CGSParentPlugin::Id()
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 TUid CProfilesGSTonesPlugin::Id() const
       
   167     {
       
   168     PRODEBUG( "CProfilesGSTonesPlugin::Id" );
       
   169     return KProfilesGSTonesPluginUid;
       
   170     }
       
   171 
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // CGSParentPlugin::DoActivateL()
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 void CProfilesGSTonesPlugin::DoActivateL
       
   178     ( const TVwsViewId& /* aPrevViewId */,
       
   179       TUid /* aCustomMessageId */,
       
   180       const TDesC8& /* aCustomMessage */ )
       
   181     {
       
   182     PRODEBUG( "CProfilesGSTonesPlugin::DoActivateL begin" );
       
   183     if ( !iContainer )
       
   184         {
       
   185         iSettingsHandler =
       
   186             CProfilesGSTonesPluginSettingsHandler::NewL( iCoeEnv );
       
   187 
       
   188         iContainer = CProfileSettingsContainer::NewL(
       
   189             *this, *iEngineHandler, *iSettingsHandler, (CProfileIndexHandler*) NULL,
       
   190             (CProfileTabHandler*) NULL, (CAknTitlePane*) NULL,
       
   191             R_PROFILE_GS_TONES_VIEW_SETTING_ITEM_LIST );
       
   192 
       
   193         iTopControl = CProfileGSTonesTopControl::NewL( iContainer );
       
   194 
       
   195         // Set the title pane text
       
   196        	CAknTitlePane* titlePane = static_cast< CAknTitlePane* >(
       
   197 		    StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   198         HBufC* title = StringLoader::LoadLC( R_PROFILES_GS_TONES_VIEW_TITLE );
       
   199         titlePane->SetTextL( *title );
       
   200         CleanupStack::PopAndDestroy( title );
       
   201 
       
   202         iNaviPaneContainer =
       
   203             CProfileNaviPaneContainer::NewL( *StatusPane(), *iEngineHandler );
       
   204         // Set the name of the active profile to navi pane
       
   205         iNaviPaneContainer->SetNaviPaneTextL();
       
   206 
       
   207         AppUi()->AddToViewStackL( *this, iContainer );
       
   208         // Top control is always on top as it listens to focus changes (which
       
   209         // will be routed to container to adapt highlight animation to focus)
       
   210         AppUi()->AddToStackL( *this, iTopControl );
       
   211 
       
   212         iContainer->MakeVisible( ETrue );
       
   213         }
       
   214     PRODEBUG( "CProfilesGSTonesPlugin::DoActivateL end" );
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // CGSParentPlugin::DoDeactivate()
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 void CProfilesGSTonesPlugin::DoDeactivate()
       
   222     {
       
   223     PRODEBUG( "CProfilesGSTonesPlugin::DoDeactivateL begin" );
       
   224     delete iNaviPaneContainer;
       
   225     iNaviPaneContainer = NULL;
       
   226 
       
   227     if ( iTopControl )
       
   228         {
       
   229         AppUi()->RemoveFromStack( iTopControl );
       
   230         delete iTopControl;
       
   231         iTopControl = NULL;
       
   232         }
       
   233     if ( iContainer )
       
   234         {
       
   235         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   236         delete iContainer;
       
   237         iContainer = NULL;
       
   238         }
       
   239     delete iSettingsHandler;
       
   240     iSettingsHandler = NULL;
       
   241     PRODEBUG( "CProfilesGSTonesPlugin::DoDeactivateL end" );
       
   242     }
       
   243 
       
   244 // ----------------------------------------------------------------------------
       
   245 // CProfilesGSTonesPlugin::HandleCommandL
       
   246 // 
       
   247 // Handles commands directed to this class.
       
   248 // ----------------------------------------------------------------------------
       
   249 void CProfilesGSTonesPlugin::HandleCommandL( TInt aCommand )
       
   250     {   
       
   251     PRODEBUG1( "CProfilesGSTonesPlugin::HandleCommandL(%d) begin", aCommand );
       
   252     CAknViewAppUi* appUi = AppUi();
       
   253     switch ( aCommand )
       
   254         {
       
   255         case EAknSoftkeyBack:
       
   256             appUi->ActivateLocalViewL( KGSPrslnPluginUid ); 
       
   257             break;
       
   258         case EProfilesGsTonesCmdChange:
       
   259         case EAknSoftkeyChange:
       
   260             PRODEBUG( "CProfilesGSTonesPlugin::HandleCommandL before EditItemL" );
       
   261             iContainer->EditItemL(
       
   262                 iContainer->SettingItemArray()->ItemIndexFromVisibleIndex(
       
   263                     iContainer->ListBox()->CurrentItemIndex() ),
       
   264                     ( aCommand == EProfilesGsTonesCmdChange ) );
       
   265             PRODEBUG( "CProfilesGSTonesPlugin::HandleCommandL after EditItemL" );
       
   266             break;
       
   267         case EAknCmdHelp:
       
   268             {
       
   269             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   270                 {
       
   271                 HlpLauncher::LaunchHelpApplicationL(
       
   272                     iEikonEnv->WsSession(), appUi->AppHelpContextL() );
       
   273                 }
       
   274             break;
       
   275             }
       
   276         default:
       
   277             appUi->HandleCommandL( aCommand );
       
   278             break;
       
   279         }
       
   280     PRODEBUG( "CProfilesGSTonesPlugin::HandleCommandL end" );
       
   281     }
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // CProfilesGSTonesPlugin::DynInitMenuPaneL
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 void CProfilesGSTonesPlugin::DynInitMenuPaneL(
       
   288     TInt aResourceId, CEikMenuPane* aMenuPane )
       
   289 	{
       
   290 	if( aResourceId == R_PROFILES_GS_OPTIONS_MENUPANE )
       
   291 		{
       
   292 		if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   293 			{
       
   294 			// Help is not supported. Hide Help from Options menu
       
   295 			aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
   296 			}
       
   297 		}
       
   298 	}
       
   299 
       
   300 // ========================= From CGSPluginInterface ==================
       
   301 
       
   302 
       
   303 // ---------------------------------------------------------------------------
       
   304 // CProfilesGSTonesPlugin::GetCaptionL()
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 void CProfilesGSTonesPlugin::GetCaptionL( TDes& aCaption ) const
       
   308     {
       
   309     PRODEBUG( "CProfilesGSTonesPlugin::GetCaptionL begin" );
       
   310     // The resource file is already opened by iResourceLoader.
       
   311     HBufC* result = StringLoader::LoadL( R_PROFILES_GS_TONES_VIEW_CAPTION );
       
   312     aCaption.Copy( *result );
       
   313     delete result;
       
   314     PRODEBUG( "CProfilesGSTonesPlugin::GetCaptionL end" );
       
   315     }
       
   316 
       
   317 // ---------------------------------------------------------------------------
       
   318 // CProfilesGSTonesPlugin::PluginProviderCategory()
       
   319 // ---------------------------------------------------------------------------
       
   320 //
       
   321 TInt CProfilesGSTonesPlugin::PluginProviderCategory() const
       
   322     {
       
   323     PRODEBUG( "CProfilesGSTonesPlugin::PluginProviderCategory" );
       
   324     return KGSPluginProviderInternal;
       
   325     }
       
   326 
       
   327 // ---------------------------------------------------------------------------
       
   328 // CProfilesGSTonesPlugin::ItemType()
       
   329 // ---------------------------------------------------------------------------
       
   330 //
       
   331 TGSListboxItemTypes CProfilesGSTonesPlugin::ItemType()
       
   332     {
       
   333     PRODEBUG( "CProfilesGSTonesPlugin::ItemType" );
       
   334     return EGSItemTypeSetting;
       
   335     }
       
   336 
       
   337 // ---------------------------------------------------------------------------
       
   338 // CProfilesGSTonesPlugin::UpdateClientRect()
       
   339 // ---------------------------------------------------------------------------
       
   340 //
       
   341 void CProfilesGSTonesPlugin::UpdateClientRect()
       
   342     {
       
   343     PRODEBUG( "CProfilesGSTonesPlugin::UpdateClientRect" );
       
   344 	iContainer->SetRect( ClientRect() );
       
   345     }
       
   346 
       
   347 // ---------------------------------------------------------------------------
       
   348 // CProfilesGSTonesPlugin::View()
       
   349 // ---------------------------------------------------------------------------
       
   350 //
       
   351 CAknView& CProfilesGSTonesPlugin::View()
       
   352     {
       
   353     PRODEBUG( "CProfilesGSTonesPlugin::View" );
       
   354     return *this;
       
   355     }
       
   356 
       
   357 // -----------------------------------------------------------------------------
       
   358 // CProfilesGSTonesPlugin::HandleActiveProfileEventL
       
   359 // -----------------------------------------------------------------------------
       
   360 //
       
   361 void CProfilesGSTonesPlugin::HandleActiveProfileEventL(
       
   362     TProfileEvent aProfileEvent, TInt aProfileId )
       
   363     {
       
   364     PRODEBUG( "CProfilesGSTonesPlugin::HandleActiveProfileEventL" );
       
   365     if( ( aProfileEvent == EProfileNewActiveProfile ) &&
       
   366         ( aProfileId != iPreviousProfile ) &&
       
   367         iNaviPaneContainer )
       
   368         {
       
   369         // Active profile has changed. Change active profile name in navi pane.
       
   370         iNaviPaneContainer->SetNaviPaneTextL();
       
   371         ShowInfoNoteL( R_PROFILES_GS_TONES_VIEW_UPDATED_NOTE );
       
   372         iPreviousProfile = aProfileId;
       
   373         }
       
   374     }
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CProfilesGSTonesPlugin::ShowInfoNoteL
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 void CProfilesGSTonesPlugin::ShowInfoNoteL( TInt aResourceId )
       
   381     {
       
   382     if( IsForeground() )
       
   383         {
       
   384         HBufC* infoText = StringLoader::LoadLC( aResourceId );
       
   385         CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   386         note->ShowNoteL( EAknGlobalInformationNote, *infoText );
       
   387 
       
   388         CleanupStack::PopAndDestroy( 2, infoText );
       
   389         }
       
   390     }
       
   391 
       
   392 // End of File
       
   393