From c0d3ccb11d1bc31767a431c72f99e4a84c26b194 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 14 Aug 2018 23:23:15 +0100 Subject: [PATCH] Move some stuff into DownloadCertificatePanel; add name(). --- src/wx/dolby_doremi_certificate_panel.cc | 20 ++++++++------------ src/wx/dolby_doremi_certificate_panel.h | 3 ++- src/wx/download_certificate_dialog.cc | 5 ++++- src/wx/download_certificate_panel.cc | 14 +++++++++++++- src/wx/download_certificate_panel.h | 4 +++- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc index 6f59b9147..5a0ce028e 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -50,17 +50,6 @@ DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, Down layout (); } -void -DolbyDoremiCertificatePanel::download (wxStaticText* message) -{ - message->SetLabel (_("Downloading certificate")); - - /* Hack: without this the SetLabel() above has no visible effect */ - wxMilliSleep (200); - - signal_manager->when_idle (boost::bind (&DolbyDoremiCertificatePanel::finish_download, this, wx_to_std (_serial->GetValue ()), message)); -} - static void try_dcp2000 (list& urls, list& files, string prefix, string serial) { @@ -156,13 +145,14 @@ try_cp850 (list& urls, list& files, string prefix, string serial } void -DolbyDoremiCertificatePanel::finish_download (string serial, wxStaticText* message) +DolbyDoremiCertificatePanel::do_download (wxStaticText* message) { /* Try dcp2000, imb and ims prefixes (see mantis #375) */ string const prefix = "ftp://anonymous@ftp.cinema.dolby.com/Certificates/"; list urls; list files; + string const serial = wx_to_std (_serial->GetValue()); bool starts_with_digit = false; optional starting_char; @@ -220,3 +210,9 @@ DolbyDoremiCertificatePanel::ready_to_download () const { return !_serial->IsEmpty (); } + +wxString +DolbyDoremiCertificatePanel::name () const +{ + return _("Dolby / Doremi"); +} diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h index b8df76569..2e1e0f54e 100644 --- a/src/wx/dolby_doremi_certificate_panel.h +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -26,7 +26,8 @@ public: DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); bool ready_to_download () const; - void download (wxStaticText* message); + void do_download (wxStaticText* message); + wxString name () const; private: void finish_download (std::string serial, wxStaticText* message); diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index e18723a4a..b4d602092 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -34,7 +34,10 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, this)); _setup.push_back (false); - _notebook->AddPage (_pages.back(), _("Dolby / Doremi"), true); + + BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { + _notebook->AddPage (i, i->name(), true); + } _download = new wxButton (this, wxID_ANY, _("Download")); sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index 4052e44a6..0c78901eb 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -20,6 +20,7 @@ #include "wx_util.h" #include "download_certificate_panel.h" +#include "lib/signal_manager.h" #include #include #include @@ -62,3 +63,14 @@ DownloadCertificatePanel::certificate () const { return _certificate; } + +void +DownloadCertificatePanel::download (wxStaticText* message) +{ + message->SetLabel (_("Downloading certificate")); + + /* Hack: without this the SetLabel() above has no visible effect */ + wxMilliSleep (200); + + signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, message)); +} diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index 6308e49b7..258d5ab25 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -35,8 +35,10 @@ public: /* Do any setup that may take a noticeable amount of time */ virtual void setup () {} virtual bool ready_to_download () const = 0; - virtual void download (wxStaticText* message) = 0; + virtual void do_download (wxStaticText* message) = 0; + virtual wxString name () const = 0; + void download (wxStaticText* message); void load (boost::filesystem::path); boost::optional certificate () const; -- 2.30.2