X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fdolby_certificate_dialog.cc;h=8661cd5f88bd9f5e6b32f4775408bab742bc94c2;hb=ffa5a512112809e2256cae7a01afcd14c99c83a6;hp=5e094844de59697771c0af68827733ceddebf983;hpb=0b6c6de07f9a3aa28c2e8ca8ef30340e3fa1bfc6;p=dcpomatic.git diff --git a/src/wx/dolby_certificate_dialog.cc b/src/wx/dolby_certificate_dialog.cc index 5e094844d..8661cd5f8 100644 --- a/src/wx/dolby_certificate_dialog.cc +++ b/src/wx/dolby_certificate_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + 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 @@ -17,13 +17,16 @@ */ -#include -#include -#include "lib/compose.hpp" -#include "lib/internet.h" -#include "lib/ui_signaller.h" #include "dolby_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; @@ -39,7 +42,7 @@ DolbyCertificateDialog::DolbyCertificateDialog (wxWindow* parent, boost::functio add (_("Country"), true); _country = add (new wxChoice (this, wxID_ANY)); _country->Append (N_("Hashemite Kingdom of Jordan")); - + add (_("Cinema"), true); _cinema = add (new wxChoice (this, wxID_ANY)); _cinema->Append (N_("Motion Picture Solutions London Mobile & QC")); @@ -52,7 +55,7 @@ DolbyCertificateDialog::DolbyCertificateDialog (wxWindow* parent, boost::functio _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)); - Bind (wxEVT_IDLE, boost::bind (&DolbyCertificateDialog::setup_countries, this)); + signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::setup_countries, this)); _country->Clear (); _cinema->Clear (); @@ -62,7 +65,7 @@ list DolbyCertificateDialog::get_dir (string dir) const { string url = String::compose ("ftp://dolbyrootcertificates:houro61l@ftp.dolby.co.uk/SHA256/%1", dir); - return ftp_ls (url); + return ftp_ls (url, false); } void @@ -72,24 +75,28 @@ DolbyCertificateDialog::setup_countries () /* Already set up */ return; } - + _country->Append (_("Fetching...")); _country->SetSelection (0); -#ifdef DCPOMATIC_OSX /* See DoremiCertificateDialog for discussion about this daft delay */ wxMilliSleep (200); -#endif - ui_signaller->when_idle (boost::bind (&DolbyCertificateDialog::finish_setup_countries, this)); + + signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_setup_countries, this)); } void DolbyCertificateDialog::finish_setup_countries () { - list const countries = get_dir (""); - _country->Clear (); - for (list::const_iterator i = countries.begin(); i != countries.end(); ++i) { - _country->Append (std_to_wx (*i)); + 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 (); } } @@ -102,17 +109,22 @@ DolbyCertificateDialog::country_selected () #ifdef DCPOMATIC_OSX wxMilliSleep (200); -#endif - ui_signaller->when_idle (boost::bind (&DolbyCertificateDialog::finish_country_selected, this)); +#endif + signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_country_selected, this)); } void DolbyCertificateDialog::finish_country_selected () { - list const cinemas = get_dir (wx_to_std (_country->GetStringSelection())); - _cinema->Clear (); - for (list::const_iterator i = cinemas.begin(); i != cinemas.end(); ++i) { - _cinema->Append (std_to_wx (*i)); + 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 (); } } @@ -126,22 +138,25 @@ DolbyCertificateDialog::cinema_selected () #ifdef DCPOMATIC_OSX wxMilliSleep (200); #endif - ui_signaller->when_idle (boost::bind (&DolbyCertificateDialog::finish_cinema_selected, this)); + signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_cinema_selected, this)); } void DolbyCertificateDialog::finish_cinema_selected () { - string const dir = String::compose ("%1/%2", wx_to_std (_country->GetStringSelection()), wx_to_std (_cinema->GetStringSelection())); - list const zips = get_dir (dir); - - _serial->Clear (); - for (list::const_iterator i = zips.begin(); i != zips.end(); ++i) { - 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))); + 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 (); } } @@ -154,13 +169,14 @@ DolbyCertificateDialog::serial_selected () void DolbyCertificateDialog::download () { + downloaded (false); _message->SetLabel (_("Downloading certificate")); #ifdef DCPOMATIC_OSX wxMilliSleep (200); #endif - ui_signaller->when_idle (boost::bind (&DolbyCertificateDialog::finish_download, this)); + signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_download, this)); } void @@ -189,5 +205,6 @@ DolbyCertificateDialog::finish_download () _message->SetLabel (std_to_wx (error.get ())); } else { _message->SetLabel (_("Certificate downloaded")); + downloaded (true); } }