summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-08-17 16:00:38 +0200
committerCarl Hetherington <cth@carlh.net>2022-08-17 16:00:38 +0200
commit6cf33e764f10f94efaf507f3c5ee53f9c04194ba (patch)
tree34df242aaecd6c7ef725cb6c78da74ed7b6d5ee5
parentbdf9625b0a7f210ff967c8bfe3ae3ee43a43c64a (diff)
Default to filtering DKDM filenames to only see *.xml, and allow
multiple DKDMs to be added at the same time (#2296).
-rw-r--r--src/tools/dcpomatic_kdm.cc72
1 files changed, 42 insertions, 30 deletions
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<DKDM>(ekdm);
- auto group = dynamic_pointer_cast<DKDMGroup> (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<DKDM>(ekdm);
+ auto group = dynamic_pointer_cast<DKDMGroup> (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 ();