|
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: CNcdPreminetProtocolMessagesParser implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdunknownparser.h" |
|
20 #include "ncdprotocolwords.h" |
|
21 #include "ncdprotocolutils.h" |
|
22 #include "ncd_cp_detailimpl.h" |
|
23 #include "ncd_parser_pp_messages.h" |
|
24 #include "ncd_parser_cp_query.h" |
|
25 #include "catalogsdebug.h" |
|
26 #include "ncd_cp_query.h" |
|
27 |
|
28 CNcdPreminetProtocolMessagesParser* |
|
29 CNcdPreminetProtocolMessagesParser::NewL( MNcdParserObserverBundle& aObservers, |
|
30 MNcdSubParserObserver& aSubParserObserver, |
|
31 TInt aDepth, |
|
32 const Xml::RTagInfo& aElement, |
|
33 const Xml::RAttributeArray& aAttributes ) |
|
34 { |
|
35 CNcdPreminetProtocolMessagesParser* self |
|
36 = new(ELeave) CNcdPreminetProtocolMessagesParser( aObservers, |
|
37 aSubParserObserver, |
|
38 aDepth ); |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL( aElement, aAttributes ); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 CNcdPreminetProtocolMessagesParser::CNcdPreminetProtocolMessagesParser( MNcdParserObserverBundle& aObservers, |
|
46 MNcdSubParserObserver& aSubParserObserver, |
|
47 TInt aDepth ) |
|
48 : CNcdSubParser( aObservers, aSubParserObserver, aDepth ) |
|
49 { |
|
50 } |
|
51 |
|
52 CNcdPreminetProtocolMessagesParser::~CNcdPreminetProtocolMessagesParser() |
|
53 { |
|
54 delete iMessages; |
|
55 iMessages = 0; |
|
56 } |
|
57 |
|
58 void CNcdPreminetProtocolMessagesParser::ConstructL( |
|
59 const Xml::RTagInfo& aElement, const Xml::RAttributeArray& /*aAttributes*/ ) |
|
60 { |
|
61 CNcdSubParser::ConstructL( aElement ); |
|
62 iMessages = new(ELeave) CArrayPtrFlat<MNcdConfigurationProtocolQuery>( 4 ); |
|
63 } |
|
64 |
|
65 void CNcdPreminetProtocolMessagesParser::OnStartElementL( const Xml::RTagInfo& aElement, |
|
66 const Xml::RAttributeArray& aAttributes, |
|
67 TInt aErrorCode ) |
|
68 { |
|
69 if( iSubParser == 0 ) |
|
70 { |
|
71 CNcdSubParser::OnStartElementL( aElement, aAttributes, aErrorCode ); |
|
72 |
|
73 TPtrC8 tag( aElement.LocalName().DesC() ); |
|
74 |
|
75 if( tag == KTagMessage ) |
|
76 { |
|
77 iSubParser = CNcdConfigurationProtocolQueryParser::NewL( *iObservers, *this, iDepth+1, aElement, aAttributes ); |
|
78 } |
|
79 |
|
80 else |
|
81 { |
|
82 iSubParser = CNcdUnknownParser::NewL( *iObservers, *this, iDepth+1, aElement, aAttributes ); |
|
83 } |
|
84 } |
|
85 else |
|
86 { |
|
87 iSubParser->OnStartElementL( aElement, aAttributes, aErrorCode ); |
|
88 } |
|
89 } |
|
90 |
|
91 |
|
92 void CNcdPreminetProtocolMessagesParser::OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode) |
|
93 { |
|
94 DLTRACEIN(("")); |
|
95 if( iSubParser == 0 && iTag && *iTag == aElement.LocalName().DesC() ) |
|
96 { |
|
97 DLTRACE(("end tag=%S",&aElement.LocalName().DesC())); |
|
98 iSubParserObserver->SubParserFinishedL( aElement.LocalName().DesC(), aErrorCode ); |
|
99 } |
|
100 else if( iSubParser ) |
|
101 { |
|
102 iSubParser->OnEndElementL( aElement, aErrorCode ); |
|
103 } |
|
104 else |
|
105 { |
|
106 DLWARNING(("end tag ignored, tag=%S",&aElement.LocalName().DesC())); |
|
107 } |
|
108 } |
|
109 |
|
110 void CNcdPreminetProtocolMessagesParser::SubParserFinishedL( const TDesC8& aTag, TInt /*aErrorCode*/ ) |
|
111 { |
|
112 DLTRACE(("tag=%S subparser=%X",&aTag,iSubParser)); |
|
113 |
|
114 if( aTag == KTagMessage ) |
|
115 { |
|
116 MNcdConfigurationProtocolQuery* message = |
|
117 static_cast<CNcdConfigurationProtocolQueryParser*>( iSubParser )->Query(); |
|
118 CleanupDeletePushL( message ); |
|
119 iMessages->AppendL( message ); |
|
120 CleanupStack::Pop( message ); |
|
121 } |
|
122 |
|
123 delete iSubParser; |
|
124 iSubParser = 0; |
|
125 } |
|
126 |
|
127 CArrayPtr<MNcdConfigurationProtocolQuery>* CNcdPreminetProtocolMessagesParser::Messages() |
|
128 { |
|
129 CArrayPtr<MNcdConfigurationProtocolQuery>* returnPtr = iMessages; |
|
130 iMessages = 0; |
|
131 return returnPtr; |
|
132 } |
|
133 |