From: Carl Hetherington Date: Tue, 3 Jan 2023 20:17:25 +0000 (+0100) Subject: Extract add_dkdm(). X-Git-Tag: v2.16.39~2 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=5fd2715af0b316d5ad0c3b08812f24af869f9fcc Extract add_dkdm(). --- 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(ekdm); - auto group = dynamic_pointer_cast (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(ekdm); + auto group = dynamic_pointer_cast (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(); }