diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-08-15 19:56:34 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-08-15 19:56:34 +0100 |
| commit | 7d293a3268c320f474d42fef15548635c3cb40b0 (patch) | |
| tree | d5b6fddfee25a780059fdeae5e838bb2a6d2e1ec | |
| parent | 4d1f0c6e97656a815f49f9240edb6bc427c58cc6 (diff) | |
| parent | 32e2c7b2a3cfabc9110f0b4720cc5d48185f9934 (diff) | |
Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
24 files changed, 844 insertions, 80 deletions
@@ -1,3 +1,8 @@ +2018-08-15 Carl Hetherington <cth@carlh.net> + + * Support download of Barco Alchemy, Christie and GDC certificates + from their FTP site. + 2018-07-20 Carl Hetherington <cth@carlh.net> * Advanced configuration option to allow any container ratio. diff --git a/graphics/osx/preferences/accounts.png b/graphics/osx/preferences/accounts.png Binary files differnew file mode 100644 index 000000000..f9909b7a5 --- /dev/null +++ b/graphics/osx/preferences/accounts.png 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg5816" + viewBox="0 0 48 48" + sodipodi:version="0.32" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + inkscape:version="0.92.3 (2405546, 2018-03-11)" + sodipodi:docname="accounts.svg" + version="1.1"> + <defs + id="defs3"> + <linearGradient + id="linearGradient2152"> + <stop + id="stop2154" + style="stop-color:#9aa29a" + offset="0" /> + <stop + id="stop2156" + style="stop-color:#b5beb5" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3601" + y2="613.94" + gradientUnits="userSpaceOnUse" + x2="385.04001" + gradientTransform="matrix(0.04860254,-0.04951283,0.04860254,0.04951283,-9.7664634,27.282)" + y1="63.870998" + x1="386.39001"> + <stop + id="stop3797" + stop-color="#ffe800" + offset="0" /> + <stop + id="stop3799" + stop-color="#dfb300" + offset="1" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + bordercolor="#666666" + inkscape:window-x="0" + inkscape:window-y="27" + pagecolor="#ffffff" + inkscape:grid-bbox="true" + inkscape:zoom="5.6568542" + inkscape:pageshadow="2" + showgrid="false" + borderopacity="1.0" + inkscape:current-layer="layer1" + inkscape:cx="-28.201318" + inkscape:cy="3.7247721" + inkscape:window-width="1366" + inkscape:pageopacity="0.0" + inkscape:window-height="704" + inkscape:document-units="px" + inkscape:snap-global="false" + inkscape:window-maximized="1" /> + <g + id="layer1" + inkscape:label="Layer 1" + inkscape:groupmode="layer"> + <g + id="g1455" + transform="translate(0.88388348)"> + <g + id="g1449"> + <path + style="fill:#b3b3b3;stroke:#808080;stroke-width:0.98399496px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 29.978487,33.024462 h 16.06181 v -3.097551 c 0,-16.716246 -16.06181,-15.645777 -16.06181,-0.0014 z" + id="path280-9-0" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + </g> + <g + id="g1446"> + <ellipse + style="opacity:1;vector-effect:none;fill:#b3b3b3;fill-opacity:1;stroke:#808080;stroke-width:0.73654598px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path282-3-6" + cx="38.009392" + cy="11.693348" + rx="4.6944504" + ry="5.4944878" /> + </g> + </g> + <g + id="g1459"> + <path + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" + id="path280-9" + d="M 1.1590826,33.024462 H 17.220893 v -3.097551 c 0,-16.716246 -16.0618104,-15.645777 -16.0618104,-0.0014 z" + style="fill:#b3b3b3;stroke:#808080;stroke-width:0.98399496px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + <ellipse + ry="5.4944878" + rx="4.6944504" + cy="11.693348" + cx="9.1899881" + id="path282-3" + style="opacity:1;vector-effect:none;fill:#b3b3b3;fill-opacity:1;stroke:#808080;stroke-width:0.73654598px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + </g> + <g + id="g1443" + transform="translate(-1.0044895)"> + <path + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" + id="path280" + d="m 13.185526,45.935377 h 23.637927 v -5.599269 c 0,-30.217034 -23.637927,-28.282004 -23.637927,-0.0024 z" + style="fill:#1a1a1a;stroke:#000000;stroke-width:1.60493279px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + <ellipse + ry="8.1366978" + rx="6.9519358" + cy="9.6214514" + cx="25.00449" + id="path282" + style="opacity:1;vector-effect:none;fill:#1a1a1a;fill-opacity:1;stroke:#000000;stroke-width:1.09073901px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + </g> + </g> + <metadata + id="metadata53"> + <rdf:RDF> + <cc:Work> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <cc:license + rdf:resource="http://creativecommons.org/licenses/publicdomain/" /> + <dc:publisher> + <cc:Agent + rdf:about="http://openclipart.org/"> + <dc:title>Openclipart</dc:title> + </cc:Agent> + </dc:publisher> + <dc:title></dc:title> + <dc:date>2010-03-29T08:04:16</dc:date> + <dc:description>"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></dc:description> + <dc:source>https://openclipart.org/detail/35215/tango-internet-mail-by-warszawianka</dc:source> + <dc:creator> + <cc:Agent> + <dc:title>warszawianka</dc:title> + </cc:Agent> + </dc:creator> + <dc:subject> + <rdf:Bag> + <rdf:li>email</rdf:li> + <rdf:li>envelope</rdf:li> + <rdf:li>externalsource</rdf:li> + <rdf:li>icon</rdf:li> + <rdf:li>letter</rdf:li> + <rdf:li>tango</rdf:li> + </rdf:Bag> + </dc:subject> + </cc:Work> + <cc:License + rdf:about="http://creativecommons.org/licenses/publicdomain/"> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Reproduction" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Distribution" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /> + </cc:License> + </rdf:RDF> + </metadata> +</svg> 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 7e2cdabf6..76c70ed5d 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -156,6 +156,12 @@ Config::set_defaults () for (int i = 0; i < NOTIFICATION_COUNT; ++i) { _notification[i] = false; } + _barco_username = optional<string>(); + _barco_password = optional<string>(); + _christie_username = optional<string>(); + _christie_password = optional<string>(); + _gdc_username = optional<string>(); + _gdc_password = optional<string>(); _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -463,6 +469,13 @@ 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"); + _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)) { cxml::Document f ("Cinemas"); @@ -806,6 +819,27 @@ 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); + } + + if (_christie_username) { + root->add_child("ChristieUsername")->add_child_text(*_christie_username); + } + if (_christie_password) { + 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 dbe6a9c21..0be3b20b9 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -423,6 +423,30 @@ public: return _notification[n]; } + boost::optional<std::string> barco_username () const { + return _barco_username; + } + + boost::optional<std::string> barco_password () const { + return _barco_password; + } + + boost::optional<std::string> christie_username () const { + return _christie_username; + } + + boost::optional<std::string> christie_password () const { + return _christie_password; + } + + boost::optional<std::string> gdc_username () const { + return _gdc_username; + } + + boost::optional<std::string> gdc_password () const { + return _gdc_password; + } + /* SET (mostly) */ void set_master_encoding_threads (int n) { @@ -769,6 +793,54 @@ 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<std::string>()); + } + + void set_barco_password (std::string p) { + maybe_set (_barco_password, p); + } + + void unset_barco_password () { + maybe_set (_barco_password, boost::optional<std::string>()); + } + + void set_christie_username (std::string u) { + maybe_set (_christie_username, u); + } + + void unset_christie_username () { + maybe_set (_christie_username, boost::optional<std::string>()); + } + + void set_christie_password (std::string p) { + maybe_set (_christie_password, p); + } + + void unset_christie_password () { + maybe_set (_christie_password, boost::optional<std::string>()); + } + + void set_gdc_username (std::string u) { + maybe_set (_gdc_username, u); + } + + void unset_gdc_username () { + maybe_set (_gdc_username, boost::optional<std::string>()); + } + + void set_gdc_password (std::string p) { + maybe_set (_gdc_password, p); + } + + void unset_gdc_password () { + maybe_set (_gdc_password, boost::optional<std::string>()); + } + void changed (Property p = OTHER); boost::signals2::signal<void (Property)> Changed; /** Emitted if read() failed on an existing Config file. There is nothing @@ -944,6 +1016,12 @@ private: boost::optional<int> _decode_reduction; bool _default_notify; bool _notification[NOTIFICATION_COUNT]; + boost::optional<std::string> _barco_username; + boost::optional<std::string> _barco_password; + boost::optional<std::string> _christie_username; + boost::optional<std::string> _christie_password; + boost::optional<std::string> _gdc_username; + boost::optional<std::string> _gdc_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<FILE*> (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<string> -get_from_zip_url (string url, string file, bool pasv, function<void (boost::filesystem::path)> 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<void (boost::file CURLcode const cr = curl_easy_perform (curl); - temp_zip.close (); + temp.close (); curl_easy_cleanup (curl); if (cr != CURLE_OK) { - return String::compose (_("Download failed (%1/%2 error %3)"), url, file, (int) cr); + return String::compose (_("Download failed (%1 error %2)"), url, (int) cr); + } + + return optional<string>(); +} + +optional<string> +get_from_url (string url, bool pasv, function<void (boost::filesystem::path)> load) +{ + ScopedTemporary temp; + optional<string> e = get_from_url (url, pasv, temp); + if (e) { + return e; + } + load (temp.file()); + return optional<string>(); +} + +/** @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<string> +get_from_zip_url (string url, string file, bool pasv, function<void (boost::filesystem::path)> load) +{ + /* Download the ZIP file to temp_zip */ + ScopedTemporary temp_zip; + optional<string> 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<void (boost::file } ScopedTemporary temp_cert; - f = temp_cert.open ("wb"); + FILE* f = temp_cert.open ("wb"); char buffer[4096]; while (true) { int const N = zip_fread (file_in_zip, buffer, sizeof (buffer)); diff --git a/src/lib/internet.h b/src/lib/internet.h index 9b88bde97..15746a44a 100644 --- a/src/lib/internet.h +++ b/src/lib/internet.h @@ -22,4 +22,5 @@ #include <boost/function.hpp> #include <boost/filesystem.hpp> +boost::optional<std::string> get_from_url (std::string url, bool pasv, boost::function<void (boost::filesystem::path)> load); boost::optional<std::string> get_from_zip_url (std::string url, std::string file, bool pasv, boost::function<void (boost::filesystem::path)> 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 <cth@carlh.net> + Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -19,12 +19,13 @@ */ #include <boost/filesystem.hpp> +#include <boost/noncopyable.hpp> #include <cstdio> /** @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 <cth@carlh.net> + + 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 <http://www.gnu.org/licenses/>. + +*/ + +#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<string> 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 <cth@carlh.net> + + 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 <http://www.gnu.org/licenses/>. + +*/ + +#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/christie_certificate_panel.cc b/src/wx/christie_certificate_panel.cc new file mode 100644 index 000000000..fa91cc2b5 --- /dev/null +++ b/src/wx/christie_certificate_panel.cc @@ -0,0 +1,85 @@ +/* + Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + + 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 <http://www.gnu.org/licenses/>. + +*/ + +#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 prefix = String::compose( + "ftp://%1:%2@certificates.christiedigital.com/Certificates/", + Config::instance()->christie_username().get(), + 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<string> all_errors; + + optional<string> error = get_from_url (url, true, boost::bind (&DownloadCertificatePanel::load, this, _1)); + if (error) { + all_errors = *error; + + 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) { + *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 <cth@carlh.net> + + 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 <http://www.gnu.org/licenses/>. + +*/ + +#include "download_certificate_panel.h" + +class ChristieCertificatePanel : public DownloadCertificatePanel +{ +public: + ChristieCertificatePanel (DownloadCertificateDialog* dialog); + + 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 6f59b9147..ea0207a9b 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -38,27 +38,10 @@ using boost::function; using boost::optional; using dcp::raw_convert; -DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (parent, dialog) +DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (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 (); -} - -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 @@ -156,8 +139,10 @@ try_cp850 (list<string>& urls, list<string>& files, string prefix, string serial } void -DolbyDoremiCertificatePanel::finish_download (string serial, wxStaticText* message) +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/"; @@ -201,10 +186,10 @@ DolbyDoremiCertificatePanel::finish_download (string serial, wxStaticText* messa } 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) { @@ -215,8 +200,8 @@ DolbyDoremiCertificatePanel::finish_download (string serial, wxStaticText* messa } } -bool -DolbyDoremiCertificatePanel::ready_to_download () const +wxString +DolbyDoremiCertificatePanel::name () const { - return !_serial->IsEmpty (); + return _("Dolby / Doremi"); } diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h index b8df76569..665281073 100644 --- a/src/wx/dolby_doremi_certificate_panel.h +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -23,13 +23,8 @@ class DolbyDoremiCertificatePanel : public DownloadCertificatePanel { public: - DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + DolbyDoremiCertificatePanel (DownloadCertificateDialog* dialog); - bool ready_to_download () const; - void download (wxStaticText* message); - -private: - void finish_download (std::string serial, wxStaticText* message); - - wxTextCtrl* _serial; + void do_download (); + wxString name () const; }; diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index e18723a4a..a12097001 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -19,6 +19,9 @@ */ #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" @@ -32,10 +35,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)); - _setup.push_back (false); - _notebook->AddPage (_pages.back(), _("Dolby / Doremi"), true); - _download = new wxButton (this, wxID_ANY, _("Download")); sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); @@ -46,6 +45,15 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) font.SetPointSize (font.GetPointSize() - 1); _message->SetFont (font); + _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); + } + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); @@ -57,8 +65,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 () @@ -69,7 +78,7 @@ DownloadCertificateDialog::~DownloadCertificateDialog () void DownloadCertificateDialog::download () { - _pages[_notebook->GetSelection()]->download (_message); + _pages[_notebook->GetSelection()]->download (); } dcp::Certificate @@ -89,17 +98,10 @@ DownloadCertificateDialog::setup_sensitivity () if (ok) { ok->Enable (static_cast<bool>(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..180c13278 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 <cth@carlh.net> + Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -33,13 +33,20 @@ public: void setup_sensitivity (); + wxNotebook* notebook () const { + return _notebook; + } + + wxStaticText* message () const { + return _message; + } + private: void download (); void page_changed (wxNotebookEvent &); wxNotebook* _notebook; std::vector<DownloadCertificatePanel*> _pages; - std::vector<bool> _setup; wxButton* _download; wxStaticText* _message; }; diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index 4052e44a6..2f3b435ef 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 <cth@carlh.net> + Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -20,6 +20,8 @@ #include "wx_util.h" #include "download_certificate_panel.h" +#include "download_certificate_dialog.h" +#include "lib/signal_manager.h" #include <dcp/util.h> #include <dcp/exceptions.h> #include <boost/bind.hpp> @@ -27,8 +29,8 @@ using boost::function; using boost::optional; -DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) - : wxPanel (parent, wxID_ANY) +DownloadCertificatePanel::DownloadCertificatePanel (DownloadCertificateDialog* dialog) + : wxPanel (dialog->notebook(), wxID_ANY) , _dialog (dialog) { _overall_sizer = new wxBoxSizer (wxVERTICAL); @@ -38,11 +40,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); } @@ -62,3 +66,20 @@ DownloadCertificatePanel::certificate () const { return _certificate; } + +void +DownloadCertificatePanel::download () +{ + _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)); +} + +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 6308e49b7..55594c74c 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -30,21 +30,20 @@ class DownloadCertificateDialog; class DownloadCertificatePanel : public wxPanel { public: - DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + DownloadCertificatePanel (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; + virtual void do_download () = 0; + virtual wxString name () const = 0; + virtual bool ready_to_download () const; + void download (); void load (boost::filesystem::path); boost::optional<dcp::Certificate> certificate () const; protected: - void layout (); - DownloadCertificateDialog* _dialog; wxFlexGridSizer* _table; + wxTextCtrl* _serial; private: wxSizer* _overall_sizer; diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 523973618..d21c8a2c1 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -910,6 +910,111 @@ 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); + + 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 () + { + Config* config = Config::instance (); + + 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 () + { + 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 (); + } + } + + 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; +}; + + class NotificationsPage : public StandardPage { public: @@ -1430,6 +1535,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/gdc_certificate_panel.cc b/src/wx/gdc_certificate_panel.cc new file mode 100644 index 000000000..a90f098f5 --- /dev/null +++ b/src/wx/gdc_certificate_panel.cc @@ -0,0 +1,69 @@ +/* + Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + + 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 <http://www.gnu.org/licenses/>. + +*/ + +#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.crt.pem", + Config::instance()->gdc_username().get(), + Config::instance()->gdc_password().get(), + wx_to_std(_serial->GetValue()) + ); + + optional<string> 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 <cth@carlh.net> + + 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 <http://www.gnu.org/licenses/>. + +*/ + +#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 0a32d1dfe..d50286bf4 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -31,10 +31,12 @@ 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 text_view.cc + christie_certificate_panel.cc cinema_dialog.cc colour_conversion_editor.cc config_dialog.cc @@ -66,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 diff --git a/test/content_test.cc b/test/content_test.cc index b077a96d6..330bbdc94 100644 --- a/test/content_test.cc +++ b/test/content_test.cc @@ -123,5 +123,6 @@ BOOST_AUTO_TEST_CASE (content_test3) /* Likewise position */ + 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)); } |
