X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_kdm.cc;h=30f2e0b827f9b3b999a5897c66b9fe76d7a2aee0;hb=6cf33e764f10f94efaf507f3c5ee53f9c04194ba;hp=965ba7a0f781295119a726bbaa9d9524aa3d2eec;hpb=1ac377eb46e4497d6f547f6d498d8c867343b331;p=dcpomatic.git diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 965ba7a0f..30f2e0b82 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -22,7 +22,6 @@ #include "wx/about_dialog.h" #include "wx/dcpomatic_button.h" #include "wx/editable_list.h" -#include "wx/file_dialog_wrapper.h" #include "wx/file_picker_ctrl.h" #include "wx/full_config_dialog.h" #include "wx/job_view_dialog.h" @@ -39,8 +38,10 @@ #include "lib/compose.hpp" #include "lib/config.h" #include "lib/cross.h" +#include "lib/dcpomatic_log.h" #include "lib/dkdm_wrapper.h" #include "lib/exceptions.h" +#include "lib/file_log.h" #include "lib/job_manager.h" #include "lib/kdm_with_metadata.h" #include "lib/screen.h" @@ -49,13 +50,14 @@ #include #include #include -#include "lib/warnings.h" -DCPOMATIC_DISABLE_WARNINGS -#include +#include +LIBDCP_DISABLE_WARNINGS +#include #include #include -#include -DCPOMATIC_ENABLE_WARNINGS +#include +#include +LIBDCP_ENABLE_WARNINGS #ifdef __WXOSX__ #include #endif @@ -180,8 +182,7 @@ public: h = new StaticText (overall_panel, _("Output")); h->SetFont (subheading_font); right->Add (h, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP * 2); - /* XXX: hard-coded non-interop here */ - _output = new KDMOutputPanel (overall_panel, false); + _output = new KDMOutputPanel (overall_panel); right->Add (_output, 0, wxALL, DCPOMATIC_SIZER_Y_GAP); _create = new Button (overall_panel, _("Create KDMs")); @@ -204,6 +205,8 @@ public: _export_dkdm->Bind (wxEVT_BUTTON, bind (&DOMFrame::export_dkdm_clicked, this)); setup_sensitivity (); + + dcpomatic_log = make_shared(State::write_path("kdm.log")); } private: @@ -339,7 +342,7 @@ private: begin, end, decrypted.annotation_text().get_value_or (""), - decrypted.content_title_text(), + title, dcp::LocalTime().as_string() ); @@ -445,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 (); @@ -621,7 +636,7 @@ public: private: - bool OnInit () + bool OnInit () override { wxSplashScreen* splash = nullptr; @@ -691,7 +706,7 @@ private: } /* An unhandled exception has occurred inside the main event loop */ - bool OnExceptionInMainLoop () + bool OnExceptionInMainLoop () override { try { throw; @@ -720,7 +735,7 @@ private: return false; } - void OnUnhandledException () + void OnUnhandledException () override { error_dialog (nullptr, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); }