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 ****************************************************************/
35 /*----------------------------------------------------------------------
37 +---------------------------------------------------------------------*/
38 #include "PltDeviceHost.h"
39 #include "PltCtrlPointTask.h"
40 #include "PltCtrlPoint.h"
41 #include "PltDatagramStream.h"
43 /*----------------------------------------------------------------------
44 | PLT_CtrlPointGetDescriptionTask::PLT_CtrlPointGetDescriptionTask
45 +---------------------------------------------------------------------*/
46 PLT_CtrlPointGetDescriptionTask::PLT_CtrlPointGetDescriptionTask(const NPT_HttpUrl
& url
,
47 PLT_CtrlPoint
* ctrl_point
,
48 NPT_TimeInterval leasetime
,
50 PLT_HttpClientSocketTask(new NPT_HttpRequest(url
, "GET", NPT_HTTP_PROTOCOL_1_1
)),
51 m_CtrlPoint(ctrl_point
),
52 m_LeaseTime(leasetime
),
57 /*----------------------------------------------------------------------
58 | PLT_CtrlPointGetDescriptionTask::~PLT_CtrlPointGetDescriptionTask
59 +---------------------------------------------------------------------*/
60 PLT_CtrlPointGetDescriptionTask::~PLT_CtrlPointGetDescriptionTask()
64 /*----------------------------------------------------------------------
65 | PLT_CtrlPointGetDescriptionTask::ProcessResponse
66 +---------------------------------------------------------------------*/
68 PLT_CtrlPointGetDescriptionTask::ProcessResponse(NPT_Result res
,
69 const NPT_HttpRequest
& request
,
70 const NPT_HttpRequestContext
& context
,
71 NPT_HttpResponse
* response
)
73 NPT_COMPILER_UNUSED(request
);
74 return m_CtrlPoint
->ProcessGetDescriptionResponse(
83 /*----------------------------------------------------------------------
84 | PLT_CtrlPointGetSCPDsTask::PLT_CtrlPointGetSCPDsTask
85 +---------------------------------------------------------------------*/
86 PLT_CtrlPointGetSCPDsTask::PLT_CtrlPointGetSCPDsTask(PLT_CtrlPoint
* ctrl_point
,
87 PLT_DeviceDataReference
& root_device
) :
88 PLT_HttpClientSocketTask(),
89 m_CtrlPoint(ctrl_point
),
90 m_RootDevice(root_device
)
94 /*----------------------------------------------------------------------
95 | PLT_CtrlPointGetSCPDsTask::ProcessResponse
96 +---------------------------------------------------------------------*/
98 PLT_CtrlPointGetSCPDsTask::ProcessResponse(NPT_Result res
,
99 const NPT_HttpRequest
& request
,
100 const NPT_HttpRequestContext
& context
,
101 NPT_HttpResponse
* response
)
103 NPT_COMPILER_UNUSED(context
);
104 return m_CtrlPoint
->ProcessGetSCPDResponse(
109 ((PLT_CtrlPointGetSCPDRequest
&)request
).m_Device
);
112 /*----------------------------------------------------------------------
113 | PLT_CtrlPointInvokeActionTask::PLT_CtrlPointInvokeActionTask
114 +---------------------------------------------------------------------*/
115 PLT_CtrlPointInvokeActionTask::PLT_CtrlPointInvokeActionTask(NPT_HttpRequest
* request
,
116 PLT_CtrlPoint
* ctrl_point
,
117 PLT_ActionReference
& action
,
119 PLT_HttpClientSocketTask(request
),
120 m_CtrlPoint(ctrl_point
),
126 /*----------------------------------------------------------------------
127 | PLT_CtrlPointInvokeActionTask::~PLT_CtrlPointInvokeActionTask
128 +---------------------------------------------------------------------*/
129 PLT_CtrlPointInvokeActionTask::~PLT_CtrlPointInvokeActionTask()
133 /*----------------------------------------------------------------------
134 | PLT_CtrlPointInvokeActionTask::ProcessResponse
135 +---------------------------------------------------------------------*/
137 PLT_CtrlPointInvokeActionTask::ProcessResponse(NPT_Result res
,
138 const NPT_HttpRequest
& request
,
139 const NPT_HttpRequestContext
& context
,
140 NPT_HttpResponse
* response
)
142 NPT_COMPILER_UNUSED(request
);
143 NPT_COMPILER_UNUSED(context
);
145 return m_CtrlPoint
->ProcessActionResponse(res
, request
, context
, response
, m_Action
, m_Userdata
);
148 /*----------------------------------------------------------------------
149 | PLT_CtrlPointHouseKeepingTask::PLT_CtrlPointHouseKeepingTask
150 +---------------------------------------------------------------------*/
151 PLT_CtrlPointHouseKeepingTask::PLT_CtrlPointHouseKeepingTask(PLT_CtrlPoint
* ctrl_point
,
152 NPT_TimeInterval timer
) :
153 m_CtrlPoint(ctrl_point
),
158 /*----------------------------------------------------------------------
159 | PLT_CtrlPointHouseKeepingTask::DoRun
160 +---------------------------------------------------------------------*/
162 PLT_CtrlPointHouseKeepingTask::DoRun()
164 while (!IsAborting((NPT_Timeout
)m_Timer
.ToSeconds()*1000)) {
166 m_CtrlPoint
->DoHouseKeeping();
171 /*----------------------------------------------------------------------
172 | PLT_CtrlPointSubscribeEventTask::PLT_CtrlPointSubscribeEventTask
173 +---------------------------------------------------------------------*/
174 PLT_CtrlPointSubscribeEventTask::PLT_CtrlPointSubscribeEventTask(NPT_HttpRequest
* request
,
175 PLT_CtrlPoint
* ctrl_point
,
176 PLT_DeviceDataReference
&device
,
177 PLT_Service
* service
,
179 PLT_HttpClientSocketTask(request
),
180 m_CtrlPoint(ctrl_point
),
187 /*----------------------------------------------------------------------
188 | PLT_CtrlPointSubscribeEventTask::~PLT_CtrlPointSubscribeEventTask
189 +---------------------------------------------------------------------*/
190 PLT_CtrlPointSubscribeEventTask::~PLT_CtrlPointSubscribeEventTask()
194 /*----------------------------------------------------------------------
195 | PLT_CtrlPointSubscribeEventTask::ProcessResponse
196 +---------------------------------------------------------------------*/
198 PLT_CtrlPointSubscribeEventTask::ProcessResponse(NPT_Result res
,
199 const NPT_HttpRequest
& request
,
200 const NPT_HttpRequestContext
& context
,
201 NPT_HttpResponse
* response
)
203 NPT_COMPILER_UNUSED(request
);
204 NPT_COMPILER_UNUSED(context
);
206 return m_CtrlPoint
->ProcessSubscribeResponse(