textresolver.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name        : TextResolver.h
00004 *  Part of     : Common Services / Common Engine
00005 *  Interface   : SDK, Text Resolver API
00006 *  Description : Offers functionality for resolving corresponding error texts
00007 *                for error codes. 
00008 *  Version     : %version: ou1cfspd#17 %
00009 *
00010 *  Copyright © 2002-2006 Nokia. All rights reserved.
00011 *  This material, including documentation and any related 
00012 *  computer programs, is protected by copyright controlled by 
00013 *  Nokia. All rights are reserved. Copying, including 
00014 *  reproducing, storing, adapting or translating, any 
00015 *  or all of this material requires the prior written consent of 
00016 *  Nokia. This material also contains confidential 
00017 *  information which may not be disclosed to others without the 
00018 *  prior written consent of Nokia.
00019 * ============================================================================
00020 */
00021 
00022 
00023 #if !defined TEXT_RESOLVER_H
00024 #define TEXT_RESOLVER_H
00025 
00026 #include <coemain.h>    //  CCoeEnv
00027 #include <TextResolver.hrh> // Resource flags 
00028 
00029 // DEFINES
00030 typedef CArrayFixFlat<TInt> CErrorResourceIdArray;
00031 typedef CArrayFixFlat<TInt> CErrorResourceFlagArray;
00032 
00134 class CTextResolver : public CBase
00135     {
00136 
00137     public:
00138 
00145         enum TErrorContext
00146             {
00151             ECtxAutomatic = 0,
00155             ECtxNoCtx = 1,
00159             ECtxNoCtxNoSeparator = 2
00160             };
00161     public:
00171         IMPORT_C static CTextResolver* NewL(CCoeEnv& aEnv);
00172            
00182         IMPORT_C static CTextResolver* NewLC(CCoeEnv& aEnv);
00183         
00190         IMPORT_C static CTextResolver* NewL();
00191 
00199         IMPORT_C static CTextResolver* NewLC();
00200 
00201         
00205         IMPORT_C ~CTextResolver();
00206 
00226                 IMPORT_C const TDesC& ResolveErrorString(
00227              TInt aError,
00228              TInt& aTextId,
00229              TUint& aFlags,
00230              TErrorContext aContext = ECtxAutomatic);
00231 
00248             IMPORT_C const TDesC& ResolveErrorString(
00249              TInt aError,
00250              TErrorContext aContext = ECtxAutomatic);
00251 
00252         private:
00253         
00254         virtual TInt ResourceForError(TInt aError);
00255         virtual void LoadResourceFilesL();
00256 
00257         // Construction
00258         CTextResolver(CCoeEnv& aEnv);
00259         CTextResolver();
00260         void ConstructL();
00261 
00262         // Utility
00263         void FindFullPathOfResourceFile(TFileName& aResFile) const;
00264         void ReadResourcesToArraysL(TInt& aError, TInt& aTextId);
00265         void Reset();
00266         void PrepareReaderLC(TResourceReader& reader);
00267 
00268         // returns NULL if fails
00269         HBufC* ReadUnicodeString(const TInt& aTextId);
00270 
00271         // returns false if any memory allocation fails or initial values 
00272         // of necessary pointers are NULL, indicating alloc failure earlier.
00273         TBool AddContextAndSeparator(TErrorContext aContext);
00274 
00275     private:
00276         
00277         CCoeEnv*                            iCoe;
00278         RResourceFile                       iRFile;
00279         TInt                                iRDSupport;
00280         TInt                                iBaseResourceFileOffset;
00281         CArrayFix<TInt>*                    iStartError;
00282         CArrayFix<TInt>*                    iAppTexts;
00283         CArrayPtr<CErrorResourceIdArray>*   iErrorTexts;
00284         CArrayPtr<CErrorResourceFlagArray>* iFlags;
00285         HBufC*                              iTextBuffer;
00286         HBufC*                              iAppNameText;
00287         HBufC*                              iContextSeparator;
00288         RFs                                 iFs;
00289         TPtrC                               iTruncatedTextPointer;
00290     };
00291 
00292 #endif
00293 
00294 // End of File

Copyright © Nokia Corporation 2001-2008
Back to top