using std::string;
using namespace libdcp;
-FileError::FileError (std::string const & message, boost::filesystem::path filename, int number)
- : _message (String::compose ("%1 (%2) (error %3)", message, filename.string(), number))
+FileError::FileError (string const & message, boost::filesystem::path filename, int number)
+ : StringError (String::compose ("%1 (%2) (error %3)", message, filename.string(), number))
, _filename (filename)
, _number (number)
{
}
+NotEncryptedError::NotEncryptedError (string const & what)
+ : StringError (String::compose ("%1 asset is not encrypted", what))
+{
+
+}
namespace libdcp
{
-/** @brief An exception related to a file */
-class FileError : public std::exception
+class StringError : public std::exception
{
public:
- FileError (std::string const & message, boost::filesystem::path filename, int number);
- ~FileError () throw () {}
+ StringError (std::string const & message)
+ : _message (message)
+ {}
+
+ ~StringError () throw () {}
/** @return error message */
char const * what () const throw () {
return _message.c_str ();
}
-
+
+private:
+ std::string _message;
+};
+
+/** @brief An exception related to a file */
+class FileError : public StringError
+{
+public:
+ FileError (std::string const & message, boost::filesystem::path filename, int number);
+ ~FileError () throw () {}
+
/** @return filename of file that was involved */
boost::filesystem::path filename () const {
return _filename;
}
private:
- /** message part */
- std::string _message;
/** filename of file that was involved */
boost::filesystem::path _filename;
int _number;
};
/** @brief A miscellaneous exception */
-class MiscError : public std::exception
+class MiscError : public StringError
{
public:
- MiscError (std::string const & message) : _message (message) {}
+ MiscError (std::string const & message)
+ : StringError (message)
+ {}
+
~MiscError () throw () {}
-
- /** @return error message */
- char const * what () const throw () {
- return _message.c_str ();
- }
-
-private:
- /** error message */
- std::string _message;
};
/** @brief A DCP read exception */
-class DCPReadError : public std::exception
+class DCPReadError : public StringError
{
public:
- DCPReadError (std::string const & message) : _message (message) {}
+ DCPReadError (std::string const & message)
+ : StringError (message)
+ {}
+
~DCPReadError () throw () {}
-
- /** @return error message */
- char const * what () const throw () {
- return _message.c_str ();
- }
-
-private:
- /** error message */
- std::string _message;
};
/** @brief An XML error */
-class XMLError : public std::exception
+class XMLError : public StringError
{
public:
- XMLError (std::string const & message) : _message (message) {}
- ~XMLError () throw () {}
+ XMLError (std::string const & message)
+ : StringError (message)
+ {}
- /** @return error message */
- char const * what () const throw () {
- return _message.c_str ();
- }
+ ~XMLError () throw () {}
+};
-private:
- /** error message */
- std::string _message;
+class NotEncryptedError : public StringError
+{
+public:
+ NotEncryptedError (std::string const & asset);
+ ~NotEncryptedError () throw () {}
};
}
/* XXX: subtitle assets? */
if ((*i)->asset_list->main_picture) {
+ if ((*i)->asset_list->main_picture->key_id.empty ()) {
+ throw NotEncryptedError ("MainPicture");
+ }
+
KDMKey kkey (
signer, cpl.id.substr (9), "MDIK", (*i)->asset_list->main_picture->key_id.substr (9),
not_valid_before, not_valid_after, key
}
if ((*i)->asset_list->main_stereoscopic_picture) {
+ if ((*i)->asset_list->main_stereoscopic_picture->key_id.empty ()) {
+ throw NotEncryptedError ("MainStereoscopicPicture");
+ }
+
KDMKey kkey (
signer, cpl.id.substr (9), "MDIK", (*i)->asset_list->main_stereoscopic_picture->key_id.substr (9),
not_valid_before, not_valid_after, key
}
if ((*i)->asset_list->main_sound) {
+ if ((*i)->asset_list->main_sound->key_id.empty ()) {
+ throw NotEncryptedError ("MainSound");
+ }
+
KDMKey kkey (
signer, cpl.id.substr (9), "MDAK", (*i)->asset_list->main_sound->key_id.substr (9),
not_valid_before, not_valid_after, key