X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fconfig_dialog.cc;h=8dd6cab68503a7cdd4d7e1781a89585e8b594300;hb=56209810c3a8510b5c0ad74dfc8ac5f5a69ea1ef;hp=63ce57823c59e792d34fdc1c03e83189d76aa0e9;hpb=6a11232620e0006f6a2b1e8d2b56e56d84229d5c;p=dcpomatic.git diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 63ce57823..8dd6cab68 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2017 Carl Hetherington This file is part of DCP-o-matic. @@ -33,6 +33,7 @@ #include "make_chain_dialog.h" #include "email_dialog.h" #include "name_format_editor.h" +#include "nag_dialog.h" #include "lib/config.h" #include "lib/ratio.h" #include "lib/filter.h" @@ -66,6 +67,13 @@ using boost::function; using boost::optional; using dcp::locale_convert; +static +void +do_nothing () +{ + +} + class Page { public: @@ -321,21 +329,25 @@ private: checked_set (_preview_sound, config->preview_sound()); optional const current_so = get_preview_sound_output (); - string configured_so; + optional configured_so; if (config->preview_sound_output()) { configured_so = config->preview_sound_output().get(); } else { /* No configured output means we should use the default */ RtAudio audio (DCPOMATIC_RTAUDIO_API); - configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; + try { + configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; + } catch (RtAudioError& e) { + /* Probably no audio devices at all */ + } } - if (!current_so || *current_so != configured_so) { + if (configured_so && current_so != configured_so) { /* Update _preview_sound_output with the configured value */ unsigned int i = 0; while (i < _preview_sound_output->GetCount()) { - if (_preview_sound_output->GetString(i) == std_to_wx(configured_so)) { + if (_preview_sound_output->GetString(i) == std_to_wx(*configured_so)) { _preview_sound_output->SetSelection (i); break; } @@ -515,6 +527,10 @@ private: _container = new wxChoice (_panel, wxID_ANY); table->Add (_container); + add_label_to_sizer (table, _panel, _("Default scale-to"), true); + _scale_to = new wxChoice (_panel, wxID_ANY); + table->Add (_scale_to); + add_label_to_sizer (table, _panel, _("Default content type"), true); _dcp_content_type = new wxChoice (_panel, wxID_ANY); table->Add (_dcp_content_type); @@ -561,16 +577,22 @@ private: _isdcf_metadata_button->Bind (wxEVT_BUTTON, boost::bind (&DefaultsPage::edit_isdcf_metadata_clicked, this)); - vector ratios = Ratio::all (); - for (size_t i = 0; i < ratios.size(); ++i) { - _container->Append (std_to_wx (ratios[i]->nickname ())); + BOOST_FOREACH (Ratio const * i, Ratio::containers()) { + _container->Append (std_to_wx(i->container_nickname())); } _container->Bind (wxEVT_CHOICE, boost::bind (&DefaultsPage::container_changed, this)); - vector const ct = DCPContentType::all (); - for (size_t i = 0; i < ct.size(); ++i) { - _dcp_content_type->Append (std_to_wx (ct[i]->pretty_name ())); + _scale_to->Append (_("Guess from content")); + + BOOST_FOREACH (Ratio const * i, Ratio::all()) { + _scale_to->Append (std_to_wx(i->image_nickname())); + } + + _scale_to->Bind (wxEVT_CHOICE, boost::bind (&DefaultsPage::scale_to_changed, this)); + + BOOST_FOREACH (DCPContentType const * i, DCPContentType::all()) { + _dcp_content_type->Append (std_to_wx (i->pretty_name ())); } setup_audio_channels_choice (_dcp_audio_channels, 2); @@ -598,6 +620,13 @@ private: if (ratios[i] == config->default_container ()) { _container->SetSelection (i); } + if (ratios[i] == config->default_scale_to ()) { + _scale_to->SetSelection (i + 1); + } + } + + if (!config->default_scale_to()) { + _scale_to->SetSelection (0); } vector const ct = DCPContentType::all (); @@ -666,6 +695,17 @@ private: Config::instance()->set_default_container (ratio[_container->GetSelection()]); } + void scale_to_changed () + { + int const s = _scale_to->GetSelection (); + if (s == 0) { + Config::instance()->set_default_scale_to (0); + } else { + vector ratio = Ratio::all (); + Config::instance()->set_default_scale_to (ratio[s - 1]); + } + } + void dcp_content_type_changed () { vector ct = DCPContentType::all (); @@ -689,6 +729,7 @@ private: wxDirPickerCtrl* _kdm_directory; #endif wxChoice* _container; + wxChoice* _scale_to; wxChoice* _dcp_content_type; wxChoice* _dcp_audio_channels; wxChoice* _standard; @@ -762,11 +803,13 @@ public: wxString title, int border, function)> set, - function (void)> get + function (void)> get, + function nag_remake ) : wxPanel (parent) , _set (set) , _get (get) + , _nag_remake (nag_remake) { wxFont subheading_font (*wxNORMAL_FONT); subheading_font.SetWeight (wxFONTWEIGHT_BOLD); @@ -840,6 +883,13 @@ public: table->Add (_button_sizer, wxGBPosition (r, 0), wxGBSpan (1, 4)); ++r; + _private_key_bad = new wxStaticText (this, wxID_ANY, _("Leaf private key does not match leaf certificate!")); + font = *wxSMALL_FONT; + font.SetWeight (wxFONTWEIGHT_BOLD); + _private_key_bad->SetFont (font); + table->Add (_private_key_bad, wxGBPosition (r, 0), wxGBSpan (1, 3)); + ++r; + _add_certificate->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::add_certificate, this)); _remove_certificate->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::remove_certificate, this)); _export_certificate->Bind (wxEVT_BUTTON, boost::bind (&CertificateChainEditor::export_certificate, this)); @@ -875,7 +925,15 @@ private: if (d->ShowModal() == wxID_OK) { try { dcp::Certificate c; - string const extra = c.read_string (dcp::file_to_string (wx_to_std (d->GetPath ()))); + string extra; + try { + extra = c.read_string (dcp::file_to_string (wx_to_std (d->GetPath ()))); + } catch (boost::filesystem::filesystem_error& e) { + error_dialog (this, wxString::Format (_("Could not load certificate (%s)"), d->GetPath().data())); + d->Destroy (); + return; + } + if (!extra.empty ()) { message_dialog ( this, @@ -884,8 +942,17 @@ private: ); } _chain->add (c); - _set (_chain); - update_certificate_list (); + if (!_chain->chain_valid ()) { + error_dialog ( + this, + _("Adding this certificate would make the chain inconsistent, so it will not be added. " + "Add certificates in order from root to intermediate to leaf.") + ); + _chain->remove (c); + } else { + _set (_chain); + update_certificate_list (); + } } catch (dcp::MiscError& e) { error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), e.what ())); } @@ -962,6 +1029,16 @@ private: ++n; } + + static wxColour normal = _private_key_bad->GetForegroundColour (); + + if (_chain->private_key_valid ()) { + _private_key_bad->Hide (); + _private_key_bad->SetForegroundColour (normal); + } else { + _private_key_bad->Show (); + _private_key_bad->SetForegroundColour (wxColour (255, 0, 0)); + } } void remake_certificates () @@ -995,6 +1072,8 @@ private: intermediate_common_name = i->subject_common_name (); } + _nag_remake (); + MakeChainDialog* d = new MakeChainDialog ( this, subject_organization_name, @@ -1026,7 +1105,8 @@ private: void update_sensitivity () { - _remove_certificate->Enable (_certificates->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1); + /* We can only remove the leaf certificate */ + _remove_certificate->Enable (_certificates->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) == (_certificates->GetItemCount() - 1)); _export_certificate->Enable (_certificates->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1); } @@ -1097,11 +1177,13 @@ private: wxStaticText* _private_key; wxButton* _load_private_key; wxButton* _export_private_key; + wxStaticText* _private_key_bad; wxSizer* _sizer; wxBoxSizer* _button_sizer; shared_ptr _chain; boost::function)> _set; boost::function (void)> _get; + boost::function _nag_remake; }; class KeysPage : public StandardPage @@ -1130,22 +1212,24 @@ private: _signer = new CertificateChainEditor ( _panel, _("Signing DCPs and KDMs"), _border, boost::bind (&Config::set_signer_chain, Config::instance (), _1), - boost::bind (&Config::signer_chain, Config::instance ()) + boost::bind (&Config::signer_chain, Config::instance ()), + boost::bind (&do_nothing) ); _panel->GetSizer()->Add (_signer); _decryption = new CertificateChainEditor ( - _panel, _("Decrypting DCPs"), _border, + _panel, _("Decrypting KDMs"), _border, boost::bind (&Config::set_decryption_chain, Config::instance (), _1), - boost::bind (&Config::decryption_chain, Config::instance ()) + boost::bind (&Config::decryption_chain, Config::instance ()), + boost::bind (&KeysPage::nag_remake_decryption_chain, this) ); _panel->GetSizer()->Add (_decryption); - _export_decryption_certificate = new wxButton (_decryption, wxID_ANY, _("Export DCP decryption\ncertificate...")); + _export_decryption_certificate = new wxButton (_decryption, wxID_ANY, _("Export KDM decryption\ncertificate...")); _decryption->add_button (_export_decryption_certificate); - _export_decryption_chain = new wxButton (_decryption, wxID_ANY, _("Export DCP decryption\nchain...")); + _export_decryption_chain = new wxButton (_decryption, wxID_ANY, _("Export KDM decryption\nchain...")); _decryption->add_button (_export_decryption_chain); _export_decryption_certificate->Bind (wxEVT_BUTTON, boost::bind (&KeysPage::export_decryption_certificate, this)); @@ -1198,6 +1282,15 @@ private: _decryption->config_changed (); } + void nag_remake_decryption_chain () + { + 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!") + ); + } + CertificateChainEditor* _signer; CertificateChainEditor* _decryption; wxButton* _export_decryption_certificate;