comparison deps/Platinum/Source/Core/PltCtrlPointTask.cpp @ 0:3425707ddbf6

Initial import (hopefully this mercurial stuff works...)
author fraserofthenight
date Mon, 06 Jul 2009 08:06:28 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3425707ddbf6
1 /*****************************************************************
2 |
3 | Platinum - Control Point Tasks
4 |
5 | Copyright (c) 2004-2008, 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 |
21 | This program is distributed in the hope that it will be useful,
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | GNU General Public License for more details.
25 |
26 | You should have received a copy of the GNU General Public License
27 | along with this program; see the file LICENSE.txt. If not, write to
28 | the Free Software Foundation, Inc.,
29 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 | http://www.gnu.org/licenses/gpl-2.0.html
31 |
32 ****************************************************************/
33
34 /*----------------------------------------------------------------------
35 | includes
36 +---------------------------------------------------------------------*/
37 #include "PltDeviceHost.h"
38 #include "PltCtrlPointTask.h"
39 #include "PltCtrlPoint.h"
40 #include "PltDatagramStream.h"
41
42 /*----------------------------------------------------------------------
43 | PLT_CtrlPointGetDescriptionTask::PLT_CtrlPointGetDescriptionTask
44 +---------------------------------------------------------------------*/
45 PLT_CtrlPointGetDescriptionTask::PLT_CtrlPointGetDescriptionTask(const NPT_HttpUrl& url,
46 PLT_CtrlPoint* ctrl_point,
47 PLT_DeviceDataReference& device) :
48 PLT_HttpClientSocketTask(new NPT_HttpRequest(url, "GET")),
49 m_CtrlPoint(ctrl_point),
50 m_Device(device)
51 {
52 }
53
54 /*----------------------------------------------------------------------
55 | PLT_CtrlPointGetDescriptionTask::~PLT_CtrlPointGetDescriptionTask
56 +---------------------------------------------------------------------*/
57 PLT_CtrlPointGetDescriptionTask::~PLT_CtrlPointGetDescriptionTask()
58 {
59 }
60
61 /*----------------------------------------------------------------------
62 | PLT_CtrlPointGetDescriptionTask::ProcessResponse
63 +---------------------------------------------------------------------*/
64 NPT_Result
65 PLT_CtrlPointGetDescriptionTask::ProcessResponse(NPT_Result res,
66 NPT_HttpRequest* request,
67 const NPT_HttpRequestContext& context,
68 NPT_HttpResponse* response)
69 {
70 NPT_COMPILER_UNUSED(request);
71 return m_CtrlPoint->ProcessGetDescriptionResponse(res, context, response, m_Device);
72 }
73
74 /*----------------------------------------------------------------------
75 | PLT_CtrlPointGetSCPDTask::PLT_CtrlPointGetSCPDTask
76 +---------------------------------------------------------------------*/
77 PLT_CtrlPointGetSCPDTask::PLT_CtrlPointGetSCPDTask(const NPT_HttpUrl& url,
78 PLT_CtrlPoint* ctrl_point,
79 PLT_DeviceDataReference& device) :
80 PLT_HttpClientSocketTask(new NPT_HttpRequest(url, "GET")),
81 m_CtrlPoint(ctrl_point),
82 m_Device(device)
83 {
84 }
85
86 /*----------------------------------------------------------------------
87 | PLT_CtrlPointGetSCPDTask::~PLT_CtrlPointGetSCPDTask
88 +---------------------------------------------------------------------*/
89 PLT_CtrlPointGetSCPDTask::~PLT_CtrlPointGetSCPDTask()
90 {
91 }
92
93 /*----------------------------------------------------------------------
94 | PLT_CtrlPointGetSCPDTask::ProcessResponse
95 +---------------------------------------------------------------------*/
96 NPT_Result
97 PLT_CtrlPointGetSCPDTask::ProcessResponse(NPT_Result res,
98 NPT_HttpRequest* request,
99 const NPT_HttpRequestContext& context,
100 NPT_HttpResponse* response)
101 {
102 NPT_COMPILER_UNUSED(context);
103 return m_CtrlPoint->ProcessGetSCPDResponse(res, request, response, m_Device);
104 }
105
106 /*----------------------------------------------------------------------
107 | PLT_CtrlPointInvokeActionTask::PLT_CtrlPointInvokeActionTask
108 +---------------------------------------------------------------------*/
109 PLT_CtrlPointInvokeActionTask::PLT_CtrlPointInvokeActionTask(NPT_HttpRequest* request,
110 PLT_CtrlPoint* ctrl_point,
111 PLT_ActionReference& action,
112 void* userdata) :
113 PLT_HttpClientSocketTask(request),
114 m_CtrlPoint(ctrl_point),
115 m_Action(action),
116 m_Userdata(userdata)
117 {
118 }
119
120 /*----------------------------------------------------------------------
121 | PLT_CtrlPointInvokeActionTask::~PLT_CtrlPointInvokeActionTask
122 +---------------------------------------------------------------------*/
123 PLT_CtrlPointInvokeActionTask::~PLT_CtrlPointInvokeActionTask()
124 {
125 }
126
127 /*----------------------------------------------------------------------
128 | PLT_CtrlPointInvokeActionTask::ProcessResponse
129 +---------------------------------------------------------------------*/
130 NPT_Result
131 PLT_CtrlPointInvokeActionTask::ProcessResponse(NPT_Result res,
132 NPT_HttpRequest* request,
133 const NPT_HttpRequestContext& context,
134 NPT_HttpResponse* response)
135 {
136 NPT_COMPILER_UNUSED(request);
137 NPT_COMPILER_UNUSED(context);
138
139 return m_CtrlPoint->ProcessActionResponse(res, response, m_Action, m_Userdata);
140 }
141
142 /*----------------------------------------------------------------------
143 | PLT_CtrlPointHouseKeepingTask::PLT_CtrlPointHouseKeepingTask
144 +---------------------------------------------------------------------*/
145 PLT_CtrlPointHouseKeepingTask::PLT_CtrlPointHouseKeepingTask(PLT_CtrlPoint* ctrl_point,
146 NPT_TimeInterval timer) :
147 m_CtrlPoint(ctrl_point),
148 m_Timer(timer)
149 {
150 }
151
152 /*----------------------------------------------------------------------
153 | PLT_CtrlPointHouseKeepingTask::DoRun
154 +---------------------------------------------------------------------*/
155 void
156 PLT_CtrlPointHouseKeepingTask::DoRun()
157 {
158 while (1) {
159 if (m_CtrlPoint) {
160 m_CtrlPoint->DoHouseKeeping();
161 }
162
163 if (IsAborting(m_Timer.m_Seconds*1000)) break;
164 }
165 }
166
167 /*----------------------------------------------------------------------
168 | PLT_CtrlPointSubscribeEventTask::PLT_CtrlPointSubscribeEventTask
169 +---------------------------------------------------------------------*/
170 PLT_CtrlPointSubscribeEventTask::PLT_CtrlPointSubscribeEventTask(NPT_HttpRequest* request,
171 PLT_CtrlPoint* ctrl_point,
172 PLT_Service* service,
173 void* userdata) :
174 PLT_HttpClientSocketTask(request),
175 m_CtrlPoint(ctrl_point),
176 m_Service(service),
177 m_Userdata(userdata)
178 {
179 }
180
181 /*----------------------------------------------------------------------
182 | PLT_CtrlPointSubscribeEventTask::~PLT_CtrlPointSubscribeEventTask
183 +---------------------------------------------------------------------*/
184 PLT_CtrlPointSubscribeEventTask::~PLT_CtrlPointSubscribeEventTask()
185 {
186 }
187
188 /*----------------------------------------------------------------------
189 | PLT_CtrlPointSubscribeEventTask::ProcessResponse
190 +---------------------------------------------------------------------*/
191 NPT_Result
192 PLT_CtrlPointSubscribeEventTask::ProcessResponse(NPT_Result res,
193 NPT_HttpRequest* request,
194 const NPT_HttpRequestContext& context,
195 NPT_HttpResponse* response)
196 {
197 NPT_COMPILER_UNUSED(request);
198 NPT_COMPILER_UNUSED(context);
199
200 return m_CtrlPoint->ProcessSubscribeResponse(res, response, m_Service, m_Userdata);
201 }