webengine/widgetregistry/Server/inc/WidgetRegistryXml.h
changeset 0 dd21522fd290
child 25 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2008 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:  This file contains the header file of the CWidgetRegistryXml class.
       
    15 *
       
    16 *                This class processes persistent registry data in XML.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef WIDGETREGISTRYXML_H
       
    22 #define WIDGETREGISTRYXML_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <libxml2_tree.h>
       
    26 #include "WidgetRegistryConstants.h"
       
    27 #include "WidgetPropertyValue.h"
       
    28 
       
    29 class RFs;
       
    30 /**
       
    31 *  CWidgetRegistryXml
       
    32 *  @since 5.0
       
    33 */
       
    34 class CWidgetRegistryXml: public CBase
       
    35     {
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Two-phased constructor.
       
    40      */
       
    41     static CWidgetRegistryXml* NewL();
       
    42 
       
    43     /**
       
    44      * Destructor.
       
    45      */
       
    46     virtual ~CWidgetRegistryXml();
       
    47 
       
    48 protected:
       
    49 
       
    50     /**
       
    51      * C++ default constructor.
       
    52      */
       
    53     CWidgetRegistryXml();
       
    54 
       
    55     /**
       
    56      * Symbian 2nd phase constructor
       
    57      */
       
    58     void ConstructL();
       
    59 
       
    60 public:
       
    61 
       
    62     /**
       
    63      * Traverse to the next Node
       
    64      *
       
    65      * @param aNode: current node
       
    66      * @since 5.0
       
    67      * @return next node
       
    68      */
       
    69     xmlNode* TraverseNextNode( xmlNode* aNode );
       
    70 
       
    71     /**
       
    72      * Convert a string in some encoding to UCS2.
       
    73      *
       
    74      * @param aEncoding encoding number
       
    75      * @param aUnicodeSizeMultiplier how many input bytes per unicode char
       
    76      * @param aInBuf input data
       
    77      * @param aOutBuf output data, allocated and returned to caller
       
    78      * @param aFileSession
       
    79      * @since 5.0
       
    80      * @return void
       
    81      */
       
    82     void ToUnicodeL( TInt aEncoding,
       
    83                      TInt aUnicodeSizeMultiplier,
       
    84                      TPtrC8 aInBuf, HBufC16** aOutBuf,
       
    85                      RFs& aFileSession );
       
    86 
       
    87     /**
       
    88      * Convert a string to some encoding from UCS2.
       
    89      *
       
    90      * @param aEncoding encoding number
       
    91      * @param aUnicodeSizeMultiplier how many input bytes per unicode char
       
    92      * @param aInBuf input data
       
    93      * @param aOutBuf output data, allocated and returned to caller
       
    94      * @param aFileSession
       
    95      * @since 5.0
       
    96      * @return void
       
    97      */
       
    98     void FromUnicodeL( TInt aEncoding,
       
    99                      TInt aUnicodeSizeMultiplier,
       
   100                      TPtrC16 aInBuf, HBufC8** aOutBuf,
       
   101                      RFs& aFileSession );
       
   102 
       
   103 
       
   104     /**
       
   105      * Utility to bundle extraction of XML text content
       
   106      *
       
   107      * @param aEncoding input buffer encoding
       
   108      * @param aUnicodeSizeMultiplier how many bytes of input make one unicode char
       
   109      * @param aInBuf input data in encoding
       
   110      * @param aOutBuf malloc'ed output buf, caller takes ownership
       
   111      * @param aFileSession CCnvCharacterSetConverter requires it
       
   112      * @since 5.0
       
   113      * @return void
       
   114      */
       
   115     void GetContentL( RFs& aFileSession,
       
   116                       xmlDocPtr aDoc,
       
   117                       xmlNode* aNode,
       
   118                       HBufC** aContent );
       
   119 
       
   120     /**
       
   121      * Utility to extract XML content as a string
       
   122      *
       
   123      * @param aFileSession CCnvCharacterSetConverter requires it
       
   124      * @param aDoc
       
   125      * @param aNode
       
   126      * @param aContent
       
   127      * @since 5.0
       
   128      * @return void
       
   129      */
       
   130     void GetTextContentAsStringL( RFs& aFileSession,
       
   131                                   xmlDocPtr aDoc,
       
   132                                   xmlNode* aNode,
       
   133                                   HBufC** aContent );
       
   134 
       
   135     void GetSubtreeAsStringL (RFs& aFileSession, xmlDocPtr aDoc, xmlNode* aNode, HBufC** aBuf, TInt& aLen);
       
   136 
       
   137     xmlChar* EncodeStringL(xmlDocPtr aDoc, xmlChar* aStringToConvert);
       
   138     HBufC* EncodeStringL(xmlDocPtr aDoc, TPtrC aStringToConvert, RFs& aFileSession);
       
   139 
       
   140     TInt EncodedStringLength(TPtrC8 aStringToConvert);
       
   141 
       
   142     TInt GetPropertyId(
       
   143         const TDesC& aKeyName );
       
   144 
       
   145     const TPtrC& XmlPropertyName( TInt aPropertyId );
       
   146 
       
   147     class TWidgetProperty
       
   148         {
       
   149     public:
       
   150         TInt id; // the TWidgetPropertyId for this name
       
   151         TPtrC name;
       
   152         TWidgetPropertyType type; // the type if valid
       
   153         TInt flags;
       
   154         };
       
   155 
       
   156     // Table describing registry entries for XML processing.  Used by
       
   157     // parser and generator.
       
   158     RArray<TWidgetProperty> iProperties;
       
   159 
       
   160     };
       
   161 
       
   162 #endif // WIDGETREGISTRYXML_H