kodi
DeviceHost.h
1 /*****************************************************************
2 |
3 | Platinum - DeviceHost
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 #include "DeviceData.h"
36 
37 namespace Platinum
38 {
39 
40 /*----------------------------------------------------------------------
41 | DeviceHost
42 +---------------------------------------------------------------------*/
43 public ref class DeviceHost : public DeviceData
44 {
45 private:
46 
47  PLT_DeviceHostReference* m_pHostHandle;
48 
49 public:
50 
51  virtual Boolean Equals(Object^ obj) override
52  {
53  if (obj == nullptr)
54  return false;
55 
56  if (!this->GetType()->IsInstanceOfType(obj))
57  return false;
58 
59  return (*m_pHandle == ((DeviceHost^)obj)->Handle);
60  }
61 
62 internal:
63 
64  property PLT_DeviceHostReference& Host
65  {
67  {
68  return *m_pHostHandle;
69  }
70  }
71 
72 internal:
73 
75  m_pHostHandle(new PLT_DeviceHostReference(devHost)),
76  DeviceData((PLT_DeviceDataReference&)*m_pHostHandle)
77  {
78  }
79 
80  DeviceHost(PLT_DeviceHost& devHost) :
81  m_pHostHandle(new PLT_DeviceHostReference(&devHost)),
82  DeviceData((PLT_DeviceDataReference&)*m_pHostHandle) // we must make sure to pass our newly created ref object
83  {
84  }
85 
86 public:
87 
88  void setLeaseTime(TimeSpan^ lease)
89  {
90  (*m_pHostHandle)->SetLeaseTime(NPT_TimeInterval((double)lease->TotalSeconds));
91  }
92 
93  NPT_Result AddIcon(DeviceIcon^ icon, array<Byte>^ data)
94  {
95  pin_ptr<Byte> pinnedBuffer = &data[0];
96  return (*m_pHostHandle)->AddIcon(icon->Handle, (const void*)pinnedBuffer, data->Length, true);
97  }
98 
99  ~DeviceHost()
100  {
101  // clean-up managed
102 
103  // clean-up unmanaged
104  this->!DeviceHost();
105  }
106 
107  !DeviceHost()
108  {
109  // clean-up unmanaged
110  if (m_pHostHandle != 0)
111  {
112  delete m_pHostHandle;
113 
114  m_pHostHandle = 0;
115  }
116  }
117 
118 };
119 
120 }
121 
122 // marshal wrapper
123 PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceHost, PLT_DeviceHost);
124 PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceHost, PLT_DeviceHostReference);
Definition: DeviceData.h:88
Definition: DeviceData.h:41
Definition: NptTime.h:50
UPnP Device Host.
Definition: PltDeviceHost.h:69
Definition: DeviceHost.h:43