More OS X debugging.
[dcpomatic.git] / src / tools / dcpomatic.cc
index 98501d3bb13d9e4f178a42d2defd02fe803e97ab..874f19d2a1d7090c35962c0ce5d3167669877349 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -39,6 +39,7 @@
 #include "wx/properties_dialog.h"
 #include "wx/wx_ui_signaller.h"
 #include "wx/about_dialog.h"
+#include "wx/kdm_dialog.h"
 #include "lib/film.h"
 #include "lib/config.h"
 #include "lib/util.h"
@@ -47,6 +48,9 @@
 #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"
 
 using std::cout;
 using std::string;
@@ -167,6 +171,7 @@ enum {
        ID_file_save,
        ID_file_properties,
        ID_jobs_make_dcp,
+       ID_jobs_make_kdms,
        ID_jobs_send_dcp_to_tms,
        ID_jobs_show_dcp,
 };
@@ -201,6 +206,7 @@ setup_menu (wxMenuBar* m)
 
        jobs_menu = new wxMenu;
        add_item (jobs_menu, _("&Make DCP"), ID_jobs_make_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION);
+       add_item (jobs_menu, _("Make &KDMs..."), ID_jobs_make_kdms, NEEDS_FILM);
        add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION);
        add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION);
 
@@ -236,6 +242,7 @@ public:
                Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_exit, this),            wxID_EXIT);
                Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::edit_preferences, this),     wxID_PREFERENCES);
                Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_dcp, this),        ID_jobs_make_dcp);
+               Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_kdms, this),       ID_jobs_make_kdms);
                Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms);
                Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_show_dcp, this),        ID_jobs_show_dcp);
                Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_about, this),           wxID_ABOUT);
@@ -283,7 +290,7 @@ private:
                        return;
                }
 
-               bool const have_dcp = film && film->have_dcp();
+               bool const have_dcp = false;//film && film->have_dcp();
                jobs_menu->Enable (ID_jobs_send_dcp_to_tms, have_dcp);
                jobs_menu->Enable (ID_jobs_show_dcp, have_dcp);
        }
@@ -407,6 +414,31 @@ private:
        {
                JobWrapper::make_dcp (this, film);
        }
+
+       void jobs_make_kdms ()
+       {
+               if (!film) {
+                       return;
+               }
+               
+               KDMDialog* d = new KDMDialog (this);
+               if (d->ShowModal () != wxID_OK) {
+                       d->Destroy ();
+                       return;
+               }
+
+               try {
+                       if (d->write_to ()) {
+                               write_kdm_files (film, d->screens (), d->from (), d->until (), d->directory ());
+                       } else {
+                               email_kdms (film, d->screens (), d->from (), d->until ());
+                       }
+               } catch (KDMError& e) {
+                       error_dialog (this, e.what ());
+               }
+       
+               d->Destroy ();
+       }
        
        void jobs_send_dcp_to_tms ()
        {