1 /*****************************************************************
3 | Platinum - Control Point Tasks
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
7 | http://www.plutinosoft.com
9 | This program is free software; you can redistribute it and/or
10 | modify it under the terms of the GNU General Public License
11 | as published by the Free Software Foundation; either version 2
12 | of the License, or (at your option) any later version.
14 | OEMs, ISVs, VARs and other distributors that combine and
15 | distribute commercially licensed software with Platinum software
16 | and do not wish to distribute the source code for the commercially
17 | licensed software under version 2, or (at your option) any later
18 | version, of the GNU General Public License (the "GPL") must enter
19 | into a commercial license agreement with Plutinosoft, LLC.
20 | licensing@plutinosoft.com
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
27 | You should have received a copy of the GNU General Public License
28 | along with this program; see the file LICENSE.txt. If not, write to
29 | the Free Software Foundation, Inc.,
30 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 | http://www.gnu.org/licenses/gpl-2.0.html
33 ****************************************************************/
36 UPnP ControlPoint Tasks
39 #ifndef _PLT_CONTROL_POINT_TASK_H_
40 #define _PLT_CONTROL_POINT_TASK_H_
42 /*----------------------------------------------------------------------
44 +---------------------------------------------------------------------*/
46 #include "PltHttpClientTask.h"
47 #include "PltDatagramStream.h"
48 #include "PltDeviceData.h"
49 #include "PltCtrlPoint.h"
51 /*----------------------------------------------------------------------
52 | forward declarations
53 +---------------------------------------------------------------------*/
56 /*----------------------------------------------------------------------
57 | PLT_CtrlPointGetDescriptionTask class
58 +---------------------------------------------------------------------*/
60 The PLT_CtrlPointGetDescriptionTask class fetches the description xml document
63 class PLT_CtrlPointGetDescriptionTask
: public PLT_HttpClientSocketTask
66 PLT_CtrlPointGetDescriptionTask(const NPT_HttpUrl
& url
,
67 PLT_CtrlPoint
* ctrl_point
,
68 NPT_TimeInterval leasetime
,
70 ~PLT_CtrlPointGetDescriptionTask() override
;
73 // PLT_HttpClientSocketTask methods
74 NPT_Result
ProcessResponse(NPT_Result res
,
75 const NPT_HttpRequest
& request
,
76 const NPT_HttpRequestContext
& context
,
77 NPT_HttpResponse
* response
) override
;
80 PLT_CtrlPoint
* m_CtrlPoint
;
81 NPT_TimeInterval m_LeaseTime
;
85 /*----------------------------------------------------------------------
86 | PLT_CtrlPointGetSCPDRequest class
87 +---------------------------------------------------------------------*/
89 The PLT_CtrlPointGetSCPDRequest class is used by a PLT_CtrlPointGetSCPDsTask task
90 to fetch a specific SCPD xml document for a given service of a given device.
92 class PLT_CtrlPointGetSCPDRequest
: public NPT_HttpRequest
95 PLT_CtrlPointGetSCPDRequest(PLT_DeviceDataReference
& device
,
97 const char* method
= "GET",
98 const char* protocol
= NPT_HTTP_PROTOCOL_1_1
) : // 1.1 for pipelining
99 NPT_HttpRequest(url
, method
, protocol
), m_Device(device
) {}
100 ~PLT_CtrlPointGetSCPDRequest() override
{}
103 PLT_DeviceDataReference m_Device
;
106 /*----------------------------------------------------------------------
107 | PLT_CtrlPointGetSCPDsTask class
108 +---------------------------------------------------------------------*/
110 The PLT_CtrlPointGetSCPDsTask class fetches the SCPD xml document of one or more
111 services for a given device.
113 class PLT_CtrlPointGetSCPDsTask
: public PLT_HttpClientSocketTask
116 PLT_CtrlPointGetSCPDsTask(PLT_CtrlPoint
* ctrl_point
, PLT_DeviceDataReference
& root_device
);
117 ~PLT_CtrlPointGetSCPDsTask() override
{}
119 NPT_Result
AddSCPDRequest(PLT_CtrlPointGetSCPDRequest
* request
) {
120 return PLT_HttpClientSocketTask::AddRequest((NPT_HttpRequest
*)request
);
123 // override to prevent calling this directly
124 NPT_Result
AddRequest(NPT_HttpRequest
*) override
{
125 // only queuing PLT_CtrlPointGetSCPDRequest allowed
126 return NPT_ERROR_NOT_SUPPORTED
;
130 // PLT_HttpClientSocketTask methods
131 NPT_Result
ProcessResponse(NPT_Result res
,
132 const NPT_HttpRequest
& request
,
133 const NPT_HttpRequestContext
& context
,
134 NPT_HttpResponse
* response
) override
;
137 PLT_CtrlPoint
* m_CtrlPoint
;
138 PLT_DeviceDataReference m_RootDevice
;
141 /*----------------------------------------------------------------------
142 | PLT_CtrlPointInvokeActionTask class
143 +---------------------------------------------------------------------*/
145 The PLT_CtrlPointInvokeActionTask class is used by a PLT_CtrlPoint to invoke
146 a specific action of a given service for a given device.
148 class PLT_CtrlPointInvokeActionTask
: public PLT_HttpClientSocketTask
151 PLT_CtrlPointInvokeActionTask(NPT_HttpRequest
* request
,
152 PLT_CtrlPoint
* ctrl_point
,
153 PLT_ActionReference
& action
,
155 ~PLT_CtrlPointInvokeActionTask() override
;
158 // PLT_HttpClientSocketTask methods
159 NPT_Result
ProcessResponse(NPT_Result res
,
160 const NPT_HttpRequest
& request
,
161 const NPT_HttpRequestContext
& context
,
162 NPT_HttpResponse
* response
) override
;
165 PLT_CtrlPoint
* m_CtrlPoint
;
166 PLT_ActionReference m_Action
;
170 /*----------------------------------------------------------------------
171 | PLT_CtrlPointHouseKeepingTask class
172 +---------------------------------------------------------------------*/
174 The PLT_CtrlPointHouseKeepingTask class is used by a PLT_CtrlPoint to keep
175 track of expired devices and autmatically renew event subscribers.
177 class PLT_CtrlPointHouseKeepingTask
: public PLT_ThreadTask
180 PLT_CtrlPointHouseKeepingTask(PLT_CtrlPoint
* ctrl_point
,
181 NPT_TimeInterval timer
= NPT_TimeInterval(5.));
184 ~PLT_CtrlPointHouseKeepingTask() override
{}
186 // PLT_ThreadTask methods
187 void DoRun() override
;
190 PLT_CtrlPoint
* m_CtrlPoint
;
191 NPT_TimeInterval m_Timer
;
194 /*----------------------------------------------------------------------
195 | PLT_CtrlPointSubscribeEventTask class
196 +---------------------------------------------------------------------*/
198 The PLT_CtrlPointSubscribeEventTask class is used to subscribe, renew or cancel
199 a subscription for a given service of a given device.
201 class PLT_CtrlPointSubscribeEventTask
: public PLT_HttpClientSocketTask
204 PLT_CtrlPointSubscribeEventTask(NPT_HttpRequest
* request
,
205 PLT_CtrlPoint
* ctrl_point
,
206 PLT_DeviceDataReference
& device
,
207 PLT_Service
* service
,
208 void* userdata
= NULL
);
209 ~PLT_CtrlPointSubscribeEventTask() override
;
212 // PLT_HttpClientSocketTask methods
213 NPT_Result
ProcessResponse(NPT_Result res
,
214 const NPT_HttpRequest
& request
,
215 const NPT_HttpRequestContext
& context
,
216 NPT_HttpResponse
* response
) override
;
219 PLT_CtrlPoint
* m_CtrlPoint
;
220 PLT_Service
* m_Service
;
221 PLT_DeviceDataReference m_Device
; // force to keep a reference to device owning m_Service
225 #endif /* _PLT_CONTROL_POINT_TASK_H_ */