From: Carl Hetherington Date: Mon, 21 Dec 2015 11:44:54 +0000 (+0000) Subject: Use new Dolby website for both Doremi and Dolby certificates (#775). X-Git-Tag: v2.6.8~3 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=5acc1fe1a98bbefbc3c3750f3e681b00642e8eee Use new Dolby website for both Doremi and Dolby certificates (#775). --- diff --git a/ChangeLog b/ChangeLog index 7aa8facf0..0cdf8131b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-12-21 c.hetherington + + * Use new Dolby website for both Doremi and Dolby certificates (#775). + 2015-12-18 c.hetherington * Fix double-calculation of DCP hashes. diff --git a/src/wx/dolby_certificate_panel.cc b/src/wx/dolby_certificate_panel.cc deleted file mode 100644 index 45d52eca2..000000000 --- a/src/wx/dolby_certificate_panel.cc +++ /dev/null @@ -1,224 +0,0 @@ -/* - Copyright (C) 2014-2015 Carl Hetherington - - 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 "dolby_certificate_panel.h" -#include "download_certificate_dialog.h" -#include "wx_util.h" -#include "lib/compose.hpp" -#include "lib/internet.h" -#include "lib/signal_manager.h" -#include "lib/util.h" -#include -#include -#include -#include - -using std::list; -using std::string; -using std::vector; -using std::cout; -using boost::optional; -using boost::algorithm::split; -using boost::algorithm::is_any_of; - -DolbyCertificatePanel::DolbyCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (parent, dialog) -{ - 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_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_label_to_sizer (_table, this, _("Serial number"), true); - _serial = new wxChoice (this, wxID_ANY); - _table->Add (_serial, 1, wxEXPAND); - - layout (); - - _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 (); -} - -string -DolbyCertificatePanel::url (string path) const -{ - return String::compose ("ftp://dolbyrootcertificates:houro61l@ftp.dolby.co.uk/SHA256/%1", path); -} - -list -DolbyCertificatePanel::get_dir (string dir) const -{ - return ftp_ls (url (dir), false); -} - -void -DolbyCertificatePanel::setup_countries () -{ - if (_country->GetCount() > 0) { - /* Already set up */ - return; - } - - _country->Append (_("Fetching...")); - _country->SetSelection (0); - - /* See DoremiCertificatePanel for discussion about this daft delay */ - wxMilliSleep (200); - - signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_setup_countries, this)); -} - -void -DolbyCertificatePanel::finish_setup_countries () -{ - try { - list const c = get_dir (""); - _country->Clear (); - BOOST_FOREACH (string i, c) { - _country->Append (std_to_wx (i)); - } - } catch (NetworkError& e) { - error_dialog (this, wxString::Format (_("Could not get country list (%s)"), e.what())); - _country->Clear (); - } -} - -void -DolbyCertificatePanel::country_selected () -{ - _cinema->Clear (); - _cinema->Append (_("Fetching...")); - _cinema->SetSelection (0); - -#ifdef DCPOMATIC_OSX - wxMilliSleep (200); -#endif - signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_country_selected, this)); -} - -void -DolbyCertificatePanel::finish_country_selected () -{ - try { - list const c = get_dir (wx_to_std (_country->GetStringSelection())); - _cinema->Clear (); - BOOST_FOREACH (string i, c) { - _cinema->Append (std_to_wx (i)); - } - } catch (NetworkError& e) { - error_dialog (this, wxString::Format (_("Could not get cinema list (%s)"), e.what ())); - _cinema->Clear (); - } -} - -void -DolbyCertificatePanel::cinema_selected () -{ - _serial->Clear (); - _serial->Append (_("Fetching...")); - _serial->SetSelection (0); - -#ifdef DCPOMATIC_OSX - wxMilliSleep (200); -#endif - signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_cinema_selected, this)); -} - -void -DolbyCertificatePanel::finish_cinema_selected () -{ - try { - list const s = get_dir (String::compose ("%1/%2", wx_to_std (_country->GetStringSelection()), wx_to_std (_cinema->GetStringSelection()))); - _serial->Clear (); - BOOST_FOREACH (string i, s) { - vector a; - split (a, i, is_any_of ("-_")); - if (a.size() >= 4) { - _serial->Append (std_to_wx (a[3]), new wxStringClientData (std_to_wx (i))); - } - } - } catch (NetworkError& e) { - error_dialog (this, wxString::Format (_("Could not get screen list (%s)"), e.what())); - _serial->Clear (); - } -} - -void -DolbyCertificatePanel::download (wxStaticText* message) -{ - message->SetLabel (_("Downloading certificate")); - -#ifdef DCPOMATIC_OSX - wxMilliSleep (200); -#endif - - signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_download, this, message)); -} - -void -DolbyCertificatePanel::finish_download (wxStaticText* message) -{ - string const zip = string_client_data (_serial->GetClientObject (_serial->GetSelection ())); - - string const file = url ( - String::compose ("%1/%2/%3", - wx_to_std (_country->GetStringSelection()), - wx_to_std (_cinema->GetStringSelection()), - zip - ) - ); - - /* Work out the certificate file name inside the zip */ - vector b; - split (b, zip, is_any_of ("_")); - if (b.size() < 2) { - message->SetLabel (_("Unexpected certificate filename form")); - return; - } - string const cert = b[0] + "_" + b[1] + ".pem.crt"; - - optional error = get_from_zip_url (file, cert, false, boost::bind (&DownloadCertificatePanel::load, this, _1)); - if (error) { - message->SetLabel (std_to_wx (error.get ())); - } else { - message->SetLabel (_("Certificate downloaded")); - _dialog->setup_sensitivity (); - } -} - -bool -DolbyCertificatePanel::ready_to_download () const -{ - return _country->GetSelection() != -1 && _cinema->GetSelection() != -1 && _serial->GetSelection() != -1; -} - -void -DolbyCertificatePanel::setup () -{ - signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::setup_countries, this)); -} diff --git a/src/wx/dolby_certificate_panel.h b/src/wx/dolby_certificate_panel.h deleted file mode 100644 index c004a7717..000000000 --- a/src/wx/dolby_certificate_panel.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2014-2015 Carl Hetherington - - 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 "download_certificate_panel.h" -#include -#include - -class DolbyCertificatePanel : public DownloadCertificatePanel -{ -public: - DolbyCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); - - void setup (); - bool ready_to_download () const; - void download (wxStaticText* message); - -private: - 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 (); - std::string url (std::string path) const; - std::list get_dir (std::string) const; - - wxChoice* _country; - wxChoice* _cinema; - wxChoice* _serial; -}; diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc new file mode 100644 index 000000000..e2035b1fb --- /dev/null +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -0,0 +1,146 @@ +/* + Copyright (C) 2014-2015 Carl Hetherington + + 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 "dolby_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 +#include +#include +#include +#include + +using std::string; +using std::cout; +using std::list; +using boost::function; +using boost::optional; + +DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (parent, dialog) +{ + 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 (&DownloadCertificateDialog::setup_sensitivity, _dialog)); + + 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)); +} + +void +DolbyDoremiCertificatePanel::finish_download (string serial, 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; + + urls.push_back (String::compose ("%1%2xxx/dcp2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial)); + files.push_back (String::compose ("dcp2000-%1.cert.sha256.pem", serial)); + + urls.push_back (String::compose ("%1%2xxx/dcp2000-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial)); + files.push_back (String::compose ("dcp2000-%1.cert.sha256.pem", serial)); + + urls.push_back (String::compose ("%1%2xxx/dcp2000-%3.certs.zip", prefix, serial.substr(0, 3), serial)); + files.push_back (String::compose ("dcp2000-%1.cert.sha256.pem", serial)); + + urls.push_back (String::compose ("%1%2xxx/imb-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial)); + files.push_back (String::compose ("imb-%1.cert.sha256.pem", serial)); + + urls.push_back (String::compose ("%1%2xxx/ims-%3.dcicerts.zip", prefix, serial.substr(0, 3), serial)); + files.push_back (String::compose ("ims-%1.cert.sha256.pem", serial)); + + int const serial_int = dcp::raw_convert (serial); + + string cat862; + if (serial_int <= 510999) { + cat862 = "CAT862_510999_and_lower"; + } else if (serial_int >= 617000) { + cat862 = "CAT862_617000_and_higher"; + } else { + int const lower = serial_int - (serial_int % 1000); + cat862 = String::compose ("CAT862_%1-%2", lower, lower + 999); + } + + urls.push_back (String::compose ("%1%2/cert_Dolby256-CAT862-%3.zip", prefix, cat862, serial_int)); + files.push_back (String::compose ("cert_Dolby256-CAT862-%1.pem.crt", serial_int)); + + string dsp100; + if (serial_int <= 999) { + dsp100 = "DSP100_053_thru_999"; + } else if (serial_int >= 3000) { + dsp100 = "DSP100_3000_and_higher"; + } else { + int const lower = serial_int - (serial_int % 1000); + dsp100 = String::compose ("DSP100_%1_thru_%2", lower, lower + 999); + } + + urls.push_back (String::compose ("%1%2/cert_Dolby256-DSP100-%3.zip", prefix, dsp100, serial_int)); + files.push_back (String::compose ("cert_Dolby256-DSP100-%1.pem.crt", serial_int)); + + list errors; + bool ok = false; + list::const_iterator i = urls.begin (); + list::const_iterator j = files.begin (); + while (!ok && i != urls.end ()) { + optional error = get_from_zip_url (*i++, *j++, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + if (error) { + errors.push_back (error.get ()); + } else { + ok = true; + } + } + + if (ok) { + message->SetLabel (_("Certificate downloaded")); + _dialog->setup_sensitivity (); + } else { + message->SetLabel (wxT ("")); + + SafeStringStream s; + BOOST_FOREACH (string e, errors) { + s << e << "\n"; + } + + error_dialog (this, std_to_wx (s.str ())); + } +} + +bool +DolbyDoremiCertificatePanel::ready_to_download () const +{ + return !_serial->IsEmpty (); +} diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h new file mode 100644 index 000000000..677403cff --- /dev/null +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2014-2015 Carl Hetherington + + 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 "download_certificate_panel.h" + +class DolbyDoremiCertificatePanel : public DownloadCertificatePanel +{ +public: + DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + + bool ready_to_download () const; + void download (wxStaticText* message); + +private: + void finish_download (std::string serial, wxStaticText* message); + + wxTextCtrl* _serial; +}; diff --git a/src/wx/doremi_certificate_panel.cc b/src/wx/doremi_certificate_panel.cc deleted file mode 100644 index bdc0b0377..000000000 --- a/src/wx/doremi_certificate_panel.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright (C) 2014-2015 Carl Hetherington - - 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 "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 -#include -#include -#include - -using std::string; -using std::cout; -using std::list; -using boost::function; -using boost::optional; - -DoremiCertificatePanel::DoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (parent, dialog) -{ - 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 (&DownloadCertificateDialog::setup_sensitivity, _dialog)); - - layout (); -} - -void -DoremiCertificatePanel::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 (&DoremiCertificatePanel::finish_download, this, wx_to_std (_serial->GetValue ()), message)); -} - -void -DoremiCertificatePanel::finish_download (string serial, wxStaticText* message) -{ - /* Try dcp2000, imb and ims prefixes (see mantis #375) */ - - list errors; - - optional error = get_from_zip_url ( - String::compose ( - "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/dcp2000-%2.dcicerts.zip", - serial.substr(0, 3), serial - ), - String::compose ("dcp2000-%1.cert.sha256.pem", serial), - true, - boost::bind (&DownloadCertificatePanel::load, this, _1) - ); - - if (error) { - errors.push_back (error.get ()); - error = get_from_zip_url ( - String::compose ( - "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/dcp2000-%2.certs.zip", - serial.substr(0, 3), serial - ), - String::compose ("dcp2000-%1.cert.sha256.pem", serial), - true, - boost::bind (&DownloadCertificatePanel::load, this, _1) - ); - } - - if (error) { - errors.push_back (error.get ()); - error = get_from_zip_url ( - String::compose ( - "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/imb-%2.dcicerts.zip", - serial.substr(0, 3), serial - ), - String::compose ("imb-%1.cert.sha256.pem", serial), - true, - boost::bind (&DownloadCertificatePanel::load, this, _1) - ); - } - - if (error) { - errors.push_back (error.get ()); - error = get_from_zip_url ( - String::compose ( - "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/ims-%2.dcicerts.zip", - serial.substr(0, 3), serial - ), - String::compose ("ims-%1.cert.sha256.pem", serial), - true, - boost::bind (&DownloadCertificatePanel::load, this, _1) - ); - } - - if (error) { - errors.push_back (error.get ()); - message->SetLabel (wxT ("")); - - SafeStringStream s; - BOOST_FOREACH (string e, errors) { - s << e << "\n"; - } - - error_dialog (this, std_to_wx (s.str ())); - } else { - message->SetLabel (_("Certificate downloaded")); - _dialog->setup_sensitivity (); - } -} - -bool -DoremiCertificatePanel::ready_to_download () const -{ - return !_serial->IsEmpty (); -} diff --git a/src/wx/doremi_certificate_panel.h b/src/wx/doremi_certificate_panel.h deleted file mode 100644 index 5fc455098..000000000 --- a/src/wx/doremi_certificate_panel.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2014-2015 Carl Hetherington - - 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 "download_certificate_panel.h" - -class DoremiCertificatePanel : public DownloadCertificatePanel -{ -public: - DoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); - - bool ready_to_download () const; - void download (wxStaticText* message); - -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 8b51edc16..0561d63cb 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -17,8 +17,7 @@ */ -#include "doremi_certificate_panel.h" -#include "dolby_certificate_panel.h" +#include "dolby_doremi_certificate_panel.h" #include "download_certificate_dialog.h" #include "wx_util.h" @@ -32,12 +31,9 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) _notebook = new wxNotebook (this, wxID_ANY); sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - _pages.push_back (new DoremiCertificatePanel (_notebook, this)); + _pages.push_back (new DolbyDoremiCertificatePanel (_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); + _notebook->AddPage (_pages.back(), _("Dolby / Doremi"), true); _download = new wxButton (this, wxID_ANY, _("Download")); sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); diff --git a/src/wx/wscript b/src/wx/wscript index 393cfcd39..8dc3e972e 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -43,8 +43,7 @@ sources = """ image_sequence_dialog.cc isdcf_metadata_dialog.cc dir_picker_ctrl.cc - dolby_certificate_panel.cc - doremi_certificate_panel.cc + dolby_doremi_certificate_panel.cc download_certificate_dialog.cc download_certificate_panel.cc file_picker_ctrl.cc