From: Carl Hetherington Date: Sun, 5 Jan 2020 14:25:58 +0000 (+0100) Subject: Move credentials settings into certificate download dialogue (#1480). X-Git-Tag: v2.15.40~3 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=a713e8258acc3f0e960c4e87ba8684902d29a591 Move credentials settings into certificate download dialogue (#1480). --- diff --git a/doc/manual/dcpomatic.xml b/doc/manual/dcpomatic.xml index 18fe753b5..3e4e1eadd 100644 --- a/doc/manual/dcpomatic.xml +++ b/doc/manual/dcpomatic.xml @@ -3018,33 +3018,6 @@ The Reset to default text will replace the current KDM emai - - -
-Accounts - - -The Accounts tab is shown in . - - -
- Accounts preferences - - - - - -
- - -DCP-o-matic can download projector certificates from the Barco, -Christie and GDC websites if you have the appropriate credentials. -Enter your usernames and passwords. - - -
- -
Notifications diff --git a/graphics/osx/preferences/accounts.png b/graphics/osx/preferences/accounts.png deleted file mode 100644 index f9909b7a5..000000000 Binary files a/graphics/osx/preferences/accounts.png and /dev/null differ diff --git a/graphics/src/accounts.svg b/graphics/src/accounts.svg deleted file mode 100644 index 920051848..000000000 --- a/graphics/src/accounts.svg +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 f0d91bf89..2e5bccd17 100755 --- a/graphics/update +++ b/graphics/update @@ -63,7 +63,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 accounts locations sound; do + for i in colour_conversions defaults email kdm_email cover_sheet keys tms notifications locations sound; do $INKSCAPE osx/preferences/$i.png src/$i.svg -w 32 -h 32 done diff --git a/platform/osx/make_dmg.sh b/platform/osx/make_dmg.sh index fa9240050..7a9542fd7 100644 --- a/platform/osx/make_dmg.sh +++ b/platform/osx/make_dmg.sh @@ -195,7 +195,6 @@ function copy_resources { cp $prefix/src/dcpomatic/graphics/osx/preferences/keys.png "$dest" cp $prefix/src/dcpomatic/graphics/osx/preferences/cover_sheet.png "$dest" cp $prefix/src/dcpomatic/graphics/osx/preferences/notifications.png "$dest" - cp $prefix/src/dcpomatic/graphics/osx/preferences/accounts.png "$dest" cp $prefix/src/dcpomatic/graphics/osx/preferences/locations.png "$dest" cp $prefix/src/dcpomatic/fonts/LiberationSans-Regular.ttf "$dest" cp $prefix/src/dcpomatic/fonts/LiberationSans-Italic.ttf "$dest" 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 + Copyright (C) 2018-2020 Carl Hetherington 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 + + 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_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 ()> get_username, + function set_username, + function unset_username, + function ()> get_password, + function set_password, + function 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(_get_username()) && _get_username().get() != "" && static_cast(_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 + + 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 . + +*/ + +#ifndef CREDENTIALS_DOWNLOAD_CERTIFICATE_PANEL_H +#define CREDENTIALS_DOWNLOAD_CERTIFICATE_PANEL_H + +#include "download_certificate_panel.h" +#include + +class PasswordEntry; + +class CredentialsDownloadCertificatePanel : public DownloadCertificatePanel +{ +public: + CredentialsDownloadCertificatePanel ( + DownloadCertificateDialog* dialog, + boost::function ()> get_username, + boost::function set_username, + boost::function unset_username, + boost::function ()> get_password, + boost::function set_password, + boost::function unset_password + ); + + virtual bool ready_to_download () const; + +private: + void username_changed (); + void password_changed (); + + boost::function (void)> _get_username; + boost::function _set_username; + boost::function _unset_username; + boost::function (void)> _get_password; + boost::function _set_password; + boost::function _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 #include #include 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 _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 + Copyright (C) 2018-2020 Carl Hetherington 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