X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic.cc;h=1e40fbd697a0935d8457d3cb04e9396c170b72b8;hb=b048889b399367bf0fc8b905c7c0cf436d629f57;hp=c646942cb3313dfc52182a6ea58d86d2979a399d;hpb=7f8fb87610ca3f4106b925a314301c84ed380232;p=dcpomatic.git diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index c646942cb..1e40fbd69 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -30,6 +30,7 @@ #include "wx/wx_signal_manager.h" #include "wx/about_dialog.h" #include "wx/kdm_dialog.h" +#include "wx/self_dkdm_dialog.h" #include "wx/servers_list_dialog.h" #include "wx/hints_dialog.h" #include "wx/update_dialog.h" @@ -48,11 +49,13 @@ #include "lib/cinema.h" #include "lib/screen_kdm.h" #include "lib/send_kdm_email_job.h" -#include "lib/server_finder.h" +#include "lib/encode_server_finder.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 "lib/dcpomatic_socket.h" #include #include #include @@ -136,7 +139,9 @@ enum { ID_content_scale_to_fit_width = 100, ID_content_scale_to_fit_height, ID_jobs_make_dcp, + ID_jobs_make_dcp_batch, ID_jobs_make_kdms, + ID_jobs_make_self_dkdm, ID_jobs_send_dcp_to_tms, ID_jobs_show_dcp, ID_tools_video_waveform, @@ -146,7 +151,8 @@ enum { ID_tools_restore_default_preferences, ID_help_report_a_problem, /* IDs for shortcuts (with no associated menu item) */ - ID_add_file + ID_add_file, + ID_remove }; class DOMFrame : public wxFrame @@ -162,6 +168,7 @@ public: , _history_items (0) , _history_position (0) , _history_separator (0) + , _update_news_requested (false) { #if defined(DCPOMATIC_WINDOWS) if (Config::instance()->win32_console ()) { @@ -200,6 +207,8 @@ public: Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::content_scale_to_fit_height, this), ID_content_scale_to_fit_height); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_make_dcp, this), ID_jobs_make_dcp); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_make_kdms, this), ID_jobs_make_kdms); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_make_dcp_batch, this), ID_jobs_make_dcp_batch); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_make_self_dkdm, this), ID_jobs_make_self_dkdm); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_show_dcp, this), ID_jobs_show_dcp); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::tools_video_waveform, this), ID_tools_video_waveform); @@ -238,14 +247,18 @@ public: overall_panel->SetSizer (main_sizer); - wxAcceleratorEntry accel[1]; + wxAcceleratorEntry accel[2]; accel[0].Set (wxACCEL_CTRL, static_cast('A'), ID_add_file); + accel[1].Set (wxACCEL_NORMAL, WXK_DELETE, ID_remove); Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file); - wxAcceleratorTable accel_table (1, accel); + Bind (wxEVT_MENU, boost::bind (&ContentPanel::remove_clicked, _film_editor->content_panel(), true), ID_remove); + wxAcceleratorTable accel_table (2, accel); SetAcceleratorTable (accel_table); /* Instantly save any config changes when using the DCP-o-matic GUI */ Config::instance()->Changed.connect (boost::bind (&Config::write, Config::instance ())); + + UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this)); } void new_film (boost::filesystem::path path) @@ -445,15 +458,23 @@ private: } try { + list screen_kdms = _film->make_kdms (d->screens(), d->cpl(), d->from(), d->until(), d->formulation()); if (d->write_to ()) { ScreenKDM::write_files ( _film->name(), - _film->make_kdms (d->screens(), d->cpl(), d->from(), d->until(), d->formulation()), + screen_kdms, d->directory() ); } else { JobManager::instance()->add ( - shared_ptr (new SendKDMEmailJob (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation ())) + shared_ptr (new SendKDMEmailJob ( + _film->name(), + _film->dcp_name(), + d->from(), + d->until(), + CinemaKDMs::collect (screen_kdms), + _film->log() + )) ); } } catch (dcp::NotEncryptedError& e) { @@ -467,6 +488,84 @@ private: d->Destroy (); } + void jobs_make_dcp_batch () + { + if (!_film) { + return; + } + + _film->write_metadata (); + + /* i = 0; try to connect via socket + i = 1; try again, and then try to start the batch converter + i = 2 onwards; try again. + */ + for (int i = 0; i < 8; ++i) { + try { + boost::asio::io_service io_service; + boost::asio::ip::tcp::resolver resolver (io_service); + boost::asio::ip::tcp::resolver::query query ("127.0.0.1", raw_convert (Config::instance()->server_port_base() + 2)); + boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query); + Socket socket (5); + socket.connect (*endpoint_iterator); + string s = _film->directory().string (); + socket.write (s.length() + 1); + socket.write ((uint8_t *) s.c_str(), s.length() + 1); + /* OK\0 */ + uint8_t ok[3]; + socket.read (ok, 3); + return; + } catch (exception& e) { + + } + + if (i == 1) { + start_batch_converter (wx_to_std (wxStandardPaths::Get().GetExecutablePath())); + } + + dcpomatic_sleep (1); + } + + error_dialog (this, _("Could not find batch converter.")); + } + + void jobs_make_self_dkdm () + { + if (!_film) { + return; + } + + SelfDKDMDialog* d = new SelfDKDMDialog (this, _film); + if (d->ShowModal () != wxID_OK) { + d->Destroy (); + return; + } + + try { + vector dkdms = Config::instance()->dkdms (); + dkdms.push_back ( + _film->make_kdm ( + Config::instance()->decryption_chain()->leaf(), + vector (), + d->cpl (), + dcp::LocalTime ("2012-01-01T01:00:00+00:00"), + dcp::LocalTime ("2112-01-01T01:00:00+00:00"), + dcp::MODIFIED_TRANSITIONAL_1 + ) + ); + + Config::instance()->set_dkdms (dkdms); + } 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.")); + } + + d->Destroy (); + } + void content_scale_to_fit_width () { VideoContentList vc = _film_editor->content_panel()->selected_video (); @@ -552,6 +651,7 @@ private: void tools_check_for_updates () { UpdateChecker::instance()->run (); + _update_news_requested = true; } void help_about () @@ -699,7 +799,9 @@ private: wxMenu* jobs_menu = new wxMenu; add_item (jobs_menu, _("&Make DCP\tCtrl-M"), ID_jobs_make_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION); + add_item (jobs_menu, _("Make DCP in &batch converter\tCtrl-B"), ID_jobs_make_dcp_batch, NEEDS_FILM | NOT_DURING_DCP_CREATION); add_item (jobs_menu, _("Make &KDMs...\tCtrl-K"), ID_jobs_make_kdms, NEEDS_FILM); + add_item (jobs_menu, _("Make DKDM for DCP-o-matic..."), ID_jobs_make_self_dkdm, NEEDS_FILM); add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL); add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL); @@ -761,6 +863,34 @@ private: _history_items = history.size (); } + void update_checker_state_changed () + { + UpdateChecker* uc = UpdateChecker::instance (); + + bool const announce = + _update_news_requested || + (uc->stable() && Config::instance()->check_for_updates()) || + (uc->test() && Config::instance()->check_for_updates() && Config::instance()->check_for_test_updates()); + + _update_news_requested = false; + + if (!announce) { + return; + } + + if (uc->state() == UpdateChecker::YES) { + UpdateDialog* dialog = new UpdateDialog (this, uc->stable (), uc->test ()); + dialog->ShowModal (); + dialog->Destroy (); + } else if (uc->state() == UpdateChecker::FAILED) { + error_dialog (this, _("The DCP-o-matic download server could not be contacted.")); + } else { + error_dialog (this, _("There are no new versions of DCP-o-matic available.")); + } + + _update_news_requested = false; + } + FilmEditor* _film_editor; FilmViewer* _film_viewer; VideoWaveformDialog* _video_waveform_dialog; @@ -773,6 +903,7 @@ private: int _history_position; wxMenuItem* _history_separator; boost::signals2::scoped_connection _config_changed_connection; + bool _update_news_requested; }; static const wxCmdLineEntryDesc command_line_description[] = { @@ -802,7 +933,7 @@ private: wxSplashScreen* splash = 0; try { - if (!Config::have_existing ()) { + if (!Config::have_existing ("config.xml")) { wxBitmap bitmap; boost::filesystem::path p = shared_path () / "splash.png"; if (bitmap.LoadFile (std_to_wx (p.string ()), wxBITMAP_TYPE_PNG)) { @@ -880,7 +1011,6 @@ private: _timer.reset (new wxTimer (this)); _timer->Start (1000); - UpdateChecker::instance()->StateChanged.connect (boost::bind (&App::update_checker_state_changed, this)); if (Config::instance()->check_for_updates ()) { UpdateChecker::instance()->run (); } @@ -917,8 +1047,7 @@ private: return true; } - /* An unhandled exception has occurred inside the main event loop */ - bool OnExceptionInMainLoop () + void report_exception () { try { throw; @@ -942,14 +1071,19 @@ private: } catch (...) { error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); } + } + /* An unhandled exception has occurred inside the main event loop */ + bool OnExceptionInMainLoop () + { + report_exception (); /* This will terminate the program */ return false; } void OnUnhandledException () { - error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); + report_exception (); } void idle () @@ -960,30 +1094,12 @@ private: void check () { try { - ServerFinder::instance()->rethrow (); + EncodeServerFinder::instance()->rethrow (); } catch (exception& e) { error_dialog (0, std_to_wx (e.what ())); } } - void update_checker_state_changed () - { - UpdateChecker* uc = UpdateChecker::instance (); - if (uc->state() == UpdateChecker::YES && (uc->stable() || uc->test())) { - UpdateDialog* dialog = new UpdateDialog (_frame, uc->stable (), uc->test ()); - dialog->ShowModal (); - dialog->Destroy (); - } else if (uc->state() == UpdateChecker::FAILED) { - if (!UpdateChecker::instance()->last_emit_was_first ()) { - error_dialog (_frame, _("The DCP-o-matic download server could not be contacted.")); - } - } else { - if (!UpdateChecker::instance()->last_emit_was_first ()) { - error_dialog (_frame, _("There are no new versions of DCP-o-matic available.")); - } - } - } - DOMFrame* _frame; shared_ptr _timer; string _film_to_load;