00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined TEXT_RESOLVER_H
00024 #define TEXT_RESOLVER_H
00025
00026 #include <coemain.h>
00027 #include <TextResolver.hrh>
00028
00029
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
00258 CTextResolver(CCoeEnv& aEnv);
00259 CTextResolver();
00260 void ConstructL();
00261
00262
00263 void FindFullPathOfResourceFile(TFileName& aResFile) const;
00264 void ReadResourcesToArraysL(TInt& aError, TInt& aTextId);
00265 void Reset();
00266 void PrepareReaderLC(TResourceReader& reader);
00267
00268
00269 HBufC* ReadUnicodeString(const TInt& aTextId);
00270
00271
00272
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