|
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 CUpnpScpdContentHandler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "upnpscpdcontenthandler.h" |
|
20 #include "upnpcontenthandlerscontroller.h" |
|
21 #include "upnpignorecontenthandler.h" |
|
22 #include "upnpactionlistcontenthandler.h" |
|
23 #include "upnpservicestatetablecontenthandler.h" |
|
24 #include "upnpservice.h" |
|
25 #include "upnpserviceliterals.h" |
|
26 |
|
27 //const TUint8 KReqiuredTagsBoundary(1) //first bit (no missing specVersion checking) |
|
28 const TUint8 KReqiuredTagsBoundary(0); //no required tag checking for now |
|
29 enum TFlagsPositions |
|
30 { |
|
31 EServiceStateTable = 0, |
|
32 //ESpecVersion, //no missing/repeated specVersion checking |
|
33 EActionList //optional |
|
34 }; |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CUpnpScpdContentHandler::NewL |
|
38 // Two-phased constructor |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CUpnpScpdContentHandler* CUpnpScpdContentHandler::NewL( |
|
42 CUpnpContentHandlersController& aController, CUpnpService& aResultService ) |
|
43 { |
|
44 CUpnpScpdContentHandler* scpdContentHandler = |
|
45 CUpnpScpdContentHandler::NewLC( aController, aResultService ); |
|
46 CleanupStack::Pop( scpdContentHandler ); |
|
47 return scpdContentHandler; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CUpnpScpdContentHandler::NewLC |
|
52 // Two-phased constructor. Leaves teh object on the CleanupStack |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CUpnpScpdContentHandler* CUpnpScpdContentHandler::NewLC( |
|
56 CUpnpContentHandlersController& aController, CUpnpService& aResultService ) |
|
57 { |
|
58 CUpnpScpdContentHandler* scpdContentHandler = |
|
59 new (ELeave) CUpnpScpdContentHandler( aController, aResultService ); |
|
60 CleanupStack::PushL( scpdContentHandler ); |
|
61 return scpdContentHandler; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CUpnpScpdContentHandler::~CUpnpScpdContentHandler |
|
66 // Destructor of CUpnpScpdContentHandler class |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CUpnpScpdContentHandler::~CUpnpScpdContentHandler() |
|
70 { |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CUpnpScpdContentHandler::CUpnpScpdContentHandler |
|
75 // Constructor |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CUpnpScpdContentHandler::CUpnpScpdContentHandler( |
|
79 CUpnpContentHandlersController& aController, CUpnpService& aResultService ) : |
|
80 CUpnpContentHandler( aController ), iResultService( aResultService ) |
|
81 { |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CUpnpScpdContentHandler::OnStartElementL |
|
86 // This method is a callback to indicate an element has been parsed. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CUpnpScpdContentHandler::OnStartElementL( const RTagInfo& aElement, |
|
90 const RAttributeArray& /*aAttributes*/ ) |
|
91 { |
|
92 TPtrC8 elementName(aElement.LocalName().DesC() ); |
|
93 if ( elementName.Compare( KUpnpActionList ) == 0 ) |
|
94 { |
|
95 RepeatedTagCheckL( EActionList, iFoundTags ); |
|
96 iController.SetCurrentContentHandlerL( CUpnpActionListContentHandler::NewL( |
|
97 iController, iResultService ) ); |
|
98 } |
|
99 else |
|
100 if ( elementName.Compare( KUpnpServiceStateTable ) == 0 ) |
|
101 { |
|
102 RepeatedTagCheckL( EServiceStateTable, iFoundTags ); |
|
103 iController.SetCurrentContentHandlerL( |
|
104 CUpnpServiceStateTableContentHandler::NewL( |
|
105 iController, iResultService ) ); |
|
106 } |
|
107 //not checked by current version |
|
108 // else if ( elementName.Compare(KUpnpSpecVersion) == 0 ) |
|
109 // { |
|
110 // RepeatedTagCheckL( ESpecVersion, iFoundTags ) |
|
111 // iController.SetCurrentContentHandlerL( |
|
112 // CUpnpSpecVersionContentHandler::NewL( iController ) |
|
113 // ) |
|
114 // } |
|
115 else |
|
116 { |
|
117 iController.SetCurrentContentHandlerL( |
|
118 CUpnpIgnoreContentHandler::NewL( iController ) ); |
|
119 } |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CUpnpScpdContentHandler::OnEndElementL |
|
124 // This method is a callback to indicate the end of the element has been reached. |
|
125 // |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CUpnpScpdContentHandler::OnEndElementL( const RTagInfo& aElement ) |
|
129 { |
|
130 ASSERT( aElement.LocalName().DesC().Compare(KUpnpScpd) == 0 ); |
|
131 if ( ( iFoundTags.iFlags & KReqiuredTagsBoundary ) == KReqiuredTagsBoundary ) |
|
132 { |
|
133 iResultService.SetArgumentTypes(); |
|
134 iController.SetPreviousContentHandler(); |
|
135 } |
|
136 else |
|
137 { |
|
138 User::Leave( KErrArgument ); //required tag not found |
|
139 } |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CUpnpScpdContentHandler::OnContentL |
|
144 // This method is a callback that sends the content of the element. |
|
145 // aErrorCode must be KErrNone, and that aBytes should contains complete |
|
146 // content (one chunk). |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CUpnpScpdContentHandler::OnContentL( const TDesC8& /*aBytes*/ ) |
|
150 { |
|
151 //User::Leave( KErrArgument ) |
|
152 } |
|
153 |
|
154 // End of File |