summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-03 21:17:25 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-04 10:25:10 +0100
commit5fd2715af0b316d5ad0c3b08812f24af869f9fcc (patch)
treea0b6b4ce2596d16746730856681eef9776bee80c
parent464daaf1bc9f8a9819a91315f0e3567e14bb7365 (diff)
Extract add_dkdm().
-rw-r--r--src/tools/dcpomatic_kdm.cc66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc
index b9cdc0b35..90e315aab 100644
--- a/src/tools/dcpomatic_kdm.cc
+++ b/src/tools/dcpomatic_kdm.cc
@@ -498,41 +498,47 @@ private:
return;
}
+ for (auto path: dialog->paths()) {
+ add_dkdm(path);
+ }
+ }
+
+ void add_dkdm(boost::filesystem::path path)
+ {
auto chain = Config::instance()->decryption_chain();
DCPOMATIC_ASSERT (chain->key());
- for (auto path: dialog->paths()) {
- try {
- dcp::EncryptedKDM ekdm(dcp::file_to_string(path, 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(new_dkdm, group);
- } 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())
- );
+ try {
+ dcp::EncryptedKDM ekdm(dcp::file_to_string(path, 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(new_dkdm, group);
+ } 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())
+ );
}
+
update_dkdm_view();
}