+void
+ContentMenu::find_missing ()
+{
+ if (_content.size() != 1) {
+ return;
+ }
+
+ shared_ptr<const Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ /* XXX: a bit nasty */
+ shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (_content.front ());
+ 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);
+ 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);
+ r = d->ShowModal ();
+ path = wx_to_std (d->GetPath ());
+ d->Destroy ();
+ }
+
+ list<shared_ptr<Content> > content;
+
+ if (r == wxID_OK) {
+ if (dc) {
+ content.push_back (shared_ptr<DCPContent>(new DCPContent(path)));
+ } else {
+ content = content_factory (path);
+ }
+ }
+
+ if (content.empty ()) {
+ return;
+ }
+
+ BOOST_FOREACH (shared_ptr<Content> i, content) {
+ shared_ptr<Job> j (new ExamineContentJob (film, i));
+
+ j->Finished.connect (
+ bind (
+ &ContentMenu::maybe_found_missing,
+ this,
+ boost::weak_ptr<Job> (j),
+ boost::weak_ptr<Content> (_content.front ()),
+ boost::weak_ptr<Content> (i)
+ )
+ );
+
+ JobManager::instance()->add (j);
+ }
+}
+
+void
+ContentMenu::re_examine ()
+{
+ shared_ptr<Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ BOOST_FOREACH (shared_ptr<Content> i, _content) {
+ JobManager::instance()->add (shared_ptr<Job> (new ExamineContentJob (film, i)));
+ }
+}
+
+void
+ContentMenu::maybe_found_missing (weak_ptr<Job> j, weak_ptr<Content> oc, weak_ptr<Content> nc)
+{
+ shared_ptr<Job> job = j.lock ();
+ if (!job || !job->finished_ok ()) {
+ return;
+ }
+
+ shared_ptr<Content> old_content = oc.lock ();
+ shared_ptr<Content> new_content = nc.lock ();
+ DCPOMATIC_ASSERT (old_content);
+ DCPOMATIC_ASSERT (new_content);
+
+ if (new_content->digest() != old_content->digest()) {
+ error_dialog (0, _("The content file(s) you specified are not the same as those that are missing. Either try again with the correct content file or remove the missing content."));
+ return;
+ }
+
+ old_content->set_paths (new_content->paths());
+}
+
+void
+ContentMenu::kdm ()
+{
+ DCPOMATIC_ASSERT (!_content.empty ());
+ shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (_content.front ());
+ DCPOMATIC_ASSERT (dcp);
+
+ wxFileDialog* d = new wxFileDialog (_parent, _("Select KDM"));
+
+ if (d->ShowModal() == wxID_OK) {
+ try {
+ dcp->add_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;
+ }
+
+ shared_ptr<Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ JobManager::instance()->add (shared_ptr<Job> (new ExamineContentJob (film, dcp)));
+ }
+
+ d->Destroy ();
+}
+
+void
+ContentMenu::ov ()
+{
+ DCPOMATIC_ASSERT (!_content.empty ());
+ shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (_content.front ());
+ DCPOMATIC_ASSERT (dcp);
+
+ wxDirDialog* d = new wxDirDialog (_parent, _("Select OV"));
+
+ if (d->ShowModal() == wxID_OK) {
+ dcp->add_ov (wx_to_std (d->GetPath ()));
+ shared_ptr<Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ JobManager::instance()->add (shared_ptr<Job> (new ExamineContentJob (film, dcp)));
+ }
+
+ d->Destroy ();
+}
+
+void
+ContentMenu::properties ()
+{
+ shared_ptr<Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ ContentPropertiesDialog* d = new ContentPropertiesDialog (_parent, film, _content.front());
+ d->ShowModal ();
+ d->Destroy ();
+}
+
+void
+ContentMenu::cpl_selected (wxCommandEvent& ev)
+{
+ if (!_pop_up_open) {
+ return;
+ }
+
+ DCPOMATIC_ASSERT (!_content.empty ());
+ shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (_content.front ());
+ DCPOMATIC_ASSERT (dcp);
+
+ DCPExaminer ex (dcp, true);
+ list<shared_ptr<dcp::CPL> > cpls = ex.cpls ();
+ DCPOMATIC_ASSERT (ev.GetId() > 0);
+ DCPOMATIC_ASSERT (ev.GetId() <= int (cpls.size()));
+
+ list<shared_ptr<dcp::CPL> >::const_iterator i = cpls.begin ();
+ for (int j = 0; j < ev.GetId() - 1; ++j) {
+ ++i;
+ }
+
+ dcp->set_cpl ((*i)->id ());
+ shared_ptr<Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ JobManager::instance()->add (shared_ptr<Job> (new ExamineContentJob (film, dcp)));
+}