mediasettings/mediasettingsengine/inc/MPSettingsRopConfigParser.h
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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:    Config descriptor parser for ROP specific settings.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // Version : %version: 2 %
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 #ifndef MPROPCONFIGPARSER_H
       
    25 #define MPROPCONFIGPARSER_H
       
    26 
       
    27 //  INCLUDES
       
    28 #include    <e32base.h>
       
    29 
       
    30 // DATA TYPES
       
    31 enum TMPRopConfType
       
    32     {
       
    33     EMPRopConfTypeInteger = 1,
       
    34     EMPRopConfTypeString = 2,
       
    35     EMPRopConfTypeIntArray = 3
       
    36     };
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 *  CMPRopSettingItem
       
    42 *   Setting item class, for storing item specific data.
       
    43 *   
       
    44 *
       
    45 *  @lib MPSettROPModel.dll
       
    46 *  @since 2.0
       
    47 */
       
    48 class CMPRopSettingItem : public CBase
       
    49     {
       
    50     public:
       
    51 
       
    52         /**
       
    53         * Two-phased constructor.
       
    54         */
       
    55         static CMPRopSettingItem* NewLC(TInt aId, const TDesC& aKey);
       
    56 
       
    57         /**
       
    58         * Destructor.
       
    59         */
       
    60         virtual ~CMPRopSettingItem();
       
    61 
       
    62     private:
       
    63 
       
    64         /**
       
    65         * C++ default constructor.
       
    66         */
       
    67         CMPRopSettingItem(TInt aId);
       
    68 
       
    69         /**
       
    70         * By default Symbian 2nd phase constructor is private.
       
    71         */
       
    72         void ConstructL(const TDesC& aKey);
       
    73 
       
    74     private: // Data
       
    75         HBufC8* iKey;
       
    76         TInt iId;
       
    77 
       
    78         TBool iValueChanged;
       
    79         TInt iError;
       
    80         TInt iIntValue;
       
    81         HBufC* iStringValue;
       
    82         RArray<TInt> iIntArray;
       
    83         TMPRopConfType iType;
       
    84 
       
    85     private:    // Friend classes
       
    86         friend class CMPSettingsModelForROP;
       
    87         friend class CMPSettingsRopConfigParser;
       
    88     };
       
    89 
       
    90 
       
    91 /**
       
    92 *  CMPSettingsRopConfigParser
       
    93 *  Config descriptor parser for ROP specific settings.
       
    94 *
       
    95 *  @lib MPSettROPModel.dll
       
    96 *  @since 2.0
       
    97 */
       
    98 class CMPSettingsRopConfigParser : public CBase
       
    99     {
       
   100     public:  // Constructors and destructor
       
   101 
       
   102         /**
       
   103         * Two-phased constructor.
       
   104         */
       
   105         static CMPSettingsRopConfigParser* NewL();
       
   106        
       
   107         /**
       
   108         * Destructor.
       
   109         */
       
   110         virtual ~CMPSettingsRopConfigParser();
       
   111 
       
   112     public: // New functions
       
   113         
       
   114         /**
       
   115         * Parses config string and places parsed setting items to item array.
       
   116         * @since 2.0
       
   117         * @param aConfigString Configuration string
       
   118         * @param aItemArray Item array
       
   119         * @return Descriptor containing config string header.
       
   120         */
       
   121         HBufC8* ParseConfigStringL(const TDesC8& aConfigString, const CArrayPtr<CMPRopSettingItem>* aItemArray);
       
   122 
       
   123         /**
       
   124         * Creates configuration string from item's data in the item array.
       
   125         * @since 2.0
       
   126         * @param aItemArray Item array
       
   127         * @param aConfigHeader Configuration string's header.
       
   128         * @return Descriptor containing configuration string.
       
   129         */
       
   130         HBufC8* CreateConfigStringL(const CArrayPtr<CMPRopSettingItem>* aItemArray, const TDesC8& aConfigHeader);
       
   131 
       
   132     private:
       
   133 
       
   134         /**
       
   135         * C++ default constructor.
       
   136         */
       
   137         CMPSettingsRopConfigParser();
       
   138 
       
   139         /**
       
   140         * By default Symbian 2nd phase constructor is private.
       
   141         */
       
   142         void ConstructL();
       
   143 
       
   144     private:
       
   145 
       
   146         /**
       
   147         * Parses config header from config string.
       
   148         */
       
   149         HBufC8* ParseConfigHeaderL();
       
   150 
       
   151         /**
       
   152         * Returns descriptor containing next config entry.
       
   153         */
       
   154         HBufC8* NextConfigEntryL(TInt& aError);
       
   155 
       
   156         /**
       
   157         * Populates entry array from configuration string.
       
   158         */
       
   159         void PopulateEntryArrayFromConfigStringL();
       
   160 
       
   161         /**
       
   162         * Populates entry array from item array.
       
   163         */
       
   164         void PopulateEntryArrayFromItemArrayL();
       
   165 
       
   166         /**
       
   167         * Creates config entry from setting item.
       
   168         */
       
   169         HBufC8* CreateConfigEntryL(CMPRopSettingItem* aItem);
       
   170 
       
   171         /**
       
   172         * Creates configuration string from entry array.
       
   173         */
       
   174         HBufC8* CreateConfigStringFromEntryArrayL();
       
   175 
       
   176         /**
       
   177         * Parses next entry from config string.
       
   178         */
       
   179         TInt GetNextEntry(TPtrC8& aEntry);
       
   180 
       
   181         /**
       
   182         * Parses setting item data from all config entries.
       
   183         */
       
   184         void ParseSettingsBufferL();
       
   185 
       
   186         /**
       
   187         * Parses setting item data from a config entry for predefined setting items.
       
   188         */
       
   189         TInt GetConfigDataL(const TDesC8& aKey, TPtrC8& aValue, TMPRopConfType& aType);
       
   190 
       
   191         /**
       
   192         * Parses value string from a config entry.
       
   193         */
       
   194         TPtrC8 ValueStringPtr(const TDesC8& aValue, TInt& aError);
       
   195 
       
   196     private:    // Data
       
   197 
       
   198         CArrayPtr<HBufC8>* iEntries;
       
   199         const CArrayPtr<CMPRopSettingItem>* iItemArray;
       
   200 
       
   201         HBufC8* iConfigHeader;
       
   202         HBufC8* iTmpBuf;
       
   203         TPtrC8 iBufferPtr;    
       
   204     };
       
   205 
       
   206 #endif      // MPROPCONFIGPARSER_H   
       
   207             
       
   208 // End of File