From 61dfa6671f042eda2267d7c179ad0468d9bdb5d0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 5 May 2020 22:28:35 +0200 Subject: Add some unit tests. --- test/kdm_naming_test.cc | 213 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 test/kdm_naming_test.cc (limited to 'test/kdm_naming_test.cc') diff --git a/test/kdm_naming_test.cc b/test/kdm_naming_test.cc new file mode 100644 index 000000000..d45e4a44e --- /dev/null +++ b/test/kdm_naming_test.cc @@ -0,0 +1,213 @@ +/* + Copyright (C) 2020 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 "lib/cinema.h" +#include "lib/screen.h" +#include "lib/config.h" +#include "lib/content_factory.h" +#include "lib/film.h" +#include "lib/kdm_with_metadata.h" +#include "test.h" +#include +#include + +using std::list; +using std::string; +using std::vector; +using boost::shared_ptr; +using boost::optional; +using boost::dynamic_pointer_cast; + +static +bool +confirm_overwrite (boost::filesystem::path) +{ + return true; +} + +static shared_ptr cinema_a_screen_1; +static shared_ptr cinema_a_screen_2; +static shared_ptr cinema_b_screen_x; +static shared_ptr cinema_b_screen_y; +static shared_ptr cinema_b_screen_z; + +BOOST_AUTO_TEST_CASE (single_kdm_naming_test) +{ + Config* c = Config::instance(); + + dcp::Certificate cert = c->decryption_chain()->leaf(); + + /* Cinema A: UTC +4:30 */ + shared_ptr cinema_a (new Cinema("Cinema A", list(), "", 4, 30)); + cinema_a_screen_1.reset(new dcpomatic::Screen("Screen 1", "", cert, vector())); + cinema_a->add_screen (cinema_a_screen_1); + cinema_a_screen_2.reset(new dcpomatic::Screen("Screen 2", "", cert, vector())); + cinema_a->add_screen (cinema_a_screen_2); + c->add_cinema (cinema_a); + + /* Cinema B: UTC -1:00 */ + shared_ptr cinema_b (new Cinema("Cinema B", list(), "", -1, 0)); + cinema_b_screen_x.reset(new dcpomatic::Screen("Screen X", "", cert, vector())); + cinema_b->add_screen (cinema_b_screen_x); + cinema_b_screen_y.reset(new dcpomatic::Screen("Screen Y", "", cert, vector())); + cinema_b->add_screen (cinema_b_screen_y); + cinema_b_screen_z.reset(new dcpomatic::Screen("Screen Z", "", cert, vector())); + cinema_b->add_screen (cinema_b_screen_z); + c->add_cinema (cinema_a); + + /* Film */ + boost::filesystem::remove_all ("build/test/single_kdm_naming_test"); + shared_ptr film = new_test_film2 ("single_kdm_naming_test"); + film->set_name ("my_great_film"); + film->examine_and_add_content (content_factory("test/data/flat_black.png").front()); + BOOST_REQUIRE (!wait_for_jobs()); + film->set_encrypted (true); + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + film->write_metadata (); + vector cpls = film->cpls (); + BOOST_REQUIRE(cpls.size() == 1); + + dcp::LocalTime from (cert.not_before()); + from.add_months (2); + dcp::LocalTime until (cert.not_after()); + until.add_months (-2); + + string const from_string = from.date() + " " + from.time_of_day(true, false); + string const until_string = until.date() + " " + until.time_of_day(true, false); + + boost::filesystem::path cpl = cpls.front().cpl_file; + KDMWithMetadataPtr kdm = kdm_for_screen ( + film, + cpls.front().cpl_file, + cinema_a_screen_1, + boost::posix_time::time_from_string(from_string), + boost::posix_time::time_from_string(until_string), + dcp::MODIFIED_TRANSITIONAL_1, + false, + optional() + ); + + list kdms; + kdms.push_back (kdm); + + write_files ( + kdms, + boost::filesystem::path("build/test/single_kdm_naming_test"), + dcp::NameFormat("KDM %c - %s - %f - %b - %e"), + &confirm_overwrite + ); + + string from_time = from.time_of_day (true, false); + boost::algorithm::replace_all (from_time, ":", "-"); + string until_time = until.time_of_day (true, false); + boost::algorithm::replace_all (until_time, ":", "-"); + + string const ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time); + BOOST_CHECK_MESSAGE (boost::filesystem::exists("build/test/single_kdm_naming_test/" + ref), "File " << ref << " not found"); +} + + +BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on("single_kdm_naming_test")) +{ + using boost::filesystem::path; + + dcp::Certificate cert = Config::instance()->decryption_chain()->leaf(); + + /* Film */ + boost::filesystem::remove_all ("build/test/directory_kdm_naming_test"); + shared_ptr film = new_test_film2 ("directory_kdm_naming_test"); + film->set_name ("my_great_film"); + film->examine_and_add_content (content_factory("test/data/flat_black.png").front()); + BOOST_REQUIRE (!wait_for_jobs()); + film->set_encrypted (true); + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + film->write_metadata (); + vector cpls = film->cpls (); + BOOST_REQUIRE(cpls.size() == 1); + + dcp::LocalTime from (cert.not_before()); + from.add_months (2); + dcp::LocalTime until (cert.not_after()); + until.add_months (-2); + + string const from_string = from.date() + " " + from.time_of_day(true, false); + string const until_string = until.date() + " " + until.time_of_day(true, false); + + list > screens; + screens.push_back (cinema_a_screen_2); + screens.push_back (cinema_b_screen_x); + screens.push_back (cinema_a_screen_1); + screens.push_back (cinema_b_screen_z); + + path const cpl = cpls.front().cpl_file; + string const cpl_id = cpls.front().cpl_id; + + list kdms; + BOOST_FOREACH (shared_ptr i, screens) { + KDMWithMetadataPtr kdm = kdm_for_screen ( + film, + cpls.front().cpl_file, + i, + boost::posix_time::time_from_string(from_string), + boost::posix_time::time_from_string(until_string), + dcp::MODIFIED_TRANSITIONAL_1, + false, + optional() + ); + + kdms.push_back (kdm); + } + + write_directories ( + collect(kdms), + path("build/test/directory_kdm_naming_test"), + dcp::NameFormat("%c - %s - %f - %b - %e"), + dcp::NameFormat("KDM %c - %s - %f - %b - %e - %i"), + &confirm_overwrite + ); + + string from_time = from.time_of_day (true, false); + boost::algorithm::replace_all (from_time, ":", "-"); + string until_time = until.time_of_day (true, false); + 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"); + path dir_b = String::compose("Cinema_B_-_%s_-_my_great_film_-_%1_%2_-_%3_%4", from.date(), from_time, until.date(), until_time); + BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b), "Directory " << dir_b << " not found"); + + path ref = String::compose("KDM_Cinema_A_-_Screen_2_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id); + BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a / ref), "File " << ref << " not found"); + + ref = String::compose("KDM_Cinema_B_-_Screen_X_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id); + BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b / ref), "File " << ref << " not found"); + + ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id); + BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a / ref), "File " << ref << " not found"); + + ref = String::compose("KDM_Cinema_B_-_Screen_Z_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id); + BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b / ref), "File " << ref << " not found"); +} + -- 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 'test/kdm_naming_test.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