|
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: CNcdConfigurationProtocolDetailParser implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdunknownparser.h" |
|
20 #include "ncdprotocolwords.h" |
|
21 #include "ncdprotocolutils.h" |
|
22 |
|
23 #include "ncd_parser_pp_datablocks.h" |
|
24 #include "ncd_pp_datablockimpl.h" |
|
25 |
|
26 #include "catalogsdebug.h" |
|
27 |
|
28 CNcdPreminetProtocolDataBlocksParser* |
|
29 CNcdPreminetProtocolDataBlocksParser::NewL( MNcdParserObserverBundle& aObservers, |
|
30 MNcdSubParserObserver& aSubParserObserver, |
|
31 TInt aDepth, |
|
32 const Xml::RTagInfo& aElement, |
|
33 const Xml::RAttributeArray& aAttributes ) |
|
34 { |
|
35 CNcdPreminetProtocolDataBlocksParser* self |
|
36 = new(ELeave) CNcdPreminetProtocolDataBlocksParser( aObservers, |
|
37 aSubParserObserver, |
|
38 aDepth ); |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL( aElement, aAttributes ); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 CNcdPreminetProtocolDataBlocksParser::CNcdPreminetProtocolDataBlocksParser( MNcdParserObserverBundle& aObservers, |
|
46 MNcdSubParserObserver& aSubParserObserver, |
|
47 TInt aDepth ) |
|
48 : CNcdSubParser( aObservers, aSubParserObserver, aDepth ) |
|
49 { |
|
50 } |
|
51 |
|
52 CNcdPreminetProtocolDataBlocksParser::~CNcdPreminetProtocolDataBlocksParser() |
|
53 { |
|
54 if( iDataBlocks ) |
|
55 { |
|
56 iDataBlocks->ResetAndDestroy(); |
|
57 } |
|
58 delete iDataBlocks; |
|
59 iDataBlocks = 0; |
|
60 |
|
61 delete iCurrentDataBlock; |
|
62 iCurrentDataBlock = 0; |
|
63 } |
|
64 |
|
65 void CNcdPreminetProtocolDataBlocksParser::ConstructL( const Xml::RTagInfo& aElement, |
|
66 const Xml::RAttributeArray& /*aAttributes*/ ) |
|
67 { |
|
68 CNcdSubParser::ConstructL( aElement ); |
|
69 iDataBlocks = new(ELeave) CArrayPtrFlat<MNcdPreminetProtocolDataBlock>( 4 ); |
|
70 } |
|
71 |
|
72 void CNcdPreminetProtocolDataBlocksParser::OnStartElementL( const Xml::RTagInfo& aElement, |
|
73 const Xml::RAttributeArray& aAttributes, |
|
74 TInt aErrorCode ) |
|
75 { |
|
76 CNcdSubParser::OnStartElementL( aElement, aAttributes, aErrorCode ); |
|
77 |
|
78 TPtrC8 tag( aElement.LocalName().DesC() ); |
|
79 DLTRACE(("dataBlocks tag=%S error=%d depth=%d",&aElement.LocalName().DesC(),aErrorCode,iDepth)); |
|
80 |
|
81 if( iSubParser ) |
|
82 { |
|
83 // Use existing subparser. |
|
84 iSubParser->OnStartElementL( aElement, aAttributes, aErrorCode ); |
|
85 } |
|
86 else if( tag == KTagDataBlock ) |
|
87 { |
|
88 iCurrentDataBlock = CNcdPreminetProtocolDataBlockImpl::NewL(); |
|
89 |
|
90 // data block attributes |
|
91 // id |
|
92 NcdProtocolUtils::AssignDesL( iCurrentDataBlock->iId, AttributeValue( KAttrId, aAttributes ) ); |
|
93 // name space |
|
94 NcdProtocolUtils::AssignDesL( iCurrentDataBlock->iNameSpace, AttributeValue( KAttrNamespace, aAttributes ) ); |
|
95 |
|
96 } |
|
97 else |
|
98 { |
|
99 iSubParser = CNcdUnknownParser::NewL( *iObservers, *this, iDepth+1, aElement, aAttributes ); |
|
100 } |
|
101 } |
|
102 |
|
103 |
|
104 void CNcdPreminetProtocolDataBlocksParser::OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode) |
|
105 { |
|
106 DLTRACEIN(("")); |
|
107 |
|
108 TPtrC8 tag( aElement.LocalName().DesC() ); |
|
109 DLTRACE(("end tag=%S",&aElement.LocalName().DesC())); |
|
110 |
|
111 if( iSubParser == 0 && iTag && *iTag == aElement.LocalName().DesC() ) |
|
112 { |
|
113 DLTRACE(("end tag=%S",&aElement.LocalName().DesC())); |
|
114 iSubParserObserver->SubParserFinishedL( aElement.LocalName().DesC(), aErrorCode ); |
|
115 } |
|
116 |
|
117 else if( iSubParser ) |
|
118 { |
|
119 iSubParser->OnEndElementL( aElement, aErrorCode ); |
|
120 } |
|
121 |
|
122 else if( tag == KTagDataBlock ) |
|
123 { |
|
124 if( iBuffer ) |
|
125 { |
|
126 iCurrentDataBlock->iContent = NcdProtocolUtils::DecodeBase64L( *iBuffer ); |
|
127 } |
|
128 iDataBlocks->AppendL( iCurrentDataBlock ); |
|
129 iCurrentDataBlock = 0; |
|
130 } |
|
131 |
|
132 else |
|
133 { |
|
134 DLWARNING(("end tag ignored, tag=%S",&aElement.LocalName().DesC())); |
|
135 } |
|
136 } |
|
137 |
|
138 CArrayPtr<MNcdPreminetProtocolDataBlock>* CNcdPreminetProtocolDataBlocksParser::DataBlocks() |
|
139 { |
|
140 CArrayPtr<MNcdPreminetProtocolDataBlock>* returnPtr = iDataBlocks; |
|
141 iDataBlocks = 0; |
|
142 return returnPtr; |
|
143 } |
|
144 |
|
145 void CNcdPreminetProtocolDataBlocksParser::SubParserFinishedL( const TDesC8& aTag, |
|
146 TInt /*aErrorCode*/ ) |
|
147 { |
|
148 DLTRACE(("tag=%S subparser=%X",&aTag,iSubParser)); |
|
149 (void) aTag; // suppresses compiler warning |
|
150 |
|
151 delete iSubParser; |
|
152 iSubParser = 0; |
|
153 } |
|
154 |
|
155 |