kodi
DeviceData.h
1 /*****************************************************************
2 |
3 | Platinum - Managed DeviceData
4 |
5 | Copyright (c) 2004-2010, 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 #pragma once
34 
35 namespace Platinum
36 {
37 
38 /*----------------------------------------------------------------------
39 | DeviceIcon
40 +---------------------------------------------------------------------*/
41 public ref class DeviceIcon : public ManagedWrapper<PLT_DeviceIcon>
42 {
43 public:
44 
45  // properties
46 
47  PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, MimeType, m_MimeType, m_pHandle);
48  PLATINUM_MANAGED_IMPLEMENT_PROPERTY(Int32, Width, m_Width, m_pHandle);
49  PLATINUM_MANAGED_IMPLEMENT_PROPERTY(Int32, Height, m_Height, m_pHandle);
50  PLATINUM_MANAGED_IMPLEMENT_PROPERTY(Int32, Depth, m_Depth, m_pHandle);
51  PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, UrlPath, m_UrlPath, m_pHandle);
52 
53 internal:
54 
55  DeviceIcon(PLT_DeviceIcon& native) :
57  {}
58 
59 public:
60  DeviceIcon() :
62  {}
63 
64  DeviceIcon(String^ mimeType, Int32 width, Int32 height, Int32 depth, String^ urlPath) :
66  {
67  MimeType = mimeType;
68  Width = width;
69  Height = height;
70  Depth = depth;
71  UrlPath = urlPath;
72  }
73 };
74 
75 }
76 
77 // marshal wrapper
78 PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceIcon, PLT_DeviceIcon);
79 
80 namespace Platinum
81 {
82 
83 ref class Service;
84 
85 /*----------------------------------------------------------------------
86 | DeviceData
87 +---------------------------------------------------------------------*/
88 public ref class DeviceData
89 {
90 protected:
91 
92  PLT_DeviceDataReference* m_pHandle;
93 
94 public:
95 
96  property String^ Description
97  {
98  String^ get()
99  {
100  NPT_String s;
101 
102  Helpers::ThrowOnError((*m_pHandle)->GetDescription(s));
103 
104  return gcnew String(s);
105  }
106  }
107 
108  property Uri^ DescriptionUrl
109  {
110  Uri^ get()
111  {
112  return marshal_as<Uri^>((*m_pHandle)->GetDescriptionUrl());
113  }
114  }
115 
116  property Uri^ UrlBase
117  {
118  Uri^ get()
119  {
120  return marshal_as<Uri^>((*m_pHandle)->GetURLBase());
121  }
122  }
123 
124  property Uri^ IconUrl
125  {
126  Uri^ get()
127  {
128  return marshal_as<Uri^>((*m_pHandle)->GetIconUrl());
129  }
130  }
131 
132  property TimeSpan^ LeaseTime
133  {
134  TimeSpan^ get()
135  {
136  return marshal_as<TimeSpan>((*m_pHandle)->GetLeaseTime());
137  }
138  }
139 
140  property String^ UUID
141  {
142  String^ get()
143  {
144  return gcnew String((*m_pHandle)->GetUUID());
145  }
146  }
147 
148  property String^ FriendlyName
149  {
150  String^ get()
151  {
152  return gcnew String((*m_pHandle)->GetFriendlyName());
153  }
154  }
155 
156  property String^ TypeName
157  {
158  String^ get()
159  {
160  return gcnew String((*m_pHandle)->GetType());
161  }
162  }
163 
164  property String^ ModelDescription
165  {
166  String^ get()
167  {
168  return gcnew String((*m_pHandle)->GetModelDescription());
169  }
170  }
171 
172  property String^ ParentUUID
173  {
174  String^ get()
175  {
176  return gcnew String((*m_pHandle)->GetParentUUID());
177  }
178  }
179 
180  property IEnumerable<Service^>^ Services
181  {
182  IEnumerable<Service^>^ get();
183  }
184 
185  property IEnumerable<DeviceData^>^ EmbeddedDevices
186  {
187  IEnumerable<DeviceData^>^ get();
188  }
189 
190 internal:
191 
192  property PLT_DeviceDataReference& Handle
193  {
195  {
196  return *m_pHandle;
197  }
198  }
199 
200 public:
201 
202  DeviceData^ FindEmbeddedDeviceByType(String^ type);
203  Service^ FindServiceById(String^ serviceId);
204  Service^ FindServiceByType(String^ type);
205  Service^ FindServiceBySCPDURL(Uri^ url);
206  Service^ FindServiceByControlURL(Uri^ url);
207  Service^ FindServiceByEventSubURL(Uri^ url);
208 
209 public:
210 
211  virtual Boolean Equals(Object^ obj) override
212  {
213  if (obj == nullptr)
214  return false;
215 
216  if (!this->GetType()->IsInstanceOfType(obj))
217  return false;
218 
219  return (*m_pHandle == *((DeviceData^)obj)->m_pHandle);
220  }
221 
222 internal:
223 
225  {
226  if (devData.IsNull())
227  throw gcnew ArgumentNullException("devData");
228 
229  m_pHandle = new PLT_DeviceDataReference(devData);
230  }
231 
232  DeviceData(PLT_DeviceData& devData)
233  {
234  m_pHandle = new PLT_DeviceDataReference(&devData);
235  }
236 
237 public:
238 
239  ~DeviceData()
240  {
241  // clean-up managed
242 
243  // clean-up unmanaged
244  this->!DeviceData();
245  }
246 
247  !DeviceData()
248  {
249  // clean-up unmanaged
250  if (m_pHandle != 0)
251  {
252  delete m_pHandle;
253 
254  m_pHandle = 0;
255  }
256  }
257 
258 };
259 
260 }
261 
262 // marshal wrapper
263 PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceData, PLT_DeviceData);
264 PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceData, PLT_DeviceDataReference);
Definition: DeviceData.h:88
Definition: Service.h:45
Definition: DeviceData.h:41
The PLT_DeviceIcon class represents a given instance of a UPnP device icon.
Definition: PltDeviceData.h:63
The PLT_DeviceData class holds information about a device being advertised or found by a control poin...
Definition: PltDeviceData.h:93
Definition: Helpers.h:274
bool IsNull() const
Returns whether this references a NULL object.
Definition: NptReferences.h:130
Definition: NptStrings.h:57