#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"
#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>
ID_content_scale_to_fit_height,
ID_jobs_make_dcp,
ID_jobs_make_kdms,
+ ID_jobs_make_self_dkdm,
ID_jobs_send_dcp_to_tms,
ID_jobs_show_dcp,
ID_tools_video_waveform,
, _history_items (0)
, _history_position (0)
, _history_separator (0)
+ , _update_news_requested (false)
{
#if defined(DCPOMATIC_WINDOWS)
if (Config::instance()->win32_console ()) {
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_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);
/* 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)
}
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),
+ _film->log()
+ ))
);
}
} catch (dcp::NotEncryptedError& e) {
d->Destroy ();
}
+ void jobs_make_self_dkdm ()
+ {
+ if (!_film) {
+ return;
+ }
+
+ SelfDKDMDialog* d = new SelfDKDMDialog (this, _film);
+ if (d->ShowModal () != wxID_OK) {
+ d->Destroy ();
+ return;
+ }
+
+ try {
+ dcp::EncryptedKDM kdm = _film->make_kdm (
+ Config::instance()->decryption_chain()->leaf(),
+ vector<dcp::Certificate> (),
+ d->cpl (),
+ dcp::LocalTime ("2012-01-01T01:00:00+00:00"),
+ dcp::LocalTime ("2112-01-01T01:00:00+00:00"),
+ dcp::MODIFIED_TRANSITIONAL_1
+ );
+
+ string const name = tidy_for_filename(_film->name()) + "_DKDM.kdm.xml";
+ kdm.as_xml (d->directory() / name);
+ } 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 ();
void tools_check_for_updates ()
{
UpdateChecker::instance()->run ();
+ _update_news_requested = true;
}
void help_about ()
{
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 ();
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 &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);
_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;
int _history_position;
wxMenuItem* _history_separator;
boost::signals2::scoped_connection _config_changed_connection;
+ bool _update_news_requested;
};
static const wxCmdLineEntryDesc command_line_description[] = {
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"));
TransformProcessType (&serial, kProcessTransformToForegroundApplication);
#endif
- cout << "set up path encoding.\n";
dcpomatic_setup_path_encoding ();
/* Enable i18n; this will create a Config object
_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 ();
}
return true;
}
- /* An unhandled exception has occurred inside the main event loop */
- bool OnExceptionInMainLoop ()
+ void report_exception ()
{
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);
}
+ }
+ /* 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 ()
}
}
- 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<wxTimer> _timer;
string _film_to_load;