Build fixes for Boost >= 1.73
[dcpomatic.git] / src / wx / barco_alchemy_certificate_panel.cc
1 /*
2     Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #include "barco_alchemy_certificate_panel.h"
22 #include "download_certificate_dialog.h"
23 #include "wx_util.h"
24 #include "lib/internet.h"
25 #include "lib/compose.hpp"
26 #include "lib/config.h"
27
28 using std::string;
29 using boost::optional;
30 #if BOOST_VERSION >= 106100
31 using namespace boost::placeholders;
32 #endif
33
34 BarcoAlchemyCertificatePanel::BarcoAlchemyCertificatePanel (DownloadCertificateDialog* dialog)
35         : DownloadCertificatePanel (dialog)
36 {
37
38 }
39
40 bool
41 BarcoAlchemyCertificatePanel::ready_to_download () const
42 {
43         return _serial->GetValue().Length() == 10;
44 }
45
46 void
47 BarcoAlchemyCertificatePanel::do_download ()
48 {
49         Config* config = Config::instance ();
50         if (!config->barco_username() || !config->barco_password()) {
51                 _dialog->message()->SetLabel(wxT(""));
52                 error_dialog (this, _("No Barco username/password configured.  Add your account details to the Accounts page in Preferences."));
53                 return;
54         }
55
56         string const serial = wx_to_std (_serial->GetValue());
57         string const url = String::compose (
58                 "ftp://%1:%2@certificates.barco.com/%3xxx/%4/Barco-ICMP.%5_cert.pem",
59                 Config::instance()->barco_username().get(),
60                 Config::instance()->barco_password().get(),
61                 serial.substr(0, 7),
62                 serial,
63                 serial
64                 );
65
66         optional<string> error = get_from_url (url, true, false, boost::bind (&DownloadCertificatePanel::load_certificate, this, _1));
67         if (error) {
68                 _dialog->message()->SetLabel(wxT(""));
69                 error_dialog (this, std_to_wx(*error));
70         } else {
71                 _dialog->message()->SetLabel (_("Certificate downloaded"));
72                 _dialog->setup_sensitivity ();
73         }
74 }
75
76 wxString
77 BarcoAlchemyCertificatePanel::name () const
78 {
79         return _("Barco Alchemy");
80 }