2e07334de7eca49e85c96899ffe6d739b0270637
[dcpomatic.git] / src / lib / kdm_with_metadata.h
1 /*
2     Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #ifndef DCPOMATIC_KDM_WITH_METADATA_H
22 #define DCPOMATIC_KDM_WITH_METADATA_H
23
24 #include <dcp/encrypted_kdm.h>
25 #include <dcp/name_format.h>
26 #include <boost/shared_ptr.hpp>
27
28 class Cinema;
29
30 class KDMWithMetadata
31 {
32 public:
33         KDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list<std::string> emails, dcp::EncryptedKDM kdm)
34                 : _name_values (name_values)
35                 , _group (group)
36                 , _emails (emails)
37                 , _kdm (kdm)
38         {}
39
40         std::string kdm_as_xml () const {
41                 return _kdm.as_xml ();
42         }
43
44         void kdm_as_xml (boost::filesystem::path out) const {
45                 return _kdm.as_xml (out);
46         }
47
48         dcp::NameFormat::Map const& name_values () const {
49                 return _name_values;
50         }
51
52         boost::optional<std::string> get (char k) const;
53
54         void const* group () const {
55                 return _group;
56         }
57
58         std::list<std::string> emails () const {
59                 return _emails;
60         }
61
62 private:
63         dcp::NameFormat::Map _name_values;
64         void const* _group;
65         std::list<std::string> _emails;
66         dcp::EncryptedKDM _kdm;
67 };
68
69
70 typedef boost::shared_ptr<KDMWithMetadata> KDMWithMetadataPtr;
71
72
73 int write_files (
74         std::list<KDMWithMetadataPtr> screen_kdms, boost::filesystem::path directory,
75         dcp::NameFormat name_format, boost::function<bool (boost::filesystem::path)> confirm_overwrite
76         );
77
78
79 void make_zip_file (std::list<KDMWithMetadataPtr> kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format);
80
81
82 std::list<std::list<KDMWithMetadataPtr> > collect (std::list<KDMWithMetadataPtr> kdms);
83
84
85 int write_directories (
86                 std::list<std::list<KDMWithMetadataPtr> > kdms,
87                 boost::filesystem::path directory,
88                 dcp::NameFormat container_name_format,
89                 dcp::NameFormat filename_format,
90                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
91                 );
92
93
94 int write_zip_files (
95                 std::list<std::list<KDMWithMetadataPtr> > kdms,
96                 boost::filesystem::path directory,
97                 dcp::NameFormat container_name_format,
98                 dcp::NameFormat filename_format,
99                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
100                 );
101
102
103 void email (
104                 std::list<std::list<KDMWithMetadataPtr> > kdms,
105                 dcp::NameFormat container_name_format,
106                 dcp::NameFormat filename_format,
107                 std::string cpl_name
108                 );
109
110 #endif
111