apengine/apsettingsplugin/src/APSettingsPlugin.cpp
changeset 0 5a93021fdf25
child 8 2e6c4614c58e
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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:  ApSettingsPlugin class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // User includes
       
    22 #include "APSettingsPlugin.h"
       
    23 #include "StringLoader.h"
       
    24 #include "utilities.h"
       
    25 
       
    26 #include <cmsettingsui.h>
       
    27 
       
    28 // System includes
       
    29 #include <eikon.hrh>
       
    30 #include <f32file.h>
       
    31 #include <ConeResLoader.h>
       
    32 #include <ApSettingsPluginRsc.rsg>
       
    33 #include <data_caging_path_literals.hrh>
       
    34 #include <apsettingsplugin.mbg>
       
    35 #include <SettingsInternalCRKeys.h>
       
    36 #include <centralrepository.h>
       
    37 
       
    38 
       
    39 const TInt KDefaultAPSettingsValue 	  = 1;	// AP settings UI supported
       
    40 
       
    41 // Resource file location
       
    42 _LIT( KApSettingsPluginRscFileName, "ApSettingsPluginRsc.rsc" );
       
    43 
       
    44 // This UID is used for both the view UID 
       
    45 // and the ECOM plugin implementation ID.
       
    46 const TUid KApSettingsPluginUid = { 0x1020736B };
       
    47 
       
    48 // ROM folder
       
    49 _LIT( KDriveZ, "z:" );
       
    50 
       
    51 // Name of the MBM file containing icons
       
    52 _LIT( KFileIcons, "apsettingsplugin.mbm");
       
    53 
       
    54 
       
    55 // ================= MEMBER FUNCTIONS =======================
       
    56 
       
    57 // ---------------------------------------------------------
       
    58 // CApSettingsPlugin::NewL
       
    59 // First phase constructor
       
    60 // ---------------------------------------------------------
       
    61 CApSettingsPlugin* CApSettingsPlugin::NewL( TAny* /*aInitParams*/ )
       
    62     {
       
    63     CApSettingsPlugin* self = new ( ELeave ) CApSettingsPlugin();
       
    64     CleanupStack::PushL( self );
       
    65     
       
    66     self->ConstructL();
       
    67                       
       
    68     CleanupStack::Pop( self );
       
    69     return self;     
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // CApSettingsPlugin::~CApSettingsPlugin
       
    74 // Destructor
       
    75 // ---------------------------------------------------------
       
    76 CApSettingsPlugin::~CApSettingsPlugin()
       
    77     {
       
    78     iResources.Close();
       
    79 #ifdef _DEBUG
       
    80     RDebug::Print( _L( "[CApSettingsPlugin] ~CApSettingsPlugin()" ) );
       
    81 #endif
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CApSettingsPlugin::Id
       
    86 // ---------------------------------------------------------
       
    87 TUid CApSettingsPlugin::Id() const
       
    88     {
       
    89     return KApSettingsPluginUid;
       
    90     }
       
    91  
       
    92 // ---------------------------------------------------------
       
    93 // CApSettingsPlugin::DoActivateL()
       
    94 // ---------------------------------------------------------      
       
    95 void CApSettingsPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/, 
       
    96                           TUid /*aCustomMessageId*/, 
       
    97                           const TDesC8& /*aCustomMessage*/ )
       
    98     {
       
    99     //no implementation required
       
   100     }
       
   101     
       
   102 // ---------------------------------------------------------
       
   103 // CApSettingsPlugin::DoDeactivate()
       
   104 // ---------------------------------------------------------
       
   105 void CApSettingsPlugin::DoDeactivate()
       
   106     {
       
   107     //no implementation required
       
   108     }
       
   109        
       
   110 // ---------------------------------------------------------
       
   111 // CApSettingsPlugin::GetCaption
       
   112 // ---------------------------------------------------------
       
   113 void CApSettingsPlugin::GetCaptionL( TDes& aCaption ) const
       
   114     {
       
   115     StringLoader::Load( aCaption, R_QTN_NETW_CONSET_NETWORK_CONNECTIONS  );
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------
       
   119 // CApSettingsPlugin::HasBitmap
       
   120 // ---------------------------------------------------------
       
   121 TBool CApSettingsPlugin::HasBitmap() const
       
   122     {
       
   123     return EFalse;
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CApSettingsPlugin::GetBitmapL
       
   128 // ---------------------------------------------------------
       
   129 void CApSettingsPlugin::GetBitmapL( CFbsBitmap* /*aBitmap*/, 
       
   130                                     CFbsBitmap* /*aMask*/ ) const
       
   131     {
       
   132     //no bitmap
       
   133     User::Leave( KErrNotFound );
       
   134     }
       
   135     
       
   136 // ---------------------------------------------------------
       
   137 // CApSettingsPlugin::PluginProviderCategory
       
   138 // ---------------------------------------------------------
       
   139 TInt CApSettingsPlugin::PluginProviderCategory() const
       
   140     {
       
   141     return EGSPluginProviderOEM;
       
   142     }
       
   143     
       
   144 // ---------------------------------------------------------
       
   145 // CApSettingsPlugin::HandleSelection
       
   146 // ---------------------------------------------------------   
       
   147 void CApSettingsPlugin::HandleSelection(
       
   148             const TGSSelectionTypes /*aSelectionType*/ )
       
   149     {
       
   150     TRAPD( error, DoSettingsL() );
       
   151     
       
   152     if( error && error != KLeaveWithoutAlert )
       
   153         {
       
   154         Utilities::ShowErrorNote(error);
       
   155         }    
       
   156     }
       
   157 
       
   158 // ---------------------------------------------------------
       
   159 // CApSettingsPlugin::ItemType
       
   160 // ---------------------------------------------------------
       
   161 TGSListboxItemTypes CApSettingsPlugin::ItemType()
       
   162     {
       
   163     return EGSItemTypeSettingDialog;
       
   164     }
       
   165     
       
   166 // ---------------------------------------------------------
       
   167 // CApSettingsPlugin::CreateIconL
       
   168 // ---------------------------------------------------------    
       
   169 CGulIcon* CApSettingsPlugin::CreateIconL( const TUid aIconType )
       
   170     {
       
   171     TFileName iconsFileName;
       
   172 
       
   173     iconsFileName.Append( KDriveZ );
       
   174     iconsFileName.Append( KDC_APP_BITMAP_DIR );
       
   175     iconsFileName.Append( KFileIcons );
       
   176     
       
   177 	CGulIcon* icon;
       
   178        
       
   179     if( aIconType == KGSIconTypeLbxItem )
       
   180         {
       
   181         icon = AknsUtils::CreateGulIconL(
       
   182         AknsUtils::SkinInstance(), 
       
   183         KAknsIIDQgnPropSetConnAccp, 
       
   184         iconsFileName,
       
   185         EMbmApsettingspluginQgn_prop_set_conn_accp,
       
   186         EMbmApsettingspluginQgn_prop_set_conn_accp_mask );
       
   187         }
       
   188      else
       
   189         {
       
   190         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   191         }
       
   192 	
       
   193 	return icon;
       
   194     }    
       
   195 
       
   196 // ---------------------------------------------------------
       
   197 // CApSettingsPlugin::Visible
       
   198 // -----------------------------------------------
       
   199 TBool CApSettingsPlugin::Visible() const
       
   200     {
       
   201   	if ( iApSettingsSupported == KDefaultAPSettingsValue )
       
   202   		{
       
   203   		return ETrue;
       
   204 		}
       
   205 	else
       
   206 		{
       
   207 		return EFalse;
       
   208 		}
       
   209     }
       
   210 
       
   211 // ---------------------------------------------------------
       
   212 // CApSettingsPlugin::CApSettingsPlugin
       
   213 // ---------------------------------------------------------
       
   214 CApSettingsPlugin::CApSettingsPlugin():
       
   215     iResources( *CCoeEnv::Static() )
       
   216     {
       
   217     // no implementation required
       
   218     }
       
   219 
       
   220 // ---------------------------------------------------------
       
   221 // CApSettingsPlugin::ConstructL
       
   222 // ---------------------------------------------------------
       
   223 TAny CApSettingsPlugin::ConstructL()
       
   224     {
       
   225     
       
   226 #ifdef _DEBUG    
       
   227     RDebug::Print( _L("[CApSettingsPlugin] ConstructL()" ) );
       
   228     RDebug::Print( _L( "[CApSettingsPlugin] Loading resource from :" ) );
       
   229     RDebug::Print( KApSettingsPluginRscFileName );
       
   230 #endif
       
   231     
       
   232     BaseConstructL();
       
   233         
       
   234     TFileName fileName;
       
   235     TDriveUnit drive( EDriveZ );
       
   236     
       
   237     fileName.Append( drive.Name() );
       
   238     fileName.Append( KDC_RESOURCE_FILES_DIR );
       
   239     fileName.Append( KApSettingsPluginRscFileName );
       
   240     
       
   241     iResources.OpenL( fileName );
       
   242     
       
   243   	iApSettingsSupported = KDefaultAPSettingsValue;
       
   244     }
       
   245     
       
   246 // ---------------------------------------------------------
       
   247 // CApSettingsPlugin::DoSettingsL
       
   248 // ---------------------------------------------------------
       
   249 void CApSettingsPlugin::DoSettingsL()
       
   250     {
       
   251     CCmSettingsUi* settings = CCmSettingsUi::NewL();
       
   252     CleanupStack::PushL( settings );
       
   253     
       
   254     if( settings->RunSettingsL() == CCmSettingsUi::EExit )
       
   255         {
       
   256         //exit from General Settings
       
   257         ProcessCommandL( EAknCmdExit );
       
   258         }
       
   259     
       
   260     CleanupStack::PopAndDestroy( settings );
       
   261     }
       
   262     
       
   263 
       
   264 //End of file