diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-01-07 00:02:00 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-01-07 00:02:00 +0000 |
| commit | 1da6ec96a4cdb4915c394bd4c272b6bfcc2033c8 (patch) | |
| tree | f9ca86522ac72599178745e43251f29560c5d61d | |
| parent | 4042c59cd8a1007e0d8f1959569bf2699bdfbe8b (diff) | |
Make certificate re-creation cancellable and default nags
to not going away (#1158).
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | src/wx/config_dialog.cc | 18 | ||||
| -rw-r--r-- | src/wx/config_dialog.h | 6 | ||||
| -rw-r--r-- | src/wx/nag_dialog.cc | 33 | ||||
| -rw-r--r-- | src/wx/nag_dialog.h | 4 |
5 files changed, 41 insertions, 25 deletions
@@ -1,3 +1,8 @@ +2018-01-07 Carl Hetherington <cth@carlh.net> + + * Make certificate re-creation cancellable and default nags + to not going away (#1158). + 2018-01-06 Carl Hetherington <cth@carlh.net> * Check that we can decrypt a DKDM when it is loaded into diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 8d10fb9eb..fb80963f4 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -32,10 +32,10 @@ using boost::shared_ptr; using boost::function; static -void +bool do_nothing () { - + return false; } Page::Page (wxSize panel_size, int border) @@ -329,7 +329,7 @@ CertificateChainEditor::CertificateChainEditor ( int border, function<void (shared_ptr<dcp::CertificateChain>)> set, function<shared_ptr<const dcp::CertificateChain> (void)> get, - function<void (void)> nag_remake + function<bool (void)> nag_remake ) : wxDialog (parent, wxID_ANY, title) , _set (set) @@ -604,7 +604,10 @@ CertificateChainEditor::remake_certificates () intermediate_common_name = i->subject_common_name (); } - _nag_remake (); + if (_nag_remake()) { + /* Cancel was clicked */ + return; + } MakeChainDialog* d = new MakeChainDialog ( this, @@ -847,13 +850,14 @@ KeysPage::import_decryption_chain_and_key () d->Destroy (); } -void +bool KeysPage::nag_remake_decryption_chain () { - NagDialog::maybe_nag ( + return NagDialog::maybe_nag ( _panel, Config::NAG_REMAKE_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!") + _("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 9a73d4e61..b76f8bc35 100644 --- a/src/wx/config_dialog.h +++ b/src/wx/config_dialog.h @@ -120,7 +120,7 @@ public: int border, boost::function<void (boost::shared_ptr<dcp::CertificateChain>)> set, boost::function<boost::shared_ptr<const dcp::CertificateChain> (void)> get, - boost::function<void (void)> nag_remake + boost::function<bool (void)> nag_remake ); void add_button (wxWindow* button); @@ -149,7 +149,7 @@ private: wxBoxSizer* _button_sizer; boost::function<void (boost::shared_ptr<dcp::CertificateChain>)> _set; boost::function<boost::shared_ptr<const dcp::CertificateChain> (void)> _get; - boost::function<void (void)> _nag_remake; + boost::function<bool (void)> _nag_remake; }; class KeysPage : public StandardPage @@ -176,7 +176,7 @@ private: void export_decryption_certificate (); void export_decryption_chain (); void config_changed () {} - void nag_remake_decryption_chain (); + bool nag_remake_decryption_chain (); void decryption_advanced (); void signing_advanced (); void export_decryption_chain_and_key (); diff --git a/src/wx/nag_dialog.cc b/src/wx/nag_dialog.cc index 69b64cb40..b7efb43db 100644 --- a/src/wx/nag_dialog.cc +++ b/src/wx/nag_dialog.cc @@ -25,7 +25,7 @@ using boost::shared_ptr; -NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message) +NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel) : wxDialog (parent, wxID_ANY, _("Important notice")) , _nag (nag) { @@ -34,15 +34,17 @@ NagDialog::NagDialog (wxWindow* parent, Config::Nag nag, wxString message) sizer->Add (_text, 1, wxEXPAND | wxALL, 6); wxCheckBox* b = new wxCheckBox (this, wxID_ANY, _("Don't show this message again")); - b->SetValue (true); - Config::instance()->set_nagged (_nag, true); sizer->Add (b, 0, wxALL, 6); b->Bind (wxEVT_CHECKBOX, bind (&NagDialog::shut_up, this, _1)); - wxStdDialogButtonSizer* buttons = CreateStdDialogButtonSizer (0); - sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder()); - buttons->SetAffirmativeButton (new wxButton (this, wxID_OK)); - buttons->Realize (); + int flags = wxOK; + if (can_cancel) { + flags |= wxCANCEL; + } + wxSizer* buttons = CreateSeparatedButtonSizer (flags); + if (buttons) { + sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder()); + } SetSizer (sizer); sizer->Layout (); @@ -57,12 +59,17 @@ NagDialog::shut_up (wxCommandEvent& ev) Config::instance()->set_nagged (_nag, ev.IsChecked()); } -void -NagDialog::maybe_nag (wxWindow* parent, Config::Nag nag, wxString message) +/** @return true if the user clicked Cancel */ +bool +NagDialog::maybe_nag (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel) { - if (!Config::instance()->nagged (nag)) { - NagDialog* d = new NagDialog (parent, nag, message); - d->ShowModal (); - d->Destroy (); + if (Config::instance()->nagged(nag)) { + return false; } + + NagDialog* d = new NagDialog (parent, nag, message, can_cancel); + int const r = d->ShowModal(); + d->Destroy (); + + return r == wxID_CANCEL; } diff --git a/src/wx/nag_dialog.h b/src/wx/nag_dialog.h index 06f98d967..83d681fef 100644 --- a/src/wx/nag_dialog.h +++ b/src/wx/nag_dialog.h @@ -26,10 +26,10 @@ class wxRichTextCtrl; class NagDialog : public wxDialog { public: - static void maybe_nag (wxWindow* parent, Config::Nag nag, wxString message); + static bool maybe_nag (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel = false); private: - NagDialog (wxWindow* parent, Config::Nag nag, wxString message); + NagDialog (wxWindow* parent, Config::Nag nag, wxString message, bool can_cancel); void shut_up (wxCommandEvent& ev); wxStaticText* _text; |
