summaryrefslogtreecommitdiffstats
path: root/lib/libUPnP/Platinum/Source/Extras
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Action.cpp92
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Action.h159
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/ActionArgumentDescription.cpp45
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/ActionArgumentDescription.h153
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/ActionDescription.cpp69
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/ActionDescription.h123
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Clix.h202
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/ControlPoint.cpp115
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/ControlPoint.h227
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/ControlPointEventBridge.cpp88
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/ControlPointEventBridge.h68
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/DeviceData.cpp168
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/DeviceData.h264
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/DeviceHost.cpp38
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/DeviceHost.h124
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Didl.cpp39
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Didl.h70
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/EnumerableNptArray.h226
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/EnumerableNptList.h234
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Helpers.cpp39
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Helpers.h378
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Http.cpp38
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Http.h286
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/MediaConnect.cpp59
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/MediaConnect.h80
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/MediaObject.cpp118
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/MediaObject.h735
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/MediaServer.cpp121
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/MediaServer.h131
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/MediaServerEventBridge.cpp103
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/MediaServerEventBridge.h97
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Neptun_marshal_as.h104
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneException.cpp39
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneException.h64
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneLoggingBridge.cpp38
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneLoggingBridge.h207
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Service.cpp97
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/Service.h147
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/StateVariable.cpp44
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/StateVariable.h165
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/UPnP.cpp81
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/UPnP.h131
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/Managed/clix.hpp209
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltMediaServerObject.h84
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltMediaServerObject.mm198
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltUPnPObject.h61
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltUPnPObject.mm118
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltDownloader.cpp132
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltDownloader.h89
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltFrameBuffer.cpp129
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltFrameBuffer.h76
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltFrameServer.cpp236
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltFrameServer.h103
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltFrameStream.cpp128
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltFrameStream.h79
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltLeaks.cpp99
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltLeaks.h51
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltMetadataHandler.cpp90
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltMetadataHandler.h91
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltRingBufferStream.cpp255
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltRingBufferStream.h119
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltStreamPump.cpp227
-rw-r--r--lib/libUPnP/Platinum/Source/Extras/PltStreamPump.h131
63 files changed, 8511 insertions, 0 deletions
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Action.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/Action.cpp
new file mode 100644
index 0000000..08a028d
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Action.cpp
@@ -0,0 +1,92 @@
+/*****************************************************************
+|
+| Platinum - Managed Action
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "Action.h"
+#include "ActionDescription.h"
+#include "Service.h"
+#include "ActionArgumentDescription.h"
+#include "EnumerableNptArray.h"
+
+Platinum::Service^ Platinum::Action::ParentService::get()
+{
+ return marshal_as<Service^>(*(*m_pHandle)->GetActionDesc().GetService());
+}
+
+Platinum::ActionDescription^ Platinum::Action::Description::get()
+{
+ return marshal_as<ActionDescription^>((*m_pHandle)->GetActionDesc());
+}
+
+IEnumerable<Platinum::ActionArgumentDescription^>^ Platinum::Action::Arguments::get()
+{
+ return gcnew Enumerables::EnumerableNptArray<ActionArgumentDescription^, PLT_ArgumentDesc*>(
+ (*m_pHandle)->GetActionDesc().GetArgumentDescs()
+ );
+}
+
+Platinum::ActionArgumentDescription^ Platinum::Action::GetArgument( String^ name )
+{
+ if (String::IsNullOrEmpty(name))
+ throw gcnew ArgumentException("null or empty", "name");
+
+ marshal_context c;
+
+ PLT_ArgumentDesc* arg = (*m_pHandle)->GetActionDesc().GetArgumentDesc(c.marshal_as<const char*>(name));
+
+ if (!arg)
+ return nullptr;
+
+ return marshal_as<ActionArgumentDescription^>(*arg);
+}
+
+Int32 Platinum::Action::SetArgumentValue( String^ name, String^ value )
+{
+ if (String::IsNullOrEmpty(name))
+ throw gcnew ArgumentException("null or empty", "name");
+
+ marshal_context c;
+ return (*m_pHandle)->SetArgumentValue(c.marshal_as<const char*>(name), c.marshal_as<const char*>(value));
+}
+
+void Platinum::Action::HandleActionResponse( NeptuneException^ error, Action^ action )
+{
+ if (action->m_pHandle == m_pHandle)
+ {
+ this->ActionResponse(error);
+ }
+}
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Action.h b/lib/libUPnP/Platinum/Source/Extras/Managed/Action.h
new file mode 100644
index 0000000..7a45f89
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Action.h
@@ -0,0 +1,159 @@
+/*****************************************************************
+|
+| Platinum - Managed Action
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+ref class ActionArgumentDescription;
+ref class ActionDescription;
+ref class Service;
+
+/*----------------------------------------------------------------------
+| Action
++---------------------------------------------------------------------*/
+public ref class Action
+{
+public:
+
+ delegate void ActionResponseDelegate(NeptuneException^ error);
+
+private:
+
+ PLT_ActionReference* m_pHandle;
+
+internal:
+
+ property PLT_ActionReference& Handle
+ {
+ PLT_ActionReference& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ property String^ Name
+ {
+ String^ get()
+ {
+ return gcnew String((*m_pHandle)->GetActionDesc().GetName());
+ }
+ }
+
+ property IEnumerable<ActionArgumentDescription^>^ Arguments
+ {
+ IEnumerable<ActionArgumentDescription^>^ get();
+ }
+
+ property Service^ ParentService
+ {
+ Service^ get();
+ }
+
+ property ActionDescription^ Description
+ {
+ ActionDescription^ get();
+ }
+
+public:
+
+ event ActionResponseDelegate^ ActionResponse;
+
+public:
+
+ ActionArgumentDescription^ GetArgument(String^ name);
+ Int32 SetArgumentValue(String^ name, String^ value);
+
+internal:
+
+ void HandleActionResponse(NeptuneException^ error, Action^ action);
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ Action^ a = (Action^)obj;
+
+ return (m_pHandle->AsPointer() == a->m_pHandle->AsPointer());
+
+ /*if (m_pHandle->AsPointer() == a->m_pHandle->AsPointer())
+ return true;
+
+ return ((*m_pHandle)->GetActionDesc() == (*a->m_pHandle)->GetActionDesc());*/
+ }
+
+internal:
+
+ Action(PLT_ActionReference& action)
+ {
+ if (action.IsNull())
+ throw gcnew ArgumentNullException("action");
+
+ m_pHandle = new PLT_ActionReference(action);
+ }
+
+public:
+
+ ~Action()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!Action();
+ }
+
+ !Action()
+ {
+ // clean-up unmanaged
+ if (m_pHandle != 0)
+ {
+ delete m_pHandle;
+
+ m_pHandle = 0;
+ }
+ }
+
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::Action, PLT_ActionReference); \ No newline at end of file
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/ActionArgumentDescription.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/ActionArgumentDescription.cpp
new file mode 100644
index 0000000..d6db6eb
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/ActionArgumentDescription.cpp
@@ -0,0 +1,45 @@
+/*****************************************************************
+|
+| Platinum - Managed ActionArgumentDescription
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "ActionArgumentDescription.h"
+#include "StateVariable.h"
+
+Platinum::StateVariable^ Platinum::ActionArgumentDescription::RelatedStateVariable::get()
+{
+ return marshal_as<StateVariable^>(*m_pHandle->GetRelatedStateVariable());
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/ActionArgumentDescription.h b/lib/libUPnP/Platinum/Source/Extras/Managed/ActionArgumentDescription.h
new file mode 100644
index 0000000..6f3fda3
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/ActionArgumentDescription.h
@@ -0,0 +1,153 @@
+/*****************************************************************
+|
+| Platinum - Managed ActionArgumentDescription
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| ActionArgumentDirection
++---------------------------------------------------------------------*/
+public enum class ActionArgumentDirection
+{
+ In,
+ Out,
+ InOut
+};
+
+ref class StateVariable;
+
+/*----------------------------------------------------------------------
+| ActionArgumentDescription
++---------------------------------------------------------------------*/
+public ref class ActionArgumentDescription
+{
+private:
+
+ PLT_ArgumentDesc* m_pHandle;
+
+public:
+
+ property String^ Name
+ {
+ String^ get()
+ {
+ return gcnew String(m_pHandle->GetName());
+ }
+ }
+
+ property ActionArgumentDirection Direction
+ {
+ ActionArgumentDirection get()
+ {
+ return ParseArgumentDirection(m_pHandle->GetDirection());
+ }
+ }
+
+ property Boolean HasReturnValue
+ {
+ Boolean get()
+ {
+ return Boolean(m_pHandle->HasReturnValue());
+ }
+ }
+
+ property StateVariable^ RelatedStateVariable
+ {
+ StateVariable^ get();
+ }
+
+private:
+
+ static ActionArgumentDirection ParseArgumentDirection(const NPT_String& dir)
+ {
+ NPT_String s (dir);
+
+ s.MakeLowercase();
+
+ if (s == "in")
+ return ActionArgumentDirection::In;
+
+ if (s == "out")
+ return ActionArgumentDirection::Out;
+
+ if (s == "inout")
+ return ActionArgumentDirection::InOut;
+
+ if (s == "io")
+ return ActionArgumentDirection::InOut;
+
+ throw gcnew ArgumentException("unknown direction");
+ }
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (m_pHandle == ((ActionArgumentDescription^)obj)->m_pHandle);
+ }
+
+internal:
+
+ ActionArgumentDescription(PLT_ArgumentDesc& devData)
+ {
+ m_pHandle = &devData;
+ }
+
+public:
+
+ ~ActionArgumentDescription()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!ActionArgumentDescription();
+ }
+
+ !ActionArgumentDescription()
+ {
+ // clean-up unmanaged
+ }
+
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::ActionArgumentDescription, PLT_ArgumentDesc);
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/ActionDescription.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/ActionDescription.cpp
new file mode 100644
index 0000000..de3ef5a
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/ActionDescription.cpp
@@ -0,0 +1,69 @@
+/*****************************************************************
+|
+| Platinum - Managed ActionDescription
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "ActionDescription.h"
+#include "Service.h"
+#include "ActionArgumentDescription.h"
+#include "EnumerableNptArray.h"
+
+Platinum::Service^ Platinum::ActionDescription::ParentService::get()
+{
+ return marshal_as<Service^>(*m_pHandle->GetService());
+}
+
+IEnumerable<Platinum::ActionArgumentDescription^>^ Platinum::ActionDescription::Arguments::get()
+{
+ return gcnew Enumerables::EnumerableNptArray<ActionArgumentDescription^, PLT_ArgumentDesc*>(
+ m_pHandle->GetArgumentDescs()
+ );
+}
+
+Platinum::ActionArgumentDescription^ Platinum::ActionDescription::GetArgument( String^ name )
+{
+ if (String::IsNullOrEmpty(name))
+ throw gcnew ArgumentException("null or empty", "name");
+
+ marshal_context c;
+
+ PLT_ArgumentDesc* arg = m_pHandle->GetArgumentDesc(c.marshal_as<const char*>(name));
+
+ if (!arg)
+ return nullptr;
+
+ return marshal_as<ActionArgumentDescription^>(*arg);
+}
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/ActionDescription.h b/lib/libUPnP/Platinum/Source/Extras/Managed/ActionDescription.h
new file mode 100644
index 0000000..dbbe1a7
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/ActionDescription.h
@@ -0,0 +1,123 @@
+/*****************************************************************
+|
+| Platinum - Managed ActionDescription
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+ref class ActionArgumentDescription;
+ref class Service;
+
+/*----------------------------------------------------------------------
+| ActionDescription
++---------------------------------------------------------------------*/
+public ref class ActionDescription
+{
+private:
+
+ PLT_ActionDesc* m_pHandle;
+
+internal:
+
+ property PLT_ActionDesc& Handle
+ {
+ PLT_ActionDesc& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ property String^ Name
+ {
+ String^ get()
+ {
+ return gcnew String(m_pHandle->GetName());
+ }
+ }
+
+ property IEnumerable<ActionArgumentDescription^>^ Arguments
+ {
+ IEnumerable<ActionArgumentDescription^>^ get();
+ }
+
+ property Service^ ParentService
+ {
+ Service^ get();
+ }
+
+public:
+
+ ActionArgumentDescription^ GetArgument(String^ name);
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (m_pHandle == ((ActionDescription^)obj)->m_pHandle);
+ }
+
+internal:
+
+ ActionDescription(PLT_ActionDesc& devData)
+ {
+ m_pHandle = &devData;
+ }
+
+public:
+
+ ~ActionDescription()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!ActionDescription();
+ }
+
+ !ActionDescription()
+ {
+ }
+
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::ActionDescription, PLT_ActionDesc);
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Clix.h b/lib/libUPnP/Platinum/Source/Extras/Managed/Clix.h
new file mode 100644
index 0000000..2b93f60
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Clix.h
@@ -0,0 +1,202 @@
+// ------------------------------------------------------------------------------------------- //
+// clix.h
+//
+// http://www.nuclex.org/articles/5-cxx/10-marshaling-strings-in-cxx-cli
+//
+// Marshals strings between .NET and C++ using C++/CLI (Visual C++ 2005 and later only).
+// Faster and cleaner than the System::Interop method because it uses garbage collected memory.
+// Use at your own leisure. No warranties whatsoever provided.
+//
+// Original code by Markus Ewald (http://www.nuclex.org/articles/marshaling-strings-in-cxx-cli)
+// Updated version including several improvements suggested by Neil Hunt
+// ------------------------------------------------------------------------------------------- //
+#pragma once
+
+#include <string>
+#include <vcclr.h>
+
+// CLI extensions namespace
+namespace clix {
+
+ /// <summary>Encoding types for strings</summary>
+ enum Encoding {
+
+ /// <summary>ANSI encoding</summary>
+ /// <remarks>
+ /// This is the default encoding you've most likely been using all around in C++. ANSI
+ /// means 8 Bit encoding with character codes depending on the system's selected code page.
+ /// <remarks>
+ E_ANSI,
+
+ /// <summary>UTF-8 encoding</summary>
+ /// <remarks>
+ /// This is the encoding commonly used for multilingual C++ strings. All ASCII characters
+ /// (0-127) will be represented as single bytes. Be aware that UTF-8 uses more than one
+ /// byte for extended characters, so std::string::length() might not reflect the actual
+ /// length of the string in characters if it contains any non-ASCII characters.
+ /// <remarks>
+ E_UTF8,
+
+ /// <summary>UTF-16 encoding</summary>
+ /// <remarks>
+ /// This is the suggested to be used for marshaling and the native encoding of .NET
+ /// strings. It is similar to UTF-8 but uses a minimum of two bytes per character, making
+ /// the number of bytes required for a given string better predictable. Be aware, however,
+ /// that UTF-16 can still use more than two bytes for a character, so std::wstring::length()
+ /// might not reflect the actual length of the string.
+ /// </remarks>
+ E_UTF16, E_UNICODE = E_UTF16
+
+ };
+
+ // Ignore this if you're just scanning the headers for informations :-)
+ /* All this template stuff might seem like overkill, but it is well thought out and enables
+ you to use a readable and convenient call while still keeping the highest possible code
+ efficiency due to compile-time evaluation of the required conversion path.
+ */
+ namespace detail {
+
+ // Get C++ string type for specified encoding
+ template<Encoding encoding> struct StringTypeSelecter;
+ template<> struct StringTypeSelecter<E_ANSI> { typedef std::string Type; };
+ template<> struct StringTypeSelecter<E_UTF8> { typedef std::string Type; };
+ template<> struct StringTypeSelecter<E_UTF16> { typedef std::wstring Type; };
+
+ // Compile-time check whether a given type is a managed System::String
+ template<typename StringType> struct IsManagedString { enum { Result = false }; };
+ template<> struct IsManagedString<System::String ^> { enum { Result = true }; };
+
+ // Compile-time selection of two types depending on a boolean expression
+ template<bool expression> struct Select;
+ template<> struct Select<false> {
+ template<typename TrueType, typename FalseType> struct Type { typedef FalseType Result; };
+ };
+ template<> struct Select<true> {
+ template<typename TrueType, typename FalseType> struct Type { typedef TrueType Result; };
+ };
+
+ // Direction of the marshaling process
+ enum MarshalingDirection {
+ CxxFromNet,
+ NetFromCxx
+ };
+
+ // The actual marshaling code
+ template<MarshalingDirection direction> struct StringMarshaler;
+
+ // Marshals to .NET from C++ strings
+ template<> struct StringMarshaler<NetFromCxx> {
+
+ template<Encoding encoding, typename SourceType>
+ static System::String ^marshal(const SourceType &string) {
+ // Constructs a std::[w]string in case someone gave us a char * to choke on
+ return marshalCxxString<encoding, SourceType>(string);
+ }
+
+ template<Encoding encoding, typename SourceType>
+ static System::String ^marshalCxxString(
+ const typename StringTypeSelecter<encoding>::Type &cxxString
+ ) {
+ typedef typename StringTypeSelecter<encoding>::Type SourceStringType;
+ size_t byteCount = cxxString.length() * sizeof(SourceStringType::value_type);
+
+ // Copy the C++ string contents into a managed array of bytes
+ array<unsigned char> ^bytes = gcnew array<unsigned char>(byteCount);
+ { pin_ptr<unsigned char> pinnedBytes = &bytes[0];
+ memcpy(pinnedBytes, cxxString.c_str(), byteCount);
+ }
+
+ // Now let one of .NET's encoding classes do the rest
+ return decode<encoding>(bytes);
+ }
+
+ private:
+ // Converts a byte array based on the selected encoding
+ template<Encoding encoding> static System::String ^decode(array<unsigned char> ^bytes);
+ template<> static System::String ^decode<E_ANSI>(array<unsigned char> ^bytes) {
+ return System::Text::Encoding::Default->GetString(bytes);
+ }
+ template<> static System::String ^decode<E_UTF8>(array<unsigned char> ^bytes) {
+ return System::Text::Encoding::UTF8->GetString(bytes);
+ }
+ template<> static System::String ^decode<E_UTF16>(array<unsigned char> ^bytes) {
+ return System::Text::Encoding::Unicode->GetString(bytes);
+ }
+ };
+
+ // Marshals to C++ strings from .NET
+ template<> struct StringMarshaler<CxxFromNet> {
+
+ template<Encoding encoding, typename SourceType>
+ static typename detail::StringTypeSelecter<encoding>::Type marshal(
+ System::String ^string
+ ) {
+ typedef typename StringTypeSelecter<encoding>::Type StringType;
+
+ // First, we use .NET's encoding classes to convert the string into a byte array
+ array<unsigned char> ^bytes = encode<encoding>(string);
+
+ // fix crash if empty string passed
+ if (bytes->Length == 0) return StringType();
+
+ // Then we construct our native string from that byte array
+ pin_ptr<unsigned char> pinnedBytes(&bytes[0]);
+ return StringType(
+ reinterpret_cast<StringType::value_type *>(static_cast<unsigned char *>(pinnedBytes)),
+ bytes->Length / sizeof(StringType::value_type)
+ );
+ }
+
+ template<> static std::wstring marshal<E_UTF16, System::String ^>(
+ System::String ^string
+ ) {
+ // fix crash if empty string passed
+ if (string->Length == 0) return std::wstring();
+
+ // We can directly access the characters in the managed string
+ pin_ptr<const wchar_t> pinnedChars(::PtrToStringChars(string));
+ return std::wstring(pinnedChars, string->Length);
+ }
+
+ private:
+ // Converts a string based on the selected encoding
+ template<Encoding encoding> static array<unsigned char> ^encode(System::String ^string);
+ template<> static array<unsigned char> ^encode<E_ANSI>(System::String ^string) {
+ return System::Text::Encoding::Default->GetBytes(string);
+ }
+ template<> static array<unsigned char> ^encode<E_UTF8>(System::String ^string) {
+ return System::Text::Encoding::UTF8->GetBytes(string);
+ }
+ template<> static array<unsigned char> ^encode<E_UTF16>(System::String ^string) {
+ return System::Text::Encoding::Unicode->GetBytes(string);
+ }
+
+ };
+
+ } // namespace detail
+
+ // ----------------------------------------------------------------------------------------- //
+ // clix::marshalString()
+ // ----------------------------------------------------------------------------------------- //
+ /// <summary>Marshals strings between .NET managed and C++ native</summary>
+ /// <remarks>
+ /// This all-in-one function marshals native C++ strings to .NET strings and vice versa.
+ /// You have to specify an encoding to use for the conversion, which always applies to the
+ /// native C++ string as .NET always uses UTF-16 for its own strings.
+ /// </remarks>
+ /// <param name="string">String to be marshalled to the other side</param>
+ /// <returns>The marshaled representation of the string</returns>
+ template<Encoding encoding, typename SourceType>
+ typename detail::Select<detail::IsManagedString<SourceType>::Result>::Type<
+ typename detail::StringTypeSelecter<encoding>::Type,
+ System::String ^
+ >::Result marshalString(SourceType string) {
+
+ // Pass on the call to our nifty template routines
+ return detail::StringMarshaler<
+ detail::IsManagedString<SourceType>::Result ? detail::CxxFromNet : detail::NetFromCxx
+ >::marshal<encoding, SourceType>(string);
+
+ }
+
+} // namespace clix
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPoint.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPoint.cpp
new file mode 100644
index 0000000..506dbec
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPoint.cpp
@@ -0,0 +1,115 @@
+/*****************************************************************
+|
+| Platinum - Managed ControlPoint
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "ControlPoint.h"
+#include "ControlPointEventBridge.h"
+#include "Action.h"
+#include "ActionDescription.h"
+#include "Service.h"
+
+void Platinum::ControlPoint::RegisterEvents()
+{
+ if (!m_pBridge)
+ {
+ m_pBridge = new ControlPointEventBridge(this);
+ }
+
+ Helpers::ThrowOnError((*m_pHandle)->AddListener(m_pBridge));
+}
+
+Platinum::Action^ Platinum::ControlPoint::CreateAction( ActionDescription^ desc )
+{
+ if (desc == nullptr)
+ throw gcnew ArgumentNullException("desc");
+
+ // create action
+ PLT_ActionReference r(new PLT_Action(desc->Handle));
+
+ return gcnew Action(r);
+}
+
+
+void Platinum::ControlPoint::InvokeAction(Action^ action)
+{
+ // register events
+ this->ActionResponse += gcnew ActionResponseDelegate(action, &Action::HandleActionResponse);
+
+ Helpers::ThrowOnError(
+ (*m_pHandle)->InvokeAction(action->Handle)
+ );
+}
+
+void Platinum::ControlPoint::Subscribe( Service^ srv )
+{
+ if (srv == nullptr)
+ throw gcnew ArgumentNullException("srv");
+
+ Helpers::ThrowOnError(
+ (*m_pHandle)->Subscribe(&srv->Handle, false)
+ );
+}
+
+void Platinum::ControlPoint::Unsubscribe( Service^ srv )
+{
+ if (srv == nullptr)
+ throw gcnew ArgumentNullException("srv");
+
+ Helpers::ThrowOnError(
+ (*m_pHandle)->Subscribe(&srv->Handle, true)
+ );
+}
+
+Platinum::ControlPoint::!ControlPoint()
+{
+ // clean-up unmanaged
+ if (m_pHandle != 0)
+ {
+ // remove listener first, is it necessary?
+ if (m_pBridge) (*m_pHandle)->RemoveListener(m_pBridge);
+
+ delete m_pHandle;
+
+ m_pHandle = 0;
+ }
+
+ if (m_pBridge != 0)
+ {
+ delete m_pBridge;
+
+ m_pBridge = 0;
+ }
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPoint.h b/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPoint.h
new file mode 100644
index 0000000..0fd0bba
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPoint.h
@@ -0,0 +1,227 @@
+/*****************************************************************
+|
+| Platinum - Managed ControlPoint
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+ref class Action;
+ref class ActionDescription;
+ref class DeviceData;
+ref class Service;
+ref class StateVariable;
+class ControlPointEventBridge;
+
+/*----------------------------------------------------------------------
+| ControlPoint
++---------------------------------------------------------------------*/
+public ref class ControlPoint
+{
+public:
+
+ delegate void DeviceAddedDelegate(DeviceData^ dev);
+ delegate void DeviceRemovedDelegate(DeviceData^ dev);
+ delegate void ActionResponseDelegate(NeptuneException^ error, Action^ action);
+ delegate void EventNotifyDelegate(Service^ srv, IEnumerable<StateVariable^>^ vars);
+
+private:
+
+ PLT_CtrlPointReference* m_pHandle;
+ ControlPointEventBridge* m_pBridge;
+ List<DeviceData^>^ m_pDevices;
+
+public:
+
+ property array<DeviceData^>^ Devices
+ {
+ array<DeviceData^>^ get()
+ {
+ System::Threading::Monitor::Enter(m_pDevices);
+
+ return m_pDevices->ToArray();
+
+ System::Threading::Monitor::Exit(m_pDevices);
+ }
+ }
+
+internal:
+
+ property PLT_CtrlPointReference& Handle
+ {
+ PLT_CtrlPointReference& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ event DeviceAddedDelegate^ DeviceAdded;
+ event DeviceRemovedDelegate^ DeviceRemoved;
+ event ActionResponseDelegate^ ActionResponse;
+ event EventNotifyDelegate^ EventNotify;
+
+internal:
+
+ void OnDeviceAdded(DeviceData^ dev)
+ {
+ // add to list
+ System::Threading::Monitor::Enter(m_pDevices);
+
+ m_pDevices->Add(dev);
+
+ System::Threading::Monitor::Exit(m_pDevices);
+
+ // handle events
+ this->DeviceAdded(dev);
+ }
+
+ void OnDeviceRemoved(DeviceData^ dev)
+ {
+ // handle events
+ this->DeviceRemoved(dev);
+
+ // remove from list
+ System::Threading::Monitor::Enter(m_pDevices);
+
+ m_pDevices->Remove(dev);
+
+ System::Threading::Monitor::Exit(m_pDevices);
+ }
+
+ void OnActionResponse(NeptuneException^ error, Action^ action)
+ {
+ this->ActionResponse(error, action);
+ }
+
+ void OnEventNotify(Service^ srv, IEnumerable<StateVariable^>^ vars)
+ {
+ this->EventNotify(srv, vars);
+ }
+
+public:
+
+ Action^ CreateAction(ActionDescription^ desc);
+ void InvokeAction(Action^ action);
+
+ void Subscribe(Service^ srv);
+ void Unsubscribe(Service^ srv);
+
+private:
+
+ void RegisterEvents();
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (*m_pHandle == *((ControlPoint^)obj)->m_pHandle);
+ }
+
+internal:
+
+ ControlPoint(PLT_CtrlPointReference& ctlPoint)
+ {
+ if (ctlPoint.IsNull())
+ throw gcnew ArgumentNullException("ctlPoint");
+
+ m_pHandle = new PLT_CtrlPointReference(ctlPoint);
+
+ RegisterEvents();
+ }
+
+ ControlPoint(PLT_CtrlPoint& ctlPoint)
+ {
+ m_pHandle = new PLT_CtrlPointReference(&ctlPoint);
+
+ RegisterEvents();
+ }
+
+public:
+
+ ControlPoint(String^ autoSearcheviceType)
+ {
+ if (String::IsNullOrEmpty(autoSearcheviceType))
+ {
+ throw gcnew ArgumentException("null or empty", "autoSearcheviceType");
+ }
+
+ marshal_context c;
+
+ m_pHandle = new PLT_CtrlPointReference(
+ new PLT_CtrlPoint(c.marshal_as<const char*>(autoSearcheviceType))
+ );
+
+ m_pDevices = gcnew List<DeviceData^>();
+
+ RegisterEvents();
+ }
+
+ ControlPoint(bool autoSearch)
+ {
+ if (autoSearch)
+ {
+ m_pHandle = new PLT_CtrlPointReference(new PLT_CtrlPoint());
+ }
+ else
+ {
+ m_pHandle = new PLT_CtrlPointReference(new PLT_CtrlPoint(0));
+ }
+
+ m_pDevices = gcnew List<DeviceData^>();
+
+ RegisterEvents();
+ }
+
+ ~ControlPoint()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!ControlPoint();
+ }
+
+ !ControlPoint();
+
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::ControlPoint, PLT_CtrlPoint);
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPointEventBridge.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPointEventBridge.cpp
new file mode 100644
index 0000000..f229202
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPointEventBridge.cpp
@@ -0,0 +1,88 @@
+/*****************************************************************
+|
+| Platinum - Managed ControlPointEventBridge
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "ControlPointEventBridge.h"
+#include "ControlPoint.h"
+#include "DeviceData.h"
+#include "Action.h"
+#include "Service.h"
+#include "EnumerableNptList.h"
+#include "StateVariable.h"
+
+NPT_Result Platinum::ControlPointEventBridge::OnDeviceAdded( PLT_DeviceDataReference& device )
+{
+ m_pControlPoint->OnDeviceAdded(gcnew DeviceData(device));
+
+ return NPT_SUCCESS;
+}
+
+NPT_Result Platinum::ControlPointEventBridge::OnDeviceRemoved( PLT_DeviceDataReference& device )
+{
+ m_pControlPoint->OnDeviceRemoved(gcnew DeviceData(device));
+
+ return NPT_SUCCESS;
+}
+
+NPT_Result Platinum::ControlPointEventBridge::OnActionResponse( NPT_Result res, PLT_ActionReference& action, void* userdata )
+{
+ if (NPT_FAILED(res))
+ {
+ m_pControlPoint->OnActionResponse(
+ gcnew NeptuneException(res),
+ gcnew Action(action)
+ );
+ }
+ else
+ {
+ m_pControlPoint->OnActionResponse(
+ nullptr,
+ gcnew Action(action)
+ );
+ }
+
+ return NPT_SUCCESS;
+}
+
+NPT_Result Platinum::ControlPointEventBridge::OnEventNotify( PLT_Service* service, NPT_List<PLT_StateVariable*>* vars )
+{
+ m_pControlPoint->OnEventNotify(
+ gcnew Service(*service),
+ gcnew Enumerables::EnumerableNptList<StateVariable^, PLT_StateVariable*>(*vars)
+ );
+
+ return NPT_SUCCESS;
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPointEventBridge.h b/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPointEventBridge.h
new file mode 100644
index 0000000..83a6807
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/ControlPointEventBridge.h
@@ -0,0 +1,68 @@
+/*****************************************************************
+|
+| Platinum - Managed ControlPointEventBridge
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+ref class ControlPoint;
+
+/*----------------------------------------------------------------------
+| ControlPointEventBridge
++---------------------------------------------------------------------*/
+private class ControlPointEventBridge : public PLT_CtrlPointListener
+{
+private:
+
+ gcroot<ControlPoint^> m_pControlPoint;
+
+public:
+
+ virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device);
+ virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device);
+ virtual NPT_Result OnActionResponse(NPT_Result res, PLT_ActionReference& action, void* userdata);
+ virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List<PLT_StateVariable*>* vars);
+
+public:
+
+ ControlPointEventBridge(gcroot<ControlPoint^> cp)
+ {
+ m_pControlPoint = cp;
+ }
+ virtual ~ControlPointEventBridge()
+ {}
+
+};
+
+
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceData.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceData.cpp
new file mode 100644
index 0000000..06a6d54
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceData.cpp
@@ -0,0 +1,168 @@
+/*****************************************************************
+|
+| Platinum - Managed DeviceData
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "DeviceData.h"
+#include "Service.h"
+#include "EnumerableNptArray.h"
+
+IEnumerable<Platinum::Service^>^ Platinum::DeviceData::Services::get()
+{
+ return gcnew Enumerables::EnumerableNptArray<Service^, PLT_Service*>(
+ (*m_pHandle)->GetServices()
+ );
+}
+
+IEnumerable<Platinum::DeviceData^>^ Platinum::DeviceData::EmbeddedDevices::get()
+{
+ return gcnew Enumerables::EnumerableNptArrayRef<DeviceData^, PLT_DeviceDataReference>(
+ (*m_pHandle)->GetEmbeddedDevices()
+ );
+}
+
+Platinum::DeviceData^ Platinum::DeviceData::FindEmbeddedDeviceByType( String^ type )
+{
+ if (String::IsNullOrEmpty(type))
+ throw gcnew ArgumentException("null or empty", "type");
+
+ PLT_DeviceDataReference r;
+ marshal_context c;
+
+ Helpers::ThrowOnErrorButNoSuchItem((*m_pHandle)->FindEmbeddedDeviceByType(
+ c.marshal_as<const char*>(type),
+ r
+ ));
+
+ if (r.IsNull())
+ return nullptr;
+
+ return marshal_as<DeviceData^>(r);
+}
+
+Platinum::Service^ Platinum::DeviceData::FindServiceById( String^ id )
+{
+ if (String::IsNullOrEmpty(id))
+ throw gcnew ArgumentException("null or empty", "id");
+
+ PLT_Service* r = 0;
+ marshal_context c;
+
+ Helpers::ThrowOnErrorButNoSuchItem((*m_pHandle)->FindServiceById(
+ c.marshal_as<const char*>(id),
+ r
+ ));
+
+ if (!r)
+ return nullptr;
+
+ return marshal_as<Service^>(*r);
+}
+
+Platinum::Service^ Platinum::DeviceData::FindServiceByType( String^ type )
+{
+ if (String::IsNullOrEmpty(type))
+ throw gcnew ArgumentException("null or empty", "type");
+
+ PLT_Service* r = 0;
+ marshal_context c;
+
+ Helpers::ThrowOnErrorButNoSuchItem((*m_pHandle)->FindServiceByType(
+ c.marshal_as<const char*>(type),
+ r
+ ));
+
+ if (!r)
+ return nullptr;
+
+ return marshal_as<Service^>(*r);
+}
+
+Platinum::Service^ Platinum::DeviceData::FindServiceBySCPDURL( Uri^ url )
+{
+ if (url == nullptr)
+ throw gcnew ArgumentNullException("url");
+
+ PLT_Service* r = 0;
+ marshal_context c;
+
+ Helpers::ThrowOnErrorButNoSuchItem((*m_pHandle)->FindServiceBySCPDURL(
+ c.marshal_as<const char*>(url->ToString()),
+ r
+ ));
+
+ if (!r)
+ return nullptr;
+
+ return marshal_as<Service^>(*r);
+}
+
+Platinum::Service^ Platinum::DeviceData::FindServiceByControlURL( Uri^ url )
+{
+ if (url == nullptr)
+ throw gcnew ArgumentNullException("url");
+
+ PLT_Service* r = 0;
+ marshal_context c;
+
+ Helpers::ThrowOnErrorButNoSuchItem((*m_pHandle)->FindServiceByControlURL(
+ c.marshal_as<const char*>(url->ToString()),
+ r
+ ));
+
+ if (!r)
+ return nullptr;
+
+ return marshal_as<Service^>(*r);
+}
+
+Platinum::Service^ Platinum::DeviceData::FindServiceByEventSubURL( Uri^ url )
+{
+ if (url == nullptr)
+ throw gcnew ArgumentNullException("url");
+
+ PLT_Service* r = 0;
+ marshal_context c;
+
+ Helpers::ThrowOnErrorButNoSuchItem((*m_pHandle)->FindServiceByEventSubURL(
+ c.marshal_as<const char*>(url->ToString()),
+ r
+ ));
+
+ if (!r)
+ return nullptr;
+
+ return marshal_as<Service^>(*r);
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceData.h b/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceData.h
new file mode 100644
index 0000000..e7e321f
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceData.h
@@ -0,0 +1,264 @@
+/*****************************************************************
+|
+| Platinum - Managed DeviceData
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| DeviceIcon
++---------------------------------------------------------------------*/
+public ref class DeviceIcon : public ManagedWrapper<PLT_DeviceIcon>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, MimeType, m_MimeType, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(Int32, Width, m_Width, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(Int32, Height, m_Height, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(Int32, Depth, m_Depth, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, UrlPath, m_UrlPath, m_pHandle);
+
+internal:
+
+ DeviceIcon(PLT_DeviceIcon& native) :
+ ManagedWrapper<PLT_DeviceIcon>(native)
+ {}
+
+public:
+ DeviceIcon() :
+ ManagedWrapper<PLT_DeviceIcon>()
+ {}
+
+ DeviceIcon(String^ mimeType, Int32 width, Int32 height, Int32 depth, String^ urlPath) :
+ ManagedWrapper<PLT_DeviceIcon>()
+ {
+ MimeType = mimeType;
+ Width = width;
+ Height = height;
+ Depth = depth;
+ UrlPath = urlPath;
+ }
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceIcon, PLT_DeviceIcon);
+
+namespace Platinum
+{
+
+ref class Service;
+
+/*----------------------------------------------------------------------
+| DeviceData
++---------------------------------------------------------------------*/
+public ref class DeviceData
+{
+protected:
+
+ PLT_DeviceDataReference* m_pHandle;
+
+public:
+
+ property String^ Description
+ {
+ String^ get()
+ {
+ NPT_String s;
+
+ Helpers::ThrowOnError((*m_pHandle)->GetDescription(s));
+
+ return gcnew String(s);
+ }
+ }
+
+ property Uri^ DescriptionUrl
+ {
+ Uri^ get()
+ {
+ return marshal_as<Uri^>((*m_pHandle)->GetDescriptionUrl());
+ }
+ }
+
+ property Uri^ UrlBase
+ {
+ Uri^ get()
+ {
+ return marshal_as<Uri^>((*m_pHandle)->GetURLBase());
+ }
+ }
+
+ property Uri^ IconUrl
+ {
+ Uri^ get()
+ {
+ return marshal_as<Uri^>((*m_pHandle)->GetIconUrl());
+ }
+ }
+
+ property TimeSpan^ LeaseTime
+ {
+ TimeSpan^ get()
+ {
+ return marshal_as<TimeSpan>((*m_pHandle)->GetLeaseTime());
+ }
+ }
+
+ property String^ UUID
+ {
+ String^ get()
+ {
+ return gcnew String((*m_pHandle)->GetUUID());
+ }
+ }
+
+ property String^ FriendlyName
+ {
+ String^ get()
+ {
+ return gcnew String((*m_pHandle)->GetFriendlyName());
+ }
+ }
+
+ property String^ TypeName
+ {
+ String^ get()
+ {
+ return gcnew String((*m_pHandle)->GetType());
+ }
+ }
+
+ property String^ ModelDescription
+ {
+ String^ get()
+ {
+ return gcnew String((*m_pHandle)->GetModelDescription());
+ }
+ }
+
+ property String^ ParentUUID
+ {
+ String^ get()
+ {
+ return gcnew String((*m_pHandle)->GetParentUUID());
+ }
+ }
+
+ property IEnumerable<Service^>^ Services
+ {
+ IEnumerable<Service^>^ get();
+ }
+
+ property IEnumerable<DeviceData^>^ EmbeddedDevices
+ {
+ IEnumerable<DeviceData^>^ get();
+ }
+
+internal:
+
+ property PLT_DeviceDataReference& Handle
+ {
+ PLT_DeviceDataReference& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ DeviceData^ FindEmbeddedDeviceByType(String^ type);
+ Service^ FindServiceById(String^ serviceId);
+ Service^ FindServiceByType(String^ type);
+ Service^ FindServiceBySCPDURL(Uri^ url);
+ Service^ FindServiceByControlURL(Uri^ url);
+ Service^ FindServiceByEventSubURL(Uri^ url);
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (*m_pHandle == *((DeviceData^)obj)->m_pHandle);
+ }
+
+internal:
+
+ DeviceData(PLT_DeviceDataReference& devData)
+ {
+ if (devData.IsNull())
+ throw gcnew ArgumentNullException("devData");
+
+ m_pHandle = new PLT_DeviceDataReference(devData);
+ }
+
+ DeviceData(PLT_DeviceData& devData)
+ {
+ m_pHandle = new PLT_DeviceDataReference(&devData);
+ }
+
+public:
+
+ ~DeviceData()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!DeviceData();
+ }
+
+ !DeviceData()
+ {
+ // clean-up unmanaged
+ if (m_pHandle != 0)
+ {
+ delete m_pHandle;
+
+ m_pHandle = 0;
+ }
+ }
+
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceData, PLT_DeviceData);
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceData, PLT_DeviceDataReference);
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceHost.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceHost.cpp
new file mode 100644
index 0000000..93b15f3
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceHost.cpp
@@ -0,0 +1,38 @@
+/*****************************************************************
+|
+| Platinum - DeviceHost
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "DeviceHost.h" \ No newline at end of file
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceHost.h b/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceHost.h
new file mode 100644
index 0000000..d920e06
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/DeviceHost.h
@@ -0,0 +1,124 @@
+/*****************************************************************
+|
+| Platinum - DeviceHost
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+#include "DeviceData.h"
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| DeviceHost
++---------------------------------------------------------------------*/
+public ref class DeviceHost : public DeviceData
+{
+private:
+
+ PLT_DeviceHostReference* m_pHostHandle;
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (*m_pHandle == ((DeviceHost^)obj)->Handle);
+ }
+
+internal:
+
+ property PLT_DeviceHostReference& Host
+ {
+ PLT_DeviceHostReference& get()
+ {
+ return *m_pHostHandle;
+ }
+ }
+
+internal:
+
+ DeviceHost(PLT_DeviceHostReference& devHost) :
+ m_pHostHandle(new PLT_DeviceHostReference(devHost)),
+ DeviceData((PLT_DeviceDataReference&)*m_pHostHandle)
+ {
+ }
+
+ DeviceHost(PLT_DeviceHost& devHost) :
+ m_pHostHandle(new PLT_DeviceHostReference(&devHost)),
+ DeviceData((PLT_DeviceDataReference&)*m_pHostHandle) // we must make sure to pass our newly created ref object
+ {
+ }
+
+public:
+
+ void setLeaseTime(TimeSpan^ lease)
+ {
+ (*m_pHostHandle)->SetLeaseTime(NPT_TimeInterval((double)lease->TotalSeconds));
+ }
+
+ NPT_Result AddIcon(DeviceIcon^ icon, array<Byte>^ data)
+ {
+ pin_ptr<Byte> pinnedBuffer = &data[0];
+ return (*m_pHostHandle)->AddIcon(icon->Handle, (const void*)pinnedBuffer, data->Length, true);
+ }
+
+ ~DeviceHost()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!DeviceHost();
+ }
+
+ !DeviceHost()
+ {
+ // clean-up unmanaged
+ if (m_pHostHandle != 0)
+ {
+ delete m_pHostHandle;
+
+ m_pHostHandle = 0;
+ }
+ }
+
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceHost, PLT_DeviceHost);
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::DeviceHost, PLT_DeviceHostReference); \ No newline at end of file
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Didl.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/Didl.cpp
new file mode 100644
index 0000000..9c8e9c2
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Didl.cpp
@@ -0,0 +1,39 @@
+/*****************************************************************
+|
+| Platinum - Managed Didl
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "Didl.h"
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Didl.h b/lib/libUPnP/Platinum/Source/Extras/Managed/Didl.h
new file mode 100644
index 0000000..57b02df
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Didl.h
@@ -0,0 +1,70 @@
+/*****************************************************************
+|
+| Platinum - Managed Didl
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltDidl.h"
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| Didl
++---------------------------------------------------------------------*/
+public ref class Didl
+{
+public:
+
+ static property String^ header
+ {
+ String^ get()
+ {
+ return gcnew String(didl_header);
+ }
+ }
+
+ static property String^ footer
+ {
+ String^ get()
+ {
+ return gcnew String(didl_footer);
+ }
+ }
+
+};
+
+}
+
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/EnumerableNptArray.h b/lib/libUPnP/Platinum/Source/Extras/Managed/EnumerableNptArray.h
new file mode 100644
index 0000000..7d17959
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/EnumerableNptArray.h
@@ -0,0 +1,226 @@
+/*****************************************************************
+|
+| Platinum - Managed EnumerableNptArray
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+namespace Enumerables
+{
+
+/*----------------------------------------------------------------------
+| EnumerableNptArray
++---------------------------------------------------------------------*/
+template<typename T_DotNetType, typename T_NativeType>
+private ref class EnumerableNptArray : public IEnumerable<T_DotNetType>
+{
+private:
+
+ ref class EnumerableNptArrayIterator : public IEnumerator<T_DotNetType>
+ {
+ private:
+
+ const NPT_Array<T_NativeType>* m_pArray;
+ NPT_Ordinal m_Index;
+
+ public:
+
+ virtual property T_DotNetType Current
+ {
+ T_DotNetType get()
+ {
+ return marshal_as<T_DotNetType>(*(*m_pArray)[m_Index]);
+ }
+ }
+
+ private:
+
+ virtual property Object^ Current2
+ {
+ Object^ get() sealed = System::Collections::IEnumerator::Current::get
+ {
+ return marshal_as<T_DotNetType>(*(*m_pArray)[m_Index]); // FIXME: This is a problem when T_NativeType is not a pointer (like PLT_DeviceDataReference for example)
+ }
+ }
+
+ public:
+
+ virtual bool MoveNext()
+ {
+ if (m_Index < m_pArray->GetItemCount() - 1)
+ {
+ m_Index++;
+ }
+
+ return false;
+ }
+
+ virtual void Reset()
+ {
+ m_Index = -1;
+ }
+
+ public:
+
+ EnumerableNptArrayIterator(const NPT_Array<T_NativeType>& array)
+ {
+ m_Index = -1;
+ m_pArray = &array;
+ }
+
+ ~EnumerableNptArrayIterator()
+ {
+ }
+
+ };
+
+private:
+
+ const NPT_Array<T_NativeType>* m_pArray;
+
+public:
+
+ virtual IEnumerator<T_DotNetType>^ GetEnumerator()
+ {
+ return gcnew EnumerableNptArrayIterator(*m_pArray);
+ }
+
+private:
+
+ virtual System::Collections::IEnumerator^ GetEnumerator2() sealed = System::Collections::IEnumerable::GetEnumerator
+ {
+ return gcnew EnumerableNptArrayIterator(*m_pArray);
+ }
+
+public:
+
+ EnumerableNptArray(const NPT_Array<T_NativeType>& array)
+ {
+ m_pArray = &array;
+ }
+};
+
+/*----------------------------------------------------------------------
+| EnumerableNptArrayRef
++---------------------------------------------------------------------*/
+template<typename T_DotNetType, typename T_NativeType>
+private ref class EnumerableNptArrayRef : public IEnumerable<T_DotNetType>
+{
+private:
+
+ ref class EnumerableNptArrayRefIterator : public IEnumerator<T_DotNetType>
+ {
+ private:
+
+ const NPT_Array<T_NativeType>* m_pArray;
+ NPT_Ordinal m_Index;
+
+ public:
+
+ virtual property T_DotNetType Current
+ {
+ T_DotNetType get()
+ {
+ return marshal_as<T_DotNetType>((*m_pArray)[m_Index]);
+ }
+ }
+
+ private:
+
+ virtual property Object^ Current2
+ {
+ Object^ get() sealed = System::Collections::IEnumerator::Current::get
+ {
+ return marshal_as<T_DotNetType>((*m_pArray)[m_Index]); // FIXME: This is a problem when T_NativeType is not a pointer (like PLT_DeviceDataReference for example)
+ }
+ }
+
+ public:
+
+ virtual bool MoveNext()
+ {
+ if (m_Index < m_pArray->GetItemCount() - 1)
+ {
+ m_Index++;
+ }
+
+ return false;
+ }
+
+ virtual void Reset()
+ {
+ m_Index = -1;
+ }
+
+ public:
+
+ EnumerableNptArrayRefIterator(const NPT_Array<T_NativeType>& array)
+ {
+ m_Index = -1;
+ m_pArray = &array;
+ }
+
+ ~EnumerableNptArrayRefIterator()
+ {
+ }
+
+ };
+
+private:
+
+ const NPT_Array<T_NativeType>* m_pArray;
+
+public:
+
+ virtual IEnumerator<T_DotNetType>^ GetEnumerator()
+ {
+ return gcnew EnumerableNptArrayRefIterator(*m_pArray);
+ }
+
+private:
+
+ virtual System::Collections::IEnumerator^ GetEnumerator2() sealed = System::Collections::IEnumerable::GetEnumerator
+ {
+ return gcnew EnumerableNptArrayRefIterator(*m_pArray);
+ }
+
+public:
+
+ EnumerableNptArrayRef(const NPT_Array<T_NativeType>& array)
+ {
+ m_pArray = &array;
+ }
+};
+
+}
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/EnumerableNptList.h b/lib/libUPnP/Platinum/Source/Extras/Managed/EnumerableNptList.h
new file mode 100644
index 0000000..fea89ae
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/EnumerableNptList.h
@@ -0,0 +1,234 @@
+/*****************************************************************
+|
+| Platinum - Managed EnumerableNptList
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+namespace Enumerables
+{
+
+/*----------------------------------------------------------------------
+| EnumerableNptList
++---------------------------------------------------------------------*/
+template<typename T_DotNetType, typename T_NativeType>
+private ref class EnumerableNptList : public IEnumerable<T_DotNetType>
+{
+private:
+
+ ref class EnumerableNptListIterator : public IEnumerator<T_DotNetType>
+ {
+ private:
+
+ const NPT_List<T_NativeType>* m_pList;
+ typename NPT_List<T_NativeType>::Iterator* m_pIt;
+
+ public:
+
+ virtual property T_DotNetType Current
+ {
+ T_DotNetType get()
+ {
+ return marshal_as<T_DotNetType>(***m_pIt); // FIXME: This is a problem when T_NativeType is not a pointer (like PLT_DeviceDataReference for example)
+ }
+ }
+
+ private:
+
+ virtual property Object^ Current2
+ {
+ Object^ get() sealed = System::Collections::IEnumerator::Current::get
+ {
+ return marshal_as<T_DotNetType>(***m_pIt); // FIXME: This is a problem when T_NativeType is not a pointer (like PLT_DeviceDataReference for example)
+ }
+ }
+
+ public:
+
+ virtual bool MoveNext()
+ {
+ if (!m_pIt)
+ {
+ m_pIt = &m_pList->GetFirstItem();
+ }
+ else
+ {
+ (*m_pIt)++;
+ }
+
+ return *m_pIt;
+ }
+
+ virtual void Reset()
+ {
+ m_pIt = 0;
+ }
+
+ public:
+
+ EnumerableNptListIterator(const NPT_List<T_NativeType>& list)
+ {
+ m_pIt = 0;
+ m_pList = &list;
+ }
+
+ ~EnumerableNptListIterator()
+ {
+ }
+
+ };
+
+private:
+
+ const NPT_List<T_NativeType>* m_pList;
+
+public:
+
+ virtual IEnumerator<T_DotNetType>^ GetEnumerator()
+ {
+ return gcnew EnumerableNptListIterator(*m_pList);
+ }
+
+private:
+
+ virtual System::Collections::IEnumerator^ GetEnumerator2() sealed = System::Collections::IEnumerable::GetEnumerator
+ {
+ return gcnew EnumerableNptListIterator(*m_pList);
+ }
+
+public:
+
+ EnumerableNptList(const NPT_List<T_NativeType>& list)
+ {
+ m_pList = &list;
+ }
+};
+
+/*----------------------------------------------------------------------
+| EnumerableNptListRef
++---------------------------------------------------------------------*/
+template<typename T_DotNetType, typename T_NativeType>
+private ref class EnumerableNptListRef : public IEnumerable<T_DotNetType>
+{
+private:
+
+ ref class EnumerableNptListRefIterator : public IEnumerator<T_DotNetType>
+ {
+ private:
+
+ const NPT_List<T_NativeType>* m_pList;
+ typename NPT_List<T_NativeType>::Iterator* m_pIt;
+
+ public:
+
+ virtual property T_DotNetType Current
+ {
+ T_DotNetType get()
+ {
+ return marshal_as<T_DotNetType>(**m_pIt);
+ }
+ }
+
+ private:
+
+ virtual property Object^ Current2
+ {
+ Object^ get() sealed = System::Collections::IEnumerator::Current::get
+ {
+ return marshal_as<T_DotNetType>(**m_pIt);
+ }
+ }
+
+ public:
+
+ virtual bool MoveNext()
+ {
+ if (!m_pIt)
+ {
+ m_pIt = &m_pList->GetFirstItem();
+ }
+ else
+ {
+ (*m_pIt)++;
+ }
+
+ return *m_pIt;
+ }
+
+ virtual void Reset()
+ {
+ m_pIt = 0;
+ }
+
+ public:
+
+ EnumerableNptListRefIterator(const NPT_List<T_NativeType>& list)
+ {
+ m_pIt = 0;
+ m_pList = &list;
+ }
+
+ ~EnumerableNptListRefIterator()
+ {
+ }
+
+ };
+
+private:
+
+ const NPT_List<T_NativeType>* m_pList;
+
+public:
+
+ virtual IEnumerator<T_DotNetType>^ GetEnumerator()
+ {
+ return gcnew EnumerableNptListRefIterator(*m_pList);
+ }
+
+private:
+
+ virtual System::Collections::IEnumerator^ GetEnumerator2() sealed = System::Collections::IEnumerable::GetEnumerator
+ {
+ return gcnew EnumerableNptListRefIterator(*m_pList);
+ }
+
+public:
+
+ EnumerableNptListRef(const NPT_List<T_NativeType>& list)
+ {
+ m_pList = &list;
+ }
+};
+
+}
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Helpers.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/Helpers.cpp
new file mode 100644
index 0000000..3dbefdf
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Helpers.cpp
@@ -0,0 +1,39 @@
+/*****************************************************************
+|
+| Platinum - Managed Helpers
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "Helpers.h"
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Helpers.h b/lib/libUPnP/Platinum/Source/Extras/Managed/Helpers.h
new file mode 100644
index 0000000..13a9764
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Helpers.h
@@ -0,0 +1,378 @@
+/*****************************************************************
+|
+| Platinum - Managed Helpers
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "NeptuneException.h"
+#include "Clix.h"
+
+using namespace clix;
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| Helpers
++---------------------------------------------------------------------*/
+private ref class Helpers
+{
+public:
+
+ static void ThrowOnError(NPT_Result r)
+ {
+ if (NPT_FAILED(r))
+ {
+ throw gcnew NeptuneException(r);
+ }
+ }
+
+ static void ThrowOnErrorButNoSuchItem(NPT_Result r)
+ {
+ if (NPT_FAILED(r) && (r != NPT_ERROR_NO_SUCH_ITEM))
+ {
+ throw gcnew NeptuneException(r);
+ }
+ }
+
+ // this code was part of RouterControl.IO (http://routercontrol.codeplex.com)
+ // for more details see:
+ // http://www.knopflerfish.org/releases/current/docs/jars/upnp/upnp_api-2.0.0/src/org/osgi/service/upnp/UPnPStateVariable.java
+ static Type^ ParseType(const NPT_String& upnpType)
+ {
+ NPT_String s (upnpType);
+
+ s.MakeLowercase();
+
+ if (s == "string")
+ return String::typeid;
+
+ if (s == "char")
+ return Char::typeid;
+
+ if (s == "boolean")
+ return Boolean::typeid;
+
+ if (s == "ui1")
+ return Byte::typeid;
+
+ if (s == "ui2")
+ return UInt16::typeid;
+
+ if (s == "ui4")
+ return UInt32::typeid;
+
+ if (s == "i1")
+ return SByte::typeid;
+
+ if (s == "i2")
+ return Int16::typeid;
+
+ if ((s == "i4") || (s == "int"))
+ return Int32::typeid;
+
+ if ((s == "r4") || (s == "float"))
+ return Single::typeid;
+
+ if ((s == "r8") || (s == "number") || (s == "fixed.14.4"))
+ return Double::typeid;
+
+ if ((s == "date") || (s == "datetime") || (s == "datetime.tz"))
+ return DateTime::typeid;
+
+ if ((s == "time") || (s == "time.tz")) // milliseconds since midnight
+ return UInt64::typeid;
+
+ if ((s == "bin.base64") || (s == "bin.hex"))
+ return array<Byte>::typeid;
+
+ if (s == "uri")
+ return Uri::typeid;
+
+ if (s == "uuid")
+ return Guid::typeid;
+
+ throw gcnew ArgumentException("unknown type", "upnpType");
+ }
+
+ static Object^ ConvertValue(const NPT_String& targetType, const NPT_String& val)
+ {
+ return ConvertValue(ParseType(targetType), val);
+ }
+
+ static Object^ ConvertValue(Type^ targetType, const NPT_String& val)
+ {
+ String^ strVal = gcnew String(val);
+
+ if (targetType == String::typeid)
+ return strVal;
+
+ if (targetType == Char::typeid)
+ {
+ if (val.IsEmpty())
+ throw gcnew ArgumentException("character value is empty", "val");
+
+ return Char(val[0]);
+ }
+
+ if (targetType == Boolean::typeid)
+ return Convert::ToBoolean(strVal);
+
+ if (targetType == Byte::typeid)
+ return Convert::ToByte(strVal);
+
+ if (targetType == SByte::typeid)
+ return Convert::ToSByte(strVal);
+
+ if (targetType == UInt16::typeid)
+ return Convert::ToUInt16(strVal);
+
+ if (targetType == UInt32::typeid)
+ return Convert::ToUInt32(strVal);
+
+ if (targetType == UInt64::typeid)
+ return Convert::ToUInt64(strVal);
+
+ if (targetType == Int16::typeid)
+ return Convert::ToInt16(strVal);
+
+ if (targetType == Int32::typeid)
+ return Convert::ToInt32(strVal);
+
+ if (targetType == Int64::typeid)
+ return Convert::ToInt64(strVal);
+
+ if (targetType == Single::typeid)
+ return Convert::ToSingle(strVal);
+
+ if (targetType == Double::typeid)
+ return Convert::ToDouble(strVal);
+
+ if (targetType == DateTime::typeid)
+ return Convert::ToDateTime(strVal);
+
+ if (targetType == array<Byte>::typeid)
+ return Convert::FromBase64String(strVal);
+
+ if (targetType == Uri::typeid)
+ return marshal_as<Uri^>(val);
+
+ if (targetType == Guid::typeid)
+ return gcnew Guid(strVal);
+
+ throw gcnew ArgumentException("unsupported type", "targetType");
+ }
+
+};
+
+/*----------------------------------------------------------------------
+| StringConv
++---------------------------------------------------------------------*/
+struct StringConv
+{
+ gcroot<msclr::interop::marshal_context^> c;
+ //const char* szAnsi;
+ std::string szAnsi;
+
+ StringConv(System::String^ s) :
+ //c(gcnew msclr::interop::marshal_context),
+ //szAnsi(c->marshal_as<E_UTF8>(s))
+ szAnsi(marshalString<E_UTF8>(s))
+ {}
+
+ ~StringConv()
+ {}
+
+ operator const char*() const
+ {
+ //return szAnsi;
+ return szAnsi.c_str();
+ }
+};
+
+/*----------------------------------------------------------------------
+| StringConvA
++---------------------------------------------------------------------*/
+struct StringConvA
+{
+ char* szAnsi;
+
+ StringConvA(System::String^ s) :
+ szAnsi(static_cast<char*>(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(s).ToPointer()))
+ {}
+
+ ~StringConvA()
+ {
+
+ System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(szAnsi));
+ }
+
+ operator LPCSTR() const
+ {
+ return szAnsi;
+ }
+};
+
+/*----------------------------------------------------------------------
+| StringConvW
++---------------------------------------------------------------------*/
+struct StringConvW
+{
+ wchar_t* szUnicode;
+
+ StringConvW(System::String^ s) :
+ szUnicode(static_cast<wchar_t*>(System::Runtime::InteropServices::Marshal::StringToHGlobalUni(s).ToPointer()))
+ {}
+
+ ~StringConvW()
+ {
+
+ System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(szUnicode));
+ }
+
+ operator LPCWSTR() const
+ {
+ return szUnicode;
+ }
+};
+
+/*----------------------------------------------------------------------
+| ManagedWrapper
++---------------------------------------------------------------------*/
+template<typename T_NativeType>
+public ref class ManagedWrapper
+{
+protected:
+
+ T_NativeType* m_pHandle;
+ bool m_Owned;
+
+internal:
+
+ property T_NativeType& Handle
+ {
+ T_NativeType& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (m_pHandle == ((ManagedWrapper^)obj)->m_pHandle);
+ }
+
+internal:
+
+ ManagedWrapper() : m_Owned(true)
+ {
+ m_pHandle = new T_NativeType();
+ }
+
+ /*ManagedWrapper(ManagedWrapper^ obj)
+ {
+ m_pHandle = new T_NativeType(obj->Handle);
+ }
+
+ ManagedWrapper(T_NativeType object_class) : m_Owned(true)
+ {
+ m_pHandle = new T_NativeType(object_class.Handle);
+ }*/
+
+ ManagedWrapper(T_NativeType& object_class) : m_Owned(false)
+ {
+ // IMPORTANT: we're keeping a reference of the native pointer
+ // so passing a reference to a local variable allocated on the stack is not OK
+ m_pHandle = &object_class;
+ }
+
+public:
+
+ ~ManagedWrapper()
+ {
+ this->!ManagedWrapper();
+ }
+
+ !ManagedWrapper()
+ {
+ if (m_pHandle != 0 && m_Owned)
+ {
+ delete m_pHandle;
+ }
+
+ m_pHandle = 0;
+ }
+};
+
+}
+
+#define PLATINUM_MANAGED_IMPLEMENT_PROPERTY(propertyType, propertyName, nativeVar, nativePtr) \
+property propertyType propertyName { \
+ propertyType get() { \
+ return (nativePtr##->##nativeVar); \
+ } \
+ void set(propertyType var) { \
+ nativePtr##->##nativeVar = (var); \
+ } \
+}
+
+#define PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(propertyType, propertyName, nativeVar, nativePtr) \
+property propertyType propertyName { \
+ propertyType get() { \
+ return marshal_as<propertyType>(nativePtr##->##nativeVar); \
+ } \
+ void set(propertyType var) { \
+ std::string s = marshalString<E_UTF8>(var); \
+ nativePtr##->##nativeVar = s.c_str(); \
+ } \
+}
+
+#define PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(propertyType, propertyName, nativeVar, nativePtr) \
+property propertyType propertyName { \
+ propertyType get() { \
+ return marshal_as<propertyType>(nativePtr##->##nativeVar); \
+ } \
+ void set(propertyType var) { \
+ nativePtr##->##nativeVar = var->Handle; \
+ } \
+}
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Http.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/Http.cpp
new file mode 100644
index 0000000..155b307
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Http.cpp
@@ -0,0 +1,38 @@
+/*****************************************************************
+|
+| Platinum - Managed Http
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "Http.h"
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Http.h b/lib/libUPnP/Platinum/Source/Extras/Managed/Http.h
new file mode 100644
index 0000000..01059f4
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Http.h
@@ -0,0 +1,286 @@
+/*****************************************************************
+|
+| Platinum - Managed Http
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| HttpRequest
++---------------------------------------------------------------------*/
+public ref class HttpRequest
+{
+protected:
+
+ NPT_HttpRequest* m_pHandle;
+
+internal:
+
+ property NPT_HttpRequest& Handle
+ {
+ NPT_HttpRequest& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (m_pHandle == ((HttpRequest^)obj)->m_pHandle);
+ }
+
+public:
+
+ // properties
+ virtual property Uri^ URI
+ {
+ Uri^ get()
+ {
+ return marshal_as<Uri^>(m_pHandle->GetUrl());
+ }
+ }
+
+internal:
+
+ // Note: Because a NPT_HttpRequest cannot do a deep copy,
+ // this only refers to the original native object
+ HttpRequest(NPT_HttpRequest& native) :
+ m_pHandle(&native)
+ {
+ }
+
+public:
+
+ ~HttpRequest()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!HttpRequest();
+ }
+
+ !HttpRequest()
+ {
+ // clean-up unmanaged
+ }
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::HttpRequest, NPT_HttpRequest);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| HttpRequest
++---------------------------------------------------------------------*/
+public ref class HttpResponse
+{
+protected:
+
+ NPT_HttpResponse* m_pHandle;
+
+internal:
+
+ property NPT_HttpResponse& Handle
+ {
+ NPT_HttpResponse& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (m_pHandle == ((HttpResponse^)obj)->m_pHandle);
+ }
+
+internal:
+
+ // Note: Because a NPT_HttpResponse cannot do a deep copy,
+ // this only refers to the original native object
+ HttpResponse(NPT_HttpResponse& native) :
+ m_pHandle(&native)
+ {
+ }
+
+public:
+
+ ~HttpResponse()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!HttpResponse();
+ }
+
+ !HttpResponse()
+ {
+ // clean-up unmanaged
+ }
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::HttpResponse, NPT_HttpResponse);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| DeviceSignature
++---------------------------------------------------------------------*/
+public enum class DeviceSignature
+{
+ Unknown,
+ XBox,
+ PS3,
+ WMP
+};
+
+/*----------------------------------------------------------------------
+| HttpRequestContext
++---------------------------------------------------------------------*/
+public ref class HttpRequestContext : ManagedWrapper<PLT_HttpRequestContext>
+{
+
+public:
+
+ ref struct SocketAddress {
+ String^ ip;
+ UInt32 port;
+ };
+
+ virtual property SocketAddress^ LocalAddress
+ {
+ SocketAddress^ get()
+ {
+ SocketAddress^ local = gcnew SocketAddress;
+ local->ip = marshal_as<String^>(Handle.GetLocalAddress().GetIpAddress().ToString());
+ local->port = Handle.GetLocalAddress().GetPort();
+ return local;
+ }
+ }
+
+ virtual property SocketAddress^ RemoteAddress
+ {
+ SocketAddress^ get()
+ {
+ SocketAddress^ local = gcnew SocketAddress;
+ local->ip = marshal_as<String^>(Handle.GetRemoteAddress().GetIpAddress().ToString());
+ local->port = Handle.GetRemoteAddress().GetPort();
+ return local;
+ }
+ }
+
+ virtual property HttpRequest^ Request
+ {
+ HttpRequest^ get()
+ {
+ return marshal_as<HttpRequest^>(m_pHandle->GetRequest());
+ }
+ }
+
+ virtual property DeviceSignature Signature
+ {
+ DeviceSignature get()
+ {
+ return ParseDeviceSignature(m_pHandle->GetDeviceSignature());
+ }
+ }
+private:
+
+ static DeviceSignature ParseDeviceSignature(PLT_DeviceSignature signature)
+ {
+ switch (signature)
+ {
+ case PLT_DEVICE_XBOX:
+ return DeviceSignature::XBox;
+ case PLT_DEVICE_PS3:
+ return DeviceSignature::PS3;
+ case PLT_DEVICE_WMP:
+ return DeviceSignature::WMP;
+ default:
+ return DeviceSignature::Unknown;
+ }
+ }
+
+
+internal:
+
+ HttpRequestContext(PLT_HttpRequestContext& native) :
+ ManagedWrapper<PLT_HttpRequestContext>(native)
+ {
+ }
+
+ ~HttpRequestContext()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!HttpRequestContext();
+ }
+
+ !HttpRequestContext()
+ {
+ // clean-up unmanaged
+ }
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::HttpRequestContext, PLT_HttpRequestContext);
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/MediaConnect.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaConnect.cpp
new file mode 100644
index 0000000..f31b433
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaConnect.cpp
@@ -0,0 +1,59 @@
+/*****************************************************************
+|
+| Platinum - Managed MediaConnect
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "MediaConnect.h"
+#include "PltMediaConnect.h"
+
+Platinum::MediaConnect::MediaConnect(PLT_MediaConnect* server) :
+ MediaServer((PLT_MediaServer*)server)
+{
+}
+
+Platinum::MediaConnect::MediaConnect(String^ friendlyName) :
+ MediaServer(new PLT_MediaConnect(StringConv(friendlyName)))
+{
+}
+
+Platinum::MediaConnect::MediaConnect(String^ friendlyName, String^ uuid, Int16 port) :
+ MediaServer(new PLT_MediaConnect(StringConv(friendlyName), true, StringConv(uuid), port))
+{
+}
+
+Platinum::MediaConnect::!MediaConnect()
+{
+
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/MediaConnect.h b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaConnect.h
new file mode 100644
index 0000000..54a9ec4
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaConnect.h
@@ -0,0 +1,80 @@
+/*****************************************************************
+|
+| Platinum - Managed MediaConnect
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "MediaServer.h"
+
+class PLT_MediaConnect;
+
+namespace Platinum
+{
+
+ref class MediaServer;
+
+/*----------------------------------------------------------------------
+| MediaConnect
++---------------------------------------------------------------------*/
+public ref class MediaConnect : public MediaServer
+{
+public:
+
+private:
+
+
+public:
+
+ // properties
+
+private:
+
+public:
+
+ MediaConnect(String^ friendlyName);
+ MediaConnect(String^ friendlyName, String^ uuid, Int16 port);
+ MediaConnect(PLT_MediaConnect* server);
+
+ ~MediaConnect()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!MediaConnect();
+ }
+
+ !MediaConnect();
+};
+
+} \ No newline at end of file
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/MediaObject.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaObject.cpp
new file mode 100644
index 0000000..23b56a7
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaObject.cpp
@@ -0,0 +1,118 @@
+/*****************************************************************
+|
+| Platinum - Managed MediaObject
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "MediaObject.h"
+#include "EnumerableNptArray.h"
+#include "EnumerableNptList.h"
+
+IEnumerable<Platinum::PersonRole^>^ Platinum::PeopleInfo::Actors::get()
+{
+ return gcnew Enumerables::EnumerableNptListRef<PersonRole^, PLT_PersonRole>(
+ m_pHandle->actors
+ );
+}
+
+IEnumerable<Platinum::PersonRole^>^ Platinum::PeopleInfo::Artists::get()
+{
+ return gcnew Enumerables::EnumerableNptListRef<PersonRole^, PLT_PersonRole>(
+ m_pHandle->artists
+ );
+}
+
+IEnumerable<Platinum::PersonRole^>^ Platinum::PeopleInfo::Authors::get()
+{
+ return gcnew Enumerables::EnumerableNptListRef<PersonRole^, PLT_PersonRole>(
+ m_pHandle->authors
+ );
+}
+
+IEnumerable<System::String^>^ Platinum::AffiliationInfo::Genres::get()
+{
+ return gcnew Enumerables::EnumerableNptListRef<String^, NPT_String>(
+ m_pHandle->genres
+ );
+}
+
+IEnumerable<System::String^>^ Platinum::ExtraInfo::Relations::get()
+{
+ return gcnew Enumerables::EnumerableNptListRef<String^, NPT_String>(
+ m_pHandle->relations
+ );
+}
+
+IEnumerable<Platinum::AlbumArtInfo^>^ Platinum::ExtraInfo::AlbumArts::get()
+{
+ return gcnew Enumerables::EnumerableNptListRef<AlbumArtInfo^, PLT_AlbumArtInfo>(
+ m_pHandle->album_arts
+ );
+}
+
+
+Platinum::ProtocolInfo^ Platinum::ProtocolInfo::GetProtocolInfo(String^ filename,
+ bool with_dlna_extension,
+ HttpRequestContext^ context)
+{
+ return marshal_as<Platinum::ProtocolInfo^>(PLT_ProtocolInfo::GetProtocolInfo(StringConv(filename),
+ with_dlna_extension,
+ (context==nullptr)?NULL:&context->Handle).ToString());
+}
+
+Platinum::ProtocolInfo^ Platinum::ProtocolInfo::GetProtocolInfoFromMimeType(String^ mime_type,
+ bool with_dlna_extension,
+ HttpRequestContext^ context)
+{
+ return marshal_as<Platinum::ProtocolInfo^>(PLT_ProtocolInfo::GetProtocolInfoFromMimeType(StringConv(mime_type),
+ with_dlna_extension,
+ (context==nullptr)?NULL:&context->Handle).ToString());
+}
+
+Platinum::MediaItem^ Platinum::MediaObject::item()
+{
+ return gcnew MediaItem(this);
+}
+
+Platinum::MediaContainer^ Platinum::MediaObject::container()
+{
+ return gcnew MediaContainer(this);
+}
+
+IEnumerable<Platinum::MediaResource^>^ Platinum::MediaObject::Resources::get()
+{
+ return gcnew Enumerables::EnumerableNptArrayRef<MediaResource^, PLT_MediaItemResource>(
+ (*m_pHandle)->m_Resources
+ );
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/MediaObject.h b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaObject.h
new file mode 100644
index 0000000..11ebfce
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaObject.h
@@ -0,0 +1,735 @@
+/*****************************************************************
+|
+| Platinum - Managed ActionDescription
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltMediaItem.h"
+#include "Http.h"
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| ObjectClass
++---------------------------------------------------------------------*/
+public ref class ObjectClass : public ManagedWrapper<PLT_ObjectClass>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Type, type, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, FriendlyName, friendly_name, m_pHandle);
+
+internal:
+
+ ObjectClass(PLT_ObjectClass& native) :
+ ManagedWrapper<PLT_ObjectClass>(native)
+ {}
+
+public:
+
+ ObjectClass(String^ type)
+ {
+ Type = type;
+ }
+
+ ObjectClass(String^ type, String^ friendly_name)
+ {
+ Type = type;
+ FriendlyName = friendly_name;
+ }
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::ObjectClass, PLT_ObjectClass);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| PersonRole
++---------------------------------------------------------------------*/
+public ref class PersonRole : public ManagedWrapper<PLT_PersonRole>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Name, name, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Role, role, m_pHandle);
+
+internal:
+
+ PersonRole(PLT_PersonRole& native) :
+ ManagedWrapper<PLT_PersonRole>(native)
+ {}
+
+public:
+ PersonRole(String^ name)
+ {
+ Name = name;
+ }
+
+ PersonRole(String^ name, String^ role)
+ {
+ Name = name;
+ Role = role;
+ }
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::PersonRole, PLT_PersonRole);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| PeopleInfo
++---------------------------------------------------------------------*/
+public ref class PeopleInfo : public ManagedWrapper<PLT_PeopleInfo>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Producer, producer, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Director, director, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Publisher, publisher, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Contributor, contributor, m_pHandle);
+
+ property IEnumerable<PersonRole^>^ Artists
+ {
+ IEnumerable<PersonRole^>^ get();
+ }
+
+ property IEnumerable<PersonRole^>^ Actors
+ {
+ IEnumerable<PersonRole^>^ get();
+ }
+
+ property IEnumerable<PersonRole^>^ Authors
+ {
+ IEnumerable<PersonRole^>^ get();
+ }
+
+public:
+
+ void AddArtist(PersonRole^ artist)
+ {
+ ((NPT_List<PLT_PersonRole>&)m_pHandle->artists).Add(artist->Handle);
+ }
+
+ void AddActor(PersonRole^ actor)
+ {
+ ((NPT_List<PLT_PersonRole>&)m_pHandle->actors).Add(actor->Handle);
+ }
+
+ void AddAuthors(PersonRole^ author)
+ {
+ ((NPT_List<PLT_PersonRole>&)m_pHandle->authors).Add(author->Handle);
+ }
+
+internal:
+
+ PeopleInfo(PLT_PeopleInfo& native) :
+ ManagedWrapper<PLT_PeopleInfo>(native)
+ {}
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::PeopleInfo, PLT_PeopleInfo);
+
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| AffiliationInfo
++---------------------------------------------------------------------*/
+public ref class AffiliationInfo : public ManagedWrapper<PLT_AffiliationInfo>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Album, album, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Playlist, playlist, m_pHandle);
+
+ property IEnumerable<String^>^ Genres
+ {
+ IEnumerable<String^>^ get();
+ }
+
+public:
+
+ void AddGenre(String^ genre)
+ {
+ m_pHandle->genres.Add(NPT_String(StringConv(genre)));
+ }
+
+internal:
+
+ AffiliationInfo(PLT_AffiliationInfo& native) :
+ ManagedWrapper<PLT_AffiliationInfo>(native)
+ {}
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::AffiliationInfo, PLT_AffiliationInfo);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| DescriptionInfo
++---------------------------------------------------------------------*/
+public ref class DescriptionInfo : public ManagedWrapper<PLT_Description>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, DescriptionText, description, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, LongDescriptionText, long_description, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, IconUri, icon_uri, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Region, region, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Rating, rating, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Date, date, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Language, language, m_pHandle);
+
+internal:
+
+ DescriptionInfo(PLT_Description& native) :
+ ManagedWrapper<PLT_Description>(native)
+ {}
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::DescriptionInfo, PLT_Description);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| RecordedInfo
++---------------------------------------------------------------------*/
+public ref class RecordedInfo : public ManagedWrapper<PLT_RecordedInfo>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, ProgramTitle, program_title, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, SeriesTitle, series_title, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, EpisodeNumber, episode_number, m_pHandle);
+
+internal:
+
+ RecordedInfo(PLT_RecordedInfo& native) :
+ ManagedWrapper<PLT_RecordedInfo>(native)
+ {}
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::RecordedInfo, PLT_RecordedInfo);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| AlbumArtInfo
++---------------------------------------------------------------------*/
+public ref class AlbumArtInfo : public ManagedWrapper<PLT_AlbumArtInfo>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Uri, uri, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, DlnaProfile, dlna_profile, m_pHandle);
+
+internal:
+
+ AlbumArtInfo(PLT_AlbumArtInfo& native) :
+ ManagedWrapper<PLT_AlbumArtInfo>(native)
+ {}
+
+public:
+ AlbumArtInfo(String^ uri)
+ {
+ Uri = uri;
+ }
+
+ AlbumArtInfo(String^ uri, String^ dlna_profile)
+ {
+ Uri = uri;
+ DlnaProfile = dlna_profile;
+ }
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::AlbumArtInfo, PLT_AlbumArtInfo);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| ExtraInfo
++---------------------------------------------------------------------*/
+public ref class ExtraInfo : public ManagedWrapper<PLT_ExtraInfo>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, ArtistDiscographyUri, artist_discography_uri, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, LyricsUri, lyrics_uri, m_pHandle);
+
+ property IEnumerable<String^>^ Relations
+ {
+ IEnumerable<String^>^ get();
+ }
+
+ property IEnumerable<AlbumArtInfo^>^ AlbumArts
+ {
+ IEnumerable<AlbumArtInfo^>^ get();
+ }
+
+public:
+
+ void AddGenre(String^ relation)
+ {
+ m_pHandle->relations.Add(NPT_String(StringConv(relation)));
+ }
+
+ void AddAlbumArtInfo(AlbumArtInfo^ info)
+ {
+ m_pHandle->album_arts.Add(info->Handle);
+ }
+
+
+internal:
+
+ ExtraInfo(PLT_ExtraInfo& native) :
+ ManagedWrapper<PLT_ExtraInfo>(native)
+ {}
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::ExtraInfo, PLT_ExtraInfo);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| MiscInfo
++---------------------------------------------------------------------*/
+public ref class MiscInfo : public ManagedWrapper<PLT_MiscInfo>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, DvdRegionCode, dvdregioncode, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, OriginalTrackNumber, original_track_number, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Toc, toc, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, UserAnnotation, user_annotation, m_pHandle);
+
+internal:
+
+ MiscInfo(PLT_MiscInfo& native) :
+ ManagedWrapper<PLT_MiscInfo>(native)
+ {}
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::MiscInfo, PLT_MiscInfo);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| ProtocolInfo
++---------------------------------------------------------------------*/
+public ref class ProtocolInfo : public ManagedWrapper<PLT_ProtocolInfo>
+{
+public:
+
+ // properties
+
+public:
+ static ProtocolInfo^ GetProtocolInfo(String^ filename)
+ {
+ return GetProtocolInfo(filename, true, nullptr);
+ }
+
+ static ProtocolInfo^ GetProtocolInfo(String^ filename,
+ bool with_dlna_extension)
+ {
+ return GetProtocolInfo(filename, with_dlna_extension, nullptr);
+ }
+
+ static ProtocolInfo^ GetProtocolInfo(String^ filename,
+ bool with_dlna_extension,
+ HttpRequestContext^ context);
+
+ static ProtocolInfo^ GetProtocolInfoFromMimeType(String^ mime_type)
+ {
+ return GetProtocolInfoFromMimeType(mime_type, true, nullptr);
+ }
+
+ static ProtocolInfo^ GetProtocolInfoFromMimeType(String^ mime_type,
+ bool with_dlna_extension)
+ {
+ return GetProtocolInfoFromMimeType(mime_type, with_dlna_extension, nullptr);
+ }
+
+ static ProtocolInfo^ GetProtocolInfoFromMimeType(String^ mime_type,
+ bool with_dlna_extension,
+ HttpRequestContext^ context);
+
+internal:
+
+ ProtocolInfo(PLT_ProtocolInfo& native) :
+ ManagedWrapper<PLT_ProtocolInfo>(native)
+ {}
+
+public:
+
+ ProtocolInfo(NPT_String& protocol_info) :
+ ManagedWrapper<PLT_ProtocolInfo>()
+ {
+ *m_pHandle = PLT_ProtocolInfo(protocol_info);
+ }
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::ProtocolInfo, PLT_ProtocolInfo);
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::ProtocolInfo, NPT_String);
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| MediaResource
++---------------------------------------------------------------------*/
+public ref class MediaResource : public ManagedWrapper<PLT_MediaItemResource>
+{
+public:
+
+ // properties
+
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, URI, m_Uri, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(ProtocolInfo^, ProtoInfo, m_ProtocolInfo, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, Duration, m_Duration, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt64, Size, m_Size, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Protection, m_Protection, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, Bitrate, m_Bitrate, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, BitsPerSample, m_BitsPerSample, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, SampleFrequency, m_SampleFrequency, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, NbAudioChannels, m_NbAudioChannels, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Resolution, m_Resolution, m_pHandle);
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, ColorDepth, m_ColorDepth, m_pHandle);
+
+internal:
+
+ MediaResource(PLT_MediaItemResource& native) :
+ ManagedWrapper<PLT_MediaItemResource>(native)
+ {}
+
+public:
+ MediaResource() :
+ ManagedWrapper<PLT_MediaItemResource>()
+ {}
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::MediaResource, PLT_MediaItemResource);
+
+namespace Platinum
+{
+ref class MediaItem;
+ref class MediaContainer;
+
+/*----------------------------------------------------------------------
+| MediaObject
++---------------------------------------------------------------------*/
+public ref class MediaObject
+{
+protected:
+
+ PLT_MediaObjectReference* m_pHandle;
+
+public:
+
+ // properties
+
+ /* common properties */
+ PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(ObjectClass^, Class, m_ObjectClass, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, ObjectID, m_ObjectID, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, ParentID, m_ParentID, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, ReferenceID, m_ReferenceID, (*m_pHandle));
+
+ /* metadata */
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Title, m_Title, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Creator, m_Creator, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_STRING_PROPERTY(String^, Date, m_Date, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(PeopleInfo^, People, m_People, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(AffiliationInfo^, Affiliation, m_Affiliation, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(DescriptionInfo^, Description, m_Description, (*m_pHandle));
+ PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(RecordedInfo^, Recorded, m_Recorded, (*m_pHandle));
+
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(bool, Restricted, m_Restricted, (*m_pHandle));
+
+ /* extras */
+ PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(ExtraInfo^, Extra, m_ExtraInfo, (*m_pHandle));
+
+ /* miscellaneous info */
+ PLATINUM_MANAGED_IMPLEMENT_OBJECT_PROPERTY(MiscInfo^, Miscellaneous, m_MiscInfo, (*m_pHandle));
+
+ property IEnumerable<MediaResource^>^ Resources
+ {
+ IEnumerable<MediaResource^>^ get();
+ }
+
+public:
+
+ void AddResource(MediaResource^ resource)
+ {
+ (*m_pHandle)->m_Resources.Add(resource->Handle);
+ }
+
+internal:
+
+ property PLT_MediaObjectReference& Handle
+ {
+ PLT_MediaObjectReference& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ MediaItem^ item();
+ MediaContainer^ container();
+
+ String^ ToDidl(String^ filter)
+ {
+ NPT_String didl;
+ didl.Reserve(1024);
+
+ marshal_context c;
+ NPT_String _filter(c.marshal_as<const char*>(filter));
+
+ (*m_pHandle)->ToDidl(_filter, didl);
+
+ return marshal_as<String^>(didl.GetChars());
+ }
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (*m_pHandle == *((MediaObject^)obj)->m_pHandle);
+ }
+
+internal:
+
+ MediaObject(PLT_MediaObjectReference& media)
+ {
+ if (media.IsNull())
+ throw gcnew ArgumentNullException("media");
+
+ m_pHandle = new PLT_MediaObjectReference(media);
+ }
+
+ MediaObject(PLT_MediaObject& media)
+ {
+ m_pHandle = new PLT_MediaObjectReference(&media);
+ }
+
+protected:
+
+ MediaObject(PLT_MediaObject* media)
+ {
+ if (media == NULL)
+ throw gcnew ArgumentNullException("media");
+
+ m_pHandle = new PLT_MediaObjectReference(media);
+ }
+
+public:
+
+ ~MediaObject()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!MediaObject();
+ }
+
+ !MediaObject()
+ {
+ // clean-up unmanaged
+ if (m_pHandle != 0)
+ {
+ delete m_pHandle;
+
+ m_pHandle = 0;
+ }
+ }
+
+};
+
+/*----------------------------------------------------------------------
+| MediaItem
++---------------------------------------------------------------------*/
+public ref class MediaItem : public MediaObject
+{
+internal:
+
+ MediaItem(PLT_MediaItem& media) : MediaObject(media)
+ {}
+
+public:
+
+ MediaItem() : MediaObject(new PLT_MediaItem)
+ {}
+
+ MediaItem(PLT_MediaObjectReference& media) : MediaObject(media)
+ {
+ if (media->IsContainer())
+ throw gcnew ArgumentException("object");
+ }
+
+ MediaItem(MediaObject^ media) : MediaObject(*media->Handle)
+ {
+ if (media->Handle->IsContainer())
+ throw gcnew ArgumentException("object");
+ }
+
+ ~MediaItem()
+ {
+ this->!MediaItem();
+ }
+
+ !MediaItem()
+ {}
+};
+
+/*----------------------------------------------------------------------
+| MediaContainer
++---------------------------------------------------------------------*/
+public ref class MediaContainer : public MediaObject
+{
+public:
+
+ // properties
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(bool, Searchable, m_Searchable, ((PLT_MediaContainer*)m_pHandle->AsPointer()));
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(Int32, ChildrenCount, m_ChildrenCount, ((PLT_MediaContainer*)m_pHandle->AsPointer()));
+ PLATINUM_MANAGED_IMPLEMENT_PROPERTY(UInt32, ContainerUpdateID, m_ContainerUpdateID, ((PLT_MediaContainer*)m_pHandle->AsPointer()));
+
+internal:
+
+ MediaContainer(PLT_MediaContainer& media) :
+ MediaObject(media)
+ {}
+
+public:
+ MediaContainer() :
+ MediaObject(new PLT_MediaContainer)
+ {}
+
+ MediaContainer(PLT_MediaObjectReference& media) :
+ MediaObject(media)
+ {
+ if (!media->IsContainer())
+ throw gcnew ArgumentException("object");
+ }
+
+ MediaContainer(MediaObject^ media) :
+ MediaObject(*media->Handle)
+ {
+ if (!media->Handle->IsContainer())
+ throw gcnew ArgumentException("object");
+ }
+
+ ~MediaContainer()
+ {
+ this->!MediaContainer();
+ }
+
+ !MediaContainer()
+ {}
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::MediaObject, PLT_MediaObject);
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::MediaObject, PLT_MediaObjectReference);
+
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::MediaItem, PLT_MediaItem);
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::MediaContainer, PLT_MediaContainer); \ No newline at end of file
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServer.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServer.cpp
new file mode 100644
index 0000000..0ecf275
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServer.cpp
@@ -0,0 +1,121 @@
+/*****************************************************************
+|
+| Platinum - Managed MediaServer
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "PltMimeType.h"
+#include "MediaServer.h"
+#include "DeviceHost.h"
+#include "MediaServerEventBridge.h"
+
+Platinum::MediaServer::MediaServer(PLT_MediaServer* server) :
+ DeviceHost(*(server))
+{
+ RegisterEvents();
+}
+
+Platinum::MediaServer::MediaServer(String^ friendlyName) :
+ DeviceHost(*(new PLT_MediaServer(StringConv(friendlyName))))
+{
+ RegisterEvents();
+}
+
+Platinum::MediaServer::MediaServer(String^ friendlyName, String^ uuid) :
+ DeviceHost(*(new PLT_MediaServer(StringConv(friendlyName), false, StringConv(uuid))))
+{
+ RegisterEvents();
+}
+
+void Platinum::MediaServer::RegisterEvents()
+{
+ if (!m_pBridge)
+ {
+ m_pBridge = new MediaServerEventBridge(this);
+ }
+
+ PLT_MediaServer* server = (PLT_MediaServer*)(Handle.AsPointer());
+ server->SetDelegate(m_pBridge);
+}
+
+Platinum::MediaServer::!MediaServer()
+{
+
+}
+
+void Platinum::MediaServer::UpdateSystemUpdateID(Int32 update)
+{
+ PLT_MediaServer* server = (PLT_MediaServer*)(Handle.AsPointer());
+ server->UpdateSystemUpdateID(update);
+}
+
+
+void Platinum::MediaServer::UpdateContainerUpdateID(String^ id, Int32 update)
+{
+ PLT_MediaServer* server = (PLT_MediaServer*)(Handle.AsPointer());
+ server->UpdateContainerUpdateID(StringConv(id), update);
+}
+
+Int32 Platinum::MediaServer::SetResponseFilePath(HttpRequestContext^ context, HttpResponse^ response, String^ filepath)
+{
+ NPT_CHECK_WARNING(PLT_HttpServer::ServeFile(context->Request->Handle,
+ context->Handle,
+ response->Handle,
+ NPT_String(StringConv(filepath))));
+
+ /* Update content type header according to file and context */
+ NPT_HttpEntity* entity = response->Handle.GetEntity();
+ if (entity) entity->SetContentType(
+ PLT_MimeType::GetMimeType(NPT_String(StringConv(filepath)),
+ &context->Handle));
+
+ /* streaming header for DLNA */
+ response->Handle.GetHeaders().SetHeader("transferMode.dlna.org", "Streaming");
+ return NPT_SUCCESS;
+}
+
+
+Int32 Platinum::MediaServer::SetResponseData(HttpRequestContext^ context, HttpResponse^ response, array<Byte>^ data)
+{
+ NPT_HttpEntity* entity = response->Handle.GetEntity();
+ if (entity)
+ {
+ pin_ptr<Byte> pinnedBuffer = &data[0];
+ entity->SetInputStream((const void*)pinnedBuffer, data->Length);
+ }
+
+ /* interactive header for DLNA ?*/
+ response->Handle.GetHeaders().SetHeader("transferMode.dlna.org", "Interactive");
+ return NPT_SUCCESS;
+} \ No newline at end of file
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServer.h b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServer.h
new file mode 100644
index 0000000..ad78319
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServer.h
@@ -0,0 +1,131 @@
+/*****************************************************************
+|
+| Platinum - Managed MediaServer
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "DeviceHost.h"
+#include "Http.h"
+
+class PLT_MediaServer;
+
+namespace Platinum
+{
+
+ref class DeviceHost;
+ref class Action;
+class MediaServerEventBridge;
+
+/*----------------------------------------------------------------------
+| MediaServer
++---------------------------------------------------------------------*/
+public ref class MediaServer : public DeviceHost
+{
+public:
+
+ delegate Int32 BrowseMetadataDelegate(Action^ action, String^ object_id, String^ filter, Int32 starting_index, Int32 requested_count, String^ sort_criteria, HttpRequestContext^ context);
+ delegate Int32 BrowseDirectChildrenDelegate(Action^ action, String^ object_id, String^ filter, Int32 starting_index, Int32 requested_count, String^ sort_criteria, HttpRequestContext^ context);
+ delegate Int32 SearchContainerDelegate(Action^ action, String^ object_id, String^ searchCriteria, String^ filter, Int32 starting_index, Int32 requested_count, String^ sort_criteria, HttpRequestContext^ context);
+ delegate Int32 ProcessFileRequestDelegate(HttpRequestContext^ context, HttpResponse^ response);
+
+private:
+
+ MediaServerEventBridge* m_pBridge;
+
+public:
+
+ // properties
+
+private:
+
+ void RegisterEvents();
+
+public:
+
+ event BrowseMetadataDelegate^ BrowseMetadata;
+ event BrowseDirectChildrenDelegate^ BrowseDirectChildren;
+ event SearchContainerDelegate^ SearchContainer;
+ event ProcessFileRequestDelegate^ ProcessFileRequest;
+
+
+internal:
+
+ Int32 OnBrowseMetadataDelegate(Action^ action, String^ object_id, String^ filter, Int32 starting_index, Int32 requested_count, String^ sort_criteria, HttpRequestContext^ context)
+ {
+ // handle events
+ return this->BrowseMetadata(action, object_id, filter, starting_index, requested_count, sort_criteria, context);
+ }
+
+ Int32 OnBrowseDirectChildrenDelegate(Action^ action, String^ object_id, String^ filter, Int32 starting_index, Int32 requested_count, String^ sort_criteria, HttpRequestContext^ context)
+ {
+ // handle events
+ return this->BrowseDirectChildren(action, object_id, filter, starting_index, requested_count, sort_criteria, context);
+ }
+
+ Int32 OnSearchContainerDelegate(Action^ action, String^ object_id, String^ searchCriteria, String^ filter, Int32 starting_index, Int32 requested_count, String^ sort_criteria, HttpRequestContext^ context)
+ {
+ // handle events
+ return this->SearchContainer(action, object_id, searchCriteria, filter, starting_index, requested_count, sort_criteria, context);
+ }
+
+ Int32 OnProcessFileRequestDelegate(HttpRequestContext^ context, HttpResponse^ response)
+ {
+ return this->ProcessFileRequest(context, response);
+ }
+
+public:
+
+ MediaServer(String^ friendlyName);
+ MediaServer(String^ friendlyName, String^ uuid);
+ MediaServer(PLT_MediaServer* server);
+
+ void UpdateSystemUpdateID(Int32 update);
+ void UpdateContainerUpdateID(String^ id, Int32 update);
+
+ ~MediaServer()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!MediaServer();
+ }
+
+ !MediaServer();
+
+
+ static Int32 SetResponseFilePath(HttpRequestContext^ context, HttpResponse^ response, String^ filepath);
+ static Int32 SetResponseData(HttpRequestContext^ context, HttpResponse^ response, array<Byte>^ data);
+};
+
+} \ No newline at end of file
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServerEventBridge.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServerEventBridge.cpp
new file mode 100644
index 0000000..32da39a
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServerEventBridge.cpp
@@ -0,0 +1,103 @@
+/*****************************************************************
+|
+| Platinum - Managed MediaServerEventBridge
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "MediaServerEventBridge.h"
+#include "MediaServer.h"
+#include "Action.h"
+
+NPT_Result Platinum::MediaServerEventBridge::OnBrowseMetadata(PLT_ActionReference& action,
+ const char* object_id,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context)
+{
+ return m_pMediaServer->OnBrowseMetadataDelegate(marshal_as<Action^>(action),
+ marshal_as<String^>(object_id),
+ marshal_as<String^>(filter),
+ starting_index,
+ requested_count,
+ marshal_as<String^>(sort_criteria),
+ marshal_as<HttpRequestContext^>(context));
+}
+
+NPT_Result Platinum::MediaServerEventBridge::OnBrowseDirectChildren(PLT_ActionReference& action,
+ const char* object_id,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context)
+{
+ return m_pMediaServer->OnBrowseDirectChildrenDelegate(marshal_as<Action^>(action),
+ marshal_as<String^>(object_id),
+ marshal_as<String^>(filter),
+ starting_index,
+ requested_count,
+ marshal_as<String^>(sort_criteria),
+ marshal_as<HttpRequestContext^>(context));
+}
+
+NPT_Result Platinum::MediaServerEventBridge::OnSearchContainer(PLT_ActionReference& action,
+ const char* object_id,
+ const char* search_criteria,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context)
+{
+
+ return m_pMediaServer->OnSearchContainerDelegate(marshal_as<Action^>(action),
+ marshal_as<String^>(object_id),
+ marshal_as<String^>(search_criteria),
+ marshal_as<String^>(filter),
+ starting_index,
+ requested_count,
+ marshal_as<String^>(sort_criteria),
+ marshal_as<HttpRequestContext^>(context));
+}
+
+NPT_Result Platinum::MediaServerEventBridge::ProcessFileRequest(NPT_HttpRequest& request,
+ const NPT_HttpRequestContext& context,
+ NPT_HttpResponse& response)
+{
+ PLT_HttpRequestContext _context(request, context);
+ return m_pMediaServer->OnProcessFileRequestDelegate(marshal_as<HttpRequestContext^>(_context),
+ marshal_as<HttpResponse^>(response));
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServerEventBridge.h b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServerEventBridge.h
new file mode 100644
index 0000000..ca13044
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/MediaServerEventBridge.h
@@ -0,0 +1,97 @@
+/*****************************************************************
+|
+| Platinum - Managed MediaServerEventBridge
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#pragma once
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltMediaServer.h"
+
+namespace Platinum
+{
+
+ref class MediaServer;
+
+/*----------------------------------------------------------------------
+| MediaServerEventBridge
++---------------------------------------------------------------------*/
+private class MediaServerEventBridge : public PLT_MediaServerDelegate
+{
+private:
+
+ gcroot<MediaServer^> m_pMediaServer;
+
+public:
+
+ // PLT_MediaServerDelegate methods
+ virtual NPT_Result OnBrowseMetadata(PLT_ActionReference& action,
+ const char* object_id,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context);
+ virtual NPT_Result OnBrowseDirectChildren(PLT_ActionReference& action,
+ const char* object_id,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context);
+ virtual NPT_Result OnSearchContainer(PLT_ActionReference& action,
+ const char* object_id,
+ const char* search_criteria,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context);
+ virtual NPT_Result ProcessFileRequest(NPT_HttpRequest& request,
+ const NPT_HttpRequestContext& context,
+ NPT_HttpResponse& response);
+
+public:
+
+ MediaServerEventBridge(gcroot<MediaServer^> server)
+ {
+ m_pMediaServer = server;
+ }
+
+ virtual ~MediaServerEventBridge()
+ {}
+
+};
+
+
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Neptun_marshal_as.h b/lib/libUPnP/Platinum/Source/Extras/Managed/Neptun_marshal_as.h
new file mode 100644
index 0000000..429be7d
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Neptun_marshal_as.h
@@ -0,0 +1,104 @@
+/*****************************************************************
+|
+| Platinum - Managed Marshalling
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace msclr {
+namespace interop {
+
+// -------------------------- NPT_IpAddress -------
+
+template<>
+inline String^ marshal_as<String^, NPT_IpAddress> (const NPT_IpAddress& from)
+{
+ return gcnew String(from.ToString());
+}
+
+// -------------------------- NPT_HttpUrl -------
+
+template<>
+inline Uri^ marshal_as<Uri^, NPT_HttpUrl> (const NPT_HttpUrl& from)
+{
+ if (!from.IsValid())
+ return nullptr;
+
+ return gcnew Uri(gcnew String(from.ToString()));
+}
+
+// -------------------------- NPT_String -------
+
+template<>
+inline Uri^ marshal_as<Uri^, NPT_String> (const NPT_String& from)
+{
+ if (from.IsEmpty())
+ return nullptr;
+
+ return gcnew Uri(gcnew String(from));
+}
+
+template<>
+inline String^ marshal_as<String^, NPT_String> (const NPT_String& from)
+{
+ return gcnew String(from);
+}
+
+// -------------------------- PLT_ProtocolInfo -------
+
+template<>
+inline String^ marshal_as<String^, PLT_ProtocolInfo> (const PLT_ProtocolInfo& from)
+{
+ return gcnew String(from.ToString());
+}
+
+// -------------------------- NPT_TimeInterval -------
+
+template<>
+inline TimeSpan marshal_as<TimeSpan, NPT_TimeInterval> (const NPT_TimeInterval& from)
+{
+ return TimeSpan(from.ToSeconds() * TimeSpan::TicksPerSecond);
+}
+
+// ---------------------------------------------
+
+
+}}
+
+
+// -------------------------- generic wrapper marshal macro -------
+
+#define PLATINUM_MANAGED_MARSHAL_AS(dotNetType,nativeType) \
+ namespace msclr { namespace interop { \
+ template<> \
+ inline dotNetType^ marshal_as<dotNetType^, nativeType> (const nativeType& from) \
+ { return gcnew dotNetType(const_cast<nativeType&>(from)); } \
+ }}
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneException.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneException.cpp
new file mode 100644
index 0000000..aef0fee
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneException.cpp
@@ -0,0 +1,39 @@
+/*****************************************************************
+|
+| Platinum - Managed NeptuneException
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "NeptuneException.h"
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneException.h b/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneException.h
new file mode 100644
index 0000000..04c943d
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneException.h
@@ -0,0 +1,64 @@
+/*****************************************************************
+|
+| Platinum - Managed NeptuneException
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| NeptuneException
++---------------------------------------------------------------------*/
+[Serializable]
+public ref class NeptuneException : Exception
+{
+private:
+
+ int m_err;
+
+public:
+
+ property int ErrorResult
+ {
+ int get() { return m_err; }
+ }
+
+public:
+
+ NeptuneException(NPT_Result r)
+ : Exception(gcnew String(NPT_ResultText(r))), m_err(r)
+ {
+ }
+
+};
+
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneLoggingBridge.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneLoggingBridge.cpp
new file mode 100644
index 0000000..d69f5eb
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneLoggingBridge.cpp
@@ -0,0 +1,38 @@
+/*****************************************************************
+|
+| Platinum - Managed NeptuneLoggingBridge
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "NeptuneLoggingBridge.h"
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneLoggingBridge.h b/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneLoggingBridge.h
new file mode 100644
index 0000000..920dd3d
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/NeptuneLoggingBridge.h
@@ -0,0 +1,207 @@
+/*****************************************************************
+|
+| Platinum - Managed NeptuneLoggingBridge
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+using namespace log4net;
+
+namespace Platinum
+{
+
+/*----------------------------------------------------------------------
+| NeptuneLoggingBridge
++---------------------------------------------------------------------*/
+class NeptuneLoggingBridge : NPT_LogHandler
+{
+private:
+
+ NPT_Mutex m_SetLoggerNameLock;
+ gcroot<String^> m_pFormatString;
+ gcroot<ILog^> m_pLogger;
+
+public:
+
+ static void Configure()
+ {
+ static NPT_Mutex lock;
+
+ lock.Lock();
+
+ static NeptuneLoggingBridge instance;
+
+ // clear config
+ NPT_LogManager::GetDefault().Configure("plist:.level=ALL;.handlers=;platinum.level=ALL;platinum.handlers=");
+
+ // get root logger
+ NPT_Logger* rootLogger = NPT_LogManager::GetLogger("platinum");
+
+ if (rootLogger)
+ {
+ // set handler
+ rootLogger->AddHandler(&instance, false);
+ }
+
+ lock.Unlock();
+ }
+
+public:
+
+ virtual void Log(const NPT_LogRecord& record)
+ {
+ gcroot<ILog^> log = SetLoggerName(record.m_LoggerName);
+
+ switch (record.m_Level)
+ {
+ case NPT_LOG_LEVEL_FATAL:
+ if (log->IsFatalEnabled)
+ {
+ log->FatalFormat(
+ m_pFormatString,
+ marshal_as<String^>(NPT_Log::GetLogLevelName(record.m_Level)),
+ marshal_as<String^>(record.m_Message),
+ marshal_as<String^>(record.m_SourceFile),
+ UInt32(record.m_SourceLine)
+ );
+ }
+
+ break;
+
+ case NPT_LOG_LEVEL_SEVERE:
+ if (log->IsErrorEnabled)
+ {
+ log->ErrorFormat(
+ m_pFormatString,
+ marshal_as<String^>(NPT_Log::GetLogLevelName(record.m_Level)),
+ marshal_as<String^>(record.m_Message),
+ marshal_as<String^>(record.m_SourceFile),
+ UInt32(record.m_SourceLine)
+ );
+ }
+
+ break;
+
+ case NPT_LOG_LEVEL_WARNING:
+ if (log->IsWarnEnabled)
+ {
+ log->WarnFormat(
+ m_pFormatString,
+ marshal_as<String^>(NPT_Log::GetLogLevelName(record.m_Level)),
+ marshal_as<String^>(record.m_Message),
+ marshal_as<String^>(record.m_SourceFile),
+ UInt32(record.m_SourceLine)
+ );
+ }
+
+ break;
+
+ case NPT_LOG_LEVEL_INFO:
+ if (log->IsInfoEnabled)
+ {
+ log->InfoFormat(
+ m_pFormatString,
+ marshal_as<String^>(NPT_Log::GetLogLevelName(record.m_Level)),
+ marshal_as<String^>(record.m_Message),
+ marshal_as<String^>(record.m_SourceFile),
+ UInt32(record.m_SourceLine)
+ );
+ }
+
+ break;
+
+ case NPT_LOG_LEVEL_FINE:
+ case NPT_LOG_LEVEL_FINER:
+ case NPT_LOG_LEVEL_FINEST:
+ if (log->IsDebugEnabled)
+ {
+ log->DebugFormat(
+ m_pFormatString,
+ marshal_as<String^>(NPT_Log::GetLogLevelName(record.m_Level)),
+ marshal_as<String^>(record.m_Message),
+ marshal_as<String^>(record.m_SourceFile),
+ UInt32(record.m_SourceLine)
+ );
+ }
+
+ break;
+
+ default:
+ if (log->IsWarnEnabled)
+ {
+ log->WarnFormat(
+ m_pFormatString,
+ marshal_as<String^>("UNKNOWN_LOG_LEVEL"),
+ marshal_as<String^>(record.m_Message),
+ marshal_as<String^>(record.m_SourceFile),
+ UInt32(record.m_SourceLine)
+ );
+ }
+
+ break;
+ }
+ }
+
+private:
+
+ gcroot<ILog^> SetLoggerName(const char* name)
+ {
+ m_SetLoggerNameLock.Lock();
+
+ gcroot<String^> loggerName = gcnew String(name);
+ gcroot<ILog^> logger = m_pLogger;
+
+ if (logger->Logger->Name != loggerName)
+ {
+ logger = LogManager::GetLogger(loggerName);
+
+ m_pLogger = logger;
+ }
+
+ m_SetLoggerNameLock.Unlock();
+
+ return logger;
+ }
+
+public:
+
+ NeptuneLoggingBridge()
+ {
+ m_pLogger = LogManager::GetLogger(gcnew String("NeptuneLoggingBridge"));
+ m_pFormatString = gcnew String("{0}: {2}:{3}: {1}");
+ }
+
+ virtual ~NeptuneLoggingBridge()
+ {
+ }
+
+};
+
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Service.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/Service.cpp
new file mode 100644
index 0000000..5f66254
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Service.cpp
@@ -0,0 +1,97 @@
+/*****************************************************************
+|
+| Platinum - Managed Service
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "Service.h"
+#include "ActionDescription.h"
+#include "StateVariable.h"
+#include "DeviceData.h"
+#include "EnumerableNptArray.h"
+#include "EnumerableNptList.h"
+
+Platinum::DeviceData^ Platinum::Service::ParentDevice::get()
+{
+ return marshal_as<DeviceData^>(*m_pHandle->GetDevice());
+}
+
+IEnumerable<Platinum::StateVariable^>^ Platinum::Service::StateVariables::get()
+{
+ return gcnew Enumerables::EnumerableNptList<StateVariable^, PLT_StateVariable*>(
+ m_pHandle->GetStateVariables()
+ );
+}
+
+IEnumerable<Platinum::ActionDescription^>^ Platinum::Service::Actions::get()
+{
+ return gcnew Enumerables::EnumerableNptArray<ActionDescription^, PLT_ActionDesc*>(
+ m_pHandle->GetActionDescs()
+ );
+}
+
+Platinum::ActionDescription^ Platinum::Service::FindAction( String^ name )
+{
+ if (String::IsNullOrEmpty(name))
+ throw gcnew ArgumentException("null or empty", "name");
+
+ marshal_context c;
+
+ PLT_ActionDesc* d = m_pHandle->FindActionDesc(
+ c.marshal_as<const char*>(name)
+ );
+
+ if (!d)
+ return nullptr;
+
+ return marshal_as<ActionDescription^>(*d);
+}
+
+Platinum::StateVariable^ Platinum::Service::FindStateVariable( String^ name )
+{
+ if (String::IsNullOrEmpty(name))
+ throw gcnew ArgumentException("null or empty", "name");
+
+ marshal_context c;
+
+ PLT_StateVariable* d = m_pHandle->FindStateVariable(
+ c.marshal_as<const char*>(name)
+ );
+
+ if (!d)
+ return nullptr;
+
+ return marshal_as<StateVariable^>(*d);
+}
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/Service.h b/lib/libUPnP/Platinum/Source/Extras/Managed/Service.h
new file mode 100644
index 0000000..1578f23
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/Service.h
@@ -0,0 +1,147 @@
+/*****************************************************************
+|
+| Platinum - Managed Service
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+ref class DeviceData;
+ref class ActionDescription;
+ref class StateVariable;
+
+/*----------------------------------------------------------------------
+| Service
++---------------------------------------------------------------------*/
+public ref class Service
+{
+private:
+
+ PLT_Service* m_pHandle;
+
+internal:
+
+ property PLT_Service& Handle
+ {
+ PLT_Service& get()
+ {
+ return *m_pHandle;
+ }
+ }
+
+public:
+
+ property Uri^ SCPDURL
+ {
+ Uri^ get()
+ {
+ return marshal_as<Uri^>(m_pHandle->GetSCPDURL());
+ }
+ }
+
+ property String^ ServiceID
+ {
+ String^ get()
+ {
+ return gcnew String(m_pHandle->GetServiceID());
+ }
+ }
+
+ property String^ ServiceType
+ {
+ String^ get()
+ {
+ return gcnew String(m_pHandle->GetServiceType());
+ }
+ }
+
+ property DeviceData^ ParentDevice
+ {
+ DeviceData^ get();
+ }
+
+ property IEnumerable<StateVariable^>^ StateVariables
+ {
+ IEnumerable<StateVariable^>^ get();
+ }
+
+ property IEnumerable<ActionDescription^>^ Actions
+ {
+ IEnumerable<ActionDescription^>^ get();
+ }
+
+public:
+
+ ActionDescription^ FindAction(String^ name);
+ StateVariable^ FindStateVariable(String^ name);
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (m_pHandle == ((Service^)obj)->m_pHandle);
+ }
+
+internal:
+
+ Service(PLT_Service& devData)
+ {
+ m_pHandle = &devData;
+ }
+
+public:
+
+ ~Service()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!Service();
+ }
+
+ !Service()
+ {
+ // clean-up unmanaged
+ }
+
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::Service, PLT_Service);
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/StateVariable.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/StateVariable.cpp
new file mode 100644
index 0000000..9a4208c
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/StateVariable.cpp
@@ -0,0 +1,44 @@
+/*****************************************************************
+|
+| Platinum - Managed StateVariable
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "StateVariable.h"
+#include "Service.h"
+
+Platinum::Service^ Platinum::StateVariable::ParentService::get()
+{
+ return marshal_as<Service^>(*m_pHandle->GetService());
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/StateVariable.h b/lib/libUPnP/Platinum/Source/Extras/Managed/StateVariable.h
new file mode 100644
index 0000000..7184a15
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/StateVariable.h
@@ -0,0 +1,165 @@
+/*****************************************************************
+|
+| Platinum - Managed StateVariable
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+ref class Service;
+
+/*----------------------------------------------------------------------
+| StateVariable
++---------------------------------------------------------------------*/
+public ref class StateVariable
+{
+private:
+
+ PLT_StateVariable* m_pHandle;
+
+public:
+
+ property String^ Name
+ {
+ String^ get()
+ {
+ return gcnew String(m_pHandle->GetName());
+ }
+ }
+
+ property Service^ ParentService
+ {
+ Service^ get();
+ }
+
+ property Type^ DataType
+ {
+ Type^ get()
+ {
+ return Helpers::ParseType(m_pHandle->GetDataType());
+ }
+ }
+
+ property String^ DataTypeString
+ {
+ String^ get()
+ {
+ return gcnew String(m_pHandle->GetDataType());
+ }
+ }
+
+ property Object^ Value
+ {
+ Object^ get()
+ {
+ return Helpers::ConvertValue(
+ m_pHandle->GetDataType(),
+ m_pHandle->GetValue()
+ );
+ }
+ }
+
+ property String^ ValueString
+ {
+ String^ get()
+ {
+ return gcnew String(m_pHandle->GetValue());
+ }
+
+ void set (String^ value)
+ {
+ if (value == nullptr)
+ throw gcnew ArgumentNullException("value");
+
+ marshal_context c;
+
+ Helpers::ThrowOnError(m_pHandle->SetValue(
+ c.marshal_as<const char*>(value)
+ ));
+ }
+ }
+
+public:
+
+ void ValidateValue(String^ value)
+ {
+ if (value == nullptr)
+ throw gcnew ArgumentNullException("value");
+
+ marshal_context c;
+
+ Helpers::ThrowOnError(m_pHandle->ValidateValue(
+ c.marshal_as<const char*>(value)
+ ));
+ }
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (m_pHandle == ((StateVariable^)obj)->m_pHandle);
+ }
+
+internal:
+
+ StateVariable(PLT_StateVariable& devData)
+ {
+ m_pHandle = &devData;
+ }
+
+public:
+
+ ~StateVariable()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!StateVariable();
+ }
+
+ !StateVariable()
+ {
+ // clean-up unmanaged
+ }
+
+};
+
+}
+
+// marshal wrapper
+PLATINUM_MANAGED_MARSHAL_AS(Platinum::StateVariable, PLT_StateVariable);
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/UPnP.cpp b/lib/libUPnP/Platinum/Source/Extras/Managed/UPnP.cpp
new file mode 100644
index 0000000..d80d745
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/UPnP.cpp
@@ -0,0 +1,81 @@
+/*****************************************************************
+|
+| Platinum - Managed UPnP
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "StdAfx.h"
+#include "UPnP.h"
+#include "ControlPoint.h"
+#include "DeviceHost.h"
+#include "NeptuneLoggingBridge.h"
+
+void Platinum::UPnP::AddControlPoint( ControlPoint^ cp )
+{
+ Helpers::ThrowOnError(m_pHandle->AddCtrlPoint(cp->Handle));
+}
+
+void Platinum::UPnP::RemoveControlPoint( ControlPoint^ cp )
+{
+ Helpers::ThrowOnError(m_pHandle->RemoveCtrlPoint(cp->Handle));
+}
+
+void Platinum::UPnP::AddDeviceHost( DeviceHost^ host )
+{
+ Helpers::ThrowOnError(m_pHandle->AddDevice((PLT_DeviceHostReference)host->Host));
+}
+
+void Platinum::UPnP::RemoveDeviceHost( DeviceHost^ host )
+{
+ Helpers::ThrowOnError(m_pHandle->RemoveDevice((PLT_DeviceHostReference)host->Host));
+}
+
+static Platinum::UPnP::UPnP()
+{
+ NeptuneLoggingBridge::Configure();
+}
+
+List<String^>^ Platinum::UPnP::GetIpAddresses(bool include_localhost)
+{
+ NPT_List<NPT_IpAddress> ips;
+ PLT_UPnPMessageHelper::GetIPAddresses(ips, include_localhost); // TODO: Throw on Error?
+
+ List<String^>^ _ips = gcnew List<String^>();
+ NPT_List<NPT_IpAddress>::Iterator ip = ips.GetFirstItem();
+ while (ip) {
+ _ips->Add(gcnew String((*ip).ToString()));
+ ++ip;
+ }
+
+ return _ips;
+} \ No newline at end of file
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/UPnP.h b/lib/libUPnP/Platinum/Source/Extras/Managed/UPnP.h
new file mode 100644
index 0000000..4c87e8d
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/UPnP.h
@@ -0,0 +1,131 @@
+/*****************************************************************
+|
+| Platinum - Managed UPnP
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+#pragma once
+
+namespace Platinum
+{
+
+ref class ControlPoint;
+ref class DeviceHost;
+class NeptuneLoggingBridge;
+
+/*----------------------------------------------------------------------
+| UPnP
++---------------------------------------------------------------------*/
+public ref class UPnP
+{
+public:
+
+ static const unsigned short DefaultPort = 1900;
+
+private:
+
+ PLT_UPnP* m_pHandle;
+
+public:
+
+ void Start()
+ {
+ Helpers::ThrowOnError(m_pHandle->Start());
+ }
+
+ void Stop()
+ {
+ if (m_pHandle) m_pHandle->Stop();
+ }
+
+ void AddControlPoint(ControlPoint^ cp);
+ void RemoveControlPoint(ControlPoint^ cp);
+
+ void AddDeviceHost(DeviceHost^ host);
+ void RemoveDeviceHost(DeviceHost^ host);
+
+ static List<String^>^ GetIpAddresses()
+ {
+ return GetIpAddresses(false);
+ }
+ static List<String^>^ GetIpAddresses(bool include_localhost);
+
+ property bool Running
+ {
+ bool get()
+ {
+ return m_pHandle->IsRunning();
+ }
+ }
+
+public:
+
+ virtual Boolean Equals(Object^ obj) override
+ {
+ if (obj == nullptr)
+ return false;
+
+ if (!this->GetType()->IsInstanceOfType(obj))
+ return false;
+
+ return (m_pHandle == ((UPnP^)obj)->m_pHandle);
+ }
+
+public:
+
+ static UPnP();
+
+ UPnP()
+ {
+ m_pHandle = new PLT_UPnP();
+ }
+
+ ~UPnP()
+ {
+ // clean-up managed
+
+ // clean-up unmanaged
+ this->!UPnP();
+ }
+
+ !UPnP()
+ {
+ // clean-up unmanaged
+ if (m_pHandle != 0)
+ {
+ delete m_pHandle;
+
+ m_pHandle = 0;
+ }
+ }
+};
+
+
+}
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/Managed/clix.hpp b/lib/libUPnP/Platinum/Source/Extras/Managed/clix.hpp
new file mode 100644
index 0000000..bb93978
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/Managed/clix.hpp
@@ -0,0 +1,209 @@
+// ------------------------------------------------------------------------------------------- //
+// clix.h
+//
+// Marshals strings between .NET and C++ using C++/CLI (Visual C++ 2005 and later only).
+// Faster and cleaner than the System::Interop method because it uses garbage collected memory.
+// Use at your own leisure. No warranties whatsoever provided.
+//
+// Original code by Markus Ewald (http://www.nuclex.org/articles/marshaling-strings-in-cxx-cli)
+// Updated version including several improvements suggested by Neil Hunt
+//
+// Licensed under the IBM CPL (free of charge, closed source commercial use is okay)
+// ------------------------------------------------------------------------------------------- //
+#pragma once
+
+#include <string>
+#include <vcclr.h>
+
+// CLI extensions namespace
+namespace clix {
+
+ /// <summary>Encoding types for strings</summary>
+ enum Encoding {
+
+ /// <summary>ANSI encoding</summary>
+ /// <remarks>
+ /// This is the default encoding you've most likely been using all around in C++. ANSI
+ /// means 8 Bit encoding with character codes depending on the system's selected code page.
+ /// <remarks>
+ E_ANSI,
+
+ /// <summary>UTF-8 encoding</summary>
+ /// <remarks>
+ /// This is the encoding commonly used for multilingual C++ strings. All ASCII characters
+ /// (0-127) will be represented as single bytes. Be aware that UTF-8 uses more than one
+ /// byte for extended characters, so std::string::length() might not reflect the actual
+ /// length of the string in characters if it contains any non-ASCII characters.
+ /// <remarks>
+ E_UTF8,
+
+ /// <summary>UTF-16 encoding</summary>
+ /// <remarks>
+ /// This is the suggested encoding for marshaling and the native encoding of .NET strings.
+ /// It is similar to UTF-8 but uses a minimum of two bytes per character, making the number
+ /// of bytes required for a given string better predictable. Be aware, however, that UTF-16
+ /// can still use more than two bytes for a character, so std::wstring::length() might not
+ /// reflect the actual length of the string.
+ /// </remarks>
+ E_UTF16, E_UNICODE = E_UTF16
+
+ };
+
+ // Ignore this if you're just scanning the headers for informations!
+ /* All this template stuff might seem like overkill, but it is well thought out and enables
+ you to use a readable and convenient call while still keeping the highest possible code
+ efficiency due to compile-time evaluation of the required conversion path.
+ */
+ namespace detail {
+
+ // Get C++ string type for specified encoding
+ template<Encoding encoding> struct StringTypeSelector;
+ template<> struct StringTypeSelector<E_ANSI> { typedef std::string Type; };
+ template<> struct StringTypeSelector<E_UTF8> { typedef std::string Type; };
+ template<> struct StringTypeSelector<E_UTF16> { typedef std::wstring Type; };
+
+ // Compile-time selection depending on whether a string is managed
+ template<typename StringType> struct IfManaged {
+ struct Select {
+ template<typename TrueType, typename FalseType>
+ struct Either { typedef FalseType Type; };
+ };
+ enum { Result = false };
+ };
+ template<> struct IfManaged<System::String ^> {
+ struct Select {
+ template<typename TrueType, typename FalseType>
+ struct Either { typedef TrueType Type; };
+ };
+ enum { Result = true };
+ };
+
+ // Direction of the marshaling process
+ enum MarshalingDirection {
+ CxxFromNet,
+ NetFromCxx
+ };
+
+ // The actual marshaling code
+ template<MarshalingDirection direction> struct StringMarshaler;
+
+ // Marshals to .NET from C++ strings
+ template<> struct StringMarshaler<NetFromCxx> {
+
+ template<Encoding encoding, typename SourceType>
+ static System::String ^marshal(const SourceType &string) {
+ // Constructs a std::[w]string in case someone gave us a char * to choke on
+ return marshalCxxString<encoding, SourceType>(string);
+ }
+
+ template<Encoding encoding, typename SourceType>
+ static System::String ^marshalCxxString(
+ const typename StringTypeSelector<encoding>::Type &cxxString
+ ) {
+ typedef typename StringTypeSelector<encoding>::Type SourceStringType;
+ size_t byteCount = cxxString.length() * sizeof(SourceStringType::value_type);
+
+ // Empty strings would cause trouble accessing the array below
+ if(byteCount == 0) {
+ return System::String::Empty;
+ }
+
+ // Copy the C++ string contents into a managed array of bytes
+ array<unsigned char> ^bytes = gcnew array<unsigned char>(byteCount);
+ { pin_ptr<unsigned char> pinnedBytes = &bytes[0];
+ memcpy(pinnedBytes, cxxString.c_str(), byteCount);
+ }
+
+ // Now let one of .NET's encoding classes do the rest
+ return decode<encoding>(bytes);
+ }
+
+ private:
+ // Converts a byte array based on the selected encoding
+ template<Encoding encoding> static System::String ^decode(array<unsigned char> ^bytes);
+ template<> static System::String ^decode<E_ANSI>(array<unsigned char> ^bytes) {
+ return System::Text::Encoding::Default->GetString(bytes);
+ }
+ template<> static System::String ^decode<E_UTF8>(array<unsigned char> ^bytes) {
+ return System::Text::Encoding::UTF8->GetString(bytes);
+ }
+ template<> static System::String ^decode<E_UTF16>(array<unsigned char> ^bytes) {
+ return System::Text::Encoding::Unicode->GetString(bytes);
+ }
+ };
+
+ // Marshals to C++ strings from .NET
+ template<> struct StringMarshaler<CxxFromNet> {
+
+ template<Encoding encoding, typename SourceType>
+ static typename detail::StringTypeSelector<encoding>::Type marshal(
+ System::String ^string
+ ) {
+ typedef typename StringTypeSelector<encoding>::Type StringType;
+
+ // Empty strings would cause a problem when accessing the empty managed array
+ if(string->Length == 0) {
+ return StringType();
+ }
+
+ // First, we use .NET's encoding classes to convert the string into a byte array
+ array<unsigned char> ^bytes = encode<encoding>(string);
+
+ // Then we construct our native string from that byte array
+ pin_ptr<unsigned char> pinnedBytes(&bytes[0]);
+ return StringType(
+ reinterpret_cast<StringType::value_type *>(static_cast<unsigned char *>(pinnedBytes)),
+ bytes->Length / sizeof(StringType::value_type)
+ );
+ }
+
+ template<> static std::wstring marshal<E_UTF16, System::String ^>(
+ System::String ^string
+ ) {
+ // We can directly accesss the characters in the managed string
+ pin_ptr<const wchar_t> pinnedChars(::PtrToStringChars(string));
+ return std::wstring(pinnedChars, string->Length);
+ }
+
+ private:
+ // Converts a string based on the selected encoding
+ template<Encoding encoding> static array<unsigned char> ^encode(System::String ^string);
+ template<> static array<unsigned char> ^encode<E_ANSI>(System::String ^string) {
+ return System::Text::Encoding::Default->GetBytes(string);
+ }
+ template<> static array<unsigned char> ^encode<E_UTF8>(System::String ^string) {
+ return System::Text::Encoding::UTF8->GetBytes(string);
+ }
+ template<> static array<unsigned char> ^encode<E_UTF16>(System::String ^string) {
+ return System::Text::Encoding::Unicode->GetBytes(string);
+ }
+
+ };
+
+ } // namespace detail
+
+ // ----------------------------------------------------------------------------------------- //
+ // clix::marshalString()
+ // ----------------------------------------------------------------------------------------- //
+ /// <summary>Marshals strings between .NET managed and C++ native</summary>
+ /// <remarks>
+ /// This all-in-one function marshals native C++ strings to .NET strings and vice versa.
+ /// You have to specify an encoding to use for the conversion, which always applies to the
+ /// native C++ string as .NET always uses UTF-16 for its own strings.
+ /// </remarks>
+ /// <param name="string">String to be marshalled to the other side</param>
+ /// <returns>The marshaled representation of the string</returns>
+ template<Encoding encoding, typename SourceType>
+ typename detail::IfManaged<SourceType>::Select::Either<
+ typename detail::StringTypeSelector<encoding>::Type,
+ System::String ^
+ >::Type marshalString(SourceType string) {
+
+ // Pass on the call to our nifty template routines
+ return detail::StringMarshaler<
+ detail::IfManaged<SourceType>::Result ? detail::CxxFromNet : detail::NetFromCxx
+ >::marshal<encoding, SourceType>(string);
+
+ }
+
+} // namespace clix
diff --git a/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltMediaServerObject.h b/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltMediaServerObject.h
new file mode 100644
index 0000000..bbc6743
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltMediaServerObject.h
@@ -0,0 +1,84 @@
+//
+// PltMediaServerObject.h
+// Platinum
+//
+// Created by Sylvain on 9/14/10.
+// Copyright 2010 Plutinosoft LLC. All rights reserved.
+//
+
+#import "Neptune.h"
+
+#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+#include <UIKit/UIKit.h>
+#else
+#import <Cocoa/Cocoa.h>
+#endif
+
+#import "PltUPnPObject.h"
+
+// define
+#if !defined(_PLATINUM_H_)
+typedef class PLT_HttpRequestContext PLT_HttpRequestContext;
+typedef class NPT_HttpResponse NPT_HttpResponse;
+#endif
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerObject
++---------------------------------------------------------------------*/
+@interface PLT_MediaServerObject : PLT_DeviceHostObject
+@property (nonatomic, assign) id delegate;
+@end
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerBrowseCapsule
++---------------------------------------------------------------------*/
+@interface PLT_MediaServerBrowseCapsule : PLT_ActionObject {
+ NSString* objectId;
+ NPT_UInt32 start;
+ NPT_UInt32 count;
+ NSString* filter;
+ NSString* sort;
+ PLT_HttpRequestContext* context;
+}
+
+- (id)initWithAction:(PLT_Action*)action objectId:(const char*)objectId filter:(const char*)filter start:(NPT_UInt32)start count:(NPT_UInt32)count sort:(const char*)sort context:(PLT_HttpRequestContext*)context;
+
+@property (readonly, copy) NSString* objectId;
+@property (readonly) NPT_UInt32 start;
+@property (readonly) NPT_UInt32 count;
+@property (readonly, copy) NSString* filter;
+@property (readonly, copy) NSString* sort;
+@end
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerSearchCapsule
++---------------------------------------------------------------------*/
+@interface PLT_MediaServerSearchCapsule : PLT_MediaServerBrowseCapsule {
+ NSString* search;
+}
+
+- (id)initWithAction:(PLT_Action*)action objectId:(const char*)objectId search:(const char*)search filter:(const char*)filter start:(NPT_UInt32)start count:(NPT_UInt32)count sort:(const char*)sort context:(PLT_HttpRequestContext*)context;
+
+@property (readonly, copy) NSString* search;
+@end
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerFileRequestCapsule
++---------------------------------------------------------------------*/
+@interface PLT_MediaServerFileRequestCapsule : NSObject {
+ NPT_HttpResponse* response;
+ PLT_HttpRequestContext* context;
+}
+
+- (id)initWithResponse:(NPT_HttpResponse*)response context:(PLT_HttpRequestContext*)context;
+@end
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerDelegateObject
++---------------------------------------------------------------------*/
+@protocol PLT_MediaServerDelegateObject
+- (NPT_Result)onBrowseMetadata:(PLT_MediaServerBrowseCapsule*)info;
+- (NPT_Result)onBrowseDirectChildren:(PLT_MediaServerBrowseCapsule*)info;
+- (NPT_Result)onSearchContainer:(PLT_MediaServerSearchCapsule*)info;
+- (NPT_Result)onFileRequest:(PLT_MediaServerFileRequestCapsule*)info;
+@end
diff --git a/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltMediaServerObject.mm b/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltMediaServerObject.mm
new file mode 100644
index 0000000..0900819
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltMediaServerObject.mm
@@ -0,0 +1,198 @@
+//
+// PltMediaServerObject.mm
+// Platinum
+//
+// Created by Sylvain on 9/14/10.
+// Copyright 2010 Plutinosoft LLC. All rights reserved.
+//
+
+#import "Platinum.h"
+#import "PltMediaServerObject.h"
+#import "PltMediaConnect.h"
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerDelegate_Wrapper
++---------------------------------------------------------------------*/
+class PLT_MediaServerDelegate_Wrapper : public PLT_MediaServerDelegate {
+public:
+ PLT_MediaServerDelegate_Wrapper(PLT_MediaServerObject* target) : m_Target(target) {}
+
+ NPT_Result OnBrowseMetadata(PLT_ActionReference& action,
+ const char* object_id,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context) {
+ if (![m_Target.delegate respondsToSelector:@selector(onBrowseMetadata:)])
+ return NPT_FAILURE;
+
+ PLT_MediaServerBrowseCapsule* capsule =
+ [[PLT_MediaServerBrowseCapsule alloc] initWithAction:action.AsPointer()
+ objectId:object_id
+ filter:filter
+ start:starting_index
+ count:requested_count
+ sort:sort_criteria
+ context:(PLT_HttpRequestContext*)&context];
+ NPT_Result result = [m_Target.delegate onBrowseMetadata:capsule];
+
+ return result;
+ }
+
+ NPT_Result OnBrowseDirectChildren(PLT_ActionReference& action,
+ const char* object_id,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context) {
+ if (![m_Target.delegate respondsToSelector:@selector(onBrowseDirectChildren:)])
+ return NPT_FAILURE;
+
+ PLT_MediaServerBrowseCapsule* capsule =
+ [[PLT_MediaServerBrowseCapsule alloc] initWithAction:action.AsPointer()
+ objectId:object_id
+ filter:filter
+ start:starting_index
+ count:requested_count
+ sort:sort_criteria
+ context:(PLT_HttpRequestContext*)&context];
+ NPT_Result result = [m_Target.delegate onBrowseDirectChildren:capsule];
+
+ return result;
+ }
+
+ NPT_Result OnSearchContainer(PLT_ActionReference& action,
+ const char* container_id,
+ const char* search_criteria,
+ const char* filter,
+ NPT_UInt32 starting_index,
+ NPT_UInt32 requested_count,
+ const char* sort_criteria,
+ const PLT_HttpRequestContext& context) {
+ if (![m_Target.delegate respondsToSelector:@selector(onSearchContainer:)])
+ return NPT_FAILURE;
+
+ PLT_MediaServerSearchCapsule* capsule =
+ [[PLT_MediaServerSearchCapsule alloc] initWithAction:action.AsPointer()
+ objectId:container_id
+ search:search_criteria
+ filter:filter
+ start:starting_index
+ count:requested_count
+ sort:sort_criteria
+ context:(PLT_HttpRequestContext*)&context];
+ NPT_Result result = [m_Target.delegate onSearchContainer:capsule];
+
+ return result;
+ }
+
+ NPT_Result ProcessFileRequest(NPT_HttpRequest& request,
+ const NPT_HttpRequestContext& context,
+ NPT_HttpResponse& response) {
+ PLT_HttpRequestContext _context(request, context);
+ PLT_MediaServerFileRequestCapsule* capsule =
+ [[PLT_MediaServerFileRequestCapsule alloc] initWithResponse:&response
+ context:&_context];
+ NPT_Result result = [m_Target.delegate onFileRequest:capsule];
+
+ return result;
+ }
+
+private:
+ PLT_MediaServerObject* m_Target;
+};
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerBrowseCapsule
++---------------------------------------------------------------------*/
+@implementation PLT_MediaServerBrowseCapsule
+
+@synthesize objectId, filter, start, count, sort;
+
+- (id)initWithAction:(PLT_Action*)action objectId:(const char*)_id filter:(const char*)_filter start:(NPT_UInt32)_start count:(NPT_UInt32)_count sort:(const char*)_sort context:(PLT_HttpRequestContext*)_context
+{
+ if ((self = [super initWithAction:action])) {
+ objectId = [[NSString alloc] initWithCString:_id encoding:NSUTF8StringEncoding];
+ filter = [[NSString alloc] initWithCString:(_filter==NULL)?"":_filter
+ encoding:NSUTF8StringEncoding];
+ sort = [[NSString alloc] initWithCString:(_sort==NULL)?"":_sort
+ encoding:NSUTF8StringEncoding];
+ start = _start;
+ count = _count;
+ context = _context;
+ }
+ return self;
+}
+
+@end
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerSearchCapsule
++---------------------------------------------------------------------*/
+@implementation PLT_MediaServerSearchCapsule
+
+@synthesize search;
+
+- (id)initWithAction:(PLT_Action*)action objectId:(const char*)_id search:(const char*)_search filter:(const char*)_filter start:(NPT_UInt32)_start count:(NPT_UInt32)_count sort:(const char*)_sort context:(PLT_HttpRequestContext*)_context
+{
+ if ((self = [super initWithAction:action
+ objectId:_id
+ filter:_filter
+ start:_start
+ count:_count
+ sort:_sort
+ context:_context])) {
+ search = [[NSString alloc] initWithCString:_search encoding:NSUTF8StringEncoding];
+ }
+ return self;
+}
+
+@end
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerFileRequestCapsule
++---------------------------------------------------------------------*/
+@implementation PLT_MediaServerFileRequestCapsule
+
+- (id)initWithResponse:(NPT_HttpResponse*)_response context:(PLT_HttpRequestContext*)_context
+{
+ if ((self = [super init])) {
+ response = _response;
+ context = _context;
+ }
+ return self;
+}
+
+@end
+
+/*----------------------------------------------------------------------
+| PLT_MediaServerObject
++---------------------------------------------------------------------*/
+@interface PLT_MediaServerObject () {
+ PLT_MediaServerDelegate_Wrapper *_wrapper;
+}
+@end
+
+@implementation PLT_MediaServerObject
+
+- (id)init
+{
+ if ((self = [super init])) {
+ PLT_MediaConnect* server = new PLT_MediaConnect("Test");
+ PLT_DeviceHostReference _device(server);
+ [self setDevice:&_device];
+
+ _wrapper = new PLT_MediaServerDelegate_Wrapper(self);
+ server->SetDelegate(_wrapper);
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ delete _wrapper;
+}
+
+@end
diff --git a/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltUPnPObject.h b/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltUPnPObject.h
new file mode 100644
index 0000000..4c9b8ed
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltUPnPObject.h
@@ -0,0 +1,61 @@
+//
+// PltUPnPObject.h
+// Platinum
+//
+// Created by Sylvain on 9/14/10.
+// Copyright 2010 Plutinosoft LLC. All rights reserved.
+//
+
+#import "Neptune.h"
+
+#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+#include <UIKit/UIKit.h>
+#else
+#import <Cocoa/Cocoa.h>
+#endif
+
+
+#if !defined(_PLATINUM_H_)
+typedef struct PLT_UPnP PLT_UPnP;
+typedef struct PLT_Action PLT_Action;
+typedef struct PLT_DeviceHostReference PLT_DeviceHostReference;
+#endif
+
+/*----------------------------------------------------------------------
+| PLT_ActionObject
++---------------------------------------------------------------------*/
+@interface PLT_ActionObject : NSObject {
+@private
+ PLT_Action* action;
+}
+
+- (id)initWithAction:(PLT_Action *)_action;
+- (NPT_Result)setValue:(NSString*)value forArgument:(NSString*)argument;
+- (NPT_Result)setErrorCode:(unsigned int)code withDescription:(NSString*)description;
+@end
+
+/*----------------------------------------------------------------------
+| PLT_DeviceHostObject
++---------------------------------------------------------------------*/
+@interface PLT_DeviceHostObject : NSObject {
+@private
+ PLT_DeviceHostReference* device;
+}
+
+- (void)setDevice:(PLT_DeviceHostReference*)_device;
+- (PLT_DeviceHostReference&)getDevice;
+@end
+
+/*----------------------------------------------------------------------
+| PLT_UPnPObject
++---------------------------------------------------------------------*/
+@interface PLT_UPnPObject : NSObject
+
+- (NPT_Result)start;
+- (NPT_Result)stop;
+- (bool)isRunning;
+
+- (NPT_Result)addDevice:(PLT_DeviceHostObject*)device;
+- (NPT_Result)removeDevice:(PLT_DeviceHostObject*)device;
+
+@end
diff --git a/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltUPnPObject.mm b/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltUPnPObject.mm
new file mode 100644
index 0000000..d49f1f5
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/ObjectiveC/PltUPnPObject.mm
@@ -0,0 +1,118 @@
+//
+// PltUPnPObject.mm
+// Platinum
+//
+// Created by Sylvain on 9/14/10.
+// Copyright 2010 Plutinosoft LLC. All rights reserved.
+//
+
+#import "Platinum.h"
+#import "PltUPnPObject.h"
+
+/*----------------------------------------------------------------------
+| PLT_ActionObject
++---------------------------------------------------------------------*/
+@implementation PLT_ActionObject
+
+- (id)initWithAction:(PLT_Action *)_action
+{
+ if ((self = [super init])) {
+ action = _action;
+ }
+ return self;
+}
+
+- (NPT_Result)setValue:(NSString *)value forArgument:(NSString *)argument
+{
+ return action->SetArgumentValue([argument UTF8String], [value UTF8String]);
+}
+
+- (NPT_Result)setErrorCode:(unsigned int)code withDescription:(NSString*)description
+{
+ return action->SetError(code, [description UTF8String]);
+}
+
+@end
+
+/*----------------------------------------------------------------------
+| PLT_DeviceHostObject
++---------------------------------------------------------------------*/
+@implementation PLT_DeviceHostObject
+
+- (id)init
+{
+ return [super init];
+}
+
+- (void)setDevice:(PLT_DeviceHostReference*)_device
+{
+ delete device;
+ device = new PLT_DeviceHostReference(*_device);
+}
+
+- (void)dealloc
+{
+ delete device;
+}
+
+- (PLT_DeviceHostReference&)getDevice
+{
+ return *device;
+}
+
+@end
+
+/*----------------------------------------------------------------------
+| PLT_UPnPObject
++---------------------------------------------------------------------*/
+
+@interface PLT_UPnPObject () {
+ PLT_UPnP *_upnp;
+ NSMutableArray *_devices;
+}
+@end
+
+@implementation PLT_UPnPObject
+
+- (id)init
+{
+ if ((self = [super init])) {
+ _upnp = new PLT_UPnP();
+ _devices = [NSMutableArray array];
+ }
+ return self;
+}
+
+-(void) dealloc
+{
+ delete _upnp;
+}
+
+- (NPT_Result)start
+{
+ return _upnp->Start();
+}
+
+- (NPT_Result)stop
+{
+ return _upnp->Stop();
+}
+
+- (bool)isRunning
+{
+ return _upnp->IsRunning();
+}
+
+- (NPT_Result)addDevice:(PLT_DeviceHostObject*)device
+{
+ [_devices addObject:device];
+ return _upnp->AddDevice([device getDevice]);
+}
+
+- (NPT_Result)removeDevice:(PLT_DeviceHostObject*)device
+{
+ [_devices removeObject:device];
+ return _upnp->RemoveDevice([device getDevice]);
+}
+
+@end
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltDownloader.cpp b/lib/libUPnP/Platinum/Source/Extras/PltDownloader.cpp
new file mode 100644
index 0000000..a910370
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltDownloader.cpp
@@ -0,0 +1,132 @@
+/*****************************************************************
+|
+| Platinum - Downloader
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltDownloader.h"
+#include "PltTaskManager.h"
+#include "Neptune.h"
+
+
+NPT_SET_LOCAL_LOGGER("platinum.extra.downloader")
+
+/*----------------------------------------------------------------------
+| PLT_Downloader::PLT_Downloader
++---------------------------------------------------------------------*/
+PLT_Downloader::PLT_Downloader(NPT_HttpUrl& url,
+ NPT_OutputStreamReference& output) :
+ PLT_HttpClientSocketTask(new NPT_HttpRequest(url,
+ "GET",
+ NPT_HTTP_PROTOCOL_1_1)),
+ m_URL(url),
+ m_Output(output),
+ m_State(PLT_DOWNLOADER_IDLE)
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_Downloader::~PLT_Downloader
++---------------------------------------------------------------------*/
+PLT_Downloader::~PLT_Downloader()
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_Downloader::DoRun
++---------------------------------------------------------------------*/
+void
+PLT_Downloader::DoRun()
+{
+ m_State = PLT_DOWNLOADER_STARTED;
+ return PLT_HttpClientSocketTask::DoRun();
+}
+
+/*----------------------------------------------------------------------
+| PLT_Downloader::DoAbort
++---------------------------------------------------------------------*/
+void
+PLT_Downloader::DoAbort()
+{
+ PLT_HttpClientSocketTask::DoAbort();
+ m_State = PLT_DOWNLOADER_IDLE;
+}
+
+/*----------------------------------------------------------------------
+| PLT_Downloader::ProcessResponse
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_Downloader::ProcessResponse(NPT_Result res,
+ const NPT_HttpRequest& request,
+ const NPT_HttpRequestContext& context,
+ NPT_HttpResponse* response)
+{
+ NPT_COMPILER_UNUSED(request);
+ NPT_COMPILER_UNUSED(context);
+
+ if (NPT_FAILED(res)) {
+ NPT_LOG_WARNING_2("Downloader error %d for %s", res, m_URL.ToString().GetChars());
+ m_State = PLT_DOWNLOADER_ERROR;
+ return res;
+ }
+
+ m_State = PLT_DOWNLOADER_DOWNLOADING;
+
+ NPT_HttpEntity* entity;
+ NPT_InputStreamReference body;
+ if (!response ||
+ !(entity = response->GetEntity()) ||
+ NPT_FAILED(entity->GetInputStream(body)) ||
+ body.IsNull()) {
+ m_State = PLT_DOWNLOADER_ERROR;
+ NPT_LOG_WARNING_2("No body %d for %s", res, m_URL.ToString().GetChars());
+ return NPT_FAILURE;
+ }
+
+ // Read body (no content length means until socket is closed)
+ res = NPT_StreamToStreamCopy(*body.AsPointer(),
+ *m_Output.AsPointer(),
+ 0,
+ entity->GetContentLength());
+
+ if (NPT_FAILED(res)) {
+ NPT_LOG_WARNING_2("Downloader error %d for %s", res, m_URL.ToString().GetChars());
+ m_State = PLT_DOWNLOADER_ERROR;
+ return res;
+ }
+
+ NPT_LOG_INFO_1("Finished downloading %s", m_URL.ToString().GetChars());
+ m_State = PLT_DOWNLOADER_SUCCESS;
+ return NPT_SUCCESS;
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltDownloader.h b/lib/libUPnP/Platinum/Source/Extras/PltDownloader.h
new file mode 100644
index 0000000..15d9279
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltDownloader.h
@@ -0,0 +1,89 @@
+/*****************************************************************
+|
+| Platinum - Downloader
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#ifndef _PLT_DOWNLOADER_H_
+#define _PLT_DOWNLOADER_H_
+
+/*----------------------------------------------------------------------
+| Includes
++---------------------------------------------------------------------*/
+#include "Neptune.h"
+#include "PltHttpClientTask.h"
+
+/*----------------------------------------------------------------------
+| forward declarations
++---------------------------------------------------------------------*/
+class PLT_Downloader;
+
+/*----------------------------------------------------------------------
+| types
++---------------------------------------------------------------------*/
+typedef enum {
+ PLT_DOWNLOADER_IDLE,
+ PLT_DOWNLOADER_STARTED,
+ PLT_DOWNLOADER_DOWNLOADING,
+ PLT_DOWNLOADER_ERROR,
+ PLT_DOWNLOADER_SUCCESS
+} Plt_DowloaderState;
+
+/*----------------------------------------------------------------------
+| PLT_Downloader class
++---------------------------------------------------------------------*/
+class PLT_Downloader : public PLT_HttpClientSocketTask
+{
+public:
+ PLT_Downloader(NPT_HttpUrl& url,
+ NPT_OutputStreamReference& output);
+ ~PLT_Downloader() override;
+
+ Plt_DowloaderState GetState() { return m_State; }
+
+ // PLT_HttpClientTask method
+ NPT_Result ProcessResponse(NPT_Result res,
+ const NPT_HttpRequest& request,
+ const NPT_HttpRequestContext& context,
+ NPT_HttpResponse* response) override;
+
+protected:
+ void DoRun() override;
+ void DoAbort() override;
+
+private:
+ // members
+ NPT_HttpUrl m_URL;
+ NPT_OutputStreamReference m_Output;
+ Plt_DowloaderState m_State;
+};
+
+#endif /* _PLT_DOWNLOADER_H_ */
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltFrameBuffer.cpp b/lib/libUPnP/Platinum/Source/Extras/PltFrameBuffer.cpp
new file mode 100644
index 0000000..5c4232d
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltFrameBuffer.cpp
@@ -0,0 +1,129 @@
+/*****************************************************************
+|
+| Platinum - Frame Buffer
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltFrameBuffer.h"
+
+NPT_SET_LOCAL_LOGGER("platinum.core.framebuffer")
+
+/*----------------------------------------------------------------------
+| PLT_FrameBuffer::PLT_FrameBuffer
++---------------------------------------------------------------------*/
+PLT_FrameBuffer::PLT_FrameBuffer(const char* mime_type) :
+ m_MimeType(mime_type),
+ m_Aborted(false)
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_FrameBuffer::~PLT_FrameBuffer
++---------------------------------------------------------------------*/
+PLT_FrameBuffer::~PLT_FrameBuffer()
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_FrameBuffer::Reset
++---------------------------------------------------------------------*/
+void
+PLT_FrameBuffer::Reset()
+{
+ NPT_AutoLock lock(m_FrameLock);
+
+ // mark that we're planning to receive more frames
+ m_Aborted = false;
+
+ // reset to 0 for new readers to
+ m_FrameIndex.SetValue(0);
+}
+
+/*----------------------------------------------------------------------
+| PLT_FrameBuffer::Abort
++---------------------------------------------------------------------*/
+void
+PLT_FrameBuffer::Abort()
+{
+ NPT_AutoLock lock(m_FrameLock);
+
+ // mark that we're not planning to receive more frames
+ m_Aborted = true;
+
+ // increment to unlock readers
+ m_FrameIndex.SetValue(m_FrameIndex.GetValue()+1);
+}
+
+/*----------------------------------------------------------------------
+| PLT_FrameBuffer::SetNextFrame
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_FrameBuffer::SetNextFrame(const NPT_Byte* data, NPT_Size size)
+{
+ NPT_AutoLock lock(m_FrameLock);
+
+ m_Frame.SetData(data, size);
+ m_FrameIndex.SetValue(m_FrameIndex.GetValue()+1);
+
+ NPT_LOG_INFO_1("Set frame %d", m_FrameIndex.GetValue());
+ return NPT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------
+| PLT_FrameBuffer::GetNextFrame
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_FrameBuffer::GetNextFrame(NPT_UInt32& last_frame_index,
+ NPT_DataBuffer& buffer,
+ NPT_Timeout timeout)
+{
+ NPT_CHECK_WARNING(m_FrameIndex.WaitWhileEquals(last_frame_index, timeout));
+
+ {
+ NPT_AutoLock lock(m_FrameLock);
+
+ // if we're aborted or we reseted, disconnect
+ if (m_Aborted || last_frame_index > (NPT_UInt32)m_FrameIndex.GetValue())
+ return NPT_ERROR_EOS;
+
+ buffer.SetData(m_Frame.GetData(), m_Frame.GetDataSize());
+
+ // update current frame index
+ last_frame_index = m_FrameIndex.GetValue();
+ NPT_LOG_INFO_1("Retrieved frame %d", last_frame_index);
+ }
+
+ return NPT_SUCCESS;
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltFrameBuffer.h b/lib/libUPnP/Platinum/Source/Extras/PltFrameBuffer.h
new file mode 100644
index 0000000..aa270df
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltFrameBuffer.h
@@ -0,0 +1,76 @@
+/*****************************************************************
+|
+| Platinum - Frame Buffer
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#ifndef _PLT_FRAME_BUFFER_H_
+#define _PLT_FRAME_BUFFER_H_
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "Neptune.h"
+
+/*----------------------------------------------------------------------
+| PLT_FrameBuffer
++---------------------------------------------------------------------*/
+class PLT_FrameBuffer
+{
+ public:
+ // constructor & destructor
+ PLT_FrameBuffer(const char* mime_type);
+ virtual ~PLT_FrameBuffer();
+
+ void Reset();
+ void Abort();
+ void AddReader() { m_Readers.Increment(); }
+ void RemoveReader() { m_Readers.Decrement(); }
+ int GetNbReaders() { return m_Readers.GetValue(); }
+ const char* GetMimeType() { return m_MimeType; }
+
+ // data buffer handling methods
+ virtual NPT_Result SetNextFrame(const NPT_Byte* buffer, NPT_Size bufferSize);
+ virtual NPT_Result GetNextFrame(NPT_UInt32& last_frame_index,
+ NPT_DataBuffer& buffer,
+ NPT_Timeout timeout = NPT_TIMEOUT_INFINITE);
+
+ protected:
+ // members
+ NPT_String m_MimeType;
+ bool m_Aborted;
+ NPT_SharedVariable m_FrameIndex;
+ NPT_DataBuffer m_Frame;
+ NPT_Mutex m_FrameLock;
+ NPT_AtomicVariable m_Readers;
+};
+
+#endif // _PLT_FRAME_BUFFER_H_
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltFrameServer.cpp b/lib/libUPnP/Platinum/Source/Extras/PltFrameServer.cpp
new file mode 100644
index 0000000..d01d414
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltFrameServer.cpp
@@ -0,0 +1,236 @@
+/*****************************************************************
+|
+| Platinum - Frame Server
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltFrameStream.h"
+#include "PltFrameServer.h"
+#include "PltUtilities.h"
+
+NPT_SET_LOCAL_LOGGER("platinum.media.server.frame")
+
+/*----------------------------------------------------------------------
+| constants
++---------------------------------------------------------------------*/
+#define BOUNDARY "BOUNDARYGOAWAY"
+
+/*----------------------------------------------------------------------
+| PLT_SocketPolicyServer
++---------------------------------------------------------------------*/
+class PLT_SocketPolicyServer : public NPT_Thread
+{
+public:
+ PLT_SocketPolicyServer(const char* policy,
+ NPT_IpPort port = 0,
+ const char* authorized_ports = "5900") :
+ m_Socket(NPT_SOCKET_FLAG_CANCELLABLE),
+ m_Policy(policy),
+ m_Port(port),
+ m_AuthorizedPorts(authorized_ports),
+ m_Aborted(false) {}
+
+ ~PLT_SocketPolicyServer() {
+ Stop();
+ }
+
+ NPT_Result Start() {
+ NPT_Result result = NPT_FAILURE;
+
+ // bind
+ // randomly try a port for our http server
+ int retries = 100;
+ do {
+ int random = NPT_System::GetRandomInteger();
+ NPT_IpPort port = (unsigned short)(50000 + (random % 15000));
+
+ result = m_Socket.Bind(
+ NPT_SocketAddress(NPT_IpAddress::Any, m_Port?m_Port:port),
+ false);
+
+ if (NPT_SUCCEEDED(result) || m_Port)
+ break;
+ } while (--retries > 0);
+
+ if (NPT_FAILED(result) || retries == 0) return NPT_FAILURE;
+
+ // remember that we're bound
+ NPT_SocketInfo info;
+ m_Socket.GetInfo(info);
+ m_Port = info.local_address.GetPort();
+
+ return NPT_Thread::Start();
+ }
+
+ NPT_Result Stop() {
+ m_Aborted = true;
+ m_Socket.Cancel();
+
+ return Wait();
+ }
+
+ void Run() {
+ do {
+ // wait for a connection
+ NPT_Socket* client = NULL;
+ NPT_LOG_FINE_1("waiting for connection on port %d...", m_Port);
+ NPT_Result result = m_Socket.WaitForNewClient(client, NPT_TIMEOUT_INFINITE);
+ if (NPT_FAILED(result) || client == NULL) return;
+
+ NPT_SocketInfo client_info;
+ client->GetInfo(client_info);
+ NPT_LOG_FINE_2("client connected (%s -> %s)",
+ client_info.local_address.ToString().GetChars(),
+ client_info.remote_address.ToString().GetChars());
+
+ // get the output stream
+ NPT_OutputStreamReference output;
+ client->GetOutputStream(output);
+
+ // generate policy based on our current IP
+ NPT_String policy = "<cross-domain-policy>";
+ policy += "<allow-access-from domain=\""+client_info.local_address.GetIpAddress().ToString()+"\" to-ports=\""+m_AuthorizedPorts+"\"/>";
+ policy += "<allow-access-from domain=\""+client_info.remote_address.GetIpAddress().ToString()+"\" to-ports=\""+m_AuthorizedPorts+"\"/>";
+ policy += "</cross-domain-policy>";
+
+ NPT_MemoryStream* mem_input = new NPT_MemoryStream();
+ mem_input->Write(policy.GetChars(), policy.GetLength());
+ NPT_InputStreamReference input(mem_input);
+
+ NPT_StreamToStreamCopy(*input, *output);
+
+
+ delete client;
+ } while (!m_Aborted);
+ }
+
+ NPT_TcpServerSocket m_Socket;
+ NPT_String m_Policy;
+ NPT_IpPort m_Port;
+ NPT_String m_AuthorizedPorts;
+ bool m_Aborted;
+};
+
+/*----------------------------------------------------------------------
+| PLT_HttpStreamRequestHandler::SetupResponse
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_HttpStreamRequestHandler::SetupResponse(NPT_HttpRequest& request,
+ const NPT_HttpRequestContext& context,
+ NPT_HttpResponse& response)
+{
+ PLT_LOG_HTTP_REQUEST(NPT_LOG_LEVEL_FINE, "PLT_HttpStreamRequestHandler::SetupResponse:", &request);
+
+ if (request.GetMethod().Compare("GET") &&
+ request.GetMethod().Compare("HEAD")) {
+ return NPT_FAILURE;
+ }
+
+ NPT_Reference<PLT_FrameBuffer> buffer;
+ if (!m_StreamValidator.OnNewRequestAccept(request, context, response, buffer)) {
+ return NPT_ERROR_NO_SUCH_ITEM;
+ }
+
+ response.SetProtocol(NPT_HTTP_PROTOCOL_1_0);
+ response.GetHeaders().SetHeader(NPT_HTTP_HEADER_CONNECTION, "close");
+ response.GetHeaders().SetHeader("Cache-Control", "no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0");
+ response.GetHeaders().SetHeader("Pragma", "no-cache");
+ response.GetHeaders().SetHeader("Expires", "Tue, 4 Jan 2000 02:43:05 GMT");
+
+ // HEAD request has no entity or if status code is not 2xx
+ if (!request.GetMethod().Compare("HEAD") || response.GetStatusCode()/100 != 2)
+ return NPT_SUCCESS;
+
+ NPT_HttpEntity* entity = response.GetEntity();
+ NPT_CHECK_POINTER_FATAL(entity);
+ entity->SetContentType("multipart/x-mixed-replace;boundary=" BOUNDARY);
+
+ NPT_InputStreamReference body(new PLT_InputFrameStream(buffer, BOUNDARY));
+ entity->SetInputStream(body, false);
+
+ return NPT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------
+| PLT_FrameServer::PLT_FrameServer
++---------------------------------------------------------------------*/
+PLT_FrameServer::PLT_FrameServer(const char* resource_name,
+ PLT_StreamValidator& stream_validator,
+ NPT_IpAddress address,
+ NPT_UInt16 port,
+ bool policy_server_enabled) :
+ PLT_HttpServer(address, port, false),
+ m_PolicyServer(NULL),
+ m_StreamValidator(stream_validator),
+ m_PolicyServerEnabled(policy_server_enabled)
+{
+ NPT_String resource(resource_name);
+ resource.Trim("/\\");
+ AddRequestHandler(
+ new PLT_HttpStreamRequestHandler(stream_validator),
+ "/" + resource,
+ true,
+ true);
+}
+
+/*----------------------------------------------------------------------
+| PLT_FrameServer::~PLT_FrameServer
++---------------------------------------------------------------------*/
+PLT_FrameServer::~PLT_FrameServer()
+{
+ delete m_PolicyServer;
+}
+
+/*----------------------------------------------------------------------
+| PLT_FrameServer::Start
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_FrameServer::Start()
+{
+ // start main server so we can get the listening port
+ NPT_CHECK_SEVERE(PLT_HttpServer::Start());
+
+ // start the xml socket policy server for flash
+ if (m_PolicyServerEnabled) {
+ m_PolicyServer = new PLT_SocketPolicyServer(
+ "",
+ 8989,
+ "5900,"+NPT_String::FromInteger(GetPort()));
+ NPT_CHECK_SEVERE(m_PolicyServer->Start());
+ }
+
+ return NPT_SUCCESS;
+}
+
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltFrameServer.h b/lib/libUPnP/Platinum/Source/Extras/PltFrameServer.h
new file mode 100644
index 0000000..e5c1192
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltFrameServer.h
@@ -0,0 +1,103 @@
+/*****************************************************************
+|
+| Platinum - Frame Server
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#ifndef _PLT_FRAME_SERVER_H_
+#define _PLT_FRAME_SERVER_H_
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "Neptune.h"
+#include "PltHttpServer.h"
+#include "PltFrameBuffer.h"
+
+/*----------------------------------------------------------------------
+| forward declarations
++---------------------------------------------------------------------*/
+class PLT_SocketPolicyServer;
+
+/*----------------------------------------------------------------------
+| PLT_StreamValidator class
++---------------------------------------------------------------------*/
+class PLT_StreamValidator
+{
+public:
+ virtual ~PLT_StreamValidator() {}
+ virtual bool OnNewRequestAccept(const NPT_HttpRequest& request,
+ const NPT_HttpRequestContext& context,
+ NPT_HttpResponse& response,
+ NPT_Reference<PLT_FrameBuffer>& buffer) = 0;
+};
+
+/*----------------------------------------------------------------------
+| PLT_HttpStreamRequestHandler
++---------------------------------------------------------------------*/
+class PLT_HttpStreamRequestHandler : public NPT_HttpRequestHandler
+{
+public:
+ // constructor
+ PLT_HttpStreamRequestHandler(PLT_StreamValidator& stream_validator) :
+ m_StreamValidator(stream_validator) {}
+
+ // NPT_HttpRequestHandler methods
+ NPT_Result SetupResponse(NPT_HttpRequest& request,
+ const NPT_HttpRequestContext& context,
+ NPT_HttpResponse& response) override;
+
+private:
+ PLT_StreamValidator& m_StreamValidator;
+};
+
+/*----------------------------------------------------------------------
+| PLT_FrameServer class
++---------------------------------------------------------------------*/
+class PLT_FrameServer : public PLT_HttpServer
+{
+public:
+ PLT_FrameServer(const char* resource_name,
+ PLT_StreamValidator& stream_validator,
+ NPT_IpAddress address = NPT_IpAddress::Any,
+ NPT_UInt16 port = 0,
+ bool policy_server_enabled = false);
+ ~PLT_FrameServer() override;
+
+ NPT_Result Start() override;
+
+protected:
+ PLT_SocketPolicyServer* m_PolicyServer;
+ PLT_StreamValidator& m_StreamValidator;
+ bool m_PolicyServerEnabled;
+};
+
+#endif /* _PLT_FRAME_SERVER_H_ */
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltFrameStream.cpp b/lib/libUPnP/Platinum/Source/Extras/PltFrameStream.cpp
new file mode 100644
index 0000000..2b3b3e1
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltFrameStream.cpp
@@ -0,0 +1,128 @@
+/*****************************************************************
+|
+| Platinum - Frame Stream
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltFrameStream.h"
+
+NPT_SET_LOCAL_LOGGER("platinum.core.framestream")
+
+/*----------------------------------------------------------------------
+| PLT_InputFrameStream::PLT_InputFrameStream
++---------------------------------------------------------------------*/
+PLT_InputFrameStream::PLT_InputFrameStream(NPT_Reference<PLT_FrameBuffer>& frame_buffer,
+ const char* boundary) :
+ m_FrameBuffer(frame_buffer),
+ m_LastFrameIndex(0),
+ m_Boundary(boundary),
+ m_Eos(false)
+{
+ m_FrameBuffer->AddReader();
+}
+
+/*----------------------------------------------------------------------
+| PLT_InputFrameStream::~PLT_InputFrameStream
++---------------------------------------------------------------------*/
+PLT_InputFrameStream::~PLT_InputFrameStream()
+{
+ m_FrameBuffer->RemoveReader();
+}
+
+/*----------------------------------------------------------------------
+| PLT_InputFrameStream::GetAvailable
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_InputFrameStream::GetAvailable(NPT_LargeSize& available)
+{
+ NPT_CHECK_WARNING(m_Part.GetAvailable(available));
+
+ if (available == 0 && !m_Eos) {
+ NPT_CHECK_WARNING(FillBuffer());
+ NPT_CHECK_WARNING(m_Part.GetAvailable(available));
+ }
+
+ return NPT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------
+| PLT_InputFrameStream::FillBuffer
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_InputFrameStream::FillBuffer()
+{
+ // reset memorystream
+ m_Part.SetDataSize(0);
+
+ // fetch next frame
+ NPT_DataBuffer frame;
+ NPT_Result result = m_FrameBuffer->GetNextFrame(m_LastFrameIndex, frame);
+
+ // error (EOS) or empty frame means we're done
+ if (NPT_FAILED(result) || frame.GetDataSize() == 0) {
+ m_Part.WriteLine("--" + m_Boundary + "--");
+ m_Eos = true;
+ return NPT_SUCCESS;
+ }
+
+ m_Part.WriteLine("--" + m_Boundary);
+ m_Part.WriteLine("Content-Type: " + NPT_String(m_FrameBuffer->GetMimeType()));
+ m_Part.WriteLine("Content-Length: "+NPT_String::FromInteger(frame.GetDataSize()));
+ m_Part.WriteLine("");
+ m_Part.Write(frame.GetData(), frame.GetDataSize());
+ m_Part.WriteLine("");
+ return NPT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------
+| PLT_InputFrameStream::Read
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_InputFrameStream::Read(void* buffer,
+ NPT_Size bytes_to_read,
+ NPT_Size* bytes_read /*= 0*/)
+{
+
+ if (bytes_read) *bytes_read = 0;
+
+ if (bytes_to_read == 0) {
+ return NPT_SUCCESS;
+ }
+
+ // make sure we have data
+ NPT_LargeSize available;
+ NPT_CHECK_WARNING(GetAvailable(available));
+
+ return m_Part.Read(buffer, bytes_to_read, bytes_read);
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltFrameStream.h b/lib/libUPnP/Platinum/Source/Extras/PltFrameStream.h
new file mode 100644
index 0000000..6d6deb8
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltFrameStream.h
@@ -0,0 +1,79 @@
+/*****************************************************************
+|
+| Platinum - Frame Stream
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#ifndef _PLT_FRAMESTREAM_H_
+#define _PLT_FRAMESTREAM_H_
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "Neptune.h"
+#include "PltFrameBuffer.h"
+
+/*----------------------------------------------------------------------
+| PLT_InputFrameStream
++---------------------------------------------------------------------*/
+class PLT_InputFrameStream : public NPT_InputStream
+{
+public:
+ // methods
+ PLT_InputFrameStream(NPT_Reference<PLT_FrameBuffer>& frame_buffer,
+ const char* boundary);
+ ~PLT_InputFrameStream() override;
+
+ // NPT_InputStream methods
+ NPT_Result Read(void* buffer,
+ NPT_Size bytes_to_read,
+ NPT_Size* bytes_read = 0) override;
+
+ NPT_Result Seek(NPT_Position offset) override { NPT_COMPILER_UNUSED(offset); return NPT_FAILURE; }
+ NPT_Result Skip(NPT_Size offset) override { NPT_COMPILER_UNUSED(offset); return NPT_FAILURE; }
+ NPT_Result Tell(NPT_Position& offset) override { NPT_COMPILER_UNUSED(offset); return NPT_FAILURE; }
+ NPT_Result GetSize(NPT_LargeSize& size) override { NPT_COMPILER_UNUSED(size); return NPT_FAILURE; }
+ NPT_Result GetAvailable(NPT_LargeSize& available) override;
+
+private:
+ NPT_Result FillBuffer();
+
+protected:
+ NPT_Reference<PLT_FrameBuffer> m_FrameBuffer;
+ NPT_MemoryStream m_Part;
+ NPT_UInt32 m_LastFrameIndex;
+ NPT_String m_Boundary;
+ bool m_Eos;
+};
+
+typedef NPT_Reference<PLT_InputFrameStream> PLT_InputFrameStreamReference;
+
+#endif /* _PLT_FRAMESTREAM_H_ */
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltLeaks.cpp b/lib/libUPnP/Platinum/Source/Extras/PltLeaks.cpp
new file mode 100644
index 0000000..91b1b99
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltLeaks.cpp
@@ -0,0 +1,99 @@
+/*****************************************************************
+|
+| Platinum - Leaks
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltLeaks.h"
+
+#if defined(WIN32)
+#include <crtdbg.h>
+#include <stdio.h>
+#include "string.h"
+
+/*----------------------------------------------------------------------
+| PLT_Leak_AllocHook
++---------------------------------------------------------------------*/
+int PLT_Leak_AllocHook(int alloc_type,
+ void* user_data,
+ size_t size,
+ int block_type,
+ long request_number,
+ const unsigned char* filename,
+ int line_number)
+{
+ (void)alloc_type;
+ (void)user_data;
+ (void)size;
+ (void)block_type;
+ (void)request_number;
+ (void)line_number;
+ (void)filename;
+ /*
+ * if (request_number == 34556)
+ * return 2;
+ *
+ */
+ return 1;
+}
+
+/*----------------------------------------------------------------------
+| PLT_Leak_Enable
++---------------------------------------------------------------------*/
+void
+PLT_Leak_Enable(void)
+{
+#if defined(_DEBUG)
+ /*
+ * If you want VC to dump file name and line number of leaking resource
+ * use #define _CRTDBG_MAP_ALLOC in suspected file (project)
+ * and #include "crtdbg.h" in suspected file
+ */
+_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF |
+ _CRTDBG_CHECK_ALWAYS_DF |
+ _CRTDBG_LEAK_CHECK_DF);
+
+_CrtSetAllocHook(PLT_Leak_AllocHook );
+
+#endif
+}
+#else
+/*----------------------------------------------------------------------
+| PLT_Leak_Enable
++---------------------------------------------------------------------*/
+void
+PLT_Leak_Enable(void)
+{
+}
+#endif
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltLeaks.h b/lib/libUPnP/Platinum/Source/Extras/PltLeaks.h
new file mode 100644
index 0000000..73d1e3a
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltLeaks.h
@@ -0,0 +1,51 @@
+/*****************************************************************
+|
+| Platinum - Leaks
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#ifndef _PLT_LEAKS_H_
+#define _PLT_LEAKS_H_
+
+/*----------------------------------------------------------------------
+| functions
++---------------------------------------------------------------------*/
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+void PLT_Leak_Enable(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _PLT_LEAKS_H_ */
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltMetadataHandler.cpp b/lib/libUPnP/Platinum/Source/Extras/PltMetadataHandler.cpp
new file mode 100644
index 0000000..b7d0312
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltMetadataHandler.cpp
@@ -0,0 +1,90 @@
+/*****************************************************************
+|
+| Platinum - Metadata Handler
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltMetadataHandler.h"
+
+NPT_SET_LOCAL_LOGGER("platinum.core.metadata.handler")
+
+/*----------------------------------------------------------------------
+| PLT_MetadataHandler::Load
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_MetadataHandler::Load(const char* filename)
+{
+ NPT_File file(filename);
+ NPT_Result res = file.Open(NPT_FILE_OPEN_MODE_READ);
+ if (res != NPT_SUCCESS) {
+ NPT_LOG_SEVERE_2("error %d opening : %s\n", res, filename);
+ } else {
+ NPT_InputStreamReference stream;
+ res = file.GetInputStream(stream);
+ if (NPT_FAILED(res)) {
+ NPT_LOG_SEVERE_2("error %d getting input stream: %s\n", res, filename);
+ }
+ res = Load(*stream);
+ if (NPT_FAILED(res)) {
+ NPT_LOG_SEVERE_2("error %d reading header: %s\n", res, filename);
+ }
+ }
+
+ return res;
+}
+
+/*----------------------------------------------------------------------
+| PLT_MetadataHandler::Save
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_MetadataHandler::Save(const char* filename)
+{
+ NPT_File file(filename);
+ NPT_Result res = file.Open(NPT_FILE_OPEN_MODE_WRITE);
+ if (res != NPT_SUCCESS) {
+ NPT_LOG_SEVERE_2("error %d opening : %s\n", res, filename);
+ } else {
+ NPT_OutputStreamReference stream;
+ res = file.GetOutputStream(stream);
+ if (NPT_FAILED(res)) {
+ NPT_LOG_SEVERE_2("error %d getting output stream: %s\n", res, filename);
+ }
+ res = Save(*stream);
+ if (NPT_FAILED(res)) {
+ NPT_LOG_SEVERE_2("error %d writing header: %s\n", res, filename);
+ }
+ }
+
+ return res;
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltMetadataHandler.h b/lib/libUPnP/Platinum/Source/Extras/PltMetadataHandler.h
new file mode 100644
index 0000000..d1709bd
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltMetadataHandler.h
@@ -0,0 +1,91 @@
+/*****************************************************************
+|
+| Platinum - Metadata Handler
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#ifndef _PLT_METADATA_HANDLER_H_
+#define _PLT_METADATA_HANDLER_H_
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "Neptune.h"
+
+/*----------------------------------------------------------------------
+| PLT_MetadataHandler class
++---------------------------------------------------------------------*/
+class PLT_MetadataHandler
+{
+public:
+ virtual ~PLT_MetadataHandler() {}
+
+ // metadata overridables
+ virtual bool HandleExtension(const char* extension) = 0;
+ virtual NPT_Result Load(NPT_InputStream& stream,
+ NPT_TimeInterval sleeptime = NPT_TimeInterval(.01),
+ NPT_TimeInterval timeout = NPT_TimeInterval(30.)) = 0;
+ virtual NPT_Result Save(NPT_OutputStream& stream,
+ NPT_TimeInterval sleeptime = NPT_TimeInterval(.01),
+ NPT_TimeInterval timeout = NPT_TimeInterval(30.)) = 0;
+
+ virtual const char* GetLicenseData(NPT_String& licenseData) = 0;
+ virtual NPT_Result GetCoverArtData(char*& caData, int& len) = 0;
+ virtual const char* GetContentID(NPT_String& value) = 0;
+ virtual const char* GetTitle(NPT_String& value) = 0;
+ virtual const char* GetDescription(NPT_String& value) = 0;
+ virtual NPT_Result GetDuration(NPT_UInt32& seconds) = 0;
+ virtual const char* GetProtection(NPT_String& protection) = 0;
+ virtual NPT_Result GetYear(NPT_Size& year) = 0;
+
+ // helper functions
+ virtual NPT_Result Load(const char* filename);
+ virtual NPT_Result Save(const char* filename);
+};
+
+/*----------------------------------------------------------------------
+| PLT_MetadataHandlerFinder
++---------------------------------------------------------------------*/
+class PLT_MetadataHandlerFinder
+{
+public:
+ // methods
+ PLT_MetadataHandlerFinder(const char* extension) : m_Extension(extension) {}
+ bool operator()(PLT_MetadataHandler* const & handler) const {
+ return handler->HandleExtension(m_Extension) ? true : false;
+ }
+
+private:
+ // members
+ NPT_String m_Extension;
+};
+
+#endif /* _PLT_METADATA_HANDLER_H_ */
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltRingBufferStream.cpp b/lib/libUPnP/Platinum/Source/Extras/PltRingBufferStream.cpp
new file mode 100644
index 0000000..92eb355
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltRingBufferStream.cpp
@@ -0,0 +1,255 @@
+/*****************************************************************
+|
+| Platinum - Ring Buffer Stream
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltRingBufferStream.h"
+#include "Neptune.h"
+
+/*----------------------------------------------------------------------
+| defines
++---------------------------------------------------------------------*/
+#ifdef max
+#undef max
+#endif
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+#ifdef min
+#undef min
+#endif
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+/*----------------------------------------------------------------------
+| PLT_RingBufferStream::PLT_RingBufferStream
++---------------------------------------------------------------------*/
+PLT_RingBufferStream::PLT_RingBufferStream(NPT_Size buffer_size,
+ bool blocking /* = true */) :
+ m_TotalBytesRead(0),
+ m_TotalBytesWritten(0),
+ m_Blocking(blocking),
+ m_Eos(false),
+ m_Aborted(false)
+{
+ m_RingBuffer = new NPT_RingBuffer(buffer_size);
+}
+
+/*----------------------------------------------------------------------
+| PLT_RingBufferStream::PLT_RingBufferStream
++---------------------------------------------------------------------*/
+PLT_RingBufferStream::PLT_RingBufferStream(NPT_RingBufferReference& buffer,
+ bool blocking /* = true */) :
+ m_RingBuffer(buffer),
+ m_TotalBytesRead(0),
+ m_TotalBytesWritten(0),
+ m_Blocking(blocking),
+ m_Eos(false),
+ m_Aborted(false)
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_RingBufferStream::~PLT_RingBufferStream
++---------------------------------------------------------------------*/
+PLT_RingBufferStream::~PLT_RingBufferStream()
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_RingBufferStream::Read
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_RingBufferStream::Read(void* buffer,
+ NPT_Size max_bytes_to_read,
+ NPT_Size* _bytes_read /*= NULL*/)
+{
+ NPT_Size bytes_to_read;
+ NPT_Size bytes_read = 0;
+
+ // reset output param first
+ if (_bytes_read) *_bytes_read = 0;
+
+ // wait for data
+ do {
+ {
+ NPT_AutoLock autoLock(m_Lock);
+
+ if (m_Aborted) {
+ return NPT_ERROR_INTERRUPTED;
+ }
+
+ // check for data
+ if (m_RingBuffer->GetAvailable())
+ break;
+
+ if (m_Eos) {
+ return NPT_ERROR_EOS;
+ } else if (!m_Blocking) {
+ return NPT_ERROR_WOULD_BLOCK;
+ }
+ }
+
+ // sleep and try again
+ NPT_System::Sleep(NPT_TimeInterval(.1));
+ } while (1);
+
+ {
+ NPT_AutoLock autoLock(m_Lock);
+
+ // try twice in case available data was not contiguous
+ for (int i=0; i<2; i++) {
+ bytes_to_read = min(max_bytes_to_read - bytes_read, m_RingBuffer->GetContiguousAvailable());
+
+ // break if nothing to read the second time
+ if (bytes_to_read == 0) break;
+
+ // read into buffer and advance
+ NPT_CHECK(m_RingBuffer->Read((unsigned char*)buffer+bytes_read, bytes_to_read));
+
+ // keep track of the total bytes we have read so far
+ m_TotalBytesRead += bytes_to_read;
+ bytes_read += bytes_to_read;
+
+ if (_bytes_read) *_bytes_read += bytes_to_read;
+ }
+ }
+
+ // we have read some chars, so return success
+ // even if we have read less than asked
+ return NPT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------
+| PLT_RingBufferStream::Write
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_RingBufferStream::Write(const void* buffer,
+ NPT_Size max_bytes_to_write,
+ NPT_Size* _bytes_written /*= NULL*/)
+{
+ NPT_Size bytes_to_write;
+ NPT_Size bytes_written = 0;
+
+ // reset output param first
+ if (_bytes_written) *_bytes_written = 0;
+
+ // wait for space
+ do {
+ {
+ NPT_AutoLock autoLock(m_Lock);
+
+ if (m_Aborted) {
+ return NPT_ERROR_INTERRUPTED;
+ }
+
+ // return immediately if we are told we're finished
+ if (m_Eos) {
+ return NPT_ERROR_EOS;
+ }
+
+ if (m_RingBuffer->GetSpace())
+ break;
+
+ if (!m_Blocking) {
+ return NPT_ERROR_WOULD_BLOCK;
+ }
+ }
+
+ // sleep and try again
+ NPT_System::Sleep(NPT_TimeInterval(.1));
+ } while (1);
+
+ {
+ NPT_AutoLock autoLock(m_Lock);
+
+ // try twice in case available space was not contiguous
+ for (int i=0; i<2; i++) {
+ bytes_to_write = min(max_bytes_to_write - bytes_written, m_RingBuffer->GetContiguousSpace());
+
+ // break if no space to write the second time
+ if (bytes_to_write == 0) break;
+
+ // write into buffer
+ NPT_CHECK(m_RingBuffer->Write((unsigned char*)buffer+bytes_written, bytes_to_write));
+
+ m_TotalBytesWritten += bytes_to_write;
+ bytes_written += bytes_to_write;
+
+ if (_bytes_written) *_bytes_written += bytes_to_write;
+ }
+ }
+
+ // we have written some chars, so return success
+ // even if we have written less than provided
+ return NPT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------
+| PLT_RingBufferStream::Flush
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_RingBufferStream::Flush()
+{
+ NPT_AutoLock autoLock(m_Lock);
+
+ m_RingBuffer->Flush();
+ m_TotalBytesRead = 0;
+ m_TotalBytesWritten = 0;
+ return NPT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------
+| PLT_RingBufferStream::SetEOS
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_RingBufferStream::SetEOS()
+{
+ NPT_AutoLock autoLock(m_Lock);
+
+ m_Eos = true;
+ return NPT_SUCCESS;
+}
+
+
+/*----------------------------------------------------------------------
+ | PLT_RingBufferStream::Abort
+ +---------------------------------------------------------------------*/
+NPT_Result
+PLT_RingBufferStream::Abort()
+{
+ NPT_AutoLock autoLock(m_Lock);
+
+ m_Aborted = true;
+ return NPT_SUCCESS;
+}
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltRingBufferStream.h b/lib/libUPnP/Platinum/Source/Extras/PltRingBufferStream.h
new file mode 100644
index 0000000..bd56b8a
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltRingBufferStream.h
@@ -0,0 +1,119 @@
+/*****************************************************************
+|
+| Platinum - Ring buffer stream
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#ifndef _PLT_RING_BUFFER_STREAM_H_
+#define _PLT_RING_BUFFER_STREAM_H_
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "Neptune.h"
+
+/*----------------------------------------------------------------------
+| PLT_RingBufferStream class
++---------------------------------------------------------------------*/
+class PLT_RingBufferStream : public NPT_DelegatingInputStream,
+ public NPT_DelegatingOutputStream
+{
+public:
+ PLT_RingBufferStream(NPT_Size buffer_size = 4096, bool blocking = true);
+ PLT_RingBufferStream(NPT_RingBufferReference& buffer, bool blocking = true);
+ ~PLT_RingBufferStream() override;
+
+ // methods
+ bool IsAborted() { return m_Aborted; }
+
+ // NPT_InputStream methods
+ NPT_Result Read(void* buffer,
+ NPT_Size bytes_to_read,
+ NPT_Size* bytes_read = NULL) override;
+ NPT_Result GetSize(NPT_LargeSize& size) override {
+ NPT_COMPILER_UNUSED(size);
+ return NPT_ERROR_NOT_SUPPORTED;
+ }
+ NPT_Result GetSpace(NPT_LargeSize& space) {
+ NPT_AutoLock autoLock(m_Lock);
+ space = m_RingBuffer->GetSpace();
+ return NPT_SUCCESS;
+ }
+ NPT_Result GetAvailable(NPT_LargeSize& available) override {
+ NPT_AutoLock autoLock(m_Lock);
+ available = m_RingBuffer->GetAvailable();
+ return NPT_SUCCESS;
+ }
+
+ // NPT_OutputStream methods
+ NPT_Result Write(const void* buffer,
+ NPT_Size bytes_to_write,
+ NPT_Size* bytes_written = NULL) override;
+ NPT_Result Flush() override;
+ NPT_Result SetEOS();
+ NPT_Result Abort();
+
+protected:
+ // NPT_DelegatingInputStream methods
+ NPT_Result InputSeek(NPT_Position offset) override {
+ NPT_COMPILER_UNUSED(offset);
+ return NPT_ERROR_NOT_SUPPORTED;
+ }
+ NPT_Result InputTell(NPT_Position& offset) override {
+ NPT_AutoLock autoLock(m_Lock);
+ offset = m_TotalBytesRead;
+ return NPT_SUCCESS;
+ }
+
+ // NPT_DelegatingOutputStream methods
+ NPT_Result OutputSeek(NPT_Position offset) override {
+ NPT_COMPILER_UNUSED(offset);
+ return NPT_ERROR_NOT_SUPPORTED;
+ }
+ NPT_Result OutputTell(NPT_Position& offset) override {
+ NPT_AutoLock autoLock(m_Lock);
+ offset = m_TotalBytesWritten;
+ return NPT_SUCCESS;
+ }
+
+private:
+ NPT_RingBufferReference m_RingBuffer;
+ NPT_Offset m_TotalBytesRead;
+ NPT_Offset m_TotalBytesWritten;
+ NPT_Mutex m_Lock;
+ bool m_Blocking;
+ bool m_Eos;
+ bool m_Aborted;
+};
+
+typedef NPT_Reference<PLT_RingBufferStream> PLT_RingBufferStreamReference;
+
+#endif // _PLT_RING_BUFFER_STREAM_H_
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltStreamPump.cpp b/lib/libUPnP/Platinum/Source/Extras/PltStreamPump.cpp
new file mode 100644
index 0000000..80d1614
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltStreamPump.cpp
@@ -0,0 +1,227 @@
+/*****************************************************************
+|
+| Platinum - Stream Pump
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+ ****************************************************************/
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "PltStreamPump.h"
+#include "Neptune.h"
+
+/*----------------------------------------------------------------------
+| PLT_StreamPump::PLT_StreamPump
++---------------------------------------------------------------------*/
+PLT_StreamPump::PLT_StreamPump(NPT_Size size) :
+ m_TotalBytesRead(0),
+ m_TotalBytesWritten(0)
+{
+ m_RingBuffer = new NPT_RingBuffer(size);
+}
+
+/*----------------------------------------------------------------------
+| PLT_StreamPump::~PLT_StreamPump
++---------------------------------------------------------------------*/
+PLT_StreamPump::~PLT_StreamPump()
+{
+ delete m_RingBuffer;
+}
+/*----------------------------------------------------------------------+
+| PLT_StreamPump::PushData
++----------------------------------------------------------------------*/
+NPT_Result
+PLT_StreamPump::PushData(NPT_OutputStream& output,
+ NPT_Size& bytes_written)
+{
+ NPT_Result res = NPT_ERROR_WOULD_BLOCK;
+ NPT_Size count = 0;
+ NPT_Size bytes_available = m_RingBuffer->GetContiguousAvailable();
+
+ bytes_written = 0;
+
+ if (bytes_available) {
+ res = output.Write(m_RingBuffer->GetReadPointer(), bytes_available, &count);
+ m_RingBuffer->MoveOut(count);
+ bytes_written += count;
+
+ // check if we wrapped around
+ bytes_available = m_RingBuffer->GetContiguousAvailable();
+ if (NPT_SUCCEEDED(res) && bytes_available) {
+ res = output.Write(m_RingBuffer->GetReadPointer(), bytes_available, &count);
+ m_RingBuffer->MoveOut(count);
+ bytes_written += count;
+ }
+ }
+
+ m_TotalBytesWritten += bytes_written;
+
+ return res;
+}
+
+/*----------------------------------------------------------------------+
+| PLT_StreamPump::PullData
++----------------------------------------------------------------------*/
+NPT_Result
+PLT_StreamPump::PullData(NPT_InputStream& input,
+ NPT_Size max_bytes_to_read)
+{
+ NPT_Result res = NPT_ERROR_WOULD_BLOCK;
+ NPT_Size byte_space = m_RingBuffer->GetContiguousSpace();
+
+ // check that there is space left
+ // make sure we don't read more than our contiguous space
+ NPT_Size nb_to_read = (max_bytes_to_read<byte_space)?max_bytes_to_read:byte_space;
+ if (nb_to_read > 0) {
+ NPT_Size count;
+ res = input.Read(m_RingBuffer->GetWritePointer(), nb_to_read, &count);
+ m_RingBuffer->MoveIn(count);
+ max_bytes_to_read -= count;
+ m_TotalBytesRead += count;
+
+ byte_space = m_RingBuffer->GetContiguousSpace();
+ nb_to_read = (max_bytes_to_read<byte_space)?max_bytes_to_read:byte_space;
+ // if we filled our contiguous space, and we wrapped, check if there is more to read
+ if (NPT_SUCCEEDED(res) && (nb_to_read > 0)) {
+ res = input.Read(m_RingBuffer->GetWritePointer(), nb_to_read, &count);
+ m_RingBuffer->MoveIn(count);
+ m_TotalBytesRead += count;
+ }
+ }
+
+ return res;
+}
+
+/*----------------------------------------------------------------------
+| PLT_PipeInputStreamPump::PLT_PipeInputStreamPump
++---------------------------------------------------------------------*/
+PLT_PipeInputStreamPump::PLT_PipeInputStreamPump(NPT_OutputStreamReference& output,
+ NPT_Size size) :
+ PLT_StreamPump(size),
+ m_Output(output),
+ m_LastRes(NPT_SUCCESS)
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_PipeInputStreamPump::~PLT_PipeInputStreamPump
++---------------------------------------------------------------------*/
+PLT_PipeInputStreamPump::~PLT_PipeInputStreamPump()
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_PipeInputStreamPump::Receive
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_PipeInputStreamPump::Receive(NPT_InputStream& input,
+ NPT_Size max_bytes_to_read,
+ NPT_Size* bytes_read)
+{
+ NPT_Size count;
+ NPT_Result res;
+
+ if ((m_LastRes == NPT_SUCCESS) || (m_LastRes == NPT_ERROR_WOULD_BLOCK)) {
+ // look at what we have buffered already from out input
+ // and if have less than what was asked, read more
+ NPT_Size available = m_RingBuffer->GetAvailable();
+ if (available < max_bytes_to_read) {
+ m_LastRes = PullData(input, max_bytes_to_read-available);
+ }
+ } else if (!m_RingBuffer->GetAvailable()) {
+ // if the buffer is now empty, return the input last error
+ return m_LastRes;
+ }
+
+ // write as much as we can on the output stream
+ res = PushData(*m_Output, count);
+
+ if (bytes_read) *bytes_read = count;
+ return res;
+}
+
+
+/*----------------------------------------------------------------------
+| PLT_PipeOutputStreamPump::PLT_PipeOutputStreamPump
++---------------------------------------------------------------------*/
+PLT_PipeOutputStreamPump::PLT_PipeOutputStreamPump(NPT_InputStreamReference& input,
+ NPT_Size size /* 65535 */,
+ NPT_Size max_bytes_to_read /* = 0 */) :
+ PLT_StreamPump(size),
+ m_Input(input),
+ m_MaxBytesToRead(max_bytes_to_read),
+ m_LastRes(NPT_SUCCESS)
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_PipeOutputStreamPump::~PLT_PipeOutputStreamPump
++---------------------------------------------------------------------*/
+PLT_PipeOutputStreamPump::~PLT_PipeOutputStreamPump()
+{
+}
+
+/*----------------------------------------------------------------------
+| PLT_PipeOutputStreamPump::Transmit
++---------------------------------------------------------------------*/
+NPT_Result
+PLT_PipeOutputStreamPump::Transmit(NPT_OutputStream& output)
+{
+ NPT_Size count;
+ NPT_Result res;
+
+ if ((m_LastRes == NPT_SUCCESS) || (m_LastRes == NPT_ERROR_WOULD_BLOCK)) {
+ // fill the entire space by default
+ NPT_Size max_space = m_RingBuffer->GetSpace();
+ if (max_space) {
+ NPT_Size max_to_read = max_space;
+ if (m_MaxBytesToRead != 0) {
+ // if a total maximum amount was set, make sure we don't read more
+ max_to_read = ((m_MaxBytesToRead - m_TotalBytesRead) < max_space) ? (m_MaxBytesToRead - m_TotalBytesRead) : max_space;
+ }
+
+ // any data to read
+ if (max_to_read) {
+ m_LastRes = PullData(*m_Input, max_to_read);
+ } else {
+ m_LastRes = NPT_ERROR_EOS;
+ }
+ }
+ } else if (!m_RingBuffer->GetAvailable()) {
+ // if the buffer is now empty, return the input last error
+ return m_LastRes;
+ }
+
+ // write as much as we can on the output stream
+ res = PushData(output, count);
+ return res;
+}
+
diff --git a/lib/libUPnP/Platinum/Source/Extras/PltStreamPump.h b/lib/libUPnP/Platinum/Source/Extras/PltStreamPump.h
new file mode 100644
index 0000000..f8fa719
--- /dev/null
+++ b/lib/libUPnP/Platinum/Source/Extras/PltStreamPump.h
@@ -0,0 +1,131 @@
+/*****************************************************************
+|
+| Platinum - Stream Pump
+|
+| Copyright (c) 2004-2010, Plutinosoft, LLC.
+| All rights reserved.
+| http://www.plutinosoft.com
+|
+| This program is free software; you can redistribute it and/or
+| modify it under the terms of the GNU General Public License
+| as published by the Free Software Foundation; either version 2
+| of the License, or (at your option) any later version.
+|
+| OEMs, ISVs, VARs and other distributors that combine and
+| distribute commercially licensed software with Platinum software
+| and do not wish to distribute the source code for the commercially
+| licensed software under version 2, or (at your option) any later
+| version, of the GNU General Public License (the "GPL") must enter
+| into a commercial license agreement with Plutinosoft, LLC.
+| licensing@plutinosoft.com
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; see the file LICENSE.txt. If not, write to
+| the Free Software Foundation, Inc.,
+| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+| http://www.gnu.org/licenses/gpl-2.0.html
+|
+****************************************************************/
+
+#ifndef _PLT_STREAM_PUMP_H_
+#define _PLT_STREAM_PUMP_H_
+
+/*----------------------------------------------------------------------
+| includes
++---------------------------------------------------------------------*/
+#include "Neptune.h"
+
+/*----------------------------------------------------------------------
+| PLT_PipeInputStream
++---------------------------------------------------------------------*/
+class PLT_PipeInputStream
+{
+public:
+ // constructor and destructor
+ virtual ~PLT_PipeInputStream() {};
+
+ // methods
+ virtual NPT_Result Receive(NPT_InputStream& stream, NPT_Size max_bytes_to_read, NPT_Size* bytes_read = 0) = 0;
+};
+
+typedef NPT_Reference<PLT_PipeInputStream> PLT_PipeInputStreamReference;
+
+/*----------------------------------------------------------------------
+| PLT_PipeOutputStream
++---------------------------------------------------------------------*/
+class PLT_PipeOutputStream
+{
+public:
+ // constructor and destructor
+ virtual ~PLT_PipeOutputStream() {};
+
+ // methods
+ virtual NPT_Result Transmit(NPT_OutputStream& stream) = 0;
+};
+
+typedef NPT_Reference<PLT_PipeOutputStream> PLT_PipeOutputStreamReference;
+
+/*----------------------------------------------------------------------
+| PLT_StreamPump class
++---------------------------------------------------------------------*/
+class PLT_StreamPump
+{
+public:
+ virtual ~PLT_StreamPump();
+
+protected:
+ // methods
+ PLT_StreamPump(NPT_Size size = 65535);
+ NPT_Result PullData(NPT_InputStream& input, NPT_Size max_bytes_to_read);
+ NPT_Result PushData(NPT_OutputStream& output, NPT_Size& bytes_written);
+
+ // members
+ NPT_RingBuffer* m_RingBuffer;
+ NPT_Offset m_TotalBytesRead;
+ NPT_Offset m_TotalBytesWritten;
+};
+
+/*----------------------------------------------------------------------
+| PLT_PipeInputStreamPump class
++---------------------------------------------------------------------*/
+class PLT_PipeInputStreamPump : public PLT_StreamPump,
+ public PLT_PipeInputStream
+{
+public:
+ PLT_PipeInputStreamPump(NPT_OutputStreamReference& output, NPT_Size size = 65535);
+ ~PLT_PipeInputStreamPump() override;
+
+ NPT_Result Receive(NPT_InputStream& input, NPT_Size max_bytes_to_read, NPT_Size* bytes_read) override;
+
+protected:
+ NPT_OutputStreamReference m_Output;
+ NPT_Result m_LastRes;
+};
+
+/*----------------------------------------------------------------------
+| PLT_PipeInputStreamPump class
++---------------------------------------------------------------------*/
+class PLT_PipeOutputStreamPump : public PLT_StreamPump,
+ public PLT_PipeOutputStream
+{
+public:
+ PLT_PipeOutputStreamPump(NPT_InputStreamReference& input,
+ NPT_Size size = 65535,
+ NPT_Size max_bytes_to_read = 0);
+ ~PLT_PipeOutputStreamPump() override;
+
+ NPT_Result Transmit(NPT_OutputStream& output) override;
+
+protected:
+ NPT_InputStreamReference m_Input;
+ NPT_Size m_MaxBytesToRead;
+ NPT_Result m_LastRes;
+};
+
+
+#endif // _PLT_STREAM_PUMP_H_