for (int i = 0; i < NOTIFICATION_COUNT; ++i) {
_notification[i] = false;
}
+ _barco_username = optional<string>();
+ _barco_password = optional<string>();
_allowed_dcp_frame_rates.clear ();
_allowed_dcp_frame_rates.push_back (24);
}
}
+ _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");
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) {
return _notification[n];
}
+ boost::optional<std::string> barco_username () const {
+ return _barco_username;
+ }
+
+ boost::optional<std::string> barco_password () const {
+ return _barco_password;
+ }
+
/* SET (mostly) */
void set_master_encoding_threads (int n) {
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 changed (Property p = OTHER);
boost::signals2::signal<void (Property)> Changed;
/** Emitted if read() failed on an existing Config file. There is nothing
boost::optional<int> _decode_reduction;
bool _default_notify;
bool _notification[NOTIFICATION_COUNT];
+ boost::optional<std::string> _barco_username;
+ boost::optional<std::string> _barco_password;
static int const _current_version;
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);
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 */
}
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));
#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);
/*
- 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.
*/
#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 ();
--- /dev/null
+/*
+ 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");
+}
--- /dev/null
+/*
+ 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;
+};
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)
{
}
}
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/";
}
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) {
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;
};
*/
#include "dolby_doremi_certificate_panel.h"
+#include "barco_alchemy_certificate_panel.h"
#include "download_certificate_dialog.h"
#include "wx_util.h"
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);
_download->Bind (wxEVT_BUTTON, boost::bind (&DownloadCertificateDialog::download, this));
_download->Enable (false);
- wxNotebookEvent ev;
- page_changed (ev);
+ _notebook->SetSelection (0);
+
+ setup_sensitivity ();
}
DownloadCertificateDialog::~DownloadCertificateDialog ()
void setup_sensitivity ();
+ wxNotebook* notebook () const {
+ return _notebook;
+ }
+
+ wxStaticText* message () const {
+ return _message;
+ }
+
private:
void download ();
void page_changed (wxNotebookEvent &);
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);
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
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<dcp::Certificate> certificate () const;
protected:
DownloadCertificateDialog* _dialog;
wxFlexGridSizer* _table;
- wxStaticText* _message;
+ wxTextCtrl* _serial;
private:
wxSizer* _overall_sizer;
boost::optional<dcp::Certificate> _certificate;
- wxTextCtrl* _serial;
};
#endif
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:
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));
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