servicediscoveryandcontrol/pnp/test/upnp/upnpdescription/src/rootdeviceparser.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // rootinfoparser.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "rootdeviceparser.h"
       
    19 #include <upnpdescriptionschema.h>
       
    20 #include "specversionparser.h"
       
    21 #include "deviceinfoparser.h"
       
    22 #include <xml/parserfeature.h>
       
    23 
       
    24 _LIT8(KXmlMimeType1, "text/xml");
       
    25 
       
    26 CRootDeviceParser* CRootDeviceParser::NewL(CUPnPDeviceDescription *aDeviceParser, const RStringPool& aStringPool)
       
    27 	{
       
    28 	CRootDeviceParser* self = new (ELeave) CRootDeviceParser(aDeviceParser, aStringPool);
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL();
       
    31 	CleanupStack::Pop(self);
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 CRootDeviceParser::CRootDeviceParser(CUPnPDeviceDescription *aDeviceDescpn, const RStringPool& aStringPool) 
       
    36 	: iDeviceDescpn(aDeviceDescpn), iStringPool(aStringPool)
       
    37 	{
       
    38 	}
       
    39 
       
    40 void CRootDeviceParser::ConstructL()	
       
    41 	{
       
    42 	iXmlParser = CParser::NewL(KXmlMimeType1(), *this);
       
    43 	iXmlParser->EnableFeature(EReportNamespaceMapping );
       
    44 	iXmlParser->EnableFeature(ESendFullContentInOneChunk);
       
    45 	}
       
    46 
       
    47 CRootDeviceParser::~CRootDeviceParser()
       
    48 	{
       
    49 	delete iXmlParser;
       
    50 	}
       
    51 
       
    52 void CRootDeviceParser::StartParseL(const TDesC8& aFragment)
       
    53 	{
       
    54 	ParseL(*iXmlParser, aFragment); 
       
    55 	}
       
    56 
       
    57 void CRootDeviceParser::ParseStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes)
       
    58 	{
       
    59 	iSiblingsCount++;
       
    60 	iString = iStringPool.OpenStringL(aElement.LocalName().DesC());
       
    61 	
       
    62 	TInt tblIndex = iString.Index ( UPNPDESCRIPTIONXMLTAGS::Table );
       
    63 	// If string lies in the main string table
       
    64 	if (tblIndex == UPNPDESCRIPTIONXMLTAGS::ESpecVersion)
       
    65 		{
       
    66 		iSiblingsCount--;
       
    67 		CSpecVersionParser* specParser = CSpecVersionParser::NewL(iDeviceDescpn, iStringPool);
       
    68 		CleanupStack::PushL(specParser);
       
    69 		StartChildParserL(specParser, aElement, aAttributes);
       
    70 		CleanupStack::Pop(specParser);
       
    71 		}
       
    72 	if ( tblIndex == UPNPDESCRIPTIONXMLTAGS::EDevice)
       
    73 		{
       
    74 		iSiblingsCount--;
       
    75 		CUPnPDevice *deviceInfo = CUPnPDevice::NewL();
       
    76 		CleanupStack::PushL( deviceInfo );
       
    77 		iDeviceDescpn->SetDeviceObjectL(deviceInfo);
       
    78 		CleanupStack::Pop(deviceInfo);
       
    79 		CDeviceInfoParser* deviceParser = CDeviceInfoParser::NewL(deviceInfo, iStringPool);
       
    80 		CleanupStack::PushL(deviceParser);
       
    81 		StartChildParserL(deviceParser, aElement, aAttributes);
       
    82 		CleanupStack::Pop(deviceParser);
       
    83 		}
       
    84 	
       
    85 	}
       
    86 		
       
    87 void CRootDeviceParser::ParseEndElementL(const RTagInfo& /*aElement*/)
       
    88 	{
       
    89 	iSiblingsCount--;
       
    90 	iString.Close();
       
    91 	}
       
    92 
       
    93 void CRootDeviceParser::ParseContentL(const TDesC8& aBytes)
       
    94 	{
       
    95 	if ( !IsBlankSpace( aBytes ) )
       
    96 		iDeviceDescpn->SetPropertyL(iString,aBytes);
       
    97 	}