brandingserver/tools/bsimport/inc/cbsimportxmlparser.h
branchRCL_3
changeset 21 cfd5c2994f10
parent 0 e6b17d312c8b
child 22 113b91e0a2ad
equal deleted inserted replaced
20:eedf17a17c27 21:cfd5c2994f10
     1 /*
     1 /*
     2 * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8 *
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Parses XML content and stores data to storage
    14 * Description:   Parses XML content and stores data to storage
    15 
       
    16 *
    15 *
    17 */
    16 */
    18 
    17 
    19 
    18 
    20 #ifndef CBSIMPORTXMLPARSER_H
    19 #ifndef CBSIMPORTXMLPARSER_H
    21 
       
    22 #define CBSIMPORTXMLPARSER_H
    20 #define CBSIMPORTXMLPARSER_H
    23 
    21 
    24 
       
    25 
       
    26 // INCLUDE FILES
    22 // INCLUDE FILES
    27 
       
    28 #include <e32base.h>
    23 #include <e32base.h>
    29 
       
    30 #include <f32file.h>
    24 #include <f32file.h>
    31 
       
    32 #include <gmxmldocument.h>
    25 #include <gmxmldocument.h>
    33 
       
    34 #include <rbsobjowningptrarray.h>
    26 #include <rbsobjowningptrarray.h>
    35 
       
    36 #include <mbselement.h>
    27 #include <mbselement.h>
    37 
    28 
    38 
       
    39 
       
    40 class CMDXMLNode;
    29 class CMDXMLNode;
    41 
       
    42 class CBSImportStorageManager;
    30 class CBSImportStorageManager;
    43 
    31 
    44 
       
    45 
       
    46 // CLASS DEFINITION
    32 // CLASS DEFINITION
    47 
       
    48 class CBSImportXMLParser : public CBase
    33 class CBSImportXMLParser : public CBase
    49 
       
    50     {
    34     {
    51 
       
    52 private: // Definitions
    35 private: // Definitions
    53 
    36 
    54 
       
    55 
       
    56     struct TImportBitmap
    37     struct TImportBitmap
    57 
       
    58         {
    38         {
    59 
       
    60         TInt iBitmapId;
    39         TInt iBitmapId;
    61 
       
    62         TInt iBitmapMaskId;
    40         TInt iBitmapMaskId;
    63 
       
    64         TInt iSkinId;
    41         TInt iSkinId;
    65 
       
    66         TInt iSkinMaskId;
    42         TInt iSkinMaskId;
    67 
       
    68         };
    43         };
    69 
    44 
    70 
       
    71 
       
    72     enum TXMLBaseTagTypes
    45     enum TXMLBaseTagTypes
    73 
       
    74         {
    46         {
    75 
       
    76         EBrandUnknown,
    47         EBrandUnknown,
    77 
       
    78         EBrandAppID,
    48         EBrandAppID,
    79 
       
    80         EBrandID,
    49         EBrandID,
    81 
       
    82         EBrandLanguage,
    50         EBrandLanguage,
    83 
       
    84         EBrandVersion,
    51         EBrandVersion,
    85 
       
    86         EBrandElement
    52         EBrandElement
    87 
       
    88         };
    53         };
    89 
       
    90         
    54         
    91 
       
    92 public:
    55 public:
    93 
    56 
    94 
       
    95 
       
    96     static CBSImportXMLParser* NewL( CBSImportStorageManager* aStorage );
    57     static CBSImportXMLParser* NewL( CBSImportStorageManager* aStorage );
    97 
       
    98     
    58     
    99 
       
   100     static CBSImportXMLParser* NewLC( CBSImportStorageManager* aStorage );
    59     static CBSImportXMLParser* NewLC( CBSImportStorageManager* aStorage );
   101 
       
   102 
       
   103 
    60 
   104     ~CBSImportXMLParser();
    61     ~CBSImportXMLParser();
   105 
    62 
   106 
       
   107 
       
   108     /**
    63     /**
   109 
       
   110      * Parse XML document and store data to storage
    64      * Parse XML document and store data to storage
   111 
       
   112      *
    65      *
   113 
       
   114      * @since S60 3.2
    66      * @since S60 3.2
   115 
       
   116      * @param aDocument XML document to parse
    67      * @param aDocument XML document to parse
   117 
       
   118      * @return none
    68      * @return none
   119 
       
   120      */
    69      */
   121 
       
   122     void ParseDocumentL( CMDXMLDocument& aDocument );
    70     void ParseDocumentL( CMDXMLDocument& aDocument );
   123 
       
   124 
       
   125 
    71 
   126 private:
    72 private:
   127 
    73 
   128 
       
   129 
       
   130     CBSImportXMLParser( CBSImportStorageManager* aStorage );
    74     CBSImportXMLParser( CBSImportStorageManager* aStorage );
   131 
       
   132     
    75     
   133 
       
   134     void ConstructL();
    76     void ConstructL();
   135 
       
   136     
    77     
       
    78     /**
       
    79      * Parses full the base element <branding> and it's child elements.
       
    80      *
       
    81      * @since S60 v3.2
       
    82      * @param aElement to parse
       
    83      */
       
    84     void ParseDocumentBaseL( CMDXMLNode* aElement );
       
    85     
       
    86     /**
       
    87      * Analyzes a child node of <branding> and stores the value to storage.
       
    88      * Ignores undetected XML nodes.
       
    89      *
       
    90      * @since S60 v3.2
       
    91      * @param aElement to parse
       
    92      */
       
    93     void AnalyzeNodeL( CMDXMLNode* aNode );
       
    94     
       
    95     /**
       
    96      * Converts a given node to TXMLBaseTagTypes. This can handle all
       
    97      * child nodes of <branding>
       
    98      *
       
    99      * @since S60 v3.2
       
   100      * @param aNode node to check
       
   101      * @return corresponding TXMLBaseTagTypes value (or EBrandUnknown).
       
   102      */
       
   103     TXMLBaseTagTypes SolveTagTypeL( CMDXMLNode* aNode );
   137 
   104 
   138     /**
   105     /**
   139 
   106      * Parses full <element> node. Returns a newly constructed MBSElement
   140      * Parses full the base element <branding> and it's child elements.
   107      * from the content of teh node. 
   141 
   108      * Ownership is transferred!
   142      *
   109      *
   143 
       
   144      * @since S60 v3.2
   110      * @since S60 v3.2
   145 
   111      * @param aNode <element> node
   146      * @param aElement to parse
   112      * @return Concrete element constructed from node. 
   147 
       
   148      */
   113      */
   149 
   114     MBSElement* ParseBrandElementL( CMDXMLNode* aNode );
   150     void ParseDocumentBaseL( CMDXMLNode* aElement );
       
   151 
       
   152     
   115     
       
   116     /**
       
   117      * Converts elements type attribute value to TBSElementType 
       
   118      * (see MBSElement).
       
   119      *
       
   120      * @since S60 v3.2
       
   121      * @param aType value of type attribute
       
   122      * @return corresponding TBrandingElementType value or KErrNotFound.
       
   123      */
       
   124     TInt SolveElementType( const TDesC& aType );
   153 
   125 
   154     /**
   126     /**
   155 
   127      * Search a child node with name inside another node. Returns the first match
   156      * Analyzes a child node of <branding> and stores the value to storage.
       
   157 
       
   158      * Ignores undetected XML nodes.
       
   159 
       
   160      *
   128      *
   161 
       
   162      * @since S60 v3.2
   129      * @since S60 v3.2
   163 
   130      * @param aNode parent node to search 
   164      * @param aElement to parse
   131      * @param aTagName Child nodes name
   165 
   132      * @return found node or NULL if not found;
   166      */
   133      */
   167 
   134     CMDXMLNode* SearchChild( CMDXMLNode* aNode, const TDesC& aChildName );
   168     void AnalyzeNodeL( CMDXMLNode* aNode );
       
   169 
       
   170     
       
   171 
   135 
   172     /**
   136     /**
   173 
   137      * Parse value from <element_value> tag. Leaves if parse fails.
   174      * Converts a given node to TXMLBaseTagTypes. This can handle all
   138      * Ownership is transferred to caller (NodeTextLC)
   175 
       
   176      * child nodes of <branding>
       
   177 
       
   178      *
   139      *
   179 
   140      * @since S60 3.2
   180      * @since S60 v3.2
   141      * @param aNode XML node to parse. should be <element_value>.
   181 
   142      * @return value from <element_value>
   182      * @param aNode node to check
       
   183 
       
   184      * @return corresponding TXMLBaseTagTypes value (or EBrandUnknown).
       
   185 
       
   186      */
   143      */
   187 
   144     HBufC* NodeTextLC( CMDXMLNode* elNode );
   188     TXMLBaseTagTypes SolveTagTypeL( CMDXMLNode* aNode );
   145     TInt   NodeIntL  ( CMDXMLNode* elNode );
   189 
   146     
   190 
       
   191 
       
   192     /**
   147     /**
   193 
   148      * Parse <element> tag for given value type. Leaves if parsing fails.
   194      * Parses full <element> node. Returns a newly constructed MBSElement
       
   195 
       
   196      * from the content of teh node. 
       
   197 
       
   198      * Ownership is transferred!
       
   199 
       
   200      *
   149      *
   201 
   150      * @since S60 3.2
   202      * @since S60 v3.2
   151      * @param aNode XML node to parse
   203 
   152      * @param aValue Parsed value
   204      * @param aNode <element> node
   153      * @return none
   205 
       
   206      * @return Concrete element constructed from node. 
       
   207 
       
   208      */
   154      */
   209 
   155     void DoParseIntegerL( CMDXMLNode* aNode, TInt& aValue );
   210     MBSElement* ParseBrandElementL( CMDXMLNode* aNode );
   156     void DoParseTextL   ( CMDXMLNode* aNode, HBufC*& aText );
   211 
   157     void DoParseFileL   ( CMDXMLNode* aNode, HBufC*& aText );
       
   158     void DoParseListL   ( CMDXMLNode* aNode, RBSObjOwningPtrArray<MBSElement>& aElementArray );
       
   159     void DoParseBitmapL ( CMDXMLNode* aNode, CBSBitmap*& aBitmap );
   212     
   160     
   213 
   161 private: // Data
   214     /**
       
   215 
       
   216      * Converts elements type attribute value to TBSElementType 
       
   217 
       
   218      * (see MBSElement).
       
   219 
       
   220      *
       
   221 
       
   222      * @since S60 v3.2
       
   223 
       
   224      * @param aType value of type attribute
       
   225 
       
   226      * @return corresponding TBrandingElementType value or KErrNotFound.
       
   227 
       
   228      */
       
   229 
       
   230     TInt SolveElementType( const TDesC& aType );
       
   231 
       
   232 
       
   233 
       
   234     /**
       
   235 
       
   236      * Search a child node with name inside another node. Returns the first match
       
   237 
       
   238      *
       
   239 
       
   240      * @since S60 v3.2
       
   241 
       
   242      * @param aNode parent node to search 
       
   243 
       
   244      * @param aTagName Child nodes name
       
   245 
       
   246      * @return found node or NULL if not found;
       
   247 
       
   248      */
       
   249 
       
   250     CMDXMLNode* SearchChild( CMDXMLNode* aNode, const TDesC& aChildName );
       
   251 
       
   252 
       
   253 
       
   254     /**
       
   255 
       
   256      * Parse value from <element_value> tag. Leaves if parse fails.
       
   257 
       
   258      * Ownership is transferred to caller (NodeTextLC)
       
   259 
       
   260      *
       
   261 
       
   262      * @since S60 3.2
       
   263 
       
   264      * @param aNode XML node to parse. should be <element_value>.
       
   265 
       
   266      * @return value from <element_value>
       
   267 
       
   268      */
       
   269 
       
   270     HBufC* NodeTextLC( CMDXMLNode* elNode );
       
   271 
       
   272     TInt   NodeIntL  ( CMDXMLNode* elNode );
       
   273 
       
   274     
   162     
   275 
       
   276     /**
       
   277 
       
   278      * Parse <element> tag for given value type. Leaves if parsing fails.
       
   279 
       
   280      *
       
   281 
       
   282      * @since S60 3.2
       
   283 
       
   284      * @param aNode XML node to parse
       
   285 
       
   286      * @param aValue Parsed value
       
   287 
       
   288      * @return none
       
   289 
       
   290      */
       
   291 
       
   292     void DoParseIntegerL( CMDXMLNode* aNode, TInt& aValue );
       
   293 
       
   294     void DoParseTextL   ( CMDXMLNode* aNode, HBufC*& aText );
       
   295 
       
   296     void DoParseFileL   ( CMDXMLNode* aNode, HBufC*& aText );
       
   297 
       
   298     void DoParseListL   ( CMDXMLNode* aNode, RBSObjOwningPtrArray<MBSElement>& aElementArray );
       
   299 
       
   300     void DoParseBitmapL ( CMDXMLNode* aNode, CBSBitmap*& aBitmap );
       
   301 
       
   302     
       
   303 
       
   304 private: // Data
       
   305 
       
   306     
       
   307 
       
   308     // Not owned. Storage where to put parsed elements
   163     // Not owned. Storage where to put parsed elements
   309 
       
   310     CBSImportStorageManager* iStorage;
   164     CBSImportStorageManager* iStorage;
   311 
       
   312     };
   165     };
   313 
   166 
   314 
       
   315 
       
   316 #endif //CBSIMPORTXMLPARSER_H
   167 #endif //CBSIMPORTXMLPARSER_H
   317