|
1 /** @file |
|
2 * Copyright (c) 2005 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 CUpnpBaseContentHandler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "upnpservicecontenthandler.h" |
|
20 #include "upnpservice.h" |
|
21 #include "upnpcontenthandlerscontroller.h" |
|
22 #include "upnpscpdcontenthandler.h" |
|
23 #include "upnpserviceliterals.h" |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CUpnpServiceContentHandler::NewL |
|
27 // Two-phased constructor |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CUpnpServiceContentHandler* CUpnpServiceContentHandler::NewL( |
|
31 CUpnpContentHandlersController& aController, CUpnpDevice* aParentDevice ) |
|
32 { |
|
33 CUpnpServiceContentHandler* serviceContentHandler = |
|
34 CUpnpServiceContentHandler::NewLC( aController, aParentDevice ); |
|
35 CleanupStack::Pop( serviceContentHandler ); |
|
36 return serviceContentHandler; |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CUpnpServiceContentHandler::NewLC |
|
41 // Two-phased constructor. Leaves teh object on the CleanupStack |
|
42 // ----------------------------------------------------------------------------- |
|
43 CUpnpServiceContentHandler* CUpnpServiceContentHandler::NewLC( |
|
44 CUpnpContentHandlersController& aController, CUpnpDevice* aParentDevice ) |
|
45 { |
|
46 CUpnpServiceContentHandler* serviceContentHandler = |
|
47 new (ELeave) CUpnpServiceContentHandler( aController, aParentDevice ); |
|
48 CleanupStack::PushL( serviceContentHandler ); |
|
49 return serviceContentHandler; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CUpnpServiceContentHandler::NewL |
|
54 // Two-phased constructor |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CUpnpServiceContentHandler* CUpnpServiceContentHandler::NewL( |
|
58 CUpnpContentHandlersController& aController, |
|
59 CUpnpService& aNotOwnedResultService ) |
|
60 { |
|
61 CUpnpServiceContentHandler* serviceContentHandler = |
|
62 CUpnpServiceContentHandler::NewLC( aController, aNotOwnedResultService ); |
|
63 CleanupStack::Pop( serviceContentHandler ); |
|
64 return serviceContentHandler; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CUpnpServiceContentHandler::NewLC |
|
69 // Two-phased constructor. Leaves teh object on the CleanupStack |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CUpnpServiceContentHandler* CUpnpServiceContentHandler::NewLC( |
|
73 CUpnpContentHandlersController& aController, |
|
74 CUpnpService& aNotOwnedResultService ) |
|
75 { |
|
76 CUpnpServiceContentHandler* serviceContentHandler = |
|
77 new (ELeave) CUpnpServiceContentHandler(aController, |
|
78 aNotOwnedResultService); |
|
79 CleanupStack::PushL( serviceContentHandler ); |
|
80 return serviceContentHandler; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CUpnpServiceContentHandler::~CUpnpServiceContentHandler |
|
85 // Destructor of CUpnpServiceContentHandler class |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 CUpnpServiceContentHandler::~CUpnpServiceContentHandler() |
|
89 { |
|
90 if ( iIsServiceOwned ) |
|
91 { |
|
92 delete iResultService; |
|
93 } |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CUpnpServiceContentHandler::CUpnpServiceContentHandler |
|
98 // Constructor |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CUpnpServiceContentHandler::CUpnpServiceContentHandler( |
|
102 CUpnpContentHandlersController& aController, CUpnpDevice* aParentDevice ) : |
|
103 CUpnpContentHandler(aController), iParentDevice(aParentDevice), |
|
104 iIsServiceOwned(ETrue) |
|
105 { |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CUpnpServiceContentHandler::CUpnpServiceContentHandler |
|
110 // Constructor |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 CUpnpServiceContentHandler::CUpnpServiceContentHandler( |
|
114 CUpnpContentHandlersController& aController, |
|
115 CUpnpService& aNotOwnedResultService ) : |
|
116 CUpnpContentHandler(aController), |
|
117 iResultService( &aNotOwnedResultService ), iIsServiceOwned( EFalse ) |
|
118 { |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CUpnpServiceContentHandler::OnStartElementL |
|
123 // This method is a callback to indicate an element has been parsed. |
|
124 // -------------------------------------------------------- --------------------- |
|
125 // |
|
126 void CUpnpServiceContentHandler::OnStartElementL( const RTagInfo& aElement, |
|
127 const RAttributeArray& /*aAttributes*/ ) |
|
128 { |
|
129 if ( aElement.LocalName().DesC().Compare( KUpnpScpd ) == 0 ) |
|
130 { |
|
131 if ( iIsServiceOwned ) |
|
132 { |
|
133 delete iResultService; |
|
134 iResultService = NULL; |
|
135 iResultService = CUpnpService::NewL( iParentDevice ); |
|
136 iParentDevice = NULL; |
|
137 } |
|
138 iController.SetCurrentContentHandlerL( CUpnpScpdContentHandler::NewL( |
|
139 iController, *iResultService ) ); |
|
140 } |
|
141 else |
|
142 { |
|
143 User::Leave( KErrArgument ); //wrong root node |
|
144 } |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CUpnpServiceContentHandler::OnEndElementL |
|
149 // This method is a callback to indicate the end of the element has been reached. |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CUpnpServiceContentHandler::OnEndElementL( |
|
153 const RTagInfo& /*aElement*/ ) |
|
154 { |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CUpnpServiceContentHandler::OnContentL |
|
159 // This method is a callback that sends the content of the element. |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CUpnpServiceContentHandler::OnContentL( const TDesC8& /*aBytes*/ ) |
|
163 { |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CUpnpServiceContentHandler::ResultService() |
|
168 // Returns parsed CUpnpService object, and pass ownership to the caller. |
|
169 // One shouldn't call this method if CUpnpServiceContentHandler dosn't have |
|
170 // ownership CUpnpService object. |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 CUpnpService* CUpnpServiceContentHandler::ResultService() |
|
174 { |
|
175 ASSERT( iIsServiceOwned ); |
|
176 CUpnpService* result = iResultService; |
|
177 iIsServiceOwned= EFalse; |
|
178 iResultService = NULL; |
|
179 return result; |
|
180 } |
|
181 |
|
182 // End of File |