|
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 <xml/documentparameters.h> |
|
21 #include <xml/taginfo.h> |
|
22 #include <xml/attribute.h> |
|
23 |
|
24 #include "iaupdateinterdepxmlparser.h" |
|
25 #include "iaupdatenodedependencyimpl.h" |
|
26 #include "iaupdatenodeversionfloorxmlparser.h" |
|
27 #include "iaupdatenodeversionroofxmlparser.h" |
|
28 #include "iaupdatenodeuidxmlparser.h" |
|
29 #include "iaupdatenodeembeddedxmlparser.h" |
|
30 #include "iaupdateprotocolconsts.h" |
|
31 |
|
32 |
|
33 CIAUpdateInterDepXmlParser* CIAUpdateInterDepXmlParser::NewL( |
|
34 RPointerArray< CIAUpdateNodeDependency >& aDependencies ) |
|
35 { |
|
36 CIAUpdateInterDepXmlParser* self = |
|
37 CIAUpdateInterDepXmlParser::NewLC( aDependencies ); |
|
38 CleanupStack::Pop( self ); |
|
39 return self; |
|
40 } |
|
41 |
|
42 |
|
43 CIAUpdateInterDepXmlParser* CIAUpdateInterDepXmlParser::NewLC( |
|
44 RPointerArray< CIAUpdateNodeDependency >& aDependencies ) |
|
45 { |
|
46 CIAUpdateInterDepXmlParser* self = |
|
47 new( ELeave ) CIAUpdateInterDepXmlParser( aDependencies ); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 CIAUpdateInterDepXmlParser::CIAUpdateInterDepXmlParser( |
|
55 RPointerArray< CIAUpdateNodeDependency >& aDependencies ) |
|
56 : CIAUpdateXmlSubParser(), |
|
57 iDependencies( aDependencies ) |
|
58 { |
|
59 |
|
60 } |
|
61 |
|
62 |
|
63 void CIAUpdateInterDepXmlParser::ConstructL() |
|
64 { |
|
65 CIAUpdateXmlSubParser::ConstructL( IAUpdateProtocolConsts::KNodeDependency() ); |
|
66 |
|
67 // Add sub parsers to the list |
|
68 |
|
69 // Notice! Because this parser may be used for multiple dependencies, the sub parsers |
|
70 // that are created here will take a pointer reference as their parameter. This way, |
|
71 // when the member variable changes here when dependency object is created, the sub parsers |
|
72 // are able to use the correct object when setting values. |
|
73 |
|
74 CIAUpdateNodeVersionXmlParser* versionFloorParser( |
|
75 CIAUpdateNodeVersionFloorXmlParser::NewLC( iDependency ) ); |
|
76 SubParsers().AppendL( versionFloorParser ); |
|
77 CleanupStack::Pop( versionFloorParser ); |
|
78 |
|
79 CIAUpdateNodeVersionXmlParser* versionRoofParser( |
|
80 CIAUpdateNodeVersionRoofXmlParser::NewLC( iDependency ) ); |
|
81 SubParsers().AppendL( versionRoofParser ); |
|
82 CleanupStack::Pop( versionRoofParser ); |
|
83 |
|
84 CIAUpdateNodeUidXmlParser* uidParser( |
|
85 CIAUpdateNodeUidXmlParser::NewLC( iDependency ) ); |
|
86 SubParsers().AppendL( uidParser ); |
|
87 CleanupStack::Pop( uidParser ); |
|
88 |
|
89 CIAUpdateNodeEmbeddedXmlParser* embeddedParser( |
|
90 CIAUpdateNodeEmbeddedXmlParser::NewLC( iDependency ) ); |
|
91 SubParsers().AppendL( embeddedParser ); |
|
92 CleanupStack::Pop( embeddedParser ); |
|
93 } |
|
94 |
|
95 |
|
96 CIAUpdateInterDepXmlParser::~CIAUpdateInterDepXmlParser() |
|
97 { |
|
98 // Delete the dependency if it has been left hanging for some reason. |
|
99 delete iDependency; |
|
100 } |
|
101 |
|
102 |
|
103 void CIAUpdateInterDepXmlParser::OnStartElementL( const Xml::RTagInfo& aElement, |
|
104 const Xml::RAttributeArray& aAttributes, |
|
105 TInt aErrorCode ) |
|
106 { |
|
107 // Let the parent do forwarding to the sub parsers if necessary. |
|
108 CIAUpdateXmlSubParser::OnStartElementL( aElement, aAttributes, aErrorCode ); |
|
109 |
|
110 // If the element is for this element, then create a new dependency object that will |
|
111 // be inserted to the dependency array when this element has been handled. |
|
112 if ( AcceptData() ) |
|
113 { |
|
114 // Element parameter is for this class object. |
|
115 // If for some reason dependency has been hanging because of some error situation |
|
116 delete iDependency; |
|
117 iDependency = NULL; |
|
118 iDependency = CIAUpdateNodeDependency::NewL(); |
|
119 } |
|
120 } |
|
121 |
|
122 void CIAUpdateInterDepXmlParser::OnEndElementL( const Xml::RTagInfo& aElement, |
|
123 TInt aErrorCode ) |
|
124 { |
|
125 // Let the parent do forwarding to the sub parsers if necessary. |
|
126 CIAUpdateXmlSubParser::OnEndElementL( aElement, aErrorCode ); |
|
127 |
|
128 if ( IsElementEnded() |
|
129 && iDependency ) |
|
130 { |
|
131 // Element parameter is for this class object. |
|
132 // Append the handled dependency into the dependency array. |
|
133 iDependencies.AppendL( iDependency ); |
|
134 iDependency = NULL; |
|
135 } |
|
136 } |