Missing files.
authorCarl Hetherington <cth@carlh.net>
Sat, 4 Feb 2017 00:08:00 +0000 (00:08 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 24 May 2017 11:23:59 +0000 (12:23 +0100)
src/lib/dkdm_wrapper.cc [new file with mode: 0644]
src/lib/dkdm_wrapper.h [new file with mode: 0644]
src/wx/new_dkdm_folder_dialog.cc [new file with mode: 0644]
src/wx/new_dkdm_folder_dialog.h [new file with mode: 0644]

diff --git a/src/lib/dkdm_wrapper.cc b/src/lib/dkdm_wrapper.cc
new file mode 100644 (file)
index 0000000..316a058
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+    Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "compose.hpp"
+#include "dkdm_wrapper.h"
+#include "dcpomatic_assert.h"
+#include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
+
+using std::string;
+using std::list;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+
+shared_ptr<DKDMBase>
+DKDMBase::read (cxml::ConstNodePtr node)
+{
+       if (node->name() == "DKDM") {
+               return shared_ptr<DKDM> (new DKDM (dcp::EncryptedKDM (node->content ())));
+       } else if (node->name() == "DKDMGroup") {
+               shared_ptr<DKDMGroup> group (new DKDMGroup (node->string_attribute ("Name")));
+               BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children()) {
+                       shared_ptr<DKDMBase> c = read (i);
+                       if (c) {
+                               group->add (c);
+                       }
+               }
+               return group;
+       }
+
+       return shared_ptr<DKDMBase> ();
+}
+
+string
+DKDM::name () const
+{
+       return String::compose ("%1 (%2)", _dkdm.content_title_text(), _dkdm.cpl_id());
+}
+
+void
+DKDM::as_xml (xmlpp::Element* node) const
+{
+       node->add_child("DKDM")->add_child_text (_dkdm.as_xml ());
+}
+
+void
+DKDMGroup::as_xml (xmlpp::Element* node) const
+{
+       xmlpp::Element* f = node->add_child("DKDMGroup");
+       f->set_attribute ("Name", _name);
+       BOOST_FOREACH (shared_ptr<DKDMBase> i, _children) {
+               i->as_xml (f);
+       }
+}
+
+void
+DKDMGroup::add (shared_ptr<DKDMBase> child)
+{
+       DCPOMATIC_ASSERT (child);
+       _children.push_back (child);
+}
+
+void
+DKDMGroup::remove (shared_ptr<DKDMBase> child)
+{
+       for (list<shared_ptr<DKDMBase> >::iterator i = _children.begin(); i != _children.end(); ++i) {
+               if (*i == child) {
+                       _children.erase (i);
+                       return;
+               }
+               shared_ptr<DKDMGroup> g = dynamic_pointer_cast<DKDMGroup> (*i);
+               if (g) {
+                       g->remove (child);
+               }
+       }
+}
diff --git a/src/lib/dkdm_wrapper.h b/src/lib/dkdm_wrapper.h
new file mode 100644 (file)
index 0000000..b877722
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+    Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include <dcp/encrypted_kdm.h>
+#include <libcxml/cxml.h>
+
+namespace xmlpp {
+       class Element;
+}
+
+class DKDMBase
+{
+public:
+       virtual std::string name () const = 0;
+       virtual void as_xml (xmlpp::Element *) const = 0;
+
+       static boost::shared_ptr<DKDMBase> read (cxml::ConstNodePtr node);
+};
+
+class DKDM : public DKDMBase
+{
+public:
+       DKDM (dcp::EncryptedKDM k)
+               : _dkdm (k)
+       {}
+
+       std::string name () const;
+       void as_xml (xmlpp::Element *) const;
+
+       dcp::EncryptedKDM dkdm () const {
+               return _dkdm;
+       }
+
+private:
+       dcp::EncryptedKDM _dkdm;
+};
+
+class DKDMGroup : public DKDMBase
+{
+public:
+       DKDMGroup (std::string name)
+               : _name (name)
+       {}
+
+       std::string name () const {
+               return _name;
+       }
+
+       void as_xml (xmlpp::Element *) const;
+
+       std::list<boost::shared_ptr<DKDMBase> > children () const {
+               return _children;
+       }
+
+       void add (boost::shared_ptr<DKDMBase> child);
+        void remove (boost::shared_ptr<DKDMBase> child);
+
+private:
+       std::string _name;
+       std::list<boost::shared_ptr<DKDMBase> > _children;
+};
diff --git a/src/wx/new_dkdm_folder_dialog.cc b/src/wx/new_dkdm_folder_dialog.cc
new file mode 100644 (file)
index 0000000..bf34ec3
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+    Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "new_dkdm_folder_dialog.h"
+
+NewDKDMFolderDialog::NewDKDMFolderDialog (wxWindow* parent)
+       : TableDialog (parent, _("Add DKDM folder"), 2, 1, true)
+{
+       add (_("Folder name"), true);
+       _name = add (new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (300, -1)));
+       layout ();
+}
+
+wxString
+NewDKDMFolderDialog::get () const
+{
+       return _name->GetValue ();
+}
+
+void
+NewDKDMFolderDialog::set (wxString s)
+{
+       _name->SetValue (s);
+}
diff --git a/src/wx/new_dkdm_folder_dialog.h b/src/wx/new_dkdm_folder_dialog.h
new file mode 100644 (file)
index 0000000..3f4a150
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+    Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic 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.
+
+    DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "table_dialog.h"
+
+class NewDKDMFolderDialog : public TableDialog
+{
+public:
+       NewDKDMFolderDialog (wxWindow* parent);
+
+       void set (wxString n);
+       wxString get () const;
+
+private:
+       wxTextCtrl* _name;
+};