os/kernelhwsrv/kernel/eka/drivers/hcr/hcr_pil.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Hardware Configuration Respoitory Platform Independent Layer (PIL)
sl@0
    15
// Contains internal definitions for the PIL software of the HCR component
sl@0
    16
// which includes the singleton class that contains the algorithms and the
sl@0
    17
// TRepository hierachy that encapsulated the repository data in all its forms
sl@0
    18
// hiding the specifics from the algoritms in the singleton HCRInternal object.
sl@0
    19
//
sl@0
    20
sl@0
    21
/**
sl@0
    22
@file hcr_pil.h
sl@0
    23
Kernel side definitions for the HCR Platform Independent Layer. 
sl@0
    24
sl@0
    25
@internalTechnology
sl@0
    26
*/
sl@0
    27
sl@0
    28
#ifndef HCR_PIL_H
sl@0
    29
#define HCR_PIL_H
sl@0
    30
sl@0
    31
sl@0
    32
// -- INCLUDES ----------------------------------------------------------------
sl@0
    33
sl@0
    34
sl@0
    35
#include <e32def.h>
sl@0
    36
#include <e32err.h> 
sl@0
    37
sl@0
    38
#include "hcr_hai.h"
sl@0
    39
sl@0
    40
sl@0
    41
// -- CLASSES -----------------------------------------------------------------
sl@0
    42
sl@0
    43
