2 Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
23 #include "dkdm_recipient.h"
25 #include "kdm_with_metadata.h"
26 #include <dcp/raw_convert.h>
29 using std::make_shared;
30 using std::shared_ptr;
33 using dcp::raw_convert;
36 DKDMRecipient::DKDMRecipient (cxml::ConstNodePtr node)
39 for (auto i: node->node_children("Email")) {
40 emails.push_back (i->content());
46 DKDMRecipient::as_xml (xmlpp::Element* node) const
48 KDMRecipient::as_xml (node);
50 for (auto i: emails) {
51 cxml::add_text_child(node, "Email", i);
57 kdm_for_dkdm_recipient (
58 shared_ptr<const Film> film,
59 boost::filesystem::path cpl,
60 shared_ptr<DKDMRecipient> recipient,
61 dcp::LocalTime valid_from,
62 dcp::LocalTime valid_to
65 if (!recipient->recipient) {
69 auto signer = Config::instance()->signer_chain();
70 if (!signer->valid()) {
71 throw InvalidSignerError();
74 auto const decrypted_kdm = film->make_kdm(cpl, valid_from, valid_to);
75 auto const kdm = decrypted_kdm.encrypt(signer, recipient->recipient.get(), {}, dcp::Formulation::MODIFIED_TRANSITIONAL_1, true, 0);
77 dcp::NameFormat::Map name_values;
78 name_values['f'] = kdm.content_title_text();
79 name_values['b'] = valid_from.date() + " " + valid_from.time_of_day(true, false);
80 name_values['e'] = valid_to.date() + " " + valid_to.time_of_day(true, false);
81 name_values['i'] = kdm.cpl_id();
83 return make_shared<KDMWithMetadata>(name_values, nullptr, recipient->emails, kdm);