Add FilmViewer::time_until_next_frame.
[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
31 BarcoAlchemyCertificatePanel::BarcoAlchemyCertificatePanel (DownloadCertificateDialog* dialog)
32         : CredentialsDownloadCertificatePanel (
33                         dialog,
34                         boost::bind(&Config::barco_username, Config::instance()),
35                         boost::bind(&Config::set_barco_username, Config::instance(), _1),
36                         boost::bind(&Config::unset_barco_username, Config::instance()),
37                         boost::bind(&Config::barco_password, Config::instance()),
38                         boost::bind(&Config::set_barco_password, Config::instance(), _1),
39                         boost::bind(&Config::unset_barco_password, Config::instance())
40                         )
41 {
42
43 }
44
45 bool
46 BarcoAlchemyCertificatePanel::ready_to_download () const
47 {
48         return CredentialsDownloadCertificatePanel::ready_to_download() && _serial->GetValue().Length() == 10;
49 }
50
51 void
52 BarcoAlchemyCertificatePanel::do_download ()
53 {
54         string const serial = wx_to_std (_serial->GetValue());
55         string const url = String::compose (
56                 "ftp://%1:%2@certificates.barco.com/%3xxx/%4/Barco-ICMP.%5_cert.pem",
57                 Config::instance()->barco_username().get(),
58                 Config::instance()->barco_password().get(),
59                 serial.substr(0, 7),
60                 serial,
61                 serial
62                 );
63
64         optional<string> error = get_from_url (url, true, false, boost::bind (&DownloadCertificatePanel::load, this, _1));
65         if (error) {
66                 _dialog->message()->SetLabel(wxT(""));
67                 error_dialog (this, std_to_wx(*error));
68         } else {
69                 _dialog->message()->SetLabel (_("Certificate downloaded"));
70                 _dialog->setup_sensitivity ();
71         }
72 }
73
74 wxString
75 BarcoAlchemyCertificatePanel::name () const
76 {
77         return _("Barco Alchemy");
78 }