X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fgdc_certificate_panel.cc;h=d78b1b56dfd2397bda51331cda5c7e0c0e43c938;hb=5063594e6836cfabed7d55f4963da9c8cf3b9f11;hp=a90f098f51b8e16874d9255cfd70a8763e2fbdf3;hpb=32e2c7b2a3cfabc9110f0b4720cc5d48185f9934;p=dcpomatic.git diff --git a/src/wx/gdc_certificate_panel.cc b/src/wx/gdc_certificate_panel.cc index a90f098f5..d78b1b56d 100644 --- a/src/wx/gdc_certificate_panel.cc +++ b/src/wx/gdc_certificate_panel.cc @@ -18,18 +18,35 @@ */ -#include "gdc_certificate_panel.h" + #include "download_certificate_dialog.h" +#include "gdc_certificate_panel.h" #include "wx_util.h" -#include "lib/internet.h" #include "lib/compose.hpp" #include "lib/config.h" +#include "lib/internet.h" +#include + using std::string; +using namespace boost::algorithm; +using boost::bind; using boost::optional; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif + GDCCertificatePanel::GDCCertificatePanel (DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (dialog) + : CredentialsDownloadCertificatePanel ( + dialog, + bind(&Config::gdc_username, Config::instance()), + bind(&Config::set_gdc_username, Config::instance(), _1), + bind(&Config::unset_gdc_username, Config::instance()), + bind(&Config::gdc_password, Config::instance()), + bind(&Config::set_gdc_password, Config::instance(), _1), + bind(&Config::unset_gdc_password, Config::instance()) + ) { } @@ -37,21 +54,21 @@ GDCCertificatePanel::GDCCertificatePanel (DownloadCertificateDialog* dialog) void GDCCertificatePanel::do_download () { - Config* config = Config::instance (); - if (!config->gdc_username() || !config->gdc_password()) { - _dialog->message()->SetLabel(wxT("")); - error_dialog (this, _("No GDC username/password configured. Add your account details to the Accounts page in Preferences.")); - return; + string serial = wx_to_std (_serial->GetValue()); + trim(serial); + if (!serial.empty() && serial[0] == 'A') { + /* We're adding the A ourselves */ + serial = serial.substr(1); } - - string const url = String::compose( + string url = String::compose( "ftp://%1:%2@ftp.gdc-tech.com/SHA256/A%3.crt.pem", Config::instance()->gdc_username().get(), Config::instance()->gdc_password().get(), - wx_to_std(_serial->GetValue()) + serial ); + trim(url); - optional error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + auto error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1, _2)); if (error) { _dialog->message()->SetLabel(wxT(""));