certificate validity periods when making KDMs (#2645).
}
- if (find(period_checks.begin(), period_checks.end(), KDMCertificatePeriod::KDM_OUTSIDE_CERTIFICATE) != period_checks.end()) {
+ if (find_if(
+ period_checks.begin(),
+ period_checks.end(),
+ [](KDMCertificatePeriod const& p) { return p.overlap == KDMCertificateOverlap::KDM_OUTSIDE_CERTIFICATE; }
+ ) != period_checks.end()) {
throw KDMCLIError(
"Some KDMs would have validity periods which are completely outside the recipient certificate periods. Such KDMs are very unlikely to work, so will not be created."
);
}
- if (find(period_checks.begin(), period_checks.end(), KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE) != period_checks.end()) {
+ if (find_if(
+ period_checks.begin(),
+ period_checks.end(),
+ [](KDMCertificatePeriod const& p) { return p.overlap == KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE; }
+ ) != period_checks.end()) {
out("For some of these KDMs the recipient certificate's validity period will not cover the whole of the KDM validity period. This might cause problems with the KDMs.");
}
KDMCertificatePeriod
-check_kdm_and_certificate_validity_periods(dcp::Certificate const& recipient, dcp::LocalTime kdm_from, dcp::LocalTime kdm_to)
+check_kdm_and_certificate_validity_periods(
+ string const& cinema_name,
+ string const& screen_name,
+ dcp::Certificate const& recipient,
+ dcp::LocalTime kdm_from,
+ dcp::LocalTime kdm_to
+ )
{
auto overlaps = [](dcp::LocalTime from_a, dcp::LocalTime to_a, dcp::LocalTime from_b, dcp::LocalTime to_b) {
return std::max(from_a, from_b) < std::min(to_a, to_b);
return bigger_from <= smaller_from && bigger_to >= smaller_to;
};
+ KDMCertificatePeriod period(
+ cinema_name,
+ screen_name,
+ recipient.not_before(),
+ recipient.not_after()
+ );
+
if (contains(recipient.not_before(), recipient.not_after(), kdm_from, kdm_to)) {
- return KDMCertificatePeriod::KDM_WITHIN_CERTIFICATE;
+ period.overlap = KDMCertificateOverlap::KDM_WITHIN_CERTIFICATE;
+ return period;
}
if (overlaps(recipient.not_before(), recipient.not_after(), kdm_from, kdm_to)) {
/* The KDM overlaps the certificate validity: maybe not the end of the world */
- return KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE;
+ period.overlap = KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE;
+ return period;
} else {
/* The KDM validity is totally outside the certificate validity: bad news */
- return KDMCertificatePeriod::KDM_OUTSIDE_CERTIFICATE;
+ period.overlap = KDMCertificateOverlap::KDM_OUTSIDE_CERTIFICATE;
+ return period;
}
}
}
-enum class KDMCertificatePeriod {
+enum class KDMCertificateOverlap {
KDM_WITHIN_CERTIFICATE,
KDM_OVERLAPS_CERTIFICATE,
KDM_OUTSIDE_CERTIFICATE
};
+struct KDMCertificatePeriod
+{
+ KDMCertificatePeriod(std::string cinema_name_, std::string screen_name_, dcp::LocalTime from_, dcp::LocalTime to_)
+ : cinema_name(std::move(cinema_name_))
+ , screen_name(std::move(screen_name_))
+ , from(std::move(from_))
+ , to(std::move(to_))
+ {}
+
+ std::string cinema_name;
+ std::string screen_name;
+ KDMCertificateOverlap overlap = KDMCertificateOverlap::KDM_WITHIN_CERTIFICATE;
+ dcp::LocalTime from;
+ dcp::LocalTime to;
+};
+
+
/** @param recipient Some KDM recipient certificate.
* @param kdm_from Proposed KDM start time.
* @param kdm_to Proposed KDM end time.
* @return Relationship between certificate and KDM validity periods.
*/
-KDMCertificatePeriod
-check_kdm_and_certificate_validity_periods(dcp::Certificate const& recipient, dcp::LocalTime kdm_from, dcp::LocalTime kdm_to);
+KDMCertificatePeriod check_kdm_and_certificate_validity_periods(
+ std::string const& cinema_name,
+ std::string const& screen_name,
+ dcp::Certificate const& recipient,
+ dcp::LocalTime kdm_from,
+ dcp::LocalTime kdm_to
+ );
#endif
dcp::LocalTime const begin(valid_from, dcp::UTCOffset(cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0));
dcp::LocalTime const end (valid_to, dcp::UTCOffset(cinema ? cinema->utc_offset_hour() : 0, cinema ? cinema->utc_offset_minute() : 0));
- period_checks.push_back(check_kdm_and_certificate_validity_periods(screen->recipient.get(), begin, end));
+ period_checks.push_back(check_kdm_and_certificate_validity_periods(cinema->name, screen->name, screen->recipient.get(), begin, end));
auto signer = Config::instance()->signer_chain();
if (!signer->valid()) {
#include "wx/about_dialog.h"
#include "wx/dcpomatic_button.h"
#include "wx/editable_list.h"
+#include "wx/invalid_certificate_period_dialog.h"
#include "wx/file_dialog.h"
#include "wx/file_picker_ctrl.h"
#include "wx/full_config_dialog.h"
return;
}
- if (find(period_checks.begin(), period_checks.end(), KDMCertificatePeriod::KDM_OUTSIDE_CERTIFICATE) != period_checks.end()) {
- error_dialog(
- this,
- _("Some KDMs would have validity periods which are completely outside the recipient certificate periods. Such KDMs are very unlikely to work, so will not be created.")
- );
- return;
- }
-
- if (find(period_checks.begin(), period_checks.end(), KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE) != period_checks.end()) {
- message_dialog(
- this,
- _("For some of these KDMs the recipient certificate's validity period will not cover the whole of the KDM validity period. This might cause problems with the KDMs.")
- );
+ if (
+ find_if(
+ period_checks.begin(),
+ period_checks.end(),
+ [](KDMCertificatePeriod const& p) { return p.overlap != KDMCertificateOverlap::KDM_WITHIN_CERTIFICATE; }
+ ) != period_checks.end()) {
+ InvalidCertificatePeriodDialog dialog(this, period_checks);
+ if (dialog.ShowModal() == wxID_CANCEL) {
+ return;
+ }
}
auto result = _output->make (
--- /dev/null
+/*
+ Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "invalid_certificate_period_dialog.h"
+#include "wx_util.h"
+#include "lib/kdm_util.h"
+#include <wx/listctrl.h>
+#include <wx/scrolwin.h>
+
+
+InvalidCertificatePeriodDialog::InvalidCertificatePeriodDialog(wxWindow* parent, std::vector<KDMCertificatePeriod> const& periods)
+ : wxDialog(parent, wxID_ANY, _("Invalid certificates"))
+ , _list(new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT))
+{
+ {
+ wxListItem ip;
+ ip.SetId(0);
+ ip.SetText(_("Cinema"));
+ ip.SetWidth(200);
+ _list->InsertColumn(0, ip);
+ }
+
+ {
+ wxListItem ip;
+ ip.SetId(1);
+ ip.SetText(_("Screen"));
+ ip.SetWidth(50);
+ _list->InsertColumn(1, ip);
+ }
+
+ {
+ wxListItem ip;
+ ip.SetId(2);
+ ip.SetText(_("Certificate start"));
+ ip.SetWidth(200);
+ _list->InsertColumn(2, ip);
+ }
+
+ {
+ wxListItem ip;
+ ip.SetId(3);
+ ip.SetText(_("Certificate end"));
+ ip.SetWidth(200);
+ _list->InsertColumn(3, ip);
+ }
+
+ int id = 0;
+ for (auto const& period: periods) {
+ wxListItem item;
+ item.SetId(id);
+ _list->InsertItem(item);
+ _list->SetItem(0, 0, std_to_wx(period.cinema_name));
+ _list->SetItem(0, 1, std_to_wx(period.screen_name));
+ _list->SetItem(0, 2, std_to_wx(period.from.as_string()));
+ _list->SetItem(0, 3, std_to_wx(period.to.as_string()));
+ }
+
+ auto overall_sizer = new wxBoxSizer(wxVERTICAL);
+
+ auto constexpr width = 700;
+
+ auto question = new wxStaticText(this, wxID_ANY, _("Some KDMs would have validity periods which are outside the recipient certificate validity periods. What do you want to do?"));
+ question->Wrap(width);
+ overall_sizer->Add(
+ question,
+ 0,
+ wxALL,
+ DCPOMATIC_DIALOG_BORDER
+ );
+
+ _list->SetSize({width, -1});
+ overall_sizer->Add(_list, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
+
+ auto buttons = CreateStdDialogButtonSizer(0);
+ if (buttons) {
+ overall_sizer->Add(CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
+ buttons->SetAffirmativeButton(new wxButton(this, wxID_OK, _("Create KDMs anyway")));
+ buttons->SetCancelButton(new wxButton(this, wxID_CANCEL, _("Cancel")));
+ buttons->Realize();
+ }
+
+ overall_sizer->Layout();
+ SetSizerAndFit(overall_sizer);
+}
+
--- /dev/null
+/*
+ Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_INVALID_CERTIFICATE_PERIOD_DIALOG_H
+#define DCPOMATIC_INVALID_CERTIFICATE_PERIOD_DIALOG_H
+
+
+#include <wx/wx.h>
+
+
+class KDMCertificatePeriod;
+class wxListCtrl;
+
+
+class InvalidCertificatePeriodDialog : public wxDialog
+{
+public:
+ InvalidCertificatePeriodDialog(wxWindow* parent, std::vector<KDMCertificatePeriod> const& periods);
+
+private:
+ wxListCtrl* _list;
+};
+
+
+#endif
+
+
#include "confirm_kdm_email_dialog.h"
#include "dcpomatic_button.h"
+#include "invalid_certificate_period_dialog.h"
#include "kdm_cpl_panel.h"
#include "kdm_dialog.h"
#include "kdm_output_panel.h"
}
}
- if (find(period_checks.begin(), period_checks.end(), KDMCertificatePeriod::KDM_OUTSIDE_CERTIFICATE) != period_checks.end()) {
- error_dialog(
- this,
- _("Some KDMs would have validity periods which are completely outside the recipient certificate periods. Such KDMs are very unlikely to work, so will not be created.")
- );
- return;
- }
-
- if (find(period_checks.begin(), period_checks.end(), KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE) != period_checks.end()) {
- message_dialog(
- this,
- _("For some of these KDMs the recipient certificate's validity period will not cover the whole of the KDM validity period. This might cause problems with the KDMs.")
- );
+ if (
+ find_if(
+ period_checks.begin(),
+ period_checks.end(),
+ [](KDMCertificatePeriod const& p) { return p.overlap != KDMCertificateOverlap::KDM_WITHIN_CERTIFICATE; }
+ ) != period_checks.end()) {
+ InvalidCertificatePeriodDialog dialog(this, period_checks);
+ if (dialog.ShowModal() == wxID_CANCEL) {
+ return;
+ }
}
} catch (dcp::BadKDMDateError& e) {
html_dialog.cc
i18n_hook.cc
image_sequence_dialog.cc
+ invalid_certificate_period_dialog.cc
instant_i18n_dialog.cc
interop_metadata_dialog.cc
job_manager_view.cc
BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_good)
{
auto const result = check_kdm_and_certificate_validity_periods(
+ "Bob's Place",
+ "Country",
dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
dcp::LocalTime("2023-01-03T10:30:00"),
dcp::LocalTime("2050-10-20T14:00:00")
);
- BOOST_CHECK(result == KDMCertificatePeriod::KDM_WITHIN_CERTIFICATE);
+ BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_WITHIN_CERTIFICATE);
}
BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_start)
{
auto const result = check_kdm_and_certificate_validity_periods(
+ "Bob's Place",
+ "Western",
dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
dcp::LocalTime("2011-01-03T10:30:00"),
dcp::LocalTime("2050-10-20T14:00:00")
);
- BOOST_CHECK(result == KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE);
+ BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE);
}
BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_end)
{
auto const result = check_kdm_and_certificate_validity_periods(
+ "Palace Hotel Ballroom",
+ "Lobby",
dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
dcp::LocalTime("2033-01-03T10:30:00"),
dcp::LocalTime("2095-10-20T14:00:00")
);
- BOOST_CHECK(result == KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE);
+ BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE);
}
BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_overlap_start_and_end)
{
auto const result = check_kdm_and_certificate_validity_periods(
+ "Palace Hotel Ballroom",
+ "Stage",
dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
dcp::LocalTime("2011-01-03T10:30:00"),
dcp::LocalTime("2095-10-20T14:00:00")
);
- BOOST_CHECK(result == KDMCertificatePeriod::KDM_OVERLAPS_CERTIFICATE);
+ BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_OVERLAPS_CERTIFICATE);
}
BOOST_AUTO_TEST_CASE(check_kdm_and_certificate_validity_periods_outside)
{
auto const result = check_kdm_and_certificate_validity_periods(
+ "Palace Hotel Ballroom",
+ "Drum Riser",
dcp::Certificate(dcp::file_to_string("test/data/cert.pem")),
dcp::LocalTime("2011-01-03T10:30:00"),
dcp::LocalTime("2012-10-20T14:00:00")
);
- BOOST_CHECK(result == KDMCertificatePeriod::KDM_OUTSIDE_CERTIFICATE);
+ BOOST_CHECK(result.overlap == KDMCertificateOverlap::KDM_OUTSIDE_CERTIFICATE);
}