|
1 /* |
|
2 * Copyright (c) 2006 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: CNcdConfigurationProtocolClientConfigurationParser implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdunknownparser.h" |
|
20 #include "ncdprotocolwords.h" |
|
21 #include "ncdprotocolutils.h" |
|
22 |
|
23 #include "ncd_parser_cp_clientconfiguration.h" |
|
24 #include "ncd_parser_cp_cookie.h" |
|
25 #include "ncd_parser_cp_details.h" |
|
26 #include "ncd_cp_clientconfigurationimpl.h" |
|
27 |
|
28 #include "catalogsdebug.h" |
|
29 |
|
30 CNcdConfigurationProtocolClientConfigurationParser* |
|
31 CNcdConfigurationProtocolClientConfigurationParser::NewL( MNcdParserObserverBundle& aObservers, |
|
32 MNcdSubParserObserver& aSubParserObserver, |
|
33 TInt aDepth, |
|
34 const Xml::RTagInfo& aElement, |
|
35 const Xml::RAttributeArray& aAttributes, |
|
36 const TDesC& aParentId ) |
|
37 { |
|
38 CNcdConfigurationProtocolClientConfigurationParser* self |
|
39 = new(ELeave) CNcdConfigurationProtocolClientConfigurationParser( aObservers, |
|
40 aSubParserObserver, |
|
41 aDepth ); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL( aElement, aAttributes, aParentId ); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 |
|
49 CNcdConfigurationProtocolClientConfigurationParser* |
|
50 CNcdConfigurationProtocolClientConfigurationParser::NewL( MNcdParserObserverBundle& aObservers, |
|
51 MNcdSubParserObserver& aSubParserObserver, |
|
52 TInt aDepth ) |
|
53 { |
|
54 CNcdConfigurationProtocolClientConfigurationParser* self |
|
55 = new(ELeave) CNcdConfigurationProtocolClientConfigurationParser( aObservers, |
|
56 aSubParserObserver, |
|
57 aDepth ); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 CNcdConfigurationProtocolClientConfigurationParser::CNcdConfigurationProtocolClientConfigurationParser( |
|
65 MNcdParserObserverBundle& aObservers, |
|
66 MNcdSubParserObserver& aSubParserObserver, |
|
67 TInt aDepth ) |
|
68 : CNcdSubParser( aObservers, aSubParserObserver, aDepth ) |
|
69 { |
|
70 } |
|
71 |
|
72 CNcdConfigurationProtocolClientConfigurationParser::~CNcdConfigurationProtocolClientConfigurationParser() |
|
73 { |
|
74 delete iClientConfiguration; |
|
75 iClientConfiguration = 0; |
|
76 } |
|
77 |
|
78 void CNcdConfigurationProtocolClientConfigurationParser::ConstructL( const Xml::RTagInfo& aElement, |
|
79 const Xml::RAttributeArray& aAttributes, |
|
80 const TDesC& aParentId ) |
|
81 { |
|
82 CNcdSubParser::ConstructL( aElement ); |
|
83 |
|
84 DLTRACEIN(("depth=%d tag=%S",iDepth,iTag)); |
|
85 DLINFO((_L("parent=%S"),&aParentId)); |
|
86 (void) aParentId; // suppresses compiler warning |
|
87 |
|
88 iClientConfiguration = CNcdConfigurationProtocolClientConfigurationImpl::NewL(); |
|
89 |
|
90 // attributes |
|
91 |
|
92 // expirationDelta |
|
93 TPtrC8 expDelta = AttributeValue( KAttrConfExpirationDelta, aAttributes ); |
|
94 if( expDelta != KNullDesC8 ) |
|
95 { |
|
96 iClientConfiguration->iExpirationDelta = NcdProtocolUtils::DesDecToIntL( expDelta ); |
|
97 } |
|
98 } |
|
99 |
|
100 |
|
101 void CNcdConfigurationProtocolClientConfigurationParser::ConstructL() |
|
102 { |
|
103 DLTRACEIN(("")); |
|
104 |
|
105 iClientConfiguration = CNcdConfigurationProtocolClientConfigurationImpl::NewL(); |
|
106 |
|
107 } |
|
108 |
|
109 |
|
110 void CNcdConfigurationProtocolClientConfigurationParser::OnStartElementL( const Xml::RTagInfo& aElement, |
|
111 const Xml::RAttributeArray& aAttributes, |
|
112 TInt aErrorCode) |
|
113 { |
|
114 if( iSubParser ) |
|
115 { |
|
116 // Use existing subparser. |
|
117 iSubParser->OnStartElementL( aElement, aAttributes, aErrorCode ); |
|
118 } |
|
119 else |
|
120 { |
|
121 CNcdSubParser::OnStartElementL( aElement, aAttributes, aErrorCode ); |
|
122 |
|
123 TPtrC8 tag( aElement.LocalName().DesC() ); |
|
124 DLTRACE(("client configuration start tag=%S error=%d depth=%d",&aElement.LocalName().DesC(),aErrorCode,iDepth)); |
|
125 |
|
126 if( tag == KTagCookies ) |
|
127 { |
|
128 iSubParser = CNcdConfigurationProtocolCookieParser::NewL( *iObservers, *this, iDepth+1, aElement, aAttributes ); |
|
129 } |
|
130 |
|
131 else if( tag == KTagDetails ) |
|
132 { |
|
133 iSubParser = CNcdConfigurationProtocolDetailsParser::NewL( *iObservers, *this, iDepth+1, aElement, aAttributes ); |
|
134 } |
|
135 |
|
136 else |
|
137 { |
|
138 iSubParser = CNcdUnknownParser::NewL( *iObservers, *this, iDepth+1, aElement, aAttributes ); |
|
139 } |
|
140 } |
|
141 } |
|
142 |
|
143 |
|
144 void CNcdConfigurationProtocolClientConfigurationParser::OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode) |
|
145 { |
|
146 DLTRACEIN(("")); |
|
147 if( iSubParser == 0 && iTag && *iTag == aElement.LocalName().DesC() ) |
|
148 { |
|
149 DLTRACE(("end tag=%S",&aElement.LocalName().DesC())); |
|
150 iSubParserObserver->SubParserFinishedL( aElement.LocalName().DesC(), aErrorCode ); |
|
151 } |
|
152 |
|
153 else if( iSubParser ) |
|
154 { |
|
155 iSubParser->OnEndElementL( aElement, aErrorCode ); |
|
156 } |
|
157 |
|
158 else |
|
159 { |
|
160 DLWARNING(("end tag ignored, tag=%S",&aElement.LocalName().DesC())); |
|
161 } |
|
162 } |
|
163 |
|
164 void CNcdConfigurationProtocolClientConfigurationParser::SubParserFinishedL( const TDesC8& aTag, |
|
165 TInt /*aErrorCode*/ ) |
|
166 { |
|
167 DLTRACE(("tag=%S subparser=%X",&aTag,iSubParser)); |
|
168 |
|
169 |
|
170 if( aTag == KTagCookies && iSubParser ) |
|
171 { |
|
172 CNcdConfigurationProtocolCookieParser* cookieParser = |
|
173 static_cast<CNcdConfigurationProtocolCookieParser*>( iSubParser ); |
|
174 iClientConfiguration->iCookies = cookieParser->Cookies(); |
|
175 } |
|
176 else if( aTag == KTagDetails && iSubParser ) |
|
177 { |
|
178 CNcdConfigurationProtocolDetailsParser* detailParser = |
|
179 static_cast<CNcdConfigurationProtocolDetailsParser*>( iSubParser ); |
|
180 iClientConfiguration->iDetails = detailParser->Details(); |
|
181 } |
|
182 |
|
183 delete iSubParser; |
|
184 iSubParser = 0; |
|
185 } |
|
186 |
|
187 |
|
188 MNcdConfigurationProtocolClientConfiguration* CNcdConfigurationProtocolClientConfigurationParser::ClientConfiguration() |
|
189 { |
|
190 MNcdConfigurationProtocolClientConfiguration* returnPtr = iClientConfiguration; |
|
191 iClientConfiguration = 0; |
|
192 return returnPtr; |
|
193 } |
|
194 |