iaupdate/IAD/engine/controller/src/iaupdateenginexmlparser.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "iaupdateenginexmlparser.h"
       
    21 #include "iaupdateenginexmlsubparser.h"
       
    22 #include "iaupdateengineconfigdata.h"
       
    23 #include "iaupdateengineconfigconsts.h"
       
    24 
       
    25 
       
    26 CIAUpdateEngineXmlParser* CIAUpdateEngineXmlParser::NewL()
       
    27     {
       
    28     CIAUpdateEngineXmlParser* self =
       
    29         CIAUpdateEngineXmlParser::NewLC();
       
    30     CleanupStack::Pop( self );
       
    31     return self;
       
    32     }
       
    33 
       
    34 
       
    35 CIAUpdateEngineXmlParser* CIAUpdateEngineXmlParser::NewLC()
       
    36     {
       
    37     // Create config data that will contain all the parsed data.
       
    38     CIAUpdateEngineConfigData* configData = 
       
    39         CIAUpdateEngineConfigData::NewLC();
       
    40     
       
    41     // Create sub parser that will handle the given elements.
       
    42     CIAUpdateEngineXmlSubParser* subParser = 
       
    43         CIAUpdateEngineXmlSubParser::NewLC( *configData );
       
    44 
       
    45     // Create the actual XML parser that uses configData and subParser.
       
    46     // Notice, that the ownership of the subParser and configData are
       
    47     // transferred here to the parser.
       
    48     CIAUpdateEngineXmlParser* self =
       
    49         new( ELeave ) CIAUpdateEngineXmlParser( subParser, configData );
       
    50 
       
    51     CleanupStack::Pop( subParser );
       
    52     CleanupStack::Pop( configData );    
       
    53 
       
    54     CleanupStack::PushL( self );
       
    55     self->ConstructL();
       
    56 
       
    57     return self;    
       
    58     }
       
    59 
       
    60 
       
    61 CIAUpdateEngineXmlParser::CIAUpdateEngineXmlParser( CIAUpdateEngineXmlSubParser* aSubParser,
       
    62                                                     CIAUpdateEngineConfigData* aConfigData )
       
    63 : CIAUpdateXmlParser( aSubParser ),
       
    64   iConfigData( aConfigData )
       
    65     {
       
    66     
       
    67     }
       
    68     
       
    69     
       
    70 void CIAUpdateEngineXmlParser::ConstructL()
       
    71     {
       
    72     CIAUpdateXmlParser::ConstructL();
       
    73     }
       
    74 
       
    75 
       
    76 CIAUpdateEngineXmlParser::~CIAUpdateEngineXmlParser()
       
    77     {
       
    78     delete iConfigData;
       
    79     }
       
    80 
       
    81 
       
    82 void CIAUpdateEngineXmlParser::ParseL()
       
    83     {
       
    84     // Reset the config data pefore starting to set new values there.
       
    85     // For example if the parsing has been done before and the config file 
       
    86     // content has changed, then old values that are not parsed now, will not
       
    87     // be left hanging.
       
    88     iConfigData->ResetL();
       
    89     ParsePrivateFileL( IAUpdateEngineConfigConsts::KConfigFile );        
       
    90     }
       
    91 
       
    92 
       
    93 const CIAUpdateEngineConfigData& CIAUpdateEngineXmlParser::ConfigData() const
       
    94     {
       
    95     return *iConfigData;
       
    96     }