+
+optional<dcp::Certificate>
+ScreenDialog::certificate () const
+{
+ return _certificate;
+}
+
+void
+ScreenDialog::load_certificate (boost::filesystem::path file)
+{
+ try {
+ _certificate = dcp::Certificate (dcp::file_to_string (file));
+ _certificate_text->SetValue (_certificate->certificate ());
+ } catch (dcp::MiscError& e) {
+ error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), e.what()));
+ }
+}
+
+void
+ScreenDialog::select_certificate ()
+{
+ wxFileDialog* d = new wxFileDialog (this, _("Select Certificate File"));
+ if (d->ShowModal () == wxID_OK) {
+ load_certificate (boost::filesystem::path (wx_to_std (d->GetPath ())));
+ }
+ d->Destroy ();
+
+ setup_sensitivity ();
+}
+
+void
+ScreenDialog::download_certificate ()
+{
+ if (_manufacturer->GetStringSelection() == _("Doremi")) {
+ DownloadCertificateDialog* d = new DoremiCertificateDialog (this, boost::bind (&ScreenDialog::load_certificate, this, _1));
+ d->ShowModal ();
+ d->Destroy ();
+ } else if (_manufacturer->GetStringSelection() == _("Dolby")) {
+ DownloadCertificateDialog* d = new DolbyCertificateDialog (this, boost::bind (&ScreenDialog::load_certificate, this, _1));
+ d->ShowModal ();
+ d->Destroy ();
+ }
+
+ setup_sensitivity ();
+}
+
+void
+ScreenDialog::setup_sensitivity ()
+{
+ wxButton* ok = dynamic_cast<wxButton*> (FindWindowById (wxID_OK, this));
+ if (ok) {
+ ok->Enable (_certificate);
+ }
+
+ _download_certificate->Enable (
+ _manufacturer->GetStringSelection() == _("Doremi") ||
+ _manufacturer->GetStringSelection() == _("Dolby")
+ );
+}