+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 ());
+ if (ic && !ic->still ()) {
+ 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 ()))));
+ }
+ 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 ()));
+ }
+ d->Destroy ();
+ }
+
+ if (!content) {
+ return;
+ }
+
+ shared_ptr<Job> j (new ExamineContentJob (film, content));
+
+ 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;
+ }
+
+ for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) {
+ 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) {
+ dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()))));
+ shared_ptr<Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ film->examine_content (dcp);
+ }
+
+ d->Destroy ();
+}