voipplugins/voipadapters/voipxmlprovisioning/voipxmlprocessor/inc/voipxmlparser.h
branchRCL_3
changeset 22 d38647835c2e
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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:  VoIP settings XML parser
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VOIPXMLPARSER_H
       
    20 #define VOIPXMLPARSER_H
       
    21 
       
    22 #include <gmxmlparser.h>
       
    23 #include <gmxmlelement.h>
       
    24 #include <gmxmlnode.h>
       
    25 
       
    26 #include "voipxmlparamhandler.h"
       
    27 
       
    28 class CVoipXmlParamHandler;
       
    29 
       
    30 /**
       
    31  *  VoIP settings XML parser.
       
    32  *  Parses an XML file and passes the parameters to XML parameter handler.
       
    33  *
       
    34  *  @code
       
    35  *    CVoIPXmlParser* parser = CVoIPXmlParser::NewLC();
       
    36  *    TFileName myfile( PathInfo::PhoneMemoryRootPath() );
       
    37  *    _LIT( KXmlFilePath, "testsettings.xml" );
       
    38  *    myfile.Append( KXmlFilePath );
       
    39  *    TUint32 serviceTabId;
       
    40  *    TInt err = parser->ImportDocument( myfile, serviceTabId );
       
    41  *    CleanupStack::PopAndDestroy( parser );
       
    42  *  @endcode
       
    43  *
       
    44  *  @lib voipxmlprocessor.lib
       
    45  *  @since S60 v5.0
       
    46  */
       
    47 NONSHARABLE_CLASS( CVoipXmlParser ) : public CBase, 
       
    48                                       public MMDXMLParserObserver
       
    49     {
       
    50 #ifdef _DEBUG
       
    51     friend class UT_CVoipXmlParser;
       
    52 #endif
       
    53 
       
    54 public:
       
    55 
       
    56     IMPORT_C static CVoipXmlParser* NewL();
       
    57     IMPORT_C static CVoipXmlParser* NewLC();
       
    58     virtual ~CVoipXmlParser();
       
    59 
       
    60     /**
       
    61      * Method for importing XML and saving settings.
       
    62      *
       
    63      * @since S60 v5.0
       
    64      * @param aFile File handle to XML file. Ownsership is taken and moved
       
    65      *              to CMDXMLParser object.
       
    66      * @param aServiceTabId Service tab ID of the created service.
       
    67      * @return KErrEof if no <nokia-provdoc> found in XML file,
       
    68      *         KErrCorrupt if XML file is corrupted,
       
    69      *         KErrAbort if no <settings type=""> found in XML file,
       
    70      *         KErrBadHandle if unrecognized node types found in XML file,
       
    71      *         KErrNotSupported if no SIP or VoIP settings found,
       
    72      *         KErrCompletion if error in storing the settings.
       
    73      */
       
    74     IMPORT_C TInt ImportDocument( RFile& aFile, TUint32& aServiceTabId );
       
    75 
       
    76     /**
       
    77      * Reads description from inside <nokia-provdescription> tags
       
    78      * and returns it in HBufC object which has been pushed into cleanup
       
    79      * stack. Also reads branding URL from XML file and sets it into argument.
       
    80      *
       
    81      * @since S60 v5.0
       
    82      * @param aFile File handle to XML file. Ownsership is taken and moved
       
    83      *              to CMDXMLParser object.
       
    84      * @param aBrandUrl Branding URL.
       
    85      * @return Descriptor object containing the description.
       
    86      */
       
    87     IMPORT_C HBufC* ReadDescriptionLC( RFile& aFile, TDes8& aBrandUrl );
       
    88 
       
    89 private:
       
    90 
       
    91     /**
       
    92      * For parsing nokia-provdescription node.
       
    93      *
       
    94      * @since S60 v5.0
       
    95      * @param aXmlElement XML element to be parsed.
       
    96      */
       
    97     void ParseDescription( CMDXMLElement& aXmlElement );
       
    98 
       
    99     /**
       
   100      * For parsing root node.
       
   101      *
       
   102      * @since S60 v5.0
       
   103      * @param aXmlElement XML element to be parsed.
       
   104      */
       
   105     void ParseRoot( CMDXMLElement& aXmlElement );
       
   106 
       
   107     /**
       
   108      * For parsing settings node.
       
   109      *
       
   110      * @since S60 v5.0
       
   111      * @param aXmlElement XML element to be parsed.
       
   112      */
       
   113     void ParseSettings( CMDXMLNode* aXmlNode );
       
   114 
       
   115 protected:
       
   116 
       
   117 // From base class MMDXMLParserObserver.
       
   118 
       
   119     /**
       
   120      * From base class MMDXMLParserObserver.
       
   121      * Call back function used to inform a client of the Parser when a
       
   122      * parsing operation completes.
       
   123      * @since S60 v5.0
       
   124      */
       
   125     void ParseFileCompleteL();
       
   126 
       
   127 private:
       
   128 
       
   129     CVoipXmlParser();
       
   130 
       
   131     void ConstructL();
       
   132 
       
   133 private: // data
       
   134 
       
   135     /**
       
   136      * XML parser object.
       
   137      * Own.
       
   138      */
       
   139     CMDXMLParser* iParser;
       
   140 
       
   141     /**
       
   142      * XML document.
       
   143      * Own.
       
   144      */
       
   145     CMDXMLDocument* iXmlDoc;
       
   146 
       
   147     /**
       
   148      * XML parameter handler.
       
   149      * Own.
       
   150      */
       
   151     CVoipXmlParamHandler* iParamHandler;
       
   152 
       
   153     /**
       
   154      * Error code to be returned in ImportDocument.
       
   155      */
       
   156     TInt iError;
       
   157 
       
   158     /**
       
   159      * Flag for telling if we are to only read
       
   160      * <nokia-provdescription> contents from the XML document.
       
   161      */
       
   162     TBool iParseDescription;
       
   163 
       
   164     /**
       
   165      * Object for holding description read from <nokia-provdescription>.
       
   166      * Own.
       
   167      */
       
   168     HBufC* iDescription;
       
   169 
       
   170     /**
       
   171      * Object for holding branding URL read from <nokia-provbrandurl>.
       
   172      * Own.
       
   173      */
       
   174     HBufC* iBrandUrl;
       
   175     };
       
   176 
       
   177 #endif // VOIPXMLPARSER_H
       
   178 
       
   179 // End of file.
       
   180