2 Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "wx/about_dialog.h"
23 #include "wx/dcpomatic_button.h"
24 #include "wx/editable_list.h"
25 #include "wx/file_picker_ctrl.h"
26 #include "wx/full_config_dialog.h"
27 #include "wx/job_view_dialog.h"
28 #include "wx/kdm_output_panel.h"
29 #include "wx/kdm_timing_panel.h"
30 #include "wx/nag_dialog.h"
31 #include "wx/new_dkdm_folder_dialog.h"
32 #include "wx/report_problem_dialog.h"
33 #include "wx/screens_panel.h"
34 #include "wx/static_text.h"
35 #include "wx/wx_signal_manager.h"
36 #include "wx/wx_util.h"
37 #include "lib/cinema.h"
38 #include "lib/collator.h"
39 #include "lib/compose.hpp"
40 #include "lib/constants.h"
41 #include "lib/config.h"
42 #include "lib/cross.h"
43 #include "lib/dcpomatic_log.h"
44 #include "lib/dkdm_wrapper.h"
45 #include "lib/exceptions.h"
46 #include "lib/file_log.h"
47 #include "lib/job_manager.h"
48 #include "lib/kdm_with_metadata.h"
49 #include "lib/screen.h"
50 #include "lib/send_kdm_email_job.h"
51 #include <dcp/encrypted_kdm.h>
52 #include <dcp/decrypted_kdm.h>
53 #include <dcp/exceptions.h>
54 #include <dcp/warnings.h>
55 LIBDCP_DISABLE_WARNINGS
56 #include <wx/filepicker.h>
57 #include <wx/preferences.h>
58 #include <wx/splash.h>
59 #include <wx/srchctrl.h>
60 #include <wx/treectrl.h>
62 LIBDCP_ENABLE_WARNINGS
64 #include <ApplicationServices/ApplicationServices.h>
66 #include <boost/bind/bind.hpp>
67 #include <unordered_set>
76 using std::make_shared;
79 using std::shared_ptr;
81 using std::unordered_set;
84 using boost::optional;
86 using std::dynamic_pointer_cast;
87 #if BOOST_VERSION >= 106100
88 using namespace boost::placeholders;
90 using namespace dcpomatic;
94 ID_help_report_a_problem = 1,
98 class DOMFrame : public wxFrame
101 explicit DOMFrame (wxString const & title)
102 : wxFrame (nullptr, -1, title)
103 , _config_dialog (nullptr)
104 , _job_view (nullptr)
106 #if defined(DCPOMATIC_WINDOWS)
107 if (Config::instance()->win32_console ()) {
110 HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
111 int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
112 FILE* hf_out = _fdopen(hCrt, "w");
113 setvbuf(hf_out, NULL, _IONBF, 1);
116 HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
117 hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
118 FILE* hf_in = _fdopen(hCrt, "r");
119 setvbuf(hf_in, NULL, _IONBF, 128);
122 std::cout << "DCP-o-matic KDM creator is starting." << "\n";
126 auto bar = new wxMenuBar;
130 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
131 Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
132 Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
133 Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_report_a_problem, this), ID_help_report_a_problem);
135 /* Use a panel as the only child of the Frame so that we avoid
136 the dark-grey background on Windows.
138 auto overall_panel = new wxPanel (this, wxID_ANY);
139 auto main_sizer = new wxBoxSizer (wxHORIZONTAL);
141 auto horizontal = new wxBoxSizer (wxHORIZONTAL);
142 auto left = new wxBoxSizer (wxVERTICAL);
143 auto right = new wxBoxSizer (wxVERTICAL);
145 horizontal->Add (left, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP * 2);
146 horizontal->Add (right, 1, wxEXPAND);
148 wxFont subheading_font (*wxNORMAL_FONT);
149 subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
151 auto h = new StaticText (overall_panel, _("Screens"));
152 h->SetFont (subheading_font);
153 left->Add (h, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
154 _screens = new ScreensPanel (overall_panel);
155 left->Add (_screens, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
157 /// TRANSLATORS: translate the word "Timing" here; do not include the "KDM|" prefix
158 h = new StaticText (overall_panel, S_("KDM|Timing"));
159 h->SetFont (subheading_font);
161 _timing = new KDMTimingPanel (overall_panel);
162 right->Add (_timing, 0, wxALL, DCPOMATIC_SIZER_Y_GAP);
164 h = new StaticText (overall_panel, _("DKDM"));
165 h->SetFont (subheading_font);
166 right->Add (h, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
168 _dkdm_search = new wxSearchCtrl(overall_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, search_ctrl_height()));
170 /* The cancel button seems to be strangely broken in GTK3; clicking on it twice sometimes works */
171 _dkdm_search->ShowCancelButton (true);
174 right->Add(_dkdm_search, 0, wxTOP | wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
176 auto dkdm_sizer = new wxBoxSizer (wxHORIZONTAL);
177 _dkdm = new wxTreeCtrl (
178 overall_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT
180 dkdm_sizer->Add(_dkdm, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
181 wxBoxSizer* dkdm_buttons = new wxBoxSizer(wxVERTICAL);
182 _add_dkdm = new Button (overall_panel, _("Add..."));
183 dkdm_buttons->Add (_add_dkdm, 0, wxALL | wxEXPAND, DCPOMATIC_BUTTON_STACK_GAP);
184 _add_dkdm_folder = new Button (overall_panel, _("Add folder..."));
185 dkdm_buttons->Add (_add_dkdm_folder, 0, wxALL | wxEXPAND, DCPOMATIC_BUTTON_STACK_GAP);
186 _remove_dkdm = new Button (overall_panel, _("Remove"));
187 dkdm_buttons->Add (_remove_dkdm, 0, wxALL | wxEXPAND, DCPOMATIC_BUTTON_STACK_GAP);
188 _export_dkdm = new Button (overall_panel, _("Export..."));
189 dkdm_buttons->Add (_export_dkdm, 0, wxALL | wxEXPAND, DCPOMATIC_BUTTON_STACK_GAP);
190 dkdm_sizer->Add (dkdm_buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
191 right->Add (dkdm_sizer, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
195 h = new StaticText (overall_panel, _("Output"));
196 h->SetFont (subheading_font);
197 right->Add (h, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
198 _output = new KDMOutputPanel (overall_panel);
199 right->Add (_output, 0, wxALL, DCPOMATIC_SIZER_Y_GAP);
201 _create = new Button (overall_panel, _("Create KDMs"));
202 right->Add (_create, 0, wxALL, DCPOMATIC_SIZER_GAP);
204 main_sizer->Add (horizontal, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
205 overall_panel->SetSizer (main_sizer);
207 /* Instantly save any config changes when using a DCP-o-matic GUI */
208 Config::instance()->Changed.connect (boost::bind (&Config::write, Config::instance ()));
210 _screens->ScreensChanged.connect (boost::bind (&DOMFrame::setup_sensitivity, this));
211 _create->Bind (wxEVT_BUTTON, bind (&DOMFrame::create_kdms, this));
212 _dkdm->Bind(wxEVT_TREE_SEL_CHANGED, boost::bind(&DOMFrame::dkdm_selection_changed, this));
213 _dkdm->Bind (wxEVT_TREE_BEGIN_DRAG, boost::bind (&DOMFrame::dkdm_begin_drag, this, _1));
214 _dkdm->Bind (wxEVT_TREE_END_DRAG, boost::bind (&DOMFrame::dkdm_end_drag, this, _1));
215 _dkdm->Bind(wxEVT_TREE_ITEM_EXPANDED, boost::bind(&DOMFrame::dkdm_expanded, this, _1));
216 _dkdm->Bind(wxEVT_TREE_ITEM_COLLAPSED, boost::bind(&DOMFrame::dkdm_collapsed, this, _1));
217 _add_dkdm->Bind (wxEVT_BUTTON, bind (&DOMFrame::add_dkdm_clicked, this));
218 _add_dkdm_folder->Bind (wxEVT_BUTTON, bind (&DOMFrame::add_dkdm_folder_clicked, this));
219 _remove_dkdm->Bind (wxEVT_BUTTON, bind (&DOMFrame::remove_dkdm_clicked, this));
220 _export_dkdm->Bind (wxEVT_BUTTON, bind (&DOMFrame::export_dkdm_clicked, this));
221 _dkdm_search->Bind(wxEVT_TEXT, boost::bind(&DOMFrame::dkdm_search_changed, this));
223 setup_sensitivity ();
225 dcpomatic_log = make_shared<FileLog>(State::write_path("kdm.log"));
231 /* false here allows the close handler to veto the close request */
235 void edit_preferences ()
237 if (!_config_dialog) {
238 _config_dialog = create_full_config_dialog ();
240 _config_dialog->Show (this);
245 auto d = new AboutDialog (this);
250 void help_report_a_problem ()
252 auto d = new ReportProblemDialog (this, shared_ptr<Film>());
253 if (d->ShowModal () == wxID_OK) {
259 void setup_menu (wxMenuBar* m)
261 auto file = new wxMenu;
264 file->Append (wxID_EXIT, _("&Exit"));
266 file->Append (wxID_EXIT, _("&Quit"));
270 file->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
272 wxMenu* edit = new wxMenu;
273 edit->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
276 wxMenu* help = new wxMenu;
278 help->Append (wxID_ABOUT, _("About DCP-o-matic"));
280 help->Append (wxID_ABOUT, _("About"));
282 help->Append (ID_help_report_a_problem, _("Report a problem..."));
284 m->Append (file, _("&File"));
286 m->Append (edit, _("&Edit"));
288 m->Append (help, _("&Help"));
291 bool confirm_overwrite (boost::filesystem::path path)
293 return confirm_dialog (
295 wxString::Format (_("File %s already exists. Do you want to overwrite it?"), std_to_wx(path.string()).data())
299 /** @id if not nullptr this is filled in with the wxTreeItemId of the selection */
300 shared_ptr<DKDMBase> selected_dkdm (wxTreeItemId* id = nullptr) const
302 wxArrayTreeItemIds selections;
303 _dkdm->GetSelections (selections);
304 if (selections.GetCount() != 1) {
315 auto i = _dkdm_id.find (selections[0]);
316 if (i == _dkdm_id.end()) {
326 auto dkdm_base = selected_dkdm ();
331 list<KDMWithMetadataPtr> kdms;
334 auto dkdm = std::dynamic_pointer_cast<DKDM>(dkdm_base);
337 /* Decrypt the DKDM */
338 dcp::DecryptedKDM decrypted (dkdm->dkdm(), Config::instance()->decryption_chain()->key().get());
339 title = decrypted.content_title_text ();
341 /* This is the signer for our new KDMs */
342 auto signer = Config::instance()->signer_chain ();
343 if (!signer->valid ()) {
344 throw InvalidSignerError ();
347 for (auto i: _screens->screens()) {
353 dcp::LocalTime begin(_timing->from(), dcp::UTCOffset(i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()));
354 dcp::LocalTime end(_timing->until(), dcp::UTCOffset(i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute()));
356 /* Make an empty KDM */
357 dcp::DecryptedKDM kdm (
360 decrypted.annotation_text().get_value_or (""),
362 dcp::LocalTime().as_string()
365 /* Add keys from the DKDM */
366 for (auto const& j: decrypted.keys()) {
370 auto const encrypted = kdm.encrypt(
371 signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(),
372 !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional<int>() : 0
375 dcp::NameFormat::Map name_values;
376 name_values['c'] = i->cinema->name;
377 name_values['s'] = i->name;
378 name_values['f'] = title;
379 name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
380 name_values['e'] = end.date() + " " + end.time_of_day(true, false);
381 name_values['i'] = encrypted.cpl_id ();
384 kdms.push_back (make_shared<KDMWithMetadata>(name_values, i->cinema.get(), i->cinema->emails, encrypted));
392 auto result = _output->make (
393 kdms, title, bind (&DOMFrame::confirm_overwrite, this, _1)
397 JobManager::instance()->add (result.first);
399 _job_view->Destroy ();
402 _job_view = new JobViewDialog (this, _("Send KDM emails"), result.first);
403 _job_view->ShowModal ();
406 if (result.second > 0) {
407 /* XXX: proper plural form support in wxWidgets? */
408 wxString s = result.second == 1 ? _("%d KDM written to %s") : _("%d KDMs written to %s");
411 wxString::Format (s, result.second, std_to_wx(_output->directory().string()).data())
414 } catch (dcp::NotEncryptedError& e) {
415 error_dialog (this, _("CPL's content is not encrypted."));
416 } catch (exception& e) {
417 error_dialog (this, std_to_wx(e.what()));
419 error_dialog (this, _("An unknown exception occurred."));
423 void setup_sensitivity ()
425 _screens->setup_sensitivity ();
426 _output->setup_sensitivity ();
427 wxArrayTreeItemIds sel;
428 _dkdm->GetSelections (sel);
429 auto group = dynamic_pointer_cast<DKDMGroup>(selected_dkdm());
430 auto dkdm = dynamic_pointer_cast<DKDM>(selected_dkdm());
431 _create->Enable (!_screens->screens().empty() && sel.GetCount() > 0 && dkdm);
432 _remove_dkdm->Enable (sel.GetCount() > 0 && (!group || group->name() != "root"));
433 _export_dkdm->Enable (sel.GetCount() > 0 && dkdm);
436 void dkdm_selection_changed()
438 _selected_dkdm = selected_dkdm();
442 void dkdm_expanded(wxTreeEvent& ev)
444 if (_ignore_expand) {
448 auto iter = _dkdm_id.find(ev.GetItem());
449 if (iter != _dkdm_id.end()) {
450 _expanded_dkdm_groups.insert(iter->second);
454 void dkdm_collapsed(wxTreeEvent& ev)
456 auto iter = _dkdm_id.find(ev.GetItem());
457 if (iter != _dkdm_id.end()) {
458 _expanded_dkdm_groups.erase(iter->second);
462 void dkdm_begin_drag (wxTreeEvent& ev)
467 void dkdm_end_drag (wxTreeEvent& ev)
469 auto from = _dkdm_id.find (_dkdm->GetSelection ());
470 auto to = _dkdm_id.find (ev.GetItem ());
471 if (from == _dkdm_id.end() || to == _dkdm_id.end() || from->first == to->first) {
475 auto group = dynamic_pointer_cast<DKDMGroup> (to->second);
477 group = to->second->parent();
480 DCPOMATIC_ASSERT (group);
481 DCPOMATIC_ASSERT (from->second->parent ());
483 from->second->parent()->remove (from->second);
484 add_dkdm(from->second, group, dynamic_pointer_cast<DKDM>(to->second));
489 void add_dkdm_clicked ()
491 auto d = new wxFileDialog(
493 _("Select DKDM file"),
496 wxT("XML files|*.xml|All files|*.*"),
500 if (d->ShowModal() == wxID_OK) {
501 auto chain = Config::instance()->decryption_chain();
502 DCPOMATIC_ASSERT (chain->key());
506 for (unsigned int i = 0; i < paths.GetCount(); ++i) {
508 dcp::EncryptedKDM ekdm(dcp::file_to_string(wx_to_std(paths[i]), MAX_KDM_SIZE));
509 /* Decrypt the DKDM to make sure that we can */
510 dcp::DecryptedKDM dkdm(ekdm, chain->key().get());
512 auto new_dkdm = make_shared<DKDM>(ekdm);
513 auto group = dynamic_pointer_cast<DKDMGroup> (selected_dkdm());
515 group = Config::instance()->dkdms ();
517 add_dkdm(new_dkdm, group);
518 } catch (dcp::KDMFormatError& e) {
521 _("Could not read file as a KDM. Perhaps it is badly formatted, or not a KDM at all."),
525 } catch (dcp::KDMDecryptionError &) {
528 _("Could not decrypt the DKDM. Perhaps it was not created with the correct certificate.")
530 } catch (dcp::MiscError& e) {
533 _("Could not read file as a KDM. It is much too large. Make sure you are loading a DKDM (XML) file."),
543 void add_dkdm_folder_clicked ()
545 auto d = new NewDKDMFolderDialog (this);
546 if (d->ShowModal() == wxID_OK) {
547 auto new_dkdm = make_shared<DKDMGroup>(wx_to_std(d->get()));
548 auto parent = dynamic_pointer_cast<DKDMGroup>(selected_dkdm());
550 parent = Config::instance()->dkdms ();
552 add_dkdm(new_dkdm, parent);
558 void update_dkdm_view()
560 _dkdm->DeleteAllItems();
562 add_dkdm_to_view(Config::instance()->dkdms());
563 if (_selected_dkdm) {
564 auto selection_in_id_map = std::find_if(_dkdm_id.begin(), _dkdm_id.end(), [this](pair<wxTreeItemId, shared_ptr<DKDMBase>> const& entry) {
565 return entry.second == _selected_dkdm;
567 if (selection_in_id_map != _dkdm_id.end()) {
568 _dkdm->SelectItem(selection_in_id_map->first);
573 /** @return true if this thing or any of its children match a search string */
574 bool matches(shared_ptr<DKDMBase> base, string const& search)
576 if (search.empty()) {
580 auto name = base->name();
581 transform(name.begin(), name.end(), name.begin(), ::tolower);
582 if (name.find(search) != string::npos) {
586 auto group = dynamic_pointer_cast<DKDMGroup>(base);
591 auto const children = group->children();
592 return std::any_of(children.begin(), children.end(), [this, search](shared_ptr<DKDMBase> child) {
593 return matches(child, search);
597 /** Add DKDMs to the view that match the current search */
598 void add_dkdm_to_view(shared_ptr<DKDMBase> base)
600 auto search = wx_to_std(_dkdm_search->GetValue());
601 transform(search.begin(), search.end(), search.begin(), ::tolower);
603 optional<wxTreeItemId> group_to_expand;
605 if (!base->parent()) {
606 /* This is the root group */
607 _dkdm_id[_dkdm->AddRoot("root")] = base;
609 /* Add base to the view */
611 auto parent_id = dkdm_to_id(base->parent());
612 added = _dkdm->AppendItem(parent_id, std_to_wx(base->name()));
613 /* Expand the group (later) if it matches the search or it was manually expanded */
614 if (!search.empty() || _expanded_dkdm_groups.find(base) != _expanded_dkdm_groups.end()) {
615 group_to_expand = added;
617 _dkdm_id[added] = base;
621 auto group = dynamic_pointer_cast<DKDMGroup>(base);
623 auto children = group->children();
625 [this](shared_ptr<DKDMBase> a, shared_ptr<DKDMBase> b) { return _collator.compare(a->name(), b->name()) < 0; }
628 for (auto i: children) {
629 if (matches(i, search)) {
635 if (group_to_expand) {
636 _ignore_expand = true;
637 _dkdm->Expand(*group_to_expand);
638 _ignore_expand = false;
642 /** @param group Group to add dkdm to */
643 void add_dkdm(shared_ptr<DKDMBase> dkdm, shared_ptr<DKDMGroup> group, shared_ptr<DKDM> previous = shared_ptr<DKDM>())
645 group->add (dkdm, previous);
646 /* We're messing with a Config-owned object here, so tell it that something has changed.
649 Config::instance()->changed ();
652 wxTreeItemId dkdm_to_id (shared_ptr<DKDMBase> dkdm)
654 for (auto const& i: _dkdm_id) {
655 if (i.second == dkdm) {
659 DCPOMATIC_ASSERT (false);
662 void remove_dkdm_clicked ()
664 auto removed = selected_dkdm ();
669 if (NagDialog::maybe_nag (
670 this, Config::NAG_DELETE_DKDM,
671 _("You are about to remove a DKDM. This will make it impossible to decrypt the DCP that the DKDM was made for, and it cannot be undone. "
677 _dkdm->Delete (dkdm_to_id (removed));
678 auto dkdms = Config::instance()->dkdms ();
679 dkdms->remove (removed);
680 Config::instance()->changed ();
683 void export_dkdm_clicked ()
685 auto removed = selected_dkdm ();
690 auto dkdm = dynamic_pointer_cast<DKDM>(removed);
695 auto d = new wxFileDialog (
696 this, _("Select DKDM File"), wxEmptyString, wxEmptyString, wxT("XML files (*.xml)|*.xml"),
697 wxFD_SAVE | wxFD_OVERWRITE_PROMPT
700 if (d->ShowModal() == wxID_OK) {
701 dkdm->dkdm().as_xml(wx_to_std(d->GetPath()));
706 void dkdm_search_changed()
711 wxPreferencesEditor* _config_dialog;
712 ScreensPanel* _screens;
713 KDMTimingPanel* _timing;
715 wxSearchCtrl* _dkdm_search;
716 typedef std::map<wxTreeItemId, std::shared_ptr<DKDMBase>> DKDMMap;
718 /* Keep a separate track of the selected DKDM so that when a search happens, and some things
719 * get removed from the view, we can restore the selection when they are re-added.
721 shared_ptr<DKDMBase> _selected_dkdm;
722 /* Keep expanded groups for the same reason */
723 unordered_set<shared_ptr<DKDMBase>> _expanded_dkdm_groups;
724 /* true if we are "artificially" expanding a group because it contains something found
727 bool _ignore_expand = false;
729 wxButton* _add_dkdm_folder;
730 wxButton* _remove_dkdm;
731 wxButton* _export_dkdm;
733 KDMOutputPanel* _output;
734 JobViewDialog* _job_view;
740 * @brief The magic App class for wxWidgets.
742 class App : public wxApp
752 bool OnInit () override
754 wxSplashScreen* splash = nullptr;
757 wxInitAllImageHandlers ();
759 Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1));
760 Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
762 splash = maybe_show_splash ();
764 SetAppName (_("DCP-o-matic KDM Creator"));
766 if (!wxApp::OnInit()) {
770 #ifdef DCPOMATIC_LINUX
771 unsetenv ("UBUNTU_MENUPROXY");
775 make_foreground_application ();
778 dcpomatic_setup_path_encoding ();
780 /* Enable i18n; this will create a Config object
781 to look for a force-configured language. This Config
782 object will be wrong, however, because dcpomatic_setup
783 hasn't yet been called and there aren't any filters etc.
786 dcpomatic_setup_i18n ();
788 /* Set things up, including filters etc.
789 which will now be internationalised correctly.
793 /* Force the configuration to be re-loaded correctly next
798 _frame = new DOMFrame (_("DCP-o-matic KDM Creator"));
799 SetTopWindow (_frame);
807 signal_manager = new wxSignalManager (this);
808 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
815 error_dialog (0, _("DCP-o-matic could not start"), std_to_wx(e.what()));
821 /* An unhandled exception has occurred inside the main event loop */
822 bool OnExceptionInMainLoop () override
826 } catch (FileError& e) {
830 _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM,
831 std_to_wx (e.what()),
832 std_to_wx (e.file().string().c_str ())
835 } catch (exception& e) {
839 _("An exception occurred: %s.\n\n") + " " + REPORT_PROBLEM,
844 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
847 /* This will terminate the program */
851 void OnUnhandledException () override
853 error_dialog (nullptr, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
858 signal_manager->ui_idle ();
861 void config_failed_to_load(Config::LoadFailure what)
863 report_config_load_failure(_frame, what);
866 void config_warning (string m)
868 message_dialog (_frame, std_to_wx(m));