locationsystemui/locationsysui/locbtnotifier/src/locbtnotifierconstantsmanager.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     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:  Implementation of Manager class for the BtGpsPsy string constants
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // System Includes
       
    21 #include <e32std.h>
       
    22 #include <bautils.h>
       
    23 #include <barsc.h>
       
    24 #include <centralrepository.h>
       
    25 
       
    26 
       
    27 // User Includes
       
    28 #include "locbtnotifierconstantsmanager.h"
       
    29 #include "locbtnotifierprivatecrkeys.h"
       
    30 
       
    31 // Resource Definitions
       
    32 #include <locbtnotifierresources.rsg>
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // Resource File Name
       
    37 _LIT(KResourceFileName, "\\resource\\apps\\locbtnotifierresources.*");
       
    38 			
       
    39 
       
    40 
       
    41 // ======== MEMBER FUNCTIONS ========
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // CLocBtNotifierConstantsManager::NewL
       
    45 // Two Phased constructor 
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CLocBtNotifierConstantsManager* CLocBtNotifierConstantsManager::NewL()
       
    49     {
       
    50     CLocBtNotifierConstantsManager* self = new( ELeave ) CLocBtNotifierConstantsManager;
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();    
       
    53     CleanupStack::Pop( self );
       
    54     return self;
       
    55     }
       
    56 
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CLocBtNotifierConstantsManager::~CLocBtNotifierConstantsManager
       
    60 // Destructor
       
    61 // -----------------------------------------------------------------------------
       
    62 CLocBtNotifierConstantsManager::~CLocBtNotifierConstantsManager()
       
    63     {
       
    64     delete iBatteryLowDialogText;
       
    65 	delete iBatteryFullDialogText;
       
    66     delete iExtAntennaConnectedDialogText;
       
    67     delete iExtAntennaDisconnectedDialogText;
       
    68     delete iExtPowerConnectedDialogText;
       
    69     delete iExtPowerDisconnectedDialogText;
       
    70     }
       
    71     
       
    72 // -----------------------------------------------------------------------------
       
    73 // CLocBtNotifierConstantsManager::ConstructL
       
    74 // -----------------------------------------------------------------------------
       
    75 void CLocBtNotifierConstantsManager::ConstructL()
       
    76     {
       
    77     //File session for resource file
       
    78     RFs fileSession;
       
    79 
       
    80     //Open file session
       
    81     User::LeaveIfError( fileSession.Connect() );
       
    82     CleanupClosePushL( fileSession );
       
    83 
       
    84     TFileName* localisedRscName = GetLocalisableResourceNameL( fileSession );
       
    85     CleanupStack::PushL( localisedRscName );
       
    86 
       
    87 	//Construct RResourceFile
       
    88 	RResourceFile localisationResourceFile;
       
    89     localisationResourceFile.OpenL( fileSession, *localisedRscName );
       
    90     CleanupClosePushL( localisationResourceFile );
       
    91 
       
    92     //Check the signature
       
    93     localisationResourceFile.ConfirmSignatureL( 0 );
       
    94     
       
    95     //Read constants from resource file
       
    96     iBatteryLowDialogText = GetTextL( localisationResourceFile, R_BATTERY_LOW );
       
    97 		
       
    98     iBatteryFullDialogText = GetTextL( localisationResourceFile, R_BATTERY_FULL );
       
    99 		
       
   100     iExtAntennaConnectedDialogText = GetTextL( localisationResourceFile, 
       
   101                                               R_EXT_ANTENNA_CONNECTED );
       
   102 		
       
   103     iExtAntennaDisconnectedDialogText = GetTextL( localisationResourceFile, 
       
   104                                                  R_EXT_ANTENNA_DISCONNECTED );
       
   105 		
       
   106     iExtPowerConnectedDialogText = GetTextL( localisationResourceFile, 
       
   107                                             R_EXT_POWER_CONNECTED );
       
   108 		
       
   109     iExtPowerDisconnectedDialogText = GetTextL( localisationResourceFile,
       
   110                                                R_EXT_POWER_DISCONNECTED );
       
   111         
       
   112         
       
   113     CleanupStack::PopAndDestroy( 3,&fileSession );
       
   114     }
       
   115     
       
   116 // ---------------------------------------------------------------------------
       
   117 // CLocBtNotifierConstantsManager::CLocBtNotifierConstantsManager
       
   118 // Private Constructor
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121  CLocBtNotifierConstantsManager::CLocBtNotifierConstantsManager()
       
   122     {
       
   123     
       
   124     }
       
   125     
       
   126 // -----------------------------------------------------------------------------
       
   127 // CLocBtNotifierConstantsManager::GetLocalisableResourceNameL
       
   128 // -----------------------------------------------------------------------------
       
   129 TFileName* CLocBtNotifierConstantsManager::GetLocalisableResourceNameL( RFs& aFs )
       
   130     {
       
   131 	TFileName* fileName = new ( ELeave ) TFileName;
       
   132 	CleanupStack::PushL( fileName );
       
   133 	
       
   134 	TFindFile findFile( aFs );
       
   135 	CDir* dir;
       
   136 	User::LeaveIfError( findFile.FindWildByDir( KResourceFileName, KNullDesC(),dir ) );
       
   137 	CleanupStack::PushL( dir );
       
   138 	  
       
   139 	TParse fileNameParser;
       
   140 	fileNameParser.Set( findFile.File(), NULL, NULL );
       
   141 	
       
   142 	fileName->Copy( fileNameParser.DriveAndPath() );
       
   143 	fileName->Append( ( *dir )[0].iName );
       
   144 	CleanupStack::PopAndDestroy( dir );
       
   145 	
       
   146 	BaflUtils::NearestLanguageFile( aFs, *fileName );
       
   147 	
       
   148 	CleanupStack::Pop( fileName );
       
   149 	return fileName;
       
   150     }
       
   151     
       
   152 // -----------------------------------------------------------------------------
       
   153 // CLocBtNotifierConstantsManager::GetTextL
       
   154 // -----------------------------------------------------------------------------
       
   155 HBufC* CLocBtNotifierConstantsManager::GetTextL( RResourceFile& aResourceFile, 
       
   156                                                 TInt aId )
       
   157     {
       
   158     // Read from resource file
       
   159     HBufC8* buffer = aResourceFile.AllocReadLC( aId );
       
   160     HBufC* retBuf;
       
   161     
       
   162     //Resource parser
       
   163     TResourceReader resourceReader;
       
   164     resourceReader.SetBuffer( buffer );
       
   165     
       
   166     retBuf = resourceReader.ReadHBufCL();
       
   167     User::LeaveIfNull( retBuf );
       
   168     
       
   169     CleanupStack::PopAndDestroy( buffer );
       
   170     
       
   171     return retBuf;
       
   172     }
       
   173 
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CLocBtNotifierConstantsManager::GetBatteryLowDialogText
       
   177 // -----------------------------------------------------------------------------
       
   178 TPtr CLocBtNotifierConstantsManager::GetBatteryLowDialogText()
       
   179     {
       
   180 	return iBatteryLowDialogText->Des();
       
   181     }
       
   182     
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CLocBtNotifierConstantsManager::GetBatteryFullDialogText
       
   186 // -----------------------------------------------------------------------------
       
   187 TPtr CLocBtNotifierConstantsManager::GetBatteryFullDialogText()
       
   188     {
       
   189 	return iBatteryFullDialogText->Des();
       
   190     }
       
   191 
       
   192     
       
   193 // -----------------------------------------------------------------------------
       
   194 // CLocBtNotifierConstantsManager::GetExtAntennaConnectedDialogText
       
   195 // -----------------------------------------------------------------------------
       
   196 TPtr CLocBtNotifierConstantsManager::GetExtAntennaConnectedDialogText()
       
   197     {
       
   198 	return iExtAntennaConnectedDialogText->Des();
       
   199     }
       
   200     
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CLocBtNotifierConstantsManager::GetExtAntennaDisconnectedDialogText
       
   204 // -----------------------------------------------------------------------------
       
   205 TPtr CLocBtNotifierConstantsManager::GetExtAntennaDisconnectedDialogText()
       
   206     {
       
   207 	return iExtAntennaDisconnectedDialogText->Des();
       
   208     }
       
   209     
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CLocBtNotifierConstantsManager::GetExtPowerConnectedDialogText
       
   213 // -----------------------------------------------------------------------------
       
   214 TPtr CLocBtNotifierConstantsManager::GetExtPowerConnectedDialogText()
       
   215     {
       
   216 	return iExtPowerConnectedDialogText->Des();
       
   217     }
       
   218     
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CLocBtNotifierConstantsManager::GetExtPowerDisconnectedDialogText
       
   222 // -----------------------------------------------------------------------------
       
   223 TPtr CLocBtNotifierConstantsManager::GetExtPowerDisconnectedDialogText()
       
   224     {
       
   225 	return iExtPowerDisconnectedDialogText->Des();
       
   226     }
       
   227     
       
   228 
       
   229  
       
   230