|
1 /** @file |
|
2 * Copyright (c) 2007 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: Implements the CUpnpErrorCodeSeekerContentHandler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "upnperrorcodeseekercontenthandler.h" |
|
20 #include "upnpcontenthandlerscontroller.h" |
|
21 #include "upnpsingletagcontenthandler.h" |
|
22 #include "upnpsoapliterals.h" |
|
23 |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CUpnpErrorCodeSeekerContentHandler::NewL |
|
27 // Two-phased constructor |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CUpnpErrorCodeSeekerContentHandler* CUpnpErrorCodeSeekerContentHandler::NewL( |
|
31 CUpnpContentHandlersController& aController, RBuf8& aErrorValue ) |
|
32 { |
|
33 CUpnpErrorCodeSeekerContentHandler* seekerContentHandler = |
|
34 CUpnpErrorCodeSeekerContentHandler::NewLC( aController, aErrorValue ); |
|
35 CleanupStack::Pop( seekerContentHandler ); |
|
36 return seekerContentHandler; |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CUpnpErrorCodeSeekerContentHandler::NewLC |
|
41 // Two-phased constructor. Leaves teh object on the CleanupStack |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CUpnpErrorCodeSeekerContentHandler* CUpnpErrorCodeSeekerContentHandler::NewLC( |
|
45 CUpnpContentHandlersController& aController, RBuf8& aErrorValue ) |
|
46 { |
|
47 CUpnpErrorCodeSeekerContentHandler* seekerContentHandler = |
|
48 new (ELeave) CUpnpErrorCodeSeekerContentHandler( aController, aErrorValue ); |
|
49 CleanupStack::PushL( seekerContentHandler ); |
|
50 return seekerContentHandler; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CUpnpErrorCodeSeekerContentHandler::~CUpnpErrorCodeSeekerContentHandler |
|
55 // Destructor of CUpnpErrorCodeSeekerContentHandler class |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CUpnpErrorCodeSeekerContentHandler::~CUpnpErrorCodeSeekerContentHandler() |
|
59 { |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CUpnpErrorCodeSeekerContentHandler::CUpnpErrorCodeSeekerContentHandler |
|
64 // Constructor |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CUpnpErrorCodeSeekerContentHandler::CUpnpErrorCodeSeekerContentHandler( |
|
68 CUpnpContentHandlersController& aController, RBuf8& aErrorValue ) : |
|
69 CUpnpContentHandler( aController ), iErrorValue( aErrorValue ) |
|
70 { |
|
71 iErrorValue.Zero(); |
|
72 iCurrentState.Set( KUpnpSoapFault ); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CUpnpErrorCodeSeekerContentHandler::OnStartElementL |
|
77 // This method is a callback to indicate an element has been parsed. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CUpnpErrorCodeSeekerContentHandler::OnStartElementL( |
|
81 const RTagInfo& aElement, const RAttributeArray& /*aAttributes*/) |
|
82 { |
|
83 SetNextStateL( aElement.LocalName().DesC() ); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CUpnpErrorCodeSeekerContentHandler::OnEndElementL |
|
88 // This method is a callback to indicate the end of the element has been reached. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CUpnpErrorCodeSeekerContentHandler::OnEndElementL( const RTagInfo& aElement ) |
|
92 { |
|
93 ASSERT( aElement.LocalName().DesC().Compare( iCurrentState ) == 0 ); |
|
94 SetPreviousState(); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CUpnpErrorCodeSeekerContentHandler::OnContentL |
|
99 // This method is a callback that sends the content of the element. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CUpnpErrorCodeSeekerContentHandler::OnContentL( const TDesC8& aBytes ) |
|
103 { |
|
104 if ( iCurrentState == KUpnpSoapErrorCode ) |
|
105 { |
|
106 CUpnpSingleTagContentHandler::SafeCopyL( iErrorValue, aBytes ); |
|
107 } |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CUpnpErrorCodeSeekerContentHandler::InterestedInAllNamespaces |
|
112 // We are interested in tags from all possible namespaces |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TBool CUpnpErrorCodeSeekerContentHandler::InterestedInAllNamespaces() |
|
116 { |
|
117 return ETrue; |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CUpnpErrorCodeSeekerContentHandler::SetNextStateL |
|
122 // Set next state of parsing. If we're interested in particular subtree |
|
123 // state will be handeled by this class, otherwise by ignore handler |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CUpnpErrorCodeSeekerContentHandler::SetNextStateL( |
|
127 const TDesC8& aFoundTagName ) |
|
128 { |
|
129 if ( iCurrentState == KUpnpSoapFault ) |
|
130 { |
|
131 SetParticularNextStateL( KUpnpSoapDetail, aFoundTagName ); |
|
132 } |
|
133 else if ( iCurrentState == KUpnpSoapDetail ) |
|
134 { |
|
135 SetParticularNextStateL( KUpnpSoapError, aFoundTagName ); |
|
136 } |
|
137 else if ( iCurrentState == KUpnpSoapError ) |
|
138 { |
|
139 SetParticularNextStateL( KUpnpSoapErrorCode, aFoundTagName ); |
|
140 } |
|
141 else |
|
142 { |
|
143 SetIgnoreHandlerL(); |
|
144 } |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CUpnpErrorCodeSeekerContentHandler::SetPreviousState() |
|
149 // Set previous state of parsing. When particular tag is ended |
|
150 // state of parsind process should be updated. |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CUpnpErrorCodeSeekerContentHandler::SetPreviousState() |
|
154 { |
|
155 if ( iCurrentState == KUpnpSoapFault ) |
|
156 { |
|
157 iController.SetPreviousContentHandler(); |
|
158 } |
|
159 else if ( iCurrentState == KUpnpSoapDetail ) |
|
160 { |
|
161 iCurrentState.Set( KUpnpSoapFault ); |
|
162 } |
|
163 else if ( iCurrentState == KUpnpSoapError ) |
|
164 { |
|
165 iCurrentState.Set( KUpnpSoapDetail ); |
|
166 } |
|
167 else if ( iCurrentState == KUpnpSoapErrorCode ) |
|
168 { |
|
169 iCurrentState.Set( KUpnpSoapError ); |
|
170 } |
|
171 else |
|
172 { |
|
173 ASSERT( EFalse ); //wrong state |
|
174 } |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CUpnpErrorCodeSeekerContentHandler::SetParticularNextStateL() |
|
179 // Set particular next state of parsing. If we're interested in particular subtree |
|
180 // state will be handeled by this class, otherwise by ignore handler |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void CUpnpErrorCodeSeekerContentHandler::SetParticularNextStateL( |
|
184 const TDesC8& aNextAcceptedState, const TDesC8& aFoundTagName ) |
|
185 { |
|
186 if ( aFoundTagName == aNextAcceptedState ) |
|
187 { |
|
188 iCurrentState.Set( aNextAcceptedState ); |
|
189 } |
|
190 else |
|
191 { |
|
192 SetIgnoreHandlerL(); |
|
193 } |
|
194 } |
|
195 // End of File |