using std::cout;
using std::vector;
+using std::exception;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
/* XXX: a bit nasty */
shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (_content.front ());
- if (ic && !ic->still ()) {
+ shared_ptr<DCPContent> dc = dynamic_pointer_cast<DCPContent> (_content.front ());
+
+ int r = wxID_CANCEL;
+ boost::filesystem::path path;
+
+ if ((ic && !ic->still ()) || dc) {
wxDirDialog* d = new wxDirDialog (0, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST);
- int const r = d->ShowModal ();
- if (r == wxID_OK) {
- content.reset (new ImageContent (film, boost::filesystem::path (wx_to_std (d->GetPath ()))));
- }
+ r = d->ShowModal ();
+ path = wx_to_std (d->GetPath ());
d->Destroy ();
} else {
wxFileDialog* d = new wxFileDialog (0, _("Choose a file"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE);
- int const r = d->ShowModal ();
- if (r == wxID_OK) {
- content = content_factory (film, wx_to_std (d->GetPath ()));
- }
+ r = d->ShowModal ();
+ path = wx_to_std (d->GetPath ());
d->Destroy ();
}
+ if (r == wxID_OK) {
+ content = content_factory (film, path);
+ }
+
if (!content) {
return;
}
wxFileDialog* d = new wxFileDialog (_parent, _("Select KDM"));
if (d->ShowModal() == wxID_OK) {
- dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()))));
+ try {
+ dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()))));
+ } catch (exception& e) {
+ error_dialog (_parent, wxString::Format (_("Could not load KDM (%s)"), e.what ()));
+ d->Destroy ();
+ return;
+ }
+
shared_ptr<Film> film = _film.lock ();
DCPOMATIC_ASSERT (film);
film->examine_content (dcp);