From 08f96200aacf9f91ef3e3f5b80224a5b2437f279 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 1 May 2020 22:53:01 +0200 Subject: Move Film::make_kdms to the call sites. --- src/tools/dcpomatic_kdm_cli.cc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index 166b22285..505a70c2b 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -229,11 +229,26 @@ from_film ( values['e'] = dcp::LocalTime(valid_to).date() + " " + dcp::LocalTime(valid_to).time_of_day(true, false); try { - list > screen_kdms = film->make_kdms ( - screens, cpl, valid_from, valid_to, formulation, disable_forensic_marking_picture, disable_forensic_marking_audio - ); + list > kdms; - write_files (screen_kdms, zip, output, container_name_format, filename_format, values, verbose); + BOOST_FOREACH (shared_ptr i, screens) { + if (i->recipient) { + dcp::EncryptedKDM const kdm = film->make_kdm ( + i->recipient.get(), + i->trusted_device_thumbprints(), + cpl, + dcp::LocalTime(valid_from, i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0), + dcp::LocalTime(valid_to, i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0), + formulation, + disable_forensic_marking_picture, + disable_forensic_marking_audio + ); + + kdms.push_back (shared_ptr(new DCPScreenKDM(i, kdm))); + } + } + + write_files (kdms, zip, output, container_name_format, filename_format, values, verbose); } catch (FileError& e) { cerr << program_name << ": " << e.what() << " (" << e.file().string() << ")\n"; exit (EXIT_FAILURE); -- cgit v1.2.3 From 36ce958a516567d8481163692c028a88c6ce0df7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 4 May 2020 22:53:08 +0200 Subject: Rename ScreenKDM -> KDMWithMetadata --- src/lib/cinema_kdms.cc | 16 +++---- src/lib/cinema_kdms.h | 6 +-- src/lib/film.cc | 2 +- src/lib/kdm_with_metadata.cc | 70 +++++++++++++++++++++++++++ src/lib/kdm_with_metadata.h | 106 +++++++++++++++++++++++++++++++++++++++++ src/lib/screen_kdm.cc | 70 --------------------------- src/lib/screen_kdm.h | 106 ----------------------------------------- src/lib/wscript | 2 +- src/tools/dcpomatic.cc | 2 +- src/tools/dcpomatic_kdm.cc | 12 ++--- src/tools/dcpomatic_kdm_cli.cc | 16 +++---- src/wx/kdm_dialog.cc | 6 +-- src/wx/kdm_output_panel.cc | 4 +- src/wx/kdm_output_panel.h | 4 +- 14 files changed, 211 insertions(+), 211 deletions(-) create mode 100644 src/lib/kdm_with_metadata.cc create mode 100644 src/lib/kdm_with_metadata.h delete mode 100644 src/lib/screen_kdm.cc delete mode 100644 src/lib/screen_kdm.h (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index 3af1e0d84..99d151152 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -47,7 +47,7 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam name_values['c'] = cinema->name; - BOOST_FOREACH (shared_ptr i, screen_kdms) { + BOOST_FOREACH (shared_ptr i, screen_kdms) { name_values['s'] = i->screen->name; name_values['i'] = i->kdm_id (); string const name = careful_string_filter(name_format.get(name_values, ".xml")); @@ -57,11 +57,11 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam zipper.close (); } -/** Collect a list of ScreenKDMs into a list of CinemaKDMs so that each +/** Collect a list of KDMWithMetadatas into a list of CinemaKDMs so that each * CinemaKDM contains the KDMs for its cinema. */ list -CinemaKDMs::collect (list > screen_kdms) +CinemaKDMs::collect (list > screen_kdms) { list cinema_kdms; @@ -71,17 +71,17 @@ CinemaKDMs::collect (list > screen_kdms) CinemaKDMs ck; - list >::iterator i = screen_kdms.begin (); + list >::iterator i = screen_kdms.begin (); ck.cinema = (*i)->screen->cinema; ck.screen_kdms.push_back (*i); - list >::iterator j = i; + list >::iterator j = i; ++i; screen_kdms.remove (*j); while (i != screen_kdms.end ()) { if ((*i)->screen->cinema == ck.cinema) { ck.screen_kdms.push_back (*i); - list >::iterator j = i; + list >::iterator j = i; ++i; screen_kdms.remove (*j); } else { @@ -117,7 +117,7 @@ CinemaKDMs::write_directories ( path /= container_name_format.get(name_values, ""); if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { boost::filesystem::create_directories (path); - ScreenKDM::write_files (i.screen_kdms, path, filename_format, name_values, confirm_overwrite); + KDMWithMetadata::write_files (i.screen_kdms, path, filename_format, name_values, confirm_overwrite); } written += i.screen_kdms.size(); } @@ -209,7 +209,7 @@ CinemaKDMs::email ( boost::algorithm::replace_all (body, "$CINEMA_NAME", i.cinema->name); string screens; - BOOST_FOREACH (shared_ptr j, i.screen_kdms) { + BOOST_FOREACH (shared_ptr j, i.screen_kdms) { screens += j->screen->name + ", "; } boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2)); diff --git a/src/lib/cinema_kdms.h b/src/lib/cinema_kdms.h index 2b82cdab6..0626ded5d 100644 --- a/src/lib/cinema_kdms.h +++ b/src/lib/cinema_kdms.h @@ -18,7 +18,7 @@ */ -#include "screen_kdm.h" +#include "kdm_with_metadata.h" class Cinema; class Job; @@ -29,7 +29,7 @@ class CinemaKDMs public: void make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const; - static std::list collect (std::list > kdms); + static std::list collect (std::list > kdms); static int write_directories ( std::list cinema_kdms, @@ -58,5 +58,5 @@ public: ); boost::shared_ptr cinema; - std::list > screen_kdms; + std::list > screen_kdms; }; diff --git a/src/lib/film.cc b/src/lib/film.cc index cbbdf5964..b233e5ee6 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -50,7 +50,7 @@ #include "text_content.h" #include "ffmpeg_content.h" #include "dcp_content.h" -#include "screen_kdm.h" +#include "kdm_with_metadata.h" #include "cinema.h" #include "change_signaller.h" #include "check_content_change_job.h" diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc new file mode 100644 index 000000000..e6b283415 --- /dev/null +++ b/src/lib/kdm_with_metadata.cc @@ -0,0 +1,70 @@ +/* + Copyright (C) 2013-2016 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 "kdm_with_metadata.h" +#include "cinema.h" +#include "screen.h" +#include "util.h" +#include + +using std::string; +using std::cout; +using std::list; +using boost::shared_ptr; + +int +KDMWithMetadata::write_files ( + list > screen_kdms, + boost::filesystem::path directory, + dcp::NameFormat name_format, + dcp::NameFormat::Map name_values, + boost::function confirm_overwrite + ) +{ + int written = 0; + + if (directory == "-") { + /* Write KDMs to the stdout */ + BOOST_FOREACH (shared_ptr i, screen_kdms) { + cout << i->kdm_as_xml (); + ++written; + } + + return written; + } + + if (!boost::filesystem::exists (directory)) { + boost::filesystem::create_directories (directory); + } + + /* Write KDMs to the specified directory */ + BOOST_FOREACH (shared_ptr i, screen_kdms) { + name_values['c'] = i->screen->cinema ? i->screen->cinema->name : ""; + name_values['s'] = i->screen->name; + name_values['i'] = i->kdm_id (); + boost::filesystem::path out = directory / careful_string_filter(name_format.get(name_values, ".xml")); + if (!boost::filesystem::exists (out) || confirm_overwrite (out)) { + i->kdm_as_xml (out); + ++written; + } + } + + return written; +} diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h new file mode 100644 index 000000000..8d6d61daa --- /dev/null +++ b/src/lib/kdm_with_metadata.h @@ -0,0 +1,106 @@ +/* + Copyright (C) 2013-2019 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 . + +*/ + +#ifndef DCPOMATIC_KDM_WITH_METADATA_H +#define DCPOMATIC_KDM_WITH_METADATA_H + +#ifdef DCPOMATIC_VARIANT_SWAROOP +#include "encrypted_ecinema_kdm.h" +#endif +#include +#include +#include + +namespace dcpomatic { + class Screen; +} + +/** Simple class to collect a screen and an encrypted KDM */ +class KDMWithMetadata +{ +public: + KDMWithMetadata (boost::shared_ptr s) + : screen (s) + {} + + virtual ~KDMWithMetadata () {} + + virtual std::string kdm_as_xml () const = 0; + virtual void kdm_as_xml (boost::filesystem::path out) const = 0; + virtual std::string kdm_id () const = 0; + + static int write_files ( + std::list > screen_kdms, boost::filesystem::path directory, + dcp::NameFormat name_format, dcp::NameFormat::Map name_values, + boost::function confirm_overwrite + ); + + boost::shared_ptr screen; +}; + +class DCPKDMWithMetadata : public KDMWithMetadata +{ +public: + DCPKDMWithMetadata (boost::shared_ptr s, dcp::EncryptedKDM k) + : KDMWithMetadata (s) + , kdm (k) + {} + + std::string kdm_as_xml () const { + return kdm.as_xml (); + } + + void kdm_as_xml (boost::filesystem::path out) const { + return kdm.as_xml (out); + } + + std::string kdm_id () const { + return kdm.cpl_id (); + } + + dcp::EncryptedKDM kdm; +}; + +#ifdef DCPOMATIC_VARIANT_SWAROOP +class ECinemaKDMWithMetadata : public KDMWithMetadata +{ +public: + ECinemaKDMWithMetadata (boost::shared_ptr s, EncryptedECinemaKDM k) + : KDMWithMetadata (s) + , kdm (k) + {} + + std::string kdm_as_xml () const { + return kdm.as_xml (); + } + + void kdm_as_xml (boost::filesystem::path out) const { + return kdm.as_xml (out); + } + + std::string kdm_id () const { + return kdm.id (); + } + + EncryptedECinemaKDM kdm; +}; +#endif + +#endif diff --git a/src/lib/screen_kdm.cc b/src/lib/screen_kdm.cc deleted file mode 100644 index f9a3fa36e..000000000 --- a/src/lib/screen_kdm.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2013-2016 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 "screen_kdm.h" -#include "cinema.h" -#include "screen.h" -#include "util.h" -#include - -using std::string; -using std::cout; -using std::list; -using boost::shared_ptr; - -int -ScreenKDM::write_files ( - list > screen_kdms, - boost::filesystem::path directory, - dcp::NameFormat name_format, - dcp::NameFormat::Map name_values, - boost::function confirm_overwrite - ) -{ - int written = 0; - - if (directory == "-") { - /* Write KDMs to the stdout */ - BOOST_FOREACH (shared_ptr i, screen_kdms) { - cout << i->kdm_as_xml (); - ++written; - } - - return written; - } - - if (!boost::filesystem::exists (directory)) { - boost::filesystem::create_directories (directory); - } - - /* Write KDMs to the specified directory */ - BOOST_FOREACH (shared_ptr i, screen_kdms) { - name_values['c'] = i->screen->cinema ? i->screen->cinema->name : ""; - name_values['s'] = i->screen->name; - name_values['i'] = i->kdm_id (); - boost::filesystem::path out = directory / careful_string_filter(name_format.get(name_values, ".xml")); - if (!boost::filesystem::exists (out) || confirm_overwrite (out)) { - i->kdm_as_xml (out); - ++written; - } - } - - return written; -} diff --git a/src/lib/screen_kdm.h b/src/lib/screen_kdm.h deleted file mode 100644 index a1e36245c..000000000 --- a/src/lib/screen_kdm.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (C) 2013-2019 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 . - -*/ - -#ifndef DCPOMATIC_SCREEN_KDM_H -#define DCPOMATIC_SCREEN_KDM_H - -#ifdef DCPOMATIC_VARIANT_SWAROOP -#include "encrypted_ecinema_kdm.h" -#endif -#include -#include -#include - -namespace dcpomatic { - class Screen; -} - -/** Simple class to collect a screen and an encrypted KDM */ -class ScreenKDM -{ -public: - ScreenKDM (boost::shared_ptr s) - : screen (s) - {} - - virtual ~ScreenKDM () {} - - virtual std::string kdm_as_xml () const = 0; - virtual void kdm_as_xml (boost::filesystem::path out) const = 0; - virtual std::string kdm_id () const = 0; - - static int write_files ( - std::list > screen_kdms, boost::filesystem::path directory, - dcp::NameFormat name_format, dcp::NameFormat::Map name_values, - boost::function confirm_overwrite - ); - - boost::shared_ptr screen; -}; - -class DCPScreenKDM : public ScreenKDM -{ -public: - DCPScreenKDM (boost::shared_ptr s, dcp::EncryptedKDM k) - : ScreenKDM (s) - , kdm (k) - {} - - std::string kdm_as_xml () const { - return kdm.as_xml (); - } - - void kdm_as_xml (boost::filesystem::path out) const { - return kdm.as_xml (out); - } - - std::string kdm_id () const { - return kdm.cpl_id (); - } - - dcp::EncryptedKDM kdm; -}; - -#ifdef DCPOMATIC_VARIANT_SWAROOP -class ECinemaScreenKDM : public ScreenKDM -{ -public: - ECinemaScreenKDM (boost::shared_ptr s, EncryptedECinemaKDM k) - : ScreenKDM (s) - , kdm (k) - {} - - std::string kdm_as_xml () const { - return kdm.as_xml (); - } - - void kdm_as_xml (boost::filesystem::path out) const { - return kdm.as_xml (out); - } - - std::string kdm_id () const { - return kdm.id (); - } - - EncryptedECinemaKDM kdm; -}; -#endif - -#endif diff --git a/src/lib/wscript b/src/lib/wscript index ea52079d0..19d68f045 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -125,6 +125,7 @@ sources = """ job_manager.cc j2k_encoder.cc json_server.cc + kdm_with_metadata.cc lock_file_checker.cc log.cc log_entry.cc @@ -145,7 +146,6 @@ sources = """ scoped_temporary.cc scp_uploader.cc screen.cc - screen_kdm.cc send_kdm_email_job.cc send_notification_email_job.cc send_problem_report_job.cc diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index aea058d80..5976de22a 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -65,7 +65,7 @@ #include "lib/job_manager.h" #include "lib/exceptions.h" #include "lib/cinema.h" -#include "lib/screen_kdm.h" +#include "lib/kdm_with_metadata.h" #include "lib/send_kdm_email_job.h" #include "lib/encode_server_finder.h" #include "lib/update_checker.h" diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index ef6b783f4..1ff69d135 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -38,7 +38,7 @@ #include "lib/util.h" #include "lib/screen.h" #include "lib/job_manager.h" -#include "lib/screen_kdm.h" +#include "lib/kdm_with_metadata.h" #include "lib/exceptions.h" #include "lib/cinema_kdms.h" #include "lib/send_kdm_email_job.h" @@ -303,7 +303,7 @@ private: return; } - list > screen_kdms; + list > screen_kdms; string title; #ifdef DCPOMATIC_VARIANT_SWAROOP @@ -328,8 +328,8 @@ private: /* Encrypt */ screen_kdms.push_back ( - shared_ptr( - new ECinemaScreenKDM(i, kdm.encrypt(i->recipient.get())) + shared_ptr( + new ECinemaKDMWithMetadata(i, kdm.encrypt(i->recipient.get())) ) ); } @@ -371,8 +371,8 @@ private: /* Encrypt */ screen_kdms.push_back ( - shared_ptr( - new DCPScreenKDM( + shared_ptr( + new DCPKDMWithMetadata( i, kdm.encrypt( signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(), diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index 505a70c2b..1aad31cb5 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -24,7 +24,7 @@ #include "lib/film.h" #include "lib/cinema.h" -#include "lib/screen_kdm.h" +#include "lib/kdm_with_metadata.h" #include "lib/cinema_kdms.h" #include "lib/config.h" #include "lib/exceptions.h" @@ -130,7 +130,7 @@ always_overwrite () void write_files ( - list > screen_kdms, + list > screen_kdms, bool zip, boost::filesystem::path output, dcp::NameFormat container_name_format, @@ -153,7 +153,7 @@ write_files ( cout << "Wrote " << N << " ZIP files to " << output << "\n"; } } else { - int const N = ScreenKDM::write_files ( + int const N = KDMWithMetadata::write_files ( screen_kdms, output, filename_format, values, bind (&always_overwrite) ); @@ -229,7 +229,7 @@ from_film ( values['e'] = dcp::LocalTime(valid_to).date() + " " + dcp::LocalTime(valid_to).time_of_day(true, false); try { - list > kdms; + list > kdms; BOOST_FOREACH (shared_ptr i, screens) { if (i->recipient) { @@ -244,7 +244,7 @@ from_film ( disable_forensic_marking_audio ); - kdms.push_back (shared_ptr(new DCPScreenKDM(i, kdm))); + kdms.push_back (shared_ptr(new DCPKDMWithMetadata(i, kdm))); } } @@ -345,15 +345,15 @@ from_dkdm ( values['e'] = dcp::LocalTime(valid_to).date() + " " + dcp::LocalTime(valid_to).time_of_day(true, false); try { - list > screen_kdms; + list > screen_kdms; BOOST_FOREACH (shared_ptr i, screens) { if (!i->recipient) { continue; } screen_kdms.push_back ( - shared_ptr( - new DCPScreenKDM( + shared_ptr( + new DCPKDMWithMetadata( i, kdm_from_dkdm( dkdm, diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index 59d961e6c..06600ac7a 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -29,7 +29,7 @@ #include "dcpomatic_button.h" #include "lib/film.h" #include "lib/screen.h" -#include "lib/screen_kdm.h" +#include "lib/kdm_with_metadata.h" #include "lib/job_manager.h" #include "lib/cinema_kdms.h" #include "lib/config.h" @@ -150,7 +150,7 @@ KDMDialog::make_clicked () shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - list > screen_kdms; + list > screen_kdms; try { /* Start off by enabling forensic marking for all */ optional for_audio; @@ -175,7 +175,7 @@ KDMDialog::make_clicked () for_audio ); - screen_kdms.push_back (shared_ptr(new DCPScreenKDM(i, kdm))); + screen_kdms.push_back (shared_ptr(new DCPKDMWithMetadata(i, kdm))); } } diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index d76a27359..0320ed1b7 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -183,7 +183,7 @@ KDMOutputPanel::kdm_write_type_changed () pair, int> KDMOutputPanel::make ( - list > screen_kdms, string name, KDMTimingPanel* timing, function confirm_overwrite + list > screen_kdms, string name, KDMTimingPanel* timing, function confirm_overwrite ) { list const cinema_kdms = CinemaKDMs::collect (screen_kdms); @@ -247,7 +247,7 @@ KDMOutputPanel::make ( if (_write_to->GetValue()) { if (_write_flat->GetValue()) { - written = ScreenKDM::write_files ( + written = KDMWithMetadata::write_files ( screen_kdms, directory(), _filename_format->get(), diff --git a/src/wx/kdm_output_panel.h b/src/wx/kdm_output_panel.h index 7b9315071..730cb9360 100644 --- a/src/wx/kdm_output_panel.h +++ b/src/wx/kdm_output_panel.h @@ -18,7 +18,7 @@ */ -#include "lib/screen_kdm.h" +#include "lib/kdm_with_metadata.h" #include "wx_util.h" #include "name_format_editor.h" #include @@ -52,7 +52,7 @@ public: } std::pair, int> make ( - std::list > screen_kdms, + std::list > screen_kdms, std::string name, KDMTimingPanel* timing, boost::function confirm_overwrite -- cgit v1.2.3 From ca56871d4860b8ead384c410fe374c2fa993f88f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 4 May 2020 23:02:45 +0200 Subject: Add KDMWithMetadataPtr typedef --- src/lib/cinema_kdms.cc | 14 +++++++------- src/lib/cinema_kdms.h | 4 ++-- src/lib/kdm_with_metadata.cc | 8 ++++---- src/lib/kdm_with_metadata.h | 17 +++++++++++------ src/tools/dcpomatic_kdm.cc | 6 +++--- src/tools/dcpomatic_kdm_cli.cc | 12 ++++++------ src/wx/kdm_dialog.cc | 4 ++-- src/wx/kdm_output_panel.cc | 4 ++-- src/wx/kdm_output_panel.h | 2 +- 9 files changed, 38 insertions(+), 33 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index 99d151152..61234ff3f 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -47,7 +47,7 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam name_values['c'] = cinema->name; - BOOST_FOREACH (shared_ptr i, screen_kdms) { + BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) { name_values['s'] = i->screen->name; name_values['i'] = i->kdm_id (); string const name = careful_string_filter(name_format.get(name_values, ".xml")); @@ -61,7 +61,7 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam * CinemaKDM contains the KDMs for its cinema. */ list -CinemaKDMs::collect (list > screen_kdms) +CinemaKDMs::collect (list screen_kdms) { list cinema_kdms; @@ -71,17 +71,17 @@ CinemaKDMs::collect (list > screen_kdms) CinemaKDMs ck; - list >::iterator i = screen_kdms.begin (); + list::iterator i = screen_kdms.begin (); ck.cinema = (*i)->screen->cinema; ck.screen_kdms.push_back (*i); - list >::iterator j = i; + list::iterator j = i; ++i; screen_kdms.remove (*j); while (i != screen_kdms.end ()) { if ((*i)->screen->cinema == ck.cinema) { ck.screen_kdms.push_back (*i); - list >::iterator j = i; + list::iterator j = i; ++i; screen_kdms.remove (*j); } else { @@ -117,7 +117,7 @@ CinemaKDMs::write_directories ( path /= container_name_format.get(name_values, ""); if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { boost::filesystem::create_directories (path); - KDMWithMetadata::write_files (i.screen_kdms, path, filename_format, name_values, confirm_overwrite); + write_files (i.screen_kdms, path, filename_format, name_values, confirm_overwrite); } written += i.screen_kdms.size(); } @@ -209,7 +209,7 @@ CinemaKDMs::email ( boost::algorithm::replace_all (body, "$CINEMA_NAME", i.cinema->name); string screens; - BOOST_FOREACH (shared_ptr j, i.screen_kdms) { + BOOST_FOREACH (KDMWithMetadataPtr j, i.screen_kdms) { screens += j->screen->name + ", "; } boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2)); diff --git a/src/lib/cinema_kdms.h b/src/lib/cinema_kdms.h index 0626ded5d..918670397 100644 --- a/src/lib/cinema_kdms.h +++ b/src/lib/cinema_kdms.h @@ -29,7 +29,7 @@ class CinemaKDMs public: void make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const; - static std::list collect (std::list > kdms); + static std::list collect (std::list kdms); static int write_directories ( std::list cinema_kdms, @@ -58,5 +58,5 @@ public: ); boost::shared_ptr cinema; - std::list > screen_kdms; + std::list screen_kdms; }; diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index e6b283415..674554f7e 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -30,8 +30,8 @@ using std::list; using boost::shared_ptr; int -KDMWithMetadata::write_files ( - list > screen_kdms, +write_files ( + list screen_kdms, boost::filesystem::path directory, dcp::NameFormat name_format, dcp::NameFormat::Map name_values, @@ -42,7 +42,7 @@ KDMWithMetadata::write_files ( if (directory == "-") { /* Write KDMs to the stdout */ - BOOST_FOREACH (shared_ptr i, screen_kdms) { + BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) { cout << i->kdm_as_xml (); ++written; } @@ -55,7 +55,7 @@ KDMWithMetadata::write_files ( } /* Write KDMs to the specified directory */ - BOOST_FOREACH (shared_ptr i, screen_kdms) { + BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) { name_values['c'] = i->screen->cinema ? i->screen->cinema->name : ""; name_values['s'] = i->screen->name; name_values['i'] = i->kdm_id (); diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index 8d6d61daa..19af0356f 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -46,15 +46,20 @@ public: virtual void kdm_as_xml (boost::filesystem::path out) const = 0; virtual std::string kdm_id () const = 0; - static int write_files ( - std::list > screen_kdms, boost::filesystem::path directory, - dcp::NameFormat name_format, dcp::NameFormat::Map name_values, - boost::function confirm_overwrite - ); - boost::shared_ptr screen; }; + +typedef boost::shared_ptr KDMWithMetadataPtr; + + +int write_files ( + std::list screen_kdms, boost::filesystem::path directory, + dcp::NameFormat name_format, dcp::NameFormat::Map name_values, + boost::function confirm_overwrite + ); + + class DCPKDMWithMetadata : public KDMWithMetadata { public: diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 1ff69d135..efc09c818 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -303,7 +303,7 @@ private: return; } - list > screen_kdms; + list screen_kdms; string title; #ifdef DCPOMATIC_VARIANT_SWAROOP @@ -328,7 +328,7 @@ private: /* Encrypt */ screen_kdms.push_back ( - shared_ptr( + KDMWithMetadataPtr( new ECinemaKDMWithMetadata(i, kdm.encrypt(i->recipient.get())) ) ); @@ -371,7 +371,7 @@ private: /* Encrypt */ screen_kdms.push_back ( - shared_ptr( + KDMWithMetadataPtr( new DCPKDMWithMetadata( i, kdm.encrypt( diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index 1aad31cb5..a1003eceb 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -130,7 +130,7 @@ always_overwrite () void write_files ( - list > screen_kdms, + list screen_kdms, bool zip, boost::filesystem::path output, dcp::NameFormat container_name_format, @@ -153,7 +153,7 @@ write_files ( cout << "Wrote " << N << " ZIP files to " << output << "\n"; } } else { - int const N = KDMWithMetadata::write_files ( + int const N = write_files ( screen_kdms, output, filename_format, values, bind (&always_overwrite) ); @@ -229,7 +229,7 @@ from_film ( values['e'] = dcp::LocalTime(valid_to).date() + " " + dcp::LocalTime(valid_to).time_of_day(true, false); try { - list > kdms; + list kdms; BOOST_FOREACH (shared_ptr i, screens) { if (i->recipient) { @@ -244,7 +244,7 @@ from_film ( disable_forensic_marking_audio ); - kdms.push_back (shared_ptr(new DCPKDMWithMetadata(i, kdm))); + kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(i, kdm))); } } @@ -345,14 +345,14 @@ from_dkdm ( values['e'] = dcp::LocalTime(valid_to).date() + " " + dcp::LocalTime(valid_to).time_of_day(true, false); try { - list > screen_kdms; + list screen_kdms; BOOST_FOREACH (shared_ptr i, screens) { if (!i->recipient) { continue; } screen_kdms.push_back ( - shared_ptr( + KDMWithMetadataPtr( new DCPKDMWithMetadata( i, kdm_from_dkdm( diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index 06600ac7a..b067ff04a 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -150,7 +150,7 @@ KDMDialog::make_clicked () shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - list > screen_kdms; + list screen_kdms; try { /* Start off by enabling forensic marking for all */ optional for_audio; @@ -175,7 +175,7 @@ KDMDialog::make_clicked () for_audio ); - screen_kdms.push_back (shared_ptr(new DCPKDMWithMetadata(i, kdm))); + screen_kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(i, kdm))); } } diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index 0320ed1b7..541674ae1 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -183,7 +183,7 @@ KDMOutputPanel::kdm_write_type_changed () pair, int> KDMOutputPanel::make ( - list > screen_kdms, string name, KDMTimingPanel* timing, function confirm_overwrite + list screen_kdms, string name, KDMTimingPanel* timing, function confirm_overwrite ) { list const cinema_kdms = CinemaKDMs::collect (screen_kdms); @@ -247,7 +247,7 @@ KDMOutputPanel::make ( if (_write_to->GetValue()) { if (_write_flat->GetValue()) { - written = KDMWithMetadata::write_files ( + written = write_files ( screen_kdms, directory(), _filename_format->get(), diff --git a/src/wx/kdm_output_panel.h b/src/wx/kdm_output_panel.h index 730cb9360..fbfc1205e 100644 --- a/src/wx/kdm_output_panel.h +++ b/src/wx/kdm_output_panel.h @@ -52,7 +52,7 @@ public: } std::pair, int> make ( - std::list > screen_kdms, + std::list screen_kdms, std::string name, KDMTimingPanel* timing, boost::function confirm_overwrite -- cgit v1.2.3 From 4e62980064496060af5a8c6ecab26ddf218aa63a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 4 May 2020 23:30:23 +0200 Subject: Remove Screen pointer from KDMWithMetadata, preferring to add metadata to a dcp::NameFormat::Map earlier in the call stack. --- src/lib/cinema_kdms.cc | 12 ++++++++---- src/lib/kdm_with_metadata.cc | 15 +++++++++++++-- src/lib/kdm_with_metadata.h | 32 +++++++++++++++++++++----------- src/tools/dcpomatic_kdm.cc | 13 +++++++++++-- src/tools/dcpomatic_kdm_cli.cc | 13 +++++++++++-- src/wx/kdm_dialog.cc | 8 +++++++- 6 files changed, 71 insertions(+), 22 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index 61234ff3f..56b76d3f9 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -29,6 +29,7 @@ #include "log.h" #include "zipper.h" #include "dcpomatic_log.h" +#include "kdm_with_metadata.h" #include #include "i18n.h" @@ -39,6 +40,7 @@ using std::string; using std::runtime_error; using boost::shared_ptr; using boost::function; +using boost::optional; void CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const @@ -48,7 +50,6 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam name_values['c'] = cinema->name; BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) { - name_values['s'] = i->screen->name; name_values['i'] = i->kdm_id (); string const name = careful_string_filter(name_format.get(name_values, ".xml")); zipper.add (name, i->kdm_as_xml()); @@ -72,14 +73,14 @@ CinemaKDMs::collect (list screen_kdms) CinemaKDMs ck; list::iterator i = screen_kdms.begin (); - ck.cinema = (*i)->screen->cinema; + ck.cinema = (*i)->cinema(); ck.screen_kdms.push_back (*i); list::iterator j = i; ++i; screen_kdms.remove (*j); while (i != screen_kdms.end ()) { - if ((*i)->screen->cinema == ck.cinema) { + if ((*i)->cinema() == ck.cinema) { ck.screen_kdms.push_back (*i); list::iterator j = i; ++i; @@ -210,7 +211,10 @@ CinemaKDMs::email ( string screens; BOOST_FOREACH (KDMWithMetadataPtr j, i.screen_kdms) { - screens += j->screen->name + ", "; + optional screen_name = j->get('n'); + if (screen_name) { + screens += *screen_name + ", "; + } } boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2)); diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index 674554f7e..012172a8e 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -28,6 +28,7 @@ using std::string; using std::cout; using std::list; using boost::shared_ptr; +using boost::optional; int write_files ( @@ -56,8 +57,6 @@ write_files ( /* Write KDMs to the specified directory */ BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) { - name_values['c'] = i->screen->cinema ? i->screen->cinema->name : ""; - name_values['s'] = i->screen->name; name_values['i'] = i->kdm_id (); boost::filesystem::path out = directory / careful_string_filter(name_format.get(name_values, ".xml")); if (!boost::filesystem::exists (out) || confirm_overwrite (out)) { @@ -68,3 +67,15 @@ write_files ( return written; } + + +optional +KDMWithMetadata::get (char k) const +{ + dcp::NameFormat::Map::const_iterator i = _name_values.find (k); + if (i == _name_values.end()) { + return optional(); + } + + return i->second; +} diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index 19af0356f..ee84d9eb4 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -28,16 +28,14 @@ #include #include -namespace dcpomatic { - class Screen; -} +class Cinema; -/** Simple class to collect a screen and an encrypted KDM */ class KDMWithMetadata { public: - KDMWithMetadata (boost::shared_ptr s) - : screen (s) + KDMWithMetadata (dcp::NameFormat::Map const& name_values, boost::shared_ptr cinema) + : _name_values (name_values) + , _cinema (cinema) {} virtual ~KDMWithMetadata () {} @@ -46,7 +44,19 @@ public: virtual void kdm_as_xml (boost::filesystem::path out) const = 0; virtual std::string kdm_id () const = 0; - boost::shared_ptr screen; + dcp::NameFormat::Map const& name_values () const { + return _name_values; + } + + boost::optional get (char k) const; + + boost::shared_ptr cinema () const { + return _cinema; + } + +private: + dcp::NameFormat::Map _name_values; + boost::shared_ptr _cinema; }; @@ -63,8 +73,8 @@ int write_files ( class DCPKDMWithMetadata : public KDMWithMetadata { public: - DCPKDMWithMetadata (boost::shared_ptr s, dcp::EncryptedKDM k) - : KDMWithMetadata (s) + DCPKDMWithMetadata (dcp::NameFormat::Map const& name_values, boost::shared_ptr cinema, dcp::EncryptedKDM k) + : KDMWithMetadata (name_values, cinema) , kdm (k) {} @@ -87,8 +97,8 @@ public: class ECinemaKDMWithMetadata : public KDMWithMetadata { public: - ECinemaKDMWithMetadata (boost::shared_ptr s, EncryptedECinemaKDM k) - : KDMWithMetadata (s) + ECinemaKDMWithMetadata (dcp::NameValues::Map const& name_values, boost::shared_ptr cinema, EncryptedECinemaKDM k) + : KDMWithMetadata (name_values, cinema) , kdm (k) {} diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index efc09c818..bda944d83 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -326,10 +326,14 @@ private: dcp::LocalTime (_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()) ); + dcp::NameFormat::Map name_values; + name_values['c'] = i->cinema->name; + name_values['s'] = i->name; + /* Encrypt */ screen_kdms.push_back ( KDMWithMetadataPtr( - new ECinemaKDMWithMetadata(i, kdm.encrypt(i->recipient.get())) + new ECinemaKDMWithMetadata(name_values, i->cinema, kdm.encrypt(i->recipient.get())) ) ); } @@ -369,11 +373,16 @@ private: kdm.add_key (j); } + dcp::NameFormat::Map name_values; + name_values['c'] = i->cinema->name; + name_values['s'] = i->name; + /* Encrypt */ screen_kdms.push_back ( KDMWithMetadataPtr( new DCPKDMWithMetadata( - i, + name_values, + i->cinema, kdm.encrypt( signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(), !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional() : 0 diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index a1003eceb..dd7fc82e3 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -244,7 +244,11 @@ from_film ( disable_forensic_marking_audio ); - kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(i, kdm))); + dcp::NameFormat::Map name_values; + name_values['c'] = i->cinema->name; + name_values['s'] = i->name; + + kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } } @@ -351,10 +355,15 @@ from_dkdm ( continue; } + dcp::NameFormat::Map name_values; + name_values['c'] = i->cinema->name; + name_values['s'] = i->name; + screen_kdms.push_back ( KDMWithMetadataPtr( new DCPKDMWithMetadata( - i, + name_values, + i->cinema, kdm_from_dkdm( dkdm, i->recipient.get(), diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index b067ff04a..f041c16c5 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -175,7 +175,13 @@ KDMDialog::make_clicked () for_audio ); - screen_kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(i, kdm))); + dcp::NameFormat::Map name_values; + if (i->cinema) { + name_values['c'] = i->cinema->name; + } + name_values['s'] = i->name; + + screen_kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } } -- cgit v1.2.3 From aa382124eeabcad7a7346d46fb5f931c1364a849 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 4 May 2020 23:37:22 +0200 Subject: Pull methods out of CinemaKDMs. --- src/lib/cinema_kdms.cc | 18 +++++++++--------- src/lib/cinema_kdms.h | 17 +++++++++-------- src/lib/send_kdm_email_job.cc | 2 +- src/tools/dcpomatic_kdm_cli.cc | 4 ++-- src/wx/kdm_output_panel.cc | 10 +++++----- 5 files changed, 26 insertions(+), 25 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index 56b76d3f9..d96a95d7f 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -43,13 +43,13 @@ using boost::function; using boost::optional; void -CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const +make_zip_file (CinemaKDMs kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) { Zipper zipper (zip_file); - name_values['c'] = cinema->name; + name_values['c'] = kdms.cinema->name; - BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) { + BOOST_FOREACH (KDMWithMetadataPtr i, kdms.screen_kdms) { name_values['i'] = i->kdm_id (); string const name = careful_string_filter(name_format.get(name_values, ".xml")); zipper.add (name, i->kdm_as_xml()); @@ -62,7 +62,7 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam * CinemaKDM contains the KDMs for its cinema. */ list -CinemaKDMs::collect (list screen_kdms) +collect (list screen_kdms) { list cinema_kdms; @@ -98,7 +98,7 @@ CinemaKDMs::collect (list screen_kdms) /** Write one directory per cinema into another directory */ int -CinemaKDMs::write_directories ( +write_directories ( list cinema_kdms, boost::filesystem::path directory, dcp::NameFormat container_name_format, @@ -128,7 +128,7 @@ CinemaKDMs::write_directories ( /** Write one ZIP file per cinema into a directory */ int -CinemaKDMs::write_zip_files ( +write_zip_files ( list cinema_kdms, boost::filesystem::path directory, dcp::NameFormat container_name_format, @@ -151,7 +151,7 @@ CinemaKDMs::write_zip_files ( /* Creating a new zip file over an existing one is an error */ boost::filesystem::remove (path); } - i.make_zip_file (path, filename_format, name_values); + make_zip_file (i, path, filename_format, name_values); written += i.screen_kdms.size(); } } @@ -167,7 +167,7 @@ CinemaKDMs::write_zip_files ( * @param cpl_name Name of the CPL that the KDMs are for. */ void -CinemaKDMs::email ( +email ( list cinema_kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, @@ -195,7 +195,7 @@ CinemaKDMs::email ( boost::filesystem::path zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); boost::filesystem::create_directories (zip_file); zip_file /= container_name_format.get(name_values, ".zip"); - i.make_zip_file (zip_file, filename_format, name_values); + make_zip_file (i, zip_file, filename_format, name_values); string subject = config->kdm_subject(); boost::algorithm::replace_all (subject, "$CPL_NAME", cpl_name); diff --git a/src/lib/cinema_kdms.h b/src/lib/cinema_kdms.h index 918670397..592bec923 100644 --- a/src/lib/cinema_kdms.h +++ b/src/lib/cinema_kdms.h @@ -27,11 +27,15 @@ class Log; class CinemaKDMs { public: - void make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const; + boost::shared_ptr cinema; + std::list screen_kdms; +}; + +void make_zip_file (CinemaKDMs kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values); - static std::list collect (std::list kdms); +std::list collect (std::list kdms); - static int write_directories ( +int write_directories ( std::list cinema_kdms, boost::filesystem::path directory, dcp::NameFormat container_name_format, @@ -40,7 +44,7 @@ public: boost::function confirm_overwrite ); - static int write_zip_files ( +int write_zip_files ( std::list cinema_kdms, boost::filesystem::path directory, dcp::NameFormat container_name_format, @@ -49,7 +53,7 @@ public: boost::function confirm_overwrite ); - static void email ( +void email ( std::list cinema_kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, @@ -57,6 +61,3 @@ public: std::string cpl_name ); - boost::shared_ptr cinema; - std::list screen_kdms; -}; diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 1b476fa63..10a571ead 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -79,7 +79,7 @@ void SendKDMEmailJob::run () { set_progress_unknown (); - CinemaKDMs::email (_cinema_kdms, _container_name_format, _filename_format, _name_values, _cpl_name); + email (_cinema_kdms, _container_name_format, _filename_format, _name_values, _cpl_name); set_progress (1); set_state (FINISHED_OK); } diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index dd7fc82e3..493eea2c9 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -140,8 +140,8 @@ write_files ( ) { if (zip) { - int const N = CinemaKDMs::write_zip_files ( - CinemaKDMs::collect (screen_kdms), + int const N = write_zip_files ( + collect (screen_kdms), output, container_name_format, filename_format, diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index 541674ae1..fe87dfccd 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -186,7 +186,7 @@ KDMOutputPanel::make ( list screen_kdms, string name, KDMTimingPanel* timing, function confirm_overwrite ) { - list const cinema_kdms = CinemaKDMs::collect (screen_kdms); + list const cinema_kdms = collect (screen_kdms); /* Decide whether to proceed */ @@ -255,8 +255,8 @@ KDMOutputPanel::make ( confirm_overwrite ); } else if (_write_folder->GetValue()) { - written = CinemaKDMs::write_directories ( - CinemaKDMs::collect (screen_kdms), + written = write_directories ( + collect (screen_kdms), directory(), _container_name_format->get(), _filename_format->get(), @@ -264,8 +264,8 @@ KDMOutputPanel::make ( confirm_overwrite ); } else if (_write_zip->GetValue()) { - written = CinemaKDMs::write_zip_files ( - CinemaKDMs::collect (screen_kdms), + written = write_zip_files ( + collect (screen_kdms), directory(), _container_name_format->get(), _filename_format->get(), -- cgit v1.2.3 From 8f8730cadb3dae36e8aa7b7c732a7c162eac0fb6 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 May 2020 00:56:54 +0200 Subject: Move some functions to kdm_with_metadata --- src/lib/cinema_kdms.cc | 245 ------------------------------------- src/lib/cinema_kdms.h | 56 --------- src/lib/kdm_with_metadata.cc | 216 ++++++++++++++++++++++++++++++++ src/lib/kdm_with_metadata.h | 35 ++++++ src/lib/send_kdm_email_job.cc | 2 +- src/lib/wscript | 1 - src/tools/dcpomatic.cc | 1 - src/tools/dcpomatic_kdm.cc | 1 - src/tools/dcpomatic_kdm_cli.cc | 1 - src/wx/confirm_kdm_email_dialog.cc | 1 - src/wx/kdm_dialog.cc | 1 - src/wx/kdm_output_panel.cc | 1 - src/wx/recreate_chain_dialog.cc | 1 - 13 files changed, 252 insertions(+), 310 deletions(-) delete mode 100644 src/lib/cinema_kdms.cc delete mode 100644 src/lib/cinema_kdms.h (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc deleted file mode 100644 index 94e83f807..000000000 --- a/src/lib/cinema_kdms.cc +++ /dev/null @@ -1,245 +0,0 @@ -/* - Copyright (C) 2013-2015 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 "exceptions.h" -#include "cinema_kdms.h" -#include "cinema.h" -#include "screen.h" -#include "config.h" -#include "util.h" -#include "emailer.h" -#include "compose.hpp" -#include "log.h" -#include "zipper.h" -#include "dcpomatic_log.h" -#include "kdm_with_metadata.h" -#include - -#include "i18n.h" - -using std::list; -using std::cout; -using std::string; -using std::runtime_error; -using boost::shared_ptr; -using boost::function; -using boost::optional; - -void -make_zip_file (list kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) -{ - Zipper zipper (zip_file); - - BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { - name_values['i'] = i->kdm_id (); - string const name = careful_string_filter(name_format.get(name_values, ".xml")); - zipper.add (name, i->kdm_as_xml()); - } - - zipper.close (); -} - -/** Collect a list of KDMWithMetadatas into a list of list so that each - * CinemaKDM contains the KDMs for its cinema. - */ -list > -collect (list screen_kdms) -{ - list > cinema_kdms; - - while (!screen_kdms.empty ()) { - - /* Get all the screens from a single cinema */ - - list ck; - - list::iterator i = screen_kdms.begin (); - ck.push_back (*i); - list::iterator j = i; - ++i; - screen_kdms.remove (*j); - - while (i != screen_kdms.end ()) { - if ((*i)->cinema() == ck.front()->cinema()) { - ck.push_back (*i); - list::iterator j = i; - ++i; - screen_kdms.remove (*j); - } else { - ++i; - } - } - - cinema_kdms.push_back (ck); - } - - return cinema_kdms; -} - -/** Write one directory per cinema into another directory */ -int -write_directories ( - list > cinema_kdms, - boost::filesystem::path directory, - dcp::NameFormat container_name_format, - dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, - function confirm_overwrite - ) -{ - /* No specific screen */ - name_values['s'] = ""; - - int written = 0; - - BOOST_FOREACH (list const & i, cinema_kdms) { - boost::filesystem::path path = directory; - path /= container_name_format.get(name_values, ""); - if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { - boost::filesystem::create_directories (path); - write_files (i, path, filename_format, name_values, confirm_overwrite); - } - written += i.size(); - } - - return written; -} - -/** Write one ZIP file per cinema into a directory */ -int -write_zip_files ( - list > cinema_kdms, - boost::filesystem::path directory, - dcp::NameFormat container_name_format, - dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, - function confirm_overwrite - ) -{ - /* No specific screen */ - name_values['s'] = ""; - - int written = 0; - - BOOST_FOREACH (list const & i, cinema_kdms) { - boost::filesystem::path path = directory; - path /= container_name_format.get(name_values, ".zip"); - if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { - if (boost::filesystem::exists (path)) { - /* Creating a new zip file over an existing one is an error */ - boost::filesystem::remove (path); - } - make_zip_file (i, path, filename_format, name_values); - written += i.size(); - } - } - - return written; -} - -/** Email one ZIP file per cinema to the cinema. - * @param cinema_kdms KDMS to email. - * @param container_name_format Format of folder / ZIP to use. - * @param filename_format Format of filenames to use. - * @param name_values Values to substitute into \p container_name_format and \p filename_format. - * @param cpl_name Name of the CPL that the KDMs are for. - */ -void -email ( - list > cinema_kdms, - dcp::NameFormat container_name_format, - dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, - string cpl_name - ) -{ - Config* config = Config::instance (); - - if (config->mail_server().empty()) { - throw NetworkError (_("No mail server configured in preferences")); - } - - /* No specific screen */ - name_values['s'] = ""; - - BOOST_FOREACH (list const & i, cinema_kdms) { - - if (i.front()->cinema()->emails.empty()) { - continue; - } - - boost::filesystem::path zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); - boost::filesystem::create_directories (zip_file); - zip_file /= container_name_format.get(name_values, ".zip"); - make_zip_file (i, zip_file, filename_format, name_values); - - string subject = config->kdm_subject(); - boost::algorithm::replace_all (subject, "$CPL_NAME", cpl_name); - boost::algorithm::replace_all (subject, "$START_TIME", name_values['b']); - boost::algorithm::replace_all (subject, "$END_TIME", name_values['e']); - boost::algorithm::replace_all (subject, "$CINEMA_NAME", i.front()->cinema()->name); - - string body = config->kdm_email().c_str(); - boost::algorithm::replace_all (body, "$CPL_NAME", cpl_name); - boost::algorithm::replace_all (body, "$START_TIME", name_values['b']); - boost::algorithm::replace_all (body, "$END_TIME", name_values['e']); - boost::algorithm::replace_all (body, "$CINEMA_NAME", i.front()->cinema()->name); - - string screens; - BOOST_FOREACH (KDMWithMetadataPtr j, i) { - optional screen_name = j->get('n'); - if (screen_name) { - screens += *screen_name + ", "; - } - } - boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2)); - - Emailer email (config->kdm_from(), i.front()->cinema()->emails, subject, body); - - BOOST_FOREACH (string i, config->kdm_cc()) { - email.add_cc (i); - } - if (!config->kdm_bcc().empty ()) { - email.add_bcc (config->kdm_bcc ()); - } - - email.add_attachment (zip_file, container_name_format.get(name_values, ".zip"), "application/zip"); - - Config* c = Config::instance (); - - try { - email.send (c->mail_server(), c->mail_port(), c->mail_protocol(), c->mail_user(), c->mail_password()); - } catch (...) { - boost::filesystem::remove (zip_file); - dcpomatic_log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log (email.email(), LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log ("Email session follows", LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL); - throw; - } - - boost::filesystem::remove (zip_file); - - dcpomatic_log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log (email.email(), LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log ("Email session follows", LogEntry::TYPE_DEBUG_EMAIL); - dcpomatic_log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL); - } -} diff --git a/src/lib/cinema_kdms.h b/src/lib/cinema_kdms.h deleted file mode 100644 index 0a5749ee8..000000000 --- a/src/lib/cinema_kdms.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2013-2015 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 "kdm_with_metadata.h" - -class Cinema; -class Job; -class Log; - -void make_zip_file (std::list kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values); - -std::list > collect (std::list kdms); - -int write_directories ( - std::list > cinema_kdms, - boost::filesystem::path directory, - dcp::NameFormat container_name_format, - dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, - boost::function confirm_overwrite - ); - -int write_zip_files ( - std::list > cinema_kdms, - boost::filesystem::path directory, - dcp::NameFormat container_name_format, - dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, - boost::function confirm_overwrite - ); - -void email ( - std::list > cinema_kdms, - dcp::NameFormat container_name_format, - dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, - std::string cpl_name - ); - diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index 012172a8e..fe4f9ccdd 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -22,13 +22,22 @@ #include "cinema.h" #include "screen.h" #include "util.h" +#include "zipper.h" +#include "config.h" +#include "dcpomatic_log.h" +#include "emailer.h" #include +#include +#include + +#include "i18n.h" using std::string; using std::cout; using std::list; using boost::shared_ptr; using boost::optional; +using boost::function; int write_files ( @@ -79,3 +88,210 @@ KDMWithMetadata::get (char k) const return i->second; } + + +void +make_zip_file (list kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) +{ + Zipper zipper (zip_file); + + BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { + name_values['i'] = i->kdm_id (); + string const name = careful_string_filter(name_format.get(name_values, ".xml")); + zipper.add (name, i->kdm_as_xml()); + } + + zipper.close (); +} + + +/** Collect a list of KDMWithMetadatas into a list of list so that each + * CinemaKDM contains the KDMs for its cinema. + */ +list > +collect (list screen_kdms) +{ + list > cinema_kdms; + + while (!screen_kdms.empty ()) { + + /* Get all the screens from a single cinema */ + + list ck; + + list::iterator i = screen_kdms.begin (); + ck.push_back (*i); + list::iterator j = i; + ++i; + screen_kdms.remove (*j); + + while (i != screen_kdms.end ()) { + if ((*i)->cinema() == ck.front()->cinema()) { + ck.push_back (*i); + list::iterator j = i; + ++i; + screen_kdms.remove (*j); + } else { + ++i; + } + } + + cinema_kdms.push_back (ck); + } + + return cinema_kdms; +} + + +/** Write one directory per cinema into another directory */ +int +write_directories ( + list > cinema_kdms, + boost::filesystem::path directory, + dcp::NameFormat container_name_format, + dcp::NameFormat filename_format, + dcp::NameFormat::Map name_values, + function confirm_overwrite + ) +{ + /* No specific screen */ + name_values['s'] = ""; + + int written = 0; + + BOOST_FOREACH (list const & i, cinema_kdms) { + boost::filesystem::path path = directory; + path /= container_name_format.get(name_values, ""); + if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { + boost::filesystem::create_directories (path); + write_files (i, path, filename_format, name_values, confirm_overwrite); + } + written += i.size(); + } + + return written; +} + + +/** Write one ZIP file per cinema into a directory */ +int +write_zip_files ( + list > cinema_kdms, + boost::filesystem::path directory, + dcp::NameFormat container_name_format, + dcp::NameFormat filename_format, + dcp::NameFormat::Map name_values, + function confirm_overwrite + ) +{ + /* No specific screen */ + name_values['s'] = ""; + + int written = 0; + + BOOST_FOREACH (list const & i, cinema_kdms) { + boost::filesystem::path path = directory; + path /= container_name_format.get(name_values, ".zip"); + if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { + if (boost::filesystem::exists (path)) { + /* Creating a new zip file over an existing one is an error */ + boost::filesystem::remove (path); + } + make_zip_file (i, path, filename_format, name_values); + written += i.size(); + } + } + + return written; +} + + +/** Email one ZIP file per cinema to the cinema. + * @param cinema_kdms KDMS to email. + * @param container_name_format Format of folder / ZIP to use. + * @param filename_format Format of filenames to use. + * @param name_values Values to substitute into \p container_name_format and \p filename_format. + * @param cpl_name Name of the CPL that the KDMs are for. + */ +void +email ( + list > cinema_kdms, + dcp::NameFormat container_name_format, + dcp::NameFormat filename_format, + dcp::NameFormat::Map name_values, + string cpl_name + ) +{ + Config* config = Config::instance (); + + if (config->mail_server().empty()) { + throw NetworkError (_("No mail server configured in preferences")); + } + + /* No specific screen */ + name_values['s'] = ""; + + BOOST_FOREACH (list const & i, cinema_kdms) { + + if (i.front()->cinema()->emails.empty()) { + continue; + } + + boost::filesystem::path zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); + boost::filesystem::create_directories (zip_file); + zip_file /= container_name_format.get(name_values, ".zip"); + make_zip_file (i, zip_file, filename_format, name_values); + + string subject = config->kdm_subject(); + boost::algorithm::replace_all (subject, "$CPL_NAME", cpl_name); + boost::algorithm::replace_all (subject, "$START_TIME", name_values['b']); + boost::algorithm::replace_all (subject, "$END_TIME", name_values['e']); + boost::algorithm::replace_all (subject, "$CINEMA_NAME", i.front()->cinema()->name); + + string body = config->kdm_email().c_str(); + boost::algorithm::replace_all (body, "$CPL_NAME", cpl_name); + boost::algorithm::replace_all (body, "$START_TIME", name_values['b']); + boost::algorithm::replace_all (body, "$END_TIME", name_values['e']); + boost::algorithm::replace_all (body, "$CINEMA_NAME", i.front()->cinema()->name); + + string screens; + BOOST_FOREACH (KDMWithMetadataPtr j, i) { + optional screen_name = j->get('n'); + if (screen_name) { + screens += *screen_name + ", "; + } + } + boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2)); + + Emailer email (config->kdm_from(), i.front()->cinema()->emails, subject, body); + + BOOST_FOREACH (string i, config->kdm_cc()) { + email.add_cc (i); + } + if (!config->kdm_bcc().empty ()) { + email.add_bcc (config->kdm_bcc ()); + } + + email.add_attachment (zip_file, container_name_format.get(name_values, ".zip"), "application/zip"); + + Config* c = Config::instance (); + + try { + email.send (c->mail_server(), c->mail_port(), c->mail_protocol(), c->mail_user(), c->mail_password()); + } catch (...) { + boost::filesystem::remove (zip_file); + dcpomatic_log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log (email.email(), LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log ("Email session follows", LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL); + throw; + } + + boost::filesystem::remove (zip_file); + + dcpomatic_log->log ("Email content follows", LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log (email.email(), LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log ("Email session follows", LogEntry::TYPE_DEBUG_EMAIL); + dcpomatic_log->log (email.notes(), LogEntry::TYPE_DEBUG_EMAIL); + } +} diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index ee84d9eb4..c2a13fced 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -70,6 +70,41 @@ int write_files ( ); +void make_zip_file (std::list kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values); + + +std::list > collect (std::list kdms); + + +int write_directories ( + std::list > cinema_kdms, + boost::filesystem::path directory, + dcp::NameFormat container_name_format, + dcp::NameFormat filename_format, + dcp::NameFormat::Map name_values, + boost::function confirm_overwrite + ); + + +int write_zip_files ( + std::list > cinema_kdms, + boost::filesystem::path directory, + dcp::NameFormat container_name_format, + dcp::NameFormat filename_format, + dcp::NameFormat::Map name_values, + boost::function confirm_overwrite + ); + + +void email ( + std::list > cinema_kdms, + dcp::NameFormat container_name_format, + dcp::NameFormat filename_format, + dcp::NameFormat::Map name_values, + std::string cpl_name + ); + + class DCPKDMWithMetadata : public KDMWithMetadata { public: diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index e9bad4c20..7b4d349f3 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -20,8 +20,8 @@ #include "send_kdm_email_job.h" #include "compose.hpp" +#include "kdm_with_metadata.h" #include "film.h" -#include "cinema_kdms.h" #include #include "i18n.h" diff --git a/src/lib/wscript b/src/lib/wscript index 19d68f045..49c55cc6d 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -47,7 +47,6 @@ sources = """ checker.cc check_content_change_job.cc cinema.cc - cinema_kdms.cc cinema_sound_processor.cc colour_conversion.cc config.cc diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 5976de22a..546286e48 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -72,7 +72,6 @@ #include "lib/cross.h" #include "lib/content_factory.h" #include "lib/compose.hpp" -#include "lib/cinema_kdms.h" #include "lib/dcpomatic_socket.h" #include "lib/hints.h" #include "lib/dcp_content.h" diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index bda944d83..bbaf5bad7 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -40,7 +40,6 @@ #include "lib/job_manager.h" #include "lib/kdm_with_metadata.h" #include "lib/exceptions.h" -#include "lib/cinema_kdms.h" #include "lib/send_kdm_email_job.h" #include "lib/compose.hpp" #include "lib/cinema.h" diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index 493eea2c9..e3e977c6a 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -25,7 +25,6 @@ #include "lib/film.h" #include "lib/cinema.h" #include "lib/kdm_with_metadata.h" -#include "lib/cinema_kdms.h" #include "lib/config.h" #include "lib/exceptions.h" #include "lib/emailer.h" diff --git a/src/wx/confirm_kdm_email_dialog.cc b/src/wx/confirm_kdm_email_dialog.cc index eca34b5cf..df6131fe1 100644 --- a/src/wx/confirm_kdm_email_dialog.cc +++ b/src/wx/confirm_kdm_email_dialog.cc @@ -23,7 +23,6 @@ #include "static_text.h" #include "check_box.h" #include "lib/config.h" -#include "lib/cinema_kdms.h" #include using std::list; diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index f041c16c5..14ba5cf05 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -31,7 +31,6 @@ #include "lib/screen.h" #include "lib/kdm_with_metadata.h" #include "lib/job_manager.h" -#include "lib/cinema_kdms.h" #include "lib/config.h" #include "lib/cinema.h" #include diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index c2884008f..dcd5c6f91 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -20,7 +20,6 @@ #include "lib/config.h" #include "lib/cinema.h" -#include "lib/cinema_kdms.h" #include "lib/send_kdm_email_job.h" #include "kdm_output_panel.h" #include "kdm_timing_panel.h" diff --git a/src/wx/recreate_chain_dialog.cc b/src/wx/recreate_chain_dialog.cc index e477cdc1f..ae6afdd08 100644 --- a/src/wx/recreate_chain_dialog.cc +++ b/src/wx/recreate_chain_dialog.cc @@ -23,7 +23,6 @@ #include "static_text.h" #include "check_box.h" #include "lib/config.h" -#include "lib/cinema_kdms.h" #include using std::list; -- cgit v1.2.3 From 0ab8cf5b312f36a14f66d4564c6f4b1694ddaae0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 May 2020 14:16:36 +0200 Subject: Rename some variables and re-implement collect(). --- src/lib/kdm_with_metadata.cc | 46 +++++++++++++++++------------------------- src/tools/dcpomatic_kdm.cc | 10 ++++----- src/tools/dcpomatic_kdm_cli.cc | 12 +++++------ src/wx/kdm_dialog.cc | 6 +++--- src/wx/kdm_output_panel.cc | 10 ++++----- 5 files changed, 38 insertions(+), 46 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index fe4f9ccdd..62d544e0b 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -41,7 +41,7 @@ using boost::function; int write_files ( - list screen_kdms, + list kdms, boost::filesystem::path directory, dcp::NameFormat name_format, dcp::NameFormat::Map name_values, @@ -52,7 +52,7 @@ write_files ( if (directory == "-") { /* Write KDMs to the stdout */ - BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) { + BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { cout << i->kdm_as_xml (); ++written; } @@ -65,7 +65,7 @@ write_files ( } /* Write KDMs to the specified directory */ - BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) { + BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { name_values['i'] = i->kdm_id (); boost::filesystem::path out = directory / careful_string_filter(name_format.get(name_values, ".xml")); if (!boost::filesystem::exists (out) || confirm_overwrite (out)) { @@ -105,41 +105,33 @@ make_zip_file (list kdms, boost::filesystem::path zip_file, } -/** Collect a list of KDMWithMetadatas into a list of list so that each - * CinemaKDM contains the KDMs for its cinema. +/** Collect a list of KDMWithMetadatas into a list of lists so that + * each list contains the KDMs for one cinema. */ list > -collect (list screen_kdms) +collect (list kdms) { - list > cinema_kdms; - - while (!screen_kdms.empty ()) { - - /* Get all the screens from a single cinema */ + list > grouped; - list ck; + BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { - list::iterator i = screen_kdms.begin (); - ck.push_back (*i); - list::iterator j = i; - ++i; - screen_kdms.remove (*j); + list >::iterator j = grouped.begin (); - while (i != screen_kdms.end ()) { - if ((*i)->cinema() == ck.front()->cinema()) { - ck.push_back (*i); - list::iterator j = i; - ++i; - screen_kdms.remove (*j); - } else { - ++i; + while (j != grouped.end()) { + if (j->front()->cinema() == i->cinema()) { + j->push_back (i); + break; } + ++j; } - cinema_kdms.push_back (ck); + if (j == grouped.end()) { + grouped.push_back (list()); + grouped.back().push_back (i); + } } - return cinema_kdms; + return grouped; } diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index bbaf5bad7..dd45401cb 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -302,7 +302,7 @@ private: return; } - list screen_kdms; + list kdms; string title; #ifdef DCPOMATIC_VARIANT_SWAROOP @@ -330,7 +330,7 @@ private: name_values['s'] = i->name; /* Encrypt */ - screen_kdms.push_back ( + kdms.push_back ( KDMWithMetadataPtr( new ECinemaKDMWithMetadata(name_values, i->cinema, kdm.encrypt(i->recipient.get())) ) @@ -377,7 +377,7 @@ private: name_values['s'] = i->name; /* Encrypt */ - screen_kdms.push_back ( + kdms.push_back ( KDMWithMetadataPtr( new DCPKDMWithMetadata( name_values, @@ -392,12 +392,12 @@ private: } } - if (screen_kdms.empty()) { + if (kdms.empty()) { return; } pair, int> result = _output->make ( - screen_kdms, title, _timing, bind (&DOMFrame::confirm_overwrite, this, _1) + kdms, title, _timing, bind (&DOMFrame::confirm_overwrite, this, _1) ); if (result.first) { diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index e3e977c6a..ec49723a8 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -129,7 +129,7 @@ always_overwrite () void write_files ( - list screen_kdms, + list kdms, bool zip, boost::filesystem::path output, dcp::NameFormat container_name_format, @@ -140,7 +140,7 @@ write_files ( { if (zip) { int const N = write_zip_files ( - collect (screen_kdms), + collect (kdms), output, container_name_format, filename_format, @@ -153,7 +153,7 @@ write_files ( } } else { int const N = write_files ( - screen_kdms, output, filename_format, values, + kdms, output, filename_format, values, bind (&always_overwrite) ); @@ -348,7 +348,7 @@ from_dkdm ( values['e'] = dcp::LocalTime(valid_to).date() + " " + dcp::LocalTime(valid_to).time_of_day(true, false); try { - list screen_kdms; + list kdms; BOOST_FOREACH (shared_ptr i, screens) { if (!i->recipient) { continue; @@ -358,7 +358,7 @@ from_dkdm ( name_values['c'] = i->cinema->name; name_values['s'] = i->name; - screen_kdms.push_back ( + kdms.push_back ( KDMWithMetadataPtr( new DCPKDMWithMetadata( name_values, @@ -377,7 +377,7 @@ from_dkdm ( ) ); } - write_files (screen_kdms, zip, output, container_name_format, filename_format, values, verbose); + write_files (kdms, zip, output, container_name_format, filename_format, values, verbose); } catch (FileError& e) { cerr << program_name << ": " << e.what() << " (" << e.file().string() << ")\n"; exit (EXIT_FAILURE); diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index 14ba5cf05..0686450fb 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -149,7 +149,7 @@ KDMDialog::make_clicked () shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - list screen_kdms; + list kdms; try { /* Start off by enabling forensic marking for all */ optional for_audio; @@ -180,7 +180,7 @@ KDMDialog::make_clicked () } name_values['s'] = i->name; - screen_kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); + kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } } @@ -196,7 +196,7 @@ KDMDialog::make_clicked () return; } - pair, int> result = _output->make (screen_kdms, film->name(), _timing, bind (&KDMDialog::confirm_overwrite, this, _1)); + pair, int> result = _output->make (kdms, film->name(), _timing, bind (&KDMDialog::confirm_overwrite, this, _1)); if (result.first) { JobManager::instance()->add (result.first); } diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index dcd5c6f91..025707b28 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -182,10 +182,10 @@ KDMOutputPanel::kdm_write_type_changed () pair, int> KDMOutputPanel::make ( - list screen_kdms, string name, KDMTimingPanel* timing, function confirm_overwrite + list kdms, string name, KDMTimingPanel* timing, function confirm_overwrite ) { - list > const cinema_kdms = collect (screen_kdms); + list > const cinema_kdms = collect (kdms); /* Decide whether to proceed */ @@ -247,7 +247,7 @@ KDMOutputPanel::make ( if (_write_to->GetValue()) { if (_write_flat->GetValue()) { written = write_files ( - screen_kdms, + kdms, directory(), _filename_format->get(), name_values, @@ -255,7 +255,7 @@ KDMOutputPanel::make ( ); } else if (_write_folder->GetValue()) { written = write_directories ( - collect (screen_kdms), + collect (kdms), directory(), _container_name_format->get(), _filename_format->get(), @@ -264,7 +264,7 @@ KDMOutputPanel::make ( ); } else if (_write_zip->GetValue()) { written = write_zip_files ( - collect (screen_kdms), + collect (kdms), directory(), _container_name_format->get(), _filename_format->get(), -- cgit v1.2.3 From 5579acd7ff7e1460f0b5bb54a4deedbd356153cd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 May 2020 15:08:50 +0200 Subject: Write 'f', 'b' and 'e' tags into all KDMWithMetadata when they are made. --- src/tools/dcpomatic_kdm.cc | 22 +++++++++++++++++----- src/tools/dcpomatic_kdm_cli.cc | 27 +++++++++++++++++---------- src/wx/kdm_dialog.cc | 12 +++++++++--- src/wx/kdm_output_panel.cc | 5 +---- src/wx/kdm_output_panel.h | 1 - 5 files changed, 44 insertions(+), 23 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index dd45401cb..7920f7e57 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -317,17 +317,23 @@ private: continue; } + dcp::LocalTime begin(_timing->from(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()); + dcp::LocalTime end(_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()); + DecryptedECinemaKDM kdm ( decrypted.id(), decrypted.name(), decrypted.key(), - dcp::LocalTime (_timing->from(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()), - dcp::LocalTime (_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()) + begin, + end ); dcp::NameFormat::Map name_values; name_values['c'] = i->cinema->name; name_values['s'] = i->name; + name_values['f'] = title; + name_values['b'] = begin.date() + " " + begin.time_of_day(true, false); + name_values['e'] = end.date() + " " + end.time_of_day(true, false); /* Encrypt */ kdms.push_back ( @@ -358,10 +364,13 @@ private: continue; } + dcp::LocalTime begin(_timing->from(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()); + dcp::LocalTime end(_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()); + /* Make an empty KDM */ dcp::DecryptedKDM kdm ( - dcp::LocalTime (_timing->from(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()), - dcp::LocalTime (_timing->until(), i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()), + begin, + end, decrypted.annotation_text().get_value_or (""), decrypted.content_title_text(), dcp::LocalTime().as_string() @@ -375,6 +384,9 @@ private: dcp::NameFormat::Map name_values; name_values['c'] = i->cinema->name; name_values['s'] = i->name; + name_values['f'] = title; + name_values['b'] = begin.date() + " " + begin.time_of_day(true, false); + name_values['e'] = end.date() + " " + end.time_of_day(true, false); /* Encrypt */ kdms.push_back ( @@ -397,7 +409,7 @@ private: } pair, int> result = _output->make ( - kdms, title, _timing, bind (&DOMFrame::confirm_overwrite, this, _1) + kdms, title, bind (&DOMFrame::confirm_overwrite, this, _1) ); if (result.first) { diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index ec49723a8..a85624c82 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -223,21 +223,22 @@ from_film ( boost::filesystem::path cpl = cpls.front().cpl_file; dcp::NameFormat::Map values; - values['f'] = film->name(); - values['b'] = dcp::LocalTime(valid_from).date() + " " + dcp::LocalTime(valid_from).time_of_day(true, false); - values['e'] = dcp::LocalTime(valid_to).date() + " " + dcp::LocalTime(valid_to).time_of_day(true, false); try { list kdms; BOOST_FOREACH (shared_ptr i, screens) { if (i->recipient) { + + dcp::LocalTime const begin(valid_from, i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0); + dcp::LocalTime const end(valid_to, i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0); + dcp::EncryptedKDM const kdm = film->make_kdm ( i->recipient.get(), i->trusted_device_thumbprints(), cpl, - dcp::LocalTime(valid_from, i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0), - dcp::LocalTime(valid_to, i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0), + begin, + end, formulation, disable_forensic_marking_picture, disable_forensic_marking_audio @@ -246,6 +247,9 @@ from_film ( dcp::NameFormat::Map name_values; name_values['c'] = i->cinema->name; name_values['s'] = i->name; + name_values['f'] = film->name(); + name_values['b'] = dcp::LocalTime(begin).date() + " " + dcp::LocalTime(begin).time_of_day(true, false); + name_values['e'] = dcp::LocalTime(end).date() + " " + dcp::LocalTime(end).time_of_day(true, false); kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } @@ -343,9 +347,6 @@ from_dkdm ( ) { dcp::NameFormat::Map values; - values['f'] = dkdm.annotation_text().get_value_or(""); - values['b'] = dcp::LocalTime(valid_from).date() + " " + dcp::LocalTime(valid_from).time_of_day(true, false); - values['e'] = dcp::LocalTime(valid_to).date() + " " + dcp::LocalTime(valid_to).time_of_day(true, false); try { list kdms; @@ -354,9 +355,15 @@ from_dkdm ( continue; } + dcp::LocalTime begin(valid_from, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()); + dcp::LocalTime end(valid_to, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()); + dcp::NameFormat::Map name_values; name_values['c'] = i->cinema->name; name_values['s'] = i->name; + name_values['f'] = dkdm.annotation_text().get_value_or(""); + name_values['b'] = begin.date() + " " + begin.time_of_day(true, false); + name_values['e'] = end.date() + " " + end.time_of_day(true, false); kdms.push_back ( KDMWithMetadataPtr( @@ -367,8 +374,8 @@ from_dkdm ( dkdm, i->recipient.get(), i->trusted_device_thumbprints(), - dcp::LocalTime(valid_from, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()), - dcp::LocalTime(valid_to, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()), + begin, + end, formulation, disable_forensic_marking_picture, disable_forensic_marking_audio diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index 0686450fb..d946e1d12 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -163,12 +163,15 @@ KDMDialog::make_clicked () BOOST_FOREACH (shared_ptr i, _screens->screens()) { if (i->recipient) { + dcp::LocalTime const begin(_timing->from(), i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0); + dcp::LocalTime const end(_timing->until(), i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0); + dcp::EncryptedKDM const kdm = film->make_kdm ( i->recipient.get(), i->trusted_device_thumbprints(), _cpl->cpl(), - dcp::LocalTime(_timing->from(), i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0), - dcp::LocalTime(_timing->until(), i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0), + begin, + end, _output->formulation(), !_output->forensic_mark_video(), for_audio @@ -179,6 +182,9 @@ KDMDialog::make_clicked () name_values['c'] = i->cinema->name; } name_values['s'] = i->name; + name_values['f'] = film->name(); + name_values['b'] = dcp::LocalTime(begin).date() + " " + dcp::LocalTime(begin).time_of_day(false, false); + name_values['e'] = dcp::LocalTime(end).date() + " " + dcp::LocalTime(end).time_of_day(false, false); kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } @@ -196,7 +202,7 @@ KDMDialog::make_clicked () return; } - pair, int> result = _output->make (kdms, film->name(), _timing, bind (&KDMDialog::confirm_overwrite, this, _1)); + pair, int> result = _output->make (kdms, film->name(), bind (&KDMDialog::confirm_overwrite, this, _1)); if (result.first) { JobManager::instance()->add (result.first); } diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index 025707b28..0a70ff125 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -182,7 +182,7 @@ KDMOutputPanel::kdm_write_type_changed () pair, int> KDMOutputPanel::make ( - list kdms, string name, KDMTimingPanel* timing, function confirm_overwrite + list kdms, string name, function confirm_overwrite ) { list > const cinema_kdms = collect (kdms); @@ -240,9 +240,6 @@ KDMOutputPanel::make ( try { dcp::NameFormat::Map name_values; - name_values['f'] = name; - name_values['b'] = dcp::LocalTime(timing->from()).date() + " " + dcp::LocalTime(timing->from()).time_of_day(false, false); - name_values['e'] = dcp::LocalTime(timing->until()).date() + " " + dcp::LocalTime(timing->until()).time_of_day(false, false); if (_write_to->GetValue()) { if (_write_flat->GetValue()) { diff --git a/src/wx/kdm_output_panel.h b/src/wx/kdm_output_panel.h index fbfc1205e..0281b26d0 100644 --- a/src/wx/kdm_output_panel.h +++ b/src/wx/kdm_output_panel.h @@ -54,7 +54,6 @@ public: std::pair, int> make ( std::list screen_kdms, std::string name, - KDMTimingPanel* timing, boost::function confirm_overwrite ); -- cgit v1.2.3 From 0a1d944d74308ccb940194bcb627652c72128650 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 May 2020 15:24:36 +0200 Subject: Set 'i' earlier in name_values. --- src/lib/kdm_with_metadata.cc | 2 -- src/lib/kdm_with_metadata.h | 9 --------- src/tools/dcpomatic_kdm.cc | 16 ++++++++-------- src/tools/dcpomatic_kdm_cli.cc | 30 +++++++++++++----------------- src/wx/kdm_dialog.cc | 1 + 5 files changed, 22 insertions(+), 36 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index 62d544e0b..bf24f709d 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -66,7 +66,6 @@ write_files ( /* Write KDMs to the specified directory */ BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { - name_values['i'] = i->kdm_id (); boost::filesystem::path out = directory / careful_string_filter(name_format.get(name_values, ".xml")); if (!boost::filesystem::exists (out) || confirm_overwrite (out)) { i->kdm_as_xml (out); @@ -96,7 +95,6 @@ make_zip_file (list kdms, boost::filesystem::path zip_file, Zipper zipper (zip_file); BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { - name_values['i'] = i->kdm_id (); string const name = careful_string_filter(name_format.get(name_values, ".xml")); zipper.add (name, i->kdm_as_xml()); } diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index c2a13fced..e7b3c23ba 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -42,7 +42,6 @@ public: virtual std::string kdm_as_xml () const = 0; virtual void kdm_as_xml (boost::filesystem::path out) const = 0; - virtual std::string kdm_id () const = 0; dcp::NameFormat::Map const& name_values () const { return _name_values; @@ -121,10 +120,6 @@ public: return kdm.as_xml (out); } - std::string kdm_id () const { - return kdm.cpl_id (); - } - dcp::EncryptedKDM kdm; }; @@ -145,10 +140,6 @@ public: return kdm.as_xml (out); } - std::string kdm_id () const { - return kdm.id (); - } - EncryptedECinemaKDM kdm; }; #endif diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 7920f7e57..da856d358 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -334,6 +334,7 @@ private: name_values['f'] = title; 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.id(); /* Encrypt */ kdms.push_back ( @@ -381,24 +382,23 @@ private: kdm.add_key (j); } + dcp::EncryptedKDM const encrypted = kdm.encrypt( + signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(), + !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional() : 0 + ); + dcp::NameFormat::Map name_values; name_values['c'] = i->cinema->name; name_values['s'] = i->name; name_values['f'] = title; 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'] = encrypted.cpl_id (); /* Encrypt */ kdms.push_back ( KDMWithMetadataPtr( - new DCPKDMWithMetadata( - name_values, - i->cinema, - kdm.encrypt( - signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(), - !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional() : 0 - ) - ) + new DCPKDMWithMetadata(name_values, i->cinema, encrypted) ) ); } diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index a85624c82..6bcad22f6 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -250,6 +250,7 @@ from_film ( name_values['f'] = film->name(); name_values['b'] = dcp::LocalTime(begin).date() + " " + dcp::LocalTime(begin).time_of_day(true, false); name_values['e'] = dcp::LocalTime(end).date() + " " + dcp::LocalTime(end).time_of_day(true, false); + name_values['i'] = kdm.cpl_id(); kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } @@ -358,19 +359,7 @@ from_dkdm ( dcp::LocalTime begin(valid_from, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()); dcp::LocalTime end(valid_to, i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()); - dcp::NameFormat::Map name_values; - name_values['c'] = i->cinema->name; - name_values['s'] = i->name; - name_values['f'] = dkdm.annotation_text().get_value_or(""); - name_values['b'] = begin.date() + " " + begin.time_of_day(true, false); - name_values['e'] = end.date() + " " + end.time_of_day(true, false); - - kdms.push_back ( - KDMWithMetadataPtr( - new DCPKDMWithMetadata( - name_values, - i->cinema, - kdm_from_dkdm( + dcp::EncryptedKDM const kdm = kdm_from_dkdm( dkdm, i->recipient.get(), i->trusted_device_thumbprints(), @@ -379,10 +368,17 @@ from_dkdm ( formulation, disable_forensic_marking_picture, disable_forensic_marking_audio - ) - ) - ) - ); + ); + + dcp::NameFormat::Map name_values; + name_values['c'] = i->cinema->name; + name_values['s'] = i->name; + name_values['f'] = dkdm.annotation_text().get_value_or(""); + 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(); + + kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } write_files (kdms, zip, output, container_name_format, filename_format, values, verbose); } catch (FileError& e) { diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index d946e1d12..d74741871 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -185,6 +185,7 @@ KDMDialog::make_clicked () name_values['f'] = film->name(); name_values['b'] = dcp::LocalTime(begin).date() + " " + dcp::LocalTime(begin).time_of_day(false, false); name_values['e'] = dcp::LocalTime(end).date() + " " + dcp::LocalTime(end).time_of_day(false, false); + name_values['i'] = kdm.cpl_id(); kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } -- cgit v1.2.3 From 6a63fd3497407f4ac978205e17a358af095882be Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 May 2020 20:03:55 +0200 Subject: Remove some now-pointless passing of name_values. --- src/lib/kdm_with_metadata.cc | 41 ++++++++++++++--------------------------- src/lib/kdm_with_metadata.h | 8 ++------ src/lib/send_kdm_email_job.cc | 19 +++++++++---------- src/lib/send_kdm_email_job.h | 6 ++---- src/tools/dcpomatic_kdm_cli.cc | 8 +++----- src/wx/kdm_output_panel.cc | 5 ----- 6 files changed, 30 insertions(+), 57 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index bf24f709d..f8718386f 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -44,7 +44,6 @@ write_files ( list kdms, boost::filesystem::path directory, dcp::NameFormat name_format, - dcp::NameFormat::Map name_values, boost::function confirm_overwrite ) { @@ -66,7 +65,7 @@ write_files ( /* Write KDMs to the specified directory */ BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { - boost::filesystem::path out = directory / careful_string_filter(name_format.get(name_values, ".xml")); + boost::filesystem::path out = directory / careful_string_filter(name_format.get(i->name_values(), ".xml")); if (!boost::filesystem::exists (out) || confirm_overwrite (out)) { i->kdm_as_xml (out); ++written; @@ -90,12 +89,12 @@ KDMWithMetadata::get (char k) const void -make_zip_file (list kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) +make_zip_file (list kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format) { Zipper zipper (zip_file); BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { - string const name = careful_string_filter(name_format.get(name_values, ".xml")); + string const name = careful_string_filter(name_format.get(i->name_values(), ".xml")); zipper.add (name, i->kdm_as_xml()); } @@ -140,21 +139,17 @@ write_directories ( boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, function confirm_overwrite ) { - /* No specific screen */ - name_values['s'] = ""; - int written = 0; BOOST_FOREACH (list const & i, cinema_kdms) { boost::filesystem::path path = directory; - path /= container_name_format.get(name_values, ""); + path /= container_name_format.get(i.front()->name_values(), ""); if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { boost::filesystem::create_directories (path); - write_files (i, path, filename_format, name_values, confirm_overwrite); + write_files (i, path, filename_format, confirm_overwrite); } written += i.size(); } @@ -170,24 +165,20 @@ write_zip_files ( boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, function confirm_overwrite ) { - /* No specific screen */ - name_values['s'] = ""; - int written = 0; BOOST_FOREACH (list const & i, cinema_kdms) { boost::filesystem::path path = directory; - path /= container_name_format.get(name_values, ".zip"); + path /= container_name_format.get(i.front()->name_values(), ".zip"); if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { if (boost::filesystem::exists (path)) { /* Creating a new zip file over an existing one is an error */ boost::filesystem::remove (path); } - make_zip_file (i, path, filename_format, name_values); + make_zip_file (i, path, filename_format); written += i.size(); } } @@ -208,7 +199,6 @@ email ( list > cinema_kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, string cpl_name ) { @@ -218,9 +208,6 @@ email ( throw NetworkError (_("No mail server configured in preferences")); } - /* No specific screen */ - name_values['s'] = ""; - BOOST_FOREACH (list const & i, cinema_kdms) { if (i.front()->cinema()->emails.empty()) { @@ -229,19 +216,19 @@ email ( boost::filesystem::path zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); boost::filesystem::create_directories (zip_file); - zip_file /= container_name_format.get(name_values, ".zip"); - make_zip_file (i, zip_file, filename_format, name_values); + zip_file /= container_name_format.get(i.front()->name_values(), ".zip"); + make_zip_file (i, zip_file, filename_format); string subject = config->kdm_subject(); boost::algorithm::replace_all (subject, "$CPL_NAME", cpl_name); - boost::algorithm::replace_all (subject, "$START_TIME", name_values['b']); - boost::algorithm::replace_all (subject, "$END_TIME", name_values['e']); + boost::algorithm::replace_all (subject, "$START_TIME", i.front()->get('b').get_value_or("")); + boost::algorithm::replace_all (subject, "$END_TIME", i.front()->get('e').get_value_or("")); boost::algorithm::replace_all (subject, "$CINEMA_NAME", i.front()->cinema()->name); string body = config->kdm_email().c_str(); boost::algorithm::replace_all (body, "$CPL_NAME", cpl_name); - boost::algorithm::replace_all (body, "$START_TIME", name_values['b']); - boost::algorithm::replace_all (body, "$END_TIME", name_values['e']); + boost::algorithm::replace_all (body, "$START_TIME", i.front()->get('b').get_value_or("")); + boost::algorithm::replace_all (body, "$END_TIME", i.front()->get('e').get_value_or("")); boost::algorithm::replace_all (body, "$CINEMA_NAME", i.front()->cinema()->name); string screens; @@ -262,7 +249,7 @@ email ( email.add_bcc (config->kdm_bcc ()); } - email.add_attachment (zip_file, container_name_format.get(name_values, ".zip"), "application/zip"); + email.add_attachment (zip_file, container_name_format.get(i.front()->name_values(), ".zip"), "application/zip"); Config* c = Config::instance (); diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index 8710460ed..7309ee2d6 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -64,12 +64,11 @@ typedef boost::shared_ptr KDMWithMetadataPtr; int write_files ( std::list screen_kdms, boost::filesystem::path directory, - dcp::NameFormat name_format, dcp::NameFormat::Map name_values, - boost::function confirm_overwrite + dcp::NameFormat name_format, boost::function confirm_overwrite ); -void make_zip_file (std::list kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values); +void make_zip_file (std::list kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format); std::list > collect (std::list kdms); @@ -80,7 +79,6 @@ int write_directories ( boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, boost::function confirm_overwrite ); @@ -90,7 +88,6 @@ int write_zip_files ( boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, boost::function confirm_overwrite ); @@ -99,7 +96,6 @@ void email ( std::list > cinema_kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, std::string cpl_name ); diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 7b4d349f3..18f686717 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -29,26 +29,25 @@ using std::string; using std::list; using boost::shared_ptr; +using boost::optional; -/** @param cinema_kdms KDMs to email. +/** @param kdms KDMs to email. * @param container_name_format Format to ues for folders / ZIP files. * @param filename_format Format to use for filenames. * @param name_values Values to substitute into \p container_name_format and \p filename_format. * @param cpl_name Name of the CPL that the KDMs are for. */ SendKDMEmailJob::SendKDMEmailJob ( - list > cinema_kdms, + list > kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, string cpl_name ) : Job (shared_ptr()) , _container_name_format (container_name_format) , _filename_format (filename_format) - , _name_values (name_values) , _cpl_name (cpl_name) - , _cinema_kdms (cinema_kdms) + , _kdms (kdms) { } @@ -61,12 +60,12 @@ SendKDMEmailJob::~SendKDMEmailJob () string SendKDMEmailJob::name () const { - dcp::NameFormat::Map::const_iterator i = _name_values.find ('f'); - if (i == _name_values.end() || i->second.empty ()) { + optional f = _kdms.front().front()->get('f'); + if (!f || f->empty()) { return _("Email KDMs"); } - return String::compose (_("Email KDMs for %1"), i->second); + return String::compose (_("Email KDMs for %2"), *f); } string @@ -79,7 +78,7 @@ void SendKDMEmailJob::run () { set_progress_unknown (); - email (_cinema_kdms, _container_name_format, _filename_format, _name_values, _cpl_name); + email (_kdms, _container_name_format, _filename_format, _cpl_name); set_progress (1); set_state (FINISHED_OK); } diff --git a/src/lib/send_kdm_email_job.h b/src/lib/send_kdm_email_job.h index 7a70d555c..452c76cee 100644 --- a/src/lib/send_kdm_email_job.h +++ b/src/lib/send_kdm_email_job.h @@ -34,10 +34,9 @@ class SendKDMEmailJob : public Job { public: SendKDMEmailJob ( - std::list > cinema_kdms, + std::list > kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map name_values, std::string cpl_name ); ~SendKDMEmailJob (); @@ -49,7 +48,6 @@ public: private: dcp::NameFormat _container_name_format; dcp::NameFormat _filename_format; - dcp::NameFormat::Map _name_values; std::string _cpl_name; - std::list > _cinema_kdms; + std::list > _kdms; }; diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index 6bcad22f6..78b4201c6 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -134,7 +134,6 @@ write_files ( boost::filesystem::path output, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - dcp::NameFormat::Map values, bool verbose ) { @@ -144,7 +143,6 @@ write_files ( output, container_name_format, filename_format, - values, bind (&always_overwrite) ); @@ -153,7 +151,7 @@ write_files ( } } else { int const N = write_files ( - kdms, output, filename_format, values, + kdms, output, filename_format, bind (&always_overwrite) ); @@ -256,7 +254,7 @@ from_film ( } } - write_files (kdms, zip, output, container_name_format, filename_format, values, verbose); + write_files (kdms, zip, output, container_name_format, filename_format, verbose); } catch (FileError& e) { cerr << program_name << ": " << e.what() << " (" << e.file().string() << ")\n"; exit (EXIT_FAILURE); @@ -380,7 +378,7 @@ from_dkdm ( kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); } - write_files (kdms, zip, output, container_name_format, filename_format, values, verbose); + write_files (kdms, zip, output, container_name_format, filename_format, verbose); } catch (FileError& e) { cerr << program_name << ": " << e.what() << " (" << e.file().string() << ")\n"; exit (EXIT_FAILURE); diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index 0a70ff125..f37865b94 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -239,7 +239,6 @@ KDMOutputPanel::make ( shared_ptr job; try { - dcp::NameFormat::Map name_values; if (_write_to->GetValue()) { if (_write_flat->GetValue()) { @@ -247,7 +246,6 @@ KDMOutputPanel::make ( kdms, directory(), _filename_format->get(), - name_values, confirm_overwrite ); } else if (_write_folder->GetValue()) { @@ -256,7 +254,6 @@ KDMOutputPanel::make ( directory(), _container_name_format->get(), _filename_format->get(), - name_values, confirm_overwrite ); } else if (_write_zip->GetValue()) { @@ -265,7 +262,6 @@ KDMOutputPanel::make ( directory(), _container_name_format->get(), _filename_format->get(), - name_values, confirm_overwrite ); } @@ -277,7 +273,6 @@ KDMOutputPanel::make ( cinema_kdms, _container_name_format->get(), _filename_format->get(), - name_values, name ) ); -- cgit v1.2.3 From 8f12e84009d7c2685bb2eeb32665876463d4e6e5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 May 2020 22:28:25 +0200 Subject: Extract common code out into kdm_for_screen() --- src/lib/screen.cc | 54 +++++++++++++++++++++++++++++++++++++++++- src/lib/screen.h | 15 ++++++++++++ src/tools/dcpomatic_kdm_cli.cc | 32 +++---------------------- src/wx/kdm_dialog.cc | 30 +++-------------------- 4 files changed, 74 insertions(+), 57 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/screen.cc b/src/lib/screen.cc index fe62a5e6c..632370810 100644 --- a/src/lib/screen.cc +++ b/src/lib/screen.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2016 Carl Hetherington + Copyright (C) 2013-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -19,12 +19,18 @@ */ #include "screen.h" +#include "kdm_with_metadata.h" +#include "film.h" +#include "cinema.h" #include #include #include +#include using std::string; using std::vector; +using boost::shared_ptr; +using boost::optional; using namespace dcpomatic; Screen::Screen (cxml::ConstNodePtr node) @@ -102,3 +108,49 @@ TrustedDevice::thumbprint () const return *_thumbprint; } + + +KDMWithMetadataPtr +kdm_for_screen ( + shared_ptr film, + boost::filesystem::path cpl, + shared_ptr screen, + boost::posix_time::ptime valid_from, + boost::posix_time::ptime valid_to, + dcp::Formulation formulation, + bool disable_forensic_marking_picture, + optional disable_forensic_marking_audio + ) +{ + if (!screen->recipient) { + return KDMWithMetadataPtr(); + } + + shared_ptr cinema = screen->cinema; + dcp::LocalTime const begin(valid_from, cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0); + dcp::LocalTime const end (valid_to, cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0); + + dcp::EncryptedKDM const kdm = film->make_kdm ( + screen->recipient.get(), + screen->trusted_device_thumbprints(), + cpl, + begin, + end, + formulation, + disable_forensic_marking_picture, + disable_forensic_marking_audio + ); + + dcp::NameFormat::Map name_values; + if (cinema) { + name_values['c'] = cinema->name; + } + name_values['s'] = screen->name; + name_values['f'] = film->name(); + 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, cinema, kdm)); +} + diff --git a/src/lib/screen.h b/src/lib/screen.h index 40990b684..33c7f280c 100644 --- a/src/lib/screen.h +++ b/src/lib/screen.h @@ -21,12 +21,14 @@ #ifndef DCPOMATIC_SCREEN_H #define DCPOMATIC_SCREEN_H +#include "kdm_with_metadata.h" #include #include #include #include class Cinema; +class Film; class TrustedDevice { @@ -79,4 +81,17 @@ public: } +KDMWithMetadataPtr +kdm_for_screen ( + boost::shared_ptr film, + boost::filesystem::path cpl, + boost::shared_ptr screen, + boost::posix_time::ptime valid_from, + boost::posix_time::ptime valid_to, + dcp::Formulation formulation, + bool disable_forensic_marking_picture, + boost::optional disable_forensic_marking_audio + ); + + #endif diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index 78b4201c6..a3075d675 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -220,40 +220,14 @@ from_film ( boost::filesystem::path cpl = cpls.front().cpl_file; - dcp::NameFormat::Map values; - try { list kdms; - BOOST_FOREACH (shared_ptr i, screens) { - if (i->recipient) { - - dcp::LocalTime const begin(valid_from, i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0); - dcp::LocalTime const end(valid_to, i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0); - - dcp::EncryptedKDM const kdm = film->make_kdm ( - i->recipient.get(), - i->trusted_device_thumbprints(), - cpl, - begin, - end, - formulation, - disable_forensic_marking_picture, - disable_forensic_marking_audio - ); - - dcp::NameFormat::Map name_values; - name_values['c'] = i->cinema->name; - name_values['s'] = i->name; - name_values['f'] = film->name(); - name_values['b'] = dcp::LocalTime(begin).date() + " " + dcp::LocalTime(begin).time_of_day(true, false); - name_values['e'] = dcp::LocalTime(end).date() + " " + dcp::LocalTime(end).time_of_day(true, false); - name_values['i'] = kdm.cpl_id(); - - kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); + KDMWithMetadataPtr p = kdm_for_screen (film, cpl, i, valid_from, valid_to, formulation, disable_forensic_marking_picture, disable_forensic_marking_audio); + if (p) { + kdms.push_back (p); } } - write_files (kdms, zip, output, container_name_format, filename_format, verbose); } catch (FileError& e) { cerr << program_name << ": " << e.what() << " (" << e.file().string() << ")\n"; diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index d74741871..d3bbf02c9 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -162,35 +162,11 @@ KDMDialog::make_clicked () } BOOST_FOREACH (shared_ptr i, _screens->screens()) { - if (i->recipient) { - dcp::LocalTime const begin(_timing->from(), i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0); - dcp::LocalTime const end(_timing->until(), i->cinema ? i->cinema->utc_offset_hour() : 0, i->cinema ? i->cinema->utc_offset_minute() : 0); - - dcp::EncryptedKDM const kdm = film->make_kdm ( - i->recipient.get(), - i->trusted_device_thumbprints(), - _cpl->cpl(), - begin, - end, - _output->formulation(), - !_output->forensic_mark_video(), - for_audio - ); - - dcp::NameFormat::Map name_values; - if (i->cinema) { - name_values['c'] = i->cinema->name; - } - name_values['s'] = i->name; - name_values['f'] = film->name(); - name_values['b'] = dcp::LocalTime(begin).date() + " " + dcp::LocalTime(begin).time_of_day(false, false); - name_values['e'] = dcp::LocalTime(end).date() + " " + dcp::LocalTime(end).time_of_day(false, false); - name_values['i'] = kdm.cpl_id(); - - kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); + KDMWithMetadataPtr p = kdm_for_screen (film, _cpl->cpl(), i, _timing->from(), _timing->until(), _output->formulation(), !_output->forensic_mark_video(), for_audio); + if (p) { + kdms.push_back (p); } } - } catch (dcp::BadKDMDateError& e) { if (e.starts_too_early()) { error_dialog (this, _("The KDM start period is before (or close to) the start of the signing certificate's validity period. Use a later start time for this KDM.")); -- cgit v1.2.3 From 581797d640af1572f884ddf4395924894b745b3a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 7 May 2020 00:00:40 +0200 Subject: Add a 'Make DKDM' dialogue box to simplify and (hopefully) clarify DKDM creation (#1637). --- src/lib/kdm_with_metadata.cc | 28 ++++++++++++++-------------- src/lib/kdm_with_metadata.h | 26 ++++++++++++++++---------- src/lib/screen.cc | 3 ++- src/lib/send_kdm_email_job.cc | 18 ++++++++++++++++++ src/lib/send_kdm_email_job.h | 8 ++++++++ src/lib/wscript | 1 + src/tools/dcpomatic.cc | 21 +++++++++++++++++++++ src/tools/dcpomatic_kdm.cc | 2 +- src/tools/dcpomatic_kdm_cli.cc | 2 +- src/wx/cinema_dialog.cc | 31 +------------------------------ src/wx/cinema_dialog.h | 14 -------------- src/wx/kdm_output_panel.cc | 5 +++-- src/wx/wscript | 4 ++++ src/wx/wx_util.cc | 37 +++++++++++++++++++++++++++++++++++++ src/wx/wx_util.h | 17 +++++++++++++++++ test/kdm_naming_test.cc | 1 - 16 files changed, 144 insertions(+), 74 deletions(-) (limited to 'src/tools/dcpomatic_kdm_cli.cc') diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index 08b6dbbab..0ef1b8f38 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -103,7 +103,7 @@ make_zip_file (list kdms, boost::filesystem::path zip_file, /** Collect a list of KDMWithMetadatas into a list of lists so that - * each list contains the KDMs for one cinema. + * each list contains the KDMs for one list. */ list > collect (list kdms) @@ -115,7 +115,7 @@ collect (list kdms) list >::iterator j = grouped.begin (); while (j != grouped.end()) { - if (j->front()->cinema() == i->cinema()) { + if (j->front()->group() == i->group()) { j->push_back (i); break; } @@ -132,10 +132,10 @@ collect (list kdms) } -/** Write one directory per cinema into another directory */ +/** Write one directory per list into another directory */ int write_directories ( - list > cinema_kdms, + list > kdms, boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, @@ -144,7 +144,7 @@ write_directories ( { int written = 0; - BOOST_FOREACH (list const & i, cinema_kdms) { + BOOST_FOREACH (list const & i, kdms) { boost::filesystem::path path = directory; path /= container_name_format.get(i.front()->name_values(), "", "s"); if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { @@ -161,7 +161,7 @@ write_directories ( /** Write one ZIP file per cinema into a directory */ int write_zip_files ( - list > cinema_kdms, + list > kdms, boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, @@ -170,7 +170,7 @@ write_zip_files ( { int written = 0; - BOOST_FOREACH (list const & i, cinema_kdms) { + BOOST_FOREACH (list const & i, kdms) { boost::filesystem::path path = directory; path /= container_name_format.get(i.front()->name_values(), ".zip", "s"); if (!boost::filesystem::exists (path) || confirm_overwrite (path)) { @@ -188,7 +188,7 @@ write_zip_files ( /** Email one ZIP file per cinema to the cinema. - * @param cinema_kdms KDMS to email. + * @param kdms KDMs to email. * @param container_name_format Format of folder / ZIP to use. * @param filename_format Format of filenames to use. * @param name_values Values to substitute into \p container_name_format and \p filename_format. @@ -196,7 +196,7 @@ write_zip_files ( */ void email ( - list > cinema_kdms, + list > kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, string cpl_name @@ -208,9 +208,9 @@ email ( throw NetworkError (_("No mail server configured in preferences")); } - BOOST_FOREACH (list const & i, cinema_kdms) { + BOOST_FOREACH (list const & i, kdms) { - if (i.front()->cinema()->emails.empty()) { + if (i.front()->emails().empty()) { continue; } @@ -223,13 +223,13 @@ email ( boost::algorithm::replace_all (subject, "$CPL_NAME", cpl_name); boost::algorithm::replace_all (subject, "$START_TIME", i.front()->get('b').get_value_or("")); boost::algorithm::replace_all (subject, "$END_TIME", i.front()->get('e').get_value_or("")); - boost::algorithm::replace_all (subject, "$CINEMA_NAME", i.front()->cinema()->name); + boost::algorithm::replace_all (subject, "$CINEMA_NAME", i.front()->get('c').get_value_or("")); string body = config->kdm_email().c_str(); boost::algorithm::replace_all (body, "$CPL_NAME", cpl_name); boost::algorithm::replace_all (body, "$START_TIME", i.front()->get('b').get_value_or("")); boost::algorithm::replace_all (body, "$END_TIME", i.front()->get('e').get_value_or("")); - boost::algorithm::replace_all (body, "$CINEMA_NAME", i.front()->cinema()->name); + boost::algorithm::replace_all (body, "$CINEMA_NAME", i.front()->get('c').get_value_or("")); string screens; BOOST_FOREACH (KDMWithMetadataPtr j, i) { @@ -240,7 +240,7 @@ email ( } boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2)); - Emailer email (config->kdm_from(), i.front()->cinema()->emails, subject, body); + Emailer email (config->kdm_from(), i.front()->emails(), subject, body); BOOST_FOREACH (string i, config->kdm_cc()) { email.add_cc (i); diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index 6b9ff23c7..b6bec1c4c 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -33,9 +33,10 @@ class Cinema; class KDMWithMetadata { public: - KDMWithMetadata (dcp::NameFormat::Map const& name_values, boost::shared_ptr cinema) + KDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list emails) : _name_values (name_values) - , _cinema (cinema) + , _group (group) + , _emails (emails) {} virtual ~KDMWithMetadata () {} @@ -49,13 +50,18 @@ public: boost::optional get (char k) const; - boost::shared_ptr cinema () const { - return _cinema; + void const* group () const { + return _group; + } + + std::list emails () const { + return _emails; } private: dcp::NameFormat::Map _name_values; - boost::shared_ptr _cinema; + void const* _group; + std::list _emails; }; @@ -75,7 +81,7 @@ std::list > collect (std::list int write_directories ( - std::list > cinema_kdms, + std::list > kdms, boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, @@ -84,7 +90,7 @@ int write_directories ( int write_zip_files ( - std::list > cinema_kdms, + std::list > kdms, boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, @@ -93,7 +99,7 @@ int write_zip_files ( void email ( - std::list > cinema_kdms, + std::list > kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, std::string cpl_name @@ -104,8 +110,8 @@ template class SpecialKDMWithMetadata : public KDMWithMetadata { public: - SpecialKDMWithMetadata (dcp::NameFormat::Map const& name_values, boost::shared_ptr cinema, T k) - : KDMWithMetadata (name_values, cinema) + SpecialKDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list emails, T k) + : KDMWithMetadata (name_values, group, emails) , kdm (k) {} diff --git a/src/lib/screen.cc b/src/lib/screen.cc index 2441efccb..61a27f2bc 100644 --- a/src/lib/screen.cc +++ b/src/lib/screen.cc @@ -29,6 +29,7 @@ using std::string; using std::vector; +using std::list; using boost::shared_ptr; using boost::optional; using namespace dcpomatic; @@ -106,6 +107,6 @@ kdm_for_screen ( name_values['e'] = end.date() + " " + end.time_of_day(true, false); name_values['i'] = kdm.cpl_id(); - return KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, cinema, kdm)); + return KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, cinema.get(), cinema ? cinema->emails : list(), kdm)); } diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 18f686717..55a171811 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -31,6 +31,24 @@ using std::list; using boost::shared_ptr; using boost::optional; +SendKDMEmailJob::SendKDMEmailJob ( + list kdms, + dcp::NameFormat container_name_format, + dcp::NameFormat filename_format, + string cpl_name + ) + : Job (shared_ptr()) + , _container_name_format (container_name_format) + , _filename_format (filename_format) + , _cpl_name (cpl_name) +{ + BOOST_FOREACH (KDMWithMetadataPtr i, kdms) { + list s; + s.push_back (i); + _kdms.push_back (s); + } +} + /** @param kdms KDMs to email. * @param container_name_format Format to ues for folders / ZIP files. * @param filename_format Format to use for filenames. diff --git a/src/lib/send_kdm_email_job.h b/src/lib/send_kdm_email_job.h index 452c76cee..fa409edaa 100644 --- a/src/lib/send_kdm_email_job.h +++ b/src/lib/send_kdm_email_job.h @@ -33,12 +33,20 @@ class Log; class SendKDMEmailJob : public Job { public: + SendKDMEmailJob ( + std::list kdms, + dcp::NameFormat container_name_format, + dcp::NameFormat filename_format, + std::string cpl_name + ); + SendKDMEmailJob ( std::list > kdms, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, std::string cpl_name ); + ~SendKDMEmailJob (); std::string name () const; diff --git a/src/lib/wscript b/src/lib/wscript index 828f0290b..0f2a5d197 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -77,6 +77,7 @@ sources = """ decoder_part.cc decrypted_ecinema_kdm.cc digester.cc + dkdm_recipient.cc dkdm_wrapper.cc dolby_cp750.cc edid.cc diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 546286e48..f69ab5a6a 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -33,6 +33,7 @@ #include "wx/recreate_chain_dialog.h" #include "wx/about_dialog.h" #include "wx/kdm_dialog.h" +#include "wx/dkdm_dialog.h" #include "wx/self_dkdm_dialog.h" #include "wx/servers_list_dialog.h" #include "wx/hints_dialog.h" @@ -226,6 +227,7 @@ enum { ID_jobs_make_dcp, ID_jobs_make_dcp_batch, ID_jobs_make_kdms, + ID_jobs_make_dkdms, ID_jobs_make_self_dkdm, ID_jobs_export, ID_jobs_send_dcp_to_tms, @@ -261,6 +263,7 @@ public: , _servers_list_dialog (0) , _config_dialog (0) , _kdm_dialog (0) + , _dkdm_dialog (0) , _templates_dialog (0) , _file_menu (0) , _history_items (0) @@ -317,6 +320,7 @@ public: Bind (wxEVT_MENU, boost::bind (&DOMFrame::content_scale_to_fit_height, this), ID_content_scale_to_fit_height); Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_make_dcp, this), ID_jobs_make_dcp); Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_make_kdms, this), ID_jobs_make_kdms); + Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_make_dkdms, this), ID_jobs_make_dkdms); Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_make_dcp_batch, this), ID_jobs_make_dcp_batch); Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_make_self_dkdm, this), ID_jobs_make_self_dkdm); Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_export, this), ID_jobs_export); @@ -796,6 +800,21 @@ private: _kdm_dialog->Show (); } + void jobs_make_dkdms () + { + if (!_film) { + return; + } + + if (_dkdm_dialog) { + _dkdm_dialog->Destroy (); + _dkdm_dialog = 0; + } + + _dkdm_dialog = new DKDMDialog (this, _film); + _dkdm_dialog->Show (); + } + /** @return false if we succeeded, true if not */ bool send_to_other_tool (int port, function start, string message) { @@ -1313,6 +1332,7 @@ private: add_item (jobs_menu, _("Make DCP in &batch converter\tCtrl-B"), ID_jobs_make_dcp_batch, NEEDS_FILM | NOT_DURING_DCP_CREATION); jobs_menu->AppendSeparator (); add_item (jobs_menu, _("Make &KDMs...\tCtrl-K"), ID_jobs_make_kdms, NEEDS_FILM); + add_item (jobs_menu, _("Make &DKDMs...\tCtrl-D"), ID_jobs_make_dkdms, NEEDS_FILM); add_item (jobs_menu, _("Make DKDM for DCP-o-matic..."), ID_jobs_make_self_dkdm, NEEDS_FILM | NEEDS_ENCRYPTION); jobs_menu->AppendSeparator (); add_item (jobs_menu, _("Export...\tCtrl-E"), ID_jobs_export, NEEDS_FILM); @@ -1484,6 +1504,7 @@ private: ServersListDialog* _servers_list_dialog; wxPreferencesEditor* _config_dialog; KDMDialog* _kdm_dialog; + DKDMDialog* _dkdm_dialog; TemplatesDialog* _templates_dialog; wxMenu* _file_menu; shared_ptr _film; diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index da856d358..117e756c7 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -398,7 +398,7 @@ private: /* Encrypt */ kdms.push_back ( KDMWithMetadataPtr( - new DCPKDMWithMetadata(name_values, i->cinema, encrypted) + new DCPKDMWithMetadata(name_values, i->cinema.get(), i->cinema->emails, encrypted) ) ); } diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index a3075d675..adb14f49e 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -350,7 +350,7 @@ from_dkdm ( name_values['e'] = end.date() + " " + end.time_of_day(true, false); name_values['i'] = kdm.cpl_id(); - kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema, kdm))); + kdms.push_back (KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, i->cinema.get(), i->cinema->emails, kdm))); } write_files (kdms, zip, output, container_name_format, filename_format, verbose); } catch (FileError& e) { diff --git a/src/wx/cinema_dialog.cc b/src/wx/cinema_dialog.cc index ff5d1faf6..31e6ebe79 100644 --- a/src/wx/cinema_dialog.cc +++ b/src/wx/cinema_dialog.cc @@ -83,37 +83,8 @@ CinemaDialog::CinemaDialog (wxWindow* parent, wxString title, string name, list< overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } - _offsets.push_back (Offset (_("UTC-11"), -11, 0)); - _offsets.push_back (Offset (_("UTC-10"), -10, 0)); - _offsets.push_back (Offset (_("UTC-9"), -9, 0)); - _offsets.push_back (Offset (_("UTC-8"), -8, 0)); - _offsets.push_back (Offset (_("UTC-7"), -7, 0)); - _offsets.push_back (Offset (_("UTC-6"), -6, 0)); - _offsets.push_back (Offset (_("UTC-5"), -5, 0)); - _offsets.push_back (Offset (_("UTC-4:30"), -4, 30)); - _offsets.push_back (Offset (_("UTC-4"), -4, 0)); - _offsets.push_back (Offset (_("UTC-3:30"), -3, 30)); - _offsets.push_back (Offset (_("UTC-3"), -3, 0)); - _offsets.push_back (Offset (_("UTC-2"), -2, 0)); - _offsets.push_back (Offset (_("UTC-1"), -1, 0)); - _offsets.push_back (Offset (_("UTC") , 0, 0)); - _offsets.push_back (Offset (_("UTC+1"), 1, 0)); - _offsets.push_back (Offset (_("UTC+2"), 2, 0)); - _offsets.push_back (Offset (_("UTC+3"), 3, 0)); - _offsets.push_back (Offset (_("UTC+4"), 4, 0)); - _offsets.push_back (Offset (_("UTC+5"), 5, 0)); - _offsets.push_back (Offset (_("UTC+5:30"), 5, 30)); - _offsets.push_back (Offset (_("UTC+6"), 6, 0)); - _offsets.push_back (Offset (_("UTC+7"), 7, 0)); - _offsets.push_back (Offset (_("UTC+8"), 8, 0)); - _offsets.push_back (Offset (_("UTC+9"), 9, 0)); - _offsets.push_back (Offset (_("UTC+9:30"), 9, 30)); - _offsets.push_back (Offset (_("UTC+10"), 10, 0)); - _offsets.push_back (Offset (_("UTC+11"), 11, 0)); - _offsets.push_back (Offset (_("UTC+12"), 12, 0)); - /* Default to UTC */ - size_t sel = 13; + size_t sel = get_offsets (_offsets); for (size_t i = 0; i < _offsets.size(); ++i) { _utc_offset->Append (_offsets[i].name); if (_offsets[i].hour == utc_offset_hour && _offsets[i].minute == utc_offset_minute) { diff --git a/src/wx/cinema_dialog.h b/src/wx/cinema_dialog.h index 9cb0a65dc..d16b0ba9c 100644 --- a/src/wx/cinema_dialog.h +++ b/src/wx/cinema_dialog.h @@ -53,19 +53,5 @@ private: EditableList* _email_list; std::vector _emails; wxChoice* _utc_offset; - - struct Offset - { - Offset (wxString n, int h, int m) - : name (n) - , hour (h) - , minute (m) - {} - - wxString name; - int hour; - int minute; - }; - std::vector _offsets; }; diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc index f37865b94..a345d0e96 100644 --- a/src/wx/kdm_output_panel.cc +++ b/src/wx/kdm_output_panel.cc @@ -53,6 +53,7 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent, bool interop) , _forensic_mark_audio_up_to (12) { wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, 0); + table->AddGrowableCol (1); add_label_to_sizer (table, this, _("KDM type"), true); @@ -200,7 +201,7 @@ KDMOutputPanel::make ( bool cinemas_with_no_email = false; BOOST_FOREACH (list i, cinema_kdms) { - if (i.front()->cinema()->emails.empty ()) { + if (i.front()->emails().empty()) { cinemas_with_no_email = true; } } @@ -215,7 +216,7 @@ KDMOutputPanel::make ( if (proceed && Config::instance()->confirm_kdm_email ()) { list emails; BOOST_FOREACH (list const& i, cinema_kdms) { - BOOST_FOREACH (string j, i.front()->cinema()->emails) { + BOOST_FOREACH (string j, i.front()->emails()) { emails.push_back (j); } } diff --git a/src/wx/wscript b/src/wx/wscript index f78a8c617..22d9f0db6 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -52,12 +52,14 @@ sources = """ dcp_panel.cc dcpomatic_button.cc disk_warning_dialog.cc + dkdm_output_panel.cc drive_wipe_warning_dialog.cc email_dialog.cc image_sequence_dialog.cc isdcf_metadata_dialog.cc dcp_text_track_dialog.cc dir_picker_ctrl.cc + dkdm_dialog.cc dolby_doremi_certificate_panel.cc download_certificate_dialog.cc download_certificate_panel.cc @@ -110,6 +112,8 @@ sources = """ question_dialog.cc rating_dialog.cc qube_certificate_panel.cc + recipients_panel.cc + recipient_dialog.cc recreate_chain_dialog.cc repeat_dialog.cc report_problem_dialog.cc diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 28f79431a..6eef0d147 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -530,3 +530,40 @@ display_progress (wxString title, wxString task) return ok; } + + +int +get_offsets (vector& offsets) +{ + offsets.push_back (Offset(_("UTC-11"), -11, 0)); + offsets.push_back (Offset(_("UTC-10"), -10, 0)); + offsets.push_back (Offset(_("UTC-9"), -9, 0)); + offsets.push_back (Offset(_("UTC-8"), -8, 0)); + offsets.push_back (Offset(_("UTC-7"), -7, 0)); + offsets.push_back (Offset(_("UTC-6"), -6, 0)); + offsets.push_back (Offset(_("UTC-5"), -5, 0)); + offsets.push_back (Offset(_("UTC-4:30"), -4, 30)); + offsets.push_back (Offset(_("UTC-4"), -4, 0)); + offsets.push_back (Offset(_("UTC-3:30"), -3, 30)); + offsets.push_back (Offset(_("UTC-3"), -3, 0)); + offsets.push_back (Offset(_("UTC-2"), -2, 0)); + offsets.push_back (Offset(_("UTC-1"), -1, 0)); + int utc = offsets.size(); + offsets.push_back (Offset(_("UTC") , 0, 0)); + offsets.push_back (Offset(_("UTC+1"), 1, 0)); + offsets.push_back (Offset(_("UTC+2"), 2, 0)); + offsets.push_back (Offset(_("UTC+3"), 3, 0)); + offsets.push_back (Offset(_("UTC+4"), 4, 0)); + offsets.push_back (Offset(_("UTC+5"), 5, 0)); + offsets.push_back (Offset(_("UTC+5:30"), 5, 30)); + offsets.push_back (Offset(_("UTC+6"), 6, 0)); + offsets.push_back (Offset(_("UTC+7"), 7, 0)); + offsets.push_back (Offset(_("UTC+8"), 8, 0)); + offsets.push_back (Offset(_("UTC+9"), 9, 0)); + offsets.push_back (Offset(_("UTC+9:30"), 9, 30)); + offsets.push_back (Offset(_("UTC+10"), 10, 0)); + offsets.push_back (Offset(_("UTC+11"), 11, 0)); + offsets.push_back (Offset(_("UTC+12"), 12, 0)); + + return utc; +} diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index af25ce0f5..8e0befba9 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -88,6 +88,23 @@ extern double calculate_mark_interval (double start); extern bool display_progress (wxString title, wxString task); extern bool report_errors_from_last_job (wxWindow* parent); + +struct Offset +{ + Offset (wxString n, int h, int m) + : name (n) + , hour (h) + , minute (m) + {} + + wxString name; + int hour; + int minute; +}; + +extern int get_offsets (std::vector& offsets); + + extern void checked_set (FilePickerCtrl* widget, boost::filesystem::path value); extern void checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value); extern void checked_set (wxSpinCtrl* widget, int value); diff --git a/test/kdm_naming_test.cc b/test/kdm_naming_test.cc index d45e4a44e..35188d5e6 100644 --- a/test/kdm_naming_test.cc +++ b/test/kdm_naming_test.cc @@ -191,7 +191,6 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on( boost::algorithm::replace_all (until_time, ":", "-"); path const base = "build/test/directory_kdm_naming_test"; - list::const_iterator i = kdms.begin (); path dir_a = String::compose("Cinema_A_-_%s_-_my_great_film_-_%1_%2_-_%3_%4", from.date(), from_time, until.date(), until_time); BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a), "Directory " << dir_a << " not found"); -- cgit v1.2.3