Connect dcpomatic_kdm to backend.
[dcpomatic.git] / src / tools / dcpomatic.cc
index 7a15475572fe837af9c8885e4906182f1234f52a..9330b1b60b7e579fe67bce611c5d422dd1352580 100644 (file)
 #include "lib/signal_manager.h"
 #include "lib/log.h"
 #include "lib/job_manager.h"
-#include "lib/transcode_job.h"
 #include "lib/exceptions.h"
 #include "lib/cinema.h"
-#include "lib/kdm.h"
+#include "lib/screen_kdm.h"
 #include "lib/send_kdm_email_job.h"
 #include "lib/server_finder.h"
-#include "lib/update.h"
+#include "lib/update_checker.h"
 #include "lib/cross.h"
 #include "lib/content_factory.h"
 #include "lib/compose.hpp"
+#include "lib/cinema_kdms.h"
 #include <dcp/exceptions.h>
 #include <wx/generic/aboutdlgg.h>
 #include <wx/stdpaths.h>
@@ -446,11 +446,22 @@ private:
                }
 
                try {
+                       list<ScreenKDM> screen_kdms = _film->make_kdms (d->screens(), d->cpl(), d->from(), d->until(), d->formulation());
                        if (d->write_to ()) {
-                               write_kdm_files (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation (), d->directory ());
+                               ScreenKDM::write_files (
+                                       _film->name(),
+                                       screen_kdms,
+                                       d->directory()
+                                       );
                        } else {
                                JobManager::instance()->add (
-                                       shared_ptr<Job> (new SendKDMEmailJob (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation ()))
+                                       shared_ptr<Job> (new SendKDMEmailJob (
+                                                                _film->name(),
+                                                                _film->dcp_name(),
+                                                                d->from(),
+                                                                d->until(),
+                                                                CinemaKDMs::collect (screen_kdms)
+                                                                ))
                                        );
                        }
                } catch (dcp::NotEncryptedError& e) {
@@ -606,7 +617,7 @@ private:
        {
                list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
                list<shared_ptr<Job> >::iterator i = jobs.begin();
-               while (i != jobs.end() && dynamic_pointer_cast<TranscodeJob> (*i) == 0) {
+               while (i != jobs.end() && (*i)->json_name() != "transcode") {
                        ++i;
                }
                bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
@@ -798,13 +809,17 @@ private:
                wxInitAllImageHandlers ();
 
                wxSplashScreen* splash = 0;
-               if (!Config::have_existing ()) {
-                       wxBitmap bitmap;
-                       boost::filesystem::path p = shared_path () / "splash.png";
-                       if (bitmap.LoadFile (std_to_wx (p.string ()), wxBITMAP_TYPE_PNG)) {
-                               splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1);
-                               wxYield ();
+               try {
+                       if (!Config::have_existing ()) {
+                               wxBitmap bitmap;
+                               boost::filesystem::path p = shared_path () / "splash.png";
+                               if (bitmap.LoadFile (std_to_wx (p.string ()), wxBITMAP_TYPE_PNG)) {
+                                       splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1);
+                                       wxYield ();
+                               }
                        }
+               } catch (boost::filesystem::filesystem_error& e) {
+                       /* Maybe we couldn't find the splash image; never mind */
                }
 
                SetAppName (_("DCP-o-matic"));
@@ -823,7 +838,6 @@ private:
                TransformProcessType (&serial, kProcessTransformToForegroundApplication);
 #endif
 
-               cout << "set up path encoding.\n";
                dcpomatic_setup_path_encoding ();
 
                /* Enable i18n; this will create a Config object
@@ -917,9 +931,22 @@ private:
                try {
                        throw;
                } catch (FileError& e) {
-                       error_dialog (0, wxString::Format (_("An exception occurred: %s (%s).\n\n" + REPORT_PROBLEM), e.what(), e.file().string().c_str ()));
+                       error_dialog (
+                               0,
+                               wxString::Format (
+                                       _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM,
+                                       std_to_wx (e.what()),
+                                       std_to_wx (e.file().string().c_str ())
+                                       )
+                               );
                } catch (exception& e) {
-                       error_dialog (0, wxString::Format (_("An exception occurred: %s.\n\n"), e.what ()) + "  " + REPORT_PROBLEM);
+                       error_dialog (
+                               0,
+                               wxString::Format (
+                                       _("An exception occurred: %s.\n\n") + " " + REPORT_PROBLEM,
+                                       std_to_wx (e.what ())
+                                       )
+                               );
                } catch (...) {
                        error_dialog (0, _("An unknown exception occurred.") + "  " + REPORT_PROBLEM);
                }