ncdengine/provider/deviceinteraction/inc/ncdtestconfig.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Declaration of CNcdDeviceService
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCDTESTCONFIG_H
       
    20 #define C_NCDTESTCONFIG_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 
       
    25 /**
       
    26  * Test configuration reader and provider
       
    27  *
       
    28  * Possible improvement: CNcdTestConfig (or other test class) should implement
       
    29  * MNcdDeviceService and it should replace CNcdDeviceService if necessary
       
    30  * so that functions that are not configured from a file are rerouted to 
       
    31  * CNcdDeviceService
       
    32  *
       
    33  * Configuration file format:
       
    34  * <key1>=<value1>
       
    35  * <key2>=<value2>
       
    36  *
       
    37  * Valid keys: currentmnc, currentmcc, homemnc, homemcc
       
    38  *
       
    39  * Example:
       
    40  * 
       
    41  * currentmnc=123
       
    42  * currentmcc=456
       
    43  * homemnc=678
       
    44  * homemcc=987
       
    45  *
       
    46  * @note The length of MNC/MCC value MUST NOT exceed 3 characters
       
    47  * @note There are no validity checks for the values
       
    48  * @note If all of the keys are not defined, the missing keys will be 
       
    49  * given empty descriptors as their values
       
    50  */
       
    51 class CNcdTestConfig : public CBase
       
    52     {
       
    53 public:
       
    54 
       
    55     enum TConfigValue
       
    56         {
       
    57         EConfigCurrentMcc = 0,
       
    58         EConfigCurrentMnc,
       
    59         EConfigHomeMcc,
       
    60         EConfigHomeMnc,
       
    61         EConfigImsi,
       
    62         
       
    63         // Do NOT use this as a parameter
       
    64         // Always keep this as the last enumeration
       
    65         EConfigInternal
       
    66         };
       
    67 
       
    68     static CNcdTestConfig* NewL( RFs& aFs, const TDesC& aConfigFile );
       
    69     
       
    70     virtual ~CNcdTestConfig();
       
    71     
       
    72 public:
       
    73 
       
    74     /**
       
    75      * Returns ETrue if the specified value was defined in the
       
    76      * config file
       
    77      */
       
    78     TBool IsSet( TConfigValue aValue ) const;
       
    79     
       
    80     /**
       
    81      * Returns the string defined in the config file
       
    82      *
       
    83      * @param aValue
       
    84      * @panic ENcdPanicNoData if the value had not been set in the config file
       
    85      */
       
    86     const TDesC& Value( TConfigValue aValue ) const;
       
    87     
       
    88     
       
    89 protected:
       
    90 
       
    91     CNcdTestConfig();
       
    92     
       
    93     void ConstructL( RFs& aFs, const TDesC& aConfigFile );        
       
    94 
       
    95     void ParseL( const TDesC& aData );
       
    96     
       
    97     TBool ParseEntityL( 
       
    98         const TDesC& aData, const TDesC& aEntityName, TConfigValue aTarget );
       
    99         
       
   100     HBufC* GetString( TConfigValue aValue ) const;
       
   101 
       
   102 private:    
       
   103     
       
   104     RPointerArray<HBufC> iConfigStrings;
       
   105     
       
   106     };
       
   107 
       
   108 #endif // C_NCDTESTCONFIG_H
       
   109