iaupdate/IAD/engine/controller/src/iaupdateenginexmlparser.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 06 Jul 2010 14:23:31 +0300
changeset 53 ae54820ef82c
parent 0 ba25891c3a9e
permissions -rw-r--r--
Revision: 201025 Kit: 2010127

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:   ?Description
*
*/



#include "iaupdateenginexmlparser.h"
#include "iaupdateenginexmlsubparser.h"
#include "iaupdateengineconfigdata.h"
#include "iaupdateengineconfigconsts.h"


CIAUpdateEngineXmlParser* CIAUpdateEngineXmlParser::NewL()
    {
    CIAUpdateEngineXmlParser* self =
        CIAUpdateEngineXmlParser::NewLC();
    CleanupStack::Pop( self );
    return self;
    }


CIAUpdateEngineXmlParser* CIAUpdateEngineXmlParser::NewLC()
    {
    // Create config data that will contain all the parsed data.
    CIAUpdateEngineConfigData* configData = 
        CIAUpdateEngineConfigData::NewLC();
    
    // Create sub parser that will handle the given elements.
    CIAUpdateEngineXmlSubParser* subParser = 
        CIAUpdateEngineXmlSubParser::NewLC( *configData );

    // Create the actual XML parser that uses configData and subParser.
    // Notice, that the ownership of the subParser and configData are
    // transferred here to the parser.
    CIAUpdateEngineXmlParser* self =
        new( ELeave ) CIAUpdateEngineXmlParser( subParser, configData );

    CleanupStack::Pop( subParser );
    CleanupStack::Pop( configData );    

    CleanupStack::PushL( self );
    self->ConstructL();

    return self;    
    }


CIAUpdateEngineXmlParser::CIAUpdateEngineXmlParser( CIAUpdateEngineXmlSubParser* aSubParser,
                                                    CIAUpdateEngineConfigData* aConfigData )
: CIAUpdateXmlParser( aSubParser ),
  iConfigData( aConfigData )
    {
    
    }
    
    
void CIAUpdateEngineXmlParser::ConstructL()
    {
    CIAUpdateXmlParser::ConstructL();
    }


CIAUpdateEngineXmlParser::~CIAUpdateEngineXmlParser()
    {
    delete iConfigData;
    }


void CIAUpdateEngineXmlParser::ParseL()
    {
    // Reset the config data pefore starting to set new values there.
    // For example if the parsing has been done before and the config file 
    // content has changed, then old values that are not parsed now, will not
    // be left hanging.
    iConfigData->ResetL();
    ParsePrivateFileL( IAUpdateEngineConfigConsts::KConfigFile );        
    }


const CIAUpdateEngineConfigData& CIAUpdateEngineXmlParser::ConfigData() const
    {
    return *iConfigData;
    }