From c0d3ccb11d1bc31767a431c72f99e4a84c26b194 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 14 Aug 2018 23:23:15 +0100 Subject: Move some stuff into DownloadCertificatePanel; add name(). --- src/wx/dolby_doremi_certificate_panel.cc | 20 ++++++++------------ src/wx/dolby_doremi_certificate_panel.h | 3 ++- src/wx/download_certificate_dialog.cc | 5 ++++- src/wx/download_certificate_panel.cc | 14 +++++++++++++- src/wx/download_certificate_panel.h | 4 +++- 5 files changed, 30 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc index 6f59b9147..5a0ce028e 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -50,17 +50,6 @@ DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, Down layout (); } -void -DolbyDoremiCertificatePanel::download (wxStaticText* message) -{ - message->SetLabel (_("Downloading certificate")); - - /* Hack: without this the SetLabel() above has no visible effect */ - wxMilliSleep (200); - - signal_manager->when_idle (boost::bind (&DolbyDoremiCertificatePanel::finish_download, this, wx_to_std (_serial->GetValue ()), message)); -} - static void try_dcp2000 (list& urls, list& files, string prefix, string serial) { @@ -156,13 +145,14 @@ try_cp850 (list& urls, list& files, string prefix, string serial } void -DolbyDoremiCertificatePanel::finish_download (string serial, wxStaticText* message) +DolbyDoremiCertificatePanel::do_download (wxStaticText* message) { /* Try dcp2000, imb and ims prefixes (see mantis #375) */ string const prefix = "ftp://anonymous@ftp.cinema.dolby.com/Certificates/"; list urls; list files; + string const serial = wx_to_std (_serial->GetValue()); bool starts_with_digit = false; optional starting_char; @@ -220,3 +210,9 @@ DolbyDoremiCertificatePanel::ready_to_download () const { return !_serial->IsEmpty (); } + +wxString +DolbyDoremiCertificatePanel::name () const +{ + return _("Dolby / Doremi"); +} diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h index b8df76569..2e1e0f54e 100644 --- a/src/wx/dolby_doremi_certificate_panel.h +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -26,7 +26,8 @@ public: DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); bool ready_to_download () const; - void download (wxStaticText* message); + void do_download (wxStaticText* message); + wxString name () const; private: void finish_download (std::string serial, wxStaticText* message); diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index e18723a4a..b4d602092 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -34,7 +34,10 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, this)); _setup.push_back (false); - _notebook->AddPage (_pages.back(), _("Dolby / Doremi"), true); + + BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { + _notebook->AddPage (i, i->name(), true); + } _download = new wxButton (this, wxID_ANY, _("Download")); sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index 4052e44a6..0c78901eb 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -20,6 +20,7 @@ #include "wx_util.h" #include "download_certificate_panel.h" +#include "lib/signal_manager.h" #include #include #include @@ -62,3 +63,14 @@ DownloadCertificatePanel::certificate () const { return _certificate; } + +void +DownloadCertificatePanel::download (wxStaticText* message) +{ + message->SetLabel (_("Downloading certificate")); + + /* Hack: without this the SetLabel() above has no visible effect */ + wxMilliSleep (200); + + signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, message)); +} diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index 6308e49b7..258d5ab25 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -35,8 +35,10 @@ public: /* 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; + virtual void do_download (wxStaticText* message) = 0; + virtual wxString name () const = 0; + void download (wxStaticText* message); void load (boost::filesystem::path); boost::optional certificate () const; -- cgit v1.2.3 From 7459697905a79ff36c8cd676a9b2f150f6491d6d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 14 Aug 2018 23:46:05 +0100 Subject: Remove unused setup stuff in DownloadCertificatePanel. --- src/wx/download_certificate_dialog.cc | 8 -------- src/wx/download_certificate_dialog.h | 3 +-- src/wx/download_certificate_panel.h | 2 -- 3 files changed, 1 insertion(+), 12 deletions(-) (limited to 'src') diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index b4d602092..bccfbb5c2 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -33,7 +33,6 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, this)); - _setup.push_back (false); BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { _notebook->AddPage (i, i->name(), true); @@ -92,17 +91,10 @@ DownloadCertificateDialog::setup_sensitivity () if (ok) { ok->Enable (static_cast(p->certificate ())); } - } void DownloadCertificateDialog::page_changed (wxNotebookEvent &) { - int const n = _notebook->GetSelection(); - if (!_setup[n]) { - _pages[n]->setup (); - _setup[n] = true; - } - setup_sensitivity (); } diff --git a/src/wx/download_certificate_dialog.h b/src/wx/download_certificate_dialog.h index dcb0a952a..0df504975 100644 --- a/src/wx/download_certificate_dialog.h +++ b/src/wx/download_certificate_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -39,7 +39,6 @@ private: wxNotebook* _notebook; std::vector _pages; - std::vector _setup; wxButton* _download; wxStaticText* _message; }; diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index 258d5ab25..98e48de39 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -32,8 +32,6 @@ 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 do_download (wxStaticText* message) = 0; virtual wxString name () const = 0; -- cgit v1.2.3 From 6a69f5ba3ce43094493785bb449c91001557b80d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Aug 2018 00:23:17 +0100 Subject: Shift some more stuff around. --- src/wx/dolby_doremi_certificate_panel.cc | 23 +++++------------------ src/wx/dolby_doremi_certificate_panel.h | 10 ++-------- src/wx/download_certificate_dialog.cc | 14 +++++++------- src/wx/download_certificate_panel.cc | 26 ++++++++++++++++++-------- src/wx/download_certificate_panel.h | 12 ++++++------ 5 files changed, 38 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc index 5a0ce028e..f0f0a2601 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -38,16 +38,10 @@ using boost::function; using boost::optional; using dcp::raw_convert; -DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (parent, dialog) +DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (parent, message, dialog) { - add_label_to_sizer (_table, this, _("Serial number"), true); - _serial = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1)); - _table->Add (_serial, 1, wxEXPAND); - _serial->Bind (wxEVT_TEXT, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog)); - - layout (); } static void @@ -145,14 +139,13 @@ try_cp850 (list& urls, list& files, string prefix, string serial } void -DolbyDoremiCertificatePanel::do_download (wxStaticText* message) +DolbyDoremiCertificatePanel::do_download (string serial) { /* Try dcp2000, imb and ims prefixes (see mantis #375) */ string const prefix = "ftp://anonymous@ftp.cinema.dolby.com/Certificates/"; list urls; list files; - string const serial = wx_to_std (_serial->GetValue()); bool starts_with_digit = false; optional starting_char; @@ -191,10 +184,10 @@ DolbyDoremiCertificatePanel::do_download (wxStaticText* message) } if (ok) { - message->SetLabel (_("Certificate downloaded")); + _message->SetLabel (_("Certificate downloaded")); _dialog->setup_sensitivity (); } else { - message->SetLabel (wxT ("")); + _message->SetLabel (wxT ("")); string s; BOOST_FOREACH (string e, errors) { @@ -205,12 +198,6 @@ DolbyDoremiCertificatePanel::do_download (wxStaticText* message) } } -bool -DolbyDoremiCertificatePanel::ready_to_download () const -{ - return !_serial->IsEmpty (); -} - wxString DolbyDoremiCertificatePanel::name () const { diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h index 2e1e0f54e..21f928621 100644 --- a/src/wx/dolby_doremi_certificate_panel.h +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -23,14 +23,8 @@ class DolbyDoremiCertificatePanel : public DownloadCertificatePanel { public: - DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + DolbyDoremiCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog); - bool ready_to_download () const; - void do_download (wxStaticText* message); + void do_download (std::string serial); wxString name () const; - -private: - void finish_download (std::string serial, wxStaticText* message); - - wxTextCtrl* _serial; }; diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index bccfbb5c2..a2219cd6f 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -32,12 +32,6 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) _notebook = new wxNotebook (this, wxID_ANY); sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, this)); - - BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { - _notebook->AddPage (i, i->name(), true); - } - _download = new wxButton (this, wxID_ANY, _("Download")); sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); @@ -48,6 +42,12 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) font.SetPointSize (font.GetPointSize() - 1); _message->SetFont (font); + _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, _message, this)); + + BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { + _notebook->AddPage (i, i->name(), true); + } + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); @@ -71,7 +71,7 @@ DownloadCertificateDialog::~DownloadCertificateDialog () void DownloadCertificateDialog::download () { - _pages[_notebook->GetSelection()]->download (_message); + _pages[_notebook->GetSelection()]->download (); } dcp::Certificate diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index 0c78901eb..f9a88a7bb 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -20,6 +20,7 @@ #include "wx_util.h" #include "download_certificate_panel.h" +#include "download_certificate_dialog.h" #include "lib/signal_manager.h" #include #include @@ -28,9 +29,10 @@ using boost::function; using boost::optional; -DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) +DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog) : wxPanel (parent, wxID_ANY) , _dialog (dialog) + , _message (message) { _overall_sizer = new wxBoxSizer (wxVERTICAL); SetSizer (_overall_sizer); @@ -39,11 +41,13 @@ DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCe _table->AddGrowableCol (1, 1); _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); -} -void -DownloadCertificatePanel::layout () -{ + add_label_to_sizer (_table, this, _("Serial number"), true); + _serial = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1)); + _table->Add (_serial, 1, wxEXPAND); + + _serial->Bind (wxEVT_TEXT, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog)); + _overall_sizer->Layout (); _overall_sizer->SetSizeHints (this); } @@ -65,12 +69,18 @@ DownloadCertificatePanel::certificate () const } void -DownloadCertificatePanel::download (wxStaticText* message) +DownloadCertificatePanel::download () { - message->SetLabel (_("Downloading certificate")); + _message->SetLabel (_("Downloading certificate")); /* Hack: without this the SetLabel() above has no visible effect */ wxMilliSleep (200); - signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, message)); + signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, wx_to_std(_serial->GetValue()))); +} + +bool +DownloadCertificatePanel::ready_to_download () const +{ + return !_serial->IsEmpty (); } diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index 98e48de39..252474c59 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -30,25 +30,25 @@ class DownloadCertificateDialog; class DownloadCertificatePanel : public wxPanel { public: - DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + DownloadCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog); - virtual bool ready_to_download () const = 0; - virtual void do_download (wxStaticText* message) = 0; + virtual void do_download (std::string serial) = 0; virtual wxString name () const = 0; - void download (wxStaticText* message); + bool ready_to_download () const; + void download (); void load (boost::filesystem::path); boost::optional certificate () const; protected: - void layout (); - DownloadCertificateDialog* _dialog; wxFlexGridSizer* _table; + wxStaticText* _message; private: wxSizer* _overall_sizer; boost::optional _certificate; + wxTextCtrl* _serial; }; #endif -- cgit v1.2.3 From f8acc34bcb4401184064598353d6c54df3cab1f9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Aug 2018 02:08:05 +0100 Subject: More rearrangement and add Barco Alchemy. --- src/lib/config.cc | 12 +++++ src/lib/config.h | 26 +++++++++++ src/lib/internet.cc | 53 +++++++++++++++------ src/lib/internet.h | 1 + src/lib/scoped_temporary.h | 5 +- src/wx/barco_alchemy_certificate_panel.cc | 77 +++++++++++++++++++++++++++++++ src/wx/barco_alchemy_certificate_panel.h | 31 +++++++++++++ src/wx/dolby_doremi_certificate_panel.cc | 12 +++-- src/wx/dolby_doremi_certificate_panel.h | 4 +- src/wx/download_certificate_dialog.cc | 9 ++-- src/wx/download_certificate_dialog.h | 8 ++++ src/wx/download_certificate_panel.cc | 9 ++-- src/wx/download_certificate_panel.h | 9 ++-- src/wx/full_config_dialog.cc | 72 +++++++++++++++++++++++++++++ src/wx/wscript | 1 + 15 files changed, 293 insertions(+), 36 deletions(-) create mode 100644 src/wx/barco_alchemy_certificate_panel.cc create mode 100644 src/wx/barco_alchemy_certificate_panel.h (limited to 'src') diff --git a/src/lib/config.cc b/src/lib/config.cc index 7e2cdabf6..792ce5619 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -156,6 +156,8 @@ Config::set_defaults () for (int i = 0; i < NOTIFICATION_COUNT; ++i) { _notification[i] = false; } + _barco_username = optional(); + _barco_password = optional(); _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -463,6 +465,9 @@ try } } + _barco_username = f.optional_string_child("BarcoUsername"); + _barco_password = f.optional_string_child("BarcoPassword"); + /* Replace any cinemas from config.xml with those from the configured file */ if (boost::filesystem::exists (_cinemas_file)) { cxml::Document f ("Cinemas"); @@ -806,6 +811,13 @@ Config::write_config () const e->add_child_text (_notification[i] ? "1" : "0"); } + if (_barco_username) { + root->add_child("BarcoUsername")->add_child_text(*_barco_username); + } + if (_barco_password) { + root->add_child("BarcoPassword")->add_child_text(*_barco_password); + } + try { doc.write_to_file_formatted(config_file().string()); } catch (xmlpp::exception& e) { diff --git a/src/lib/config.h b/src/lib/config.h index dbe6a9c21..8bf766c02 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -423,6 +423,14 @@ public: return _notification[n]; } + boost::optional barco_username () const { + return _barco_username; + } + + boost::optional barco_password () const { + return _barco_password; + } + /* SET (mostly) */ void set_master_encoding_threads (int n) { @@ -769,6 +777,22 @@ public: maybe_set (_notification[n], v); } + void set_barco_username (std::string u) { + maybe_set (_barco_username, u); + } + + void unset_barco_username () { + maybe_set (_barco_username, boost::optional()); + } + + void set_barco_password (std::string p) { + maybe_set (_barco_password, p); + } + + void unset_barco_password () { + maybe_set (_barco_password, boost::optional()); + } + void changed (Property p = OTHER); boost::signals2::signal Changed; /** Emitted if read() failed on an existing Config file. There is nothing @@ -944,6 +968,8 @@ private: boost::optional _decode_reduction; bool _default_notify; bool _notification[NOTIFICATION_COUNT]; + boost::optional _barco_username; + boost::optional _barco_password; static int const _current_version; diff --git a/src/lib/internet.cc b/src/lib/internet.cc index c1bb5e88f..846dbf7ca 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -38,27 +38,23 @@ using boost::optional; using boost::function; using boost::algorithm::trim; + static size_t -get_from_zip_url_data (void* buffer, size_t size, size_t nmemb, void* stream) +get_from_url_data (void* buffer, size_t size, size_t nmemb, void* stream) { FILE* f = reinterpret_cast (stream); return fwrite (buffer, size, nmemb, f); } -/** @param url URL of ZIP file. - * @param file Filename within ZIP file. - * @param load Function passed a (temporary) filesystem path of the unpacked file. - */ +static optional -get_from_zip_url (string url, string file, bool pasv, function load) +get_from_url (string url, bool pasv, ScopedTemporary& temp) { - /* Download the ZIP file to temp_zip */ CURL* curl = curl_easy_init (); - curl_easy_setopt (curl, CURLOPT_URL, url.c_str ()); + curl_easy_setopt (curl, CURLOPT_URL, url.c_str()); - ScopedTemporary temp_zip; - FILE* f = temp_zip.open ("wb"); - curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_zip_url_data); + FILE* f = temp.open ("w"); + curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_url_data); curl_easy_setopt (curl, CURLOPT_WRITEDATA, f); curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0); curl_easy_setopt (curl, CURLOPT_FTP_USE_EPRT, 0); @@ -71,10 +67,39 @@ get_from_zip_url (string url, string file, bool pasv, function(); +} + +optional +get_from_url (string url, bool pasv, function load) +{ + ScopedTemporary temp; + optional e = get_from_url (url, pasv, temp); + if (e) { + return e; + } + load (temp.file()); + return optional(); +} + +/** @param url URL of ZIP file. + * @param file Filename within ZIP file. + * @param load Function passed a (temporary) filesystem path of the unpacked file. + */ +optional +get_from_zip_url (string url, string file, bool pasv, function load) +{ + /* Download the ZIP file to temp_zip */ + ScopedTemporary temp_zip; + optional e = get_from_url (url, pasv, temp_zip); + if (e) { + return e; } /* Open the ZIP file and read `file' out of it */ @@ -110,7 +135,7 @@ get_from_zip_url (string url, string file, bool pasv, function #include +boost::optional get_from_url (std::string url, bool pasv, boost::function load); boost::optional get_from_zip_url (std::string url, std::string file, bool pasv, boost::function load); diff --git a/src/lib/scoped_temporary.h b/src/lib/scoped_temporary.h index 87c8e387f..986f565a0 100644 --- a/src/lib/scoped_temporary.h +++ b/src/lib/scoped_temporary.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -19,12 +19,13 @@ */ #include +#include #include /** @class ScopedTemporary * @brief A temporary file which is deleted when the ScopedTemporary object goes out of scope. */ -class ScopedTemporary +class ScopedTemporary : public boost::noncopyable { public: ScopedTemporary (); diff --git a/src/wx/barco_alchemy_certificate_panel.cc b/src/wx/barco_alchemy_certificate_panel.cc new file mode 100644 index 000000000..ba7deb8fd --- /dev/null +++ b/src/wx/barco_alchemy_certificate_panel.cc @@ -0,0 +1,77 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see . + +*/ + +#include "barco_alchemy_certificate_panel.h" +#include "download_certificate_dialog.h" +#include "wx_util.h" +#include "lib/internet.h" +#include "lib/compose.hpp" +#include "lib/config.h" + +using std::string; +using boost::optional; + +BarcoAlchemyCertificatePanel::BarcoAlchemyCertificatePanel (DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (dialog) +{ + +} + +bool +BarcoAlchemyCertificatePanel::ready_to_download () const +{ + return _serial->GetValue().Length() == 10; +} + +void +BarcoAlchemyCertificatePanel::do_download () +{ + Config* config = Config::instance (); + if (!config->barco_username() || !config->barco_password()) { + _dialog->message()->SetLabel(wxT("")); + error_dialog (this, _("No Barco username/password configured. Add your account details to the Accounts page in Preferences.")); + return; + } + + string const serial = wx_to_std (_serial->GetValue()); + string const url = String::compose ( + "ftp://%1:%2@certificates.barco.com/%3xxx/%4/Barco-ICMP.%5_cert.pem", + Config::instance()->barco_username().get(), + Config::instance()->barco_password().get(), + serial.substr(0, 7), + serial, + serial + ); + + optional error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + if (error) { + _dialog->message()->SetLabel(wxT("")); + error_dialog (this, std_to_wx(*error)); + } else { + _dialog->message()->SetLabel (_("Certificate downloaded")); + _dialog->setup_sensitivity (); + } +} + +wxString +BarcoAlchemyCertificatePanel::name () const +{ + return _("Barco Alchemy"); +} diff --git a/src/wx/barco_alchemy_certificate_panel.h b/src/wx/barco_alchemy_certificate_panel.h new file mode 100644 index 000000000..83a74fa21 --- /dev/null +++ b/src/wx/barco_alchemy_certificate_panel.h @@ -0,0 +1,31 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see . + +*/ + +#include "download_certificate_panel.h" + +class BarcoAlchemyCertificatePanel : public DownloadCertificatePanel +{ +public: + BarcoAlchemyCertificatePanel (DownloadCertificateDialog* dialog); + + bool ready_to_download () const; + void do_download (); + wxString name () const; +}; diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc index f0f0a2601..ea0207a9b 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -38,8 +38,8 @@ using boost::function; using boost::optional; using dcp::raw_convert; -DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (parent, message, dialog) +DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (dialog) { } @@ -139,8 +139,10 @@ try_cp850 (list& urls, list& files, string prefix, string serial } void -DolbyDoremiCertificatePanel::do_download (string serial) +DolbyDoremiCertificatePanel::do_download () { + string const serial = wx_to_std (_serial->GetValue()); + /* Try dcp2000, imb and ims prefixes (see mantis #375) */ string const prefix = "ftp://anonymous@ftp.cinema.dolby.com/Certificates/"; @@ -184,10 +186,10 @@ DolbyDoremiCertificatePanel::do_download (string serial) } if (ok) { - _message->SetLabel (_("Certificate downloaded")); + _dialog->message()->SetLabel (_("Certificate downloaded")); _dialog->setup_sensitivity (); } else { - _message->SetLabel (wxT ("")); + _dialog->message()->SetLabel (wxT ("")); string s; BOOST_FOREACH (string e, errors) { diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h index 21f928621..665281073 100644 --- a/src/wx/dolby_doremi_certificate_panel.h +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -23,8 +23,8 @@ class DolbyDoremiCertificatePanel : public DownloadCertificatePanel { public: - DolbyDoremiCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog); + DolbyDoremiCertificatePanel (DownloadCertificateDialog* dialog); - void do_download (std::string serial); + void do_download (); wxString name () const; }; diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index a2219cd6f..6ca605f56 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -19,6 +19,7 @@ */ #include "dolby_doremi_certificate_panel.h" +#include "barco_alchemy_certificate_panel.h" #include "download_certificate_dialog.h" #include "wx_util.h" @@ -42,7 +43,8 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) font.SetPointSize (font.GetPointSize() - 1); _message->SetFont (font); - _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, _message, this)); + _pages.push_back (new DolbyDoremiCertificatePanel (this)); + _pages.push_back (new BarcoAlchemyCertificatePanel (this)); BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { _notebook->AddPage (i, i->name(), true); @@ -59,8 +61,9 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) _download->Bind (wxEVT_BUTTON, boost::bind (&DownloadCertificateDialog::download, this)); _download->Enable (false); - wxNotebookEvent ev; - page_changed (ev); + _notebook->SetSelection (0); + + setup_sensitivity (); } DownloadCertificateDialog::~DownloadCertificateDialog () diff --git a/src/wx/download_certificate_dialog.h b/src/wx/download_certificate_dialog.h index 0df504975..180c13278 100644 --- a/src/wx/download_certificate_dialog.h +++ b/src/wx/download_certificate_dialog.h @@ -33,6 +33,14 @@ public: void setup_sensitivity (); + wxNotebook* notebook () const { + return _notebook; + } + + wxStaticText* message () const { + return _message; + } + private: void download (); void page_changed (wxNotebookEvent &); diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index f9a88a7bb..2f3b435ef 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -29,10 +29,9 @@ using boost::function; using boost::optional; -DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog) - : wxPanel (parent, wxID_ANY) +DownloadCertificatePanel::DownloadCertificatePanel (DownloadCertificateDialog* dialog) + : wxPanel (dialog->notebook(), wxID_ANY) , _dialog (dialog) - , _message (message) { _overall_sizer = new wxBoxSizer (wxVERTICAL); SetSizer (_overall_sizer); @@ -71,12 +70,12 @@ DownloadCertificatePanel::certificate () const void DownloadCertificatePanel::download () { - _message->SetLabel (_("Downloading certificate")); + _dialog->message()->SetLabel (_("Downloading certificate")); /* Hack: without this the SetLabel() above has no visible effect */ wxMilliSleep (200); - signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, wx_to_std(_serial->GetValue()))); + signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this)); } bool diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index 252474c59..55594c74c 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -30,12 +30,12 @@ class DownloadCertificateDialog; class DownloadCertificatePanel : public wxPanel { public: - DownloadCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog); + DownloadCertificatePanel (DownloadCertificateDialog* dialog); - virtual void do_download (std::string serial) = 0; + virtual void do_download () = 0; virtual wxString name () const = 0; + virtual bool ready_to_download () const; - bool ready_to_download () const; void download (); void load (boost::filesystem::path); boost::optional certificate () const; @@ -43,12 +43,11 @@ public: protected: DownloadCertificateDialog* _dialog; wxFlexGridSizer* _table; - wxStaticText* _message; + wxTextCtrl* _serial; private: wxSizer* _overall_sizer; boost::optional _certificate; - wxTextCtrl* _serial; }; #endif diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 523973618..bf26519e1 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -910,6 +910,77 @@ private: wxButton* _reset_email; }; +class AccountsPage : public StandardPage +{ +public: + AccountsPage (wxSize panel_size, int border) + : StandardPage (panel_size, border) + {} + + wxString GetName () const + { + return _("Accounts"); + } + +#ifdef DCPOMATIC_OSX + wxBitmap GetLargeIcon () const + { + return wxBitmap ("accounts", wxBITMAP_TYPE_PNG_RESOURCE); + } +#endif + + void setup () + { + wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + table->AddGrowableCol (1, 1); + _panel->GetSizer()->Add (table, 1, wxEXPAND | wxALL, _border); + + add_label_to_sizer (table, _panel, _("certificates.barco.com username"), true); + _barco_username = new wxTextCtrl (_panel, wxID_ANY); + table->Add (_barco_username, 1, wxEXPAND | wxALL); + + add_label_to_sizer (table, _panel, _("certificates.barco.com password"), true); + _barco_password = new wxTextCtrl (_panel, wxID_ANY); + table->Add (_barco_password, 1, wxEXPAND | wxALL); + + _barco_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::barco_username_changed, this)); + _barco_password->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::barco_password_changed, this)); + } + + void config_changed () + { + Config* config = Config::instance (); + + checked_set (_barco_username, config->barco_username().get_value_or("")); + checked_set (_barco_password, config->barco_password().get_value_or("")); + } + + void barco_username_changed () + { + wxString const s = _barco_username->GetValue(); + if (!s.IsEmpty()) { + Config::instance()->set_barco_username (wx_to_std(s)); + } else { + Config::instance()->unset_barco_username (); + } + } + + void barco_password_changed () + { + wxString const s = _barco_password->GetValue(); + if (!s.IsEmpty()) { + Config::instance()->set_barco_password (wx_to_std(s)); + } else { + Config::instance()->unset_barco_password (); + } + } + +private: + wxTextCtrl* _barco_username; + wxTextCtrl* _barco_password; +}; + + class NotificationsPage : public StandardPage { public: @@ -1430,6 +1501,7 @@ create_full_config_dialog () e->AddPage (new TMSPage (ps, border)); e->AddPage (new EmailPage (ps, border)); e->AddPage (new KDMEmailPage (ps, border)); + e->AddPage (new AccountsPage (ps, border)); e->AddPage (new NotificationsPage (ps, border)); e->AddPage (new CoverSheetPage (ps, border)); e->AddPage (new AdvancedPage (ps, border)); diff --git a/src/wx/wscript b/src/wx/wscript index 0a32d1dfe..39617b840 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -31,6 +31,7 @@ sources = """ audio_mapping_view.cc audio_panel.cc audio_plot.cc + barco_alchemy_certificate_panel.cc batch_job_view.cc subtitle_appearance_dialog.cc text_panel.cc -- cgit v1.2.3 From 89abe02431bd8d885197883a3ffafdc8d836dce4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Aug 2018 02:24:26 +0100 Subject: Christie support. --- src/lib/config.cc | 11 +++++ src/lib/config.h | 26 +++++++++++ src/wx/christie_certificate_panel.cc | 87 +++++++++++++++++++++++++++++++++++ src/wx/christie_certificate_panel.h | 30 ++++++++++++ src/wx/download_certificate_dialog.cc | 2 + src/wx/full_config_dialog.cc | 34 ++++++++++++++ src/wx/wscript | 1 + 7 files changed, 191 insertions(+) create mode 100644 src/wx/christie_certificate_panel.cc create mode 100644 src/wx/christie_certificate_panel.h (limited to 'src') diff --git a/src/lib/config.cc b/src/lib/config.cc index 792ce5619..28af9b303 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -158,6 +158,8 @@ Config::set_defaults () } _barco_username = optional(); _barco_password = optional(); + _christie_username = optional(); + _christie_password = optional(); _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -467,6 +469,8 @@ try _barco_username = f.optional_string_child("BarcoUsername"); _barco_password = f.optional_string_child("BarcoPassword"); + _christie_username = f.optional_string_child("ChristieUsername"); + _christie_password = f.optional_string_child("ChristiePassword"); /* Replace any cinemas from config.xml with those from the configured file */ if (boost::filesystem::exists (_cinemas_file)) { @@ -818,6 +822,13 @@ Config::write_config () const root->add_child("BarcoPassword")->add_child_text(*_barco_password); } + if (_christie_username) { + root->add_child("ChristieUsername")->add_child_text(*_christie_username); + } + if (_christie_password) { + root->add_child("ChristiePassword")->add_child_text(*_christie_password); + } + try { doc.write_to_file_formatted(config_file().string()); } catch (xmlpp::exception& e) { diff --git a/src/lib/config.h b/src/lib/config.h index 8bf766c02..b710f537d 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -431,6 +431,14 @@ public: return _barco_password; } + boost::optional christie_username () const { + return _christie_username; + } + + boost::optional christie_password () const { + return _christie_password; + } + /* SET (mostly) */ void set_master_encoding_threads (int n) { @@ -793,6 +801,22 @@ public: maybe_set (_barco_password, boost::optional()); } + void set_christie_username (std::string u) { + maybe_set (_christie_username, u); + } + + void unset_christie_username () { + maybe_set (_christie_username, boost::optional()); + } + + void set_christie_password (std::string p) { + maybe_set (_christie_password, p); + } + + void unset_christie_password () { + maybe_set (_christie_password, boost::optional()); + } + void changed (Property p = OTHER); boost::signals2::signal Changed; /** Emitted if read() failed on an existing Config file. There is nothing @@ -970,6 +994,8 @@ private: bool _notification[NOTIFICATION_COUNT]; boost::optional _barco_username; boost::optional _barco_password; + boost::optional _christie_username; + boost::optional _christie_password; static int const _current_version; diff --git a/src/wx/christie_certificate_panel.cc b/src/wx/christie_certificate_panel.cc new file mode 100644 index 000000000..53d815bf7 --- /dev/null +++ b/src/wx/christie_certificate_panel.cc @@ -0,0 +1,87 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see . + +*/ + +#include "christie_certificate_panel.h" +#include "download_certificate_dialog.h" +#include "wx_util.h" +#include "lib/internet.h" +#include "lib/compose.hpp" +#include "lib/config.h" + +using std::string; +using boost::optional; + +ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (dialog) +{ + +} + +void +ChristieCertificatePanel::do_download () +{ + Config* config = Config::instance (); + if (!config->christie_username() || !config->christie_password()) { + _dialog->message()->SetLabel(wxT("")); + error_dialog (this, _("No Christie username/password configured. Add your account details to the Accounts page in Preferences.")); + return; + } + + string const serial = wx_to_std (_serial->GetValue()); + string const url = String::compose ( + "ftp://%1:%2@certificates.christiedigital.com/Certificates/F-IMB/F-IMB_000000%3_sha256.pem", + Config::instance()->christie_username().get(), + Config::instance()->christie_password().get(), + serial + ); + + optional all_errors; + + optional error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + if (error) { + all_errors = *error; + + string const url = String::compose ( + "ftp://%1:%2@certificates.christiedigital.com/Certificates/F-IMB/F-IMB_000000%3_sha256.pem", + Config::instance()->christie_username().get(), + Config::instance()->christie_password().get(), + serial + ); + + error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + if (error) { + *all_errors += "\n" + *error; + } + } + + if (all_errors) { + _dialog->message()->SetLabel(wxT("")); + error_dialog (this, std_to_wx(*all_errors)); + } else { + _dialog->message()->SetLabel (_("Certificate downloaded")); + _dialog->setup_sensitivity (); + } +} + +wxString +ChristieCertificatePanel::name () const +{ + return _("Christie"); +} diff --git a/src/wx/christie_certificate_panel.h b/src/wx/christie_certificate_panel.h new file mode 100644 index 000000000..0c9a64d46 --- /dev/null +++ b/src/wx/christie_certificate_panel.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see . + +*/ + +#include "download_certificate_panel.h" + +class ChristieCertificatePanel : public DownloadCertificatePanel +{ +public: + ChristieCertificatePanel (DownloadCertificateDialog* dialog); + + void do_download (); + wxString name () const; +}; diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index 6ca605f56..dfafee36c 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -20,6 +20,7 @@ #include "dolby_doremi_certificate_panel.h" #include "barco_alchemy_certificate_panel.h" +#include "christie_certificate_panel.h" #include "download_certificate_dialog.h" #include "wx_util.h" @@ -45,6 +46,7 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) _pages.push_back (new DolbyDoremiCertificatePanel (this)); _pages.push_back (new BarcoAlchemyCertificatePanel (this)); + _pages.push_back (new ChristieCertificatePanel (this)); BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { _notebook->AddPage (i, i->name(), true); diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index bf26519e1..d21c8a2c1 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -943,8 +943,18 @@ public: _barco_password = new wxTextCtrl (_panel, wxID_ANY); table->Add (_barco_password, 1, wxEXPAND | wxALL); + add_label_to_sizer (table, _panel, _("certificates.christiedigital.com username"), true); + _christie_username = new wxTextCtrl (_panel, wxID_ANY); + table->Add (_christie_username, 1, wxEXPAND | wxALL); + + add_label_to_sizer (table, _panel, _("certificates.christiedigital.com password"), true); + _christie_password = new wxTextCtrl (_panel, wxID_ANY); + table->Add (_christie_password, 1, wxEXPAND | wxALL); + _barco_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::barco_username_changed, this)); _barco_password->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::barco_password_changed, this)); + _christie_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::christie_username_changed, this)); + _christie_password->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::christie_password_changed, this)); } void config_changed () @@ -953,6 +963,8 @@ public: checked_set (_barco_username, config->barco_username().get_value_or("")); checked_set (_barco_password, config->barco_password().get_value_or("")); + checked_set (_christie_username, config->christie_username().get_value_or("")); + checked_set (_christie_password, config->christie_password().get_value_or("")); } void barco_username_changed () @@ -975,9 +987,31 @@ public: } } + void christie_username_changed () + { + wxString const s = _christie_username->GetValue(); + if (!s.IsEmpty()) { + Config::instance()->set_christie_username (wx_to_std(s)); + } else { + Config::instance()->unset_christie_username (); + } + } + + void christie_password_changed () + { + wxString const s = _christie_password->GetValue(); + if (!s.IsEmpty()) { + Config::instance()->set_christie_password (wx_to_std(s)); + } else { + Config::instance()->unset_christie_password (); + } + } + private: wxTextCtrl* _barco_username; wxTextCtrl* _barco_password; + wxTextCtrl* _christie_username; + wxTextCtrl* _christie_password; }; diff --git a/src/wx/wscript b/src/wx/wscript index 39617b840..560bfc1ab 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -36,6 +36,7 @@ sources = """ subtitle_appearance_dialog.cc text_panel.cc text_view.cc + christie_certificate_panel.cc cinema_dialog.cc colour_conversion_editor.cc config_dialog.cc -- cgit v1.2.3 From c3fc23c2670ae6377ef42a4e4af051d47b88e75d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Aug 2018 10:10:19 +0100 Subject: Christie fixes. --- src/wx/christie_certificate_panel.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/wx/christie_certificate_panel.cc b/src/wx/christie_certificate_panel.cc index 53d815bf7..fa91cc2b5 100644 --- a/src/wx/christie_certificate_panel.cc +++ b/src/wx/christie_certificate_panel.cc @@ -44,26 +44,24 @@ ChristieCertificatePanel::do_download () return; } - string const serial = wx_to_std (_serial->GetValue()); - string const url = String::compose ( - "ftp://%1:%2@certificates.christiedigital.com/Certificates/F-IMB/F-IMB_000000%3_sha256.pem", + string const prefix = String::compose( + "ftp://%1:%2@certificates.christiedigital.com/Certificates/", Config::instance()->christie_username().get(), - Config::instance()->christie_password().get(), - serial + Config::instance()->christie_password().get() ); + string serial = wx_to_std (_serial->GetValue()); + serial.insert (0, 12 - serial.length(), '0'); + + string const url = String::compose ("%1F-IMB/F-IMB_%2_sha256.pem", prefix, serial); + optional all_errors; optional error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); if (error) { all_errors = *error; - string const url = String::compose ( - "ftp://%1:%2@certificates.christiedigital.com/Certificates/F-IMB/F-IMB_000000%3_sha256.pem", - Config::instance()->christie_username().get(), - Config::instance()->christie_password().get(), - serial - ); + string const url = String::compose ("%1IMB-S2/IMB-S2_%2_sha256.pem", prefix, serial); error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); if (error) { -- cgit v1.2.3 From 998b2eea5640cda23950ff6c5e24bd1f9ccb160f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Aug 2018 10:51:16 +0100 Subject: Add GDC and accounts icon. --- graphics/src/accounts.svg | 179 ++++++++++++++++++++++++++++++++++ graphics/update | 2 +- src/lib/config.cc | 11 +++ src/lib/config.h | 26 +++++ src/wx/download_certificate_dialog.cc | 2 + src/wx/gdc_certificate_panel.cc | 69 +++++++++++++ src/wx/gdc_certificate_panel.h | 30 ++++++ src/wx/wscript | 1 + 8 files changed, 319 insertions(+), 1 deletion(-) create mode 100644 graphics/src/accounts.svg create mode 100644 src/wx/gdc_certificate_panel.cc create mode 100644 src/wx/gdc_certificate_panel.h (limited to 'src') diff --git a/graphics/src/accounts.svg b/graphics/src/accounts.svg new file mode 100644 index 000000000..920051848 --- /dev/null +++ b/graphics/src/accounts.svg @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Openclipart + + + + 2010-03-29T08:04:16 + "E-mail" icon from <a href="http://tango.freedesktop.org/Tango_Desktop_Project"> Tango Project </a> +\n<br><br> +\nSince version 0.8.90 Tango Project icons are Public Domain: <a href="http://tango.freedesktop.org/Frequently_Asked_Questions#Terms_of_Use.3F"> Tango Project FAQ </a> + https://openclipart.org/detail/35215/tango-internet-mail-by-warszawianka + + + warszawianka + + + + + email + envelope + externalsource + icon + letter + tango + + + + + + + + + + + diff --git a/graphics/update b/graphics/update index 9815cf9a7..51336745e 100755 --- a/graphics/update +++ b/graphics/update @@ -55,7 +55,7 @@ else # OS X preferences icons # servers.png does not have an SVG version mkdir -p osx/preferences - for i in colour_conversions defaults email kdm_email cover_sheet keys tms notifications; do + for i in colour_conversions defaults email kdm_email cover_sheet keys tms notifications accounts; do $INKSCAPE osx/preferences/$i.png src/$i.svg -w 32 -h 32 done diff --git a/src/lib/config.cc b/src/lib/config.cc index 28af9b303..76c70ed5d 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -160,6 +160,8 @@ Config::set_defaults () _barco_password = optional(); _christie_username = optional(); _christie_password = optional(); + _gdc_username = optional(); + _gdc_password = optional(); _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -471,6 +473,8 @@ try _barco_password = f.optional_string_child("BarcoPassword"); _christie_username = f.optional_string_child("ChristieUsername"); _christie_password = f.optional_string_child("ChristiePassword"); + _gdc_username = f.optional_string_child("GDCUsername"); + _gdc_password = f.optional_string_child("GDCPassword"); /* Replace any cinemas from config.xml with those from the configured file */ if (boost::filesystem::exists (_cinemas_file)) { @@ -829,6 +833,13 @@ Config::write_config () const root->add_child("ChristiePassword")->add_child_text(*_christie_password); } + if (_gdc_username) { + root->add_child("GDCUsername")->add_child_text(*_gdc_username); + } + if (_gdc_password) { + root->add_child("GDCPassword")->add_child_text(*_gdc_password); + } + try { doc.write_to_file_formatted(config_file().string()); } catch (xmlpp::exception& e) { diff --git a/src/lib/config.h b/src/lib/config.h index b710f537d..0be3b20b9 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -439,6 +439,14 @@ public: return _christie_password; } + boost::optional gdc_username () const { + return _gdc_username; + } + + boost::optional gdc_password () const { + return _gdc_password; + } + /* SET (mostly) */ void set_master_encoding_threads (int n) { @@ -817,6 +825,22 @@ public: maybe_set (_christie_password, boost::optional()); } + void set_gdc_username (std::string u) { + maybe_set (_gdc_username, u); + } + + void unset_gdc_username () { + maybe_set (_gdc_username, boost::optional()); + } + + void set_gdc_password (std::string p) { + maybe_set (_gdc_password, p); + } + + void unset_gdc_password () { + maybe_set (_gdc_password, boost::optional()); + } + void changed (Property p = OTHER); boost::signals2::signal Changed; /** Emitted if read() failed on an existing Config file. There is nothing @@ -996,6 +1020,8 @@ private: boost::optional _barco_password; boost::optional _christie_username; boost::optional _christie_password; + boost::optional _gdc_username; + boost::optional _gdc_password; static int const _current_version; diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index dfafee36c..a12097001 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -21,6 +21,7 @@ #include "dolby_doremi_certificate_panel.h" #include "barco_alchemy_certificate_panel.h" #include "christie_certificate_panel.h" +#include "gdc_certificate_panel.h" #include "download_certificate_dialog.h" #include "wx_util.h" @@ -47,6 +48,7 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) _pages.push_back (new DolbyDoremiCertificatePanel (this)); _pages.push_back (new BarcoAlchemyCertificatePanel (this)); _pages.push_back (new ChristieCertificatePanel (this)); + _pages.push_back (new GDCCertificatePanel (this)); BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { _notebook->AddPage (i, i->name(), true); diff --git a/src/wx/gdc_certificate_panel.cc b/src/wx/gdc_certificate_panel.cc new file mode 100644 index 000000000..b4352dff4 --- /dev/null +++ b/src/wx/gdc_certificate_panel.cc @@ -0,0 +1,69 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see . + +*/ + +#include "gdc_certificate_panel.h" +#include "download_certificate_dialog.h" +#include "wx_util.h" +#include "lib/internet.h" +#include "lib/compose.hpp" +#include "lib/config.h" + +using std::string; +using boost::optional; + +GDCCertificatePanel::GDCCertificatePanel (DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (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 const url = String::compose( + "ftp://%1:%2@ftp.gdc-tech.com/SHA256/A%3", + Config::instance()->gdc_username().get(), + Config::instance()->gdc_password().get(), + serial + ); + + optional error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + + if (error) { + _dialog->message()->SetLabel(wxT("")); + error_dialog (this, std_to_wx(*error)); + } else { + _dialog->message()->SetLabel (_("Certificate downloaded")); + _dialog->setup_sensitivity (); + } +} + +wxString +GDCCertificatePanel::name () const +{ + return _("GDC"); +} diff --git a/src/wx/gdc_certificate_panel.h b/src/wx/gdc_certificate_panel.h new file mode 100644 index 000000000..18a78e586 --- /dev/null +++ b/src/wx/gdc_certificate_panel.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see . + +*/ + +#include "download_certificate_panel.h" + +class GDCCertificatePanel : public DownloadCertificatePanel +{ +public: + GDCCertificatePanel (DownloadCertificateDialog* dialog); + + void do_download (); + wxString name () const; +}; diff --git a/src/wx/wscript b/src/wx/wscript index 560bfc1ab..d50286bf4 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -68,6 +68,7 @@ sources = """ font_files_dialog.cc full_config_dialog.cc gain_calculator_dialog.cc + gdc_certificate_panel.cc hints_dialog.cc job_view.cc job_view_dialog.cc -- cgit v1.2.3 From d9561404372d187ea7813389ac69545de614f259 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Aug 2018 12:38:00 +0100 Subject: Build fixes. --- src/wx/gdc_certificate_panel.cc | 2 +- test/content_test.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wx/gdc_certificate_panel.cc b/src/wx/gdc_certificate_panel.cc index b4352dff4..d4b82d199 100644 --- a/src/wx/gdc_certificate_panel.cc +++ b/src/wx/gdc_certificate_panel.cc @@ -48,7 +48,7 @@ GDCCertificatePanel::do_download () "ftp://%1:%2@ftp.gdc-tech.com/SHA256/A%3", Config::instance()->gdc_username().get(), Config::instance()->gdc_password().get(), - serial + wx_to_std(_serial->GetValue()) ); optional error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); diff --git a/test/content_test.cc b/test/content_test.cc index 31484c0d2..330bbdc94 100644 --- a/test/content_test.cc +++ b/test/content_test.cc @@ -123,6 +123,6 @@ BOOST_AUTO_TEST_CASE (content_test3) /* Likewise position */ - cout << to_string(content->position()) << " " << DCPTime::from_seconds(15.0 / 25.0) << "\n"; + std::cout << to_string(content->position()) << " " << to_string(DCPTime::from_seconds(15.0 / 25.0)) << "\n"; BOOST_CHECK (content->position() == DCPTime::from_seconds (15.0 / 25.0)); } -- cgit v1.2.3 From 32e2c7b2a3cfabc9110f0b4720cc5d48185f9934 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 15 Aug 2018 16:37:04 +0100 Subject: Missing extension (thanks Igor). --- src/wx/gdc_certificate_panel.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/wx/gdc_certificate_panel.cc b/src/wx/gdc_certificate_panel.cc index d4b82d199..a90f098f5 100644 --- a/src/wx/gdc_certificate_panel.cc +++ b/src/wx/gdc_certificate_panel.cc @@ -45,7 +45,7 @@ GDCCertificatePanel::do_download () } string const url = String::compose( - "ftp://%1:%2@ftp.gdc-tech.com/SHA256/A%3", + "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()) -- cgit v1.2.3