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