2 Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "compose.hpp"
24 #include "kdm_with_metadata.h"
25 #include "send_kdm_email_job.h"
32 using std::shared_ptr;
35 using boost::optional;
38 SendKDMEmailJob::SendKDMEmailJob (
39 list<KDMWithMetadataPtr> kdms,
40 dcp::NameFormat container_name_format,
41 dcp::NameFormat filename_format,
43 vector<string> extra_addresses
45 : Job (shared_ptr<Film>())
46 , _container_name_format (container_name_format)
47 , _filename_format (filename_format)
48 , _cpl_name (cpl_name)
49 , _extra_addresses (extra_addresses)
52 list<KDMWithMetadataPtr> s;
59 /** @param kdms KDMs to email.
60 * @param container_name_format Format to use for folders / ZIP files.
61 * @param filename_format Format to use for filenames.
62 * @param name_values Values to substitute into \p container_name_format and \p filename_format.
63 * @param cpl_name Name of the CPL that the KDMs are for.
65 SendKDMEmailJob::SendKDMEmailJob (
66 list<list<KDMWithMetadataPtr>> kdms,
67 dcp::NameFormat container_name_format,
68 dcp::NameFormat filename_format,
70 vector<string> extra_addresses
72 : Job (shared_ptr<Film>())
73 , _container_name_format (container_name_format)
74 , _filename_format (filename_format)
75 , _cpl_name (cpl_name)
77 , _extra_addresses (extra_addresses)
83 SendKDMEmailJob::~SendKDMEmailJob ()
90 SendKDMEmailJob::name () const
92 auto f = _kdms.front().front()->get('f');
93 if (!f || f->empty()) {
94 return _("Email KDMs");
97 return String::compose (_("Email KDMs for %1"), *f);
102 SendKDMEmailJob::json_name () const
104 return N_("send_kdm_email");
109 SendKDMEmailJob::run ()
111 set_progress_unknown ();
112 send_emails (_kdms, _container_name_format, _filename_format, _cpl_name, _extra_addresses);
114 set_state (FINISHED_OK);