From c2cbab19cc66ec3e2e2e7e5c8c208983396de70c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 30 Jan 2019 11:27:53 +0000 Subject: [PATCH] Hide the 'export decryption chain' button in the advanced page of preferences. --- src/wx/config_dialog.cc | 51 +++++++++++++++++++++-------------------- src/wx/config_dialog.h | 3 ++- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 8b6d215a2..13a405670 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -408,6 +408,8 @@ CertificateChainEditor::CertificateChainEditor ( _button_sizer = new wxBoxSizer (wxHORIZONTAL); _remake_certificates = new Button (this, _("Re-make certificates and key...")); _button_sizer->Add (_remake_certificates, 1, wxRIGHT, border); + _export_chain = new Button (this, _("Export chain...")); + _button_sizer->Add (_export_chain, 1, wxRIGHT, border); table->Add (_button_sizer, wxGBPosition (r, 0), wxGBSpan (1, 4)); ++r; @@ -424,6 +426,7 @@ CertificateChainEditor::CertificateChainEditor ( _certificates->Bind (wxEVT_LIST_ITEM_SELECTED, bind (&CertificateChainEditor::update_sensitivity, this)); _certificates->Bind (wxEVT_LIST_ITEM_DESELECTED, bind (&CertificateChainEditor::update_sensitivity, this)); _remake_certificates->Bind (wxEVT_BUTTON, bind (&CertificateChainEditor::remake_certificates, this)); + _export_chain->Bind (wxEVT_BUTTON, bind (&CertificateChainEditor::export_chain, this)); _import_private_key->Bind (wxEVT_BUTTON, bind (&CertificateChainEditor::import_private_key, this)); _export_private_key->Bind (wxEVT_BUTTON, bind (&CertificateChainEditor::export_private_key, this)); @@ -542,6 +545,29 @@ CertificateChainEditor::export_certificate () d->Destroy (); } +void +CertificateChainEditor::export_chain () +{ + wxFileDialog* d = new wxFileDialog ( + this, _("Select Chain File"), wxEmptyString, wxEmptyString, wxT("PEM files (*.pem)|*.pem"), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT + ); + + if (d->ShowModal () == wxID_OK) { + boost::filesystem::path path (wx_to_std(d->GetPath())); + FILE* f = fopen_boost (path, "w"); + if (!f) { + throw OpenFileError (path, errno, false); + } + + string const s = _get()->chain(); + checked_fwrite (s.c_str(), s.length(), f, path); + fclose (f); + } + + d->Destroy (); +} + void CertificateChainEditor::update_certificate_list () { @@ -737,8 +763,6 @@ KeysPage::setup () wxButton* export_decryption_certificate = new Button (_panel, _("Export KDM decryption certificate...")); sizer->Add (export_decryption_certificate, 0, wxLEFT, _border); - wxButton* export_decryption_chain = new Button (_panel, _("Export KDM decryption chain...")); - sizer->Add (export_decryption_chain, 0, wxLEFT, _border); wxButton* export_settings = new Button (_panel, _("Export all KDM decryption settings...")); sizer->Add (export_settings, 0, wxLEFT, _border); wxButton* import_settings = new Button (_panel, _("Import all KDM decryption settings...")); @@ -747,7 +771,6 @@ KeysPage::setup () sizer->Add (decryption_advanced, 0, wxALL, _border); export_decryption_certificate->Bind (wxEVT_BUTTON, bind (&KeysPage::export_decryption_certificate, this)); - export_decryption_chain->Bind (wxEVT_BUTTON, bind (&KeysPage::export_decryption_chain, this)); export_settings->Bind (wxEVT_BUTTON, bind (&KeysPage::export_decryption_chain_and_key, this)); import_settings->Bind (wxEVT_BUTTON, bind (&KeysPage::import_decryption_chain_and_key, this)); decryption_advanced->Bind (wxEVT_BUTTON, bind (&KeysPage::decryption_advanced, this)); @@ -867,28 +890,6 @@ KeysPage::nag_remake_decryption_chain () ); } -void -KeysPage::export_decryption_chain () -{ - wxFileDialog* d = new wxFileDialog ( - _panel, _("Select Chain File"), wxEmptyString, _("dcpomatic_kdm_decryption_chain.pem"), wxT ("PEM files (*.pem)|*.pem"), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT - ); - - if (d->ShowModal () == wxID_OK) { - boost::filesystem::path path (wx_to_std(d->GetPath())); - FILE* f = fopen_boost (path, "w"); - if (!f) { - throw OpenFileError (path, errno, false); - } - - string const s = Config::instance()->decryption_chain()->chain(); - checked_fwrite (s.c_str(), s.length(), f, path); - fclose (f); - } - d->Destroy (); -} - void KeysPage::export_decryption_certificate () { diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index 3b8762d8b..896b463d8 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -135,6 +135,7 @@ private: void update_private_key (); void import_private_key (); void export_private_key (); + void export_chain (); wxListCtrl* _certificates; wxButton* _add_certificate; @@ -144,6 +145,7 @@ private: wxStaticText* _private_key; wxButton* _import_private_key; wxButton* _export_private_key; + wxButton* _export_chain; wxStaticText* _private_key_bad; wxSizer* _sizer; wxBoxSizer* _button_sizer; @@ -173,7 +175,6 @@ private: void setup (); void export_decryption_certificate (); - void export_decryption_chain (); void config_changed () {} bool nag_remake_decryption_chain (); void decryption_advanced (); -- 2.30.2