Mercurial > projects > hoofbaby
comparison deps/Platinum/Source/Core/PltCtrlPoint.h @ 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 | |
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 #ifndef _PLT_CONTROL_POINT_H_ | |
35 #define _PLT_CONTROL_POINT_H_ | |
36 | |
37 /*---------------------------------------------------------------------- | |
38 | includes | |
39 +---------------------------------------------------------------------*/ | |
40 #include "Neptune.h" | |
41 #include "PltService.h" | |
42 #include "PltHttpServerListener.h" | |
43 #include "PltSsdpListener.h" | |
44 #include "PltDeviceData.h" | |
45 | |
46 /*---------------------------------------------------------------------- | |
47 | forward declarations | |
48 +---------------------------------------------------------------------*/ | |
49 class PLT_HttpServer; | |
50 class PLT_CtrlPointHouseKeepingTask; | |
51 class PLT_SsdpSearchTask; | |
52 class PLT_SsdpListenTask; | |
53 | |
54 /*---------------------------------------------------------------------- | |
55 | PLT_CtrlPointListener class | |
56 +---------------------------------------------------------------------*/ | |
57 class PLT_CtrlPointListener | |
58 { | |
59 public: | |
60 virtual ~PLT_CtrlPointListener() {} | |
61 | |
62 virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device) = 0; | |
63 virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device) = 0; | |
64 virtual NPT_Result OnActionResponse(NPT_Result res, PLT_ActionReference& action, void* userdata) = 0; | |
65 virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List<PLT_StateVariable*>* vars) = 0; | |
66 }; | |
67 | |
68 typedef NPT_List<PLT_CtrlPointListener*> PLT_CtrlPointListenerList; | |
69 | |
70 /*---------------------------------------------------------------------- | |
71 | PLT_CtrlPoint class | |
72 +---------------------------------------------------------------------*/ | |
73 class PLT_CtrlPoint : public PLT_SsdpPacketListener, | |
74 public PLT_SsdpSearchResponseListener | |
75 { | |
76 public: | |
77 PLT_CtrlPoint(const char* autosearch = "upnp:rootdevice"); // pass NULL to bypass the multicast search | |
78 | |
79 NPT_Result AddListener(PLT_CtrlPointListener* listener); | |
80 NPT_Result RemoveListener(PLT_CtrlPointListener* listener); | |
81 void IgnoreUUID(const char* uuid); | |
82 NPT_Result InspectDevice(const char* location, | |
83 const char* uuid, | |
84 NPT_Timeout leasetime = 1800); | |
85 NPT_Result Search(const NPT_HttpUrl& url = NPT_HttpUrl("239.255.255.250", 1900, "*"), | |
86 const char* target = "upnp:rootdevice", | |
87 NPT_Cardinal mx = 5); | |
88 NPT_Result Discover(const NPT_HttpUrl& url = NPT_HttpUrl("239.255.255.250", 1900, "*"), | |
89 const char* target = "ssdp:all", | |
90 NPT_Cardinal mx = 5, | |
91 NPT_Timeout repeat = 50000); | |
92 NPT_Result InvokeAction(PLT_ActionReference& action, void* userdata = NULL); | |
93 NPT_Result Subscribe(PLT_Service* service, bool cancel = false, void* userdata = NULL); | |
94 | |
95 // NPT_HttpRequestHandler methods | |
96 virtual NPT_Result ProcessHttpRequest(NPT_HttpRequest& request, | |
97 const NPT_HttpRequestContext& context, | |
98 NPT_HttpResponse& response); | |
99 | |
100 // PLT_SsdpSearchResponseListener methods | |
101 virtual NPT_Result ProcessSsdpSearchResponse(NPT_Result res, | |
102 const NPT_HttpRequestContext& context, | |
103 NPT_HttpResponse* response); | |
104 // PLT_SsdpPacketListener method | |
105 virtual NPT_Result OnSsdpPacket(NPT_HttpRequest& request, | |
106 const NPT_HttpRequestContext& context); | |
107 | |
108 // helper methods | |
109 NPT_Result FindDevice(const char* uuid, PLT_DeviceDataReference& device); | |
110 | |
111 protected: | |
112 virtual ~PLT_CtrlPoint(); | |
113 | |
114 NPT_Result Start(PLT_SsdpListenTask* task); | |
115 NPT_Result Stop(PLT_SsdpListenTask* task); | |
116 | |
117 NPT_Result ProcessSsdpNotify(NPT_HttpRequest& request, | |
118 const NPT_HttpRequestContext& context); | |
119 NPT_Result ProcessSsdpMessage(NPT_HttpMessage* message, | |
120 const NPT_HttpRequestContext& context, | |
121 NPT_String& uuid); | |
122 NPT_Result ProcessGetDescriptionResponse(NPT_Result res, | |
123 const NPT_HttpRequestContext& context, | |
124 NPT_HttpResponse* response, | |
125 PLT_DeviceDataReference& device); | |
126 NPT_Result ProcessGetSCPDResponse(NPT_Result res, | |
127 NPT_HttpRequest* request, | |
128 NPT_HttpResponse* response, | |
129 PLT_DeviceDataReference& device); | |
130 NPT_Result ProcessActionResponse(NPT_Result res, | |
131 NPT_HttpResponse* response, | |
132 PLT_ActionReference& action, | |
133 void* userdata); | |
134 NPT_Result ProcessSubscribeResponse(NPT_Result res, | |
135 NPT_HttpResponse* response, | |
136 PLT_Service* service, | |
137 void* userdata); | |
138 NPT_Result ProcessHttpNotify(NPT_HttpRequest& request, | |
139 const NPT_HttpRequestContext& context, | |
140 NPT_HttpResponse& response); | |
141 private: | |
142 // methods | |
143 NPT_Result DoHouseKeeping(); | |
144 NPT_Result RemoveDevice(PLT_DeviceDataReference& data); | |
145 NPT_Result ParseFault(PLT_ActionReference& action, NPT_XmlElementNode* fault); | |
146 PLT_SsdpSearchTask* CreateSearchTask(const NPT_HttpUrl& url, | |
147 const char* target, | |
148 NPT_Cardinal mx, | |
149 const NPT_IpAddress& address); | |
150 | |
151 private: | |
152 friend class NPT_Reference<PLT_CtrlPoint>; | |
153 friend class PLT_UPnP; | |
154 friend class PLT_UPnP_CtrlPointStartIterator; | |
155 friend class PLT_UPnP_CtrlPointStopIterator; | |
156 friend class PLT_EventSubscriberRemoverIterator; | |
157 friend class PLT_CtrlPointGetDescriptionTask; | |
158 friend class PLT_CtrlPointGetSCPDTask; | |
159 friend class PLT_CtrlPointInvokeActionTask; | |
160 friend class PLT_CtrlPointHouseKeepingTask; | |
161 friend class PLT_CtrlPointSubscribeEventTask; | |
162 | |
163 NPT_List<NPT_String> m_UUIDsToIgnore; | |
164 NPT_Lock<PLT_CtrlPointListenerList> m_ListenerList; | |
165 PLT_HttpServer* m_EventHttpServer; | |
166 NPT_HttpRequestHandler* m_EventHttpServerHandler; | |
167 PLT_TaskManager m_TaskManager; | |
168 NPT_Lock<NPT_List<PLT_DeviceDataReference> > m_Devices; | |
169 NPT_Lock<NPT_List<PLT_EventSubscriber*> > m_Subscribers; | |
170 NPT_String m_AutoSearch; | |
171 }; | |
172 | |
173 typedef NPT_Reference<PLT_CtrlPoint> PLT_CtrlPointReference; | |
174 | |
175 #endif /* _PLT_CONTROL_POINT_H_ */ |