X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdkdm_recipient.cc;h=c73379bed9cded1f3963fad8a62bf32bf67b4095;hb=refs%2Fheads%2F2493-player-export-frame;hp=f03a1597b8bfd093aa5abe08eb6bb3877097d981;hpb=3e96f929fdf740f414b114c5d9765e22fcc46de6;p=dcpomatic.git diff --git a/src/lib/dkdm_recipient.cc b/src/lib/dkdm_recipient.cc index f03a1597b..c73379bed 100644 --- a/src/lib/dkdm_recipient.cc +++ b/src/lib/dkdm_recipient.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,23 +18,26 @@ */ + +#include "config.h" #include "dkdm_recipient.h" -#include "kdm_with_metadata.h" #include "film.h" +#include "kdm_with_metadata.h" #include -#include +#include +using std::make_shared; +using std::shared_ptr; using std::string; using std::vector; -using boost::shared_ptr; using dcp::raw_convert; DKDMRecipient::DKDMRecipient (cxml::ConstNodePtr node) : KDMRecipient (node) { - BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Email")) { + for (auto i: node->node_children("Email")) { emails.push_back (i->content()); } @@ -48,7 +51,7 @@ DKDMRecipient::as_xml (xmlpp::Element* node) const { KDMRecipient::as_xml (node); - BOOST_FOREACH (string i, emails) { + for (auto i: emails) { node->add_child("Email")->add_child_text(i); } @@ -67,29 +70,26 @@ kdm_for_dkdm_recipient ( ) { if (!recipient->recipient) { - return KDMWithMetadataPtr(); + return {}; } - dcp::LocalTime const begin(valid_from, recipient->utc_offset_hour, recipient->utc_offset_minute); - dcp::LocalTime const end (valid_to, recipient->utc_offset_hour, recipient->utc_offset_minute); + dcp::LocalTime const begin(valid_from, dcp::UTCOffset(recipient->utc_offset_hour, recipient->utc_offset_minute)); + dcp::LocalTime const end (valid_to, dcp::UTCOffset(recipient->utc_offset_hour, recipient->utc_offset_minute)); + + auto signer = Config::instance()->signer_chain(); + if (!signer->valid()) { + throw InvalidSignerError(); + } - dcp::EncryptedKDM const kdm = film->make_kdm ( - recipient->recipient.get(), - vector(), - cpl, - begin, - end, - dcp::MODIFIED_TRANSITIONAL_1, - true, - 0 - ); + auto const decrypted_kdm = film->make_kdm(cpl, begin, end); + auto const kdm = decrypted_kdm.encrypt(signer, recipient->recipient.get(), {}, dcp::Formulation::MODIFIED_TRANSITIONAL_1, true, 0); dcp::NameFormat::Map name_values; - name_values['f'] = film->name(); + name_values['f'] = kdm.content_title_text(); name_values['b'] = begin.date() + " " + begin.time_of_day(true, false); name_values['e'] = end.date() + " " + end.time_of_day(true, false); name_values['i'] = kdm.cpl_id(); - return KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, 0, recipient->emails, kdm)); + return make_shared(name_values, nullptr, recipient->emails, kdm); }