namespace HCR
sl@0
    44
{
sl@0
    45
sl@0
    46
    class TRepository;
sl@0
    47
sl@0
    48
sl@0
    49
    /**< Mask for testing for word size settings */
sl@0
    50
    static const TInt KMaskWordTypes = 0x0000FFFF;      
sl@0
    51
sl@0
    52
    /**< Mask for testing for large settings */  
sl@0
    53
    static const TInt KMaskLargeTypes = 0xFFFF0000;
sl@0
    54
sl@0
    55
    
sl@0
    56
	/**
sl@0
    57
	 *  Class implements the reference to the setting, it consists of two
sl@0
    58
	 * pointers to the repository where the setting is set and to the setting
sl@0
    59
	 * data itself.   
sl@0
    60
	 */
sl@0
    61
	class TSettingRef
sl@0
    62
		{
sl@0
    63
	public:
sl@0
    64
sl@0
    65
	    /**
sl@0
    66
	     *  Default C++ constructor. It initiates the reference class 
sl@0
    67
	     * object with the reference structure data.
sl@0
    68
	     * @param aSetRef          Reference Setting data 
sl@0
    69
	     */
sl@0
    70
	    TSettingRef()
sl@0
    71
	        {iRep = NULL; iSet = NULL;}
sl@0
    72
	    
sl@0
    73
	    /**
sl@0
    74
	     *  C++ constructor. It initiates the the reference class object 
sl@0
    75
	     * @param  aRepos          Pointer to the settings repository
sl@0
    76
	     * @param  aSetting        Pointer to the setting
sl@0
    77
	     */
sl@0
    78
	    TSettingRef(TRepository* aRepos, SSettingBase* aSetting)
sl@0
    79
			{ iRep = aRepos; iSet = aSetting; }
sl@0
    80
	    
sl@0
    81
	   
sl@0
    82
	        
sl@0
    83
	    /**
sl@0
    84
	     *   C++ destructor.
sl@0
    85
	     */
sl@0
    86
        ~TSettingRef()
sl@0
    87
        	{ }
sl@0
    88
        
sl@0
    89
	public:
sl@0
    90
	    /**< Pointer to the repository*/
sl@0
    91
	    TRepository*  iRep;
sl@0
    92
	    /**< Pointer to the setting*/
sl@0
    93
	    SSettingBase* iSet;
sl@0
    94
		};
sl@0
    95
	
sl@0
    96
sl@0
    97
	//Disable WINS (old Visual C++) warning
sl@0
    98
	#pragma warning(disable:4284)
sl@0
    99
	/**
sl@0
   100
	 * Internal HCR, SafeArray (TSa) class. 
sl@0
   101
	 * Safe Array implementation is based on a smart pointer
sl@0
   102
	 * pattern which wraps the pointer by the template class and give it a new
sl@0
   103
	 * flavour. In this case it guarantees that the heap allocated array 
sl@0
   104
	 * associated with the class instance variable pointer will be deallocated 
sl@0
   105
	 * during stack unwinding.
sl@0
   106
	 * IMPORTANT! 
sl@0
   107
	 * Please don't instantiate this class on the heap as this will break the 
sl@0
   108
	 * functionality of this class. Operator [] does not check the boundary of
sl@0
   109
	 * the array, consider safe array implementation as a simple replacement of
sl@0
   110
	 * standard pointer with all its drawbacks.
sl@0
   111
	 */
sl@0
   112
sl@0
   113
	template <typename T>
sl@0
   114
	    class TSa
sl@0
   115
	        {
sl@0
   116
	        public:
sl@0
   117
	            /** 
sl@0
   118
	             *  Default constructor.
sl@0
   119
	             * During initialization it sets the member variable pointer iSa
sl@0
   120
	             * to NULL. 
sl@0
   121
	             */
sl@0
   122
	            inline TSa() :iSa(NULL){}
sl@0
   123
	            
sl@0
   124
	           
sl@0
   125
	            /**
sl@0
   126
	             *  operator()() returns an address to the array  
sl@0
   127
	             * maintained by this SafeArray object.
sl@0
   128
	             * It can be usefull when it's necessary to get the pointer  
sl@0
   129
	             * value, for instance passing as function parameter.
sl@0
   130
	             * @return         Pointer to the first element of the 
sl@0
   131
	             *                 maintained array of elements of type T. 
sl@0
   132
	             *  
sl@0
   133
	             */
sl@0
   134
	            inline T* operator ()(){return iSa;}
sl@0
   135
	         
sl@0
   136
	            /**
sl@0
   137
	             * operator=() changes the memory ownership by   
sl@0
   138
	             * reinitiazing SafeArray class object with the address to   
sl@0
   139
	             * already allocated array. The original heap allocation  
sl@0
   140
	             * associated with this SafeArray object is deallocated before
sl@0
   141
	             * reassignment. It's implemented in hcr_pil.cpp.
sl@0
   142
	             * @param  aP      Pointer to the already allocated array of
sl@0
   143
	             *                 elements of the type T.
sl@0
   144
	             * @return         Reference to (*this) object.
sl@0
   145
	             */
sl@0
   146
	             TSa<T>& operator=(T* aP);
sl@0
   147
	                
sl@0
   148
	            
sl@0
   149
	            /**
sl@0
   150
	             * operator[]() returns the reference to the element of 
sl@0
   151
	             * array maintained by this SafeArray object at position defined
sl@0
   152
	             * by aIndex function parameter. 
sl@0
   153
	             * @param  aIndex      Position of the element within SafeArray
sl@0
   154
	             * @return             Reference to the element from the array
sl@0
   155
	             */
sl@0
   156
	            inline T& operator[](TInt aIndex){return *(iSa + aIndex);}
sl@0
   157
	            
sl@0
   158
	           	             
sl@0
   159
	            /**
sl@0
   160
	             *  Destructor
sl@0
   161
	             */
sl@0
   162
	            ~TSa();
sl@0
   163
	                
sl@0
   164
	                        
sl@0
   165
	        private:
sl@0
   166
	            /**
sl@0
   167
	             *  Copy constructor must not be called explicitly by the
sl@0
   168
	             * code
sl@0
   169
	             */
sl@0
   170
	            inline TSa(TSa& aSa);
sl@0
   171
	            
sl@0
   172
	        protected:
sl@0
   173
	            /**< Pointer to the allocated heap array*/
sl@0
   174
	            T*     iSa;
sl@0
   175
	        };
sl@0
   176
#pragma warning(default:4284)
sl@0
   177
	 
sl@0
   178
	                
sl@0
   179
    /**
sl@0
   180
     *  Internal HCR class, object of this class is created by the kernel 
sl@0
   181
     * when the kernel extensions are loaded and initialized.
sl@0
   182
     */
sl@0
   183
    class HCRInternal
sl@0
   184
        {
sl@0
   185
    public:       
sl@0
   186
sl@0
   187
        /**
sl@0
   188
         * Internal HCR states
sl@0
   189
         */
sl@0
   190
        enum States 
sl@0
   191
            {
sl@0
   192
            EStatUndef              = 0x00000000,
sl@0
   193
            EStatNotReady           = 0x00010000,
sl@0
   194
            EStatConstructed        = EStatNotReady + 0x0001,
sl@0
   195
            EStatVariantInitialised = EStatNotReady + 0x0002,
sl@0
   196
            EStatInitialised        = EStatNotReady + 0x0004,
sl@0
   197
sl@0
   198
            EStatReady              = 0x00020000,
sl@0
   199
sl@0
   200
            EStatFailed             = 0x00800000,
sl@0
   201
sl@0
   202
            EStatMajornMask         = 0xFFFF0000,
sl@0
   203
            EStatMinorMask          = 0x0000FFFF
sl@0
   204
            };
sl@0
   205
sl@0
   206
        // For Test
sl@0
   207
        enum TReposId
sl@0
   208
            {
sl@0
   209
            ECoreRepos = 1,
sl@0
   210
            EOverrideRepos
sl@0
   211
            };
sl@0
   212
sl@0
   213
    public:
sl@0
   214
        /**
sl@0
   215
         *  Default C++ constructor.
sl@0
   216
         */
sl@0
   217
        HCRInternal();
sl@0
   218
        
sl@0
   219
        /**
sl@0
   220
         *  C++ constructor with passing MVariant object for further  
sl@0
   221
         * instance variable initialization.
sl@0
   222
         */
sl@0
   223
		HCRInternal(HCR::MVariant* aVar);
sl@0
   224
		
sl@0
   225
		/**
sl@0
   226
		 *  C++ destructor.
sl@0
   227
		 */
sl@0
   228
        ~HCRInternal();
sl@0
   229
     
sl@0
   230
        /**
sl@0
   231
         *  The method initializes  internal instance variable pointers
sl@0
   232
         * to the addresses of repositories by getting them via call to Variant 
sl@0
   233
         * object functional API.
sl@0
   234
         * @return          
sl@0
   235
         *  - KErrNone        No errors reported
sl@0
   236
         *  - KErrGeneral     Internal HCR fault
sl@0
   237
         *  - KErrArgument    Programming error in PSL, ptr/rc 
sl@0
   238
         *                    mismatch
sl@0
   239
         *  - KErrNoMemory    Memory allocation failure
sl@0
   240
         */
sl@0
   241
        TInt Initialise();
sl@0
   242
sl@0
   243
        /**
sl@0
   244
         *  Based on the input parameter aId it switches the selected repository 
sl@0
   245
         * to the given name. It is searching the new repository file in 
sl@0
   246
         * \sys\bin and \sys\Data respectively. It keeps the original value of 
sl@0
   247
         * the repository if the file not found.
sl@0
   248
         * @param aFileName     The zero terminated, c-style ASCII string of the 
sl@0
   249
         *                      new repository file without path. If the name is
sl@0
   250
         *                      an empty string (NULL) the it deletes the 
sl@0
   251
         *                      repository object
sl@0
   252
         * @param aId         The internal repository identifier (see TReposId)
sl@0
   253
         * @return 
sl@0
   254
         *  - KErrNone          if successful, the selected internal repository  
sl@0
   255
         *                      variables point to the new HCR or the referenced 
sl@0
   256
         *                      repository object deleted.
sl@0
   257
         *  - KErrNotFound      if the new repository file not found.
sl@0
   258
         *  - KErrNotSupported  if repository identifier not supported
sl@0
   259
         */      
sl@0
   260
        TInt SwitchRepository(const TText * aFileName, const TReposId aId=ECoreRepos);
sl@0
   261
sl@0
   262
        
sl@0
   263
        /**
sl@0
   264
         *  Internal HCR method checks all repositories integrity.
sl@0
   265
         * @return
sl@0
   266
         *  - KErrNone          Successful, no errors reported
sl@0
   267
         *  - KErrAlreadyExist  Check for the setting duplicates fails
sl@0
   268
         *  - KErrCorrupt       One of the repositories was found to be corrupt 
sl@0
   269
         *                      e.g. repository header incorrect, settings not 
sl@0
   270
         *                      ordered etc
sl@0
   271
         */
sl@0
   272
        TInt CheckIntegrity();
sl@0
   273
sl@0
   274
        /**
sl@0
   275
         * Internal HCR method returns a current HCR state.
sl@0
   276
         * @return Current HCR composite status flag data member, @see States 
sl@0
   277
         *         for more details
sl@0
   278
         */
sl@0
   279
        TUint32 GetStatus();
sl@0
   280
        
sl@0
   281
        /**
sl@0
   282
         *  The method searches the given setting defined by aId parameter
sl@0
   283
         * and with the type defined by aType parameter. Reference setting data
sl@0
   284
         * is returned in aSetting output parameter. The search procedure is 
sl@0
   285
         * performed through all enabled repositories. It starts looking in 
sl@0
   286
         * Override first, then if setting is not found it goes to CoreImg and
sl@0
   287
         * in the end in Variant repository.
sl@0
   288
         * @param   aId         in: setting to find
sl@0
   289
         * @param   aType       in: required type
sl@0
   290
         * @param   aSetting    out: found setting reference data
sl@0
   291
         * @return              The following errors are returned:
sl@0
   292
         *     - KErrNone         It successfuly ends, no errors are reported
sl@0
   293
         *     - KErrNotFound     The setting was not found
sl@0
   294
         *     - KErrArgument     The found setting type does not match the aType
sl@0
   295
         */
sl@0
   296
        TInt FindSetting(const TSettingId& aId, TSettingType aType,
sl@0
   297
                                                        TSettingRef& aSetting);
sl@0
   298
        
sl@0
   299
        /**
sl@0
   300
         *  Internal HCR helper method finds setting and its type.
sl@0
   301
         * @param   aId         in:  setting id to find
sl@0
   302
         * @param   aType       out: found setting type. If the setting is  
sl@0
   303
         *                      not found, the returned value is set to 
sl@0
   304
         *                      ETypeUndefined
sl@0
   305
         * @param   aSetting    out: found setting data
sl@0
   306
         * @return               The following errors can be returned:
sl@0
   307
         *     - KErrNone       It successfuly ends, no errors are reported
sl@0
   308
         *     - KErrNotFound   The setting was not found
sl@0
   309
         */
sl@0
   310
        TInt FindSettingWithType(const TSettingId& aId, TSettingType& aType,
sl@0
   311
                                 TSettingRef& aSetting);
sl@0
   312
sl@0
   313
       
sl@0
   314
        /**
sl@0
   315
         *  Internal helper method search all the word settings provided
sl@0
   316
         * in aIds[] settings array. The search procedure starts from Override
sl@0
   317
         * store, if the setting is not found there, it goes through the CoreImg
sl@0
   318
         * and finaly ends up in the Variant data.
sl@0
   319
         * @param   aNum        in: number of settings to find
sl@0
   320
         * @param   aIds        in: array of settings to find
sl@0
   321
         * @param   aValues     out: all found settings values are written  
sl@0
   322
         *                      back to this array. If the setting is not found
sl@0
   323
         *                      the returned setting value is set to 0
sl@0
   324
         * @param   aTypes      out: If this array is provided by upper user,
sl@0
   325
         *                      the setting types are written back to this array.
sl@0
   326
         *                      If the element is not found, its type is set to
sl@0
   327
         *                      ETypeUndefined. 
sl@0
   328
         * @param   aErrors     out: user must always provide this array, 
sl@0
   329
         *                      where the method will report the search result 
sl@0
   330
         *                      for each individual setting. There are three 
sl@0
   331
         *                      possible values:
sl@0
   332
         *                      - KErrNone  Setting is found, no errors reported
sl@0
   333
         *                      - KErrNotFound Setting is not found
sl@0
   334
         *                      - KErrErrArgument Found setting has larger than
sl@0
   335
         *                        four bytes size
sl@0
   336
         * @return  The following errors can be returned:
sl@0
   337
         *  - Zero or positive number of settings found in category, -ve on error
sl@0
   338
         *  - KErrArgument if some parameters are wrong(i.e. aErrors is a null
sl@0
   339
         *                   pointer, aNum is negative and so on) 
sl@0
   340
         *  - KErrNotReady if the HCR is used before it has been initialised
sl@0
   341
         *  - KErrCorrupt  if HCR finds a repository to be corrupt
sl@0
   342
         *  - KErrGeneral  if an internal failure occurs, see trace
sl@0
   343
         *  
sl@0
   344
         * @pre Caller must invoke this function inside the thread critical 
sl@0
   345
         *      section to let the method finish its job. It avoids memory leak 
sl@0
   346
         *      in case of possible client thread termination. 
sl@0
   347
         */
sl@0
   348
        TInt GetWordSettings(TInt aNum, const SSettingId aIds[], TInt32 aValues[],
sl@0
   349
                                TSettingType aTypes[], TInt aErrors[]);
sl@0
   350
        
sl@0
   351
        /**
sl@0
   352
         *  Internal HCR method returns the number of settings in the specified
sl@0
   353
         * category.
sl@0
   354
         * @param aCatUid   in: The setting identifier category to use in the 
sl@0
   355
         *                      search
sl@0
   356
         * @return 
sl@0
   357
         *  - Zero or positive number of settings found in category, -ve on error
sl@0
   358
         *  - KErrNotReady if the HCR is used before it has been initialised
sl@0
   359
         *  - KErrCorrupt if HCR finds a repository to be corrupt
sl@0
   360
         *  - KErrGeneral if an internal failure occurs, see trace
sl@0
   361
         */
sl@0
   362
        TInt FindNumSettingsInCategory (TCategoryUid aCatUid);
sl@0
   363
        
sl@0
   364
        
sl@0
   365
        /**
sl@0
   366
         * Internal HCR method searches all elements within the specified 
sl@0
   367
         * category aCatUid.
sl@0
   368
         * @param aCatUid   in: The setting identifier category to use in the search
sl@0
   369
         * @param aMaxNum   in: The maximum number of settings to return. It is also 
sl@0
   370
         *                  the size of the arrays in the following arguments 
sl@0
   371
         * @param aElIds    out: Client supplied array populated on exit. Large
sl@0
   372
         *                  enough to hold all elements in category.
sl@0
   373
         * @param aTypes    out: Client supplied array populated with setting types 
sl@0
   374
         *                  enumerations on exit. May be 0 if client is 
sl@0
   375
         *                  not interested.
sl@0
   376
         * @param aLens     out: Client supplied array populated with setting lengths
sl@0
   377
         *                  on exit. May be 0 if client is not interested.
sl@0
   378
         *
sl@0
   379
         * @return Zero or positive number of settings found in category, -ve on error
sl@0
   380
         *  - KErrArgument if some parameters are wrong(i.e. aErrors is a null
sl@0
   381
         *                   pointer, aNum is negative and so on)
sl@0
   382
         *  - KErrNotReady if the HCR is used before it has been initialised
sl@0
   383
         *  - KErrCorrupt  if HCR finds a repository to be corrupt
sl@0
   384
         *  - KErrGeneral  if an internal failure occurs, see trace
sl@0
   385
         */
sl@0
   386
        TInt FindSettings(TCategoryUid aCatUid, 
sl@0
   387
                TInt aMaxNum,  TElementId aIds[],  
sl@0
   388
                TSettingType aTypes[], TUint16 aLens[]);
sl@0
   389
sl@0
   390
sl@0
   391
        /**
sl@0
   392
         *  Internal HCR method finds all the settings within the specified 
sl@0
   393
         * category and which matches aMask and aPattern.
sl@0
   394
         * @param aCat      in: The category to retrieve settings for
sl@0
   395
         * @param aMaxNum   in: The maximum number of settings to retrieve. It  
sl@0
   396
         *                  is also the size of the arrays in the following 
sl@0
   397
         *                  arguments   
sl@0
   398
         * @param aElemMask in: The bits in the Element ID to be checked against 
sl@0
   399
         *                  aPattern
sl@0
   400
         * @param aPattern  in: Identified the bits that must be set for a 
sl@0
   401
         *                  setting to be returned in the search
sl@0
   402
         * @param aIds      out: Client supplied array populated on exit. Large
sl@0
   403
         *                  enough to hold aMaxNum element ids.
sl@0
   404
         * @param aTypes    out: Client supplied array populated with setting types 
sl@0
   405
         *                  enumerations on exit. May be 0 if client is 
sl@0
   406
         *                  not interested.
sl@0
   407
         * @param aLen      out: Client supplied array populated with setting 
sl@0
   408
         *                  lengths on exit. May be 0 if client is not interested.
sl@0
   409
         * @return 
sl@0
   410
         *  - Zero or positive number of settings found in category, -ve on error
sl@0
   411
         *  - KErrArgument if some parameters are wrong(i.e. aErrors is a null
sl@0
   412
         *                   pointer, aNum is negative and so on) 
sl@0
   413
         *  - KErrNotReady if the HCR is used before it has been initialised
sl@0
   414
         *  - KErrCorrupt  if HCR finds a repository to be corrupt
sl@0
   415
         *  - KErrGeneral  if an internal failure occurs, see trace
sl@0
   416
         */
sl@0
   417
        TInt FindSettings(TCategoryUid aCat, TInt aMaxNum, 
sl@0
   418
                TUint32 aMask, TUint32 aPattern,  
sl@0
   419
                TElementId aIds[], TSettingType aTypes[], TUint16 aLens[]);
sl@0
   420
 
sl@0
   421
    private:    
sl@0
   422
    	/** Member holding the status of the HCR service */
sl@0
   423
        TUint32 iStatus;
sl@0
   424
    
sl@0
   425
        /** Handle on the variant code in the PSL component part */    
sl@0
   426
        HCR::MVariant* iVariant;    
sl@0
   427
        
sl@0
   428
        /** Compiled settings in the PSL code */
sl@0
   429
        TRepository* iVariantStore;
sl@0
   430
        
sl@0
   431
        /** File settings in the core ROM image */
sl@0
   432
        TRepository* iCoreImgStore;
sl@0
   433
        
sl@0
   434
        /** File settings shadowed in RAM from NAND */
sl@0
   435
        TRepository* iOverrideStore;
sl@0
   436
        
sl@0
   437
        friend class HCRInternalTestObserver;
sl@0
   438
sl@0
   439
        };
sl@0
   440
    
sl@0
   441
    
sl@0
   442
    /**
sl@0
   443
     *  Base Repository class. This class defines API needed to be 
sl@0
   444
     * implemented in the derived classes.
sl@0
   445
     */
sl@0
   446
    class TRepository
sl@0
   447
        {
sl@0
   448
    public: 
sl@0
   449
    	// Repository methods		
sl@0
   450
		virtual ~TRepository();
sl@0
   451
        virtual TInt CheckIntegrity ()=0;
sl@0
   452
        virtual TInt FindSetting (const TSettingId& aId, TSettingRef& aSetting)=0;
sl@0
   453
        
sl@0
   454
        /**
sl@0
   455
         *  Pure virtual function, must implement the search procedure for the
sl@0
   456
         * setting in the repository within the bounds defined by aLow and aHigh
sl@0
   457
         * parameters. It returns found setting reference data and its position.
sl@0
   458
         * @param   aId         in:  Setting to find
sl@0
   459
         * @param   aSetting    out: Found setting reference data
sl@0
   460
         * @param   aPosition   out: Position the found setting in the repository
sl@0
   461
         * @param   aLow        in:  Low index where to start search
sl@0
   462
         * @param   aHigh       in:  High index where to end search
sl@0
   463
         * @return
sl@0
   464
         *  - KErrNone          Successful, no errors were reported 
sl@0
   465
         *  - KErrNotFound      Either the repository does not have any settings,
sl@0
   466
         *                      and its length is zero or the setting was not
sl@0
   467
         *                      found, all output parameters are set to zeros in
sl@0
   468
         *                      this case. 
sl@0
   469
         */
sl@0
   470
        virtual TInt FindSetting (const TSettingId& aId, TSettingRef& aSetting,
sl@0
   471
                TInt32& aPosition, TInt32 aLow, TInt32 aHigh) = 0;
sl@0
   472
        
sl@0
   473
        /**
sl@0
   474
         *  Pure virtual function, must implement the word setting search 
sl@0
   475
         * procedure.
sl@0
   476
         * @param   aNum        in: Number of settings to be found
sl@0
   477
         * @param   aIds        in: An array of setting ids pointers to be found
sl@0
   478
         * @param   aValues     out: An array of pointers to the values 
sl@0
   479
         *                      populated during search procedure.
sl@0
   480
         * @param   aTypes      out: An array of pointers to the types populated
sl@0
   481
         *                      during search procedure.
sl@0
   482
         * @param   aErrors     out: An array of pointers to the errors populated
sl@0
   483
         *                      during search procedure. This can be the following
sl@0
   484
         *                      errors:
sl@0
   485
         *                          - KErrNone      Successfuly done, no errors 
sl@0
   486
         *                            reported
sl@0
   487
         *                          - KErrNotFound  The setting was not found
sl@0
   488
         *                          - KErrArgument  The found setting type is large
sl@0
   489
         *                            than 4 bytes.
sl@0
   490
         * @return
sl@0
   491
         *  - KErrNone      Successfuly done, no errors reported
sl@0
   492
         *  - KErrNotReady  Repository is not ready
sl@0
   493
         *  - system wider error
sl@0
   494
         */
sl@0
   495
        virtual TInt GetWordSettings(TInt aNum, SSettingId* aIds[], 
sl@0
   496
                       TInt32* aValues[], TSettingType* aTypes[], 
sl@0
   497
                       TInt* aErrors[])=0;
sl@0
   498
sl@0
   499
        /**
sl@0
   500
         * Pure virtual function, must return a reference to TSettingRef
sl@0
   501
         * structure at specified position within the repository.
sl@0
   502
         * @param   aIndex      in: Setting position(index) in the repository
sl@0
   503
         * @param   aRef        out: Reference data storage
sl@0
   504
         */
sl@0
   505
        virtual void GetSettingRef(TInt32 aIndex, TSettingRef& aRef) = 0;
sl@0
   506
        
sl@0
   507
        /**
sl@0
   508
         *  Pure virtual function, must implement the search all elements within 
sl@0
   509
         * the defined category.
sl@0
   510
         * @param   aCatUid     in: Category id where to search the elements
sl@0
   511
         * @param   aFirst      out: Repository index where the first element is
sl@0
   512
         *                           situated
sl@0
   513
         * @param   aLast       out: Repository index where the last element is
sl@0
   514
         *                           situated
sl@0
   515
         * @return
sl@0
   516
         *  - KErrNone      Successfuly done, no errors were reported
sl@0
   517
         *  - KErrNotFound  No any elements were found in this category or repo-
sl@0
   518
         *                  sitory is empty
sl@0
   519
         */
sl@0
   520
        virtual TInt FindNumSettingsInCategory(TCategoryUid aCatUid, 
sl@0
   521
                TInt32& aFirst, TInt32& aLast) = 0;
sl@0
   522
        
sl@0
   523
       
sl@0
   524
        // Setting accessor methods
sl@0
   525
        virtual TBool IsWordValue(const TSettingRef& aRef);
sl@0
   526
        virtual TBool IsLargeValue(const TSettingRef& aRef);
sl@0
   527
        virtual void GetId(const TSettingRef& aRef, SSettingId& aId);
sl@0
   528
        virtual TInt32 GetType(const TSettingRef& aRef);
sl@0
   529
        virtual TUint16 GetLength(const TSettingRef& aRef);
sl@0
   530
        
sl@0
   531
        virtual void GetSettingInfo(const TSettingRef& aRef, 
sl@0
   532
                TElementId& aId, TSettingType& aType, TUint16& aLen);
sl@0
   533
sl@0
   534
        
sl@0
   535
        virtual TInt GetValue(const TSettingRef& aRef, UValueWord& aValue)=0;
sl@0
   536
        virtual TInt GetLargeValue(const TSettingRef& aRef, UValueLarge& aValue)=0;
sl@0
   537
sl@0
   538
        };
sl@0
   539
    
sl@0
   540
    
sl@0
   541
    /**
sl@0
   542
     * Compoiled repository class
sl@0
   543
     */
sl@0
   544
    class TRepositoryCompiled : public TRepository
sl@0
   545
        {
sl@0
   546
    public: 
sl@0
   547
        static TRepository* New(const SRepositoryCompiled* aRepos);
sl@0
   548
        virtual ~TRepositoryCompiled();
sl@0
   549
        
sl@0
   550
        virtual TInt CheckIntegrity();
sl@0
   551
        
sl@0
   552
        virtual TInt FindSetting(const TSettingId& aId, TSettingRef& aSetting);
sl@0
   553
        
sl@0
   554
        /**
sl@0
   555
         *  Pure virtual function defined in the base class TRepository, 
sl@0
   556
         * it implements the search procedure for the setting in the repository 
sl@0
   557
         * within the bounds defined by aLow and aHigh parameters. It returns 
sl@0
   558
         * found setting reference data and its position. Also @see TRepository
sl@0
   559
         * for more details. 
sl@0
   560
         */
sl@0
   561
        virtual TInt FindSetting (const TSettingId& aId, TSettingRef& aSetting,
sl@0
   562
                 TInt32& aPosition,TInt32 aLow, TInt32 aHigh);
sl@0
   563
        
sl@0
   564
                
sl@0
   565
        /** 
sl@0
   566
         *  Pure virtual function defined in the base TRepository class,
sl@0
   567
         * it implement the word setting search procedure. Also @see TRepository
sl@0
   568
         * for more details.
sl@0
   569
         */
sl@0
   570
        virtual TInt GetWordSettings(TInt aNum, SSettingId* aIds[], 
sl@0
   571
                    TInt32* aValues[], TSettingType* aTypes[], TInt* aErrors[]);
sl@0
   572
sl@0
   573
        
sl@0
   574
        /**
sl@0
   575
         *  This method implements returning a reference to TSettingRef
sl@0
   576
         * structure at specified position within the repository. 
sl@0
   577
         */
sl@0
   578
        virtual  void GetSettingRef(TInt32 aIndex, TSettingRef& aRef);
sl@0
   579
        
sl@0
   580
        /**
sl@0
   581
         *  Pure virtual function defined in the base TRepository class, 
sl@0
   582
         *  implements the search for all elements procedure withinthe defined
sl@0
   583
         *  category. Also @see TRepository for more details.
sl@0
   584
         */
sl@0
   585
        virtual TInt FindNumSettingsInCategory(TCategoryUid aCatUid,
sl@0
   586
                TInt32& aFirst, TInt32& aLast);
sl@0
   587
        virtual TInt GetValue(const TSettingRef& aRef, UValueWord& aValue);
sl@0
   588
        virtual TInt GetLargeValue(const TSettingRef& aRef, UValueLarge& aValue);
sl@0
   589
sl@0
   590
        
sl@0
   591
    private:
sl@0
   592
        TRepositoryCompiled(const SRepositoryCompiled* aRepos);
sl@0
   593
        
sl@0
   594
    private:   
sl@0
   595
        const SRepositoryCompiled* iRepos;
sl@0
   596
        };
sl@0
   597
    
sl@0
   598
    /**
sl@0
   599
    */
sl@0
   600
    class TRepositoryFile : public TRepository
sl@0
   601
        {
sl@0
   602
    public: 
sl@0
   603
        static TRepository* New(const SRepositoryFile* aRepos);
sl@0
   604
        virtual ~TRepositoryFile();
sl@0
   605
        
sl@0
   606
        virtual TInt CheckIntegrity();
sl@0
   607
        virtual TInt FindSetting(const TSettingId& aId, TSettingRef& aSetting);
sl@0
   608
        
sl@0
   609
        /**
sl@0
   610
         *  Pure virtual function defined in the base class TRepository, 
sl@0
   611
         * it implements the search procedure for the setting in the repository 
sl@0
   612
         * within the bounds defined by aLow and aHigh parameters. It returns 
sl@0
   613
         * found setting reference data and its position. Also @see TRepository
sl@0
   614
         * for more details. 
sl@0
   615
         */
sl@0
   616
        virtual TInt FindSetting (const TSettingId& aId, TSettingRef& aSetting,
sl@0
   617
                          TInt32& aPosition, TInt32 aLow, TInt32 aHigh);
sl@0
   618
sl@0
   619
        /** 
sl@0
   620
         *  Pure virtual function defined in the base TRepository class,
sl@0
   621
         * it implement the word setting search procedure. Also @see TRepository
sl@0
   622
         * for more details.
sl@0
   623
         */
sl@0
   624
        virtual TInt GetWordSettings(TInt aNum, SSettingId* aIds[], 
sl@0
   625
                         TInt32* aValues[], TSettingType* aTypes[],
sl@0
   626
                         TInt* aErrors[]);
sl@0
   627
sl@0
   628
        /**
sl@0
   629
         *  This method implements returning a reference to TSettingRef
sl@0
   630
         * structure at specified position within the repository. 
sl@0
   631
         */
sl@0
   632
        virtual  void GetSettingRef(TInt32 aIndex, TSettingRef& aRef);
sl@0
   633
sl@0
   634
        /**
sl@0
   635
         *  Pure virtual function defined in the base TRepository class, 
sl@0
   636
         *  implements the search for all elements procedure withinthe defined
sl@0
   637
         *  category. Also @see TRepository for more details.
sl@0
   638
         */ 
sl@0
   639
        virtual TInt FindNumSettingsInCategory(TCategoryUid aCatUid,
sl@0
   640
                TInt32& aFirst, TInt32& aLast);
sl@0
   641
        virtual TInt GetValue(const TSettingRef& aRef, UValueWord& aValue);
sl@0
   642
        virtual TInt GetLargeValue(const TSettingRef& aRef, UValueLarge& aValue);
sl@0
   643
       
sl@0
   644
    private:
sl@0
   645
        TRepositoryFile(const SRepositoryFile* aRepos);
sl@0
   646
        
sl@0
   647
    private:
sl@0
   648
        const SRepositoryFile* iRepos;
sl@0
   649
        };
sl@0
   650
        
sl@0
   651
     
sl@0
   652
    } // namespace HCR
sl@0
   653
sl@0
   654
sl@0
   655
sl@0
   656
// -- GLOBALS -----------------------------------------------------------------
sl@0
   657
sl@0
   658
sl@0
   659
GLREF_C HCR::HCRInternal gHCR;
sl@0
   660
sl@0
   661
#define HCRSingleton (&gHCR)
sl@0
   662
sl@0
   663
#define HCRReady    ((gHCR.GetStatus() & HCRInternal::EStatReady) == HCRInternal::EStatReady)
sl@0
   664
#define HCRNotReady ((gHCR.GetStatus() & HCRInternal::EStatReady) == 0)
sl@0
   665
sl@0
   666
sl@0
   667
sl@0
   668
#endif // HCR_PIL_H
sl@0
   669