1.1 --- a/epoc32/include/coneresloader.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/coneresloader.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,134 @@
1.4 -coneresloader.h
1.5 +/*
1.6 +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* 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
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description: Cone Resource Loader API enables adding and removing
1.19 +* localized resource files into the CONE environment.
1.20 +*
1.21 +*/
1.22 +
1.23 +
1.24 +#ifndef CONERESLOADER_H
1.25 +#define CONERESLOADER_H
1.26 +
1.27 +// forward declarations
1.28 +class CCoeEnv;
1.29 +
1.30 +/**
1.31 +* Class encapsulates methods for opening and closing localised resource files
1.32 +* in the CONE environment. The actual reading of resources from an opened
1.33 +* resource file is done using various CCoeEnv provided resource-reading
1.34 +* methods. Cone Resource Loader API consist of the RConeResourceLoader class.
1.35 +*
1.36 +* Only one resource at a time may be open by one RConeResourceLoader instance.
1.37 +* You can use several RConeResourceLoader instances for accessing several
1.38 +* resources simultaneously or use one instance and close the previous resource
1.39 +* before opening a new one.
1.40 +*
1.41 +* The implementation uses BaflUtils::NearestLanguageFile to search for
1.42 +* a localised resource in proper search order.
1.43 +*
1.44 +* Usage example:
1.45 +*
1.46 +* @code
1.47 +* #include <ConeResLoader.h>
1.48 +*
1.49 +* // Get CCoeEnv instance
1.50 +* CEikonEnv* eikEnv = CEikonEnv::Static();
1.51 +*
1.52 +* // Initialize loader
1.53 +* RConeResourceLoader rLoader(eikEnv);
1.54 +*
1.55 +* // Open resource file
1.56 +* _LIT( KSampleResourceFileName, "Z:\\System\\Apps\\sample\\sample.rsc" );
1.57 +* TFileName fileName(KSampleResourceFileName);
1.58 +* rLoader.OpenL(fileName);
1.59 +*
1.60 +* // Push resource loader to cleanup stack, so that it will always be properly
1.61 +* // closed when popped.
1.62 +* CleanupClosePushL(rLoader);
1.63 +*
1.64 +* // Read a resource
1.65 +* iSomeArray = eikEnv->ReadDesC16ArrayResourceL(R_SOME_RESOURCE);
1.66 +*
1.67 +* // Pop and destroy rLoader from stack.
1.68 +* // This also calls close on rLoader since CleanupClosePushL was used.
1.69 +* CleanupStack::PopAndDestroy(); // rLoader
1.70 +*
1.71 +* @endcode
1.72 +*
1.73 +* @lib commonengine.lib
1.74 +* @since S60 2.0
1.75 +*/
1.76 +class RConeResourceLoader
1.77 + {
1.78 + public:
1.79 + /**
1.80 + * Constructor.
1.81 + *
1.82 + * @param aEnv is a reference to Control environment in which resource
1.83 + * is loaded.
1.84 + */
1.85 + IMPORT_C RConeResourceLoader(CCoeEnv& aEnv);
1.86 +
1.87 + /**
1.88 + * Opens the resource file for reading. Only one resource may be open
1.89 + * at a time. Panics if this instance already has a file open.
1.90 + * The implementation uses BaflUtils::NearestLanguageFile to search
1.91 + * for a localized resource file in proper search order.
1.92 + *
1.93 + * @param aFileName is the resource file name to open. This parameter
1.94 + * value is changed to the best matching language file found. The drive
1.95 + * letter is required in the filename.
1.96 + * @return a Symbian OS error code.
1.97 + *
1.98 + * @panic KErrNotSupported The instance already has a file open.
1.99 + */
1.100 + IMPORT_C TInt Open(TFileName& aFileName);
1.101 +
1.102 + /**
1.103 + * Opens the resource file for reading. Only one resource may be open
1.104 + * at a time. Leaves if this instance already has a file open.
1.105 + * The implementation uses BaflUtils::NearestLanguageFile to search
1.106 + * for a localized resource file in proper search order.
1.107 + *
1.108 + * @param aFileName Reference for resource file name. Please
1.109 + * note that drive letter is required !
1.110 + *
1.111 + * @leave KErrNotSupported The instance already has a file open.
1.112 + */
1.113 + IMPORT_C void OpenL(TFileName& aFileName);
1.114 +
1.115 +
1.116 + /**
1.117 + * Closes the opened resource file, if one is open. Does nothing if no
1.118 + * file has been opened. New resource file may be opened after the
1.119 + * previous has been closed. Always remember to close the resource when
1.120 + * finished using it.
1.121 + */
1.122 + IMPORT_C void Close();
1.123 +
1.124 + private:
1.125 +
1.126 + // Prohibit copy constructor and assigment operator because not deriving from CBase.
1.127 + RConeResourceLoader(const RConeResourceLoader&);
1.128 + RConeResourceLoader& operator= ( const RConeResourceLoader& );
1.129 +
1.130 + // Needed for closing
1.131 + CCoeEnv& iEnv;
1.132 + TInt iResourceFileOffset;
1.133 + };
1.134 +
1.135 +
1.136 +#endif
1.137 +
1.138 +// End of File