X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fchristie_certificate_panel.cc;h=ab131e015cf0ba95135cef0693e38e2b2b743634;hb=8ccbe70f3c2f5db9e88978a98f3ad5735ece07ab;hp=53d815bf7a3a0663158294c933fa8ac29d865eb2;hpb=89abe02431bd8d885197883a3ffafdc8d836dce4;p=dcpomatic.git diff --git a/src/wx/christie_certificate_panel.cc b/src/wx/christie_certificate_panel.cc index 53d815bf7..ab131e015 100644 --- a/src/wx/christie_certificate_panel.cc +++ b/src/wx/christie_certificate_panel.cc @@ -27,9 +27,22 @@ using std::string; using boost::optional; +using boost::bind; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (dialog) + : CredentialsDownloadCertificatePanel ( + dialog, + bind(&Config::christie_username, Config::instance()), + bind(&Config::set_christie_username, Config::instance(), _1), + bind(&Config::unset_christie_username, Config::instance()), + bind(&Config::christie_password, Config::instance()), + bind(&Config::set_christie_password, Config::instance(), _1), + bind(&Config::unset_christie_password, Config::instance()) + ) + { } @@ -37,46 +50,39 @@ ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* d void ChristieCertificatePanel::do_download () { - Config* config = Config::instance (); - if (!config->christie_username() || !config->christie_password()) { - _dialog->message()->SetLabel(wxT("")); - error_dialog (this, _("No Christie username/password configured. Add your account details to the Accounts page in Preferences.")); - return; - } - - string const serial = wx_to_std (_serial->GetValue()); - string const url = String::compose ( - "ftp://%1:%2@certificates.christiedigital.com/Certificates/F-IMB/F-IMB_000000%3_sha256.pem", + string const prefix = String::compose( + "ftp://%1:%2@certificates.christiedigital.com/Certificates/", Config::instance()->christie_username().get(), - Config::instance()->christie_password().get(), - serial + Config::instance()->christie_password().get() ); + string serial = wx_to_std (_serial->GetValue()); + serial.insert (0, 12 - serial.length(), '0'); + + string const url = String::compose ("%1F-IMB/F-IMB_%2_sha256.pem", prefix, serial); + optional all_errors; + bool ok = true; - optional error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + optional error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate_from_chain, this, _1)); if (error) { all_errors = *error; - string const url = String::compose ( - "ftp://%1:%2@certificates.christiedigital.com/Certificates/F-IMB/F-IMB_000000%3_sha256.pem", - Config::instance()->christie_username().get(), - Config::instance()->christie_password().get(), - serial - ); + string const url = String::compose ("%1IMB-S2/IMB-S2_%2_sha256.pem", prefix, serial); - error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate_from_chain, this, _1)); if (error) { *all_errors += "\n" + *error; + ok = false; } } - if (all_errors) { - _dialog->message()->SetLabel(wxT("")); - error_dialog (this, std_to_wx(*all_errors)); - } else { + if (ok) { _dialog->message()->SetLabel (_("Certificate downloaded")); _dialog->setup_sensitivity (); + } else { + _dialog->message()->SetLabel(wxT("")); + error_dialog (this, std_to_wx(*all_errors)); } }