From: Carl Hetherington Date: Wed, 17 Aug 2022 14:00:38 +0000 (+0200) Subject: Default to filtering DKDM filenames to only see *.xml, and allow X-Git-Tag: v2.16.22~17 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=6cf33e764f10f94efaf507f3c5ee53f9c04194ba Default to filtering DKDM filenames to only see *.xml, and allow multiple DKDMs to be added at the same time (#2296). --- diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 7a8d7cf34..30f2e0b82 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -448,41 +448,53 @@ private: void add_dkdm_clicked () { - auto d = new wxFileDialog (this, _("Select DKDM file")); + auto d = new wxFileDialog( + this, + _("Select DKDM file"), + wxEmptyString, + wxEmptyString, + wxT("XML files|*.xml|All files|*.*"), + wxFD_MULTIPLE + ); + if (d->ShowModal() == wxID_OK) { auto chain = Config::instance()->decryption_chain(); DCPOMATIC_ASSERT (chain->key()); - try { - dcp::EncryptedKDM ekdm(dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)); - /* Decrypt the DKDM to make sure that we can */ - dcp::DecryptedKDM dkdm(ekdm, chain->key().get()); - - auto new_dkdm = make_shared(ekdm); - auto group = dynamic_pointer_cast (selected_dkdm()); - if (!group) { - group = Config::instance()->dkdms (); + wxArrayString paths; + d->GetPaths(paths); + for (unsigned int i = 0; i < paths.GetCount(); ++i) { + try { + dcp::EncryptedKDM ekdm(dcp::file_to_string(wx_to_std(paths[i]), MAX_KDM_SIZE)); + /* Decrypt the DKDM to make sure that we can */ + dcp::DecryptedKDM dkdm(ekdm, chain->key().get()); + + auto new_dkdm = make_shared(ekdm); + auto group = dynamic_pointer_cast (selected_dkdm()); + if (!group) { + group = Config::instance()->dkdms (); + } + add_dkdm_model (new_dkdm, group); + add_dkdm_view (new_dkdm); + } catch (dcp::KDMFormatError& e) { + error_dialog ( + this, + _("Could not read file as a KDM. Perhaps it is badly formatted, or not a KDM at all."), + std_to_wx(e.what()) + ); + return; + } catch (dcp::KDMDecryptionError &) { + error_dialog ( + this, + _("Could not decrypt the DKDM. Perhaps it was not created with the correct certificate.") + ); + } catch (dcp::MiscError& e) { + error_dialog ( + this, + _("Could not read file as a KDM. It is much too large. Make sure you are loading a DKDM (XML) file."), + std_to_wx(e.what()) + ); } - add_dkdm_model (new_dkdm, group); - add_dkdm_view (new_dkdm); - } catch (dcp::KDMFormatError& e) { - error_dialog ( - this, - _("Could not read file as a KDM. Perhaps it is badly formatted, or not a KDM at all."), - std_to_wx(e.what()) - ); - return; - } catch (dcp::KDMDecryptionError &) { - error_dialog ( - this, - _("Could not decrypt the DKDM. Perhaps it was not created with the correct certificate.") - ); - } catch (dcp::MiscError& e) { - error_dialog ( - this, - _("Could not read file as a KDM. It is much too large. Make sure you are loading a DKDM (XML) file."), - std_to_wx(e.what()) - ); } } d->Destroy ();