Move some stuff into DownloadCertificatePanel; add name().
authorCarl Hetherington <cth@carlh.net>
Tue, 14 Aug 2018 22:23:15 +0000 (23:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 15 Aug 2018 09:57:06 +0000 (10:57 +0100)
src/wx/dolby_doremi_certificate_panel.cc
src/wx/dolby_doremi_certificate_panel.h
src/wx/download_certificate_dialog.cc
src/wx/download_certificate_panel.cc
src/wx/download_certificate_panel.h

index 6f59b91477d4b1719e6e19a4709054c03be1129b..5a0ce028e646298e50768ae97a34357da82b21e5 100644 (file)
@@ -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<string>& urls, list<string>& files, string prefix, string serial)
 {
@@ -156,13 +145,14 @@ try_cp850 (list<string>& urls, list<string>& 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<string> urls;
        list<string> files;
+       string const serial = wx_to_std (_serial->GetValue());
 
        bool starts_with_digit = false;
        optional<char> starting_char;
@@ -220,3 +210,9 @@ DolbyDoremiCertificatePanel::ready_to_download () const
 {
        return !_serial->IsEmpty ();
 }
+
+wxString
+DolbyDoremiCertificatePanel::name () const
+{
+       return _("Dolby / Doremi");
+}
index b8df7656934ccc07165479380b8dd8893f2102e5..2e1e0f54e36a06cb6d5527719a6a0b465df36d32 100644 (file)
@@ -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);
index e18723a4a08213a4e59e42c0431b592a8393e5ba..b4d6020928473c2fafbaca6cf523ebfc157a8aa8 100644 (file)
@@ -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);
index 4052e44a6e8245ff7d1bde1f146eeef9e09f5d1d..0c78901eba551e21e9a76fc3b94f1467e09413d2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
 
     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 <dcp/util.h>
 #include <dcp/exceptions.h>
 #include <boost/bind.hpp>
@@ -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));
+}
index 6308e49b708fb625ee8ca421f64fa5b1002658f1..258d5ab25372c5a6cdc724797b82596334f27be8 100644 (file)
@@ -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<dcp::Certificate> certificate () const;