1 /* |
|
2 * Copyright (c) 2002 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: XML parser implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <xml/parser.h> |
|
21 #include "BTSUXmlParser.h" |
|
22 #include "BTServiceUtils.h" |
|
23 #include "BTSUCapabilityResolver.h" |
|
24 #include "BTSURefObjectResolver.h" |
|
25 #include "BTSUDebug.h" |
|
26 |
|
27 |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CBTSUXmlParser::CBTSUXmlParser |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CBTSUXmlParser::CBTSUXmlParser() |
|
38 { |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CBTSUXmlParser::ConstructL |
|
43 // Symbian 2nd phase constructor can leave. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void CBTSUXmlParser::ConstructL() |
|
47 { |
|
48 FLOG(_L("[BTSU]\t CBTSUXmlParser::ConstructL()")); |
|
49 |
|
50 User::LeaveIfError( iFileSession.Connect() ); |
|
51 |
|
52 FLOG(_L("[BTSU]\t CBTSUXmlParser::ConstructL() completed")); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CBTSUXmlParser::NewL |
|
57 // Two-phased constructor. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CBTSUXmlParser* CBTSUXmlParser::NewL() |
|
61 { |
|
62 CBTSUXmlParser* self = new( ELeave ) CBTSUXmlParser; |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop(); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // Destructor |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CBTSUXmlParser::~CBTSUXmlParser() |
|
74 { |
|
75 FLOG(_L("[BTSU]\t CBTSUXmlParser::~CBTSUXmlParser()")); |
|
76 |
|
77 iFileSession.Close(); |
|
78 |
|
79 FLOG(_L("[BTSU]\t CBTSUXmlParser::~CBTSUXmlParser() completed")); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CBTSUXmlParser::GetCapabilityListL |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 CDesCArrayFlat* CBTSUXmlParser::GetCapabilityListL( const TDesC& /*aFileName */) |
|
87 { |
|
88 return NULL; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CBTSUXmlParser::GetCapabilityListL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 RArray<TBTSUImageCap>* CBTSUXmlParser::GetImgCapabilityListL( const TDesC& aFileName ) |
|
96 { |
|
97 FLOG(_L("[BTSU]\t CBTSUXmlParser::GetCapabilityListL()")); |
|
98 |
|
99 if ( &aFileName == NULL || |
|
100 aFileName.Length() == 0 || |
|
101 aFileName.Length() > KMaxFileName ) |
|
102 { |
|
103 User::Leave( KErrArgument ); |
|
104 } |
|
105 |
|
106 // Create result array |
|
107 // |
|
108 RArray<TBTSUImageCap>* array = new (ELeave) RArray<TBTSUImageCap>(); |
|
109 CleanupStack::PushL( array ); |
|
110 |
|
111 // Set content handler |
|
112 // |
|
113 CBTSUCapabilityResolver *resolver = CBTSUCapabilityResolver::NewL( array ); |
|
114 CleanupStack::PushL(resolver); |
|
115 // Create parser |
|
116 // |
|
117 Xml::CParser *parser=Xml::CParser::NewL( _L8( "text/xml" ), *resolver ); |
|
118 CleanupStack::PushL(parser); |
|
119 // Parse |
|
120 // |
|
121 Xml::ParseL(*parser, iFileSession, aFileName); |
|
122 |
|
123 if(!resolver->IsCompleted()) |
|
124 { |
|
125 User::Leave(KErrCompletion); |
|
126 } |
|
127 |
|
128 |
|
129 CleanupStack::PopAndDestroy(2); //parser & resolver |
|
130 CleanupStack::Pop( array ); |
|
131 |
|
132 |
|
133 FLOG(_L("[BTSU]\t CBTSUXmlParser::GetCapabilityListL() completed")); |
|
134 |
|
135 return array; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CBTSUXmlParser::GetRefObjectListL |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 CDesCArrayFlat* CBTSUXmlParser::GetRefObjectListL( const TDesC& aFileName ) |
|
143 { |
|
144 FLOG(_L("[BTSU]\t CBTSUXmlParser::GetRefObjectListL()")); |
|
145 |
|
146 if ( &aFileName == NULL || |
|
147 aFileName.Length() == 0 || |
|
148 aFileName.Length() > KMaxFileName ) |
|
149 { |
|
150 User::Leave( KErrArgument ); |
|
151 } |
|
152 |
|
153 // Create result array |
|
154 // |
|
155 CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat( KBTSUArrayGranularity ); |
|
156 CleanupStack::PushL( array ); |
|
157 |
|
158 // Set content handler |
|
159 // |
|
160 CBTSURefObjectResolver *resolver = CBTSURefObjectResolver::NewL( array ); |
|
161 CleanupStack::PushL(resolver); |
|
162 // Create parser |
|
163 // |
|
164 Xml::CParser *parser = Xml::CParser::NewL( _L8( "text/xml" ), *resolver ); |
|
165 CleanupStack::PushL( parser ); |
|
166 // Parse |
|
167 // |
|
168 Xml::ParseL(*parser, iFileSession, aFileName); |
|
169 |
|
170 CleanupStack::PopAndDestroy(2); // parser & resolver |
|
171 CleanupStack::Pop( array ); |
|
172 |
|
173 FLOG(_L("[BTSU]\t CBTSUXmlParser::GetRefObjectListL() completed")); |
|
174 |
|
175 return array; |
|
176 } |
|
177 |
|
178 // End of File |
|