summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-08-15 02:08:05 +0100
committerCarl Hetherington <cth@carlh.net>2018-08-15 10:57:07 +0100
commitf8acc34bcb4401184064598353d6c54df3cab1f9 (patch)
treef3861ef2b616beb1de08f14a70605480e1feeebc /src/wx
parent6a69f5ba3ce43094493785bb449c91001557b80d (diff)
More rearrangement and add Barco Alchemy.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/barco_alchemy_certificate_panel.cc77
-rw-r--r--src/wx/barco_alchemy_certificate_panel.h31
-rw-r--r--src/wx/dolby_doremi_certificate_panel.cc12
-rw-r--r--src/wx/dolby_doremi_certificate_panel.h4
-rw-r--r--src/wx/download_certificate_dialog.cc9
-rw-r--r--src/wx/download_certificate_dialog.h8
-rw-r--r--src/wx/download_certificate_panel.cc9
-rw-r--r--src/wx/download_certificate_panel.h9
-rw-r--r--src/wx/full_config_dialog.cc72
-rw-r--r--src/wx/wscript1
10 files changed, 212 insertions, 20 deletions
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/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<string>& urls, list<string>& 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<dcp::Certificate> certificate () const;
@@ -43,12 +43,11 @@ public:
protected:
DownloadCertificateDialog* _dialog;
wxFlexGridSizer* _table;
- wxStaticText* _message;
+ wxTextCtrl* _serial;
private:
wxSizer* _overall_sizer;
boost::optional<dcp::Certificate> _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