Mercurial > projects > hoofbaby
annotate deps/Platinum/Source/Core/PltUPnP.cpp @ 0:3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
author | fraserofthenight |
---|---|
date | Mon, 06 Jul 2009 08:06:28 -0700 |
parents | |
children |
rev | line source |
---|---|
0
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
1 /***************************************************************** |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
2 | |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
3 | Platinum - UPnP Engine |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
4 | |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
5 | Copyright (c) 2004-2008, Plutinosoft, LLC. |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
6 | All rights reserved. |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
7 | http://www.plutinosoft.com |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
8 | |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
9 | This program is free software; you can redistribute it and/or |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
10 | modify it under the terms of the GNU General Public License |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
11 | as published by the Free Software Foundation; either version 2 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
12 | of the License, or (at your option) any later version. |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
13 | |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
14 | OEMs, ISVs, VARs and other distributors that combine and |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
15 | distribute commercially licensed software with Platinum software |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
16 | and do not wish to distribute the source code for the commercially |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
17 | licensed software under version 2, or (at your option) any later |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
18 | version, of the GNU General Public License (the "GPL") must enter |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
19 | into a commercial license agreement with Plutinosoft, LLC. |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
20 | |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
21 | This program is distributed in the hope that it will be useful, |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
24 | GNU General Public License for more details. |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
25 | |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
26 | You should have received a copy of the GNU General Public License |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
27 | along with this program; see the file LICENSE.txt. If not, write to |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
28 | the Free Software Foundation, Inc., |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
29 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
30 | http://www.gnu.org/licenses/gpl-2.0.html |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
31 | |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
32 ****************************************************************/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
33 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
34 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
35 | includes |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
36 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
37 #include "Neptune.h" |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
38 #include "PltVersion.h" |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
39 #include "PltUPnP.h" |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
40 #include "PltDeviceHost.h" |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
41 #include "PltCtrlPoint.h" |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
42 #include "PltSsdp.h" |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
43 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
44 NPT_SET_LOCAL_LOGGER("platinum.core.upnp") |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
45 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
46 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
47 | PLT_UPnP_CtrlPointStartIterator class |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
48 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
49 class PLT_UPnP_CtrlPointStartIterator |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
50 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
51 public: |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
52 PLT_UPnP_CtrlPointStartIterator(PLT_SsdpListenTask* listen_task) : |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
53 m_ListenTask(listen_task) {} |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
54 virtual ~PLT_UPnP_CtrlPointStartIterator() {} |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
55 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
56 NPT_Result operator()(PLT_CtrlPointReference& ctrl_point) const { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
57 NPT_CHECK_SEVERE(ctrl_point->Start(m_ListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
58 return NPT_SUCCESS; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
59 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
60 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
61 private: |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
62 PLT_SsdpListenTask* m_ListenTask; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
63 }; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
64 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
65 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
66 | PLT_UPnP_CtrlPointStopIterator class |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
67 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
68 class PLT_UPnP_CtrlPointStopIterator |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
69 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
70 public: |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
71 PLT_UPnP_CtrlPointStopIterator(PLT_SsdpListenTask* listen_task) : |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
72 m_ListenTask(listen_task) {} |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
73 virtual ~PLT_UPnP_CtrlPointStopIterator() {} |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
74 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
75 NPT_Result operator()(PLT_CtrlPointReference& ctrl_point) const { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
76 return ctrl_point->Stop(m_ListenTask); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
77 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
78 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
79 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
80 private: |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
81 PLT_SsdpListenTask* m_ListenTask; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
82 }; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
83 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
84 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
85 | PLT_UPnP_DeviceStartIterator class |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
86 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
87 class PLT_UPnP_DeviceStartIterator |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
88 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
89 public: |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
90 PLT_UPnP_DeviceStartIterator(PLT_SsdpListenTask* listen_task) : |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
91 m_ListenTask(listen_task) {} |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
92 virtual ~PLT_UPnP_DeviceStartIterator() {} |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
93 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
94 NPT_Result operator()(PLT_DeviceHostReference& device_host) const { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
95 NPT_CHECK_SEVERE(device_host->Start(m_ListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
96 return NPT_SUCCESS; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
97 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
98 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
99 private: |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
100 PLT_SsdpListenTask* m_ListenTask; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
101 }; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
102 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
103 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
104 | PLT_UPnP_DeviceStopIterator class |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
105 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
106 class PLT_UPnP_DeviceStopIterator |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
107 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
108 public: |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
109 PLT_UPnP_DeviceStopIterator(PLT_SsdpListenTask* listen_task) : |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
110 m_ListenTask(listen_task) {} |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
111 virtual ~PLT_UPnP_DeviceStopIterator() {} |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
112 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
113 NPT_Result operator()(PLT_DeviceHostReference& device_host) const { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
114 return device_host->Stop(m_ListenTask); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
115 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
116 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
117 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
118 private: |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
119 PLT_SsdpListenTask* m_ListenTask; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
120 }; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
121 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
122 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
123 | PLT_UPnP::PLT_UPnP |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
124 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
125 PLT_UPnP::PLT_UPnP(NPT_UInt32 port, bool multicast /* = true */) : |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
126 m_Started(false), |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
127 m_Port(port), |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
128 m_Multicast(multicast), |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
129 m_SsdpListenTask(NULL) |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
130 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
131 NPT_HttpClient::m_UserAgentHeader = "Platinum/" PLT_PLATINUM_VERSION_STRING; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
132 NPT_HttpServer::m_ServerHeader = "UPnP/1.0, Platinum/" PLT_PLATINUM_VERSION_STRING; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
133 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
134 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
135 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
136 | PLT_UPnP::~PLT_UPnP |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
137 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
138 PLT_UPnP::~PLT_UPnP() |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
139 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
140 Stop(); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
141 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
142 m_CtrlPoints.Clear(); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
143 m_Devices.Clear(); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
144 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
145 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
146 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
147 | PLT_UPnP::Start() |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
148 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
149 NPT_Result |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
150 PLT_UPnP::Start() |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
151 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
152 NPT_LOG_INFO("Starting UPnP..."); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
153 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
154 NPT_AutoLock lock(m_Lock); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
155 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
156 if (m_Started == true) return NPT_FAILURE; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
157 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
158 NPT_Socket* socket = m_Multicast?new NPT_UdpMulticastSocket(): new NPT_UdpSocket(); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
159 NPT_CHECK_SEVERE(socket->Bind(NPT_SocketAddress(NPT_IpAddress::Any, m_Port))); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
160 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
161 /* create the ssdp listener */ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
162 m_SsdpListenTask = new PLT_SsdpListenTask(socket, m_Multicast); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
163 NPT_CHECK_SEVERE(m_TaskManager.StartTask(m_SsdpListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
164 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
165 /* start devices & ctrlpoints */ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
166 m_CtrlPoints.Apply(PLT_UPnP_CtrlPointStartIterator(m_SsdpListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
167 m_Devices.Apply(PLT_UPnP_DeviceStartIterator(m_SsdpListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
168 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
169 m_Started = true; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
170 return NPT_SUCCESS; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
171 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
172 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
173 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
174 | PLT_UPnP::Stop |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
175 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
176 NPT_Result |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
177 PLT_UPnP::Stop() |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
178 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
179 NPT_AutoLock lock(m_Lock); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
180 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
181 if (m_Started == false) return NPT_FAILURE; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
182 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
183 NPT_LOG_INFO("Stopping UPnP..."); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
184 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
185 // Stop ctrlpoints and devices first |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
186 m_CtrlPoints.Apply(PLT_UPnP_CtrlPointStopIterator(m_SsdpListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
187 m_Devices.Apply(PLT_UPnP_DeviceStopIterator(m_SsdpListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
188 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
189 m_TaskManager.StopAllTasks(); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
190 m_SsdpListenTask = NULL; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
191 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
192 m_Started = false; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
193 return NPT_SUCCESS; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
194 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
195 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
196 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
197 | PLT_UPnP::AddDevice |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
198 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
199 NPT_Result |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
200 PLT_UPnP::AddDevice(PLT_DeviceHostReference& device) |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
201 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
202 NPT_AutoLock lock(m_Lock); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
203 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
204 if (m_Started) { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
205 NPT_LOG_INFO("Starting Device..."); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
206 NPT_CHECK_SEVERE(device->Start(m_SsdpListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
207 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
208 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
209 m_Devices.Add(device); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
210 return NPT_SUCCESS; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
211 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
212 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
213 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
214 | PLT_UPnP::RemoveDevice |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
215 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
216 NPT_Result |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
217 PLT_UPnP::RemoveDevice(PLT_DeviceHostReference& device) |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
218 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
219 NPT_AutoLock lock(m_Lock); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
220 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
221 if (m_Started) { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
222 device->Stop(m_SsdpListenTask); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
223 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
224 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
225 return m_Devices.Remove(device); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
226 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
227 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
228 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
229 | PLT_UPnP::AddCtrlPoint |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
230 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
231 NPT_Result |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
232 PLT_UPnP::AddCtrlPoint(PLT_CtrlPointReference& ctrl_point) |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
233 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
234 NPT_AutoLock lock(m_Lock); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
235 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
236 if (m_Started) { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
237 NPT_LOG_INFO("Starting Ctrlpoint..."); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
238 NPT_CHECK_SEVERE(ctrl_point->Start(m_SsdpListenTask)); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
239 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
240 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
241 m_CtrlPoints.Add(ctrl_point); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
242 return NPT_SUCCESS; |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
243 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
244 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
245 /*---------------------------------------------------------------------- |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
246 | PLT_UPnP::RemoveCtrlPoint |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
247 +---------------------------------------------------------------------*/ |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
248 NPT_Result |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
249 PLT_UPnP::RemoveCtrlPoint(PLT_CtrlPointReference& ctrl_point) |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
250 { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
251 NPT_AutoLock lock(m_Lock); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
252 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
253 if (m_Started) { |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
254 ctrl_point->Stop(m_SsdpListenTask); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
255 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
256 |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
257 return m_CtrlPoints.Remove(ctrl_point); |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
258 } |
3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
fraserofthenight
parents:
diff
changeset
|
259 |