kodi
PltCtrlPointTask.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | Platinum - Control Point Tasks
4 |
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
8 |
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.
13 |
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
21 |
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.
26 |
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
32 |
33 ****************************************************************/
34 
39 #ifndef _PLT_CONTROL_POINT_TASK_H_
40 #define _PLT_CONTROL_POINT_TASK_H_
41 
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 #include "PltHttpClientTask.h"
47 #include "PltDatagramStream.h"
48 #include "PltDeviceData.h"
49 #include "PltCtrlPoint.h"
50 
51 /*----------------------------------------------------------------------
52 | forward declarations
53 +---------------------------------------------------------------------*/
54 class PLT_Action;
55 
56 /*----------------------------------------------------------------------
57 | PLT_CtrlPointGetDescriptionTask class
58 +---------------------------------------------------------------------*/
64 {
65 public:
67  PLT_CtrlPoint* ctrl_point,
68  NPT_TimeInterval leasetime,
69  NPT_String uuid);
71 
72 protected:
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;
78 
79 protected:
80  PLT_CtrlPoint* m_CtrlPoint;
81  NPT_TimeInterval m_LeaseTime;
82  NPT_String m_UUID;
83 };
84 
85 /*----------------------------------------------------------------------
86 | PLT_CtrlPointGetSCPDRequest class
87 +---------------------------------------------------------------------*/
93 {
94 public:
96  const char* url,
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 {}
101 
102  // members
103  PLT_DeviceDataReference m_Device;
104 };
105 
106 /*----------------------------------------------------------------------
107 | PLT_CtrlPointGetSCPDsTask class
108 +---------------------------------------------------------------------*/
114 {
115 public:
117  ~PLT_CtrlPointGetSCPDsTask() override {}
118 
119  NPT_Result AddSCPDRequest(PLT_CtrlPointGetSCPDRequest* request) {
120  return PLT_HttpClientSocketTask::AddRequest((NPT_HttpRequest*)request);
121  }
122 
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;
127  }
128 
129 protected:
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;
135 
136 protected:
137  PLT_CtrlPoint* m_CtrlPoint;
138  PLT_DeviceDataReference m_RootDevice;
139 };
140 
141 /*----------------------------------------------------------------------
142 | PLT_CtrlPointInvokeActionTask class
143 +---------------------------------------------------------------------*/
149 {
150 public:
152  PLT_CtrlPoint* ctrl_point,
153  PLT_ActionReference& action,
154  void* userdata);
155  ~PLT_CtrlPointInvokeActionTask() override;
156 
157 protected:
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;
163 
164 protected:
165  PLT_CtrlPoint* m_CtrlPoint;
166  PLT_ActionReference m_Action;
167  void* m_Userdata;
168 };
169 
170 /*----------------------------------------------------------------------
171 | PLT_CtrlPointHouseKeepingTask class
172 +---------------------------------------------------------------------*/
178 {
179 public:
181  NPT_TimeInterval timer = NPT_TimeInterval(5.));
182 
183 protected:
184  ~PLT_CtrlPointHouseKeepingTask() override {}
185 
186  // PLT_ThreadTask methods
187  void DoRun() override;
188 
189 protected:
190  PLT_CtrlPoint* m_CtrlPoint;
191  NPT_TimeInterval m_Timer;
192 };
193 
194 /*----------------------------------------------------------------------
195 | PLT_CtrlPointSubscribeEventTask class
196 +---------------------------------------------------------------------*/
202 {
203 public:
205  PLT_CtrlPoint* ctrl_point,
206  PLT_DeviceDataReference& device,
207  PLT_Service* service,
208  void* userdata = NULL);
210 
211 protected:
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;
217 
218 protected:
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
222  void* m_Userdata;
223 };
224 
225 #endif /* _PLT_CONTROL_POINT_TASK_H_ */
Definition: NptHttp.h:566
The PLT_HttpClientSocketTask class is the base class used to send a HTTP request asynchronously using...
Definition: PltHttpClientTask.h:58
The PLT_CtrlPointHouseKeepingTask class is used by a PLT_CtrlPoint to keep track of expired devices a...
Definition: PltCtrlPointTask.h:177
Definition: NptHttp.h:315
Definition: NptHttp.h:126
Definition: NptHttp.h:282
UPnP ControlPoint.
UPnP Service.
Definition: PltService.h:67
Definition: NptTime.h:50
HTTP Client tasks.
The PLT_CtrlPointSubscribeEventTask class is used to subscribe, renew or cancel a subscription for a ...
Definition: PltCtrlPointTask.h:201
void DoRun() override
This method to override in derived classes is the main task loop.
Definition: PltHttpClientTask.cpp:107
The PLT_CtrlPointInvokeActionTask class is used by a PLT_CtrlPoint to invoke a specific action of a g...
Definition: PltCtrlPointTask.h:148
Datagram Input/Output Neptune streams.
The PLT_CtrlPointGetSCPDRequest class is used by a PLT_CtrlPointGetSCPDsTask task to fetch a specific...
Definition: PltCtrlPointTask.h:92
The PLT_CtrlPointGetDescriptionTask class fetches the description xml document from a UPnP device...
Definition: PltCtrlPointTask.h:63
The PLT_Action class provides a mechanism to call or verify the validity of a specific UPNP service a...
Definition: PltAction.h:121
UPnP Device information.
The PLT_CtrlPointGetSCPDsTask class fetches the SCPD xml document of one or more services for a given...
Definition: PltCtrlPointTask.h:113
The PLT_ThreadTask class is a base class for executing a given task in a worker thread.
Definition: PltThreadTask.h:56
Definition: NptStrings.h:57
The PLT_CtrlPoint class implements the base functionality of a UPnP ControlPoint. ...
Definition: PltCtrlPoint.h:89