From 320c20b9538c985005dc850d685eecfc1a5edc98 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 13 May 2017 21:50:06 +0100 Subject: Give a slightly better error whn trying to add a KDM using add-file (#1035). --- src/lib/content_factory.cc | 5 +++++ src/lib/exceptions.cc | 4 ++++ src/lib/exceptions.h | 6 ++++++ 3 files changed, 15 insertions(+) (limited to 'src/lib') diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index 87f4e36a0..e5e73f890 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -170,6 +170,11 @@ content_factory (shared_ptr film, boost::filesystem::path path) } else if (ext == ".srt" || ext == ".ssa" || ext == ".ass") { single.reset (new TextSubtitleContent (film, path)); } else if (ext == ".xml") { + cxml::Document doc; + doc.read_file (path); + if (doc.root_name() == "DCinemaSecurityMessage") { + throw KDMAsContentError (); + } single.reset (new DCPSubtitleContent (film, path)); } else if (ext == ".mxf" && dcp::SMPTESubtitleAsset::valid_mxf (path)) { single.reset (new DCPSubtitleContent (film, path)); diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc index 4590531b7..cf3708896 100644 --- a/src/lib/exceptions.cc +++ b/src/lib/exceptions.cc @@ -86,3 +86,7 @@ ProgrammingError::ProgrammingError (string file, int line) { } + +KDMAsContentError::KDMAsContentError () + : runtime_error (_("This file is a KDM. KDMs should be added to DCP content by right-clicking the content and choosing \"Add KDM\".")) +{} diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index c2f82e15b..c1b1aef4b 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -252,4 +252,10 @@ public: {} }; +class KDMAsContentError : public std::runtime_error +{ +public: + KDMAsContentError (); +}; + #endif -- cgit v1.2.3