2 Copyright (C) 2020 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/>.
21 #include "dkdm_recipient.h"
22 #include "kdm_with_metadata.h"
24 #include <dcp/raw_convert.h>
25 #include <boost/foreach.hpp>
30 using boost::shared_ptr;
31 using dcp::raw_convert;
34 DKDMRecipient::DKDMRecipient (cxml::ConstNodePtr node)
37 BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Email")) {
38 emails.push_back (i->content());
41 utc_offset_hour = node->number_child<int>("UTCOffsetHour");
42 utc_offset_minute = node->number_child<int>("UTCOffsetMinute");
47 DKDMRecipient::as_xml (xmlpp::Element* node) const
49 KDMRecipient::as_xml (node);
51 BOOST_FOREACH (string i, emails) {
52 node->add_child("Email")->add_child_text(i);
55 node->add_child("UTCOffsetHour")->add_child_text(raw_convert<string>(utc_offset_hour));
56 node->add_child("UTCOffsetMinute")->add_child_text(raw_convert<string>(utc_offset_minute));
61 kdm_for_dkdm_recipient (
62 shared_ptr<const Film> film,
63 boost::filesystem::path cpl,
64 shared_ptr<DKDMRecipient> recipient,
65 boost::posix_time::ptime valid_from,
66 boost::posix_time::ptime valid_to
69 if (!recipient->recipient) {
70 return KDMWithMetadataPtr();
73 dcp::LocalTime const begin(valid_from, recipient->utc_offset_hour, recipient->utc_offset_minute);
74 dcp::LocalTime const end (valid_to, recipient->utc_offset_hour, recipient->utc_offset_minute);
76 dcp::EncryptedKDM const kdm = film->make_kdm (
77 recipient->recipient.get(),
82 dcp::MODIFIED_TRANSITIONAL_1,
87 dcp::NameFormat::Map name_values;
88 name_values['f'] = film->name();
89 name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
90 name_values['e'] = end.date() + " " + end.time_of_day(true, false);
91 name_values['i'] = kdm.cpl_id();
93 return KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, 0, recipient->emails, kdm));