williamr@2: /* williamr@2: * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Cone Resource Loader API enables adding and removing williamr@2: * localized resource files into the CONE environment. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef CONERESLOADER_H williamr@2: #define CONERESLOADER_H williamr@2: williamr@2: // forward declarations williamr@2: class CCoeEnv; williamr@2: williamr@2: /** williamr@2: * Class encapsulates methods for opening and closing localised resource files williamr@2: * in the CONE environment. The actual reading of resources from an opened williamr@2: * resource file is done using various CCoeEnv provided resource-reading williamr@2: * methods. Cone Resource Loader API consist of the RConeResourceLoader class. williamr@2: * williamr@2: * Only one resource at a time may be open by one RConeResourceLoader instance. williamr@2: * You can use several RConeResourceLoader instances for accessing several williamr@2: * resources simultaneously or use one instance and close the previous resource williamr@2: * before opening a new one. williamr@2: * williamr@2: * The implementation uses BaflUtils::NearestLanguageFile to search for williamr@2: * a localised resource in proper search order. williamr@2: * williamr@2: * Usage example: williamr@2: * williamr@2: * @code williamr@2: * #include williamr@2: * williamr@2: * // Get CCoeEnv instance williamr@2: * CEikonEnv* eikEnv = CEikonEnv::Static(); williamr@2: * williamr@2: * // Initialize loader williamr@2: * RConeResourceLoader rLoader(eikEnv); williamr@2: * williamr@2: * // Open resource file williamr@2: * _LIT( KSampleResourceFileName, "Z:\\System\\Apps\\sample\\sample.rsc" ); williamr@2: * TFileName fileName(KSampleResourceFileName); williamr@2: * rLoader.OpenL(fileName); williamr@2: * williamr@2: * // Push resource loader to cleanup stack, so that it will always be properly williamr@2: * // closed when popped. williamr@2: * CleanupClosePushL(rLoader); williamr@2: * williamr@2: * // Read a resource williamr@2: * iSomeArray = eikEnv->ReadDesC16ArrayResourceL(R_SOME_RESOURCE); williamr@2: * williamr@2: * // Pop and destroy rLoader from stack. williamr@2: * // This also calls close on rLoader since CleanupClosePushL was used. williamr@2: * CleanupStack::PopAndDestroy(); // rLoader williamr@2: * williamr@2: * @endcode williamr@2: * williamr@2: * @lib commonengine.lib williamr@2: * @since S60 2.0 williamr@2: */ williamr@2: class RConeResourceLoader williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Constructor. williamr@2: * williamr@2: * @param aEnv is a reference to Control environment in which resource williamr@2: * is loaded. williamr@2: */ williamr@2: IMPORT_C RConeResourceLoader(CCoeEnv& aEnv); williamr@2: williamr@2: /** williamr@2: * Opens the resource file for reading. Only one resource may be open williamr@2: * at a time. Panics if this instance already has a file open. williamr@2: * The implementation uses BaflUtils::NearestLanguageFile to search williamr@2: * for a localized resource file in proper search order. williamr@2: * williamr@2: * @param aFileName is the resource file name to open. This parameter williamr@2: * value is changed to the best matching language file found. The drive williamr@2: * letter is required in the filename. williamr@2: * @return a Symbian OS error code. williamr@2: * williamr@2: * @panic KErrNotSupported The instance already has a file open. williamr@2: */ williamr@2: IMPORT_C TInt Open(TFileName& aFileName); williamr@2: williamr@2: /** williamr@2: * Opens the resource file for reading. Only one resource may be open williamr@2: * at a time. Leaves if this instance already has a file open. williamr@2: * The implementation uses BaflUtils::NearestLanguageFile to search williamr@2: * for a localized resource file in proper search order. williamr@2: * williamr@2: * @param aFileName Reference for resource file name. Please williamr@2: * note that drive letter is required ! williamr@2: * williamr@2: * @leave KErrNotSupported The instance already has a file open. williamr@2: */ williamr@2: IMPORT_C void OpenL(TFileName& aFileName); williamr@2: williamr@2: williamr@2: /** williamr@2: * Closes the opened resource file, if one is open. Does nothing if no williamr@2: * file has been opened. New resource file may be opened after the williamr@2: * previous has been closed. Always remember to close the resource when williamr@2: * finished using it. williamr@2: */ williamr@2: IMPORT_C void Close(); williamr@2: williamr@2: private: williamr@2: williamr@2: // Prohibit copy constructor and assigment operator because not deriving from CBase. williamr@2: RConeResourceLoader(const RConeResourceLoader&); williamr@2: RConeResourceLoader& operator= ( const RConeResourceLoader& ); williamr@2: williamr@2: // Needed for closing williamr@2: CCoeEnv& iEnv; williamr@2: TInt iResourceFileOffset; williamr@2: }; williamr@2: williamr@2: williamr@2: #endif williamr@2: williamr@2: // End of File