Very basic DCP verification in the player (#1238).
[dcpomatic.git] / src / tools / dcpomatic_player.cc
1 /*
2     Copyright (C) 2017-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #include "lib/cross.h"
22 #include "lib/config.h"
23 #include "lib/util.h"
24 #include "lib/update_checker.h"
25 #include "lib/compose.hpp"
26 #include "lib/dcp_content.h"
27 #include "lib/job_manager.h"
28 #include "lib/job.h"
29 #include "lib/video_content.h"
30 #include "lib/subtitle_content.h"
31 #include "lib/ratio.h"
32 #include "lib/verify_dcp_job.h"
33 #include "wx/wx_signal_manager.h"
34 #include "wx/wx_util.h"
35 #include "wx/about_dialog.h"
36 #include "wx/report_problem_dialog.h"
37 #include "wx/film_viewer.h"
38 #include "wx/player_information.h"
39 #include "wx/update_dialog.h"
40 #include "wx/player_config_dialog.h"
41 #include "wx/verify_dcp_dialog.h"
42 #include <wx/wx.h>
43 #include <wx/stdpaths.h>
44 #include <wx/splash.h>
45 #include <wx/cmdline.h>
46 #include <wx/preferences.h>
47 #include <wx/progdlg.h>
48 #ifdef __WXOSX__
49 #include <ApplicationServices/ApplicationServices.h>
50 #endif
51 #include <boost/bind.hpp>
52 #include <iostream>
53
54 #ifdef check
55 #undef check
56 #endif
57
58 using std::string;
59 using std::cout;
60 using std::exception;
61 using std::vector;
62 using boost::shared_ptr;
63 using boost::optional;
64 using boost::dynamic_pointer_cast;
65
66 enum {
67         ID_file_open = 1,
68         ID_file_add_ov,
69         ID_file_add_kdm,
70         ID_file_history,
71         /* Allow spare IDs after _history for the recent files list */
72         ID_file_close = 100,
73         ID_view_scale_appropriate,
74         ID_view_scale_full,
75         ID_view_scale_half,
76         ID_view_scale_quarter,
77         ID_help_report_a_problem,
78         ID_tools_verify,
79         ID_tools_check_for_updates,
80 };
81
82 class DOMFrame : public wxFrame
83 {
84 public:
85         DOMFrame ()
86                 : wxFrame (0, -1, _("DCP-o-matic Player"))
87                 , _update_news_requested (false)
88                 , _info (0)
89                 , _config_dialog (0)
90                 , _file_menu (0)
91                 , _history_items (0)
92                 , _history_position (0)
93                 , _history_separator (0)
94                 , _viewer (0)
95         {
96
97 #if defined(DCPOMATIC_WINDOWS)
98                 maybe_open_console ();
99                 cout << "DCP-o-matic Player is starting." << "\n";
100 #endif
101
102                 wxMenuBar* bar = new wxMenuBar;
103                 setup_menu (bar);
104                 set_menu_sensitivity ();
105                 SetMenuBar (bar);
106
107 #ifdef DCPOMATIC_WINDOWS
108                 SetIcon (wxIcon (std_to_wx ("id")));
109 #endif
110
111                 _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this));
112                 config_changed ();
113
114                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this), ID_file_open);
115                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_ov, this), ID_file_add_ov);
116                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_kdm, this), ID_file_add_kdm);
117                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE);
118                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_close, this), ID_file_close);
119                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
120                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
121                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>()), ID_view_scale_appropriate);
122                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(0)), ID_view_scale_full);
123                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(1)), ID_view_scale_half);
124                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(2)), ID_view_scale_quarter);
125                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
126                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_report_a_problem, this), ID_help_report_a_problem);
127                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_verify, this), ID_tools_verify);
128                 Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_check_for_updates, this), ID_tools_check_for_updates);
129
130                 /* Use a panel as the only child of the Frame so that we avoid
131                    the dark-grey background on Windows.
132                 */
133                 wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
134
135                 _viewer = new FilmViewer (overall_panel, false, false);
136                 _viewer->set_dcp_decode_reduction (Config::instance()->decode_reduction ());
137                 _info = new PlayerInformation (overall_panel, _viewer);
138                 wxSizer* main_sizer = new wxBoxSizer (wxVERTICAL);
139                 main_sizer->Add (_viewer, 1, wxEXPAND | wxALL, 6);
140                 main_sizer->Add (_info, 0, wxEXPAND | wxALL, 6);
141                 overall_panel->SetSizer (main_sizer);
142
143 #ifdef __WXOSX__
144                 wxAcceleratorEntry* accel = new wxAcceleratorEntry[1];
145                 accel[0].Set(wxACCEL_CTRL, static_cast<int>('W'), ID_file_close);
146                 wxAcceleratorTable accel_table (1, accel);
147                 SetAcceleratorTable (accel_table);
148                 delete[] accel;
149 #endif
150
151                 UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
152         }
153
154         void set_decode_reduction (optional<int> reduction)
155         {
156                 _viewer->set_dcp_decode_reduction (reduction);
157                 _info->triggered_update ();
158                 Config::instance()->set_decode_reduction (reduction);
159         }
160
161         void load_dcp (boost::filesystem::path dir)
162         {
163                 _film.reset (new Film (optional<boost::filesystem::path>()));
164                 shared_ptr<DCPContent> dcp;
165                 try {
166                         dcp.reset (new DCPContent (_film, dir));
167                 } catch (boost::filesystem::filesystem_error& e) {
168                         error_dialog (this, _("Could not load DCP"), std_to_wx (e.what()));
169                         return;
170                 }
171
172                 _film->examine_and_add_content (dcp, true);
173
174                 JobManager* jm = JobManager::instance ();
175
176                 wxProgressDialog* progress = new wxProgressDialog (_("DCP-o-matic Player"), _("Loading DCP"));
177
178                 while (jm->work_to_do() || signal_manager->ui_idle()) {
179                         dcpomatic_sleep (1);
180                         progress->Pulse ();
181                 }
182
183                 progress->Destroy ();
184
185                 DCPOMATIC_ASSERT (!jm->get().empty());
186
187                 shared_ptr<Job> last = jm->get().back();
188                 if (last->finished_in_error()) {
189                         error_dialog(this, std_to_wx(last->error_summary()) + ".\n", std_to_wx(last->error_details()));
190                         return;
191                 }
192
193                 if (dcp->subtitle) {
194                         dcp->subtitle->set_use (true);
195                 }
196
197                 Ratio const * r = Ratio::nearest_from_ratio(dcp->video->size().ratio());
198                 if (r) {
199                         _film->set_container(r);
200                 }
201
202                 _viewer->set_film (_film);
203                 _viewer->set_position (DCPTime ());
204                 _info->triggered_update ();
205
206                 Config::instance()->add_to_player_history (dir);
207
208                 set_menu_sensitivity ();
209         }
210
211 private:
212
213         void setup_menu (wxMenuBar* m)
214         {
215                 _file_menu = new wxMenu;
216                 _file_menu->Append (ID_file_open, _("&Open...\tCtrl-O"));
217                 _file_add_ov = _file_menu->Append (ID_file_add_ov, _("&Add OV..."));
218                 _file_add_kdm = _file_menu->Append (ID_file_add_kdm, _("&Add KDM..."));
219
220                 _history_position = _file_menu->GetMenuItems().GetCount();
221
222                 _file_menu->AppendSeparator ();
223                 _file_menu->Append (ID_file_close, _("&Close"));
224                 _file_menu->AppendSeparator ();
225
226 #ifdef __WXOSX__
227                 _file_menu->Append (wxID_EXIT, _("&Exit"));
228 #else
229                 _file_menu->Append (wxID_EXIT, _("&Quit"));
230 #endif
231
232 #ifdef __WXOSX__
233                 _file_menu->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
234 #else
235                 wxMenu* edit = new wxMenu;
236                 edit->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
237 #endif
238
239                 wxMenu* view = new wxMenu;
240                 optional<int> c = Config::instance()->decode_reduction();
241                 view->AppendRadioItem(ID_view_scale_appropriate, _("Set decode resolution to match display"))->Check(!static_cast<bool>(c));
242                 view->AppendRadioItem(ID_view_scale_full, _("Decode at full resolution"))->Check(c && c.get() == 0);
243                 view->AppendRadioItem(ID_view_scale_half, _("Decode at half resolution"))->Check(c && c.get() == 1);
244                 view->AppendRadioItem(ID_view_scale_quarter, _("Decode at quarter resolution"))->Check(c && c.get() == 2);
245
246                 wxMenu* tools = new wxMenu;
247                 _tools_verify = tools->Append (ID_tools_verify, _("Verify DCP"));
248                 tools->AppendSeparator ();
249                 tools->Append (ID_tools_check_for_updates, _("Check for updates"));
250
251                 wxMenu* help = new wxMenu;
252 #ifdef __WXOSX__
253                 help->Append (wxID_ABOUT, _("About DCP-o-matic"));
254 #else
255                 help->Append (wxID_ABOUT, _("About"));
256 #endif
257                 help->Append (ID_help_report_a_problem, _("Report a problem..."));
258
259                 m->Append (_file_menu, _("&File"));
260 #ifndef __WXOSX__
261                 m->Append (edit, _("&Edit"));
262 #endif
263                 m->Append (view, _("&View"));
264                 m->Append (tools, _("&Tools"));
265                 m->Append (help, _("&Help"));
266         }
267
268         void file_open ()
269         {
270                 wxString d = wxStandardPaths::Get().GetDocumentsDir();
271                 if (Config::instance()->last_player_load_directory()) {
272                         d = std_to_wx (Config::instance()->last_player_load_directory()->string());
273                 }
274
275                 wxDirDialog* c = new wxDirDialog (this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
276
277                 int r;
278                 while (true) {
279                         r = c->ShowModal ();
280                         if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
281                                 error_dialog (this, _("You did not select a folder.  Make sure that you select a folder before clicking Open."));
282                         } else {
283                                 break;
284                         }
285                 }
286
287                 if (r == wxID_OK) {
288                         boost::filesystem::path const dcp (wx_to_std (c->GetPath ()));
289                         load_dcp (dcp);
290                         Config::instance()->set_last_player_load_directory (dcp.parent_path());
291                 }
292
293                 c->Destroy ();
294         }
295
296         void file_add_ov ()
297         {
298                 wxDirDialog* c = new wxDirDialog (
299                         this,
300                         _("Select DCP to open as OV"),
301                         wxStandardPaths::Get().GetDocumentsDir(),
302                         wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
303                         );
304
305                 int r;
306                 while (true) {
307                         r = c->ShowModal ();
308                         if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
309                                 error_dialog (this, _("You did not select a folder.  Make sure that you select a folder before clicking Open."));
310                         } else {
311                                 break;
312                         }
313                 }
314
315                 if (r == wxID_OK) {
316                         DCPOMATIC_ASSERT (_film);
317                         shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
318                         DCPOMATIC_ASSERT (dcp);
319                         dcp->add_ov (wx_to_std(c->GetPath()));
320                         dcp->examine (shared_ptr<Job>());
321                         /* Maybe we just gained some subtitles */
322                         if (dcp->subtitle) {
323                                 dcp->subtitle->set_use (true);
324                         }
325                 }
326
327                 c->Destroy ();
328                 _info->triggered_update ();
329         }
330
331         void file_add_kdm ()
332         {
333                 wxFileDialog* d = new wxFileDialog (this, _("Select KDM"));
334
335                 if (d->ShowModal() == wxID_OK) {
336                         DCPOMATIC_ASSERT (_film);
337                         shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
338                         DCPOMATIC_ASSERT (dcp);
339                         try {
340                                 dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)));
341                                 dcp->examine (shared_ptr<Job>());
342                         } catch (exception& e) {
343                                 error_dialog (this, wxString::Format (_("Could not load KDM.")), std_to_wx(e.what()));
344                                 d->Destroy ();
345                                 return;
346                         }
347                 }
348
349                 d->Destroy ();
350                 _info->triggered_update ();
351         }
352
353         void file_history (wxCommandEvent& event)
354         {
355                 vector<boost::filesystem::path> history = Config::instance()->player_history ();
356                 int n = event.GetId() - ID_file_history;
357                 if (n >= 0 && n < static_cast<int> (history.size ())) {
358                         load_dcp (history[n]);
359                 }
360         }
361
362         void file_close ()
363         {
364                 _viewer->set_film (shared_ptr<Film>());
365                 _film.reset ();
366                 _info->triggered_update ();
367                 set_menu_sensitivity ();
368         }
369
370         void file_exit ()
371         {
372                 Close ();
373         }
374
375         void edit_preferences ()
376         {
377                 if (!_config_dialog) {
378                         _config_dialog = create_player_config_dialog ();
379                 }
380                 _config_dialog->Show (this);
381         }
382
383         void tools_verify ()
384         {
385                 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
386                 DCPOMATIC_ASSERT (dcp);
387
388                 JobManager* jm = JobManager::instance ();
389                 jm->add (shared_ptr<Job> (new VerifyDCPJob (dcp->directories())));
390
391                 wxProgressDialog* progress = new wxProgressDialog (_("DCP-o-matic Player"), _("Verifying DCP"));
392
393                 while (jm->work_to_do() || signal_manager->ui_idle()) {
394                         dcpomatic_sleep (1);
395                         progress->Pulse ();
396                 }
397
398                 progress->Destroy ();
399
400                 DCPOMATIC_ASSERT (!jm->get().empty());
401                 shared_ptr<VerifyDCPJob> last = dynamic_pointer_cast<VerifyDCPJob> (jm->get().back());
402                 DCPOMATIC_ASSERT (last);
403
404                 VerifyDCPDialog* d = new VerifyDCPDialog (this, last->notes ());
405                 d->ShowModal ();
406                 d->Destroy ();
407         }
408
409         void tools_check_for_updates ()
410         {
411                 UpdateChecker::instance()->run ();
412                 _update_news_requested = true;
413         }
414
415         void help_about ()
416         {
417                 AboutDialog* d = new AboutDialog (this);
418                 d->ShowModal ();
419                 d->Destroy ();
420         }
421
422         void help_report_a_problem ()
423         {
424                 ReportProblemDialog* d = new ReportProblemDialog (this);
425                 if (d->ShowModal () == wxID_OK) {
426                         d->report ();
427                 }
428                 d->Destroy ();
429         }
430
431         void update_checker_state_changed ()
432         {
433                 UpdateChecker* uc = UpdateChecker::instance ();
434
435                 bool const announce =
436                         _update_news_requested ||
437                         (uc->stable() && Config::instance()->check_for_updates()) ||
438                         (uc->test() && Config::instance()->check_for_updates() && Config::instance()->check_for_test_updates());
439
440                 _update_news_requested = false;
441
442                 if (!announce) {
443                         return;
444                 }
445
446                 if (uc->state() == UpdateChecker::YES) {
447                         UpdateDialog* dialog = new UpdateDialog (this, uc->stable (), uc->test ());
448                         dialog->ShowModal ();
449                         dialog->Destroy ();
450                 } else if (uc->state() == UpdateChecker::FAILED) {
451                         error_dialog (this, _("The DCP-o-matic download server could not be contacted."));
452                 } else {
453                         error_dialog (this, _("There are no new versions of DCP-o-matic available."));
454                 }
455
456                 _update_news_requested = false;
457         }
458
459         void config_changed ()
460         {
461                 /* Instantly save any config changes when using the player GUI */
462                 try {
463                         Config::instance()->write_config();
464                 } catch (exception& e) {
465                         error_dialog (
466                                 this,
467                                 wxString::Format (
468                                         _("Could not write to config file at %s.  Your changes have not been saved."),
469                                         std_to_wx (Config::instance()->cinemas_file().string()).data()
470                                         )
471                                 );
472                 }
473
474                 for (int i = 0; i < _history_items; ++i) {
475                         delete _file_menu->Remove (ID_file_history + i);
476                 }
477
478                 if (_history_separator) {
479                         _file_menu->Remove (_history_separator);
480                 }
481                 delete _history_separator;
482                 _history_separator = 0;
483
484                 int pos = _history_position;
485
486                 vector<boost::filesystem::path> history = Config::instance()->player_history ();
487
488                 if (!history.empty ()) {
489                         _history_separator = _file_menu->InsertSeparator (pos++);
490                 }
491
492                 for (size_t i = 0; i < history.size(); ++i) {
493                         string s;
494                         if (i < 9) {
495                                 s = String::compose ("&%1 %2", i + 1, history[i].string());
496                         } else {
497                                 s = history[i].string();
498                         }
499                         _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s));
500                 }
501
502                 _history_items = history.size ();
503         }
504
505         void set_menu_sensitivity ()
506         {
507                 _tools_verify->Enable (static_cast<bool>(_film));
508                 _file_add_ov->Enable (static_cast<bool>(_film));
509                 _file_add_kdm->Enable (static_cast<bool>(_film));
510         }
511
512         bool _update_news_requested;
513         PlayerInformation* _info;
514         wxPreferencesEditor* _config_dialog;
515         wxMenu* _file_menu;
516         int _history_items;
517         int _history_position;
518         wxMenuItem* _history_separator;
519         FilmViewer* _viewer;
520         boost::shared_ptr<Film> _film;
521         boost::signals2::scoped_connection _config_changed_connection;
522         wxMenuItem* _file_add_ov;
523         wxMenuItem* _file_add_kdm;
524         wxMenuItem* _tools_verify;
525 };
526
527 static const wxCmdLineEntryDesc command_line_description[] = {
528         { wxCMD_LINE_PARAM, 0, 0, "DCP to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
529         { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
530 };
531
532 /** @class App
533  *  @brief The magic App class for wxWidgets.
534  */
535 class App : public wxApp
536 {
537 public:
538         App ()
539                 : wxApp ()
540                 , _frame (0)
541         {}
542
543 private:
544
545         bool OnInit ()
546         try
547         {
548                 wxInitAllImageHandlers ();
549
550                 Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
551                 Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
552
553                 wxSplashScreen* splash = maybe_show_splash ();
554
555                 SetAppName (_("DCP-o-matic Player"));
556
557                 if (!wxApp::OnInit()) {
558                         return false;
559                 }
560
561 #ifdef DCPOMATIC_LINUX
562                 unsetenv ("UBUNTU_MENUPROXY");
563 #endif
564
565 #ifdef __WXOSX__
566                 ProcessSerialNumber serial;
567                 GetCurrentProcess (&serial);
568                 TransformProcessType (&serial, kProcessTransformToForegroundApplication);
569 #endif
570
571                 dcpomatic_setup_path_encoding ();
572
573                 /* Enable i18n; this will create a Config object
574                    to look for a force-configured language.  This Config
575                    object will be wrong, however, because dcpomatic_setup
576                    hasn't yet been called and there aren't any filters etc.
577                    set up yet.
578                 */
579                 dcpomatic_setup_i18n ();
580
581                 /* Set things up, including filters etc.
582                    which will now be internationalised correctly.
583                 */
584                 dcpomatic_setup ();
585
586                 /* Force the configuration to be re-loaded correctly next
587                    time it is needed.
588                 */
589                 Config::drop ();
590
591                 _frame = new DOMFrame ();
592                 SetTopWindow (_frame);
593                 _frame->Maximize ();
594                 if (splash) {
595                         splash->Destroy ();
596                 }
597                 _frame->Show ();
598
599                 signal_manager = new wxSignalManager (this);
600
601                 if (!_dcp_to_load.empty() && boost::filesystem::is_directory (_dcp_to_load)) {
602                         try {
603                                 _frame->load_dcp (_dcp_to_load);
604                         } catch (exception& e) {
605                                 error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load DCP %1.")), _dcp_to_load)), std_to_wx(e.what()));
606                         }
607                 }
608
609                 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
610
611                 if (Config::instance()->check_for_updates ()) {
612                         UpdateChecker::instance()->run ();
613                 }
614
615                 return true;
616         }
617         catch (exception& e)
618         {
619                 error_dialog (0, _("DCP-o-matic Player could not start."), std_to_wx(e.what()));
620                 return true;
621         }
622
623         void OnInitCmdLine (wxCmdLineParser& parser)
624         {
625                 parser.SetDesc (command_line_description);
626                 parser.SetSwitchChars (wxT ("-"));
627         }
628
629         bool OnCmdLineParsed (wxCmdLineParser& parser)
630         {
631                 if (parser.GetParamCount() > 0) {
632                         _dcp_to_load = wx_to_std (parser.GetParam (0));
633                 }
634
635                 return true;
636         }
637
638         void report_exception ()
639         {
640                 try {
641                         throw;
642                 } catch (FileError& e) {
643                         error_dialog (
644                                 0,
645                                 wxString::Format (
646                                         _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM,
647                                         std_to_wx (e.what()),
648                                         std_to_wx (e.file().string().c_str ())
649                                         )
650                                 );
651                 } catch (exception& e) {
652                         error_dialog (
653                                 0,
654                                 wxString::Format (
655                                         _("An exception occurred: %s.\n\n") + REPORT_PROBLEM,
656                                         std_to_wx (e.what ())
657                                         )
658                                 );
659                 } catch (...) {
660                         error_dialog (0, _("An unknown exception occurred.") + "  " + REPORT_PROBLEM);
661                 }
662         }
663
664         /* An unhandled exception has occurred inside the main event loop */
665         bool OnExceptionInMainLoop ()
666         {
667                 report_exception ();
668                 /* This will terminate the program */
669                 return false;
670         }
671
672         void OnUnhandledException ()
673         {
674                 report_exception ();
675         }
676
677         void idle ()
678         {
679                 signal_manager->ui_idle ();
680         }
681
682         void config_failed_to_load ()
683         {
684                 message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
685         }
686
687         void config_warning (string m)
688         {
689                 message_dialog (_frame, std_to_wx (m));
690         }
691
692         DOMFrame* _frame;
693         string _dcp_to_load;
694 };
695
696 IMPLEMENT_APP (App)