From 72d1f6694f032a6044a4b14ee9ad9cba2b9756f3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Mar 2019 00:44:54 +0000 Subject: [PATCH] Nag/warn when removing KDM decryption certificate. --- src/lib/config.h | 2 +- src/wx/config_dialog.cc | 19 ++++++++++++------- src/wx/config_dialog.h | 6 +++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/lib/config.h b/src/lib/config.h index 7f8dd0cd4..7d21964a4 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -366,7 +366,7 @@ public: enum Nag { NAG_DKDM_CONFIG, NAG_ENCRYPTED_METADATA, - NAG_REMAKE_DECRYPTION_CHAIN, + NAG_ALTER_DECRYPTION_CHAIN, NAG_BAD_SIGNER_CHAIN, /* Not really a nag but it's the same idea */ NAG_INITIAL_SETUP, diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index a9cf7da07..0a7e45221 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington + Copyright (C) 2012-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -332,12 +332,12 @@ CertificateChainEditor::CertificateChainEditor ( int border, function)> set, function (void)> get, - function nag_remake + function nag_alter ) : wxDialog (parent, wxID_ANY, title) , _set (set) , _get (get) - , _nag_remake (nag_remake) + , _nag_alter (nag_alter) { wxFont subheading_font (*wxNORMAL_FONT); subheading_font.SetWeight (wxFONTWEIGHT_BOLD); @@ -499,6 +499,11 @@ CertificateChainEditor::add_certificate () void CertificateChainEditor::remove_certificate () { + if (_nag_alter()) { + /* Cancel was clicked */ + return; + } + int i = _certificates->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (i == -1) { return; @@ -634,7 +639,7 @@ CertificateChainEditor::remake_certificates () intermediate_common_name = i->subject_common_name (); } - if (_nag_remake()) { + if (_nag_alter()) { /* Cancel was clicked */ return; } @@ -793,7 +798,7 @@ KeysPage::decryption_advanced () _panel, _("Decrypting KDMs"), _border, bind (&Config::set_decryption_chain, Config::instance (), _1), bind (&Config::decryption_chain, Config::instance ()), - bind (&KeysPage::nag_remake_decryption_chain, this) + bind (&KeysPage::nag_alter_decryption_chain, this) ); c->ShowModal(); @@ -889,11 +894,11 @@ KeysPage::import_decryption_chain_and_key () } bool -KeysPage::nag_remake_decryption_chain () +KeysPage::nag_alter_decryption_chain () { return NagDialog::maybe_nag ( _panel, - Config::NAG_REMAKE_DECRYPTION_CHAIN, + Config::NAG_ALTER_DECRYPTION_CHAIN, _("If you continue with this operation you will no longer be able to use any DKDMs that you have created. Also, any KDMs that have been sent to you will become useless. Proceed with caution!"), true ); diff --git a/src/wx/config_dialog.h b/src/wx/config_dialog.h index 896b463d8..ab2553e56 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -120,7 +120,7 @@ public: int border, boost::function)> set, boost::function (void)> get, - boost::function nag_remake + boost::function nag_alter ); void add_button (wxWindow* button); @@ -151,7 +151,7 @@ private: wxBoxSizer* _button_sizer; boost::function)> _set; boost::function (void)> _get; - boost::function _nag_remake; + boost::function _nag_alter; }; class KeysPage : public StandardPage @@ -176,7 +176,7 @@ private: void export_decryption_certificate (); void config_changed () {} - bool nag_remake_decryption_chain (); + bool nag_alter_decryption_chain (); void decryption_advanced (); void signing_advanced (); void export_decryption_chain_and_key (); -- 2.30.2