X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fdolby_certificate_dialog.cc;h=58ad73e0d2a25c0635ac7e208e78719a89e893f0;hb=aeb835a18c8df347e0ed68fb24631b320abeb611;hp=e5bb1896207fe396464624e7ca730093b8d217ab;hpb=d344423f8a0e9765684f5e25a6ce4966a3da31d0;p=dcpomatic.git diff --git a/src/wx/dolby_certificate_dialog.cc b/src/wx/dolby_certificate_dialog.cc index e5bb18962..58ad73e0d 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,17 +17,19 @@ */ -#include -#include -#include "lib/compose.hpp" -#include "lib/internet.h" #include "dolby_certificate_dialog.h" #include "wx_util.h" +#include "lib/compose.hpp" +#include "lib/internet.h" +#include "lib/signal_manager.h" +#include +#include +#include +#include using std::list; using std::string; using std::vector; -using std::stringstream; using std::cout; using boost::optional; using boost::algorithm::split; @@ -39,7 +41,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")); @@ -72,15 +74,23 @@ DolbyCertificateDialog::setup_countries () /* Already set up */ return; } - + _country->Append (_("Fetching...")); _country->SetSelection (0); - run_gui_loop (); - - list const countries = get_dir (""); + +#ifdef DCPOMATIC_OSX + /* See DoremiCertificateDialog for discussion about this daft delay */ + wxMilliSleep (200); +#endif + signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_setup_countries, this)); +} + +void +DolbyCertificateDialog::finish_setup_countries () +{ _country->Clear (); - for (list::const_iterator i = countries.begin(); i != countries.end(); ++i) { - _country->Append (std_to_wx (*i)); + BOOST_FOREACH (string i, get_dir ("")) { + _country->Append (std_to_wx (i)); } } @@ -90,12 +100,19 @@ DolbyCertificateDialog::country_selected () _cinema->Clear (); _cinema->Append (_("Fetching...")); _cinema->SetSelection (0); - run_gui_loop (); - - list const cinemas = get_dir (wx_to_std (_country->GetStringSelection())); + +#ifdef DCPOMATIC_OSX + wxMilliSleep (200); +#endif + signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_country_selected, this)); +} + +void +DolbyCertificateDialog::finish_country_selected () +{ _cinema->Clear (); - for (list::const_iterator i = cinemas.begin(); i != cinemas.end(); ++i) { - _cinema->Append (std_to_wx (*i)); + BOOST_FOREACH (string i, get_dir (wx_to_std (_country->GetStringSelection()))) { + _cinema->Append (std_to_wx (i)); } } @@ -105,17 +122,24 @@ DolbyCertificateDialog::cinema_selected () _serial->Clear (); _serial->Append (_("Fetching...")); _serial->SetSelection (0); - run_gui_loop (); +#ifdef DCPOMATIC_OSX + wxMilliSleep (200); +#endif + 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) { + BOOST_FOREACH (string i, get_dir (dir)) { vector a; - split (a, *i, is_any_of ("-_")); + split (a, i, is_any_of ("-_")); if (a.size() >= 4) { - _serial->Append (std_to_wx (a[3]), new wxStringClientData (std_to_wx (*i))); + _serial->Append (std_to_wx (a[3]), new wxStringClientData (std_to_wx (i))); } } } @@ -129,9 +153,19 @@ DolbyCertificateDialog::serial_selected () void DolbyCertificateDialog::download () { + downloaded (false); _message->SetLabel (_("Downloading certificate")); - run_gui_loop (); +#ifdef DCPOMATIC_OSX + wxMilliSleep (200); +#endif + + signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_download, this)); +} + +void +DolbyCertificateDialog::finish_download () +{ string const zip = string_client_data (_serial->GetClientObject (_serial->GetSelection ())); string const file = String::compose ( @@ -155,5 +189,6 @@ DolbyCertificateDialog::download () _message->SetLabel (std_to_wx (error.get ())); } else { _message->SetLabel (_("Certificate downloaded")); + downloaded (true); } }