uifw/AvKon/akncompamode/gs/src/akncompags.cpp
changeset 21 558113899881
parent 14 3320e4e6e8bb
child 22 75713bee6484
child 33 b3425bf29f82
equal deleted inserted replaced
14:3320e4e6e8bb 21:558113899881
     1 /*
       
     2 * Copyright (c) 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:  View for compa mode settings
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "akncompags.h"
       
    20 #include "akncompagsmodel.h"
       
    21 #include "akncompagscontainer.h"
       
    22 #include "akncompags.hrh"
       
    23 
       
    24 #include <avkon.mbg> // icons
       
    25 #include <akncompagsrsc.rsg>
       
    26 #include <gsfwviewuids.h>
       
    27 #include <gsprivatepluginproviderids.h>
       
    28 
       
    29 #include <AknQueryDialog.h>
       
    30 #include <aknradiobuttonsettingpage.h>
       
    31 #include <aknViewAppUi.h>
       
    32 #include <StringLoader.h>
       
    33 #include <bautils.h>
       
    34 #include <coeaui.h>
       
    35 #include <eikfrlbd.h>
       
    36 #include <ecom/implementationproxy.h>
       
    37 #include <hlplch.h>             // For HlpLauncher
       
    38 
       
    39 #include <gscommon.hrh>
       
    40 
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 // --------------------------------------------------------------------------
       
    44 CAknCompaGS::CAknCompaGS()
       
    45   : iResourceLoader( *iCoeEnv )
       
    46     {
       
    47     }
       
    48 
       
    49 // --------------------------------------------------------------------------
       
    50 // Create a compa-mode settings plugin
       
    51 // --------------------------------------------------------------------------
       
    52 CAknCompaGS* CAknCompaGS::NewL( TAny* /*aInitParams*/ )
       
    53     {
       
    54     CAknCompaGS* self = new( ELeave ) CAknCompaGS ();
       
    55 
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop();
       
    59 
       
    60     return self;
       
    61     }
       
    62 
       
    63 // --------------------------------------------------------------------------
       
    64 //
       
    65 // --------------------------------------------------------------------------
       
    66 void CAknCompaGS::ConstructL()
       
    67     {
       
    68     TParse parse;
       
    69     parse.Set( KAknCompaGSResourceFileName,
       
    70                &KDC_RESOURCE_FILES_DIR, NULL );
       
    71     TFileName fileName( parse.FullName() );
       
    72 
       
    73     // Get language of resource file
       
    74     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
    75 
       
    76     // Open resource file
       
    77     iResourceLoader.OpenL( fileName );
       
    78 
       
    79     iModel = CAknCompaGSModel::NewL();
       
    80 
       
    81     BaseConstructL( R_AKNCOMPAGS_VIEW );
       
    82     }
       
    83 
       
    84 
       
    85 // --------------------------------------------------------------------------
       
    86 //
       
    87 // --------------------------------------------------------------------------
       
    88 CAknCompaGS::~CAknCompaGS()
       
    89     {
       
    90     iResourceLoader.Close();
       
    91     delete iModel;
       
    92     }
       
    93 
       
    94 // --------------------------------------------------------------------------
       
    95 // Return plugin implementation ID
       
    96 // --------------------------------------------------------------------------
       
    97 TUid CAknCompaGS::Id() const
       
    98     {
       
    99     return KAknCompaGSUid;
       
   100     }
       
   101 
       
   102 // --------------------------------------------------------------------------
       
   103 // Get caption of the plugin (localized name of the view)
       
   104 // --------------------------------------------------------------------------
       
   105 void CAknCompaGS::GetCaptionL( TDes& aCaption ) const
       
   106     {
       
   107     // the resource file is already opened.
       
   108     HBufC* result = StringLoader::LoadL( R_AKNCOMPAGS_LIST_CAPTION );
       
   109 
       
   110     aCaption.Copy( *result );
       
   111     delete result;
       
   112     }
       
   113 
       
   114 // --------------------------------------------------------------------------
       
   115 // Return ID of plugin provider category
       
   116 // --------------------------------------------------------------------------
       
   117 TInt CAknCompaGS::PluginProviderCategory() const
       
   118     {
       
   119     // To identify as internal plug-in.
       
   120     return KGSPluginProviderInternal;
       
   121     }
       
   122 
       
   123 // --------------------------------------------------------------------------
       
   124 // Return if the plugin should be visible in the settings framework
       
   125 // --------------------------------------------------------------------------
       
   126 TBool CAknCompaGS::Visible() const
       
   127     {
       
   128     return iModel->FeatureEnabled();
       
   129     }
       
   130 
       
   131 
       
   132 // --------------------------------------------------------------------------
       
   133 // Handle command
       
   134 // --------------------------------------------------------------------------
       
   135 void CAknCompaGS::HandleCommandL( TInt aCommand )
       
   136     {
       
   137     switch ( aCommand )
       
   138         {
       
   139         case EGSMSKCmdAppChange:
       
   140             HandleListBoxSelectionL();
       
   141             break;
       
   142         case EGSCmdAppChange:
       
   143             HandleListBoxSelectionL();
       
   144             break;
       
   145         case EAknSoftkeyBack:
       
   146             iAppUi->ActivateLocalViewL( iPrevViewId.iViewUid );
       
   147             break;
       
   148         case EAknCmdHelp:
       
   149             HlpLauncher::LaunchHelpApplicationL(
       
   150                 iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
       
   151             break;
       
   152         default:
       
   153             iAppUi->HandleCommandL( aCommand );
       
   154             break;
       
   155         }
       
   156     }
       
   157 
       
   158 // --------------------------------------------------------------------------
       
   159 // Return container
       
   160 // --------------------------------------------------------------------------
       
   161 CAknCompaGSContainer* CAknCompaGS::Container()
       
   162     {
       
   163     return static_cast<CAknCompaGSContainer*>( iContainer );
       
   164     }
       
   165 
       
   166 
       
   167 // --------------------------------------------------------------------------
       
   168 // Create container
       
   169 // --------------------------------------------------------------------------
       
   170 void CAknCompaGS::NewContainerL()
       
   171     {
       
   172     iContainer = new( ELeave ) CAknCompaGSContainer;
       
   173     }
       
   174 
       
   175 // --------------------------------------------------------------------------
       
   176 // Activate view
       
   177 // --------------------------------------------------------------------------
       
   178 void CAknCompaGS::DoActivateL( const TVwsViewId& aPrevViewId,
       
   179                                      TUid aCustomMessageId,
       
   180                                      const TDesC8& aCustomMessage )
       
   181     {
       
   182     iPrevViewId = aPrevViewId;
       
   183 
       
   184     CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   185     }
       
   186 
       
   187 // --------------------------------------------------------------------------
       
   188 // Handle list box selection
       
   189 // --------------------------------------------------------------------------
       
   190 void CAknCompaGS::HandleListBoxSelectionL()
       
   191     {
       
   192     const TInt currentFeatureId = Container()->CurrentFeatureId();
       
   193 
       
   194     switch ( currentFeatureId )
       
   195         {
       
   196         case KCompaGSIdState:
       
   197             {
       
   198             TBool newValue = !iModel->CompaAppState();
       
   199             iModel->SetCompaAppState(newValue);
       
   200             Container()->UpdateListBoxL( currentFeatureId, newValue );
       
   201             }
       
   202             break;
       
   203        default:
       
   204             break;
       
   205         }
       
   206     }
       
   207 
       
   208 // --------------------------------------------------------------------------
       
   209 // Create icon of desired type
       
   210 // --------------------------------------------------------------------------
       
   211 CGulIcon* CAknCompaGS::CreateIconL( const TUid aIconType )
       
   212     {
       
   213     CGulIcon* icon;
       
   214     TParse* fp = new( ELeave ) TParse();
       
   215     CleanupStack::PushL( fp );
       
   216     fp->Set( KAknCompaGSIconDirAndName, &KDC_BITMAP_DIR, NULL );
       
   217 
       
   218     if( aIconType == KGSIconTypeLbxItem )
       
   219         {
       
   220         icon = AknsUtils::CreateGulIconL(
       
   221         AknsUtils::SkinInstance(),
       
   222         KAknsIIDNone,
       
   223         fp->FullName(),
       
   224         EMbmAvkonQgn_prop_folder_apps_medium,
       
   225         EMbmAvkonQgn_prop_folder_apps_medium_mask );
       
   226         }
       
   227     else
       
   228         {
       
   229         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   230         }
       
   231 
       
   232     CleanupStack::PopAndDestroy( fp );
       
   233 
       
   234     return icon;
       
   235     }
       
   236 
       
   237 // --------------------------------------------------------------------------
       
   238 // Return factory functions for ECOM interface implementations
       
   239 // --------------------------------------------------------------------------
       
   240 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( 
       
   241     TInt& aTableCount )
       
   242     {
       
   243     static const TImplementationProxy KAknCompaGSImplementationTable[] = 
       
   244         {
       
   245         IMPLEMENTATION_PROXY_ENTRY( 0x2001114A, CAknCompaGS::NewL )
       
   246         };
       
   247 
       
   248     aTableCount = sizeof( KAknCompaGSImplementationTable ) 
       
   249         / sizeof( TImplementationProxy );
       
   250     return KAknCompaGSImplementationTable;
       
   251     }