Revert "Bump libdcp for new method."
[dcpomatic.git] / src / tools / dcpomatic.cc
index 6b1d4d260dc3b044252ed5423502d3ca98541f2c..d4695f1fa08b04475dd4210a3ff7ee40c5b02601 100644 (file)
@@ -58,7 +58,9 @@
 #include "lib/compose.hpp"
 #include "lib/cinema_kdms.h"
 #include "lib/dcpomatic_socket.h"
+#include "lib/hints.h"
 #include <dcp/exceptions.h>
+#include <dcp/raw_convert.h>
 #include <wx/generic/aboutdlgg.h>
 #include <wx/stdpaths.h>
 #include <wx/cmdline.h>
@@ -74,6 +76,7 @@
 #include <boost/noncopyable.hpp>
 #include <iostream>
 #include <fstream>
+/* This is OK as it's only used with DCPOMATIC_WINDOWS */
 #include <sstream>
 
 #ifdef check
@@ -93,6 +96,7 @@ using std::exception;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
+using dcp::raw_convert;
 
 class FilmChangedDialog : public boost::noncopyable
 {
@@ -169,6 +173,7 @@ public:
                , _hints_dialog (0)
                , _servers_list_dialog (0)
                , _config_dialog (0)
+               , _kdm_dialog (0)
                , _file_menu (0)
                , _history_items (0)
                , _history_position (0)
@@ -312,6 +317,8 @@ public:
                _film = film;
                _film_viewer->set_film (_film);
                _film_editor->set_film (_film);
+               delete _video_waveform_dialog;
+               _video_waveform_dialog = 0;
                set_menu_sensitivity ();
                Config::instance()->add_to_history (_film->directory ());
        }
@@ -455,6 +462,15 @@ private:
                        }
                }
 
+               if (!get_hints(_film).empty() && Config::instance()->show_hints_before_make_dcp()) {
+                       HintsDialog* hints = new HintsDialog (this, _film, false);
+                       int const r = hints->ShowModal();
+                       hints->Destroy ();
+                       if (r == wxID_CANCEL) {
+                               return;
+                       }
+               }
+
                try {
                        /* It seems to make sense to auto-save metadata here, since the make DCP may last
                           a long time, and crashes/power failures are moderately likely.
@@ -474,41 +490,13 @@ private:
                        return;
                }
 
-               KDMDialog* d = new KDMDialog (this, _film);
-               if (d->ShowModal () != wxID_OK) {
-                       d->Destroy ();
-                       return;
-               }
-
-               try {
-                       list<ScreenKDM> screen_kdms = _film->make_kdms (d->screens(), d->cpl(), d->from(), d->until(), d->formulation());
-                       if (d->write_to ()) {
-                               ScreenKDM::write_files (
-                                       _film->name(),
-                                       screen_kdms,
-                                       d->directory()
-                                       );
-                       } else {
-                               JobManager::instance()->add (
-                                       shared_ptr<Job> (new SendKDMEmailJob (
-                                                                _film->name(),
-                                                                _film->dcp_name(),
-                                                                d->from(),
-                                                                d->until(),
-                                                                CinemaKDMs::collect (screen_kdms),
-                                                                _film->log()
-                                                                ))
-                                       );
-                       }
-               } catch (dcp::NotEncryptedError& e) {
-                       error_dialog (this, _("CPL's content is not encrypted."));
-               } catch (exception& e) {
-                       error_dialog (this, e.what ());
-               } catch (...) {
-                       error_dialog (this, _("An unknown exception occurred."));
+               if (_kdm_dialog) {
+                       _kdm_dialog->Destroy ();
+                       _kdm_dialog = 0;
                }
 
-               d->Destroy ();
+               _kdm_dialog = new KDMDialog (this, _film);
+               _kdm_dialog->Show (this);
        }
 
        void jobs_make_dcp_batch ()
@@ -517,6 +505,15 @@ private:
                        return;
                }
 
+               if (!get_hints(_film).empty() && Config::instance()->show_hints_before_make_dcp()) {
+                       HintsDialog* hints = new HintsDialog (this, _film, false);
+                       int const r = hints->ShowModal();
+                       hints->Destroy ();
+                       if (r == wxID_CANCEL) {
+                               return;
+                       }
+               }
+
                _film->write_metadata ();
 
                /* i = 0; try to connect via socket
@@ -654,7 +651,7 @@ private:
        void tools_video_waveform ()
        {
                if (!_video_waveform_dialog) {
-                       _video_waveform_dialog = new VideoWaveformDialog (this, _film_viewer);
+                       _video_waveform_dialog = new VideoWaveformDialog (this, _film, _film_viewer);
                }
 
                _video_waveform_dialog->Show ();
@@ -663,7 +660,7 @@ private:
        void tools_hints ()
        {
                if (!_hints_dialog) {
-                       _hints_dialog = new HintsDialog (this, _film);
+                       _hints_dialog = new HintsDialog (this, _film, true);
                }
 
                _hints_dialog->Show ();
@@ -908,12 +905,13 @@ private:
                }
 
                for (size_t i = 0; i < history.size(); ++i) {
-                       SafeStringStream s;
+                       string s;
                        if (i < 9) {
-                               s << "&" << (i + 1) << " ";
+                               s = String::compose ("&%1 %2", i + 1, history[i].string());
+                       } else {
+                               s = history[i].string();
                        }
-                       s << history[i].string();
-                       _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s.str ()));
+                       _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s));
                }
 
                _history_items = history.size ();
@@ -953,6 +951,7 @@ private:
        HintsDialog* _hints_dialog;
        ServersListDialog* _servers_list_dialog;
        wxPreferencesEditor* _config_dialog;
+       KDMDialog* _kdm_dialog;
        wxMenu* _file_menu;
        shared_ptr<Film> _film;
        int _history_items;
@@ -987,6 +986,8 @@ private:
        {
                wxInitAllImageHandlers ();
 
+               Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
+
                wxSplashScreen* splash = 0;
                try {
                        if (!Config::have_existing ("config.xml")) {
@@ -1156,6 +1157,11 @@ private:
                }
        }
 
+       void config_failed_to_load ()
+       {
+               message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
+       }
+
        DOMFrame* _frame;
        shared_ptr<wxTimer> _timer;
        string _film_to_load;