Fix build.
[dcpomatic.git] / src / wx / kdm_dialog.cc
index 79f78b2327a24751f2b86be43e76a2e6285582ae..9135baf236a08fe20805e26cf9be68bc010d24d5 100644 (file)
@@ -21,6 +21,7 @@
 
 #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"
@@ -33,6 +34,7 @@
 #include "lib/film.h"
 #include "lib/job_manager.h"
 #include "lib/kdm_with_metadata.h"
+#include "lib/kdm_util.h"
 #include "lib/screen.h"
 #include <libcxml/cxml.h>
 #include <dcp/exceptions.h>
@@ -171,17 +173,36 @@ KDMDialog::make_clicked ()
                        for_audio = _output->forensic_mark_audio_up_to();
                }
 
+               vector<KDMCertificatePeriod> period_checks;
+
+               std::function<dcp::DecryptedKDM (dcp::LocalTime, dcp::LocalTime)> make_kdm = [film, this](dcp::LocalTime begin, dcp::LocalTime end) {
+                       return film->make_kdm(_cpl->cpl(), begin, end);
+               };
+
                for (auto i: _screens->screens()) {
-                       auto p = kdm_for_screen (film, _cpl->cpl(), i, _timing->from(), _timing->until(), _output->formulation(), !_output->forensic_mark_video(), for_audio);
+                       auto p = kdm_for_screen(make_kdm, i, _timing->from(), _timing->until(), _output->formulation(), !_output->forensic_mark_video(), for_audio, period_checks);
                        if (p) {
                                kdms.push_back (p);
                        }
                }
+
+               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) {
                if (e.starts_too_early()) {
                        error_dialog (this, _("The KDM start period is before (or close to) the start of the signing certificate's validity period.  Use a later start time for this KDM."));
                } else {
-                       error_dialog (this, _("The KDM end period is after (or close to) the end of the signing certficates' validity period.  Either use an earlier end time for this KDM or re-create your signing certificates in the DCP-o-matic preferences window."));
+                       error_dialog (this, _("The KDM end period is after (or close to) the end of the signing certificates' validity period.  Either use an earlier end time for this KDM or re-create your signing certificates in the DCP-o-matic preferences window."));
                }
                return;
        } catch (runtime_error& e) {