summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-05-20 22:08:52 +0200
committerCarl Hetherington <cth@carlh.net>2020-05-20 23:39:23 +0200
commitdda7d841eac2305379aa86d11249dbb4b98d5bb7 (patch)
tree4f28cc7c53ec0586ba892b0f65a34653d25273f2
parent48841aa4a4aa4704e1e054b294bac23996be6dd0 (diff)
Tell the user when they load a KDM which will not do anything useful (part of #1161).
-rw-r--r--src/wx/content_menu.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc
index e9b6c3240..ec966b81a 100644
--- a/src/wx/content_menu.cc
+++ b/src/wx/content_menu.cc
@@ -52,6 +52,7 @@ using std::list;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
+using boost::optional;
enum {
/* Start at 256 so we can have IDs on _cpl_menu from 1 to 255 */
@@ -405,14 +406,38 @@ ContentMenu::kdm ()
wxFileDialog* d = new wxFileDialog (_parent, _("Select KDM"));
if (d->ShowModal() == wxID_OK) {
+ optional<dcp::EncryptedKDM> kdm;
try {
- dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)));
+ kdm = dcp::EncryptedKDM (dcp::file_to_string(wx_to_std(d->GetPath()), MAX_KDM_SIZE));
} catch (exception& e) {
error_dialog (_parent, _("Could not load KDM"), std_to_wx(e.what()));
d->Destroy ();
return;
}
+ DCPExaminer ex (dcp, true);
+
+ bool kdm_matches_any_cpl = false;
+ BOOST_FOREACH (shared_ptr<dcp::CPL> i, ex.cpls()) {
+ if (i->id() == kdm->cpl_id()) {
+ kdm_matches_any_cpl = true;
+ }
+ }
+
+
+ bool kdm_matches_selected_cpl = dcp->cpl() || kdm->cpl_id() == dcp->cpl().get();
+
+ if (!kdm_matches_any_cpl) {
+ error_dialog (_parent, _("This KDM was not made for this DCP. You will need a different one."));
+ return;
+ }
+
+ if (!kdm_matches_selected_cpl && kdm_matches_any_cpl) {
+ message_dialog (_parent, _("This KDM was made for one of the CPLs in this DCP, but not the currently selected one. To play the currently-selected CPL you will need a different KDM."));
+ }
+
+ dcp->add_kdm (*kdm);
+
shared_ptr<Film> film = _film.lock ();
DCPOMATIC_ASSERT (film);
JobManager::instance()->add (shared_ptr<Job> (new ExamineContentJob (film, dcp)));