+void
+ContentMenu::find_missing ()
+{
+ if (_content.size() != 1) {
+ return;
+ }
+
+ shared_ptr<const Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ shared_ptr<Content> content;
+
+ /* 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 ();
+ }
+
+ if (r == wxID_OK) {
+ content = content_factory (film, path);
+ }
+
+ if (!content) {
+ return;
+ }
+
+ shared_ptr<Job> j (new ExamineContentJob (film, content));
+
+ _job_connection = j->Finished.connect (
+ bind (
+ &ContentMenu::maybe_found_missing,
+ this,
+ boost::weak_ptr<Job> (j),
+ boost::weak_ptr<Content> (_content.front ()),
+ boost::weak_ptr<Content> (content)
+ )
+ );
+
+ JobManager::instance()->add (j);
+}
+
+void
+ContentMenu::re_examine ()
+{
+ shared_ptr<Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ BOOST_FOREACH (shared_ptr<Content> i, _content) {
+ film->examine_content (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_path (new_content->path (0));
+}
+
+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 ()))));
+ } 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);
+ }
+
+ d->Destroy ();
+}
+
+void
+ContentMenu::properties ()
+{
+ ContentPropertiesDialog* d = new ContentPropertiesDialog (_parent, _content.front ());
+ d->ShowModal ();
+ d->Destroy ();
+}