From: Carl Hetherington Date: Tue, 5 May 2020 18:03:55 +0000 (+0200) Subject: Remove some now-pointless passing of name_values. X-Git-Tag: v2.15.72~6^2~9 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=6a63fd3497407f4ac978205e17a358af095882be Remove some now-pointless passing of name_values. --- 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 ) );