2 Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "gdc_certificate_panel.h"
22 #include "download_certificate_dialog.h"
24 #include "lib/internet.h"
25 #include "lib/compose.hpp"
26 #include "lib/config.h"
29 using boost::optional;
31 #if BOOST_VERSION >= 106100
32 using namespace boost::placeholders;
35 GDCCertificatePanel::GDCCertificatePanel (DownloadCertificateDialog* dialog)
36 : CredentialsDownloadCertificatePanel (
38 bind(&Config::gdc_username, Config::instance()),
39 bind(&Config::set_gdc_username, Config::instance(), _1),
40 bind(&Config::unset_gdc_username, Config::instance()),
41 bind(&Config::gdc_password, Config::instance()),
42 bind(&Config::set_gdc_password, Config::instance(), _1),
43 bind(&Config::unset_gdc_password, Config::instance())
50 GDCCertificatePanel::do_download ()
52 string serial = wx_to_std (_serial->GetValue());
53 if (!serial.empty() && serial[0] == 'A') {
54 /* We're adding the A ourselves */
55 serial = serial.substr(1);
57 string const url = String::compose(
58 "ftp://%1:%2@ftp.gdc-tech.com/SHA256/A%3.crt.pem",
59 Config::instance()->gdc_username().get(),
60 Config::instance()->gdc_password().get(),
64 auto error = get_from_url (url, true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1, _2));
67 _dialog->message()->SetLabel(wxT(""));
68 error_dialog (this, std_to_wx(*error));
70 _dialog->message()->SetLabel (_("Certificate downloaded"));
71 _dialog->setup_sensitivity ();
76 GDCCertificatePanel::name () const