diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-01-05 15:25:58 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-01-06 10:29:24 +0100 |
| commit | a713e8258acc3f0e960c4e87ba8684902d29a591 (patch) | |
| tree | 4023978fc160f8e75ced0b8be1e13b7dea452aa3 /src | |
| parent | c9772ea0129d59e84cc85cd3908e712b5df56970 (diff) | |
Move credentials settings into certificate download dialogue (#1480).
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/barco_alchemy_certificate_panel.cc | 19 | ||||
| -rw-r--r-- | src/wx/barco_alchemy_certificate_panel.h | 4 | ||||
| -rw-r--r-- | src/wx/christie_certificate_panel.cc | 19 | ||||
| -rw-r--r-- | src/wx/christie_certificate_panel.h | 6 | ||||
| -rw-r--r-- | src/wx/credentials_download_certificate_panel.cc | 92 | ||||
| -rw-r--r-- | src/wx/credentials_download_certificate_panel.h | 59 | ||||
| -rw-r--r-- | src/wx/download_certificate_dialog.h | 1 | ||||
| -rw-r--r-- | src/wx/download_certificate_panel.h | 2 | ||||
| -rw-r--r-- | src/wx/full_config_dialog.cc | 140 | ||||
| -rw-r--r-- | src/wx/gdc_certificate_panel.cc | 18 | ||||
| -rw-r--r-- | src/wx/gdc_certificate_panel.h | 6 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
12 files changed, 193 insertions, 174 deletions
diff --git a/src/wx/barco_alchemy_certificate_panel.cc b/src/wx/barco_alchemy_certificate_panel.cc index 84048c65c..47dd85e07 100644 --- a/src/wx/barco_alchemy_certificate_panel.cc +++ b/src/wx/barco_alchemy_certificate_panel.cc @@ -29,7 +29,15 @@ using std::string; using boost::optional; BarcoAlchemyCertificatePanel::BarcoAlchemyCertificatePanel (DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (dialog) + : CredentialsDownloadCertificatePanel ( + dialog, + boost::bind(&Config::barco_username, Config::instance()), + boost::bind(&Config::set_barco_username, Config::instance(), _1), + boost::bind(&Config::unset_barco_username, Config::instance()), + boost::bind(&Config::barco_password, Config::instance()), + boost::bind(&Config::set_barco_password, Config::instance(), _1), + boost::bind(&Config::unset_barco_password, Config::instance()) + ) { } @@ -37,19 +45,12 @@ BarcoAlchemyCertificatePanel::BarcoAlchemyCertificatePanel (DownloadCertificateD bool BarcoAlchemyCertificatePanel::ready_to_download () const { - return _serial->GetValue().Length() == 10; + return CredentialsDownloadCertificatePanel::ready_to_download() && _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", diff --git a/src/wx/barco_alchemy_certificate_panel.h b/src/wx/barco_alchemy_certificate_panel.h index 83a74fa21..fce7d3f5d 100644 --- a/src/wx/barco_alchemy_certificate_panel.h +++ b/src/wx/barco_alchemy_certificate_panel.h @@ -18,9 +18,9 @@ */ -#include "download_certificate_panel.h" +#include "credentials_download_certificate_panel.h" -class BarcoAlchemyCertificatePanel : public DownloadCertificatePanel +class BarcoAlchemyCertificatePanel : public CredentialsDownloadCertificatePanel { public: BarcoAlchemyCertificatePanel (DownloadCertificateDialog* dialog); diff --git a/src/wx/christie_certificate_panel.cc b/src/wx/christie_certificate_panel.cc index 9e95aa994..7db3fef25 100644 --- a/src/wx/christie_certificate_panel.cc +++ b/src/wx/christie_certificate_panel.cc @@ -27,9 +27,19 @@ using std::string; using boost::optional; +using boost::bind; ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (dialog) + : CredentialsDownloadCertificatePanel ( + dialog, + bind(&Config::christie_username, Config::instance()), + bind(&Config::set_christie_username, Config::instance(), _1), + bind(&Config::unset_christie_username, Config::instance()), + bind(&Config::christie_password, Config::instance()), + bind(&Config::set_christie_password, Config::instance(), _1), + bind(&Config::unset_christie_password, Config::instance()) + ) + { } @@ -37,13 +47,6 @@ ChristieCertificatePanel::ChristieCertificatePanel (DownloadCertificateDialog* d 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(), diff --git a/src/wx/christie_certificate_panel.h b/src/wx/christie_certificate_panel.h index 0c9a64d46..41278cb7c 100644 --- a/src/wx/christie_certificate_panel.h +++ b/src/wx/christie_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,9 +18,9 @@ */ -#include "download_certificate_panel.h" +#include "credentials_download_certificate_panel.h" -class ChristieCertificatePanel : public DownloadCertificatePanel +class ChristieCertificatePanel : public CredentialsDownloadCertificatePanel { public: ChristieCertificatePanel (DownloadCertificateDialog* dialog); diff --git a/src/wx/credentials_download_certificate_panel.cc b/src/wx/credentials_download_certificate_panel.cc new file mode 100644 index 000000000..fb4908269 --- /dev/null +++ b/src/wx/credentials_download_certificate_panel.cc @@ -0,0 +1,92 @@ +/* + Copyright (C) 2020 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_dialog.h" +#include "credentials_download_certificate_panel.h" +#include "password_entry.h" +#include "wx_util.h" + +using std::string; +using boost::function; +using boost::optional; + +CredentialsDownloadCertificatePanel::CredentialsDownloadCertificatePanel ( + DownloadCertificateDialog* dialog, + function<optional<string> ()> get_username, + function<void (string)> set_username, + function<void ()> unset_username, + function<optional<string> ()> get_password, + function<void (string)> set_password, + function<void ()> unset_password + ) + : DownloadCertificatePanel (dialog) + , _get_username (get_username) + , _set_username (set_username) + , _unset_username (unset_username) + , _get_password (get_password) + , _set_password (set_password) + , _unset_password (unset_password) +{ + add_label_to_sizer (_table, this, _("User name"), true); + _username = new wxTextCtrl (this, wxID_ANY, std_to_wx(_get_username().get_value_or("")), wxDefaultPosition, wxSize(300, -1)); + _table->Add (_username, 1, wxEXPAND); + + add_label_to_sizer (_table, this, _("Password"), true); + _password = new PasswordEntry (this); + _password->set (_get_password().get_value_or("")); + _table->Add (_password->get_panel(), 1, wxEXPAND); + + _username->Bind (wxEVT_TEXT, boost::bind(&CredentialsDownloadCertificatePanel::username_changed, this)); + _password->Changed.connect (boost::bind(&CredentialsDownloadCertificatePanel::password_changed, this)); + + _overall_sizer->Layout (); + _overall_sizer->SetSizeHints (this); +} + +bool +CredentialsDownloadCertificatePanel::ready_to_download () const +{ + return DownloadCertificatePanel::ready_to_download() && static_cast<bool>(_get_username()) && _get_username().get() != "" && static_cast<bool>(_get_password()) && _get_password().get() != ""; +} + +void +CredentialsDownloadCertificatePanel::username_changed () +{ + wxString const s = _username->GetValue(); + if (!s.IsEmpty()) { + _set_username (wx_to_std(s)); + } else { + _unset_username (); + } + _dialog->setup_sensitivity (); +} + +void +CredentialsDownloadCertificatePanel::password_changed () +{ + string const s = _password->get(); + if (!s.empty()) { + _set_password (s); + } else { + _unset_password (); + } + _dialog->setup_sensitivity (); +} + diff --git a/src/wx/credentials_download_certificate_panel.h b/src/wx/credentials_download_certificate_panel.h new file mode 100644 index 000000000..68472462a --- /dev/null +++ b/src/wx/credentials_download_certificate_panel.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2020 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/>. + +*/ + +#ifndef CREDENTIALS_DOWNLOAD_CERTIFICATE_PANEL_H +#define CREDENTIALS_DOWNLOAD_CERTIFICATE_PANEL_H + +#include "download_certificate_panel.h" +#include <boost/function.hpp> + +class PasswordEntry; + +class CredentialsDownloadCertificatePanel : public DownloadCertificatePanel +{ +public: + CredentialsDownloadCertificatePanel ( + DownloadCertificateDialog* dialog, + boost::function<boost::optional<std::string> ()> get_username, + boost::function<void (std::string)> set_username, + boost::function<void ()> unset_username, + boost::function<boost::optional<std::string> ()> get_password, + boost::function<void (std::string)> set_password, + boost::function<void ()> unset_password + ); + + virtual bool ready_to_download () const; + +private: + void username_changed (); + void password_changed (); + + boost::function<boost::optional<std::string> (void)> _get_username; + boost::function<void (std::string)> _set_username; + boost::function<void ()> _unset_username; + boost::function<boost::optional<std::string> (void)> _get_password; + boost::function<void (std::string)> _set_password; + boost::function<void ()> _unset_password; + + wxTextCtrl* _username; + PasswordEntry* _password; +}; + +#endif diff --git a/src/wx/download_certificate_dialog.h b/src/wx/download_certificate_dialog.h index 180c13278..a2fbf808f 100644 --- a/src/wx/download_certificate_dialog.h +++ b/src/wx/download_certificate_dialog.h @@ -18,6 +18,7 @@ */ +#include <dcp/certificate.h> #include <wx/wx.h> #include <wx/notebook.h> diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index 55594c74c..d1f0bf4de 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -44,9 +44,9 @@ protected: DownloadCertificateDialog* _dialog; wxFlexGridSizer* _table; wxTextCtrl* _serial; + wxSizer* _overall_sizer; private: - wxSizer* _overall_sizer; boost::optional<dcp::Certificate> _certificate; }; diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index f586672a8..ce199e58a 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -981,145 +981,6 @@ 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 user name"), 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 PasswordEntry (_panel); - table->Add (_barco_password->get_panel(), 1, wxEXPAND | wxALL); - - add_label_to_sizer (table, _panel, _("certificates.christiedigital.com user name"), 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 PasswordEntry (_panel); - table->Add (_christie_password->get_panel(), 1, wxEXPAND | wxALL); - - add_label_to_sizer (table, _panel, _("GDC user name"), true); - _gdc_username = new wxTextCtrl (_panel, wxID_ANY); - table->Add (_gdc_username, 1, wxEXPAND | wxALL); - - add_label_to_sizer (table, _panel, _("GDC password"), true); - _gdc_password = new PasswordEntry (_panel); - table->Add (_gdc_password->get_panel(), 1, wxEXPAND | wxALL); - - _barco_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::barco_username_changed, this)); - _barco_password->Changed.connect (boost::bind(&AccountsPage::barco_password_changed, this)); - _christie_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::christie_username_changed, this)); - _christie_password->Changed.connect (boost::bind(&AccountsPage::christie_password_changed, this)); - _gdc_username->Bind (wxEVT_TEXT, boost::bind(&AccountsPage::gdc_username_changed, this)); - _gdc_password->Changed.connect (boost::bind(&AccountsPage::gdc_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("")); - checked_set (_gdc_username, config->gdc_username().get_value_or("")); - checked_set (_gdc_password, config->gdc_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 () - { - string const s = _barco_password->get(); - if (!s.empty()) { - Config::instance()->set_barco_password(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 () - { - string const s = _christie_password->get(); - if (!s.empty()) { - Config::instance()->set_christie_password(s); - } else { - Config::instance()->unset_christie_password(); - } - } - - void gdc_username_changed () - { - wxString const s = _gdc_username->GetValue(); - if (!s.IsEmpty()) { - Config::instance()->set_gdc_username (wx_to_std(s)); - } else { - Config::instance()->unset_gdc_username (); - } - } - - void gdc_password_changed () - { - string const s = _gdc_password->get(); - if (!s.empty()) { - Config::instance()->set_gdc_password(s); - } else { - Config::instance()->unset_gdc_password(); - } - } - -private: - wxTextCtrl* _barco_username; - PasswordEntry* _barco_password; - wxTextCtrl* _christie_username; - PasswordEntry* _christie_password; - wxTextCtrl* _gdc_username; - PasswordEntry* _gdc_password; -}; - - class NotificationsPage : public StandardPage { public: @@ -1683,7 +1544,6 @@ 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 index b0bb31674..a4301087d 100644 --- a/src/wx/gdc_certificate_panel.cc +++ b/src/wx/gdc_certificate_panel.cc @@ -27,9 +27,18 @@ using std::string; using boost::optional; +using boost::bind; GDCCertificatePanel::GDCCertificatePanel (DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (dialog) + : CredentialsDownloadCertificatePanel ( + dialog, + bind(&Config::gdc_username, Config::instance()), + bind(&Config::set_gdc_username, Config::instance(), _1), + bind(&Config::unset_gdc_username, Config::instance()), + bind(&Config::gdc_password, Config::instance()), + bind(&Config::set_gdc_password, Config::instance(), _1), + bind(&Config::unset_gdc_password, Config::instance()) + ) { } @@ -37,13 +46,6 @@ GDCCertificatePanel::GDCCertificatePanel (DownloadCertificateDialog* 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(), diff --git a/src/wx/gdc_certificate_panel.h b/src/wx/gdc_certificate_panel.h index 18a78e586..b69c7a51f 100644 --- a/src/wx/gdc_certificate_panel.h +++ b/src/wx/gdc_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,9 +18,9 @@ */ -#include "download_certificate_panel.h" +#include "credentials_download_certificate_panel.h" -class GDCCertificatePanel : public DownloadCertificatePanel +class GDCCertificatePanel : public CredentialsDownloadCertificatePanel { public: GDCCertificatePanel (DownloadCertificateDialog* dialog); diff --git a/src/wx/wscript b/src/wx/wscript index b04054a77..f4fc4927e 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -48,6 +48,7 @@ sources = """ content_view.cc controls.cc closed_captions_dialog.cc + credentials_download_certificate_panel.cc dcp_panel.cc dcpomatic_button.cc email_dialog.cc |
