Display thumbprint rather than whole certificate in screen dialogue.
authorCarl Hetherington <cth@carlh.net>
Sun, 15 Nov 2015 18:59:04 +0000 (18:59 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 15 Nov 2015 18:59:04 +0000 (18:59 +0000)
src/wx/dolby_certificate_panel.cc
src/wx/doremi_certificate_panel.cc
src/wx/download_certificate_dialog.cc
src/wx/download_certificate_panel.cc
src/wx/download_certificate_panel.h
src/wx/screen_dialog.cc
src/wx/screen_dialog.h

index 8652f43b632c052c6459d2a48b36fac6e672da55..7e6404cfb67ece29e946f2aa83ea776919e2b410 100644 (file)
@@ -201,6 +201,7 @@ DolbyCertificatePanel::finish_download (wxStaticText* message)
                message->SetLabel (std_to_wx (error.get ()));
        } else {
                message->SetLabel (_("Certificate downloaded"));
+               _dialog->setup_sensitivity ();
        }
 }
 
index b80a660c11714801627cc1ac164e742cb5ca062c..8b54d1c37e7b36d11e1eae1ad281c518149ec116 100644 (file)
@@ -103,6 +103,7 @@ DoremiCertificatePanel::finish_download (string serial, wxStaticText* message)
                error_dialog (this, std_to_wx (error.get ()));
        } else {
                message->SetLabel (_("Certificate downloaded"));
+               _dialog->setup_sensitivity ();
        }
 }
 
index 5a621d26fafbf614e05da44a1241f9266f87cf19..743eb4a3da53dfbaab0aef6abcfbe5333f31cedd 100644 (file)
@@ -22,6 +22,8 @@
 #include "download_certificate_dialog.h"
 #include "wx_util.h"
 
+using boost::optional;
+
 DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent)
        : wxDialog (parent, wxID_ANY, _("Download certificate"))
 {
@@ -70,13 +72,21 @@ DownloadCertificateDialog::download ()
 dcp::Certificate
 DownloadCertificateDialog::certificate () const
 {
-       return _pages[_notebook->GetSelection()]->certificate ();
+       optional<dcp::Certificate> c = _pages[_notebook->GetSelection()]->certificate ();
+       DCPOMATIC_ASSERT (c);
+       return c.get ();
 }
 
 void
 DownloadCertificateDialog::setup_sensitivity ()
 {
-       _download->Enable (_pages[_notebook->GetSelection()]->ready_to_download ());
+       DownloadCertificatePanel* p = _pages[_notebook->GetSelection()];
+       _download->Enable (p->ready_to_download ());
+       wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
+       if (ok) {
+               ok->Enable (p->certificate ());
+       }
+
 }
 
 void
@@ -87,4 +97,6 @@ DownloadCertificateDialog::page_changed ()
                _pages[n]->setup ();
                _setup[n] = true;
        }
+
+       setup_sensitivity ();
 }
index 7b670261b89d53219c9744d72d46a669d4e7be04..1379025c66ae1268ae20a086f90d29f9f094dcc3 100644 (file)
@@ -24,6 +24,7 @@
 #include <boost/bind.hpp>
 
 using boost::function;
+using boost::optional;
 
 DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog)
        : wxPanel (parent, wxID_ANY)
@@ -55,9 +56,8 @@ DownloadCertificatePanel::load (boost::filesystem::path file)
        }
 }
 
-dcp::Certificate
+optional<dcp::Certificate>
 DownloadCertificatePanel::certificate () const
 {
-       DCPOMATIC_ASSERT (_certificate);
-       return _certificate.get ();
+       return _certificate;
 }
index 850236128173958d17be167081513477ce19183b..6f3c329b5388967171cf3a584b0a9fd0e5fe27e9 100644 (file)
@@ -37,7 +37,7 @@ public:
        virtual void download (wxStaticText* message) = 0;
 
        void load (boost::filesystem::path);
-       dcp::Certificate certificate () const;
+       boost::optional<dcp::Certificate> certificate () const;
 
 protected:
        void layout ();
index 02bbe96ea5786be93c7e78cb9fe03226a2fbde3c..9857c9c17197f3770503b056def601d92dc8ca42 100644 (file)
@@ -40,22 +40,20 @@ ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, optiona
 
        add (_("Certificate"), true);
        wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+       _certificate_thumbprint = new wxStaticText (this, wxID_ANY, wxT (""));
+       wxFont font = _certificate_thumbprint->GetFont ();
+       font.SetFamily (wxFONTFAMILY_TELETYPE);
+       _certificate_thumbprint->SetFont (font);
+       if (certificate) {
+               _certificate_thumbprint->SetLabel (std_to_wx (certificate->thumbprint ()));
+       }
        _load_certificate = new wxButton (this, wxID_ANY, _("Load from file..."));
        _download_certificate = new wxButton (this, wxID_ANY, _("Download..."));
-       s->Add (_load_certificate, 1, wxEXPAND);
-       s->Add (_download_certificate, 1, wxEXPAND);
+       s->Add (_certificate_thumbprint, 1, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
+       s->Add (_load_certificate, 0, wxLEFT | wxRIGHT | wxEXPAND, DCPOMATIC_SIZER_X_GAP);
+       s->Add (_download_certificate, 0, wxLEFT | wxRIGHT | wxEXPAND, DCPOMATIC_SIZER_X_GAP);
        add (s);
 
-       add_spacer ();
-       _certificate_text = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (320, 256), wxTE_MULTILINE | wxTE_READONLY);
-       if (certificate) {
-               _certificate_text->SetValue (certificate->certificate ());
-       }
-       wxFont font = wxSystemSettings::GetFont (wxSYS_ANSI_FIXED_FONT);
-       font.SetPointSize (font.GetPointSize() / 2);
-       _certificate_text->SetFont (font);
-       add (_certificate_text);
-
        _load_certificate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreenDialog::select_certificate, this));
        _download_certificate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreenDialog::download_certificate, this));
 
@@ -80,7 +78,7 @@ ScreenDialog::load_certificate (boost::filesystem::path file)
 {
        try {
                _certificate = dcp::Certificate (dcp::file_to_string (file));
-               _certificate_text->SetValue (std_to_wx (_certificate->certificate ()));
+               _certificate_thumbprint->SetLabel (std_to_wx (_certificate->thumbprint ()));
        } catch (dcp::MiscError& e) {
                error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), std_to_wx(e.what()).data()));
        }
@@ -104,7 +102,7 @@ ScreenDialog::download_certificate ()
        DownloadCertificateDialog* d = new DownloadCertificateDialog (this);
        if (d->ShowModal() == wxID_OK) {
                _certificate = d->certificate ();
-               _certificate_text->SetValue (std_to_wx (_certificate->certificate ()));
+               _certificate_thumbprint->SetLabel (std_to_wx (_certificate->thumbprint ()));
        }
        d->Destroy ();
        setup_sensitivity ();
index 36686273ac9be7d5fad8d88307053bef4b150324..1110bc99291aff022d209c2c70eb6fb3a8819e00 100644 (file)
@@ -40,9 +40,9 @@ private:
        void setup_sensitivity ();
 
        wxTextCtrl* _name;
+       wxStaticText* _certificate_thumbprint;
        wxButton* _load_certificate;
        wxButton* _download_certificate;
-       wxTextCtrl* _certificate_text;
 
        boost::optional<dcp::Certificate> _certificate;
 };