+++ /dev/null
-/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "dolby_certificate_dialog.h"
-#include "wx_util.h"
-#include "lib/compose.hpp"
-#include "lib/internet.h"
-#include "lib/signal_manager.h"
-#include "lib/util.h"
-#include <curl/curl.h>
-#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
-#include <iostream>
-
-using std::list;
-using std::string;
-using std::vector;
-using std::cout;
-using boost::optional;
-using boost::algorithm::split;
-using boost::algorithm::is_any_of;
-
-DolbyCertificateDialog::DolbyCertificateDialog (wxWindow* parent, boost::function<void (boost::filesystem::path)> load)
- : DownloadCertificateDialog (parent, load)
-{
- add (_("Country"), true);
- _country = add (new wxChoice (this, wxID_ANY));
- _country->Append (N_("Hashemite Kingdom of Jordan"));
-
- add (_("Cinema"), true);
- _cinema = add (new wxChoice (this, wxID_ANY));
- _cinema->Append (N_("Motion Picture Solutions London Mobile & QC"));
-
- add (_("Serial number"), true);
- _serial = add (new wxChoice (this, wxID_ANY));
-
- add_common_widgets ();
-
- _country->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificateDialog::country_selected, this));
- _cinema->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificateDialog::cinema_selected, this));
- _serial->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificateDialog::serial_selected, this));
- signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::setup_countries, this));
-
- _country->Clear ();
- _cinema->Clear ();
-}
-
-list<string>
-DolbyCertificateDialog::get_dir (string dir) const
-{
- string url = String::compose ("ftp://dolbyrootcertificates:houro61l@ftp.dolby.co.uk/SHA256/%1", dir);
- return ftp_ls (url, false);
-}
-
-void
-DolbyCertificateDialog::setup_countries ()
-{
- if (_country->GetCount() > 0) {
- /* Already set up */
- return;
- }
-
- _country->Append (_("Fetching..."));
- _country->SetSelection (0);
-
- /* See DoremiCertificateDialog for discussion about this daft delay */
- wxMilliSleep (200);
-
- signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_setup_countries, this));
-}
-
-void
-DolbyCertificateDialog::finish_setup_countries ()
-{
- try {
- list<string> const c = get_dir ("");
- _country->Clear ();
- BOOST_FOREACH (string i, c) {
- _country->Append (std_to_wx (i));
- }
- } catch (NetworkError& e) {
- error_dialog (this, wxString::Format (_("Could not get country list (%s)"), e.what()));
- _country->Clear ();
- }
-}
-
-void
-DolbyCertificateDialog::country_selected ()
-{
- _cinema->Clear ();
- _cinema->Append (_("Fetching..."));
- _cinema->SetSelection (0);
-
-#ifdef DCPOMATIC_OSX
- wxMilliSleep (200);
-#endif
- signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_country_selected, this));
-}
-
-void
-DolbyCertificateDialog::finish_country_selected ()
-{
- try {
- list<string> const c = get_dir (wx_to_std (_country->GetStringSelection()));
- _cinema->Clear ();
- BOOST_FOREACH (string i, c) {
- _cinema->Append (std_to_wx (i));
- }
- } catch (NetworkError& e) {
- error_dialog (this, wxString::Format (_("Could not get cinema list (%s)"), e.what ()));
- _cinema->Clear ();
- }
-}
-
-void
-DolbyCertificateDialog::cinema_selected ()
-{
- _serial->Clear ();
- _serial->Append (_("Fetching..."));
- _serial->SetSelection (0);
-
-#ifdef DCPOMATIC_OSX
- wxMilliSleep (200);
-#endif
- signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_cinema_selected, this));
-}
-
-void
-DolbyCertificateDialog::finish_cinema_selected ()
-{
- try {
- list<string> const s = get_dir (String::compose ("%1/%2", wx_to_std (_country->GetStringSelection()), wx_to_std (_cinema->GetStringSelection())));
- _serial->Clear ();
- BOOST_FOREACH (string i, s) {
- vector<string> a;
- split (a, i, is_any_of ("-_"));
- if (a.size() >= 4) {
- _serial->Append (std_to_wx (a[3]), new wxStringClientData (std_to_wx (i)));
- }
- }
- } catch (NetworkError& e) {
- error_dialog (this, wxString::Format (_("Could not get screen list (%s)"), e.what()));
- _serial->Clear ();
- }
-}
-
-void
-DolbyCertificateDialog::serial_selected ()
-{
- _download->Enable (true);
-}
-
-void
-DolbyCertificateDialog::download ()
-{
- downloaded (false);
- _message->SetLabel (_("Downloading certificate"));
-
-#ifdef DCPOMATIC_OSX
- wxMilliSleep (200);
-#endif
-
- signal_manager->when_idle (boost::bind (&DolbyCertificateDialog::finish_download, this));
-}
-
-void
-DolbyCertificateDialog::finish_download ()
-{
- string const zip = string_client_data (_serial->GetClientObject (_serial->GetSelection ()));
-
- string const file = String::compose (
- "ftp://dolbyrootcertificates:houro61l@ftp.dolby.co.uk/SHA256/%1/%2/%3",
- wx_to_std (_country->GetStringSelection()),
- wx_to_std (_cinema->GetStringSelection()),
- zip
- );
-
- /* Work out the certificate file name inside the zip */
- vector<string> b;
- split (b, zip, is_any_of ("_"));
- if (b.size() < 2) {
- _message->SetLabel (_("Unexpected certificate filename form"));
- return;
- }
- string const cert = b[0] + "_" + b[1] + ".pem.crt";
-
- optional<string> error = get_from_zip_url (file, cert, _load);
- if (error) {
- _message->SetLabel (std_to_wx (error.get ()));
- } else {
- _message->SetLabel (_("Certificate downloaded"));
- downloaded (true);
- }
-}
+++ /dev/null
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <curl/curl.h>
-#include "download_certificate_dialog.h"
-
-class DolbyCertificateDialog : public DownloadCertificateDialog
-{
-public:
- DolbyCertificateDialog (wxWindow *, boost::function<void (boost::filesystem::path)>);
-
-private:
- void download ();
- void finish_download ();
- void setup_countries ();
- void finish_setup_countries ();
- void country_selected ();
- void finish_country_selected ();
- void cinema_selected ();
- void finish_cinema_selected ();
- void serial_selected ();
- std::list<std::string> get_dir (std::string) const;
-
- wxChoice* _country;
- wxChoice* _cinema;
- wxChoice* _serial;
-};
--- /dev/null
+/*
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "dolby_certificate_panel.h"
+#include "download_certificate_dialog.h"
+#include "wx_util.h"
+#include "lib/compose.hpp"
+#include "lib/internet.h"
+#include "lib/signal_manager.h"
+#include "lib/util.h"
+#include <curl/curl.h>
+#include <boost/algorithm/string.hpp>
+#include <boost/foreach.hpp>
+#include <iostream>
+
+using std::list;
+using std::string;
+using std::vector;
+using std::cout;
+using boost::optional;
+using boost::algorithm::split;
+using boost::algorithm::is_any_of;
+
+DolbyCertificatePanel::DolbyCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog)
+ : DownloadCertificatePanel (parent, dialog)
+{
+ add_label_to_sizer (_table, this, _("Country"), true);
+ _country = new wxChoice (this, wxID_ANY);
+ _table->Add (_country, 1, wxEXPAND);
+ _country->Append (N_("Hashemite Kingdom of Jordan"));
+
+ add_label_to_sizer (_table, this, _("Cinema"), true);
+ _cinema = new wxChoice (this, wxID_ANY);
+ _table->Add (_cinema, 1, wxEXPAND);
+ _cinema->Append (N_("Motion Picture Solutions London Mobile & QC"));
+
+ add_label_to_sizer (_table, this, _("Serial number"), true);
+ _serial = new wxChoice (this, wxID_ANY);
+ _table->Add (_serial, 1, wxEXPAND);
+
+ layout ();
+
+ _country->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificatePanel::country_selected, this));
+ _cinema->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificatePanel::cinema_selected, this));
+ _serial->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog));
+
+ _country->Clear ();
+ _cinema->Clear ();
+}
+
+list<string>
+DolbyCertificatePanel::get_dir (string dir) const
+{
+ string url = String::compose ("ftp://dolbyrootcertificates:houro61l@ftp.dolby.co.uk/SHA256/%1", dir);
+ return ftp_ls (url, false);
+}
+
+void
+DolbyCertificatePanel::setup_countries ()
+{
+ if (_country->GetCount() > 0) {
+ /* Already set up */
+ return;
+ }
+
+ _country->Append (_("Fetching..."));
+ _country->SetSelection (0);
+
+ /* See DoremiCertificatePanel for discussion about this daft delay */
+ wxMilliSleep (200);
+
+ signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_setup_countries, this));
+}
+
+void
+DolbyCertificatePanel::finish_setup_countries ()
+{
+ try {
+ list<string> const c = get_dir ("");
+ _country->Clear ();
+ BOOST_FOREACH (string i, c) {
+ _country->Append (std_to_wx (i));
+ }
+ } catch (NetworkError& e) {
+ error_dialog (this, wxString::Format (_("Could not get country list (%s)"), e.what()));
+ _country->Clear ();
+ }
+}
+
+void
+DolbyCertificatePanel::country_selected ()
+{
+ _cinema->Clear ();
+ _cinema->Append (_("Fetching..."));
+ _cinema->SetSelection (0);
+
+#ifdef DCPOMATIC_OSX
+ wxMilliSleep (200);
+#endif
+ signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_country_selected, this));
+}
+
+void
+DolbyCertificatePanel::finish_country_selected ()
+{
+ try {
+ list<string> const c = get_dir (wx_to_std (_country->GetStringSelection()));
+ _cinema->Clear ();
+ BOOST_FOREACH (string i, c) {
+ _cinema->Append (std_to_wx (i));
+ }
+ } catch (NetworkError& e) {
+ error_dialog (this, wxString::Format (_("Could not get cinema list (%s)"), e.what ()));
+ _cinema->Clear ();
+ }
+}
+
+void
+DolbyCertificatePanel::cinema_selected ()
+{
+ _serial->Clear ();
+ _serial->Append (_("Fetching..."));
+ _serial->SetSelection (0);
+
+#ifdef DCPOMATIC_OSX
+ wxMilliSleep (200);
+#endif
+ signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_cinema_selected, this));
+}
+
+void
+DolbyCertificatePanel::finish_cinema_selected ()
+{
+ try {
+ list<string> const s = get_dir (String::compose ("%1/%2", wx_to_std (_country->GetStringSelection()), wx_to_std (_cinema->GetStringSelection())));
+ _serial->Clear ();
+ BOOST_FOREACH (string i, s) {
+ vector<string> a;
+ split (a, i, is_any_of ("-_"));
+ if (a.size() >= 4) {
+ _serial->Append (std_to_wx (a[3]), new wxStringClientData (std_to_wx (i)));
+ }
+ }
+ } catch (NetworkError& e) {
+ error_dialog (this, wxString::Format (_("Could not get screen list (%s)"), e.what()));
+ _serial->Clear ();
+ }
+}
+
+void
+DolbyCertificatePanel::download (wxStaticText* message)
+{
+ message->SetLabel (_("Downloading certificate"));
+
+#ifdef DCPOMATIC_OSX
+ wxMilliSleep (200);
+#endif
+
+ signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::finish_download, this, message));
+}
+
+void
+DolbyCertificatePanel::finish_download (wxStaticText* message)
+{
+ string const zip = string_client_data (_serial->GetClientObject (_serial->GetSelection ()));
+
+ string const file = String::compose (
+ "ftp://dolbyrootcertificates:houro61l@ftp.dolby.co.uk/SHA256/%1/%2/%3",
+ wx_to_std (_country->GetStringSelection()),
+ wx_to_std (_cinema->GetStringSelection()),
+ zip
+ );
+
+ /* Work out the certificate file name inside the zip */
+ vector<string> b;
+ split (b, zip, is_any_of ("_"));
+ if (b.size() < 2) {
+ message->SetLabel (_("Unexpected certificate filename form"));
+ return;
+ }
+ string const cert = b[0] + "_" + b[1] + ".pem.crt";
+
+ optional<string> error = get_from_zip_url (file, cert, boost::bind (&DownloadCertificatePanel::load, this, _1));
+ if (error) {
+ message->SetLabel (std_to_wx (error.get ()));
+ } else {
+ message->SetLabel (_("Certificate downloaded"));
+ }
+}
+
+bool
+DolbyCertificatePanel::ready_to_download () const
+{
+ /* XXX */
+ return false;
+}
+
+void
+DolbyCertificatePanel::setup ()
+{
+ signal_manager->when_idle (boost::bind (&DolbyCertificatePanel::setup_countries, this));
+}
--- /dev/null
+/*
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "download_certificate_panel.h"
+#include <curl/curl.h>
+#include <list>
+
+class DolbyCertificatePanel : public DownloadCertificatePanel
+{
+public:
+ DolbyCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog);
+
+ void setup ();
+ bool ready_to_download () const;
+ void download (wxStaticText* message);
+
+private:
+ void finish_download (wxStaticText* message);
+ void setup_countries ();
+ void finish_setup_countries ();
+ void country_selected ();
+ void finish_country_selected ();
+ void cinema_selected ();
+ void finish_cinema_selected ();
+ std::list<std::string> get_dir (std::string) const;
+
+ wxChoice* _country;
+ wxChoice* _cinema;
+ wxChoice* _serial;
+};
+++ /dev/null
-/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <curl/curl.h>
-#include <zip.h>
-#include "lib/compose.hpp"
-#include "lib/util.h"
-#include "lib/signal_manager.h"
-#include "lib/internet.h"
-#include "doremi_certificate_dialog.h"
-#include "wx_util.h"
-#include <iostream>
-
-using std::string;
-using std::cout;
-using boost::function;
-using boost::optional;
-
-DoremiCertificateDialog::DoremiCertificateDialog (wxWindow* parent, function<void (boost::filesystem::path)> load)
- : DownloadCertificateDialog (parent, load)
-{
- add (_("Server serial number"), true);
- _serial = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1)));
-
- _serial->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DoremiCertificateDialog::set_sensitivity, this));
-
- add_common_widgets ();
-}
-
-void
-DoremiCertificateDialog::download ()
-{
- string const serial = wx_to_std (_serial->GetValue ());
- if (serial.length() != 6) {
- error_dialog (this, _("Doremi serial numbers must have 6 digits"));
- return;
- }
-
- downloaded (false);
- _message->SetLabel (_("Downloading certificate"));
-
- /* Hack: without this the SetLabel() above has no visible effect */
- wxMilliSleep (200);
-
- signal_manager->when_idle (boost::bind (&DoremiCertificateDialog::finish_download, this, serial));
-}
-
-void
-DoremiCertificateDialog::finish_download (string serial)
-{
- /* Try dcp2000, imb and ims prefixes (see mantis #375) */
-
- optional<string> error = get_from_zip_url (
- String::compose (
- "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/dcp2000-%2.dcicerts.zip",
- serial.substr(0, 3), serial
- ),
- String::compose ("dcp2000-%1.cert.sha256.pem", serial),
- _load
- );
-
- if (error) {
- error = get_from_zip_url (
- String::compose (
- "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/imb-%2.dcicerts.zip",
- serial.substr(0, 3), serial
- ),
- String::compose ("imb-%1.cert.sha256.pem", serial),
- _load
- );
- }
-
- if (error) {
- error = get_from_zip_url (
- String::compose (
- "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/ims-%2.dcicerts.zip",
- serial.substr(0, 3), serial
- ),
- String::compose ("ims-%1.cert.sha256.pem", serial),
- _load
- );
- }
-
- if (error) {
- _message->SetLabel (wxT (""));
- error_dialog (this, std_to_wx (error.get ()));
- } else {
- _message->SetLabel (_("Certificate downloaded"));
- downloaded (true);
- }
-}
-
-void
-DoremiCertificateDialog::set_sensitivity ()
-{
- _download->Enable (!_serial->IsEmpty ());
-}
+++ /dev/null
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "download_certificate_dialog.h"
-
-class DoremiCertificateDialog : public DownloadCertificateDialog
-{
-public:
- DoremiCertificateDialog (wxWindow *, boost::function<void (boost::filesystem::path)>);
-
-private:
- void download ();
- void set_sensitivity ();
-
- void finish_download (std::string serial);
-
- wxTextCtrl* _serial;
-};
--- /dev/null
+/*
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "doremi_certificate_panel.h"
+#include "download_certificate_dialog.h"
+#include "wx_util.h"
+#include "lib/compose.hpp"
+#include "lib/util.h"
+#include "lib/signal_manager.h"
+#include "lib/internet.h"
+#include <curl/curl.h>
+#include <zip.h>
+#include <iostream>
+
+using std::string;
+using std::cout;
+using boost::function;
+using boost::optional;
+
+DoremiCertificatePanel::DoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog)
+ : DownloadCertificatePanel (parent, dialog)
+{
+ add_label_to_sizer (_table, this, _("Server serial number"), true);
+ _serial = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1));
+ _table->Add (_serial, 1, wxEXPAND);
+
+ _serial->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog));
+
+ layout ();
+}
+
+void
+DoremiCertificatePanel::download (wxStaticText* message)
+{
+ string const serial = wx_to_std (_serial->GetValue ());
+ if (serial.length() != 6) {
+ error_dialog (this, _("Doremi serial numbers must have 6 digits"));
+ return;
+ }
+
+ message->SetLabel (_("Downloading certificate"));
+
+ /* Hack: without this the SetLabel() above has no visible effect */
+ wxMilliSleep (200);
+
+ signal_manager->when_idle (boost::bind (&DoremiCertificatePanel::finish_download, this, serial, message));
+}
+
+void
+DoremiCertificatePanel::finish_download (string serial, wxStaticText* message)
+{
+ /* Try dcp2000, imb and ims prefixes (see mantis #375) */
+
+ optional<string> error = get_from_zip_url (
+ String::compose (
+ "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/dcp2000-%2.dcicerts.zip",
+ serial.substr(0, 3), serial
+ ),
+ String::compose ("dcp2000-%1.cert.sha256.pem", serial),
+ boost::bind (&DownloadCertificatePanel::load, this, _1)
+ );
+
+ if (error) {
+ error = get_from_zip_url (
+ String::compose (
+ "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/imb-%2.dcicerts.zip",
+ serial.substr(0, 3), serial
+ ),
+ String::compose ("imb-%1.cert.sha256.pem", serial),
+ boost::bind (&DownloadCertificatePanel::load, this, _1)
+ );
+ }
+
+ if (error) {
+ error = get_from_zip_url (
+ String::compose (
+ "ftp://service:t3chn1c1an@ftp.doremilabs.com/Certificates/%1xxx/ims-%2.dcicerts.zip",
+ serial.substr(0, 3), serial
+ ),
+ String::compose ("ims-%1.cert.sha256.pem", serial),
+ boost::bind (&DownloadCertificatePanel::load, this, _1)
+ );
+ }
+
+ if (error) {
+ message->SetLabel (wxT (""));
+ error_dialog (this, std_to_wx (error.get ()));
+ } else {
+ message->SetLabel (_("Certificate downloaded"));
+ }
+}
+
+bool
+DoremiCertificatePanel::ready_to_download () const
+{
+ return !_serial->IsEmpty ();
+}
--- /dev/null
+/*
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "download_certificate_panel.h"
+
+class DoremiCertificatePanel : public DownloadCertificatePanel
+{
+public:
+ DoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog);
+
+ bool ready_to_download () const;
+ void download (wxStaticText* message);
+
+private:
+ void finish_download (std::string serial, wxStaticText* message);
+
+ wxTextCtrl* _serial;
+};
*/
-#include "wx_util.h"
+#include "doremi_certificate_panel.h"
+#include "dolby_certificate_panel.h"
#include "download_certificate_dialog.h"
-#include <boost/bind.hpp>
-
-using boost::function;
+#include "wx_util.h"
-DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent, function<void (boost::filesystem::path)> load)
- : TableDialog (parent, _("Download certificate"), 2, 1, true)
- , _load (load)
- , _message (0)
- , _download (0)
+DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent)
+ : wxDialog (parent, wxID_ANY, _("Download certificate"))
{
+ wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
-}
+ _notebook = new wxNotebook (this, wxID_ANY);
+ sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-void
-DownloadCertificateDialog::add_common_widgets ()
-{
- add_spacer ();
- _download = add (new wxButton (this, wxID_ANY, _("Download")));
+ _pages.push_back (new DoremiCertificatePanel (_notebook, this));
+ _setup.push_back (false);
+ _notebook->AddPage (_pages.back(), _("Doremi"), true);
+ _pages.push_back (new DolbyCertificatePanel (_notebook, this));
+ _setup.push_back (false);
+ _notebook->AddPage (_pages.back(), _("Dolby"), false);
- add_spacer ();
- _message = add (new wxStaticText (this, wxID_ANY, wxT ("")));
+ _download = new wxButton (this, wxID_ANY, _("Download"));
+ sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
+ _message = new wxStaticText (this, wxID_ANY, wxT (""));
+ sizer->Add (_message, 0, wxALL, DCPOMATIC_SIZER_GAP);
wxFont font = _message->GetFont();
font.SetStyle (wxFONTSTYLE_ITALIC);
font.SetPointSize (font.GetPointSize() - 1);
_message->SetFont (font);
+ wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+ if (buttons) {
+ sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+ }
+
+ SetSizerAndFit (sizer);
+
+ _notebook->Bind (wxEVT_NOTEBOOK_PAGE_CHANGED, boost::bind (&DownloadCertificateDialog::page_changed, this));
_download->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DownloadCertificateDialog::download, this));
_download->Enable (false);
- layout ();
+ page_changed ();
+}
+
+void
+DownloadCertificateDialog::download ()
+{
+ _pages[_notebook->GetSelection()]->download (_message);
+}
- wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
- ok->Enable (false);
+dcp::Certificate
+DownloadCertificateDialog::certificate () const
+{
+ return _pages[_notebook->GetSelection()]->certificate ();
+}
+
+void
+DownloadCertificateDialog::setup_sensitivity ()
+{
+ _download->Enable (_pages[_notebook->GetSelection()]->ready_to_download ());
}
void
-DownloadCertificateDialog::downloaded (bool done)
+DownloadCertificateDialog::page_changed ()
{
- wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
- ok->Enable (done);
+ int const n = _notebook->GetSelection();
+ if (!_setup[n]) {
+ _pages[n]->setup ();
+ _setup[n] = true;
+ }
}
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-#ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_DIALOG_H
-#define DCPOMATIC_DOWNLOAD_CERTIFICATE_DIALOG_H
-
#include <wx/wx.h>
-#include <boost/function.hpp>
-#include <boost/filesystem.hpp>
-#include "table_dialog.h"
+#include <wx/notebook.h>
+
+class DownloadCertificatePanel;
-class DownloadCertificateDialog : public TableDialog
+class DownloadCertificateDialog : public wxDialog
{
public:
- DownloadCertificateDialog (wxWindow *, boost::function<void (boost::filesystem::path)>);
+ DownloadCertificateDialog (wxWindow* parent);
-protected:
- void add_common_widgets ();
- void downloaded (bool done);
+ dcp::Certificate certificate () const;
- boost::function<void (boost::filesystem::path)> _load;
- wxStaticText* _message;
- wxButton* _download;
+ void setup_sensitivity ();
private:
- virtual void download () = 0;
-};
+ void download ();
+ void page_changed ();
-#endif
+ wxNotebook* _notebook;
+ std::vector<DownloadCertificatePanel*> _pages;
+ std::vector<bool> _setup;
+ wxButton* _download;
+ wxStaticText* _message;
+};
--- /dev/null
+/*
+ Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "wx_util.h"
+#include "download_certificate_panel.h"
+#include <dcp/util.h>
+#include <dcp/exceptions.h>
+#include <boost/bind.hpp>
+
+using boost::function;
+
+DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog)
+ : wxPanel (parent, wxID_ANY)
+ , _dialog (dialog)
+{
+ _overall_sizer = new wxBoxSizer (wxVERTICAL);
+ SetSizer (_overall_sizer);
+
+ _table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ _table->AddGrowableCol (1, 1);
+
+ _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+}
+
+void
+DownloadCertificatePanel::layout ()
+{
+ _overall_sizer->Layout ();
+ _overall_sizer->SetSizeHints (this);
+}
+
+void
+DownloadCertificatePanel::load (boost::filesystem::path file)
+{
+ try {
+ _certificate = dcp::Certificate (dcp::file_to_string (file));
+ } catch (dcp::MiscError& e) {
+ error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), std_to_wx(e.what()).data()));
+ }
+}
+
+dcp::Certificate
+DownloadCertificatePanel::certificate () const
+{
+ DCPOMATIC_ASSERT (_certificate);
+ return _certificate.get ();
+}
--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H
+#define DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H
+
+#include <dcp/certificate.h>
+#include <wx/wx.h>
+#include <boost/optional.hpp>
+
+class DownloadCertificateDialog;
+
+class DownloadCertificatePanel : public wxPanel
+{
+public:
+ DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog);
+
+ /* Do any setup that may take a noticeable amount of time */
+ virtual void setup () {}
+ virtual bool ready_to_download () const = 0;
+ virtual void download (wxStaticText* message) = 0;
+
+ void load (boost::filesystem::path);
+ dcp::Certificate certificate () const;
+
+protected:
+ void layout ();
+
+ DownloadCertificateDialog* _dialog;
+ wxFlexGridSizer* _table;
+
+private:
+ wxSizer* _overall_sizer;
+ boost::optional<dcp::Certificate> _certificate;
+};
+
+#endif
#include "screen_dialog.h"
#include "wx_util.h"
-#include "doremi_certificate_dialog.h"
-#include "dolby_certificate_dialog.h"
+#include "download_certificate_dialog.h"
#include "lib/compose.hpp"
#include "lib/util.h"
#include <dcp/exceptions.h>
add (_("Name"), true);
_name = add (new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (320, -1)));
- add (_("Server manufacturer"), true);
- _manufacturer = add (new wxChoice (this, wxID_ANY));
-
add (_("Certificate"), true);
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
_load_certificate = new wxButton (this, wxID_ANY, _("Load from file..."));
_certificate_text->SetFont (font);
add (_certificate_text);
- _manufacturer->Append (_("Unknown"));
- _manufacturer->Append (_("Doremi"));
- _manufacturer->Append (_("Dolby"));
- _manufacturer->Append (_("Other"));
- _manufacturer->SetSelection (0);
-
_load_certificate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreenDialog::select_certificate, this));
_download_certificate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreenDialog::download_certificate, this));
- _manufacturer->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ScreenDialog::setup_sensitivity, this));
setup_sensitivity ();
layout ();
{
try {
_certificate = dcp::Certificate (dcp::file_to_string (file));
- _certificate_text->SetValue (_certificate->certificate ());
+ _certificate_text->SetValue (std_to_wx (_certificate->certificate ()));
} catch (dcp::MiscError& e) {
error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), std_to_wx(e.what()).data()));
}
void
ScreenDialog::download_certificate ()
{
- if (_manufacturer->GetStringSelection() == _("Doremi")) {
- DownloadCertificateDialog* d = new DoremiCertificateDialog (this, boost::bind (&ScreenDialog::load_certificate, this, _1));
- d->ShowModal ();
- d->Destroy ();
- } else if (_manufacturer->GetStringSelection() == _("Dolby")) {
- DownloadCertificateDialog* d = new DolbyCertificateDialog (this, boost::bind (&ScreenDialog::load_certificate, this, _1));
- d->ShowModal ();
- d->Destroy ();
+ DownloadCertificateDialog* d = new DownloadCertificateDialog (this);
+ if (d->ShowModal() == wxID_OK) {
+ _certificate = d->certificate ();
+ _certificate_text->SetValue (std_to_wx (_certificate->certificate ()));
}
-
+ d->Destroy ();
setup_sensitivity ();
}
if (ok) {
ok->Enable (static_cast<bool>(_certificate));
}
-
- _download_certificate->Enable (
- _manufacturer->GetStringSelection() == _("Doremi") ||
- _manufacturer->GetStringSelection() == _("Dolby")
- );
}
void setup_sensitivity ();
wxTextCtrl* _name;
- wxChoice* _manufacturer;
wxButton* _load_certificate;
wxButton* _download_certificate;
wxTextCtrl* _certificate_text;
image_sequence_dialog.cc
isdcf_metadata_dialog.cc
dir_picker_ctrl.cc
- dolby_certificate_dialog.cc
- doremi_certificate_dialog.cc
+ dolby_certificate_panel.cc
+ doremi_certificate_panel.cc
download_certificate_dialog.cc
+ download_certificate_panel.cc
file_picker_ctrl.cc
film_editor.cc
film_viewer.cc