summaryrefslogtreecommitdiff
path: root/src/wx/config_dialog.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-02 11:59:58 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-02 19:22:59 +0100
commite4537bfa1592674bc4838e4b9b2a72f0adeecc99 (patch)
tree0843f4a71e6ddeb62e2c921a11c71baf141de043 /src/wx/config_dialog.cc
parent16f0bebe211e18ed35b5bd32fd6dcfb915f5e02a (diff)
Move Keys preferences to its own file.
Diffstat (limited to 'src/wx/config_dialog.cc')
-rw-r--r--src/wx/config_dialog.cc222
1 files changed, 0 insertions, 222 deletions
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index 6b5669722..a011dbe15 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -53,13 +53,6 @@ using namespace boost::placeholders;
using namespace dcpomatic::preferences;
-static
-bool
-do_nothing()
-{
- return false;
-}
-
Page::Page(wxSize panel_size, int border)
: _border(border)
, _panel(nullptr)
@@ -333,221 +326,6 @@ GeneralPage::check_for_test_updates_changed()
Config::instance()->set_check_for_test_updates(_check_for_test_updates->GetValue());
}
-wxString
-KeysPage::GetName() const
-{
- return _("Keys");
-}
-
-void
-KeysPage::setup()
-{
- wxFont subheading_font(*wxNORMAL_FONT);
- subheading_font.SetWeight(wxFONTWEIGHT_BOLD);
-
- auto sizer = _panel->GetSizer();
-
- {
- auto m = new StaticText(_panel, _("Decrypting KDMs"));
- m->SetFont(subheading_font);
- sizer->Add(m, 0, wxALL | wxEXPAND, _border);
- }
-
- auto kdm_buttons = new wxBoxSizer(wxVERTICAL);
-
- auto export_decryption_certificate = new Button(_panel, _("Export KDM decryption leaf certificate..."));
- kdm_buttons->Add(export_decryption_certificate, 0, wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
- auto export_settings = new Button(_panel, _("Export all KDM decryption settings..."));
- kdm_buttons->Add(export_settings, 0, wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
- auto import_settings = new Button(_panel, _("Import all KDM decryption settings..."));
- kdm_buttons->Add(import_settings, 0, wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
- auto decryption_advanced = new Button(_panel, _("Advanced..."));
- kdm_buttons->Add(decryption_advanced, 0);
-
- sizer->Add(kdm_buttons, 0, wxLEFT, _border);
-
- export_decryption_certificate->Bind(wxEVT_BUTTON, bind(&KeysPage::export_decryption_certificate, 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));
-
- {
- auto m = new StaticText(_panel, _("Signing DCPs and KDMs"));
- m->SetFont(subheading_font);
- sizer->Add(m, 0, wxALL | wxEXPAND, _border);
- }
-
- auto signing_buttons = new wxBoxSizer(wxVERTICAL);
-
- auto signing_advanced = new Button(_panel, _("Advanced..."));
- signing_buttons->Add(signing_advanced, 0, wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
- auto remake_signing = new Button(_panel, _("Re-make certificates and key..."));
- signing_buttons->Add(remake_signing, 0, wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-
- sizer->Add(signing_buttons, 0, wxLEFT, _border);
-
- signing_advanced->Bind(wxEVT_BUTTON, bind(&KeysPage::signing_advanced, this));
- remake_signing->Bind(wxEVT_BUTTON, bind(&KeysPage::remake_signing, this));
-}
-
-
-void
-KeysPage::remake_signing()
-{
- MakeChainDialog dialog(_panel, Config::instance()->signer_chain());
-
- if (dialog.ShowModal() == wxID_OK) {
- Config::instance()->set_signer_chain(dialog.get());
- }
-}
-
-
-void
-KeysPage::decryption_advanced()
-{
- CertificateChainEditor editor(
- _panel, _("Decrypting KDMs"), _border,
- bind(&Config::set_decryption_chain, Config::instance(), _1),
- bind(&Config::decryption_chain, Config::instance()),
- bind(&KeysPage::nag_alter_decryption_chain, this)
- );
-
- editor.ShowModal();
-}
-
-void
-KeysPage::signing_advanced()
-{
- CertificateChainEditor editor(
- _panel, _("Signing DCPs and KDMs"), _border,
- bind(&Config::set_signer_chain, Config::instance(), _1),
- bind(&Config::signer_chain, Config::instance()),
- bind(&do_nothing)
- );
-
- editor.ShowModal();
-}
-
-void
-KeysPage::export_decryption_chain_and_key()
-{
- wxFileDialog dialog(
- _panel, _("Select Export File"), wxEmptyString, wxEmptyString, char_to_wx("DOM files (*.dom)|*.dom"),
- wxFD_SAVE | wxFD_OVERWRITE_PROMPT
- );
-
- if (dialog.ShowModal() != wxID_OK) {
- return;
- }
-
- boost::filesystem::path path(wx_to_std(dialog.GetPath()));
- dcp::File f(path, "w");
- if (!f) {
- throw OpenFileError(path, f.open_error(), OpenFileError::WRITE);
- }
-
- auto const chain = Config::instance()->decryption_chain()->chain();
- f.checked_write(chain.c_str(), chain.length());
- auto const key = Config::instance()->decryption_chain()->key();
- DCPOMATIC_ASSERT(key);
- f.checked_write(key->c_str(), key->length());
-}
-
-void
-KeysPage::import_decryption_chain_and_key()
-{
- if (NagDialog::maybe_nag(
- _panel,
- Config::NAG_IMPORT_DECRYPTION_CHAIN,
- _("If you continue with this operation you will no longer be able to use any DKDMs that you have created with the current certificates and key. Also, any KDMs that have been sent to you for those certificates will become useless. Proceed with caution!"),
- true
- )) {
- return;
- }
-
- wxFileDialog dialog(
- _panel, _("Select File To Import"), wxEmptyString, wxEmptyString, char_to_wx("DOM files (*.dom)|*.dom")
- );
-
- if (dialog.ShowModal() != wxID_OK) {
- return;
- }
-
- auto new_chain = make_shared<dcp::CertificateChain>();
-
- dcp::File f(wx_to_std(dialog.GetPath()), "r");
- if (!f) {
- throw OpenFileError(f.path(), f.open_error(), OpenFileError::WRITE);
- }
-
- string current;
- while (!f.eof()) {
- char buffer[128];
- if (f.gets(buffer, 128) == 0) {
- break;
- }
- current += buffer;
- if (strncmp (buffer, "-----END CERTIFICATE-----", 25) == 0) {
- new_chain->add(dcp::Certificate(current));
- current = "";
- } else if (strncmp(buffer, "-----END RSA PRIVATE KEY-----", 29) == 0) {
- new_chain->set_key(current);
- current = "";
- }
- }
-
- if (new_chain->chain_valid() && new_chain->private_key_valid()) {
- Config::instance()->set_decryption_chain(new_chain);
- } else {
- error_dialog(_panel, variant::wx::insert_dcpomatic(_("Invalid %s export file")));
- }
-}
-
-bool
-KeysPage::nag_alter_decryption_chain()
-{
- return NagDialog::maybe_nag(
- _panel,
- 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
- );
-}
-
-void
-KeysPage::export_decryption_certificate()
-{
- auto config = Config::instance();
- wxString default_name = char_to_wx("dcpomatic");
- if (!config->dcp_creator().empty()) {
- default_name += char_to_wx("_") + std_to_wx(careful_string_filter(config->dcp_creator()));
- }
- if (!config->dcp_issuer().empty()) {
- default_name += char_to_wx("_") + std_to_wx(careful_string_filter(config->dcp_issuer()));
- }
- default_name += char_to_wx("_kdm_decryption_cert.pem");
-
- wxFileDialog dialog(
- _panel, _("Select Certificate File"), wxEmptyString, default_name, char_to_wx("PEM files (*.pem)|*.pem"),
- wxFD_SAVE | wxFD_OVERWRITE_PROMPT
- );
-
- if (dialog.ShowModal() != wxID_OK) {
- return;
- }
-
- boost::filesystem::path path(wx_to_std(dialog.GetPath()));
- if (path.extension() != ".pem") {
- path += ".pem";
- }
- dcp::File f(path, "w");
- if (!f) {
- throw OpenFileError(path, f.open_error(), OpenFileError::WRITE);
- }
-
- auto const s = Config::instance()->decryption_chain()->leaf().certificate(true);
- f.checked_write(s.c_str(), s.length());
-}
wxString
SoundPage::GetName() const