|
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 "rootserviceparser.h" |
|
19 #include <upnpdescriptionschema.h> |
|
20 #include "specversionparser.h" |
|
21 #include "cactionparser.h" |
|
22 #include "cstatetableparser.h" |
|
23 |
|
24 _LIT8(KXmlMimeType1, "text/xml"); |
|
25 |
|
26 CRootServiceParser* CRootServiceParser::NewL(CUPnPServiceDescription *aServiceParser, const RStringPool& aStringPool) |
|
27 { |
|
28 CRootServiceParser* self = new (ELeave) CRootServiceParser(aServiceParser, aStringPool); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 CRootServiceParser::CRootServiceParser(CUPnPServiceDescription *aServiceDesc, const RStringPool& aStringPool) : iServiceDesc(aServiceDesc), iStringPool(aStringPool) |
|
36 { |
|
37 } |
|
38 |
|
39 void CRootServiceParser::ConstructL() |
|
40 { |
|
41 iXmlParser = CParser::NewL(KXmlMimeType1(), *this); |
|
42 iXmlParser->EnableFeature(EReportNamespaceMapping ); |
|
43 iXmlParser->EnableFeature(ESendFullContentInOneChunk); |
|
44 } |
|
45 |
|
46 CRootServiceParser::~CRootServiceParser() |
|
47 { |
|
48 delete iXmlParser; |
|
49 } |
|
50 |
|
51 void CRootServiceParser::StartParseL(const TDesC8& aFragment) |
|
52 { |
|
53 ParseL(*iXmlParser, aFragment); |
|
54 } |
|
55 |
|
56 void CRootServiceParser::ParseStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes) |
|
57 { |
|
58 iSiblingsCount++; |
|
59 iString = iStringPool.OpenStringL(aElement.LocalName().DesC()); |
|
60 TInt tblIndex = iString.Index ( UPNPDESCRIPTIONXMLTAGS::Table ); |
|
61 |
|
62 switch(tblIndex) |
|
63 { |
|
64 case UPNPDESCRIPTIONXMLTAGS::ESpecVersion: |
|
65 { |
|
66 CSpecVersionParser* specParser = CSpecVersionParser::NewL(iServiceDesc, iStringPool); |
|
67 CleanupStack::PushL( specParser ); |
|
68 StartChildParserL(specParser, aElement, aAttributes); |
|
69 CleanupStack::Pop( specParser ); |
|
70 iSiblingsCount--; |
|
71 } |
|
72 break; |
|
73 |
|
74 case UPNPDESCRIPTIONXMLTAGS::EAction: |
|
75 { |
|
76 CUPnPAction* action = CUPnPAction::NewL(); |
|
77 iServiceDesc->AppendToActionList( action ); |
|
78 CActionParser* actionParser = CActionParser::NewL(action, iStringPool); |
|
79 CleanupStack::PushL(actionParser); |
|
80 StartChildParserL(actionParser, aElement, aAttributes); |
|
81 CleanupStack::Pop( actionParser ); |
|
82 iSiblingsCount--; |
|
83 } |
|
84 break; |
|
85 |
|
86 case UPNPDESCRIPTIONXMLTAGS::EStateVariable: |
|
87 { |
|
88 CUPnPStateVariable* stateVariable = CUPnPStateVariable::NewL(); |
|
89 CleanupStack::PushL( stateVariable ); |
|
90 iServiceDesc->AppendToServiceStateTable( stateVariable ); |
|
91 CleanupStack::Pop( stateVariable ); |
|
92 CStateTableParser* stateTableParser = CStateTableParser::NewL(stateVariable, iStringPool); |
|
93 CleanupStack::PushL( stateTableParser ); |
|
94 StartChildParserL(stateTableParser , aElement, aAttributes); |
|
95 CleanupStack::Pop( stateTableParser ); |
|
96 iSiblingsCount--; |
|
97 } |
|
98 break; |
|
99 |
|
100 //default: Don't do anything |
|
101 |
|
102 } |
|
103 |
|
104 } |
|
105 |
|
106 void CRootServiceParser::ParseEndElementL(const RTagInfo& /*aElement*/) |
|
107 { |
|
108 iSiblingsCount--; |
|
109 iString.Close(); |
|
110 } |
|
111 |
|
112 void CRootServiceParser::ParseContentL(const TDesC8& /*aBytes*/) |
|
113 { |
|
114 } |
|
115 |
|
116 |