diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-11-15 18:38:47 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-11-15 18:38:47 +0000 |
| commit | 1a14ae26a73489ae8990bfda1a432d229c3bb2d5 (patch) | |
| tree | 077589ad4feef778d8646af7a4767cc2e3f870fe /src | |
| parent | ffa5a512112809e2256cae7a01afcd14c99c83a6 (diff) | |
Rearrange cerficate download UI a bit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/dolby_certificate_panel.cc (renamed from src/wx/dolby_certificate_dialog.cc) | 90 | ||||
| -rw-r--r-- | src/wx/dolby_certificate_panel.h (renamed from src/wx/dolby_certificate_dialog.h) | 17 | ||||
| -rw-r--r-- | src/wx/doremi_certificate_panel.cc (renamed from src/wx/doremi_certificate_dialog.cc) | 48 | ||||
| -rw-r--r-- | src/wx/doremi_certificate_panel.h (renamed from src/wx/doremi_certificate_dialog.h) | 16 | ||||
| -rw-r--r-- | src/wx/download_certificate_dialog.cc | 73 | ||||
| -rw-r--r-- | src/wx/download_certificate_dialog.h | 34 | ||||
| -rw-r--r-- | src/wx/download_certificate_panel.cc | 63 | ||||
| -rw-r--r-- | src/wx/download_certificate_panel.h | 53 | ||||
| -rw-r--r-- | src/wx/screen_dialog.cc | 34 | ||||
| -rw-r--r-- | src/wx/screen_dialog.h | 1 | ||||
| -rw-r--r-- | src/wx/wscript | 5 |
11 files changed, 283 insertions, 151 deletions
diff --git a/src/wx/dolby_certificate_dialog.cc b/src/wx/dolby_certificate_panel.cc index 8661cd5f8..8652f43b6 100644 --- a/src/wx/dolby_certificate_dialog.cc +++ b/src/wx/dolby_certificate_panel.cc @@ -17,7 +17,8 @@ */ -#include "dolby_certificate_dialog.h" +#include "dolby_certificate_panel.h" +#include "download_certificate_dialog.h" #include "wx_util.h" #include "lib/compose.hpp" #include "lib/internet.h" @@ -36,40 +37,42 @@ using boost::optional; using boost::algorithm::split; using boost::algorithm::is_any_of; -DolbyCertificateDialog::DolbyCertificateDialog (wxWindow* parent, boost::function<void (boost::filesystem::path)> load) - : DownloadCertificateDialog (parent, load) +DolbyCertificatePanel::DolbyCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (parent, dialog) { - add (_("Country"), true); - _country = add (new wxChoice (this, wxID_ANY)); + add_label_to_sizer (_table, this, _("Country"), true); + _country = new wxChoice (this, wxID_ANY); + _table->Add (_country, 1, wxEXPAND); _country->Append (N_("Hashemite Kingdom of Jordan")); - add (_("Cinema"), true); - _cinema = add (new wxChoice (this, wxID_ANY)); + add_label_to_sizer (_table, this, _("Cinema"), true); + _cinema = new wxChoice (this, wxID_ANY); + _table->Add (_cinema, 1, wxEXPAND); _cinema->Append (N_("Motion Picture Solutions London Mobile & QC")); - add (_("Serial number"), true); - _serial = add (new wxChoice (this, wxID_ANY)); + add_label_to_sizer (_table, this, _("Serial number"), true); + _serial = new wxChoice (this, wxID_ANY); + _table->Add (_serial, 1, wxEXPAND); - add_common_widgets (); + layout (); - _country->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificateDialog::country_selected, this)); - _cinema->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificateDialog::cinema_selected, this)); - _serial->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificateDialog::serial_selected, this)); - signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::setup_countries, this)); + _country->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificatePanel::country_selected, this)); + _cinema->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificatePanel::cinema_selected, this)); + _serial->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog)); _country->Clear (); _cinema->Clear (); } list<string> -DolbyCertificateDialog::get_dir (string dir) const +DolbyCertificatePanel::get_dir (string dir) const { string url = String::compose ("ftp://dolbyrootcertificates:houro61l@ftp.dolby.co.uk/SHA256/%1", dir); return ftp_ls (url, false); } void -DolbyCertificateDialog::setup_countries () +DolbyCertificatePanel::setup_countries () { if (_country->GetCount() > 0) { /* Already set up */ @@ -79,14 +82,14 @@ DolbyCertificateDialog::setup_countries () _country->Append (_("Fetching...")); _country->SetSelection (0); - /* See DoremiCertificateDialog for discussion about this daft delay */ + /* See DoremiCertificatePanel for discussion about this daft delay */ wxMilliSleep (200); - signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_setup_countries, this)); + signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_setup_countries, this)); } void -DolbyCertificateDialog::finish_setup_countries () +DolbyCertificatePanel::finish_setup_countries () { try { list<string> const c = get_dir (""); @@ -101,7 +104,7 @@ DolbyCertificateDialog::finish_setup_countries () } void -DolbyCertificateDialog::country_selected () +DolbyCertificatePanel::country_selected () { _cinema->Clear (); _cinema->Append (_("Fetching...")); @@ -110,11 +113,11 @@ DolbyCertificateDialog::country_selected () #ifdef DCPOMATIC_OSX wxMilliSleep (200); #endif - signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_country_selected, this)); + signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_country_selected, this)); } void -DolbyCertificateDialog::finish_country_selected () +DolbyCertificatePanel::finish_country_selected () { try { list<string> const c = get_dir (wx_to_std (_country->GetStringSelection())); @@ -129,7 +132,7 @@ DolbyCertificateDialog::finish_country_selected () } void -DolbyCertificateDialog::cinema_selected () +DolbyCertificatePanel::cinema_selected () { _serial->Clear (); _serial->Append (_("Fetching...")); @@ -138,11 +141,11 @@ DolbyCertificateDialog::cinema_selected () #ifdef DCPOMATIC_OSX wxMilliSleep (200); #endif - signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_cinema_selected, this)); + signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_cinema_selected, this)); } void -DolbyCertificateDialog::finish_cinema_selected () +DolbyCertificatePanel::finish_cinema_selected () { try { list<string> const s = get_dir (String::compose ("%1/%2", wx_to_std (_country->GetStringSelection()), wx_to_std (_cinema->GetStringSelection()))); @@ -161,26 +164,19 @@ DolbyCertificateDialog::finish_cinema_selected () } void -DolbyCertificateDialog::serial_selected () +DolbyCertificatePanel::download (wxStaticText* message) { - _download->Enable (true); -} - -void -DolbyCertificateDialog::download () -{ - downloaded (false); - _message->SetLabel (_("Downloading certificate")); + message->SetLabel (_("Downloading certificate")); #ifdef DCPOMATIC_OSX wxMilliSleep (200); #endif - signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_download, this)); + signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_download, this, message)); } void -DolbyCertificateDialog::finish_download () +DolbyCertificatePanel::finish_download (wxStaticText* message) { string const zip = string_client_data (_serial->GetClientObject (_serial->GetSelection ())); @@ -195,16 +191,28 @@ DolbyCertificateDialog::finish_download () vector<string> b; split (b, zip, is_any_of ("_")); if (b.size() < 2) { - _message->SetLabel (_("Unexpected certificate filename form")); + message->SetLabel (_("Unexpected certificate filename form")); return; } string const cert = b[0] + "_" + b[1] + ".pem.crt"; - optional<string> error = get_from_zip_url (file, cert, _load); + optional<string> error = get_from_zip_url (file, cert, boost::bind (&DownloadCertificatePanel::load, this, _1)); if (error) { - _message->SetLabel (std_to_wx (error.get ())); + message->SetLabel (std_to_wx (error.get ())); } else { - _message->SetLabel (_("Certificate downloaded")); - downloaded (true); + message->SetLabel (_("Certificate downloaded")); } } + +bool +DolbyCertificatePanel::ready_to_download () const +{ + /* XXX */ + return false; +} + +void +DolbyCertificatePanel::setup () +{ + signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::setup_countries, this)); +} diff --git a/src/wx/dolby_certificate_dialog.h b/src/wx/dolby_certificate_panel.h index e9bbffda0..1ac47ae76 100644 --- a/src/wx/dolby_certificate_dialog.h +++ b/src/wx/dolby_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,24 +17,27 @@ */ +#include "download_certificate_panel.h" #include <curl/curl.h> -#include "download_certificate_dialog.h" +#include <list> -class DolbyCertificateDialog : public DownloadCertificateDialog +class DolbyCertificatePanel : public DownloadCertificatePanel { public: - DolbyCertificateDialog (wxWindow *, boost::function<void (boost::filesystem::path)>); + DolbyCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + + void setup (); + bool ready_to_download () const; + void download (wxStaticText* message); private: - void download (); - void finish_download (); + void finish_download (wxStaticText* message); void setup_countries (); void finish_setup_countries (); void country_selected (); void finish_country_selected (); void cinema_selected (); void finish_cinema_selected (); - void serial_selected (); std::list<std::string> get_dir (std::string) const; wxChoice* _country; diff --git a/src/wx/doremi_certificate_dialog.cc b/src/wx/doremi_certificate_panel.cc index ffb2a0f99..b80a660c1 100644 --- a/src/wx/doremi_certificate_dialog.cc +++ b/src/wx/doremi_certificate_panel.cc @@ -17,14 +17,15 @@ */ -#include <curl/curl.h> -#include <zip.h> +#include "doremi_certificate_panel.h" +#include "download_certificate_dialog.h" +#include "wx_util.h" #include "lib/compose.hpp" #include "lib/util.h" #include "lib/signal_manager.h" #include "lib/internet.h" -#include "doremi_certificate_dialog.h" -#include "wx_util.h" +#include <curl/curl.h> +#include <zip.h> #include <iostream> using std::string; @@ -32,19 +33,20 @@ using std::cout; using boost::function; using boost::optional; -DoremiCertificateDialog::DoremiCertificateDialog (wxWindow* parent, function<void (boost::filesystem::path)> load) - : DownloadCertificateDialog (parent, load) +DoremiCertificatePanel::DoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (parent, dialog) { - add (_("Server serial number"), true); - _serial = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1))); + add_label_to_sizer (_table, this, _("Server serial number"), true); + _serial = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1)); + _table->Add (_serial, 1, wxEXPAND); - _serial->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DoremiCertificateDialog::set_sensitivity, this)); + _serial->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog)); - add_common_widgets (); + layout (); } void -DoremiCertificateDialog::download () +DoremiCertificatePanel::download (wxStaticText* message) { string const serial = wx_to_std (_serial->GetValue ()); if (serial.length() != 6) { @@ -52,17 +54,16 @@ DoremiCertificateDialog::download () return; } - downloaded (false); - _message->SetLabel (_("Downloading certificate")); + message->SetLabel (_("Downloading certificate")); /* Hack: without this the SetLabel() above has no visible effect */ wxMilliSleep (200); - signal_manager->when_idle (boost::bind (&DoremiCertificateDialog::finish_download, this, serial)); + signal_manager->when_idle (boost::bind (&DoremiCertificatePanel::finish_download, this, serial, message)); } void -DoremiCertificateDialog::finish_download (string serial) +DoremiCertificatePanel::finish_download (string serial, wxStaticText* message) { /* Try dcp2000, imb and ims prefixes (see mantis #375) */ @@ -72,7 +73,7 @@ DoremiCertificateDialog::finish_download (string serial) serial.substr(0, 3), serial ), String::compose ("dcp2000-%1.cert.sha256.pem", serial), - _load + boost::bind (&DownloadCertificatePanel::load, this, _1) ); if (error) { @@ -82,7 +83,7 @@ DoremiCertificateDialog::finish_download (string serial) serial.substr(0, 3), serial ), String::compose ("imb-%1.cert.sha256.pem", serial), - _load + boost::bind (&DownloadCertificatePanel::load, this, _1) ); } @@ -93,21 +94,20 @@ DoremiCertificateDialog::finish_download (string serial) serial.substr(0, 3), serial ), String::compose ("ims-%1.cert.sha256.pem", serial), - _load + boost::bind (&DownloadCertificatePanel::load, this, _1) ); } if (error) { - _message->SetLabel (wxT ("")); + message->SetLabel (wxT ("")); error_dialog (this, std_to_wx (error.get ())); } else { - _message->SetLabel (_("Certificate downloaded")); - downloaded (true); + message->SetLabel (_("Certificate downloaded")); } } -void -DoremiCertificateDialog::set_sensitivity () +bool +DoremiCertificatePanel::ready_to_download () const { - _download->Enable (!_serial->IsEmpty ()); + return !_serial->IsEmpty (); } diff --git a/src/wx/doremi_certificate_dialog.h b/src/wx/doremi_certificate_panel.h index b249736ec..5fc455098 100644 --- a/src/wx/doremi_certificate_dialog.h +++ b/src/wx/doremi_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,18 +17,18 @@ */ -#include "download_certificate_dialog.h" +#include "download_certificate_panel.h" -class DoremiCertificateDialog : public DownloadCertificateDialog +class DoremiCertificatePanel : public DownloadCertificatePanel { public: - DoremiCertificateDialog (wxWindow *, boost::function<void (boost::filesystem::path)>); + DoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); -private: - void download (); - void set_sensitivity (); + bool ready_to_download () const; + void download (wxStaticText* message); - void finish_download (std::string serial); +private: + void finish_download (std::string serial, wxStaticText* message); wxTextCtrl* _serial; }; diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index 275c943db..5a621d26f 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -17,47 +17,74 @@ */ -#include "wx_util.h" +#include "doremi_certificate_panel.h" +#include "dolby_certificate_panel.h" #include "download_certificate_dialog.h" -#include <boost/bind.hpp> - -using boost::function; +#include "wx_util.h" -DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent, function<void (boost::filesystem::path)> load) - : TableDialog (parent, _("Download certificate"), 2, 1, true) - , _load (load) - , _message (0) - , _download (0) +DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) + : wxDialog (parent, wxID_ANY, _("Download certificate")) { + wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); -} + _notebook = new wxNotebook (this, wxID_ANY); + sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); -void -DownloadCertificateDialog::add_common_widgets () -{ - add_spacer (); - _download = add (new wxButton (this, wxID_ANY, _("Download"))); + _pages.push_back (new DoremiCertificatePanel (_notebook, this)); + _setup.push_back (false); + _notebook->AddPage (_pages.back(), _("Doremi"), true); + _pages.push_back (new DolbyCertificatePanel (_notebook, this)); + _setup.push_back (false); + _notebook->AddPage (_pages.back(), _("Dolby"), false); - add_spacer (); - _message = add (new wxStaticText (this, wxID_ANY, wxT (""))); + _download = new wxButton (this, wxID_ANY, _("Download")); + sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); + _message = new wxStaticText (this, wxID_ANY, wxT ("")); + sizer->Add (_message, 0, wxALL, DCPOMATIC_SIZER_GAP); wxFont font = _message->GetFont(); font.SetStyle (wxFONTSTYLE_ITALIC); font.SetPointSize (font.GetPointSize() - 1); _message->SetFont (font); + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); + if (buttons) { + sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } + + SetSizerAndFit (sizer); + + _notebook->Bind (wxEVT_NOTEBOOK_PAGE_CHANGED, boost::bind (&DownloadCertificateDialog::page_changed, this)); _download->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DownloadCertificateDialog::download, this)); _download->Enable (false); - layout (); + page_changed (); +} + +void +DownloadCertificateDialog::download () +{ + _pages[_notebook->GetSelection()]->download (_message); +} - wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this)); - ok->Enable (false); +dcp::Certificate +DownloadCertificateDialog::certificate () const +{ + return _pages[_notebook->GetSelection()]->certificate (); +} + +void +DownloadCertificateDialog::setup_sensitivity () +{ + _download->Enable (_pages[_notebook->GetSelection()]->ready_to_download ()); } void -DownloadCertificateDialog::downloaded (bool done) +DownloadCertificateDialog::page_changed () { - wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this)); - ok->Enable (done); + int const n = _notebook->GetSelection(); + if (!_setup[n]) { + _pages[n]->setup (); + _setup[n] = true; + } } diff --git a/src/wx/download_certificate_dialog.h b/src/wx/download_certificate_dialog.h index 85d8f15ab..7d319dcfe 100644 --- a/src/wx/download_certificate_dialog.h +++ b/src/wx/download_certificate_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,29 +17,27 @@ */ -#ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_DIALOG_H -#define DCPOMATIC_DOWNLOAD_CERTIFICATE_DIALOG_H - #include <wx/wx.h> -#include <boost/function.hpp> -#include <boost/filesystem.hpp> -#include "table_dialog.h" +#include <wx/notebook.h> + +class DownloadCertificatePanel; -class DownloadCertificateDialog : public TableDialog +class DownloadCertificateDialog : public wxDialog { public: - DownloadCertificateDialog (wxWindow *, boost::function<void (boost::filesystem::path)>); + DownloadCertificateDialog (wxWindow* parent); -protected: - void add_common_widgets (); - void downloaded (bool done); + dcp::Certificate certificate () const; - boost::function<void (boost::filesystem::path)> _load; - wxStaticText* _message; - wxButton* _download; + void setup_sensitivity (); private: - virtual void download () = 0; -}; + void download (); + void page_changed (); -#endif + wxNotebook* _notebook; + std::vector<DownloadCertificatePanel*> _pages; + std::vector<bool> _setup; + wxButton* _download; + wxStaticText* _message; +}; diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc new file mode 100644 index 000000000..7b670261b --- /dev/null +++ b/src/wx/download_certificate_panel.cc @@ -0,0 +1,63 @@ +/* + Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "wx_util.h" +#include "download_certificate_panel.h" +#include <dcp/util.h> +#include <dcp/exceptions.h> +#include <boost/bind.hpp> + +using boost::function; + +DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) + : wxPanel (parent, wxID_ANY) + , _dialog (dialog) +{ + _overall_sizer = new wxBoxSizer (wxVERTICAL); + SetSizer (_overall_sizer); + + _table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + _table->AddGrowableCol (1, 1); + + _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); +} + +void +DownloadCertificatePanel::layout () +{ + _overall_sizer->Layout (); + _overall_sizer->SetSizeHints (this); +} + +void +DownloadCertificatePanel::load (boost::filesystem::path file) +{ + try { + _certificate = dcp::Certificate (dcp::file_to_string (file)); + } catch (dcp::MiscError& e) { + error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), std_to_wx(e.what()).data())); + } +} + +dcp::Certificate +DownloadCertificatePanel::certificate () const +{ + DCPOMATIC_ASSERT (_certificate); + return _certificate.get (); +} diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h new file mode 100644 index 000000000..850236128 --- /dev/null +++ b/src/wx/download_certificate_panel.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H +#define DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H + +#include <dcp/certificate.h> +#include <wx/wx.h> +#include <boost/optional.hpp> + +class DownloadCertificateDialog; + +class DownloadCertificatePanel : public wxPanel +{ +public: + DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + + /* 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; + + void load (boost::filesystem::path); + dcp::Certificate certificate () const; + +protected: + void layout (); + + DownloadCertificateDialog* _dialog; + wxFlexGridSizer* _table; + +private: + wxSizer* _overall_sizer; + boost::optional<dcp::Certificate> _certificate; +}; + +#endif diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc index 98a525318..02bbe96ea 100644 --- a/src/wx/screen_dialog.cc +++ b/src/wx/screen_dialog.cc @@ -19,8 +19,7 @@ #include "screen_dialog.h" #include "wx_util.h" -#include "doremi_certificate_dialog.h" -#include "dolby_certificate_dialog.h" +#include "download_certificate_dialog.h" #include "lib/compose.hpp" #include "lib/util.h" #include <dcp/exceptions.h> @@ -39,9 +38,6 @@ ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, optiona add (_("Name"), true); _name = add (new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (320, -1))); - add (_("Server manufacturer"), true); - _manufacturer = add (new wxChoice (this, wxID_ANY)); - add (_("Certificate"), true); wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); _load_certificate = new wxButton (this, wxID_ANY, _("Load from file...")); @@ -60,15 +56,8 @@ ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, optiona _certificate_text->SetFont (font); add (_certificate_text); - _manufacturer->Append (_("Unknown")); - _manufacturer->Append (_("Doremi")); - _manufacturer->Append (_("Dolby")); - _manufacturer->Append (_("Other")); - _manufacturer->SetSelection (0); - _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)); - _manufacturer->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ScreenDialog::setup_sensitivity, this)); setup_sensitivity (); layout (); @@ -91,7 +80,7 @@ ScreenDialog::load_certificate (boost::filesystem::path file) { try { _certificate = dcp::Certificate (dcp::file_to_string (file)); - _certificate_text->SetValue (_certificate->certificate ()); + _certificate_text->SetValue (std_to_wx (_certificate->certificate ())); } catch (dcp::MiscError& e) { error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), std_to_wx(e.what()).data())); } @@ -112,16 +101,12 @@ ScreenDialog::select_certificate () 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 (); + DownloadCertificateDialog* d = new DownloadCertificateDialog (this); + if (d->ShowModal() == wxID_OK) { + _certificate = d->certificate (); + _certificate_text->SetValue (std_to_wx (_certificate->certificate ())); } - + d->Destroy (); setup_sensitivity (); } @@ -132,9 +117,4 @@ ScreenDialog::setup_sensitivity () if (ok) { ok->Enable (static_cast<bool>(_certificate)); } - - _download_certificate->Enable ( - _manufacturer->GetStringSelection() == _("Doremi") || - _manufacturer->GetStringSelection() == _("Dolby") - ); } diff --git a/src/wx/screen_dialog.h b/src/wx/screen_dialog.h index 66f3f422f..36686273a 100644 --- a/src/wx/screen_dialog.h +++ b/src/wx/screen_dialog.h @@ -40,7 +40,6 @@ private: void setup_sensitivity (); wxTextCtrl* _name; - wxChoice* _manufacturer; wxButton* _load_certificate; wxButton* _download_certificate; wxTextCtrl* _certificate_text; diff --git a/src/wx/wscript b/src/wx/wscript index 821043b40..7b106c6b0 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -43,9 +43,10 @@ sources = """ image_sequence_dialog.cc isdcf_metadata_dialog.cc dir_picker_ctrl.cc - dolby_certificate_dialog.cc - doremi_certificate_dialog.cc + dolby_certificate_panel.cc + doremi_certificate_panel.cc download_certificate_dialog.cc + download_certificate_panel.cc file_picker_ctrl.cc film_editor.cc film_viewer.cc |
