Mercurial > projects > hoofbaby
comparison deps/Platinum/Source/Core/PltDeviceData.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 - Device Data | |
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_DEVICE_DATA_H_ | |
35 #define _PLT_DEVICE_DATA_H_ | |
36 | |
37 /*---------------------------------------------------------------------- | |
38 | includes | |
39 +---------------------------------------------------------------------*/ | |
40 #include "Neptune.h" | |
41 | |
42 /*---------------------------------------------------------------------- | |
43 | forward declarations | |
44 +---------------------------------------------------------------------*/ | |
45 class PLT_Service; | |
46 class PLT_DeviceData; | |
47 | |
48 typedef NPT_Reference<PLT_DeviceData> PLT_DeviceDataReference; | |
49 typedef NPT_List<PLT_DeviceDataReference> PLT_DeviceDataReferenceList; | |
50 | |
51 /*---------------------------------------------------------------------- | |
52 | PLT_DeviceIcon class | |
53 +---------------------------------------------------------------------*/ | |
54 class PLT_DeviceIcon | |
55 { | |
56 public: | |
57 PLT_DeviceIcon(const char* mimetype = "", | |
58 NPT_Int32 width = 0, | |
59 NPT_Int32 height = 0, | |
60 NPT_Int32 depth = 0, | |
61 const char* urlpath = "") : | |
62 m_MimeType(mimetype), | |
63 m_Width(width), | |
64 m_Height(height), | |
65 m_Depth(depth), | |
66 m_UrlPath(urlpath) {} | |
67 virtual ~PLT_DeviceIcon() {} | |
68 | |
69 NPT_String m_MimeType; | |
70 NPT_Int32 m_Width; | |
71 NPT_Int32 m_Height; | |
72 NPT_Int32 m_Depth; | |
73 NPT_String m_UrlPath; | |
74 }; | |
75 | |
76 /*---------------------------------------------------------------------- | |
77 | PLT_DeviceData class | |
78 +---------------------------------------------------------------------*/ | |
79 class PLT_DeviceData | |
80 { | |
81 public: | |
82 PLT_DeviceData( | |
83 NPT_HttpUrl description_url = NPT_HttpUrl(NULL, 0, "/"), | |
84 const char* uuid = "", | |
85 NPT_TimeInterval lease_time = NPT_TimeInterval(1800, 0), | |
86 const char* device_type = "", | |
87 const char* friendly_name = ""); | |
88 | |
89 /* Getters */ | |
90 virtual NPT_Result GetDescription(NPT_String& desc); | |
91 virtual NPT_String GetDescriptionUrl(const char* bind_addr = NULL); | |
92 virtual NPT_HttpUrl GetURLBase(); | |
93 virtual NPT_Result GetDescription(NPT_XmlElementNode* parent, NPT_XmlElementNode** device = NULL); | |
94 virtual NPT_String GetIconUrl(const char* mimetype = NULL, NPT_Int32 maxsize = 0, NPT_Int32 maxdepth = 0); | |
95 | |
96 const NPT_TimeInterval& GetLeaseTime() const { return m_LeaseTime; } | |
97 const NPT_String& GetUUID() const { return m_UUID; } | |
98 const NPT_String& GetFriendlyName() const { return m_FriendlyName; } | |
99 const NPT_String& GetType() const { return m_DeviceType; } | |
100 const NPT_String& GetModelDescription() const { return m_ModelDescription; } | |
101 const NPT_String& GetParentUUID() const { return m_ParentUUID; } | |
102 | |
103 const NPT_Array<PLT_Service*>& GetServices() const { return m_Services; } | |
104 const NPT_Array<PLT_DeviceDataReference>& GetEmbeddedDevices() const { return m_EmbeddedDevices; } | |
105 | |
106 NPT_Result FindEmbeddedDeviceByType(const char* type, PLT_DeviceDataReference& device); | |
107 NPT_Result FindServiceById(const char* id, PLT_Service*& service); | |
108 NPT_Result FindServiceByType(const char* type, PLT_Service*& service); | |
109 NPT_Result FindServiceByDescriptionURI(const char* uri, PLT_Service*& service); | |
110 NPT_Result FindServiceByControlURI(const char* uri, PLT_Service*& service); | |
111 NPT_Result FindServiceByEventSubURI(const char* uri, PLT_Service*& service); | |
112 | |
113 /* called by PLT_Device subclasses */ | |
114 NPT_Result AddDevice(PLT_DeviceDataReference& device); | |
115 NPT_Result AddService(PLT_Service* service); | |
116 | |
117 NPT_Result ToLog(int level = NPT_LOG_LEVEL_FINE); | |
118 | |
119 protected: | |
120 virtual ~PLT_DeviceData(); | |
121 virtual void Cleanup(); | |
122 virtual NPT_Result OnAddExtraInfo(NPT_XmlElementNode* /*device_node*/) { return NPT_SUCCESS; } | |
123 | |
124 private: | |
125 /* called by PLT_CtrlPoint when new device is discovered */ | |
126 NPT_Result SetURLBase(NPT_HttpUrl& url_base); | |
127 NPT_TimeStamp GetLeaseTimeLastUpdate(); | |
128 NPT_Result SetLeaseTime(NPT_TimeInterval lease_time); | |
129 NPT_Result SetDescription(const char* szDescription, | |
130 const NPT_IpAddress& local_iface_ip); | |
131 NPT_Result SetDescriptionDevice(NPT_XmlElementNode* device_node); | |
132 | |
133 public: | |
134 NPT_String m_Manufacturer; | |
135 NPT_String m_ManufacturerURL; | |
136 NPT_String m_ModelDescription; | |
137 NPT_String m_ModelName; | |
138 NPT_String m_ModelNumber; | |
139 NPT_String m_ModelURL; | |
140 NPT_String m_SerialNumber; | |
141 NPT_String m_UPC; | |
142 NPT_String m_PresentationURL; | |
143 NPT_String m_DlnaDoc; | |
144 NPT_String m_DlnaCap; | |
145 | |
146 protected: | |
147 friend class NPT_Reference<PLT_DeviceData>; | |
148 friend class PLT_DeviceDataFinder; | |
149 friend class PLT_DeviceDataFinderByType; | |
150 friend class PLT_CtrlPoint; | |
151 friend class PLT_DeviceReadyIterator; | |
152 friend class PLT_DeviceHost; | |
153 | |
154 //members | |
155 NPT_String m_ParentUUID; | |
156 NPT_String m_UUID; | |
157 NPT_HttpUrl m_URLDescription; | |
158 NPT_String m_URLBasePath; | |
159 NPT_String m_DeviceType; | |
160 NPT_String m_FriendlyName; | |
161 NPT_TimeInterval m_LeaseTime; | |
162 NPT_TimeStamp m_LeaseTimeLastUpdate; | |
163 NPT_Array<PLT_Service*> m_Services; | |
164 NPT_Array<PLT_DeviceDataReference> m_EmbeddedDevices; | |
165 NPT_Array<PLT_DeviceIcon> m_Icons; | |
166 | |
167 /* IP address of interface used when retrieving device description. | |
168 We need the info for the control point subscription callback */ | |
169 NPT_IpAddress m_LocalIfaceIp; | |
170 }; | |
171 | |
172 /*---------------------------------------------------------------------- | |
173 | PLT_DeviceDataFinder | |
174 +---------------------------------------------------------------------*/ | |
175 class PLT_DeviceDataFinder | |
176 { | |
177 public: | |
178 // methods | |
179 PLT_DeviceDataFinder(const char* uuid) : m_UUID(uuid) {} | |
180 virtual ~PLT_DeviceDataFinder() {} | |
181 | |
182 bool operator()(const PLT_DeviceDataReference& data) const { | |
183 return data->m_UUID.Compare(m_UUID, true) ? false : true; | |
184 } | |
185 | |
186 private: | |
187 // members | |
188 NPT_String m_UUID; | |
189 }; | |
190 | |
191 /*---------------------------------------------------------------------- | |
192 | PLT_DeviceDataFinderByType | |
193 +---------------------------------------------------------------------*/ | |
194 class PLT_DeviceDataFinderByType | |
195 { | |
196 public: | |
197 // methods | |
198 PLT_DeviceDataFinderByType(const char* type) : m_Type(type) {} | |
199 virtual ~PLT_DeviceDataFinderByType() {} | |
200 | |
201 bool operator()(const PLT_DeviceDataReference& data) const { | |
202 return data->m_DeviceType.Compare(m_Type, true) ? false : true; | |
203 } | |
204 | |
205 private: | |
206 // members | |
207 NPT_String m_Type; | |
208 }; | |
209 | |
210 #endif /* _PLT_DEVICE_DATA_H_ */ | |
211 |