From bfb8c684886592f325f85c490d9f0aafd7056734 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 4 Feb 2017 00:08:00 +0000 Subject: [PATCH] Missing files. --- src/lib/dkdm_wrapper.cc | 93 ++++++++++++++++++++++++++++++++ src/lib/dkdm_wrapper.h | 78 +++++++++++++++++++++++++++ src/wx/new_dkdm_folder_dialog.cc | 41 ++++++++++++++ src/wx/new_dkdm_folder_dialog.h | 33 ++++++++++++ 4 files changed, 245 insertions(+) create mode 100644 src/lib/dkdm_wrapper.cc create mode 100644 src/lib/dkdm_wrapper.h create mode 100644 src/wx/new_dkdm_folder_dialog.cc create mode 100644 src/wx/new_dkdm_folder_dialog.h diff --git a/src/lib/dkdm_wrapper.cc b/src/lib/dkdm_wrapper.cc new file mode 100644 index 000000000..316a0581e --- /dev/null +++ b/src/lib/dkdm_wrapper.cc @@ -0,0 +1,93 @@ +/* + Copyright (C) 2017 Carl Hetherington + + 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 . + +*/ + +#include "compose.hpp" +#include "dkdm_wrapper.h" +#include "dcpomatic_assert.h" +#include +#include + +using std::string; +using std::list; +using boost::shared_ptr; +using boost::dynamic_pointer_cast; + +shared_ptr +DKDMBase::read (cxml::ConstNodePtr node) +{ + if (node->name() == "DKDM") { + return shared_ptr (new DKDM (dcp::EncryptedKDM (node->content ()))); + } else if (node->name() == "DKDMGroup") { + shared_ptr group (new DKDMGroup (node->string_attribute ("Name"))); + BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children()) { + shared_ptr c = read (i); + if (c) { + group->add (c); + } + } + return group; + } + + return shared_ptr (); +} + +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 i, _children) { + i->as_xml (f); + } +} + +void +DKDMGroup::add (shared_ptr child) +{ + DCPOMATIC_ASSERT (child); + _children.push_back (child); +} + +void +DKDMGroup::remove (shared_ptr child) +{ + for (list >::iterator i = _children.begin(); i != _children.end(); ++i) { + if (*i == child) { + _children.erase (i); + return; + } + shared_ptr g = dynamic_pointer_cast (*i); + if (g) { + g->remove (child); + } + } +} diff --git a/src/lib/dkdm_wrapper.h b/src/lib/dkdm_wrapper.h new file mode 100644 index 000000000..b877722d9 --- /dev/null +++ b/src/lib/dkdm_wrapper.h @@ -0,0 +1,78 @@ +/* + Copyright (C) 2017 Carl Hetherington + + 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 . + +*/ + +#include +#include + +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 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 > children () const { + return _children; + } + + void add (boost::shared_ptr child); + void remove (boost::shared_ptr child); + +private: + std::string _name; + std::list > _children; +}; diff --git a/src/wx/new_dkdm_folder_dialog.cc b/src/wx/new_dkdm_folder_dialog.cc new file mode 100644 index 000000000..bf34ec3bf --- /dev/null +++ b/src/wx/new_dkdm_folder_dialog.cc @@ -0,0 +1,41 @@ +/* + Copyright (C) 2017 Carl Hetherington + + 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 . + +*/ + +#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 index 000000000..3f4a1503e --- /dev/null +++ b/src/wx/new_dkdm_folder_dialog.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2017 Carl Hetherington + + 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 . + +*/ + +#include "table_dialog.h" + +class NewDKDMFolderDialog : public TableDialog +{ +public: + NewDKDMFolderDialog (wxWindow* parent); + + void set (wxString n); + wxString get () const; + +private: + wxTextCtrl* _name; +}; -- 2.30.2