voicerecorder/gsplugin/src/CVRGSPlugin.cpp
branchRCL_3
changeset 20 072a5fa0c63b
parent 19 2f5c9ee7098c
child 21 c6bafb5162d8
equal deleted inserted replaced
19:2f5c9ee7098c 20:072a5fa0c63b
     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:  Main settings view class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CVRGSPlugin.h"
       
    21 #include "CVRGSPluginContainer.h"
       
    22 
       
    23 #include "VRConsts.h"
       
    24 #include <voicerecorder.rsg>
       
    25 #include "voicerecorder.hrh"
       
    26 
       
    27 #include "VRUtils.h"
       
    28 
       
    29 #include <f32file.h> // For icon generation
       
    30 #include <gsvoicerecorderplugin.mbg> // For icon generation
       
    31 
       
    32 #include <data_caging_path_literals.hrh>
       
    33 #include <avkon.hrh>
       
    34 #include <aknViewAppUi.h>
       
    35 #include <akntitle.h>  // CAknTitlePane
       
    36 #include <featmgr.h>
       
    37 #include <StringLoader.h>     //for StringLoader
       
    38 #include <gsfwviewuids.h>     //for KGSMainViewUid
       
    39 #include <hlplch.h>             // For HlpLauncher
       
    40 #include <bautils.h>            // for BaflUtils
       
    41 #include <AknQueryDialog.h>
       
    42 
       
    43 // ========================= MEMBER FUNCTIONS ================================
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CVRGSPlugin::CVRGSPlugin
       
    47 // C++ constructor
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CVRGSPlugin::CVRGSPlugin()
       
    51     : iResourceLoader( *iCoeEnv  )
       
    52     {
       
    53     
       
    54     }
       
    55 
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CVRGSPlugin::NewLC
       
    59 // Symbian OS two-phased constructor
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CVRGSPlugin* CVRGSPlugin::NewL( TAny* /*aInitParams*/ )
       
    63     {
       
    64     CVRGSPlugin* self = new(ELeave) CVRGSPlugin();
       
    65 	CleanupStack::PushL(self);
       
    66 	self->ConstructL();
       
    67 	CleanupStack::Pop(self);
       
    68 	return self;
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CVRGSPlugin::ConstructL
       
    74 // Symbian OS 2nd phase constructor
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CVRGSPlugin::ConstructL()
       
    78     {
       
    79 #ifdef _DEBUG    
       
    80     RDebug::Print(_L("[CVRGSPlugin] ConstructL()" ));
       
    81     RDebug::Print( _L( "[CVRGSPlugin] Loading resource from :" ) );
       
    82     RDebug::Print( KVRAppResourceFile );
       
    83 #endif
       
    84     
       
    85      // Find the resource file
       
    86     TParse parse;
       
    87     parse.Set( KVRAppResourceFile,    
       
    88                &KDC_APP_RESOURCE_DIR, 
       
    89                NULL );
       
    90     TFileName fileName( parse.FullName() );
       
    91     
       
    92     // Get language of resource file
       
    93     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
    94 
       
    95     // Open resource file
       
    96     iResourceLoader.OpenL( fileName );    
       
    97     FeatureManager::InitializeLibL();
       
    98     
       
    99     BaseConstructL( R_VOREC_GS_SETTING_LIST_VIEW );
       
   100     
       
   101     iCaption = StringLoader::LoadL( R_VOREC_GS_SETTINGS_TITLE );
       
   102     }
       
   103 
       
   104 
       
   105 // Destructor
       
   106 CVRGSPlugin::~CVRGSPlugin()
       
   107     {
       
   108     FeatureManager::UnInitializeLib();
       
   109 
       
   110     if( iContainer )
       
   111         {
       
   112         if ( iAppUi )
       
   113             {
       
   114             iAppUi->RemoveFromViewStack( *this, iContainer );
       
   115             }
       
   116         delete iContainer;
       
   117         iContainer=NULL;
       
   118         }  
       
   119         
       
   120     iResourceLoader.Close(); 
       
   121     
       
   122     delete iCaption; 
       
   123     }
       
   124 
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CVRGSPlugin::Id
       
   128 // Return UID of view
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 TUid CVRGSPlugin::Id() const
       
   132     {
       
   133     return KGSVoiceRecorderGSPluginUid;
       
   134     }
       
   135 
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CVRGSPlugin::HandleCommandL
       
   139 // Handle commands
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CVRGSPlugin::HandleCommandL( TInt aCommand )
       
   143     {
       
   144    
       
   145     switch ( aCommand )
       
   146         {
       
   147         case ECmdChange:
       
   148         case EAknCmdOpen:
       
   149             // Delegate to container
       
   150             Container()->HandleListBoxSelectionL( EAknCmdOpen );
       
   151             break;
       
   152         case ECmdMSK:
       
   153         	// Delegate to container
       
   154         	// Selection view is not open when command is ECmdMSK
       
   155             Container()->HandleListBoxSelectionL( ECmdMSK );
       
   156         	break;          
       
   157         case EAknSoftkeyBack:
       
   158         case ECmdCancel:   
       
   159             // Activate previous view
       
   160 #ifdef _DEBUG                
       
   161     RDebug::Print(_L("VRGS: activating view 0x%x"), iPrevViewId.iViewUid.iUid);                            
       
   162 #endif
       
   163             iAppUi->ActivateLocalViewL( iPrevViewId.iViewUid );
       
   164             break; 
       
   165         case EAknCmdHelp:
       
   166             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   167                 {
       
   168                 HlpLauncher::LaunchHelpApplicationL(
       
   169                     iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
       
   170                 }
       
   171             break;           
       
   172         case ECmdOk: // Exit selected from options menu
       
   173             {
       
   174             iAppUi->HandleCommandL( EEikCmdExit ); 
       
   175             break;
       
   176             }
       
   177         default:
       
   178             iAppUi->HandleCommandL( aCommand );
       
   179             break;
       
   180         } 
       
   181     }
       
   182     
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // CVRGSPlugin::DoActivate
       
   186 // Activate this view
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189     
       
   190 void CVRGSPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
       
   191                                   TUid aCustomMessageId,
       
   192                                   const TDesC8& aCustomMessage )
       
   193     {       
       
   194     CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   195     }
       
   196 
       
   197 
       
   198 // ---------------------------------------------------------------------------
       
   199 // CVRGSPlugin::DoDeactivate
       
   200 // Deactivate this view
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 void CVRGSPlugin::DoDeactivate()
       
   204     {
       
   205     CGSBaseView::DoDeactivate();
       
   206     }
       
   207     
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CVRGSPlugin::HandleClientRectChange
       
   211 // Handle screen size change.
       
   212 // -----------------------------------------------------------------------------
       
   213 //
       
   214 void CVRGSPlugin::HandleClientRectChange()
       
   215     {
       
   216     if ( iContainer )
       
   217         {
       
   218         iContainer->SetRect( ClientRect() );
       
   219         } 
       
   220     }
       
   221 
       
   222 
       
   223 // ---------------------------------------------------------------------------
       
   224 // CVRGSPlugin::Container
       
   225 // Return handle to container class.
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 CVRGSPluginContainer* CVRGSPlugin::Container()
       
   229     {
       
   230     return static_cast<CVRGSPluginContainer*>( iContainer );
       
   231     }
       
   232     
       
   233     
       
   234 // ---------------------------------------------------------------------------
       
   235 // CVRGSPlugin::HandleListBoxSelectionL
       
   236 // Handle any user actions while in the list view.
       
   237 // ---------------------------------------------------------------------------
       
   238 //
       
   239 void CVRGSPlugin::HandleListBoxSelectionL() 
       
   240     {
       
   241     // Delegate to container
       
   242     Container()->HandleListBoxSelectionL( ECmdChange );
       
   243     }
       
   244 
       
   245 
       
   246 // ---------------------------------------------------------------------------
       
   247 // CVRGSPlugin::GetCaptionL
       
   248 // Caption text for view to be displayed in NaviPane.
       
   249 // ---------------------------------------------------------------------------
       
   250 //
       
   251 void CVRGSPlugin::GetCaptionL( TDes& aCaption ) const
       
   252     {
       
   253     aCaption.Copy( *iCaption );
       
   254     }
       
   255     
       
   256     
       
   257 // ---------------------------------------------------------------------------
       
   258 // CVRGSPlugin::NewContainerL
       
   259 // Creates new iContainer.
       
   260 // ---------------------------------------------------------------------------
       
   261 //
       
   262 void CVRGSPlugin::NewContainerL()
       
   263     {
       
   264     iContainer = new( ELeave ) CVRGSPluginContainer;
       
   265     }
       
   266 
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // CVRGSPlugin::CreateIconL
       
   270 // Return the icon, if has one.
       
   271 // ---------------------------------------------------------------------------
       
   272 //
       
   273 CGulIcon* CVRGSPlugin::CreateIconL( const TUid /*aIconType*/ )
       
   274     {
       
   275 
       
   276 	// New implementation
       
   277 	TParse* fp = new(ELeave) TParse();
       
   278     CleanupStack::PushL( fp );
       
   279     TInt err = fp->Set( KVRPluginFile, &KDC_APP_BITMAP_DIR, NULL ); 
       
   280 
       
   281     if ( err != KErrNone )
       
   282         { 
       
   283         User::Leave( err );
       
   284         }
       
   285 
       
   286     TBuf<KMaxFileName> fileName = fp->FullName();
       
   287     CleanupStack::PopAndDestroy();  //fp
       
   288 
       
   289     CGulIcon* icon;
       
   290     
       
   291     icon = AknsUtils::CreateGulIconL(
       
   292         AknsUtils::SkinInstance(), 
       
   293         KAknsIIDQgnPropSetAppsVoirec,
       
   294         fileName,
       
   295         EMbmGsvoicerecorderpluginQgn_prop_set_apps_voirec,
       
   296 		EMbmGsvoicerecorderpluginQgn_prop_set_apps_voirec_mask );
       
   297     
       
   298     return icon;
       
   299 
       
   300     }
       
   301     
       
   302    
       
   303 // ---------------------------------------------------------------------------
       
   304 // CVRGSPlugin::Visible()
       
   305 // Method for checking, if plugin should be visible and used in GS.
       
   306 // ---------------------------------------------------------------------------
       
   307 //    
       
   308 TBool CVRGSPlugin::Visible() const
       
   309     {
       
   310     if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ||
       
   311          FeatureManager::FeatureSupported( KFeatureIdMmc ) )
       
   312         {
       
   313         return ETrue;
       
   314         }
       
   315     else
       
   316         {
       
   317         return EFalse;
       
   318         }
       
   319 
       
   320     }
       
   321     
       
   322     
       
   323 // ---------------------------------------------------------------------------
       
   324 // CVRGSPlugin::CustomOperationL()
       
   325 // Reserved for later use.
       
   326 // ---------------------------------------------------------------------------
       
   327 //        
       
   328 TAny* CVRGSPlugin::CustomOperationL( TAny* aParam1, TAny* /*aParam2*/ )
       
   329     {
       
   330     return aParam1;    
       
   331     }
       
   332 
       
   333 
       
   334 // ---------------------------------------------------------------------------
       
   335 // CVRSettingsDialog::DynInitMenuPaneL
       
   336 // 
       
   337 // ---------------------------------------------------------------------------
       
   338 //
       
   339 void CVRGSPlugin::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   340 	{
       
   341 
       
   342 	switch ( aResourceId )
       
   343 		{
       
   344 		case R_VOREC_GS_SETTINGS_MENUPANE:
       
   345 			{
       
   346 			// Check if HELP is enabled in FeatureManager, if not, disable the Help menu item
       
   347 			if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
       
   348 				{
       
   349 				aMenuPane->SetItemDimmed(EAknCmdHelp, ETrue);
       
   350 				}
       
   351             break; 
       
   352 			}
       
   353 		case R_VR_SETTINGS_MENUPANE:
       
   354 			{
       
   355 			// Check if HELP is enabled in FeatureManager, if not, disable the Help menu item
       
   356 			if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
       
   357 				{
       
   358 				aMenuPane->SetItemDimmed(ECmdHelp, ETrue);
       
   359 				}
       
   360             break; 
       
   361 			}
       
   362 
       
   363 
       
   364 		default:
       
   365 			{
       
   366 			break;
       
   367 			}
       
   368 		}
       
   369 	}   
       
   370 
       
   371 // End of file
       
   372 
       
   373