|
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 CUpnpActionContentHandler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "upnpallowedvaluelistcontenthandler.h" |
|
20 #include "upnpcontenthandlerscontroller.h" |
|
21 #include "upnpignorecontenthandler.h" |
|
22 #include "upnpstatevariable.h" |
|
23 #include "upnpserviceliterals.h" |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CUpnpAllowedValueListContentHandler::NewL |
|
27 // Two-phased constructor |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CUpnpAllowedValueListContentHandler* CUpnpAllowedValueListContentHandler::NewL( |
|
31 CUpnpContentHandlersController& aController, |
|
32 CUpnpStateVariable& aResultStateVariable ) |
|
33 { |
|
34 CUpnpAllowedValueListContentHandler* actionContentHandler = |
|
35 CUpnpAllowedValueListContentHandler::NewLC( aController, aResultStateVariable ); |
|
36 CleanupStack::Pop( actionContentHandler ); |
|
37 return actionContentHandler; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CUpnpAllowedValueListContentHandler::NewLC |
|
42 // Two-phased constructor. Leaves teh object on the CleanupStack |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CUpnpAllowedValueListContentHandler* CUpnpAllowedValueListContentHandler::NewLC( |
|
46 CUpnpContentHandlersController& aController, |
|
47 CUpnpStateVariable& aResultStateVariable ) |
|
48 { |
|
49 CUpnpAllowedValueListContentHandler* actionContentHandler = |
|
50 new (ELeave) CUpnpAllowedValueListContentHandler(aController, |
|
51 aResultStateVariable); |
|
52 CleanupStack::PushL( actionContentHandler ); |
|
53 return actionContentHandler; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CUpnpAllowedValueListContentHandler::~CUpnpAllowedValueListContentHandler |
|
58 // Destructor of CUpnpAllowedValueListContentHandler class |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CUpnpAllowedValueListContentHandler::~CUpnpAllowedValueListContentHandler() |
|
62 { |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CUpnpAllowedValueListContentHandler::CUpnpAllowedValueListContentHandler |
|
67 // Constructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CUpnpAllowedValueListContentHandler::CUpnpAllowedValueListContentHandler( |
|
71 CUpnpContentHandlersController& aController, |
|
72 CUpnpStateVariable& aResultStateVariable ) : |
|
73 CUpnpContentHandler( aController ), |
|
74 iResultStateVariable( aResultStateVariable ), |
|
75 iIsInsideAllowedValue( EFalse ) |
|
76 { |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CUpnpAllowedValueListContentHandler::OnStartElementL |
|
81 // This method is a callback to indicate an element has been parsed. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CUpnpAllowedValueListContentHandler::OnStartElementL( |
|
85 const RTagInfo& aElement, const RAttributeArray& /*aAttributes*/ ) |
|
86 { |
|
87 if ( !iIsInsideAllowedValue ) |
|
88 { |
|
89 const TDesC8& elementName( aElement.LocalName().DesC() ); |
|
90 if ( elementName.Compare( KUpnpAllowedValue ) == 0 ) |
|
91 { |
|
92 iIsInsideAllowedValue = ETrue; |
|
93 } |
|
94 else |
|
95 { |
|
96 iController.SetCurrentContentHandlerL( |
|
97 CUpnpIgnoreContentHandler::NewL( iController ) ); |
|
98 } |
|
99 } |
|
100 else |
|
101 { |
|
102 iController.SetCurrentContentHandlerL( |
|
103 CUpnpIgnoreContentHandler::NewL( iController ) ); |
|
104 //User::Leave( KErrArgument ) //content="textOnly" not checked now |
|
105 } |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CUpnpAllowedValueListContentHandler::OnEndElementL |
|
110 // This method is a callback to indicate the end of the element has been reached. |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CUpnpAllowedValueListContentHandler::OnEndElementL( const RTagInfo& aElement ) |
|
114 { |
|
115 if ( iIsInsideAllowedValue ) |
|
116 { |
|
117 ASSERT( aElement.LocalName().DesC().Compare(KUpnpAllowedValue) == 0 ); |
|
118 iIsInsideAllowedValue = EFalse; |
|
119 } |
|
120 else |
|
121 { |
|
122 ASSERT(aElement.LocalName().DesC().Compare(KUpnpAllowedValueList)==0); |
|
123 iController.SetPreviousContentHandler(); |
|
124 |
|
125 } |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CUpnpAllowedValueListContentHandler::OnContentL |
|
130 // This method is a callback that sends the content of the element. |
|
131 // aErrorCode must be KErrNone, and that aBytes should contains complete |
|
132 // content (one chunk). |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CUpnpAllowedValueListContentHandler::OnContentL( const TDesC8& aBytes ) |
|
136 { |
|
137 if ( iIsInsideAllowedValue ) |
|
138 { |
|
139 iResultStateVariable.AddAllowedValueL( aBytes ); |
|
140 } |
|
141 else |
|
142 { |
|
143 //User::Leave( KErrArgument ) |
|
144 } |
|
145 } |
|
146 |
|
147 // End of File |