extras/about/aboutgsplugin/Src/aboutgsplugin.cpp
branchRCL_3
changeset 21 10c6e6d6e4d9
parent 0 3ee3dfdd8d69
equal deleted inserted replaced
20:41b775cdc0c8 21:10c6e6d6e4d9
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Source file for CAboutGsPlugin class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <aknViewAppUi.h>
       
    20 #include <ConeResLoader.h>
       
    21 #include <barsread.h>       // For TResourceReader
       
    22 #include <StringLoader.h>
       
    23 #include <apgcli.h>
       
    24 #include <AknLaunchAppService.h>
       
    25 #include <bautils.h>
       
    26 
       
    27 // Includes from GS framework:
       
    28 #include <gsfwviewuids.h>
       
    29 #include <gsprivatepluginproviderids.h>
       
    30 
       
    31 
       
    32 // Plugin includes:
       
    33 #include <aboutgspluginrsc.rsg>
       
    34 #include <aboutgsplugin.mbg>
       
    35 
       
    36 
       
    37 // Includes
       
    38 #include "aboutgsplugin.h"
       
    39 
       
    40 #define ABOUTAPPUID  0x10005a22
       
    41 
       
    42 const TUid KAboutGsPluginUid = { 0x102833A0 };
       
    43 
       
    44 // svg icons
       
    45 _LIT( KGSAboutGsPluginIconFileName, "\\resource\\apps\\aboutgsplugin.mif");
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CAboutGsPlugin::CAboutGsPlugin()
       
    49 //
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CAboutGsPlugin::CAboutGsPlugin()
       
    53     : iPlgResourceLoader( *iCoeEnv ), iNullService( NULL )
       
    54     {
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CAboutGsPlugin::~CAboutGsPlugin()
       
    59 //
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CAboutGsPlugin::~CAboutGsPlugin()
       
    63     {
       
    64     iPlgResourceLoader.Close();
       
    65     if ( iNullService )
       
    66     	{
       
    67     	delete iNullService;
       
    68     	iNullService = NULL;
       
    69     	}
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CAboutGsPlugin::ConstructL()
       
    74 //
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CAboutGsPlugin::ConstructL()
       
    78     {
       
    79     OpenLocalizedResourceFileL();
       
    80     }
       
    81 
       
    82 
       
    83 void CAboutGsPlugin::OpenLocalizedResourceFileL()
       
    84     {
       
    85     TFileName resourceFileName;
       
    86     TPtrC driveLetter = TParsePtrC( RProcess().FileName() ).Drive();
       
    87     _LIT( KResoureFileName, "aboutgspluginrsc.rsc" );
       
    88    
       
    89     resourceFileName.Copy( driveLetter );  
       
    90     resourceFileName.Append( KDC_ECOM_RESOURCE_DIR );
       
    91     resourceFileName.Append( KResoureFileName );
       
    92 
       
    93     RFs fsSession;
       
    94     User::LeaveIfError( fsSession.Connect() );
       
    95 
       
    96     // Find the resource file:
       
    97     TParse parse;
       
    98     parse.Set( resourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
       
    99     TFileName fileName( parse.FullName() );
       
   100 
       
   101     // Get language of resource file:
       
   102     BaflUtils::NearestLanguageFile( fsSession, fileName );
       
   103 
       
   104     // Open resource file:
       
   105     iPlgResourceLoader.OpenL( fileName );
       
   106 
       
   107     // If leave occurs before this, close is called automatically when the
       
   108     // thread exits.
       
   109     fsSession.Close ( );
       
   110     }
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CAboutGsPlugin::NewL()
       
   115 //
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 CAboutGsPlugin* CAboutGsPlugin::NewL( TAny* /*aInitParams*/ )
       
   119   {
       
   120   	CAboutGsPlugin* self = new( ELeave ) CAboutGsPlugin();
       
   121   	CleanupStack::PushL( self );
       
   122   	self->ConstructL();
       
   123   	CleanupStack::Pop( self );
       
   124   	return self;
       
   125   }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // CGSParentPlugin::Id()
       
   129 //
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 TUid CAboutGsPlugin::Id() const
       
   133     {
       
   134     return KAboutGsPluginUid;
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CGSParentPlugin::DoActivateL()
       
   139 //
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CAboutGsPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
       
   143                                   TUid /*aCustomMessageId*/,
       
   144                                   const TDesC8& /*aCustomMessage*/ )
       
   145     {
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CGSParentPlugin::DoDeactivate()
       
   150 //
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 void CAboutGsPlugin::DoDeactivate()
       
   154     {
       
   155     }
       
   156 
       
   157 
       
   158 // ---------------------------------------------------------------------------
       
   159 // CAboutGsPlugin::GetCaptionL()
       
   160 //
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 void CAboutGsPlugin::GetCaptionL( TDes& aCaption ) const
       
   164 	{
       
   165 	HBufC* result = StringLoader::LoadL( R_ABOUT_GS_VIEW_CAPTION );
       
   166 	aCaption.Copy( *result );
       
   167 	delete result;
       
   168 	result = NULL;
       
   169     }
       
   170 
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // CAboutGsPlugin::PluginProviderCategory()
       
   174 //
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 TInt CAboutGsPlugin::PluginProviderCategory() const
       
   178     {
       
   179     return KGSPluginProviderInternal;
       
   180     }
       
   181 
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CAboutGsPlugin::CreateIconL
       
   185 // Return the icon, if has one.
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 CGulIcon* CAboutGsPlugin::CreateIconL( const TUid aIconType )
       
   189     {
       
   190     CGulIcon* icon;
       
   191 
       
   192     if( aIconType == KGSIconTypeLbxItem )
       
   193         {
       
   194         icon = AknsUtils::CreateGulIconL(
       
   195         AknsUtils::SkinInstance(),
       
   196         KAknsIIDQgnPropCpDevAbout,
       
   197         KGSAboutGsPluginIconFileName,
       
   198         EMbmAboutgspluginQgn_prop_cp_dev_about,
       
   199         EMbmAboutgspluginQgn_prop_cp_dev_about_mask );
       
   200         }
       
   201      else
       
   202         {
       
   203         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   204         }
       
   205 
       
   206     return icon;
       
   207     }
       
   208 
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CAboutGsPlugin::ItemType
       
   212 // ---------------------------------------------------------------------------
       
   213 //
       
   214 TGSListboxItemTypes CAboutGsPlugin::ItemType()
       
   215     {
       
   216     // See TGSListboxItemTypes for details.
       
   217     return EGSItemTypeSettingDialog;
       
   218     }
       
   219 
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // CAboutGsPlugin::HandleSelection
       
   223 // ---------------------------------------------------------------------------
       
   224 //
       
   225 void CAboutGsPlugin::HandleSelection( 
       
   226         const TGSSelectionTypes /*aSelectionType*/ )
       
   227     {
       
   228     // This used as a call-back from paren plugin to handle selection. Because
       
   229     // this plugin is of type EGSItemTypeSettingDialog, DoActivateL is never 
       
   230     // called on selection but only HandleSelection. See TGSListboxItemTypes
       
   231     // for details.
       
   232     TRAP_IGNORE( LaunchAboutAppL() );
       
   233     }
       
   234 
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // CAboutGsPlugin::LaunchAboutAppL
       
   238 // ---------------------------------------------------------------------------
       
   239 //
       
   240 void CAboutGsPlugin::LaunchAboutAppL()
       
   241     {
       
   242     TUid  aboutAppUid;
       
   243     aboutAppUid.iUid = ABOUTAPPUID;
       
   244     iNullService = CAknNullService::NewL( aboutAppUid, NULL );
       
   245     }
       
   246 
       
   247 
       
   248 //End of File